index.jsx 109.7 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5
/**
 * 徐立
 * 2019年9月22日
 * 动态表格组件返回对应的组件
 */
6
import React, {Component} from 'react';
徐立's avatar
徐立 committed
7
import md5 from 'js-md5';
8
import FormModal from './FormModal';
徐立's avatar
徐立 committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import {
  message,
  Icon,
  Input,
  InputNumber,
  Button,
  Checkbox,
  DatePicker,
  Radio,
  Switch,
  Row,
  Col,
  Select,
  Form,
  Table,
tb53863844's avatar
tb53863844 committed
24
  Cascader,
徐立's avatar
徐立 committed
25
} from 'antd';
chscls@163.com's avatar
chscls@163.com committed
26
import UUID from 'react-native-uuid';
徐立's avatar
徐立 committed
27
import QRCode from 'qrcode.react';
28
import {EditorState, Editor} from 'draft-js';
徐立's avatar
徐立 committed
29
import MyBlockRenderer from '../App/MyBlockRender';
tb53863844's avatar
tb53863844 committed
30
import CronEditor from 'antd-cron-editor';
徐立's avatar
徐立 committed
31 32 33 34 35 36 37
import {
  List as MobileList,
  Flex,
  Card,
  Switch as MobileSwitch,
} from 'antd-mobile';
import ReactEcharts from 'echarts-for-react';
38
import ZdyTable from '../Table/index';
39
import {connect} from 'dva';
徐立's avatar
徐立 committed
40 41
import UploadCom from '../libs/UploadCom';
import TableSelect from '../libs/TableSelect';
42
import LocationCom from '../libs/LocationCom';
徐立's avatar
徐立 committed
43 44
import MobileDate from '../libs/MobileDate';
import ChildForm from '../libs/ChildForm';
tb53863844's avatar
tb53863844 committed
45
import Neo4jD3Com from '../libs/Neo4jD3Com';
chscls@163.com's avatar
chscls@163.com committed
46
import ImgUploadCom from '../libs/ImgUploadCom';
47
import VideoUploadCom from '../libs/VideoUploadCom';
徐立's avatar
徐立 committed
48 49 50 51
import moment from 'moment';
import router from 'umi/router';
import TableList from '../libs/TableList';
import styles from './style.less';
chscls@163.com's avatar
chscls@163.com committed
52
import config from '@/webPublic/one_stop_public/config';
53 54 55
import {isEmpty, isNaN, cloneDeep} from 'lodash';
import {queryApiActionPath} from '../utils/queryConfig';
import {extend} from 'umi-request';
徐立's avatar
徐立 committed
56
import Highlighter from 'react-highlight-words';
徐立's avatar
徐立 committed
57
import Signature from '../Signature';
58
import {changeToDraftState} from '../utils/myutils';
59
import baseX from 'base-x';
60 61 62
import {Base16Encode} from '../Base16/index';
import {getToken} from '../utils/token';
import {formulaList} from '../excelInitFuc/functionList';
徐立's avatar
徐立 committed
63
import FilePreview from '../filePreview';
chscls@163.com's avatar
chscls@163.com committed
64
import DraftEditorCom from '../App/DraftEditorCom';
徐立's avatar
徐立 committed
65
import MobileItem from './MobileItem';
66

67 68
const Bs64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const base64 = baseX(Bs64);
69

wanyielin's avatar
wanyielin committed
70 71
function getBase64(value) {
  return value ? base64.encode(new Buffer(value)) : null;
徐立's avatar
徐立 committed
72
}
73

徐立's avatar
徐立 committed
74 75 76 77 78 79
const codeMessage = {
  200: '服务器成功返回请求的数据。',
  201: '新建或修改数据成功。',
  202: '一个请求已经进入后台排队(异步任务)。',
  204: '删除数据成功。',
  400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
chscls@163.com's avatar
chscls@163.com committed
80
  401: '登录已过期,请重新登录',
徐立's avatar
徐立 committed
81 82 83 84 85 86 87 88 89 90
  403: '用户得到授权,但是访问是被禁止的。',
  404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
  406: '请求的格式不可得。',
  410: '请求的资源被永久删除,且不会再得到的。',
  422: '当创建一个对象时,发生一个验证错误。',
  500: '服务器发生错误,请检查服务器。',
  502: '网关错误。',
  503: '服务不可用,服务器暂时过载或维护。',
  504: '网关超时。',
};
91 92
const {TextArea} = Input;
const {Option} = Select;
93
const { RangePicker} = DatePicker;
徐立's avatar
徐立 committed
94
const errorHandler = error => {
95
  const {response} = error;
徐立's avatar
徐立 committed
96

徐立's avatar
徐立 committed
97 98
  if (response && response.status) {
    const errorText = codeMessage[response.status] || response.statusText;
徐立's avatar
徐立 committed
99

100
    message.error(`请求错误${errorText}`);
chscls@163.com's avatar
chscls@163.com committed
101 102 103 104 105
    if (response.status === 401) {
      return window.g_app._store.dispatch({
        type: 'login/loginout',
      });
    }
徐立's avatar
徐立 committed
106
  } else {
107
    message.error(`网络故障,请检查网络链接或联系管理员`);
徐立's avatar
徐立 committed
108 109 110
  }
};

111
@connect(({DataColumn, SqlManageEntity, formList, loading}) => ({
112 113 114 115
  DataColumn,
  SqlManageEntity,
  formList,
  loading: loading.models.DataColumn || loading.models.SqlManageEntity || loading.models.formList,
徐立's avatar
徐立 committed
116 117
}))
export default class tableCom extends Component {
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
  constructor(props) {
    super(props);
    this.state = {
      options: this.props.options || [],
      labels: [],
      url: null,
      selectDis: true, // 让下拉框在获取到数据前失效,防止网络卡顿用户点击时造成页面白屏
      isDate: true, // 避免重复调用
      sqlKeys: {},
      searchText: '',
      reqUrls: {},
      res: null,
      option: {},
      sqlModel: {},
      columns: [],
      sqlContent: null,
      modalProps: {},
      modalTitle: '',
      modalInit: {},
      modalCode: null,
      dataSource: {
        list: [],
        pagination: false,
      },
    };
    this.excludeKeys = ['defaultValues', ''];
  }
145 146
  closeModal = (fk, callback) => {
    const {dispatch} = this.props;
tb53863844's avatar
tb53863844 committed
147
    const x = this.props.DataColumn.isShowModal
148
    x[fk] = false
149 150
    dispatch({
      type: 'DataColumn/showModal',
151
      payload: {isShowModal: x},
152 153 154
      callback: callback,
    });
  };
徐立's avatar
徐立 committed
155
  showModal = (fk, title, data, modalProps) => {
156

157
    const {dispatch} = this.props;
tb53863844's avatar
tb53863844 committed
158
    const x = this.props.DataColumn.isShowModal
159
    x[fk] = true
160 161
    dispatch({
      type: 'DataColumn/showModal',
162
      payload: {isShowModal: x},
163
      callback: () => {
徐立's avatar
徐立 committed
164 165 166 167 168 169
        this.setState({
          modalInit: data,
          modalTitle: title,
          modalCode: fk,
          modalProps: modalProps,
        });
170 171 172
      },
    });
  };
徐立's avatar
徐立 committed
173

174
  equal = (obj1, obj2, json, sqlContent, depth) => {
徐立's avatar
徐立 committed
175
    if (obj1 == null && obj2 != null) {
176
      return false;
徐立's avatar
徐立 committed
177 178
    }
    if (obj1 != null && obj2 == null) {
179
      return false;
徐立's avatar
徐立 committed
180 181
    }
    if (obj1 == null && obj2 == null) {
182
      return true;
徐立's avatar
徐立 committed
183 184 185 186
    }

    if (obj1 instanceof Date) {
      if (obj1.valueOf() != obj2.valueOf()) {
187
        return false;
徐立's avatar
徐立 committed
188 189 190
      }
    } else if (obj1 instanceof moment) {
      if (obj1.valueOf() != obj2.valueOf()) {
191
        return false;
徐立's avatar
徐立 committed
192 193 194
      }
    } else if (typeof obj1 == 'function') {
      if (obj1.toString() != obj2.toString()) {
195
        return false;
徐立's avatar
徐立 committed
196 197 198
      }
    }

199
    const keys = new Set();
徐立's avatar
徐立 committed
200
    if (obj2 != null) {
201 202 203
      Object.keys(obj2).forEach(k => {
        if (k != '') keys.add(k);
      });
徐立's avatar
徐立 committed
204 205
    }
    if (obj1 != null) {
206 207 208
      Object.keys(obj1).forEach(k => {
        if (k != '') keys.add(k);
      });
徐立's avatar
徐立 committed
209 210
    }

211
    let res = true;
徐立's avatar
徐立 committed
212 213

    for (let key of keys) {
214 215
      if (key == '') {
        continue;
徐立's avatar
徐立 committed
216
      }
徐立's avatar
徐立 committed
217

徐立's avatar
徐立 committed
218
      if (this.excludeKeys.includes(key)) {
219
        continue;
徐立's avatar
徐立 committed
220 221 222
      }

      if (obj1[key] == null && obj2[key] != null) {
223
        res = false;
徐立's avatar
徐立 committed
224 225 226
        break;
      }
      if (obj1[key] != null && obj2[key] == null) {
227
        res = false;
徐立's avatar
徐立 committed
228 229
        break;
      }
徐立's avatar
徐立 committed
230

231 232 233 234 235 236 237 238 239
      if (
        depth == 1 &&
        ((this.props.json.sqlKey == null &&
          sqlContent == null &&
          json.formula == null &&
          json.funcs == null) ||
          (sqlContent != null && sqlContent.indexOf(key) == -1) ||
          (json.formula != null &&
            json.formula.indexOf(key) == -1 &&
徐立's avatar
徐立 committed
240 241
            json.funcs != null &&
            json.funcs.indexOf(key) == -1))
242 243 244 245
      ) {
        this.excludeKeys.push(key);

        continue;
徐立's avatar
徐立 committed
246 247 248
      }

      if (obj1[key] == null && obj2[key] == null) {
249
        continue;
徐立's avatar
徐立 committed
250 251
      }
      if (isNaN(obj1[key]) && isNaN(obj2[key])) {
252
        continue;
徐立's avatar
徐立 committed
253 254 255 256 257 258 259 260 261
      }
      /*  if (this.typeOf(obj1[key]) != this.typeOf(obj1[key])) {

         res = false
         break;
       } */

      if (obj1[key] instanceof Array) {
        if (obj1[key].length != obj2[key].length) {
262
          res = false;
徐立's avatar
徐立 committed
263 264
          break;
        } else {
265
          var xx = true;
徐立's avatar
徐立 committed
266 267

          for (var i = 0; i < obj1[key].length; i++) {
chscls@163.com's avatar
chscls@163.com committed
268
            if (!this.equal(obj1[key][i], obj2[key][i], json, sqlContent, depth + 1)) {
269
              xx = false;
徐立's avatar
徐立 committed
270 271 272 273 274
              break;
            }
          }

          if (!xx) {
275
            res = false;
徐立's avatar
徐立 committed
276 277 278 279
            break;
          }
        }
      } else if (obj1[key] instanceof Object) {
280
        const x = this.equal(obj1[key], obj2[key], json, sqlContent, depth + 1);
徐立's avatar
徐立 committed
281 282

        if (!x) {
283
          res = false;
徐立's avatar
徐立 committed
284 285
          break;
        }
286
      } else if (typeof obj1[key] == 'function') {
徐立's avatar
徐立 committed
287
        if (obj1[key].toString() != obj2[key].toString()) {
288
          res = false;
徐立's avatar
徐立 committed
289 290 291 292
          break;
        }
      } else {
        if (obj1[key] != obj2[key]) {
293
          res = false;
徐立's avatar
徐立 committed
294 295 296 297 298 299 300 301
          break;
        }
      }
    }

    return res;
  };

wanyielin's avatar
wanyielin committed
302
  getRender = (com, props) => {
chscls@163.com's avatar
chscls@163.com committed
303 304 305 306
    if (com == 'p') return <p {...props} />;
    if (com == 'ul') return <ul {...props} />;
    if (com == 'li') return <li {...props} />;
    if (com == 'video') return <video {...props} />;
307 308 309 310 311 312 313 314 315
    if (com == 'span') return <span {...props} />;
    if (com == 'a') return <a {...props} />;
    if (com == 'div') return <div {...props} />;
    if (com == 'canvas') return <canvas {...props} />;
    if (com == 'iframe') return <iframe {...props} />;
    if (com == 'img') {
      const src =
        props.src != null
          ? props.src.indexOf('http') > -1
316 317
          ? props.src
          : config.httpServer + props.src
318
          : null;
319
      const pp = {...props, src: src};
320
      return <img {...pp} />;
徐立's avatar
徐立 committed
321
    }
322
  };
徐立's avatar
徐立 committed
323

徐立's avatar
徐立 committed
324 325 326
  /**
   * 判断传入值是否为JSON文本
   */
327
  isJSON = str => {
徐立's avatar
徐立 committed
328 329 330 331 332 333 334 335 336 337 338 339 340
    if (typeof str == 'string') {
      try {
        var obj = JSON.parse(str);
        if (typeof obj == 'object' && obj) {
          return true;
        } else {
          return false;
        }
      } catch (e) {
        console.log('error:' + str + '!!!' + e);
        return false;
      }
    }
tb53863844's avatar
tb53863844 committed
341

342
  };
徐立's avatar
徐立 committed
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
  /**
   * 上传文件输入
   * 使用antd上传组件
   */
  file = {
    name: 'file',
    action: queryApiActionPath() + '/upload',
    onChange: info => {
      if (info.file.status !== 'uploading') {
        this.setState({
          img: info.file.response,
        });
      }
      if (info.file.status === 'done') {
        message.success(`图像添加成功,如需保存请点击保存`);
      } else if (info.file.status === 'error') {
        message.error(`图像添加失败.`);
      }
    },
  };
  obj = {};
  childObj = {};
  count = [];
  handleSearch = (selectedKeys, confirm) => {
    confirm();
368
    this.setState({searchText: selectedKeys[0]});
徐立's avatar
徐立 committed
369 370 371 372
  };

  handleReset = clearFilters => {
    clearFilters();
373 374 375 376 377 378 379
    this.resetSearchText();
  };

  resetSearchText = () => {
    this.setState({
      searchText: '',
    });
徐立's avatar
徐立 committed
380 381 382
  };

  getColumnSearchProps = (dataIndex, title) => ({
383 384
    filterDropdown: ({setSelectedKeys, selectedKeys, confirm, clearFilters}) => (
      <div style={{padding: 8}}>
徐立's avatar
徐立 committed
385 386 387 388 389 390 391 392
        <Input
          ref={node => {
            this.searchInput = node;
          }}
          placeholder={`请输入${title}`}
          value={selectedKeys[0]}
          onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
          onPressEnter={() => this.handleSearch(selectedKeys, confirm)}
393
          style={{width: 188, marginBottom: 8, display: 'block'}}
徐立's avatar
徐立 committed
394 395 396 397 398 399 400
        />
        <Button
          type="primary"
          onClick={() => this.handleSearch(selectedKeys, confirm)}
          icon="search"
          loading={this.props.loading}
          size="small"
401
          style={{width: 90, marginRight: 8}}
徐立's avatar
徐立 committed
402 403 404
        >
          搜索
        </Button>
405 406 407 408
        <Button
          loading={this.props.loading}
          onClick={() => this.handleReset(clearFilters)}
          size="small"
409
          style={{width: 90}}
410
        >
徐立's avatar
徐立 committed
411 412 413 414
          重置
        </Button>
      </div>
    ),
415
    filterIcon: filtered => <Icon type="search" style={{color: filtered ? '#1890ff' : 'red'}}/>,
416
    onFilter: (value, record) =>
徐立's avatar
徐立 committed
417
      record[dataIndex]
418
        ? record[dataIndex]
tb53863844's avatar
tb53863844 committed
419 420 421
          .toString()
          .toLowerCase()
          .includes(value.toLowerCase())
422
        : '',
徐立's avatar
徐立 committed
423 424 425 426 427 428 429
    onFilterDropdownVisibleChange: visible => {
      if (visible) {
        setTimeout(() => this.searchInput.select());
      }
    },
    render: text => {
      if (text != null) {
430 431
        return (
          <Highlighter
432
            highlightStyle={{backgroundColor: '#ffc069', padding: 0}}
433 434 435 436 437
            searchWords={[this.state.searchText]}
            autoEscape
            textToHighlight={text.toString()}
          />
        );
徐立's avatar
徐立 committed
438
      } else {
439
        return '';
徐立's avatar
徐立 committed
440 441 442
      }
    },
  });
443 444 445 446 447 448 449 450 451 452 453 454
  searchJson = (value, json, level, labs) => {

    for (var i = 0; i < json.length; i++) {
      if (json[i].value == value[level]) {
        labs.push(json[i].label)
        if (json[i].children) {

          this.searchJson(value, json[i].children, level + 1, labs);
        }
        break;
      }
    }
tb53863844's avatar
tb53863844 committed
455
  }
456

徐立's avatar
徐立 committed
457
  componentWillReceiveProps(props) {
458
    const {json, mapData, obj} = props;
459
    if (json == null || this.props.safe) {
徐立's avatar
徐立 committed
460 461
      return;
    }
462 463 464 465
    if (
      !(this.dataFilter.includes(json.comName) || json.comName == 'TableSelect') &&
      json.isFormulaOnce
    ) {
徐立's avatar
徐立 committed
466 467
      return;
    }
468 469 470 471 472 473 474
    if (
      !(
        this.dataFilter.includes(json.comName) ||
        json.comName == 'TableSelect' ||
        (json.formula != null && json.formula != '')
      )
    ) {
徐立's avatar
徐立 committed
475 476
      return;
    }
477 478 479 480
    const obj2 = props.form.getFieldsValue();
    const bb = this.equal(this.obj, obj2, json, this.state.sqlContent, 1);
    let bb2 = true;
    let childObj2 = {};
徐立's avatar
徐立 committed
481 482 483
    if (props.fatherCode) {
      if (obj2 != null && obj2[props.fatherCode]) {
        childObj2 = obj2[props.fatherCode][props.index];
徐立's avatar
徐立 committed
484

485
        bb2 = this.equal(this.childObj, childObj2, json, this.state.sqlContent, 1);
徐立's avatar
徐立 committed
486 487 488 489
      }
    }

    if (!(bb && bb2)) {
490
      const now = new Date().valueOf();
徐立's avatar
徐立 committed
491 492 493 494 495 496 497 498 499 500 501

      let j = 0;
      for (var i = 0; i < this.count.length; i++) {
        if (now - this.count[i] < 1000) {
          break;
        } else {
          j = i;
        }
      }

      if (j > 0) {
502
        this.count.splice(0, j);
徐立's avatar
徐立 committed
503 504
      }
      if (this.count.length > 10) {
505
        console.log(
tb53863844's avatar
tb53863844 committed
506
          `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
507
          1}列:存在循环风险,1秒内执行超过10次,现已停止执行,请检查,`,
508
        );
徐立's avatar
徐立 committed
509 510 511 512

        return;
      }
      if (!bb) {
513
        this.obj = cloneDeep(obj2);
徐立's avatar
徐立 committed
514 515
      }
      if (!bb2) {
516
        this.childObj = cloneDeep(childObj2);
徐立's avatar
徐立 committed
517
      }
518
      this.count.push(now);
徐立's avatar
徐立 committed
519
    } else {
520
      return;
徐立's avatar
徐立 committed
521 522
    }

wanyielin's avatar
wanyielin committed
523
    const bindObj = this.getColumn('c1');
chscls@163.com's avatar
chscls@163.com committed
524

525 526 527
    let dataColumn =
      this.props.fatherCode != null
        ? bindObj
528 529 530 531
        ? {
          ...bindObj,
          base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
        }
532
        : {base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`}
533 534
        : bindObj;
    if (this.props.fatherCode == null && dataColumn == null)
535
      dataColumn = {base52: this.props.uuid};
536

wanyielin's avatar
wanyielin committed
537 538
    if (!this.props.isEdit && this.props.fatherCode) {
      if (bindObj != null) {
539
        dataColumn.base52 = bindObj.base52;
wanyielin's avatar
wanyielin committed
540
      } else {
541
        dataColumn.base52 = this.props.uuid;
chscls@163.com's avatar
chscls@163.com committed
542
      }
wanyielin's avatar
wanyielin committed
543 544
    }

545 546 547 548 549 550 551
    if (this.dataFilter.includes(json.comName) || json.comName == 'TableSelect') {
      const obj2 = {
        ...obj,
        ...props.form.getFieldsValue(),
        ...props.defaultValues[this.props.formKey],
      };
      this.getData(json, dataColumn, obj2);
徐立's avatar
徐立 committed
552
    }
553 554
    if (json.formula != null && json.formula != '' && !json.isFormulaOnce) {
      this.getFunctionValue(json.formula, dataColumn, json);
徐立's avatar
徐立 committed
555 556
    }
  }
557

558
  dataFilter = ['Select', 'Radio', 'Checkbox', 'Cascader'];
徐立's avatar
徐立 committed
559 560

  getData = (json, dataColumn, obj, init) => {
561

562 563
    const allValues = JSON.stringify(obj);
    if (json.comName == 'TableSelect') {
564 565
      const {dispatch} = this.props;
      const {sqlKey, optionType} = json;
566
      if (optionType == 'sql') {
徐立's avatar
徐立 committed
567 568
        dispatch({
          type: 'SqlManageEntity/find',
569
          payload: {sqlKey: sqlKey},
徐立's avatar
徐立 committed
570
          callback: sqlModel => {
571
            this.setState({sqlModel});
徐立's avatar
徐立 committed
572 573 574
            if (sqlModel.dataObjId) {
              dispatch({
                type: 'formList/getHead',
575
                payload: {dataObjId: sqlModel.dataObjId},
徐立's avatar
徐立 committed
576 577
                callback: datas => {
                  if (datas) {
578
                    const columns = [];
徐立's avatar
徐立 committed
579 580 581 582 583
                    for (var i = 0; i < datas.length; i++) {
                      if (i <= json.colNum ? json.colNum : 10) {
                        let column = {};
                        column.title = datas[i].title;
                        column.dataIndex = datas[i].name;
584 585 586 587
                        if (
                          ['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'].includes(datas[i].type)
                        ) {
                          column.render = val => moment(val).format('YYYY-MM-DD HH:mm:ss');
徐立's avatar
徐立 committed
588 589 590
                        }
                        columns.push(column);
                      } else {
591
                        break;
徐立's avatar
徐立 committed
592 593
                      }
                    }
594
                    this.setState({columns});
徐立's avatar
徐立 committed
595
                  }
596 597
                },
              });
徐立's avatar
徐立 committed
598
            } else {
599
              const cols = sqlModel.cols;
徐立's avatar
徐立 committed
600
              if (cols != null || cols.length > 0) {
601 602
                const columns = [];
                const cll = JSON.parse(cols);
徐立's avatar
徐立 committed
603 604 605 606 607
                for (var k in cll) {
                  let column = {};
                  column.title = cll[k].title;
                  column.dataIndex = cll[k].name;
                  if (['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'].includes(cll[k].type)) {
608
                    var ff = 'YYYY-MM-DD HH:mm:ss';
徐立's avatar
徐立 committed
609
                    switch (cll[k].type) {
610 611 612 613 614 615 616 617 618
                      case 'DATE':
                        ff = 'YYYY-MM-DD';
                        break;
                      case 'YEAR':
                        ff = 'YYYY';
                        break;
                      case 'TIME':
                        ff = 'HH:mm:ss';
                        break;
徐立's avatar
徐立 committed
619 620
                    }

621
                    column.render = val => moment(parseInt(val)).format(ff);
徐立's avatar
徐立 committed
622 623 624 625 626
                  }
                  if (cll[k].isQuery) {
                    column = {
                      ...this.getColumnSearchProps(cll[k].name, cll[k].title),
                      ...column,
627
                    };
徐立's avatar
徐立 committed
628 629 630 631
                  }

                  columns.push(column);
                }
632
                this.setState({columns});
徐立's avatar
徐立 committed
633 634 635 636
              }

              dispatch({
                type: 'DataColumn/getSqlData',
637
                payload: {sqlKey, allValues},
徐立's avatar
徐立 committed
638 639 640
                callback: list => {
                  const x = {
                    list: list,
641 642
                    pagination: false,
                  };
643
                  this.setState({dataSource: x});
644 645
                },
              });
徐立's avatar
徐立 committed
646
            }
647 648 649
          },
        });
      } else if (optionType == 'reference' && dataColumn.referenceObjId) {
徐立's avatar
徐立 committed
650 651
        dispatch({
          type: 'formList/getHead',
652
          payload: {dataObjId: dataColumn.referenceObjId},
徐立's avatar
徐立 committed
653 654
          callback: datas => {
            if (datas) {
655
              const columns = [];
徐立's avatar
徐立 committed
656 657 658 659 660 661
              for (var i = 0; i < datas.length; i++) {
                if (i <= json.colNum ? json.colNum : 10) {
                  let column = {};
                  column.title = datas[i].title;
                  column.dataIndex = datas[i].name;
                  if (['DATE', 'DATETIME', 'TIME', 'TIMESTAMP', 'YEAR'].includes(datas[i].type)) {
662
                    column.render = val => moment(val).format('YYYY-MM-DD HH:mm:ss');
徐立's avatar
徐立 committed
663 664 665
                  }
                  columns.push(column);
                } else {
666
                  break;
徐立's avatar
徐立 committed
667 668
                }
              }
669
              this.setState({columns});
徐立's avatar
徐立 committed
670
            }
671 672
          },
        });
徐立's avatar
徐立 committed
673 674
      }
    }
675

徐立's avatar
徐立 committed
676
    if (json.optionType != null && this.dataFilter.includes(json.comName)) {
677

徐立's avatar
徐立 committed
678
      switch (json.optionType) {
679
        case 'reference':
徐立's avatar
徐立 committed
680
          if (dataColumn.referenceObjId != null) {
681
            this.fetchData(obj, dataColumn, init, json.filterSql, allValues);
徐立's avatar
徐立 committed
682 683
          }
          break;
684 685
        case 'enum':
          if (json.enums != null && json.enums != '') {
徐立's avatar
徐立 committed
686 687
            var enu;
            try {
688
              enu = JSON.parse(json.enums);
徐立's avatar
徐立 committed
689
            } catch (e) {
690 691
              message.error('枚举json格式存在问题');
              enu = [];
徐立's avatar
徐立 committed
692 693
            }

694
            this.changeEnum(obj, dataColumn, enu);
徐立's avatar
徐立 committed
695 696
          }
          break;
697 698 699 700 701 702 703 704 705 706 707
        case 'sql':
          if (json.sqlKey != null && json.sqlKey != '') {
            this.fetchData3(
              obj,
              dataColumn,
              init,
              json.sqlKey,
              json.labelName,
              json.valueName,
              allValues,
            );
徐立's avatar
徐立 committed
708 709
          }
          break;
710 711
        case 'func':
          if (json.funcs != null && json.funcs != '') {
712
            if (json.comName == "Cascader") {
tb53863844's avatar
tb53863844 committed
713 714 715 716
              try {
                this.getFunctionValue(json.funcs, {base52: this.props.uuid}, json, () => {
                  if (init != null && Object.keys(init).length > 0) {
                    let base52 = dataColumn.base52;
717
                    let vlu = this.props.form.getFieldsValue()[base52];
tb53863844's avatar
tb53863844 committed
718
                    const labs = [];
719 720
                    this.searchJson(vlu, this.state.options, 0, labs)

tb53863844's avatar
tb53863844 committed
721 722 723
                    this.setState({labels: labs});
                  } else if (!this.props.isEdit && Object.keys(obj).length > 0) {
                    let base52 = dataColumn.base52;
724

tb53863844's avatar
tb53863844 committed
725
                    const vlu = obj[base52];
726

tb53863844's avatar
tb53863844 committed
727
                    const labs = [];
728
                    this.searchJson(vlu, this.state.options, 0, labs)
tb53863844's avatar
tb53863844 committed
729 730 731 732 733 734
                    this.setState({labels: labs});
                  }
                });
              } catch (e) {
                message.error('公式选项配置存在问题');
              }
735
            } else {
tb53863844's avatar
tb53863844 committed
736 737 738 739
              try {
                this.getFunctionValue(json.funcs, {base52: this.props.uuid}, json, () => {
                  if (init != null && Object.keys(init).length > 0) {
                    let base52 = dataColumn.base52;
740
                    let vlu = this.props.form.getFieldsValue()[base52]
tb53863844's avatar
tb53863844 committed
741 742 743 744 745 746 747 748 749 750 751 752 753
                    const labs = [];
                    if (vlu instanceof Array) {
                      for (var i = 0; i < this.state.options.length; i++) {
                        if (vlu.includes(this.state.options[i].value)) {
                          labs.push(this.state.options[i].label);
                        }
                      }
                    } else {
                      for (var i = 0; i < this.state.options.length; i++) {
                        if (vlu == this.state.options[i].value) {
                          labs.push(this.state.options[i].label);
                          break;
                        }
chscls@163.com's avatar
chscls@163.com committed
754 755
                      }
                    }
756

tb53863844's avatar
tb53863844 committed
757 758 759
                    this.setState({labels: labs});
                  } else if (!this.props.isEdit && Object.keys(obj).length > 0) {
                    let base52 = dataColumn.base52;
760

tb53863844's avatar
tb53863844 committed
761
                    const vlu = obj[base52];
762

tb53863844's avatar
tb53863844 committed
763 764 765 766 767 768 769 770 771 772 773 774 775
                    const labs = [];
                    if (vlu instanceof Array) {
                      for (var i = 0; i < this.state.options.length; i++) {
                        if (vlu.includes(this.state.options[i].value)) {
                          labs.push(this.state.options[i].label);
                        }
                      }
                    } else {
                      for (var i = 0; i < this.state.options.length; i++) {
                        if (vlu == this.state.options[i].value) {
                          labs.push(this.state.options[i].label);
                          break;
                        }
chscls@163.com's avatar
chscls@163.com committed
776 777
                      }
                    }
778

tb53863844's avatar
tb53863844 committed
779
                    this.setState({labels: labs});
chscls@163.com's avatar
chscls@163.com committed
780
                  }
tb53863844's avatar
tb53863844 committed
781 782 783 784
                });
              } catch (e) {
                message.error('公式选项配置存在问题');
              }
wanyielin's avatar
wanyielin committed
785

786
            }
wanyielin's avatar
wanyielin committed
787 788


徐立's avatar
徐立 committed
789 790 791 792
          }
          break;
      }
    }
793
  };
徐立's avatar
徐立 committed
794 795 796

  setValues = (base52, json, values) => {
    try {
797
      this.props.form.setFieldsValue(values);
徐立's avatar
徐立 committed
798
    } catch (e) {
799
      console.log(
tb53863844's avatar
tb53863844 committed
800
        `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
801
        1}列:公式配置有误,回调函数内部错误,`,
802 803
        e,
      );
徐立's avatar
徐立 committed
804
    }
805 806 807 808
    if (!this.props.isEdit) {


      if (this.props.setRealTimeValues) {
tb53863844's avatar
tb53863844 committed
809 810
        this.props.setRealTimeValues(values)
      }
811

tb53863844's avatar
tb53863844 committed
812
    }
813

814
  };
wanyielin's avatar
wanyielin committed
815
  reqUtil = (base52, json, orgCallback, url, method, params, callback, options = {}) => {
徐立's avatar
徐立 committed
816
    //查缓存
chscls@163.com's avatar
chscls@163.com committed
817
    var isChange = true;
818 819
    if (url.indexOf('http') === -1) {
      url = config.httpServer + url;
徐立's avatar
徐立 committed
820
    }
821
    const {reqUrls} = this.state;
徐立's avatar
徐立 committed
822
    if (reqUrls[url] != null) {
823
      const ps = reqUrls[url].params;
徐立's avatar
徐立 committed
824 825

      if (Object.keys(params).length != Object.keys(ps).length) {
826
        isChange = true;
徐立's avatar
徐立 committed
827 828 829
      } else {
        for (var key in params) {
          if (params[key] == null && ps[key] != null) {
830
            isChange = true;
徐立's avatar
徐立 committed
831 832
            break;
          } else if (params[key] != null && ps[key] == null) {
833
            isChange = true;
徐立's avatar
徐立 committed
834 835 836
            break;
          } else {
            if (params[key] != ps[key]) {
837 838
              isChange = true;
              break;
徐立's avatar
徐立 committed
839 840 841 842 843
            }
          }
        }
      }
    } else {
844
      reqUrls[url] = {params: params};
845
      isChange = true;
徐立's avatar
徐立 committed
846
    }
847

徐立's avatar
徐立 committed
848 849
    if (!isChange) {
      if (callback) {
850
        const data = reqUrls[url].data;
徐立's avatar
徐立 committed
851

852 853
        if (json.optionType && json.optionType == 'func') {
          const res = callback(data);
徐立's avatar
徐立 committed
854

855
          if (res != null && !(typeof res === 'function')) {
856
            this.setState({options: res, selectDis: false}, () => {
857
              if (orgCallback) orgCallback();
chscls@163.com's avatar
chscls@163.com committed
858
            });
徐立's avatar
徐立 committed
859
          }
860
        } else if (json.comName == 'Button') {
徐立's avatar
徐立 committed
861
          try {
862
            callback(data);
徐立's avatar
徐立 committed
863
          } catch (e) {
864
            console.log(
tb53863844's avatar
tb53863844 committed
865
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
866
              1}列:公式配置有误,回调函数内部错误,`,
867 868
              e,
            );
869
            //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
870
          }
tb53863844's avatar
tb53863844 committed
871
        } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
徐立's avatar
徐立 committed
872
          try {
873
            const x = callback(data);
徐立's avatar
徐立 committed
874
            if (x != null) {
875
              this.setState({option: x});
徐立's avatar
徐立 committed
876 877
            }
          } catch (e) {
878
            console.log(
tb53863844's avatar
tb53863844 committed
879
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
880
              1}列:公式配置有误,回调函数内部错误,`,
881 882
              e,
            );
徐立's avatar
徐立 committed
883 884 885 886
          }
        } else {
          if (base52) {
            try {
887
              const x = callback(data);
888
              if (x == null || x != 'NaN') this.props.form.setFieldsValue({[base52]: x});
徐立's avatar
徐立 committed
889
            } catch (e) {
890
              console.log(
tb53863844's avatar
tb53863844 committed
891
                `页面${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
892
                1}列:公式配置有误,回调函数内部错误,`,
893 894
                e,
              );
徐立's avatar
徐立 committed
895 896 897 898
            }
          }
        }
      }
899
      return 'norefeshxxxxxxxxxxxxxxxxxxxx';
徐立's avatar
徐立 committed
900
    }
tb53863844's avatar
tb53863844 committed
901 902 903 904

    for (let i in params) {
      if (params[i] == null) {
        delete params[i];
徐立's avatar
徐立 committed
905
      }
tb53863844's avatar
tb53863844 committed
906
    }
907

tb53863844's avatar
tb53863844 committed
908 909 910
    if (getToken() != null) {
      params.token = getToken();
    }
徐立's avatar
徐立 committed
911

tb53863844's avatar
tb53863844 committed
912 913 914 915 916 917 918 919 920 921 922 923
    const requestParams = params;
    const umiRequest = extend({
      errorHandler, // 默认错误处理
      credentials: 'omit', // 默认请求是否带上cookie
      mode: 'cors',
      ...options,
    });
    umiRequest(url, {
      data: requestParams,
      method: method,
      requestType: 'form',
    }).then(data => {
924
      const {reqUrls} = this.state;
tb53863844's avatar
tb53863844 committed
925
      reqUrls[url].data = data;
926
      this.setState({res: data, reqUrls}, () => {
tb53863844's avatar
tb53863844 committed
927 928 929 930 931
        if (callback) {
          if (json.optionType && json.optionType == 'func') {
            const res = callback(data);

            if (res != null && !(typeof res === 'function')) {
932
              this.setState({options: res, selectDis: false}, () => {
tb53863844's avatar
tb53863844 committed
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
                if (orgCallback) orgCallback();
              });
            }
          } else if (json.comName == 'Button') {
            try {
              callback(data);
            } catch (e) {
              console.log(
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
            try {
              const x = callback(data);
              if (x != null) {
950
                this.setState({option: x});
徐立's avatar
徐立 committed
951
              }
tb53863844's avatar
tb53863844 committed
952 953 954 955 956 957 958 959 960
            } catch (e) {
              console.log(
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          } else {
            if (base52) {
徐立's avatar
徐立 committed
961
              try {
962
                const x = callback(data);
963
                if (x == null || x != 'NaN') this.props.form.setFieldsValue({[base52]: x});
徐立's avatar
徐立 committed
964
              } catch (e) {
965
                console.log(
tb53863844's avatar
tb53863844 committed
966
                  `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
967
                  1}列:公式配置有误,回调函数内部错误,`,
968 969
                  e,
                );
徐立's avatar
徐立 committed
970 971 972
              }
            }
          }
tb53863844's avatar
tb53863844 committed
973
        }
974 975
      });
    });
徐立's avatar
徐立 committed
976

tb53863844's avatar
tb53863844 committed
977

978 979
    return 'norefeshxxxxxxxxxxxxxxxxxxxx';
  };
wanyielin's avatar
wanyielin committed
980
  sqlUtil = (base52, json, orgCallback, sqlKey, params, callback, options = {}) => {
徐立's avatar
徐立 committed
981 982
    //查缓存
    var isChange = false;
983
    const {sqlKeys} = this.state;
徐立's avatar
徐立 committed
984 985

    if (sqlKeys[sqlKey] != null) {
986
      const ps = sqlKeys[sqlKey].params;
徐立's avatar
徐立 committed
987 988

      if (params.length != ps.length) {
989
        isChange = true;
徐立's avatar
徐立 committed
990 991 992
      } else {
        for (var i = 0; i < params.length; i++) {
          if (params[i] != ps[i]) {
993
            isChange = true;
徐立's avatar
徐立 committed
994 995 996 997
            break;
          }
        }
      }
tb53863844's avatar
tb53863844 committed
998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
      if (!isChange) {
        const os = sqlKeys[sqlKey].options;
        if (Object.keys(options).length != Object.keys(os).length) {
          isChange = true;
        } else {
          for (var k in options) {
            if (os[k] == null || options[k] != os[k]) {
              isChange = true;
              break;
            }
          }
        }
      }


徐立's avatar
徐立 committed
1013
    } else {
1014
      sqlKeys[sqlKey] = {params: params, options: options};
1015
      isChange = true;
徐立's avatar
徐立 committed
1016 1017 1018
    }
    if (!isChange) {
      if (callback) {
1019 1020 1021 1022
        const data = sqlKeys[sqlKey].data;
        if (json.optionType && json.optionType == 'func') {
          const res = callback(data);
          if (res != null && !(typeof res === 'function')) {
1023
            this.setState({options: res, selectDis: false}, () => {
1024
              if (orgCallback) orgCallback();
chscls@163.com's avatar
chscls@163.com committed
1025
            });
徐立's avatar
徐立 committed
1026
          }
1027
        } else if (json.comName == 'Button') {
徐立's avatar
徐立 committed
1028
          try {
1029
            callback(data);
徐立's avatar
徐立 committed
1030
          } catch (e) {
1031
            console.log(
tb53863844's avatar
tb53863844 committed
1032
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1033
              1}列:公式配置有误,回调函数内部错误,`,
1034 1035
              e,
            );
徐立's avatar
徐立 committed
1036
          }
tb53863844's avatar
tb53863844 committed
1037
        } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
徐立's avatar
徐立 committed
1038
          try {
1039
            const x = callback(data);
徐立's avatar
徐立 committed
1040
            if (x != null) {
1041
              this.setState({option: x});
徐立's avatar
徐立 committed
1042 1043
            }
          } catch (e) {
1044
            console.log(
tb53863844's avatar
tb53863844 committed
1045
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1046
              1}列:公式配置有误,回调函数内部错误,`,
1047 1048
              e,
            );
徐立's avatar
徐立 committed
1049 1050 1051 1052
          }
        } else {
          if (base52) {
            try {
1053
              const x = callback(data);
1054
              if (x == null || x != 'NaN') this.props.form.setFieldsValue({[base52]: x});
徐立's avatar
徐立 committed
1055
            } catch (e) {
1056
              console.log(
tb53863844's avatar
tb53863844 committed
1057
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1058
                1}列:公式配置有误,回调函数内部错误,`,
1059 1060
                e,
              );
徐立's avatar
徐立 committed
1061 1062 1063 1064
            }
          }
        }
      }
1065
      return 'norefeshxxxxxxxxxxxxxxxxxxxx';
徐立's avatar
徐立 committed
1066 1067
    }

tb53863844's avatar
tb53863844 committed
1068

1069
    const url = queryApiActionPath() + '/DataColumnApi/getSqlData';
1070
    this.setState({sqlKeys}, () => {
tb53863844's avatar
tb53863844 committed
1071 1072
      const umiRequest = extend({
        errorHandler, // 默认错误处理
tb53863844's avatar
tb53863844 committed
1073 1074
        credentials: options.credentials || 'omit', // 默认请求是否带上cookie
        mode: options.mode || 'cors'
tb53863844's avatar
tb53863844 committed
1075 1076 1077 1078 1079 1080 1081
      });
      const allValues = JSON.stringify({
        ...this.props.obj,
        ...this.props.form.getFieldsValue(),
        ...this.props.defaultValues[this.props.formKey],
        ...options
      });
1082
      const pp = {sqlKey: Base16Encode(sqlKey), params, allValues: Base16Encode(allValues)};
wanyielin's avatar
wanyielin committed
1083
      if (getToken() != null) {
1084
        pp.token = getToken();
徐立's avatar
徐立 committed
1085
      }
tb53863844's avatar
tb53863844 committed
1086

徐立's avatar
徐立 committed
1087
      umiRequest(url, {
wanyielin's avatar
wanyielin committed
1088
        data: pp,
徐立's avatar
徐立 committed
1089
        method: 'POST',
1090
        requestType: 'form',
徐立's avatar
徐立 committed
1091
      }).then(data => {
1092
        const {sqlKeys} = this.state;
1093
        sqlKeys[sqlKey].data = data;
1094
        this.setState({sqlKeys});
徐立's avatar
徐立 committed
1095
        if (data == null) {
1096
          return;
徐立's avatar
徐立 committed
1097 1098 1099
        }

        if (callback) {
1100 1101
          if (json.optionType && json.optionType == 'func') {
            const res = callback(data);
徐立's avatar
徐立 committed
1102

1103
            if (res != null && !(typeof res === 'function')) {
1104
              this.setState({options: res, selectDis: false}, () => {
1105
                if (orgCallback) orgCallback();
chscls@163.com's avatar
chscls@163.com committed
1106
              });
徐立's avatar
徐立 committed
1107
            }
1108
          } else if (json.comName == 'Button') {
徐立's avatar
徐立 committed
1109
            try {
1110
              callback(data);
徐立's avatar
徐立 committed
1111
            } catch (e) {
1112
              console.log(
tb53863844's avatar
tb53863844 committed
1113
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1114
                1}列:公式配置有误,回调函数内部错误,`,
1115 1116
                e,
              );
徐立's avatar
徐立 committed
1117
            }
tb53863844's avatar
tb53863844 committed
1118
          } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == "Graph") {
徐立's avatar
徐立 committed
1119
            try {
1120
              const x = callback(data);
徐立's avatar
徐立 committed
1121
              if (x != null) {
1122
                this.setState({option: x});
徐立's avatar
徐立 committed
1123 1124
              }
            } catch (e) {
1125
              console.log(
tb53863844's avatar
tb53863844 committed
1126
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1127
                1}列:公式配置有误,回调函数内部错误,`,
1128 1129
                e,
              );
徐立's avatar
徐立 committed
1130 1131 1132 1133
            }
          } else {
            if (base52) {
              try {
1134
                const x = callback(data);
1135
                if (x == null || x != 'NaN') this.props.form.setFieldsValue({[base52]: x});
徐立's avatar
徐立 committed
1136
              } catch (e) {
1137
                console.log(
tb53863844's avatar
tb53863844 committed
1138
                  `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1139
                  1}列:公式配置有误,回调函数内部错误,`,
1140 1141
                  e,
                );
徐立's avatar
徐立 committed
1142 1143 1144 1145
              }
            }
          }
        }
1146 1147
      });
    });
徐立's avatar
徐立 committed
1148

1149 1150
    return 'norefeshxxxxxxxxxxxxxxxxxxxx';
  };
徐立's avatar
徐立 committed
1151

wanyielin's avatar
wanyielin committed
1152
  getFunctionValue = (fun, column, json, callback) => {
tb53863844's avatar
tb53863844 committed
1153
    if (this.props.safe) return
1154 1155
    const base52 = column.base52;

徐立's avatar
徐立 committed
1156 1157 1158 1159
    /**
     * 中台函数库注入
     * 动态生成表单配置函数所使用
     */
1160
    let functionObj = {};
徐立's avatar
徐立 committed
1161
    formulaList.map(item => {
1162 1163 1164 1165
      item.children.map(arr => {
        functionObj[arr.callKey] = arr.function;
      });
    });
徐立's avatar
徐立 committed
1166
    try {
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
      var fun1 = new Function(
        'obj',
        'init',
        'modalInit',
        'defaultValues',
        'env',
        'index',
        'fatherCode',
        'utils',
        '$',
        'routerState',
        'shareData',
        'sceneRouter',
        fun,
      );
      let obj;
1183

1184 1185 1186 1187 1188 1189
      if (!this.props.isEdit && this.props.fatherCode) {
        obj = {
          ...this.props.fatherObj,
          ...this.props.form.getFieldsValue(),
          ...this.props.defaultValues[this.props.formKey],
        };
wanyielin's avatar
wanyielin committed
1190
      } else {
1191
        obj = {
tb53863844's avatar
tb53863844 committed
1192
          ...(this.props.fatherObj ? this.props.fatherObj : {}),
1193 1194 1195 1196
          ...this.props.obj,
          ...this.props.form.getFieldsValue(),
          ...this.props.defaultValues[this.props.formKey],
        };
chscls@163.com's avatar
chscls@163.com committed
1197
      }
1198 1199 1200 1201 1202
      const value = fun1(
        obj,
        this.props.init,
        this.props.modalInit,
        this.props.defaultValues,
徐立's avatar
徐立 committed
1203 1204 1205 1206 1207
        {
          clientType: this.props.get,
          formCode: this.props.formCode,
          formId: this.props.formId,
          isEdit: this.props.isEdit,
1208 1209
          taskAssignee: this.props.taskAssignee,
          userId: this.props.userId,
1210
          taskId: this.props.taskId,
徐立's avatar
徐立 committed
1211
        },
1212 1213
        this.props.index,
        this.props.fatherCode,
wanyielin's avatar
wanyielin committed
1214
        {
1215
          moment,
wanyielin's avatar
wanyielin committed
1216
          sql: this.sqlUtil.bind(this, base52, json, callback),
1217
          message,
tb53863844's avatar
tb53863844 committed
1218
          importExcel: this.props.importExcel,
1219
          router: router,
徐立's avatar
徐立 committed
1220
          uuid: UUID,
徐立's avatar
徐立 committed
1221
          setValues: this.setValues.bind(this, base52, json),
wanyielin's avatar
wanyielin committed
1222
          req: this.reqUtil.bind(this, base52, json, callback),
1223
          md5,
1224 1225 1226 1227
          showModal: this.showModal,
          closeModal: this.closeModal,
          render: this.getRender,
          base64: getBase64,
1228
          form: this.props.form,
徐立's avatar
徐立 committed
1229
        },
徐立's avatar
徐立 committed
1230
        functionObj,
1231 1232
        this.props.routerState,
        this.props.messageData,
1233 1234 1235 1236
        this.props.concealModel,
      );
      if (base52) {
        if (value != null && value == 'norefeshxxxxxxxxxxxxxxxxxxxx') {
徐立's avatar
徐立 committed
1237 1238 1239 1240 1241
        } else {
          /**
           * 会出现重复调用2次,然后NAN造成无限循环
           */
          if (isNaN(value)) {
1242
            return;
徐立's avatar
徐立 committed
1243
          }
1244 1245 1246 1247
          if (json.comName == 'Button') {
            return value;
          } else if (json.optionType && json.optionType == 'func') {
            if (value != null && !(typeof value === 'function')) {
1248
              this.setState({options: value, selectDis: false}, () => {
1249
                if (callback) callback();
chscls@163.com's avatar
chscls@163.com committed
1250
              });
chscls@163.com's avatar
chscls@163.com committed
1251
            }
tb53863844's avatar
tb53863844 committed
1252
          } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
1253
            this.setState({option: value});
徐立's avatar
徐立 committed
1254 1255
          } else {
            try {
1256
              this.props.form.setFieldsValue({[base52]: value});
1257 1258
            } catch {
              console.log(
tb53863844's avatar
tb53863844 committed
1259
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1260
                1}列:公式配置有误,函数内部错误,`,
1261 1262
                e,
              );
徐立's avatar
徐立 committed
1263 1264 1265 1266 1267
            }
          }
        }
      }
    } catch (e) {
1268
      console.log(
tb53863844's avatar
tb53863844 committed
1269
        `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1270
        1}列:公式配置有误,暂存失败,`,
1271 1272
        e,
      );
徐立's avatar
徐立 committed
1273
    }
1274
  };
1275

徐立's avatar
徐立 committed
1276
  componentDidMount() {
1277
    const {json, mapData, obj, init} = this.props;
徐立's avatar
徐立 committed
1278
    if (json == null) {
1279
      return;
徐立's avatar
徐立 committed
1280
    }
1281
    if (json.sqlKey != null && json.sqlKey != '') {
1282
      const {dispatch} = this.props;
徐立's avatar
徐立 committed
1283 1284
      dispatch({
        type: 'SqlManageEntity/find',
1285
        payload: {sqlKey: json.sqlKey},
徐立's avatar
徐立 committed
1286
        callback: res => {
1287
          this.setState({sqlContent: res.sql});
1288 1289 1290
        },
      });
    }
徐立's avatar
徐立 committed
1291

wanyielin's avatar
wanyielin committed
1292 1293
    const bindObj = this.getColumn('c1');

1294 1295 1296
    let dataColumn =
      this.props.fatherCode != null
        ? bindObj
1297 1298 1299 1300
        ? {
          ...bindObj,
          base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
        }
1301
        : {base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`}
1302 1303
        : bindObj;
    if (this.props.fatherCode == null && dataColumn == null)
1304
      dataColumn = {base52: this.props.uuid};
徐立's avatar
徐立 committed
1305

wanyielin's avatar
wanyielin committed
1306 1307
    if (!this.props.isEdit && this.props.fatherCode) {
      if (bindObj != null) {
1308
        dataColumn.base52 = bindObj.base52;
wanyielin's avatar
wanyielin committed
1309
      } else {
1310
        dataColumn.base52 = this.props.uuid;
徐立's avatar
徐立 committed
1311 1312 1313
      }
    }

1314 1315 1316 1317
    this.getData(json, dataColumn, obj);
    if (json.formula != null && json.formula != '' && !this.props.safe) {
      this.getFunctionValue(json.formula, dataColumn, json);
    }
徐立's avatar
徐立 committed
1318
  }
1319

徐立's avatar
徐立 committed
1320
  fetchData3 = (obj, dataColumn, init, sqlKey, labelName, valueName, allValues) => {
1321
    const {dispatch} = this.props;
徐立's avatar
徐立 committed
1322 1323 1324 1325

    if (init != null && Object.keys(init).length > 0) {
      dispatch({
        type: 'DataColumn/getSqlOptions',
1326
        payload: {sqlKey, allValues},
徐立's avatar
徐立 committed
1327 1328
        callback: options => {
          const optionsx = [];
1329
          let base52 = dataColumn.base52;
1330
          let vl = this.props.form.getFieldsValue()[base52];
wanyielin's avatar
wanyielin committed
1331
          let isExist = false;
徐立's avatar
徐立 committed
1332
          for (var i = 0; i < options.length; i++) {
wanyielin's avatar
wanyielin committed
1333 1334
            if (vl == options[i][valueName] && !isExist) {
              isExist = true;
徐立's avatar
徐立 committed
1335 1336 1337 1338 1339 1340
            }
            optionsx.push({
              label: options[i][labelName],
              value: options[i][valueName],
            });
          }
徐立's avatar
徐立 committed
1341

wanyielin's avatar
wanyielin committed
1342
          if (!isExist && vl != null && options.length > 0) {
1343
            this.props.form.setFieldsValue({[base52]: null});
徐立's avatar
徐立 committed
1344
          }
1345
          this.setState({options: optionsx, selectDis: false});
徐立's avatar
徐立 committed
1346 1347 1348
        },
      });
    } else if (!this.props.isEdit && Object.keys(obj).length > 0) {
1349
      let base52 = dataColumn.base52;
徐立's avatar
徐立 committed
1350
      if (this.props.fatherCode) {
1351 1352
        const x = base52.split('.');
        base52 = x[x.length - 1];
徐立's avatar
徐立 committed
1353
      }
徐立's avatar
徐立 committed
1354 1355 1356
      if (obj[base52]) {
        dispatch({
          type: 'DataColumn/getSqlLabels',
1357
          payload: {sqlKey, values: obj[base52], labelName, valueName, allValues},
徐立's avatar
徐立 committed
1358
          callback: labels => {
1359
            this.setState({labels, selectDis: false});
徐立's avatar
徐立 committed
1360 1361
          },
        });
chscls@163.com's avatar
chscls@163.com committed
1362
      }
徐立's avatar
徐立 committed
1363 1364 1365
    } else {
      dispatch({
        type: 'DataColumn/getSqlOptions',
1366
        payload: {sqlKey, allValues},
徐立's avatar
徐立 committed
1367
        callback: options => {
1368
          let base52 = dataColumn.base52;
1369
          let vl = this.props.form.getFieldsValue()[base52];
徐立's avatar
徐立 committed
1370
          const optionsx = [];
wanyielin's avatar
wanyielin committed
1371
          let isExist = false;
徐立's avatar
徐立 committed
1372
          for (var i = 0; i < options.length; i++) {
wanyielin's avatar
wanyielin committed
1373 1374
            if (vl == options[i][valueName] && !isExist) {
              isExist = true;
徐立's avatar
徐立 committed
1375 1376 1377 1378 1379 1380
            }
            optionsx.push({
              label: options[i][labelName],
              value: options[i][valueName],
            });
          }
徐立's avatar
徐立 committed
1381

wanyielin's avatar
wanyielin committed
1382
          if (!isExist && vl != null && options.length > 0) {
徐立's avatar
徐立 committed
1383
            //console.log("isExist",optionsx,vl,isExist)
1384
            this.props.form.setFieldsValue({[base52]: null});
wanyielin's avatar
wanyielin committed
1385
          }
徐立's avatar
徐立 committed
1386

1387
          this.setState({options: optionsx, selectDis: false});
徐立's avatar
徐立 committed
1388 1389 1390
        },
      });
    }
1391
  };
徐立's avatar
徐立 committed
1392 1393 1394
  changeEnum = (obj, dataColumn, options) => {
    if (!this.props.isEdit && Object.keys(obj).length > 0) {
      const values = obj[dataColumn.base52];
1395
      const labels = [];
徐立's avatar
徐立 committed
1396 1397 1398 1399
      if (values != null) {
        if (values instanceof Array) {
          for (var i = 0; i < options.length; i++) {
            if (values.includes(options[i].value)) {
1400
              labels.push(options[i].label);
徐立's avatar
徐立 committed
1401 1402 1403 1404 1405 1406
              // break;
            }
          }
        } else {
          for (var i = 0; i < options.length; i++) {
            if (values == options[i].value) {
1407
              labels.push(options[i].label);
徐立's avatar
徐立 committed
1408 1409 1410 1411 1412 1413
              // break;
            }
          }
        }
      }

1414
      this.setState({labels: labels, selectDis: false});
徐立's avatar
徐立 committed
1415
    } else {
1416
      this.setState({options: options, selectDis: false});
徐立's avatar
徐立 committed
1417
    }
1418
  };
徐立's avatar
徐立 committed
1419
  fetchData = (obj, dataColumn, init, filterSql, allValues) => {
1420
    const {dispatch} = this.props;
徐立's avatar
徐立 committed
1421 1422 1423 1424

    if (init != null && Object.keys(init).length > 0) {
      dispatch({
        type: 'DataColumn/getOptions',
1425
        payload: {id: dataColumn.id, filterSql, allValues},
徐立's avatar
徐立 committed
1426 1427 1428 1429 1430 1431 1432 1433
        callback: options => {
          const optionsx = [];
          for (var i = 0; i < options.length; i++) {
            optionsx.push({
              label: options[i][dataColumn.referenceNameName],
              value: options[i][dataColumn.referenceCodeName],
            });
          }
1434
          this.setState({options: optionsx, selectDis: false});
徐立's avatar
徐立 committed
1435 1436 1437 1438 1439 1440
        },
      });
    } else if (!this.props.isEdit && Object.keys(obj).length > 0) {
      if (obj[dataColumn.base52]) {
        dispatch({
          type: 'DataColumn/getLabels',
1441
          payload: {id: dataColumn.id, values: obj[dataColumn.base52], filterSql, allValues},
徐立's avatar
徐立 committed
1442
          callback: labels => {
1443
            this.setState({labels, selectDis: false});
徐立's avatar
徐立 committed
1444 1445 1446 1447 1448 1449
          },
        });
      }
    } else {
      dispatch({
        type: 'DataColumn/getOptions',
1450
        payload: {id: dataColumn.id, filterSql, allValues},
徐立's avatar
徐立 committed
1451 1452 1453 1454 1455 1456 1457 1458
        callback: options => {
          const optionsx = [];
          for (var i = 0; i < options.length; i++) {
            optionsx.push({
              label: options[i][dataColumn.referenceNameName],
              value: options[i][dataColumn.referenceCodeName],
            });
          }
1459
          this.setState({options: optionsx, selectDis: false});
徐立's avatar
徐立 committed
1460 1461 1462
        },
      });
    }
1463
  };
徐立's avatar
徐立 committed
1464
  getColumn = key => {
1465
    let {mapData, json} = this.props;
徐立's avatar
徐立 committed
1466 1467 1468 1469 1470 1471 1472 1473 1474

    const columnIds = json.columnIds;

    if (
      columnIds == null ||
      Object.keys(columnIds).length == 0 ||
      columnIds[key] == null ||
      mapData == null
    ) {
chscls@163.com's avatar
chscls@163.com committed
1475
      return null;
徐立's avatar
徐立 committed
1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487
    }

    const dataColumn = mapData[columnIds[key][columnIds[key].length - 1]];

    return dataColumn;
  };

  render() {
    /**
     * json为申请表单
     * obj为查看详情用户输入值
     */
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498
    let {
      json,
      obj,
      mapData,
      init,
      sqlData,
      defaultValues,
      get,
      formKey,
      isEdit,
      datas,
chscls@163.com's avatar
chscls@163.com committed
1499
      taskAssignee,
tb53863844's avatar
tb53863844 committed
1500
      userId, i,
徐立's avatar
徐立 committed
1501
      j,
徐立's avatar
徐立 committed
1502
      isPreview,
chlolch's avatar
chlolch committed
1503 1504
      currentFormTitle,
      getCellValue
1505
    } = this.props;
1506 1507
    const {options, labels, selectDis, modalCode, modalTitle, modalInit, modalProps} = this.state;
    const {getFieldDecorator, getFieldError, getFieldProps} = this.props.form;
1508
    const disabled = json != null ? json.disabled : false;
1509
    const permRank = json != null ? (json.permRank != null ? json.permRank : 0) : 0;
徐立's avatar
徐立 committed
1510 1511 1512
    if (json == null) {
      return <></>;
    }
chscls@163.com's avatar
chscls@163.com committed
1513
    //私有
1514
    if (!isEdit && permRank == 1 && taskAssignee != userId) {
chscls@163.com's avatar
chscls@163.com committed
1515 1516
      return <></>;
    }
徐立's avatar
徐立 committed
1517
    if (json.comName == 'QRCode') {
1518 1519 1520 1521 1522 1523
      if (
        this.state.option == null ||
        this.state.option.value == null ||
        this.state.option.value == null
      )
        return <></>;
1524
      return <QRCode {...this.state.option} key={this.props.uuid}/>;
徐立's avatar
徐立 committed
1525 1526
    }
    if (json.comName == 'Echart') {
1527 1528
      return (
        <ReactEcharts
1529
          style={{height: json.height || 500}}
1530 1531 1532 1533 1534 1535 1536 1537
          key={this.props.uuid}
          option={this.state.option || {}}
          notMerge={true}
          lazyUpdate={true}
          theme={'theme_name'}
          onEvents={{}}
        />
      );
徐立's avatar
徐立 committed
1538
    }
tb53863844's avatar
tb53863844 committed
1539 1540 1541 1542
    if (json.comName == 'Graph') {
      return (
        <Neo4jD3Com
          key={this.props.uuid}
tb53863844's avatar
tb53863844 committed
1543
          json={json}
1544
          option={this.state.option || []}/>
tb53863844's avatar
tb53863844 committed
1545 1546 1547
      );
    }

1548

徐立's avatar
徐立 committed
1549
    if (json.comName == 'PartForm') {
1550
      const fk = this.props.form.getFieldsValue()[this.props.uuid] || json.childFormKey;
徐立's avatar
徐立 committed
1551
      if (fk == null) {
1552
        return <></>;
徐立's avatar
徐立 committed
1553 1554 1555 1556
      }
      if (formKey == fk) {
        return <>片段表单key不能和自身相同</>;
      }
1557 1558 1559 1560
      return (
        <>
          {this.props.form.getFieldDecorator(this.props.uuid, {
            initialValue: fk,
1561
          })(<Input type="hidden"/>)}{' '}
1562
          <ZdyTable
1563
            taskId={this.props.taskId}
1564
            setRealTimeValues={this.props.setRealTimeValues}
tb53863844's avatar
tb53863844 committed
1565
            hfInstance={this.props.hfInstance}
tb53863844's avatar
tb53863844 committed
1566
            currentFormTitle={this.props.getCurrentFormTitle ? this.props.getCurrentFormTitle(fk) : null}
tb53863844's avatar
tb53863844 committed
1567
            getCellValue={getCellValue}
1568
            taskAssignee={taskAssignee}
1569
            isWebPrint={this.props.isWebPrint || false}
1570
            userId={userId}
1571
            key={fk}
chlolch's avatar
chlolch committed
1572
            isPreview={isPreview}
chscls@163.com's avatar
chscls@163.com committed
1573
            modalInit={modalInit}
1574
            datas={datas}
tb53863844's avatar
tb53863844 committed
1575
            trees={this.props.trees}
1576 1577 1578 1579 1580 1581
            get={get}
            isChild={true}
            currentFormKey={fk}
            isEdit={isEdit}
            obj={obj}
            init={init}
chscls@163.com's avatar
chscls@163.com committed
1582 1583
            formCode={this.props.formCode}
            formId={this.props.formId}
1584 1585 1586 1587 1588 1589 1590 1591
            form={this.props.form}
            mapData={mapData}
            sqlData={sqlData}
            {...datas[fk]}
            defaultValues={defaultValues}
          />
        </>
      );
徐立's avatar
徐立 committed
1592
    }
tb53863844's avatar
tb53863844 committed
1593 1594
    if (json.comName == 'Excel') {
      const value = getCellValue(i, j, currentFormTitle)
1595
      const xx = <div style={{textAlign: "center", height: value == null ? 20 : null}}>{value}</div>
chlolch's avatar
chlolch committed
1596 1597 1598
      return xx;
    }
    if (json.comName == 'Label') {
1599
      let uid;
徐立's avatar
徐立 committed
1600
      if (this.props.fatherCode != null) {
1601
        uid = `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`;
徐立's avatar
徐立 committed
1602
      } else {
1603
        uid = this.props.uuid;
徐立's avatar
徐立 committed
1604 1605
      }
      if (!isEdit) {
1606
        return obj[this.props.uuid] || json.initialValue || '';
徐立's avatar
徐立 committed
1607 1608
      } else {
        if (this.props.fatherCode != null) {
1609 1610 1611 1612
          return (
            <>
              {this.props.form.getFieldDecorator(uid, {
                initialValue: obj[this.props.uuid] || json.initialValue,
1613
              })(<Input type="hidden"/>)}
1614 1615
              <span
                style={{
1616

1617 1618 1619 1620 1621 1622 1623 1624 1625
                  fontWeight: get == 'mobile' ? 'bold' : '',
                  marginRight: get == 'mobile' ? 12 : '',
                }}
                {...json.props}
              >
                {obj[this.props.uuid] || json.initialValue}
              </span>
            </>
          );
wanyielin's avatar
wanyielin committed
1626
        } else {
1627 1628 1629
          return (
            <>
              {this.props.form.getFieldDecorator(uid, {
1630
                initialValue: this.props.form.getFieldsValue()[uid] || json.initialValue,
1631
              })(<Input type="hidden"/>)}
1632 1633
              <span
                style={{
1634

1635 1636 1637 1638 1639
                  fontWeight: get == 'mobile' ? 'bold' : '',
                  marginRight: get == 'mobile' ? 12 : '',
                }}
                {...json.props}
              >
1640
                {this.props.form.getFieldsValue()[uid]}
1641 1642 1643
              </span>
            </>
          );
wanyielin's avatar
wanyielin committed
1644
        }
徐立's avatar
徐立 committed
1645 1646 1647 1648
      }
    }

    if (json.comName == 'Description') {
1649 1650
      const key = json.sqls[json.sqls.length - 1];
      var cm = '';
徐立's avatar
徐立 committed
1651 1652 1653 1654
      var value;

      if (obj != null && obj.defaultValues) {
        if (obj.defaultValues[formKey]) {
1655
          value = obj.defaultValues[formKey][key];
徐立's avatar
徐立 committed
1656
        } else if (defaultValues) {
1657
          value = defaultValues[key];
徐立's avatar
徐立 committed
1658 1659
        }
      } else if (defaultValues) {
1660
        value = defaultValues[key];
徐立's avatar
徐立 committed
1661 1662 1663
      }
      switch (json.viewName) {
        case 'TextArea':
1664 1665 1666
          cm = (
            <span>
              {value}
1667
              {get === 'mobile' ? <br/> : ''}
1668 1669
            </span>
          );
徐立's avatar
徐立 committed
1670 1671
          break;
        case 'Switch':
1672 1673 1674
          cm = (
            <span>
              {value}
1675
              {get === 'mobile' ? <br/> : ''}
1676 1677
            </span>
          );
徐立's avatar
徐立 committed
1678 1679 1680

          break;
        case 'Input':
1681
          cm = (
1682
            <span style={{paddingRight: get == 'mobile' ? 8 : ''}}>
1683
              {value}
1684
              {get === 'mobile' ? <br/> : ''}
1685 1686
            </span>
          );
徐立's avatar
徐立 committed
1687 1688

          break;
tb53863844's avatar
tb53863844 committed
1689
        case 'Cron':
1690
          cm = (
1691
            <span style={{paddingRight: get == 'mobile' ? 8 : ''}}>
tb53863844's avatar
tb53863844 committed
1692
                {value}
1693
              {get === 'mobile' ? <br/> : ''}
tb53863844's avatar
tb53863844 committed
1694
              </span>
1695 1696 1697
          );

          break;
徐立's avatar
徐立 committed
1698
        case 'InputNumber':
1699 1700 1701
          cm = (
            <span>
              {value}
1702
              {get === 'mobile' ? <br/> : ''}
1703 1704
            </span>
          );
徐立's avatar
徐立 committed
1705 1706 1707

          break;
        case 'DatePicker':
1708 1709
          cm = value ? (
            <span>
徐立's avatar
徐立 committed
1710
              {moment(parseInt(value)).format('YYYY-MM-DD HH:mm:ss')}
1711
              {get === 'mobile' ? <br/> : ''}
1712 1713
            </span>
          ) : (
1714 1715
            ''
          );
徐立's avatar
徐立 committed
1716 1717 1718

          break;
        case 'UploadCom':
1719
          const files = value.files || [];
徐立's avatar
徐立 committed
1720 1721 1722 1723
          cm = (
            <>
              <ul>
                {files.map((f, index2) => {
1724 1725 1726 1727
                  if (
                    !this.props.isPrint &&
                    (f.path.indexOf('.png') != -1 || f.path.indexOf('.jpg') != -1)
                  ) {
1728 1729 1730
                    return (
                      <img
                        key={index2}
1731
                        style={{width: 100, height: 100}}
1732 1733 1734
                        src={queryApiActionPath() + f.path}
                      />
                    );
徐立's avatar
徐立 committed
1735
                  }
1736 1737 1738 1739 1740 1741 1742
                  return (
                    <li key={index2}>
                      <a target="_blank" key={f.path} href={queryApiActionPath() + f.path}>
                        {f.name}
                      </a>
                    </li>
                  );
徐立's avatar
徐立 committed
1743 1744
                })}
              </ul>
1745
              {get === 'mobile' ? <br/> : ''}
徐立's avatar
徐立 committed
1746 1747 1748 1749 1750
            </>
          );

          break;
        case 'ImgUploadCom':
1751
          if (value == null || value == '') {
1752
            cm = <div style={{width: json.width, height: json.height}}></div>;
wanyielin's avatar
wanyielin committed
1753
          } else {
1754 1755 1756 1757
            cm = (
              <>
                <img
                  src={config.httpServer + value}
1758
                  style={{width: json.width, height: json.height}}
1759
                />
1760
                {get === 'mobile' ? <br/> : ''}
1761 1762
              </>
            );
wanyielin's avatar
wanyielin committed
1763
          }
徐立's avatar
徐立 committed
1764

1765 1766 1767
          break;
        case 'VideoUploadCom':
          if (value == null || value == '') {
1768
            cm = <div style={{width: json.width, height: json.height}}>
1769 1770 1771 1772 1773 1774
            </div>;
          } else {
            cm = (
              <>
                <img
                  src={config.httpServer + value}
1775
                  style={{width: json.width, height: json.height}}
1776
                />
1777
                {get === 'mobile' ? <br/> : ''}
1778 1779 1780
              </>
            );
          }
徐立's avatar
徐立 committed
1781 1782
          break;
      }
chlolch's avatar
chlolch committed
1783
      if (get === 'mobile') {
徐立's avatar
徐立 committed
1784 1785 1786 1787
        if (
          (json.isMobileLabel != null && json.isMobileLabel) ||
          (json.isMobileLabel == null && json.isLabel)
        ) {
chlolch's avatar
chlolch committed
1788
          if (obj && obj.defaultValues && obj.defaultValues[formKey]) {
1789
            return (
徐立's avatar
徐立 committed
1790 1791
              <MobileItem
                isPreview={isPreview}
1792 1793
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
1794 1795 1796 1797 1798
                label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ''}
              >
                {cm}
              </MobileItem>
            );
chlolch's avatar
chlolch committed
1799
          } else {
徐立's avatar
徐立 committed
1800 1801
            return (
              <>
徐立's avatar
徐立 committed
1802 1803
                <MobileItem
                  isPreview={isPreview}
1804 1805
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
chlolch's avatar
chlolch committed
1806 1807 1808
                  label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ''}
                >
                  {cm}
徐立's avatar
徐立 committed
1809
                </MobileItem>
chlolch's avatar
chlolch committed
1810 1811
                {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
                  initialValue: value,
1812
                })(<Input type="hidden"/>)}
chlolch's avatar
chlolch committed
1813
              </>
徐立's avatar
徐立 committed
1814
            );
chlolch's avatar
chlolch committed
1815 1816 1817 1818 1819 1820 1821 1822 1823 1824
          }
        } else {
          if (!isEdit && obj.defaultValues && obj.defaultValues[formKey]) {
            return cm;
          } else {
            return (
              <>
                {cm}
                {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
                  initialValue: value,
1825
                })(<Input type="hidden"/>)}
chlolch's avatar
chlolch committed
1826 1827 1828 1829 1830 1831 1832 1833 1834 1835
              </>
            );
          }
        }
      } else {
        if (json.isLabel) {
          if (obj && obj.defaultValues && obj.defaultValues[formKey]) {
            if (!isEdit) {
              return (
                <Row
1836
                  style={{
chlolch's avatar
chlolch committed
1837
                    minHeight: 40,
1838 1839
                    lineHeight: '40px',
                  }}
chlolch's avatar
chlolch committed
1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863
                >
                  <Col
                    className={json.label ? json.label : sqlData[key] ? styles.row_col_div : ''}
                    span={json.labelSpan}
                    style={{
                      textAlign: json.labelSpan === 24 ? 'left' : 'right',
                      lineHeight: '40px',
                      whiteSpace: 'nowrap',
                      overflow: 'hidden',
                      fontSize: 14,
                      color: 'rgba(0,0,0,0.85)',
                    }}
                  >
                    {json.label ? (
                      <>
                        {json.label}
                        <span
                          style={{
                            position: 'relative',
                            top: '-0.5px',
                            margin: '0 8px 0 2px',
                          }}
                        >
                          :
徐立's avatar
徐立 committed
1864
                        </span>
chlolch's avatar
chlolch committed
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876
                      </>
                    ) : sqlData[key] ? (
                      <>
                        {sqlData[key].title}
                        <span
                          style={{
                            position: 'relative',
                            top: '-0.5px',
                            margin: '0 8px 0 2px',
                          }}
                        >
                          :
徐立's avatar
徐立 committed
1877
                        </span>
chlolch's avatar
chlolch committed
1878 1879
                      </>
                    ) : (
1880 1881
                      ''
                    )}
chlolch's avatar
chlolch committed
1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898
                  </Col>
                  <Col
                    span={json.wrapperSpan}
                    style={{
                      position: 'relative',
                      lineHeight: '40px',
                      zoom: 1,
                      fontSize: 14,
                    }}
                  >
                    {cm}
                  </Col>
                </Row>
              );
            } else {
              return (
                <Form.Item
1899 1900
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
chlolch's avatar
chlolch committed
1901
                  label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ''}
徐立's avatar
徐立 committed
1902 1903
                >
                  {cm}
chlolch's avatar
chlolch committed
1904 1905 1906
                </Form.Item>
              );
            }
徐立's avatar
徐立 committed
1907 1908
          } else {
            return (
chlolch's avatar
chlolch committed
1909 1910
              <>
                <Form.Item
1911 1912
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
chlolch's avatar
chlolch committed
1913 1914 1915 1916 1917 1918
                  label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ''}
                >
                  {cm}
                </Form.Item>
                {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
                  initialValue: value,
1919
                })(<Input type="hidden"/>)}
chlolch's avatar
chlolch committed
1920
              </>
1921
            );
徐立's avatar
徐立 committed
1922
          }
徐立's avatar
徐立 committed
1923
        } else {
chlolch's avatar
chlolch committed
1924 1925 1926
          if (!isEdit && obj.defaultValues && obj.defaultValues[formKey]) {
            return cm;
          } else {
1927 1928
            return (
              <>
chlolch's avatar
chlolch committed
1929
                {cm}
1930 1931
                {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
                  initialValue: value,
1932
                })(<Input type="hidden"/>)}
1933 1934
              </>
            );
徐立's avatar
徐立 committed
1935 1936 1937 1938 1939 1940 1941
          }
        }
      }
    }

    var cm;
    var required = false;
wanyielin's avatar
wanyielin committed
1942
    const bindObj = this.getColumn('c1');
徐立's avatar
徐立 committed
1943

1944 1945 1946
    let dataColumn =
      this.props.fatherCode != null
        ? bindObj
1947 1948 1949 1950
        ? {
          ...bindObj,
          base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
        }
1951
        : {base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`}
1952
        : bindObj;
徐立's avatar
徐立 committed
1953

wanyielin's avatar
wanyielin committed
1954
    if (this.props.fatherCode == null && dataColumn == null) {
1955
      dataColumn = {base52: this.props.uuid};
chscls@163.com's avatar
chscls@163.com committed
1956
    }
wanyielin's avatar
wanyielin committed
1957
    if (dataColumn.isNull != null && !dataColumn.isNull) {
chscls@163.com's avatar
chscls@163.com committed
1958
      required = true;
徐立's avatar
徐立 committed
1959 1960
    }

1961
    var title = json.label || (dataColumn && dataColumn.title);
徐立's avatar
徐立 committed
1962
    var initValue;
1963
    const objinit = {...init, ...obj};
1964

1965
    if (objinit != null && Object.keys(objinit).length > 0) {
徐立's avatar
徐立 committed
1966
      if (this.props.fatherCode != null) {
徐立's avatar
徐立 committed
1967 1968 1969 1970
        initValue =
          objinit[this.props.index] != null
            ? objinit[this.props.index][bindObj ? bindObj.base52 : this.props.uuid]
            : null;
徐立's avatar
徐立 committed
1971
      } else {
chlolch's avatar
chlolch committed
1972
        initValue = objinit[dataColumn.base52];
徐立's avatar
徐立 committed
1973 1974 1975
      }
    } else {
      if (json.initialValue != null) {
1976

徐立's avatar
徐立 committed
1977
        try {
1978
          initValue = JSON.parse(json.initialValue);
徐立's avatar
徐立 committed
1979
        } catch (e) {
1980

1981
          initValue = null;
徐立's avatar
徐立 committed
1982 1983 1984
        }
      }
    }
chlolch's avatar
chlolch committed
1985

1986 1987 1988 1989
    if(initValue === null || initValue === undefined){
      initValue = '';
    }

徐立's avatar
徐立 committed
1990 1991
    if (!isEdit) {
      if (this.props.fatherCode) {
wanyielin's avatar
wanyielin committed
1992
        if (bindObj != null) {
1993
          dataColumn.base52 = bindObj.base52;
wanyielin's avatar
wanyielin committed
1994
        } else {
1995
          dataColumn.base52 = this.props.uuid;
chscls@163.com's avatar
chscls@163.com committed
1996
        }
徐立's avatar
徐立 committed
1997 1998 1999 2000 2001 2002
      }
      switch (json.comName) {
        // 电子签章展示
        // case 'Signature':
        //   cm = <img  src={queryApiActionPath()+obj[dataColumn.base52]} />
        //   break;
chscls@163.com's avatar
chscls@163.com committed
2003
        case 'RichText':
2004
          // console.log(obj[dataColumn.base52]);
徐立's avatar
徐立 committed
2005 2006 2007 2008 2009 2010 2011 2012
          cm = (
            <Editor
              key={dataColumn.base52}
              readOnly={true}
              blockRendererFn={MyBlockRenderer.bind(this, true, null, null, null)}
              editorState={changeToDraftState(obj[dataColumn.base52])}
            />
          );
chscls@163.com's avatar
chscls@163.com committed
2013
          break;
徐立's avatar
徐立 committed
2014
        case 'TextArea':
2015 2016 2017 2018 2019 2020 2021 2022 2023
          cm = (
            <span
              style={{
                wordBreak: 'break-all',
              }}
            >
              {obj[dataColumn.base52]}
            </span>
          );
徐立's avatar
徐立 committed
2024 2025 2026 2027 2028 2029
          break;
        case 'Switch':
          cm = <span>{obj[dataColumn.base52]}</span>;

          break;
        case 'Input':
徐立's avatar
徐立 committed
2030 2031 2032 2033 2034 2035 2036 2037 2038
          cm = (
            <span
              style={{
                wordBreak: 'break-all',
              }}
            >
              {obj[dataColumn.base52]}
            </span>
          );
徐立's avatar
徐立 committed
2039 2040

          break;
wanyielin's avatar
wanyielin committed
2041 2042
        case 'InputHidden':
          cm = <></>;
徐立's avatar
徐立 committed
2043

wanyielin's avatar
wanyielin committed
2044
          break;
徐立's avatar
徐立 committed
2045 2046 2047 2048 2049 2050 2051 2052
        case 'InputNumber':
          cm = <span>{obj[dataColumn.base52]}</span>;

          break;
        /**
         * 为Radio为单选
         */
        case 'Radio':
2053
          cm = <span>{labels != null && labels.length > 0 ? Object.values(labels[0]) : ''}</span>;
徐立's avatar
徐立 committed
2054 2055 2056 2057 2058 2059 2060

          break;
        /**
         * 为Checked为多选
         * 该组件需要调用请求
         */
        case 'Checkbox':
2061 2062 2063 2064
          cm = (
            <span>
              {labels != null
                ? labels.map((r, i) =>
tb53863844's avatar
tb53863844 committed
2065 2066 2067 2068
                  i == 0 ? (
                    typeof r == 'string' ? (
                      <span>{r}</span>
                    ) : (
2069 2070
                      Object.values(r)
                    )
tb53863844's avatar
tb53863844 committed
2071
                  ) : typeof r == 'string' ? (
2072
                    <span style={{marginLeft: 12}}>{r}</span>
tb53863844's avatar
tb53863844 committed
2073
                  ) : (
2074 2075
                    ',' + Object.values(r)
                  ),
tb53863844's avatar
tb53863844 committed
2076
                )
2077 2078 2079
                : ''}
            </span>
          );
徐立's avatar
徐立 committed
2080 2081 2082

          break;
        case 'Select':
2083
          cm = <span>{labels != null && labels.length > 0 ? Object.values(labels[0]) : ''}</span>;
徐立's avatar
徐立 committed
2084 2085

          break;
tb53863844's avatar
tb53863844 committed
2086
        case 'Cascader':
2087
          cm = <span>
tb53863844's avatar
tb53863844 committed
2088
          {labels != null
2089
            ? labels.join(json.spliter ? json.spliter : "")
tb53863844's avatar
tb53863844 committed
2090 2091
            : ''}
        </span>
2092
          break;
徐立's avatar
徐立 committed
2093
        case 'TableSelect':
2094 2095 2096 2097
          const ds =
            obj[dataColumn.base52] && obj[dataColumn.base52].selects
              ? Object.values(obj[dataColumn.base52].selects)
              : [];
徐立's avatar
徐立 committed
2098
          if (json.showTable) {
2099 2100 2101 2102 2103 2104 2105 2106 2107
            cm = (
              <Table
                get={get}
                columns={this.state.columns}
                size="small"
                dataSource={ds}
                pagination={false}
              />
            );
徐立's avatar
徐立 committed
2108
          } else {
2109 2110 2111 2112 2113
            cm = (
              <span>
                {ds.map((r, i) => (i == 0 ? r[json.labelName] : ',' + r[json.labelName]))}
              </span>
            );
徐立's avatar
徐立 committed
2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126
          }

          break;
        case 'RangePicker':
          const begin = dataColumn;
          const end = this.getColumn('c2');
          const ivs = [];

          if (initValue != null && init != null) {
            ivs.push(moment(parseInt(initValue)));
            if (end != null) ivs.push(moment(parseInt(init[end.base52])));
          }
          if (begin != null && end != null) {
徐立's avatar
徐立 committed
2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141
            if (!obj[begin.base52]) {
              cm = <span>暂无</span>;
            } else {
              cm = (
                <span>
                  {moment(parseInt(obj[begin.base52])).format(
                    json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                  )}{' '}
{' '}
                  {moment(parseInt(obj[end.base52])).format(
                    json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                  )}
                </span>
              );
            }
徐立's avatar
徐立 committed
2142
          } else {
2143
            cm = '';
徐立's avatar
徐立 committed
2144
          }
徐立's avatar
徐立 committed
2145
          title = title ? title : '起止时间';
徐立's avatar
徐立 committed
2146 2147 2148 2149
          break;
        case 'DatePicker':
          if (obj[dataColumn.base52] && obj[dataColumn.base52].indexOf('-') === -1) {
            cm = (
2150 2151 2152 2153 2154
              <span>
                {moment(parseInt(obj[dataColumn.base52])).format(
                  json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                )}
              </span>
徐立's avatar
徐立 committed
2155 2156 2157
            );
          } else {
            cm = (
2158 2159 2160
              <span>
                {obj[dataColumn.base52]
                  ? moment(+new Date(obj[dataColumn.base52])).format(
tb53863844's avatar
tb53863844 committed
2161 2162
                    json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                  )
2163 2164
                  : ''}
              </span>
徐立's avatar
徐立 committed
2165 2166 2167 2168 2169 2170 2171 2172 2173 2174
            );
          }

          break;

        case 'UploadCom':
          /**
           * 查找不到数据 添加判断
           * 只有一个附件返回的是一个对象不是数组,暂时使用2个判断
           */
2175 2176 2177
          if (!isEmpty(obj[dataColumn.base52])) {
            // 首先判断是否为空对象
            let ary;
徐立's avatar
徐立 committed
2178 2179 2180 2181
            /**
             * 判断返回值是否为JSON字符串,不是则直接使用
             */
            if (this.isJSON(obj[dataColumn.base52])) {
2182
              ary = JSON.parse(obj[dataColumn.base52]);
徐立's avatar
徐立 committed
2183
            } else {
2184
              ary = obj[dataColumn.base52];
徐立's avatar
徐立 committed
2185
            }
2186 2187
            if (!!ary.files) {
              // 然后判断存在多个附件的数组是否存在
徐立's avatar
徐立 committed
2188 2189 2190 2191
              const files = !isEmpty(ary) ? ary.files : [];
              cm = (
                <ul>
                  {files.map((f, index2) => {
2192 2193 2194 2195 2196 2197 2198 2199 2200
                    // if (f.path.indexOf('.png') != -1 || f.path.indexOf('.jpg') != -1) {
                    //   return (
                    //     <img
                    //       key={index2}
                    //       style={{ width: 100, height: 100 }}
                    //       src={queryApiActionPath() + f.path}
                    //     />
                    //   );
                    // }
2201
                    if (get === 'web' && !this.props.isPrint) {
2202 2203
                      return (
                        <li key={index2}>
2204
                          <FilePreview path={queryApiActionPath() + f.path} pathName={f.name}/>
2205 2206
                        </li>
                      );
徐立's avatar
徐立 committed
2207
                    }
2208 2209 2210 2211 2212 2213 2214
                    return (
                      <li key={index2}>
                        <a target="_blank" key={f.path} href={queryApiActionPath() + f.path}>
                          {f.name}
                        </a>
                      </li>
                    );
徐立's avatar
徐立 committed
2215 2216 2217 2218 2219 2220 2221
                  })}
                </ul>
              );
            } else {
              const files = !isEmpty(ary) ? ary : [];
              cm = (
                <ul>
徐立's avatar
徐立 committed
2222
                  {Array.isArray(files) &&
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233
                  files.map((f, index2) => {
                    // if (f.filePath.indexOf('.png') != -1 || f.filePath.indexOf('.jpg') != -1) {
                    //   return (
                    //     <img
                    //       key={index2}
                    //       style={{ width: 100, height: 100 }}
                    //       src={queryApiActionPath() + f.filePath}
                    //     />
                    //   );
                    // }
                    if (get === 'web' || !this.props.isPrint) {
2234
                      return (
徐立's avatar
徐立 committed
2235
                        <li key={index2}>
2236
                          <FilePreview path={queryApiActionPath() + f.path} pathName={f.name}/>
徐立's avatar
徐立 committed
2237
                        </li>
2238
                      );
2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251
                    }
                    return (
                      <li key={index2}>
                        <a
                          target="_blank"
                          key={f.filePath}
                          href={queryApiActionPath() + f.filePath}
                        >
                          {f.fileName}
                        </a>
                      </li>
                    );
                  })}
徐立's avatar
徐立 committed
2252 2253 2254 2255
                </ul>
              );
            }
          } else {
2256
            cm = (
2257
              <span style={{display: 'inline-block', width: '100%', textAlign: 'center'}}>
2258 2259 2260
                暂无附件
              </span>
            );
徐立's avatar
徐立 committed
2261 2262 2263 2264
          }

          break;
        case 'ImgUploadCom':
2265
          if (obj[dataColumn.base52] == null || obj[dataColumn.base52] == '') {
2266 2267
            cm = <div style={{
              width: json.width,
2268 2269
              height: json.height
            }}>
2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282

            </div>;
          } else {
            cm = FilePreview ? (
              <FilePreview
                path={config.httpServer + obj[dataColumn.base52]}
                pathName={obj[dataColumn.base52]}
                width={json.width}
                height={json.height}
              />
            ) : (
              <img
                src={config.httpServer + obj[dataColumn.base52]}
2283
                style={{width: json.width, height: json.height}}
2284 2285 2286 2287 2288 2289 2290 2291 2292
              />
            );
          }

          break;
        case 'VideoUploadCom':
          if (obj[dataColumn.base52] == null || obj[dataColumn.base52] == '') {
            cm = <div style={{
              width: json.width,
2293 2294
              height: json.height
            }}>
2295 2296

            </div>;
wanyielin's avatar
wanyielin committed
2297
          } else {
2298 2299 2300 2301
            cm = FilePreview ? (
              <FilePreview
                path={config.httpServer + obj[dataColumn.base52]}
                pathName={obj[dataColumn.base52]}
徐立's avatar
徐立 committed
2302 2303
                width={json.width}
                height={json.height}
2304 2305
              />
            ) : (
2306 2307
              <img
                src={config.httpServer + obj[dataColumn.base52]}
2308
                style={{width: json.width, height: json.height}}
2309 2310
              />
            );
chscls@163.com's avatar
1  
chscls@163.com committed
2311
          }
徐立's avatar
徐立 committed
2312

徐立's avatar
徐立 committed
2313 2314
          break;
        case 'Signature':
2315 2316 2317 2318
          cm = (
            <img
              src={config.httpServer + obj[dataColumn.base52]}
              style={{
徐立's avatar
徐立 committed
2319
                marginLeft: 5,
2320 2321
                width:
                  get === 'mobile'
徐立's avatar
徐立 committed
2322
                    ? document.documentElement.clientWidth - 10 || document.body.clientWidth - 10
2323 2324 2325 2326 2327
                    : json.width,
                height: get === 'mobile' ? '' : json.height,
              }}
            />
          );
徐立's avatar
徐立 committed
2328 2329 2330

          break;
        case 'ChildForm':
2331
          const xxxxx = obj[dataColumn.base52];
徐立's avatar
徐立 committed
2332
          if (xxxxx == null) {
2333 2334
            cm = <></>;
            Chil
徐立's avatar
徐立 committed
2335 2336 2337
            break;
          }
          if (Object.keys(xxxxx).length > 0) {
2338 2339 2340 2341 2342
            delete xxxxx[''];
          }

          cm = (
            <ChildForm
2343
              taskId={this.props.taskId}
2344
              setRealTimeValues={this.props.setRealTimeValues}
chscls@163.com's avatar
chscls@163.com committed
2345
              modalInit={modalInit}
tb53863844's avatar
tb53863844 committed
2346
              trees={this.props.trees}
chlolch's avatar
chlolch committed
2347
              isPreview={isPreview}
tb53863844's avatar
tb53863844 committed
2348 2349 2350 2351
              hfInstance={this.props.hfInstance}
              getCurrentFormTitle={this.props.getCurrentFormTitle}
              getCellValue={getCellValue}

2352 2353 2354 2355 2356 2357 2358 2359
              fatherObj={obj}
              json={json}
              rights={json.rights || ['add', 'delete']}
              isMobile={get === 'mobile'}
              value={xxxxx}
              deleteName={json.deleteName}
              addName={json.addName}
              isEdit={isEdit}
chscls@163.com's avatar
chscls@163.com committed
2360 2361
              formCode={this.props.formCode}
              formId={this.props.formId}
2362 2363 2364 2365 2366 2367 2368 2369
              base52={dataColumn.base52}
              mapData={mapData}
              datas={datas ? datas[json.childFormKey] : null}
              defaultValues={defaultValues}
              sqlData={sqlData}
              form={this.props.form}
            />
          );
徐立's avatar
徐立 committed
2370 2371
          break;
        case 'Button':
2372
          let events = {};
徐立's avatar
徐立 committed
2373 2374

          if (json.events != null) {
2375
            events = this.getFunctionValue(json.events, {base52: this.props.uuid}, json);
徐立's avatar
徐立 committed
2376
          }
wanyielin's avatar
wanyielin committed
2377
          if (events && events.dom) {
2378
            cm = events.dom;
wanyielin's avatar
wanyielin committed
2379
          } else {
徐立's avatar
徐立 committed
2380
            const ev = {
wanyielin's avatar
wanyielin committed
2381
              children: json.initialValue,
2382 2383
              ...events,
            };
wanyielin's avatar
wanyielin committed
2384
            if (json.isLink) {
2385
              cm = <a {...ev} />;
wanyielin's avatar
wanyielin committed
2386
            } else {
2387
              cm = <Button loading={this.props.loading} type="primary" {...ev} />;
徐立's avatar
徐立 committed
2388 2389
            }
          }
徐立's avatar
徐立 committed
2390

徐立's avatar
徐立 committed
2391 2392
          break;
        case 'LocationCom':
2393 2394 2395 2396 2397
          cm = <span><LocationCom get={get}
                                  btnName={json.btnName}
                                  btnSucName={json.btnSucName}
                                  width={json.width} json={json}
                                  showMap={json.showMap} value={obj[dataColumn.base52]}/></span>;
徐立's avatar
徐立 committed
2398 2399 2400
          break;

        case 'Table':
2401 2402
          if (json.objCode == null || json.objCode == '') {
            cm = <></>;
徐立's avatar
徐立 committed
2403
          }
2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418
          cm = (
            <TableList
              get={get}
              isTree={json.isTree}
              json={json}
              loading={this.props.loading}
              showHeader={json.showHeader}
              isHiddenPage={json.isHiddenPage}
              pageSize={json.pageSize}
              value={obj[dataColumn.base52 || this.props.uuid] || {}}
              objCode={json.objCode}
              sql={json.filterSql}
              rights={json.rights}
            />
          );
徐立's avatar
徐立 committed
2419 2420
          break;
        default:
2421
          cm = <span>缺乏字段{json.comName}的匹配项</span>;
徐立's avatar
徐立 committed
2422 2423 2424 2425 2426
          break;
      }
    } else {
      if (json.vlds && json.vlds.length > 0) {
        for (let i in json.vlds) {
2427
          if (json.vlds[i].validatorFunc && json.vlds[i].validatorFunc != '') {
徐立's avatar
徐立 committed
2428
            try {
2429 2430
              let fn = new Function('rule', 'value', 'callback', json.vlds[i].validatorFunc);
              json.vlds[i].validator = fn;
徐立's avatar
徐立 committed
2431
            } catch (e) {
2432
              console.log(e);
徐立's avatar
徐立 committed
2433 2434 2435 2436 2437 2438
            }
          }
        }
      }
      switch (json.comName) {
        case 'Button':
2439
          let events = {};
徐立's avatar
徐立 committed
2440 2441

          if (json.events != null) {
2442
            events = this.getFunctionValue(json.events, {base52: this.props.uuid}, json);
徐立's avatar
徐立 committed
2443
          }
wanyielin's avatar
wanyielin committed
2444
          if (events && events.dom) {
2445
            cm = events.dom;
wanyielin's avatar
wanyielin committed
2446
          } else {
徐立's avatar
徐立 committed
2447
            const ev = {
wanyielin's avatar
wanyielin committed
2448
              children: json.initialValue,
2449 2450
              ...events,
            };
wanyielin's avatar
wanyielin committed
2451
            if (json.isLink) {
2452
              cm = <a {...ev} />;
wanyielin's avatar
wanyielin committed
2453
            } else {
2454
              cm = <Button loading={this.props.loading} type="primary" {...ev} />;
徐立's avatar
徐立 committed
2455 2456
            }
          }
徐立's avatar
徐立 committed
2457

徐立's avatar
徐立 committed
2458 2459 2460
          break;
        case 'TextArea':
          if (get === 'mobile') {
chlolch's avatar
chlolch committed
2461 2462 2463 2464 2465
            cm = getFieldDecorator(dataColumn.base52, {
              initialValue: initValue,
              rules:
                json.vlds && json.vlds.length > 0
                  ? json.vlds
2466
                  : [{required: required, message: '请输入' + title}],
徐立's avatar
徐立 committed
2467 2468
            })(
              <TextArea
钟是志's avatar
钟是志 committed
2469
                autoSize={{minRows: 4}}
徐立's avatar
徐立 committed
2470 2471 2472 2473
                disabled={disabled}
                placeholder={json.placeholder}
              />,
            );
2474
            /*  cm = (
徐立's avatar
徐立 committed
2475 2476 2477
              <MobileTextareaItem
                {...getFieldProps(dataColumn.base52, {
                  initialValue: initValue,
2478 2479 2480 2481
                  rules:
                    json.vlds && json.vlds.length > 0
                      ? json.vlds
                      : [{ required: required, message: '请输入' + title }],
徐立's avatar
徐立 committed
2482 2483 2484 2485 2486 2487 2488 2489
                })}
                //disabled={disabled}
                style={{ fontSize: 14 }}
                clear
                autoHeight
                // title={<span className={styles.text}>{dataColumn.title}</span>}
                placeholder={json.placeholder}
              />
chlolch's avatar
chlolch committed
2490
            ); */
徐立's avatar
徐立 committed
2491 2492 2493 2494 2495
            if (
              ((json.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
2496 2497
              cm = (
                <Form.Item
2498 2499
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
2500 2501 2502 2503 2504
                  label={title}
                >
                  {cm}
                </Form.Item>
              );
徐立's avatar
徐立 committed
2505 2506
            }
          } else {
2507
            // console.log(JSON.stringify(this.props.form.getFieldsValue()), '----formValue----');
徐立's avatar
徐立 committed
2508 2509
            cm = getFieldDecorator(dataColumn.base52, {
              initialValue: initValue,
2510 2511 2512
              rules:
                json.vlds && json.vlds.length > 0
                  ? json.vlds
2513
                  : [{required: required, message: '请输入' + title}],
徐立's avatar
徐立 committed
2514 2515
            })(
              <TextArea
钟是志's avatar
钟是志 committed
2516
                autoSize={{minRows: 4}}
徐立's avatar
徐立 committed
2517 2518 2519 2520 2521
                disabled={disabled}
                rows={4}
                placeholder={json.placeholder}
              />,
            );
徐立's avatar
徐立 committed
2522 2523 2524 2525
          }
          break;
        case 'Switch':
          if (get === 'mobile') {
2526
            if (dataColumn == null || json.formula != null) {
2527
              cm = this.props.form.getFieldsValue()[this.props.uuid];
2528 2529
              break;
            }
徐立's avatar
徐立 committed
2530 2531
            cm = (
              <MobileList.Item
2532 2533 2534 2535 2536 2537 2538
                extra={
                  <MobileSwitch
                    {...getFieldProps(dataColumn.base52, {
                      initialValue: initValue,
                      rules:
                        json.vlds && json.vlds.length > 0
                          ? json.vlds
2539
                          : [{required: required, message: '请选择' + title}],
2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550
                    })}
                    disabled={disabled}
                    onClick={checked => {
                      // set new value
                      this.props.form.setFieldsValue({
                        [dataColumn.base52]: checked,
                      });
                    }}
                  />
                }
              >
徐立's avatar
徐立 committed
2551
                {(json.isMobileLabel != null && json.isMobileLabel) ||
2552
                (json.isMobileLabel == null && json.isLabel)
徐立's avatar
徐立 committed
2553 2554
                  ? title
                  : ''}
2555 2556 2557
              </MobileList.Item>
            );
            break;
徐立's avatar
徐立 committed
2558 2559 2560 2561 2562
          }

          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            valuePropName: 'checked',
2563 2564 2565
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
2566
                : [{required: required, message: '请选择' + title}],
2567 2568 2569 2570 2571 2572 2573
          })(
            <Switch
              disabled={disabled}
              checkedChildren={json.checkedChildren}
              unCheckedChildren={json.unCheckedChildren}
            />,
          );
徐立's avatar
徐立 committed
2574 2575

          break;
2576

徐立's avatar
徐立 committed
2577 2578 2579
        case 'Input':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
2580 2581 2582
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
2583
                : [{required: required, message: '请输入' + title}],
2584 2585 2586
          })(
            <Input
              disabled={disabled}
2587
              style={{width: json.width}}
2588 2589 2590
              placeholder={json.placeholder}
            />,
          );
徐立's avatar
徐立 committed
2591 2592
          if (get == 'mobile') {
            cm = <div>{cm}</div>;
徐立's avatar
徐立 committed
2593 2594 2595 2596 2597
            if (
              ((json.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
徐立's avatar
徐立 committed
2598
              cm = (
徐立's avatar
徐立 committed
2599 2600
                <MobileItem
                  isPreview={isPreview}
2601 2602
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
徐立's avatar
徐立 committed
2603 2604 2605
                  label={title}
                >
                  {cm}
徐立's avatar
徐立 committed
2606
                </MobileItem>
徐立's avatar
徐立 committed
2607 2608 2609
              );
            }
          }
徐立's avatar
徐立 committed
2610
          break;
wanyielin's avatar
wanyielin committed
2611 2612
        case 'InputHidden':
          cm = getFieldDecorator(dataColumn.base52, {
2613
            initialValue: initValue,
2614
          })(<Input type="hidden"/>);
徐立's avatar
徐立 committed
2615 2616 2617 2618
          break;
        case 'InputNumber':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
2619 2620 2621
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
2622
                : [{required: required, message: '请输入' + title}],
2623 2624 2625 2626 2627 2628 2629 2630 2631 2632
          })(
            <InputNumber
              disabled={disabled}
              placeholder={json.placeholder}
              max={json.max}
              min={json.min}
              precision={json.precision}
              step={json.step}
            />,
          );
徐立's avatar
徐立 committed
2633
          if (get == 'mobile') {
2634
            cm = <div>{cm}</div>;
徐立's avatar
徐立 committed
2635 2636 2637 2638 2639
            if (
              ((json.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
2640
              cm = (
徐立's avatar
徐立 committed
2641 2642
                <MobileItem
                  isPreview={isPreview}
2643 2644
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
2645 2646 2647
                  label={title}
                >
                  {cm}
徐立's avatar
徐立 committed
2648
                </MobileItem>
2649
              );
徐立's avatar
徐立 committed
2650 2651 2652 2653 2654 2655 2656 2657 2658 2659
            }
          }
          break;

        /**
         * 为Radio为单选
         */
        case 'Radio':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
2660 2661 2662
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
2663 2664
                : [{required: required, message: '请选择' + dataColumn.title}],
          })(<Radio.Group options={options} disabled={disabled}/>);
徐立's avatar
徐立 committed
2665
          if (get == 'mobile') {
2666
            cm = <div>{cm}</div>;
徐立's avatar
徐立 committed
2667 2668 2669 2670 2671
            if (
              ((json.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
2672
              cm = (
徐立's avatar
徐立 committed
2673 2674
                <MobileItem
                  isPreview={isPreview}
2675 2676
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
2677 2678 2679
                  label={title}
                >
                  {cm}
徐立's avatar
徐立 committed
2680
                </MobileItem>
2681
              );
徐立's avatar
徐立 committed
2682 2683 2684 2685 2686 2687 2688 2689 2690 2691
            }
          }
          break;
        /**
         * 为Checked为多选
         * 该组件需要调用请求
         */
        case 'Checkbox':
          if (get === 'mobile') {
            cm = (
2692 2693 2694 2695 2696 2697
              <Flex direction="column" align="start">
                {getFieldDecorator(dataColumn.base52, {
                  initialValue: initValue, // 默认值
                  rules:
                    json.vlds && json.vlds.length > 0
                      ? json.vlds
2698 2699
                      : [{required: required, message: '请选择' + dataColumn.title}],
                })(<Checkbox.Group options={options} disabled={disabled}/>)}
徐立's avatar
徐立 committed
2700
              </Flex>
2701
            );
徐立's avatar
徐立 committed
2702

徐立's avatar
徐立 committed
2703 2704 2705 2706 2707
            if (
              ((json.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
2708
              cm = (
徐立's avatar
徐立 committed
2709 2710
                <MobileItem
                  isPreview={isPreview}
2711 2712
                  labelCol={{span: json.labelSpan}}
                  wrapperCol={{span: json.wrapperSpan}}
2713 2714 2715
                  label={title}
                >
                  {cm}
徐立's avatar
徐立 committed
2716
                </MobileItem>
2717
              );
徐立's avatar
徐立 committed
2718 2719
            }

2720
            break;
徐立's avatar
徐立 committed
2721 2722 2723 2724
          }

          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
2725 2726 2727
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
2728 2729
                : [{required: required, message: '请选择' + dataColumn.title}],
          })(<Checkbox.Group options={options} disabled={disabled}/>);
徐立's avatar
徐立 committed
2730 2731 2732 2733 2734

          break;
        case 'Select':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
2735 2736 2737
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
2738
                : [{required: required, message: '请选择' + dataColumn.title}],
徐立's avatar
徐立 committed
2739 2740 2741 2742 2743 2744
          })(
            <Select
              allowClear
              showSearch
              disabled={selectDis || disabled}
              placeholder={json.placeholder}
2745
              style={{width: json.width}}
徐立's avatar
徐立 committed
2746
              optionFilterProp="children"
徐立's avatar
徐立 committed
2747
              getPopupContainer={
2748
                this.props.isDynamic && document.querySelector('#dynamic_div')
徐立's avatar
徐立 committed
2749
                  ? () => {
tb53863844's avatar
tb53863844 committed
2750 2751
                    return document.querySelector('#dynamic_div');
                  }
徐立's avatar
徐立 committed
2752 2753
                  : ''
              }
wanyielin's avatar
wanyielin committed
2754
              onFocus={() => {
2755 2756
                get === 'mobile' // 移动端取消输入键盘弹出
                  ? setTimeout(() => {
tb53863844's avatar
tb53863844 committed
2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768
                    if (document.querySelectorAll(`.ant-select-search__field`).length > 0) {
                      let ary = [...document.querySelectorAll(`.ant-select-search__field`)];
                      ary.map(item => {
                        item.setAttribute('readonly', 'readonly');
                        // setTimeout(() => {
                        //   ary.map(arr => {
                        //     arr.removeAttribute('readonly');
                        //   })
                        // });
                      });
                    }
                  })
2769
                  : null;
徐立's avatar
徐立 committed
2770 2771
              }}
              filterOption={(input, option) =>
2772 2773 2774
                option
                  ? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                  : false
徐立's avatar
徐立 committed
2775 2776
              }
            >
2777
              {options && options instanceof Array
2778
                ? options.map(r => (
tb53863844's avatar
tb53863844 committed
2779 2780 2781 2782
                  <Option key={r.value} value={r.value}>
                    {r.label}
                  </Option>
                ))
2783 2784
                : ''}
            </Select>,
徐立's avatar
徐立 committed
2785
          );
徐立's avatar
徐立 committed
2786 2787 2788 2789 2790 2791
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
2792
            cm = (
徐立's avatar
徐立 committed
2793 2794
              <MobileItem
                isPreview={isPreview}
2795 2796
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
2797 2798 2799
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
2800
              </MobileItem>
2801
            );
徐立's avatar
徐立 committed
2802
          } else if (get === 'mobile') {
2803
            cm = <div>{cm}</div>;
徐立's avatar
徐立 committed
2804 2805
          }

tb53863844's avatar
tb53863844 committed
2806 2807 2808 2809 2810 2811 2812 2813 2814 2815
          break;

        case 'Cascader':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [{required: required, message: '请选择' + dataColumn.title}],
          })(<Cascader options={options}
2816 2817 2818 2819 2820
                       allowClear
                       showSearch
                       disabled={disabled}
                       placeholder={json.placeholder}
                       style={{width: json.width}}/>);
tb53863844's avatar
tb53863844 committed
2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          } else if (get === 'mobile') {
            cm = <div>{cm}</div>;
          }

徐立's avatar
徐立 committed
2841 2842 2843 2844 2845
          break;
        case 'TableSelect':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue || {},

2846 2847 2848 2849
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [
tb53863844's avatar
tb53863844 committed
2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861
                  {
                    validator: (rule, value, callback) => {
                      if (
                        (Object.keys(value).length == 0 ||
                          Object.keys(value.selects).length == 0) &&
                        required != null &&
                        required
                      ) {
                        var errors = [];
                        errors.push(new Error('请选择至少一个', rule.field));
                      }
                      callback(errors);
2862
                    },
tb53863844's avatar
tb53863844 committed
2863 2864 2865
                    required: required,
                  },
                ],
2866 2867 2868 2869 2870 2871 2872 2873
          })(
            <TableSelect
              get={get}
              json={json}
              dataColumn={dataColumn}
              columns={this.state.columns}
              dataSource={this.state.dataSource}
              sqlModel={this.state.sqlModel}
2874
              resetSearchText={this.resetSearchText}
2875
            />,
徐立's avatar
徐立 committed
2876
          );
徐立's avatar
徐立 committed
2877 2878 2879 2880 2881 2882
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
2883
            cm = (
徐立's avatar
徐立 committed
2884 2885
              <MobileItem
                isPreview={isPreview}
2886 2887
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
2888 2889 2890
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
2891
              </MobileItem>
2892
            );
徐立's avatar
徐立 committed
2893 2894 2895 2896 2897 2898 2899
          }
          break;

        case 'RangePicker':
          const begin = dataColumn;
          var end = this.getColumn('c2');
          if (end == null) {
2900
            end = {base52: this.props.uuid + '_2'};
徐立's avatar
徐立 committed
2901 2902 2903 2904 2905 2906 2907 2908 2909
          }
          const ivs = [];
          if (initValue != null && init != null) {
            ivs.push(moment(parseInt(initValue)));
            ivs.push(moment(parseInt(init[end.base52])));
          }
          if (!isEdit) {
            cm = (
              <span>
2910 2911 2912 2913 2914 2915 2916
                {moment(parseInt(obj[begin.base52])).format(
                  json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                )}{' '}
{' '}
                {moment(parseInt(obj[end.base52])).format(
                  json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                )}
徐立's avatar
徐立 committed
2917 2918 2919 2920 2921 2922
              </span>
            );
          } else {
            if (get === 'mobile') {
              cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
                initialValue: ivs,
2923 2924 2925
                rules:
                  json.vlds && json.vlds.length > 0
                    ? json.vlds
2926 2927
                    : [{required: required, message: '请选择起止时间'}],
              })(<MobileDate disabled={disabled} formate={json.format}/>);
徐立's avatar
徐立 committed
2928 2929 2930 2931 2932
              if (
                ((json.isMobileLabel != null && json.isMobileLabel) ||
                  (json.isMobileLabel == null && json.isLabel)) &&
                title
              ) {
2933
                cm = (
徐立's avatar
徐立 committed
2934 2935
                  <MobileItem
                    isPreview={isPreview}
2936 2937
                    labelCol={{span: json.labelSpan}}
                    wrapperCol={{span: json.wrapperSpan}}
2938 2939 2940
                    label={title}
                  >
                    {cm}
徐立's avatar
徐立 committed
2941
                  </MobileItem>
2942
                );
徐立's avatar
徐立 committed
2943
              }
2944
              break;
徐立's avatar
徐立 committed
2945 2946 2947
            }
            cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
              initialValue: ivs,
2948 2949 2950
              rules:
                json.vlds && json.vlds.length > 0
                  ? json.vlds
2951
                  : [{required: required, message: '请选择起止时间'}],
2952 2953 2954 2955 2956 2957 2958
            })(
              <RangePicker
                showTime={json.showTime != null ? json.showTime : true}
                format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'}
                disabled={disabled}
              />,
            );
徐立's avatar
徐立 committed
2959 2960 2961 2962 2963 2964
          }
          if (json.label == null) title = '起止时间';
          break;
        case 'DatePicker':
          var iv = null;
          if (initValue != null) {
wanyielin's avatar
wanyielin committed
2965
            iv = moment(typeof initValue === 'string' ? +initValue : initValue);
徐立's avatar
徐立 committed
2966 2967 2968 2969
          }
          // console.log(iv,json.format)
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: iv,
2970 2971 2972
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
2973
                : [{required: required, message: '请选择起止时间'}],
2974 2975 2976 2977 2978 2979 2980
          })(
            <DatePicker
              disabled={disabled}
              showTime={json.showTime != null ? json.showTime : true}
              onOpenChange={
                get === 'mobile'
                  ? () => {
tb53863844's avatar
tb53863844 committed
2981 2982 2983 2984 2985 2986 2987
                    // 取消唤起移动端小键盘
                    setTimeout(() => {
                      if (document.querySelector('.ant-calendar-input ')) {
                        document
                          .querySelector('.ant-calendar-input ')
                          .setAttribute('readonly', 'readonly');
                        setTimeout(() => {
2988 2989
                          document
                            .querySelector('.ant-calendar-input ')
tb53863844's avatar
tb53863844 committed
2990 2991 2992 2993 2994
                            .removeAttribute('readonly');
                        });
                      }
                    });
                  }
2995 2996
                  : () => {
                  }
2997 2998 2999 3000
              }
              format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'}
            />,
          );
徐立's avatar
徐立 committed
3001 3002 3003 3004 3005 3006
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
3007
            cm = (
徐立's avatar
徐立 committed
3008 3009
              <MobileItem
                isPreview={isPreview}
3010 3011
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3012 3013 3014
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
3015
              </MobileItem>
3016
            );
徐立's avatar
徐立 committed
3017 3018 3019 3020 3021 3022 3023 3024 3025 3026
          }
          break;

        case 'UploadCom':
          let files = [];
          // if (initValue != null) {
          if (initValue != null && !isEmpty(initValue.files)) {
            files = initValue.files;
          }
          cm = getFieldDecorator(dataColumn.base52, {
3027
            initialValue: {files: files},
3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040
            rules: [
              {
                validator: (rule, value, callback) => {
                  if (value.files.length == 0 && required != null && required) {
                    var errors = [];
                    errors.push(new Error('至少上传一个', rule.field));
                  }
                  callback(errors);
                },
                required: required,
                message: '请选择附件',
              },
            ],
tb53863844's avatar
tb53863844 committed
3041
          })(<UploadCom isMultiple={json.isMultiple} accept={json.accept} btnName={json.btnName}/>);
徐立's avatar
徐立 committed
3042 3043 3044 3045 3046 3047
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
3048
            cm = (
徐立's avatar
徐立 committed
3049 3050
              <MobileItem
                isPreview={isPreview}
3051 3052
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
chscls@163.com's avatar
chscls@163.com committed
3053 3054 3055
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
3056
              </MobileItem>
chscls@163.com's avatar
chscls@163.com committed
3057 3058 3059
            );
          }
          break;
徐立's avatar
徐立 committed
3060
        case 'RichText':
chscls@163.com's avatar
chscls@163.com committed
3061
          cm = getFieldDecorator(dataColumn.base52, {
chscls@163.com's avatar
chscls@163.com committed
3062
            initialValue: initValue,
徐立's avatar
徐立 committed
3063 3064 3065
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
3066 3067
                : [{required: required, message: '请输入'}],
          })(<DraftEditorCom placeholder={json.placeholder}/>);
徐立's avatar
徐立 committed
3068 3069 3070 3071 3072 3073
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
chscls@163.com's avatar
chscls@163.com committed
3074
            cm = (
徐立's avatar
徐立 committed
3075 3076
              <MobileItem
                isPreview={isPreview}
3077 3078
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3079 3080 3081
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
3082
              </MobileItem>
3083
            );
徐立's avatar
徐立 committed
3084 3085
          }
          break;
3086 3087 3088 3089 3090 3091
        case 'Cron':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
3092
                : [{required: required, message: '请输入' + title}],
3093
          })(
3094
            <CronEditor style={{width: 600}}/>
3095 3096
          );
          break;
徐立's avatar
徐立 committed
3097 3098 3099
        case 'LocationCom':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: {},
徐立's avatar
徐立 committed
3100 3101 3102
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
3103
                : [{required: required, message: '请进行定位'}],
3104 3105 3106
          })(
            <LocationCom
              get={get}
tb53863844's avatar
tb53863844 committed
3107
              json={json}
3108 3109 3110 3111 3112 3113
              btnName={json.btnName}
              btnSucName={json.btnSucName}
              width={json.width}
              showMap={json.showMap}
            />,
          );
徐立's avatar
徐立 committed
3114 3115 3116 3117 3118 3119
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
3120
            cm = (
徐立's avatar
徐立 committed
3121 3122
              <MobileItem
                isPreview={isPreview}
3123 3124
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3125 3126 3127
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
3128
              </MobileItem>
3129
            );
徐立's avatar
徐立 committed
3130 3131 3132
          }
          break;
        case 'ChildForm':
3133 3134 3135 3136 3137 3138

          // console.log(dataColumn.base52, '----key-ChildForm--'); // KUSyCzEhdCJ
          // console.log(JSON.stringify(this.props.form.getFieldsValue()), '----formValue----');
          // console.log(JSON.stringify(initValue)); // undefined

          cm = getFieldDecorator(dataColumn.base52, {initialValue: initValue || {},})(
3139
            <ChildForm
3140
              taskId={this.props.taskId}
3141
              setRealTimeValues={this.props.setRealTimeValues}
3142
              rights={json.rights || []}
tb53863844's avatar
tb53863844 committed
3143 3144 3145
              hfInstance={this.props.hfInstance}
              getCurrentFormTitle={this.props.getCurrentFormTitle}
              getCellValue={getCellValue}
3146
              isMobile={get === 'mobile'}
tb53863844's avatar
tb53863844 committed
3147
              trees={this.props.trees}
tb53863844's avatar
tb53863844 committed
3148
              fatherObj={obj}
chlolch's avatar
chlolch committed
3149
              isPreview={isPreview}
3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162
              num={json.num}
              min={json.min}
              max={json.max}
              json={json}
              deleteName={json.deleteName}
              addName={json.addName}
              isEdit={isEdit}
              base52={dataColumn.base52}
              mapData={mapData}
              datas={datas ? datas[json.childFormKey] : null}
              defaultValues={defaultValues}
              sqlData={sqlData}
              form={this.props.form}
3163 3164
            />,
          );
徐立's avatar
徐立 committed
3165

徐立's avatar
徐立 committed
3166 3167 3168 3169 3170 3171
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
3172
            cm = (
徐立's avatar
徐立 committed
3173 3174
              <MobileItem
                isPreview={isPreview}
3175 3176
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3177 3178 3179
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
3180
              </MobileItem>
3181
            );
徐立's avatar
徐立 committed
3182 3183 3184
          }
          break;
        case 'ImgUploadCom':
chscls@163.com's avatar
chscls@163.com committed
3185 3186
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
徐立's avatar
徐立 committed
3187 3188 3189
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
3190 3191
                : [{required: required, message: '请上传图片'}],
          })(<ImgUploadCom json={json} disabled={disabled}/>);
徐立's avatar
徐立 committed
3192 3193 3194 3195 3196 3197
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
3198
            cm = (
徐立's avatar
徐立 committed
3199 3200
              <MobileItem
                isPreview={isPreview}
3201 3202
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          break;
        case 'VideoUploadCom':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
3216
                : [{required: required, message: '请上传视频'}],
3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228
          })(<VideoUploadCom json={json}
                             disabled={disabled}
          />);
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
3229 3230
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3231 3232 3233
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
3234
              </MobileItem>
3235
            );
徐立's avatar
徐立 committed
3236 3237 3238 3239 3240
          }
          break;
        case 'Signature':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
徐立's avatar
徐立 committed
3241 3242 3243
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
3244
                : [{required: required, message: '请进行签名'}],
3245 3246 3247 3248
          })(
            <Signature
              width={
                get === 'mobile'
徐立's avatar
徐立 committed
3249
                  ? document.documentElement.clientWidth - 10 || document.body.clientWidth - 10
3250 3251 3252 3253 3254
                  : json.width
              }
              height={json.height}
            />,
          );
徐立's avatar
徐立 committed
3255 3256 3257 3258 3259 3260
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
3261
            cm = (
徐立's avatar
徐立 committed
3262 3263
              <MobileItem
                isPreview={isPreview}
3264 3265
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3266 3267 3268
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
3269
              </MobileItem>
3270
            );
徐立's avatar
徐立 committed
3271 3272 3273
          }
          break;
        case 'Table':
3274 3275
          if (json.objCode == null || json.objCode == '') {
            cm = <></>;
徐立's avatar
徐立 committed
3276
          } else {
3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296
            cm = (
              <>
                {getFieldDecorator(dataColumn.base52 || this.props.uuid, {
                  initialValue: initValue || {},
                })(
                  <TableList
                    json={json}
                    isTree={json.isTree}
                    isHiddenPage={json.isHiddenPage}
                    showHeader={json.showHeader}
                    loading={this.props.loading}
                    pageSize={json.pageSize}
                    objCode={json.objCode}
                    sql={json.filterSql}
                    rights={json.rights}
                    get={get}
                  />,
                )}
              </>
            );
徐立's avatar
徐立 committed
3297 3298 3299 3300 3301 3302 3303
          }
          break;
      }
    }

    if (json.isLabel) {
      if (get === 'mobile' && !this.props.isEdit) {
3304
        return (
3305
          <Card style={{margin: 5, border: '1px solid #ccc'}}>
3306 3307
            {modalCode ? (
              <FormModal
徐立's avatar
徐立 committed
3308
                {...modalProps}
tb53863844's avatar
tb53863844 committed
3309
                visible={this.props.DataColumn.isShowModal[modalCode]}
3310
                handleCancel={this.closeModal.bind(this, modalCode)}
3311 3312 3313
                title={modalTitle}
              >
                <ZdyTable
3314
                  taskId={this.props.taskId}
chscls@163.com's avatar
chscls@163.com committed
3315 3316
                  taskAssignee={taskAssignee}
                  userId={userId}
tb53863844's avatar
tb53863844 committed
3317
                  trees={this.props.trees}
3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334
                  modalInit={modalInit}
                  key={modalCode}
                  datas={datas}
                  get={get}
                  isChild={true}
                  currentFormKey={modalCode}
                  isEdit={isEdit}
                  obj={obj}
                  init={init}
                  form={this.props.form}
                  mapData={mapData}
                  sqlData={sqlData}
                  {...datas[modalCode]}
                  defaultValues={defaultValues}
                />
              </FormModal>
            ) : (
3335 3336
              ''
            )}
3337
            <Card.Header title={<span style={{fontSize: 14}}>{title}:</span>}/>
3338 3339 3340
            <Card.Body>{cm}</Card.Body>
          </Card>
        );
徐立's avatar
徐立 committed
3341 3342
      }
      if (get === 'web') {
3343

3344
        if (!isEdit) {
徐立's avatar
徐立 committed
3345 3346
          return (
            <Row
徐立's avatar
徐立 committed
3347
              style={{
3348 3349
                minHeight: 40,
                lineHeight: '40px',
徐立's avatar
徐立 committed
3350
              }}
3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362
            >
              <Col
                className={title ? styles.row_col_div : ''}
                span={json.labelSpan}
                style={{
                  textAlign: json.labelSpan === 24 ? 'left' : 'right',
                  lineHeight: '40px',
                  whiteSpace: 'nowrap',
                  overflow: 'hidden',
                  fontSize: 14,
                  color: 'rgba(0,0,0,0.85)',
                }}
徐立's avatar
徐立 committed
3363 3364
              >
                {title}
3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384
                {title && (
                  <span
                    style={{
                      position: 'relative',
                      top: '-0.5px',
                      margin: '0 8px 0 2px',
                    }}
                  >
                    :
                  </span>
                )}
              </Col>
              <Col
                span={json.wrapperSpan}
                style={{
                  position: 'relative',
                  lineHeight: '40px',
                  zoom: 1,
                  fontSize: 14,
                }}
徐立's avatar
徐立 committed
3385 3386
              >
                {cm}
3387 3388 3389
              </Col>
              {modalCode ? (
                <FormModal
徐立's avatar
徐立 committed
3390
                  {...modalProps}
tb53863844's avatar
tb53863844 committed
3391
                  visible={this.props.DataColumn.isShowModal[modalCode]}
3392
                  handleCancel={this.closeModal.bind(this, modalCode)}
3393 3394 3395
                  title={modalTitle}
                >
                  <ZdyTable
3396
                    taskId={this.props.taskId}
3397 3398
                    taskAssignee={taskAssignee}
                    userId={userId}
tb53863844's avatar
tb53863844 committed
3399
                    trees={this.props.trees}
3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416
                    modalInit={modalInit}
                    key={modalCode}
                    datas={datas}
                    get={get}
                    isChild={true}
                    currentFormKey={modalCode}
                    isEdit={isEdit}
                    obj={obj}
                    init={init}
                    form={this.props.form}
                    mapData={mapData}
                    sqlData={sqlData}
                    {...datas[modalCode]}
                    defaultValues={defaultValues}
                  />
                </FormModal>
              ) : (
3417 3418
                ''
              )}
3419 3420
            </Row>
          );
徐立's avatar
徐立 committed
3421
        } else {
3422

徐立's avatar
徐立 committed
3423
          return (
3424 3425 3426
            <>
              {modalCode ? (
                <FormModal
徐立's avatar
徐立 committed
3427
                  {...modalProps}
tb53863844's avatar
tb53863844 committed
3428
                  visible={this.props.DataColumn.isShowModal[modalCode]}
3429
                  handleCancel={this.closeModal.bind(this, modalCode)}
3430 3431 3432
                  title={modalTitle}
                >
                  <ZdyTable
3433
                    taskId={this.props.taskId}
3434 3435
                    taskAssignee={taskAssignee}
                    userId={userId}
tb53863844's avatar
tb53863844 committed
3436
                    trees={this.props.trees}
3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453
                    modalInit={modalInit}
                    key={modalCode}
                    datas={datas}
                    get={get}
                    isChild={true}
                    currentFormKey={modalCode}
                    isEdit={isEdit}
                    obj={obj}
                    init={init}
                    form={this.props.form}
                    mapData={mapData}
                    sqlData={sqlData}
                    {...datas[modalCode]}
                    defaultValues={defaultValues}
                  />
                </FormModal>
              ) : (
3454 3455
                ''
              )}
3456
              <Form.Item
3457 3458
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3459 3460 3461 3462 3463 3464
                label={title}
              >
                {cm}
              </Form.Item>
            </>
          );
徐立's avatar
徐立 committed
3465
        }
徐立's avatar
徐立 committed
3466
      } else {
3467 3468 3469 3470
        return (
          <>
            {modalCode ? (
              <FormModal
3471
                {...modalProps}
tb53863844's avatar
tb53863844 committed
3472
                visible={this.props.DataColumn.isShowModal[modalCode]}
3473
                handleCancel={this.closeModal.bind(this, modalCode)}
3474 3475 3476
                title={modalTitle}
              >
                <ZdyTable
3477
                  taskId={this.props.taskId}
3478 3479
                  taskAssignee={taskAssignee}
                  userId={userId}
3480
                  modalInit={modalInit}
tb53863844's avatar
tb53863844 committed
3481
                  trees={this.props.trees}
3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497
                  key={modalCode}
                  datas={datas}
                  get={get}
                  isChild={true}
                  currentFormKey={modalCode}
                  isEdit={isEdit}
                  obj={obj}
                  init={init}
                  form={this.props.form}
                  mapData={mapData}
                  sqlData={sqlData}
                  {...datas[modalCode]}
                  defaultValues={defaultValues}
                />
              </FormModal>
            ) : (
3498 3499
              ''
            )}
3500 3501 3502
            {cm}
          </>
        );
徐立's avatar
徐立 committed
3503 3504
      }
    } else {
chscls@163.com's avatar
chscls@163.com committed
3505
      return (
3506 3507 3508
        <>
          {modalCode ? (
            <FormModal
徐立's avatar
徐立 committed
3509
              {...modalProps}
tb53863844's avatar
tb53863844 committed
3510
              visible={this.props.DataColumn.isShowModal[modalCode]}
3511
              handleCancel={this.closeModal.bind(this, modalCode)}
3512 3513 3514
              title={modalTitle}
            >
              <ZdyTable
3515
                taskId={this.props.taskId}
3516 3517
                taskAssignee={taskAssignee}
                userId={userId}
tb53863844's avatar
tb53863844 committed
3518
                trees={this.props.trees}
3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535
                modalInit={modalInit}
                key={modalCode}
                datas={datas}
                get={get}
                isChild={true}
                currentFormKey={modalCode}
                isEdit={isEdit}
                obj={obj}
                init={init}
                form={this.props.form}
                mapData={mapData}
                sqlData={sqlData}
                {...datas[modalCode]}
                defaultValues={defaultValues}
              />
            </FormModal>
          ) : (
3536 3537
            ''
          )}
3538
          {json.isMobileLabel && !isEdit && get == 'mobile' ? (
徐立's avatar
徐立 committed
3539 3540
            <MobileItem
              isPreview={isPreview}
3541 3542
              labelCol={{span: json.labelSpan}}
              wrapperCol={{span: json.wrapperSpan}}
3543 3544 3545 3546
              label={title}
            >
              {cm}
            </MobileItem>
徐立's avatar
徐立 committed
3547 3548 3549
          ) : isEdit && get == 'web' ? (
            json.isLabel ? (
              <Form.Item
3550 3551
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
徐立's avatar
徐立 committed
3552 3553
                label={title}
              >
chlolch's avatar
chlolch committed
3554
                {cm}
徐立's avatar
徐立 committed
3555 3556
              </Form.Item>
            ) : (
3557 3558
              <Form.Item>{cm}</Form.Item>
            )
徐立's avatar
徐立 committed
3559
          ) : (
3560 3561
            cm
          )}
3562
        </>
chscls@163.com's avatar
chscls@163.com committed
3563
      );
徐立's avatar
徐立 committed
3564 3565 3566
    }
  }
}