index.jsx 109.2 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 24 25 26
import {
  message,
  Icon,
  Input,
  InputNumber,
  Button,
  Checkbox,
  DatePicker,
  Radio,
  Switch,
  Modal,
  TimePicker,
  Row,
  Col,
  Select,
  Upload,
  Form,
  Table,
tb53863844's avatar
tb53863844 committed
27
  Cascader,
徐立's avatar
徐立 committed
28
} from 'antd';
chscls@163.com's avatar
chscls@163.com committed
29
import UUID from 'react-native-uuid';
徐立's avatar
徐立 committed
30
import QRCode from 'qrcode.react';
31
import {EditorState, Editor} from 'draft-js';
徐立's avatar
徐立 committed
32
import MyBlockRenderer from '../App/MyBlockRender';
tb53863844's avatar
tb53863844 committed
33
import CronEditor from 'antd-cron-editor';
徐立's avatar
徐立 committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
import {
  InputItem as MobileInputItem,
  ImagePicker as MobileImagePicker,
  Modal as MobileModal,
  DatePicker as MobileDatePicker,
  List as MobileList,
  Picker as MobilePicker,
  Flex,
  Card,
  Toast,
  Checkbox as MobileCheckbox,
  TextareaItem as MobileTextareaItem,
  Switch as MobileSwitch,
} from 'antd-mobile';
import ReactEcharts from 'echarts-for-react';
49
import ZdyTable from '../Table/index';
50
import {connect} from 'dva';
徐立's avatar
徐立 committed
51 52
import UploadCom from '../libs/UploadCom';
import TableSelect from '../libs/TableSelect';
53
import LocationCom from '../libs/LocationCom';
徐立's avatar
徐立 committed
54 55
import MobileDate from '../libs/MobileDate';
import ChildForm from '../libs/ChildForm';
tb53863844's avatar
tb53863844 committed
56
import Neo4jD3Com from '../libs/Neo4jD3Com';
chscls@163.com's avatar
chscls@163.com committed
57
import ImgUploadCom from '../libs/ImgUploadCom';
58
import VideoUploadCom from '../libs/VideoUploadCom';
徐立's avatar
徐立 committed
59 60 61 62
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
63
import config from '@/webPublic/one_stop_public/config';
64 65 66
import {isEmpty, isNaN, cloneDeep} from 'lodash';
import {queryApiActionPath} from '../utils/queryConfig';
import {extend} from 'umi-request';
徐立's avatar
徐立 committed
67
import Highlighter from 'react-highlight-words';
徐立's avatar
徐立 committed
68
import Signature from '../Signature';
69
import {changeToDraftState} from '../utils/myutils';
70
import baseX from 'base-x';
71 72 73
import {Base16Encode} from '../Base16/index';
import {getToken} from '../utils/token';
import {formulaList} from '../excelInitFuc/functionList';
徐立's avatar
徐立 committed
74
import FilePreview from '../filePreview';
chscls@163.com's avatar
chscls@163.com committed
75
import DraftEditorCom from '../App/DraftEditorCom';
徐立's avatar
徐立 committed
76
import MobileItem from './MobileItem';
77

78 79
const Bs64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const base64 = baseX(Bs64);
80

wanyielin's avatar
wanyielin committed
81 82
function getBase64(value) {
  return value ? base64.encode(new Buffer(value)) : null;
徐立's avatar
徐立 committed
83
}
84

徐立's avatar
徐立 committed
85 86 87 88 89 90
const codeMessage = {
  200: '服务器成功返回请求的数据。',
  201: '新建或修改数据成功。',
  202: '一个请求已经进入后台排队(异步任务)。',
  204: '删除数据成功。',
  400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
chscls@163.com's avatar
chscls@163.com committed
91
  401: '登录已过期,请重新登录',
徐立's avatar
徐立 committed
92 93 94 95 96 97 98 99 100 101
  403: '用户得到授权,但是访问是被禁止的。',
  404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
  406: '请求的格式不可得。',
  410: '请求的资源被永久删除,且不会再得到的。',
  422: '当创建一个对象时,发生一个验证错误。',
  500: '服务器发生错误,请检查服务器。',
  502: '网关错误。',
  503: '服务不可用,服务器暂时过载或维护。',
  504: '网关超时。',
};
102 103 104 105
const {TextArea} = Input;
const {Option} = Select;
const must = <span style={{color: '#FF5350', marginLeft: 5, marginRight: 5}}>*</span>;
const {MonthPicker, RangePicker} = DatePicker;
徐立's avatar
徐立 committed
106 107
const AgreeItem = MobileCheckbox.AgreeItem;
const errorHandler = error => {
108
  const {response} = error;
徐立's avatar
徐立 committed
109

徐立's avatar
徐立 committed
110 111
  if (response && response.status) {
    const errorText = codeMessage[response.status] || response.statusText;
徐立's avatar
徐立 committed
112

113
    message.error(`请求错误${errorText}`);
chscls@163.com's avatar
chscls@163.com committed
114 115 116 117 118
    if (response.status === 401) {
      return window.g_app._store.dispatch({
        type: 'login/loginout',
      });
    }
徐立's avatar
徐立 committed
119
  } else {
120
    message.error(`网络故障,请检查网络链接或联系管理员`);
徐立's avatar
徐立 committed
121 122 123
  }
};

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

167
    const {dispatch} = this.props;
tb53863844's avatar
tb53863844 committed
168
    const x = this.props.DataColumn.isShowModal
169
    x[fk] = true
170 171
    dispatch({
      type: 'DataColumn/showModal',
172
      payload: {isShowModal: x},
173
      callback: () => {
徐立's avatar
徐立 committed
174 175 176 177 178 179
        this.setState({
          modalInit: data,
          modalTitle: title,
          modalCode: fk,
          modalProps: modalProps,
        });
180 181 182
      },
    });
  };
徐立's avatar
徐立 committed
183

184
  equal = (obj1, obj2, json, sqlContent, depth) => {
徐立's avatar
徐立 committed
185
    if (obj1 == null && obj2 != null) {
186
      return false;
徐立's avatar
徐立 committed
187 188
    }
    if (obj1 != null && obj2 == null) {
189
      return false;
徐立's avatar
徐立 committed
190 191
    }
    if (obj1 == null && obj2 == null) {
192
      return true;
徐立's avatar
徐立 committed
193 194 195 196
    }

    if (obj1 instanceof Date) {
      if (obj1.valueOf() != obj2.valueOf()) {
197
        return false;
徐立's avatar
徐立 committed
198 199 200
      }
    } else if (obj1 instanceof moment) {
      if (obj1.valueOf() != obj2.valueOf()) {
201
        return false;
徐立's avatar
徐立 committed
202 203 204
      }
    } else if (typeof obj1 == 'function') {
      if (obj1.toString() != obj2.toString()) {
205
        return false;
徐立's avatar
徐立 committed
206 207 208
      }
    }

209
    const keys = new Set();
徐立's avatar
徐立 committed
210
    if (obj2 != null) {
211 212 213
      Object.keys(obj2).forEach(k => {
        if (k != '') keys.add(k);
      });
徐立's avatar
徐立 committed
214 215
    }
    if (obj1 != null) {
216 217 218
      Object.keys(obj1).forEach(k => {
        if (k != '') keys.add(k);
      });
徐立's avatar
徐立 committed
219 220
    }

221
    let res = true;
徐立's avatar
徐立 committed
222 223

    for (let key of keys) {
224 225
      if (key == '') {
        continue;
徐立's avatar
徐立 committed
226
      }
徐立's avatar
徐立 committed
227

徐立's avatar
徐立 committed
228
      if (this.excludeKeys.includes(key)) {
229
        continue;
徐立's avatar
徐立 committed
230 231 232
      }

      if (obj1[key] == null && obj2[key] != null) {
233
        res = false;
徐立's avatar
徐立 committed
234 235 236
        break;
      }
      if (obj1[key] != null && obj2[key] == null) {
237
        res = false;
徐立's avatar
徐立 committed
238 239
        break;
      }
徐立's avatar
徐立 committed
240

241 242 243 244 245 246 247 248 249
      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
250 251
            json.funcs != null &&
            json.funcs.indexOf(key) == -1))
252 253 254 255
      ) {
        this.excludeKeys.push(key);

        continue;
徐立's avatar
徐立 committed
256 257 258
      }

      if (obj1[key] == null && obj2[key] == null) {
259
        continue;
徐立's avatar
徐立 committed
260 261
      }
      if (isNaN(obj1[key]) && isNaN(obj2[key])) {
262
        continue;
徐立's avatar
徐立 committed
263 264 265 266 267 268 269 270 271
      }
      /*  if (this.typeOf(obj1[key]) != this.typeOf(obj1[key])) {

         res = false
         break;
       } */

      if (obj1[key] instanceof Array) {
        if (obj1[key].length != obj2[key].length) {
272
          res = false;
徐立's avatar
徐立 committed
273 274
          break;
        } else {
275
          var xx = true;
徐立's avatar
徐立 committed
276 277

          for (var i = 0; i < obj1[key].length; i++) {
chscls@163.com's avatar
chscls@163.com committed
278
            if (!this.equal(obj1[key][i], obj2[key][i], json, sqlContent, depth + 1)) {
279
              xx = false;
徐立's avatar
徐立 committed
280 281 282 283 284
              break;
            }
          }

          if (!xx) {
285
            res = false;
徐立's avatar
徐立 committed
286 287 288 289
            break;
          }
        }
      } else if (obj1[key] instanceof Object) {
290
        const x = this.equal(obj1[key], obj2[key], json, sqlContent, depth + 1);
徐立's avatar
徐立 committed
291 292

        if (!x) {
293
          res = false;
徐立's avatar
徐立 committed
294 295
          break;
        }
296
      } else if (typeof obj1[key] == 'function') {
徐立's avatar
徐立 committed
297
        if (obj1[key].toString() != obj2[key].toString()) {
298
          res = false;
徐立's avatar
徐立 committed
299 300 301 302
          break;
        }
      } else {
        if (obj1[key] != obj2[key]) {
303
          res = false;
徐立's avatar
徐立 committed
304 305 306 307 308 309 310 311
          break;
        }
      }
    }

    return res;
  };

wanyielin's avatar
wanyielin committed
312
  getRender = (com, props) => {
chscls@163.com's avatar
chscls@163.com committed
313 314 315 316
    if (com == 'p') return <p {...props} />;
    if (com == 'ul') return <ul {...props} />;
    if (com == 'li') return <li {...props} />;
    if (com == 'video') return <video {...props} />;
317 318 319 320 321 322 323 324 325
    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
326 327
          ? props.src
          : config.httpServer + props.src
328
          : null;
329
      const pp = {...props, src: src};
330
      return <img {...pp} />;
徐立's avatar
徐立 committed
331
    }
332
  };
徐立's avatar
徐立 committed
333

徐立's avatar
徐立 committed
334 335 336
  /**
   * 判断传入值是否为JSON文本
   */
337
  isJSON = str => {
徐立's avatar
徐立 committed
338 339 340 341 342 343 344 345 346 347 348 349 350
    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
351

352
  };
徐立's avatar
徐立 committed
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
  /**
   * 上传文件输入
   * 使用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();
378
    this.setState({searchText: selectedKeys[0]});
徐立's avatar
徐立 committed
379 380 381 382
  };

  handleReset = clearFilters => {
    clearFilters();
383 384 385 386 387 388 389
    this.resetSearchText();
  };

  resetSearchText = () => {
    this.setState({
      searchText: '',
    });
徐立's avatar
徐立 committed
390 391 392
  };

  getColumnSearchProps = (dataIndex, title) => ({
393 394
    filterDropdown: ({setSelectedKeys, selectedKeys, confirm, clearFilters}) => (
      <div style={{padding: 8}}>
徐立's avatar
徐立 committed
395 396 397 398 399 400 401 402
        <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)}
403
          style={{width: 188, marginBottom: 8, display: 'block'}}
徐立's avatar
徐立 committed
404 405 406 407 408 409 410
        />
        <Button
          type="primary"
          onClick={() => this.handleSearch(selectedKeys, confirm)}
          icon="search"
          loading={this.props.loading}
          size="small"
411
          style={{width: 90, marginRight: 8}}
徐立's avatar
徐立 committed
412 413 414
        >
          搜索
        </Button>
415 416 417 418
        <Button
          loading={this.props.loading}
          onClick={() => this.handleReset(clearFilters)}
          size="small"
419
          style={{width: 90}}
420
        >
徐立's avatar
徐立 committed
421 422 423 424
          重置
        </Button>
      </div>
    ),
425
    filterIcon: filtered => <Icon type="search" style={{color: filtered ? '#1890ff' : 'red'}}/>,
426
    onFilter: (value, record) =>
徐立's avatar
徐立 committed
427
      record[dataIndex]
428
        ? record[dataIndex]
tb53863844's avatar
tb53863844 committed
429 430 431
          .toString()
          .toLowerCase()
          .includes(value.toLowerCase())
432
        : '',
徐立's avatar
徐立 committed
433 434 435 436 437 438 439
    onFilterDropdownVisibleChange: visible => {
      if (visible) {
        setTimeout(() => this.searchInput.select());
      }
    },
    render: text => {
      if (text != null) {
440 441
        return (
          <Highlighter
442
            highlightStyle={{backgroundColor: '#ffc069', padding: 0}}
443 444 445 446 447
            searchWords={[this.state.searchText]}
            autoEscape
            textToHighlight={text.toString()}
          />
        );
徐立's avatar
徐立 committed
448
      } else {
449
        return '';
徐立's avatar
徐立 committed
450 451 452
      }
    },
  });
453 454 455 456 457 458 459 460 461 462 463 464
  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
465
  }
466

徐立's avatar
徐立 committed
467
  componentWillReceiveProps(props) {
468
    const {json, mapData, obj} = props;
469
    if (json == null || this.props.safe) {
徐立's avatar
徐立 committed
470 471
      return;
    }
472 473 474 475
    if (
      !(this.dataFilter.includes(json.comName) || json.comName == 'TableSelect') &&
      json.isFormulaOnce
    ) {
徐立's avatar
徐立 committed
476 477
      return;
    }
478 479 480 481 482 483 484
    if (
      !(
        this.dataFilter.includes(json.comName) ||
        json.comName == 'TableSelect' ||
        (json.formula != null && json.formula != '')
      )
    ) {
徐立's avatar
徐立 committed
485 486
      return;
    }
487 488 489 490
    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
491 492 493
    if (props.fatherCode) {
      if (obj2 != null && obj2[props.fatherCode]) {
        childObj2 = obj2[props.fatherCode][props.index];
徐立's avatar
徐立 committed
494

495
        bb2 = this.equal(this.childObj, childObj2, json, this.state.sqlContent, 1);
徐立's avatar
徐立 committed
496 497 498 499
      }
    }

    if (!(bb && bb2)) {
500
      const now = new Date().valueOf();
徐立's avatar
徐立 committed
501 502 503 504 505 506 507 508 509 510 511

      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) {
512
        this.count.splice(0, j);
徐立's avatar
徐立 committed
513 514
      }
      if (this.count.length > 10) {
515
        console.log(
tb53863844's avatar
tb53863844 committed
516
          `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
517
          1}列:存在循环风险,1秒内执行超过10次,现已停止执行,请检查,`,
518
        );
徐立's avatar
徐立 committed
519 520 521 522

        return;
      }
      if (!bb) {
523
        this.obj = cloneDeep(obj2);
徐立's avatar
徐立 committed
524 525
      }
      if (!bb2) {
526
        this.childObj = cloneDeep(childObj2);
徐立's avatar
徐立 committed
527
      }
528
      this.count.push(now);
徐立's avatar
徐立 committed
529
    } else {
530
      return;
徐立's avatar
徐立 committed
531 532
    }

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

535 536 537
    let dataColumn =
      this.props.fatherCode != null
        ? bindObj
538 539 540 541
        ? {
          ...bindObj,
          base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
        }
542
        : {base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`}
543 544
        : bindObj;
    if (this.props.fatherCode == null && dataColumn == null)
545
      dataColumn = {base52: this.props.uuid};
546

wanyielin's avatar
wanyielin committed
547 548
    if (!this.props.isEdit && this.props.fatherCode) {
      if (bindObj != null) {
549
        dataColumn.base52 = bindObj.base52;
wanyielin's avatar
wanyielin committed
550
      } else {
551
        dataColumn.base52 = this.props.uuid;
chscls@163.com's avatar
chscls@163.com committed
552
      }
wanyielin's avatar
wanyielin committed
553 554
    }

555 556 557 558 559 560 561
    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
562
    }
563 564
    if (json.formula != null && json.formula != '' && !json.isFormulaOnce) {
      this.getFunctionValue(json.formula, dataColumn, json);
徐立's avatar
徐立 committed
565 566
    }
  }
567

568
  dataFilter = ['Select', 'Radio', 'Checkbox', 'Cascader'];
徐立's avatar
徐立 committed
569 570

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

572 573
    const allValues = JSON.stringify(obj);
    if (json.comName == 'TableSelect') {
574 575
      const {dispatch} = this.props;
      const {sqlKey, optionType} = json;
576
      if (optionType == 'sql') {
徐立's avatar
徐立 committed
577 578
        dispatch({
          type: 'SqlManageEntity/find',
579
          payload: {sqlKey: sqlKey},
徐立's avatar
徐立 committed
580
          callback: sqlModel => {
581
            this.setState({sqlModel});
徐立's avatar
徐立 committed
582 583 584
            if (sqlModel.dataObjId) {
              dispatch({
                type: 'formList/getHead',
585
                payload: {dataObjId: sqlModel.dataObjId},
徐立's avatar
徐立 committed
586 587
                callback: datas => {
                  if (datas) {
588
                    const columns = [];
徐立's avatar
徐立 committed
589 590 591 592 593
                    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;
594 595 596 597
                        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
598 599 600
                        }
                        columns.push(column);
                      } else {
601
                        break;
徐立's avatar
徐立 committed
602 603
                      }
                    }
604
                    this.setState({columns});
徐立's avatar
徐立 committed
605
                  }
606 607
                },
              });
徐立's avatar
徐立 committed
608
            } else {
609
              const cols = sqlModel.cols;
徐立's avatar
徐立 committed
610
              if (cols != null || cols.length > 0) {
611 612
                const columns = [];
                const cll = JSON.parse(cols);
徐立's avatar
徐立 committed
613 614 615 616 617
                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)) {
618
                    var ff = 'YYYY-MM-DD HH:mm:ss';
徐立's avatar
徐立 committed
619
                    switch (cll[k].type) {
620 621 622 623 624 625 626 627 628
                      case 'DATE':
                        ff = 'YYYY-MM-DD';
                        break;
                      case 'YEAR':
                        ff = 'YYYY';
                        break;
                      case 'TIME':
                        ff = 'HH:mm:ss';
                        break;
徐立's avatar
徐立 committed
629 630
                    }

631
                    column.render = val => moment(parseInt(val)).format(ff);
徐立's avatar
徐立 committed
632 633 634 635 636
                  }
                  if (cll[k].isQuery) {
                    column = {
                      ...this.getColumnSearchProps(cll[k].name, cll[k].title),
                      ...column,
637
                    };
徐立's avatar
徐立 committed
638 639 640 641
                  }

                  columns.push(column);
                }
642
                this.setState({columns});
徐立's avatar
徐立 committed
643 644 645 646
              }

              dispatch({
                type: 'DataColumn/getSqlData',
647
                payload: {sqlKey, allValues},
徐立's avatar
徐立 committed
648 649 650
                callback: list => {
                  const x = {
                    list: list,
651 652
                    pagination: false,
                  };
653
                  this.setState({dataSource: x});
654 655
                },
              });
徐立's avatar
徐立 committed
656
            }
657 658 659
          },
        });
      } else if (optionType == 'reference' && dataColumn.referenceObjId) {
徐立's avatar
徐立 committed
660 661
        dispatch({
          type: 'formList/getHead',
662
          payload: {dataObjId: dataColumn.referenceObjId},
徐立's avatar
徐立 committed
663 664
          callback: datas => {
            if (datas) {
665
              const columns = [];
徐立's avatar
徐立 committed
666 667 668 669 670 671
              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)) {
672
                    column.render = val => moment(val).format('YYYY-MM-DD HH:mm:ss');
徐立's avatar
徐立 committed
673 674 675
                  }
                  columns.push(column);
                } else {
676
                  break;
徐立's avatar
徐立 committed
677 678
                }
              }
679
              this.setState({columns});
徐立's avatar
徐立 committed
680
            }
681 682
          },
        });
徐立's avatar
徐立 committed
683 684
      }
    }
685

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

徐立's avatar
徐立 committed
688
      switch (json.optionType) {
689
        case 'reference':
徐立's avatar
徐立 committed
690
          if (dataColumn.referenceObjId != null) {
691
            this.fetchData(obj, dataColumn, init, json.filterSql, allValues);
徐立's avatar
徐立 committed
692 693
          }
          break;
694 695
        case 'enum':
          if (json.enums != null && json.enums != '') {
徐立's avatar
徐立 committed
696 697
            var enu;
            try {
698
              enu = JSON.parse(json.enums);
徐立's avatar
徐立 committed
699
            } catch (e) {
700 701
              message.error('枚举json格式存在问题');
              enu = [];
徐立's avatar
徐立 committed
702 703
            }

704
            this.changeEnum(obj, dataColumn, enu);
徐立's avatar
徐立 committed
705 706
          }
          break;
707 708 709 710 711 712 713 714 715 716 717
        case 'sql':
          if (json.sqlKey != null && json.sqlKey != '') {
            this.fetchData3(
              obj,
              dataColumn,
              init,
              json.sqlKey,
              json.labelName,
              json.valueName,
              allValues,
            );
徐立's avatar
徐立 committed
718 719
          }
          break;
720 721
        case 'func':
          if (json.funcs != null && json.funcs != '') {
722
            if (json.comName == "Cascader") {
tb53863844's avatar
tb53863844 committed
723 724 725 726 727 728
              try {
                this.getFunctionValue(json.funcs, {base52: this.props.uuid}, json, () => {
                  if (init != null && Object.keys(init).length > 0) {
                    let base52 = dataColumn.base52;
                    let vlu = this.props.form.getFieldValue(base52);
                    const labs = [];
729 730
                    this.searchJson(vlu, this.state.options, 0, labs)

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

tb53863844's avatar
tb53863844 committed
735
                    const vlu = obj[base52];
736

tb53863844's avatar
tb53863844 committed
737
                    const labs = [];
738
                    this.searchJson(vlu, this.state.options, 0, labs)
tb53863844's avatar
tb53863844 committed
739 740 741 742 743 744
                    this.setState({labels: labs});
                  }
                });
              } catch (e) {
                message.error('公式选项配置存在问题');
              }
745
            } else {
tb53863844's avatar
tb53863844 committed
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
              try {
                this.getFunctionValue(json.funcs, {base52: this.props.uuid}, json, () => {
                  if (init != null && Object.keys(init).length > 0) {
                    let base52 = dataColumn.base52;
                    let vlu = this.props.form.getFieldValue(base52);
                    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
764 765
                      }
                    }
766

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

tb53863844's avatar
tb53863844 committed
771
                    const vlu = obj[base52];
772

tb53863844's avatar
tb53863844 committed
773 774 775 776 777 778 779 780 781 782 783 784 785
                    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
786 787
                      }
                    }
788

tb53863844's avatar
tb53863844 committed
789
                    this.setState({labels: labs});
chscls@163.com's avatar
chscls@163.com committed
790
                  }
tb53863844's avatar
tb53863844 committed
791 792 793 794
                });
              } catch (e) {
                message.error('公式选项配置存在问题');
              }
wanyielin's avatar
wanyielin committed
795

796
            }
wanyielin's avatar
wanyielin committed
797 798


徐立's avatar
徐立 committed
799 800 801 802
          }
          break;
      }
    }
803
  };
徐立's avatar
徐立 committed
804 805 806

  setValues = (base52, json, values) => {
    try {
807
      this.props.form.setFieldsValue(values);
徐立's avatar
徐立 committed
808
    } catch (e) {
809
      console.log(
tb53863844's avatar
tb53863844 committed
810
        `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
811
        1}列:公式配置有误,回调函数内部错误,`,
812 813
        e,
      );
徐立's avatar
徐立 committed
814
    }
815 816 817 818
    if (!this.props.isEdit) {


      if (this.props.setRealTimeValues) {
tb53863844's avatar
tb53863844 committed
819 820
        this.props.setRealTimeValues(values)
      }
821

tb53863844's avatar
tb53863844 committed
822
    }
823

824
  };
wanyielin's avatar
wanyielin committed
825
  reqUtil = (base52, json, orgCallback, url, method, params, callback, options = {}) => {
徐立's avatar
徐立 committed
826
    //查缓存
chscls@163.com's avatar
chscls@163.com committed
827
    var isChange = true;
828 829
    if (url.indexOf('http') === -1) {
      url = config.httpServer + url;
徐立's avatar
徐立 committed
830
    }
831
    const {reqUrls} = this.state;
徐立's avatar
徐立 committed
832
    if (reqUrls[url] != null) {
833
      const ps = reqUrls[url].params;
徐立's avatar
徐立 committed
834 835

      if (Object.keys(params).length != Object.keys(ps).length) {
836
        isChange = true;
徐立's avatar
徐立 committed
837 838 839
      } else {
        for (var key in params) {
          if (params[key] == null && ps[key] != null) {
840
            isChange = true;
徐立's avatar
徐立 committed
841 842
            break;
          } else if (params[key] != null && ps[key] == null) {
843
            isChange = true;
徐立's avatar
徐立 committed
844 845 846
            break;
          } else {
            if (params[key] != ps[key]) {
847 848
              isChange = true;
              break;
徐立's avatar
徐立 committed
849 850 851 852 853
            }
          }
        }
      }
    } else {
854
      reqUrls[url] = {params: params};
855
      isChange = true;
徐立's avatar
徐立 committed
856
    }
857

徐立's avatar
徐立 committed
858 859
    if (!isChange) {
      if (callback) {
860
        const data = reqUrls[url].data;
徐立's avatar
徐立 committed
861

862 863
        if (json.optionType && json.optionType == 'func') {
          const res = callback(data);
徐立's avatar
徐立 committed
864

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

    for (let i in params) {
      if (params[i] == null) {
        delete params[i];
徐立's avatar
徐立 committed
915
      }
tb53863844's avatar
tb53863844 committed
916
    }
917

tb53863844's avatar
tb53863844 committed
918 919 920
    if (getToken() != null) {
      params.token = getToken();
    }
徐立's avatar
徐立 committed
921

tb53863844's avatar
tb53863844 committed
922 923 924 925 926 927 928 929 930 931 932 933
    const requestParams = params;
    const umiRequest = extend({
      errorHandler, // 默认错误处理
      credentials: 'omit', // 默认请求是否带上cookie
      mode: 'cors',
      ...options,
    });
    umiRequest(url, {
      data: requestParams,
      method: method,
      requestType: 'form',
    }).then(data => {
934
      const {reqUrls} = this.state;
tb53863844's avatar
tb53863844 committed
935
      reqUrls[url].data = data;
936
      this.setState({res: data, reqUrls}, () => {
tb53863844's avatar
tb53863844 committed
937 938 939 940 941
        if (callback) {
          if (json.optionType && json.optionType == 'func') {
            const res = callback(data);

            if (res != null && !(typeof res === 'function')) {
942
              this.setState({options: res, selectDis: false}, () => {
tb53863844's avatar
tb53863844 committed
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
                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) {
960
                this.setState({option: x});
徐立's avatar
徐立 committed
961
              }
tb53863844's avatar
tb53863844 committed
962 963 964 965 966 967 968 969 970
            } 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
971
              try {
972
                const x = callback(data);
973
                if (x == null || x != 'NaN') this.props.form.setFieldsValue({[base52]: x});
徐立's avatar
徐立 committed
974
              } catch (e) {
975
                console.log(
tb53863844's avatar
tb53863844 committed
976
                  `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
977
                  1}列:公式配置有误,回调函数内部错误,`,
978 979
                  e,
                );
徐立's avatar
徐立 committed
980 981 982
              }
            }
          }
tb53863844's avatar
tb53863844 committed
983
        }
984 985
      });
    });
徐立's avatar
徐立 committed
986

tb53863844's avatar
tb53863844 committed
987

988 989
    return 'norefeshxxxxxxxxxxxxxxxxxxxx';
  };
wanyielin's avatar
wanyielin committed
990
  sqlUtil = (base52, json, orgCallback, sqlKey, params, callback, options = {}) => {
徐立's avatar
徐立 committed
991 992
    //查缓存
    var isChange = false;
993
    const {sqlKeys} = this.state;
徐立's avatar
徐立 committed
994 995

    if (sqlKeys[sqlKey] != null) {
996
      const ps = sqlKeys[sqlKey].params;
徐立's avatar
徐立 committed
997 998

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

tb53863844's avatar
tb53863844 committed
1078

1079
    const url = queryApiActionPath() + '/DataColumnApi/getSqlData';
1080
    this.setState({sqlKeys}, () => {
tb53863844's avatar
tb53863844 committed
1081 1082
      const umiRequest = extend({
        errorHandler, // 默认错误处理
tb53863844's avatar
tb53863844 committed
1083 1084
        credentials: options.credentials || 'omit', // 默认请求是否带上cookie
        mode: options.mode || 'cors'
tb53863844's avatar
tb53863844 committed
1085 1086 1087 1088 1089 1090 1091
      });
      const allValues = JSON.stringify({
        ...this.props.obj,
        ...this.props.form.getFieldsValue(),
        ...this.props.defaultValues[this.props.formKey],
        ...options
      });
1092
      const pp = {sqlKey: Base16Encode(sqlKey), params, allValues: Base16Encode(allValues)};
wanyielin's avatar
wanyielin committed
1093
      if (getToken() != null) {
1094
        pp.token = getToken();
徐立's avatar
徐立 committed
1095
      }
tb53863844's avatar
tb53863844 committed
1096

徐立's avatar
徐立 committed
1097
      umiRequest(url, {
wanyielin's avatar
wanyielin committed
1098
        data: pp,
徐立's avatar
徐立 committed
1099
        method: 'POST',
1100
        requestType: 'form',
徐立's avatar
徐立 committed
1101
      }).then(data => {
1102
        const {sqlKeys} = this.state;
1103
        sqlKeys[sqlKey].data = data;
1104
        this.setState({sqlKeys});
徐立's avatar
徐立 committed
1105
        if (data == null) {
1106
          return;
徐立's avatar
徐立 committed
1107 1108 1109
        }

        if (callback) {
1110 1111
          if (json.optionType && json.optionType == 'func') {
            const res = callback(data);
徐立's avatar
徐立 committed
1112

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

1159 1160
    return 'norefeshxxxxxxxxxxxxxxxxxxxx';
  };
徐立's avatar
徐立 committed
1161

wanyielin's avatar
wanyielin committed
1162
  getFunctionValue = (fun, column, json, callback) => {
tb53863844's avatar
tb53863844 committed
1163
    if (this.props.safe) return
1164 1165
    const base52 = column.base52;

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

1194 1195 1196 1197 1198 1199
      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
1200
      } else {
1201
        obj = {
tb53863844's avatar
tb53863844 committed
1202
          ...(this.props.fatherObj ? this.props.fatherObj : {}),
1203 1204 1205 1206
          ...this.props.obj,
          ...this.props.form.getFieldsValue(),
          ...this.props.defaultValues[this.props.formKey],
        };
chscls@163.com's avatar
chscls@163.com committed
1207
      }
1208

1209 1210 1211 1212 1213
      const value = fun1(
        obj,
        this.props.init,
        this.props.modalInit,
        this.props.defaultValues,
徐立's avatar
徐立 committed
1214 1215 1216 1217 1218
        {
          clientType: this.props.get,
          formCode: this.props.formCode,
          formId: this.props.formId,
          isEdit: this.props.isEdit,
1219 1220
          taskAssignee: this.props.taskAssignee,
          userId: this.props.userId,
徐立's avatar
徐立 committed
1221
        },
1222 1223
        this.props.index,
        this.props.fatherCode,
wanyielin's avatar
wanyielin committed
1224
        {
徐立's avatar
徐立 committed
1225
          moment: moment,
wanyielin's avatar
wanyielin committed
1226
          sql: this.sqlUtil.bind(this, base52, json, callback),
1227
          message: message,
tb53863844's avatar
tb53863844 committed
1228
          importExcel: this.props.importExcel,
1229
          router: router,
徐立's avatar
徐立 committed
1230
          uuid: UUID,
徐立's avatar
徐立 committed
1231
          setValues: this.setValues.bind(this, base52, json),
wanyielin's avatar
wanyielin committed
1232
          req: this.reqUtil.bind(this, base52, json, callback),
1233 1234 1235 1236 1237
          md5: md5,
          showModal: this.showModal,
          closeModal: this.closeModal,
          render: this.getRender,
          base64: getBase64,
1238
          form: this.props.form,
徐立's avatar
徐立 committed
1239
        },
徐立's avatar
徐立 committed
1240
        functionObj,
1241 1242
        this.props.routerState,
        this.props.messageData,
1243 1244 1245 1246
        this.props.concealModel,
      );
      if (base52) {
        if (value != null && value == 'norefeshxxxxxxxxxxxxxxxxxxxx') {
徐立's avatar
徐立 committed
1247 1248 1249 1250 1251
        } else {
          /**
           * 会出现重复调用2次,然后NAN造成无限循环
           */
          if (isNaN(value)) {
1252
            return;
徐立's avatar
徐立 committed
1253
          }
1254 1255 1256 1257
          if (json.comName == 'Button') {
            return value;
          } else if (json.optionType && json.optionType == 'func') {
            if (value != null && !(typeof value === 'function')) {
1258
              this.setState({options: value, selectDis: false}, () => {
1259
                if (callback) callback();
chscls@163.com's avatar
chscls@163.com committed
1260
              });
chscls@163.com's avatar
chscls@163.com committed
1261
            }
tb53863844's avatar
tb53863844 committed
1262
          } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
1263
            this.setState({option: value});
徐立's avatar
徐立 committed
1264 1265
          } else {
            try {
1266
              this.props.form.setFieldsValue({[base52]: value});
1267 1268
            } catch {
              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 1276 1277
            }
          }
        }
      }
    } catch (e) {
1278
      console.log(
tb53863844's avatar
tb53863844 committed
1279
        `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}${this.props.i + 1}行,第${this.props.j +
tb53863844's avatar
tb53863844 committed
1280
        1}列:公式配置有误,暂存失败,`,
1281 1282
        e,
      );
徐立's avatar
徐立 committed
1283
    }
1284
  };
1285

徐立's avatar
徐立 committed
1286
  componentDidMount() {
1287
    const {json, mapData, obj, init} = this.props;
徐立's avatar
徐立 committed
1288
    if (json == null) {
1289
      return;
徐立's avatar
徐立 committed
1290
    }
1291
    if (json.sqlKey != null && json.sqlKey != '') {
1292
      const {dispatch} = this.props;
徐立's avatar
徐立 committed
1293 1294
      dispatch({
        type: 'SqlManageEntity/find',
1295
        payload: {sqlKey: json.sqlKey},
徐立's avatar
徐立 committed
1296
        callback: res => {
1297
          this.setState({sqlContent: res.sql});
1298 1299 1300
        },
      });
    }
徐立's avatar
徐立 committed
1301

wanyielin's avatar
wanyielin committed
1302 1303
    const bindObj = this.getColumn('c1');

1304 1305 1306
    let dataColumn =
      this.props.fatherCode != null
        ? bindObj
1307 1308 1309 1310
        ? {
          ...bindObj,
          base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
        }
1311
        : {base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`}
1312 1313
        : bindObj;
    if (this.props.fatherCode == null && dataColumn == null)
1314
      dataColumn = {base52: this.props.uuid};
徐立's avatar
徐立 committed
1315

wanyielin's avatar
wanyielin committed
1316 1317
    if (!this.props.isEdit && this.props.fatherCode) {
      if (bindObj != null) {
1318
        dataColumn.base52 = bindObj.base52;
wanyielin's avatar
wanyielin committed
1319
      } else {
1320
        dataColumn.base52 = this.props.uuid;
徐立's avatar
徐立 committed
1321 1322 1323
      }
    }

1324 1325 1326 1327
    this.getData(json, dataColumn, obj);
    if (json.formula != null && json.formula != '' && !this.props.safe) {
      this.getFunctionValue(json.formula, dataColumn, json);
    }
徐立's avatar
徐立 committed
1328
  }
1329

徐立's avatar
徐立 committed
1330
  fetchData3 = (obj, dataColumn, init, sqlKey, labelName, valueName, allValues) => {
1331
    const {dispatch} = this.props;
徐立's avatar
徐立 committed
1332 1333 1334 1335

    if (init != null && Object.keys(init).length > 0) {
      dispatch({
        type: 'DataColumn/getSqlOptions',
1336
        payload: {sqlKey, allValues},
徐立's avatar
徐立 committed
1337 1338
        callback: options => {
          const optionsx = [];
1339 1340
          let base52 = dataColumn.base52;
          let vl = this.props.form.getFieldValue(base52);
wanyielin's avatar
wanyielin committed
1341
          let isExist = false;
徐立's avatar
徐立 committed
1342
          for (var i = 0; i < options.length; i++) {
wanyielin's avatar
wanyielin committed
1343 1344
            if (vl == options[i][valueName] && !isExist) {
              isExist = true;
徐立's avatar
徐立 committed
1345 1346 1347 1348 1349 1350
            }
            optionsx.push({
              label: options[i][labelName],
              value: options[i][valueName],
            });
          }
徐立's avatar
徐立 committed
1351

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

wanyielin's avatar
wanyielin committed
1392
          if (!isExist && vl != null && options.length > 0) {
徐立's avatar
徐立 committed
1393
            //console.log("isExist",optionsx,vl,isExist)
1394
            this.props.form.setFieldsValue({[base52]: null});
wanyielin's avatar
wanyielin committed
1395
          }
徐立's avatar
徐立 committed
1396

1397
          this.setState({options: optionsx, selectDis: false});
徐立's avatar
徐立 committed
1398 1399 1400
        },
      });
    }
1401
  };
徐立's avatar
徐立 committed
1402 1403 1404
  changeEnum = (obj, dataColumn, options) => {
    if (!this.props.isEdit && Object.keys(obj).length > 0) {
      const values = obj[dataColumn.base52];
1405
      const labels = [];
徐立's avatar
徐立 committed
1406 1407 1408 1409
      if (values != null) {
        if (values instanceof Array) {
          for (var i = 0; i < options.length; i++) {
            if (values.includes(options[i].value)) {
1410
              labels.push(options[i].label);
徐立's avatar
徐立 committed
1411 1412 1413 1414 1415 1416
              // break;
            }
          }
        } else {
          for (var i = 0; i < options.length; i++) {
            if (values == options[i].value) {
1417
              labels.push(options[i].label);
徐立's avatar
徐立 committed
1418 1419 1420 1421 1422 1423
              // break;
            }
          }
        }
      }

1424
      this.setState({labels: labels, selectDis: false});
徐立's avatar
徐立 committed
1425
    } else {
1426
      this.setState({options: options, selectDis: false});
徐立's avatar
徐立 committed
1427
    }
1428
  };
徐立's avatar
徐立 committed
1429
  fetchData = (obj, dataColumn, init, filterSql, allValues) => {
1430
    const {dispatch} = this.props;
徐立's avatar
徐立 committed
1431 1432 1433 1434

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

    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
1485
      return null;
徐立's avatar
徐立 committed
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
    }

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

    return dataColumn;
  };

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

1558

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

1626 1627 1628 1629 1630 1631 1632 1633 1634
                  fontWeight: get == 'mobile' ? 'bold' : '',
                  marginRight: get == 'mobile' ? 12 : '',
                }}
                {...json.props}
              >
                {obj[this.props.uuid] || json.initialValue}
              </span>
            </>
          );
wanyielin's avatar
wanyielin committed
1635
        } else {
1636 1637 1638 1639
          return (
            <>
              {this.props.form.getFieldDecorator(uid, {
                initialValue: this.props.form.getFieldValue(uid) || json.initialValue,
1640
              })(<Input type="hidden"/>)}
1641 1642
              <span
                style={{
1643

1644 1645 1646 1647 1648 1649 1650 1651 1652
                  fontWeight: get == 'mobile' ? 'bold' : '',
                  marginRight: get == 'mobile' ? 12 : '',
                }}
                {...json.props}
              >
                {this.props.form.getFieldValue(uid)}
              </span>
            </>
          );
wanyielin's avatar
wanyielin committed
1653
        }
徐立's avatar
徐立 committed
1654 1655 1656 1657
      }
    }

    if (json.comName == 'Description') {
1658 1659
      const key = json.sqls[json.sqls.length - 1];
      var cm = '';
徐立's avatar
徐立 committed
1660 1661 1662 1663
      var value;

      if (obj != null && obj.defaultValues) {
        if (obj.defaultValues[formKey]) {
1664
          value = obj.defaultValues[formKey][key];
徐立's avatar
徐立 committed
1665
        } else if (defaultValues) {
1666
          value = defaultValues[key];
徐立's avatar
徐立 committed
1667 1668
        }
      } else if (defaultValues) {
1669
        value = defaultValues[key];
徐立's avatar
徐立 committed
1670 1671 1672
      }
      switch (json.viewName) {
        case 'TextArea':
1673 1674 1675
          cm = (
            <span>
              {value}
1676
              {get === 'mobile' ? <br/> : ''}
1677 1678
            </span>
          );
徐立's avatar
徐立 committed
1679 1680
          break;
        case 'Switch':
1681 1682 1683
          cm = (
            <span>
              {value}
1684
              {get === 'mobile' ? <br/> : ''}
1685 1686
            </span>
          );
徐立's avatar
徐立 committed
1687 1688 1689

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

          break;
tb53863844's avatar
tb53863844 committed
1698
        case 'Cron':
1699
          cm = (
1700
            <span style={{paddingRight: get == 'mobile' ? 8 : ''}}>
tb53863844's avatar
tb53863844 committed
1701
                {value}
1702
              {get === 'mobile' ? <br/> : ''}
tb53863844's avatar
tb53863844 committed
1703
              </span>
1704 1705 1706
          );

          break;
徐立's avatar
徐立 committed
1707
        case 'InputNumber':
1708 1709 1710
          cm = (
            <span>
              {value}
1711
              {get === 'mobile' ? <br/> : ''}
1712 1713
            </span>
          );
徐立's avatar
徐立 committed
1714 1715 1716

          break;
        case 'DatePicker':
1717 1718
          cm = value ? (
            <span>
徐立's avatar
徐立 committed
1719
              {moment(parseInt(value)).format('YYYY-MM-DD HH:mm:ss')}
1720
              {get === 'mobile' ? <br/> : ''}
1721 1722
            </span>
          ) : (
1723 1724
            ''
          );
徐立's avatar
徐立 committed
1725 1726 1727

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

          break;
        case 'ImgUploadCom':
1760
          if (value == null || value == '') {
1761
            cm = <div style={{width: json.width, height: json.height}}></div>;
wanyielin's avatar
wanyielin committed
1762
          } else {
1763 1764 1765 1766
            cm = (
              <>
                <img
                  src={config.httpServer + value}
1767
                  style={{width: json.width, height: json.height}}
1768
                />
1769
                {get === 'mobile' ? <br/> : ''}
1770 1771
              </>
            );
wanyielin's avatar
wanyielin committed
1772
          }
徐立's avatar
徐立 committed
1773

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

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

1953 1954 1955
    let dataColumn =
      this.props.fatherCode != null
        ? bindObj
1956 1957 1958 1959
        ? {
          ...bindObj,
          base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`,
        }
1960
        : {base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`}
1961
        : bindObj;
徐立's avatar
徐立 committed
1962

wanyielin's avatar
wanyielin committed
1963
    if (this.props.fatherCode == null && dataColumn == null) {
1964
      dataColumn = {base52: this.props.uuid};
chscls@163.com's avatar
chscls@163.com committed
1965
    }
wanyielin's avatar
wanyielin committed
1966
    if (dataColumn.isNull != null && !dataColumn.isNull) {
chscls@163.com's avatar
chscls@163.com committed
1967
      required = true;
徐立's avatar
徐立 committed
1968 1969
    }

1970
    var title = json.label || (dataColumn && dataColumn.title);
徐立's avatar
徐立 committed
1971
    var initValue;
1972
    const objinit = {...init, ...obj};
1973

1974
    if (objinit != null && Object.keys(objinit).length > 0) {
徐立's avatar
徐立 committed
1975
      if (this.props.fatherCode != null) {
徐立's avatar
徐立 committed
1976 1977 1978 1979
        initValue =
          objinit[this.props.index] != null
            ? objinit[this.props.index][bindObj ? bindObj.base52 : this.props.uuid]
            : null;
徐立's avatar
徐立 committed
1980
      } else {
chlolch's avatar
chlolch committed
1981
        initValue = objinit[dataColumn.base52];
徐立's avatar
徐立 committed
1982 1983 1984
      }
    } else {
      if (json.initialValue != null) {
1985

徐立's avatar
徐立 committed
1986
        try {
1987
          initValue = JSON.parse(json.initialValue);
徐立's avatar
徐立 committed
1988
        } catch (e) {
1989

1990
          initValue = null;
徐立's avatar
徐立 committed
1991 1992 1993
        }
      }
    }
chlolch's avatar
chlolch committed
1994

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

          break;
        case 'Input':
徐立's avatar
徐立 committed
2035 2036 2037 2038 2039 2040 2041 2042 2043
          cm = (
            <span
              style={{
                wordBreak: 'break-all',
              }}
            >
              {obj[dataColumn.base52]}
            </span>
          );
徐立's avatar
徐立 committed
2044 2045

          break;
wanyielin's avatar
wanyielin committed
2046 2047
        case 'InputHidden':
          cm = <></>;
徐立's avatar
徐立 committed
2048

wanyielin's avatar
wanyielin committed
2049
          break;
徐立's avatar
徐立 committed
2050 2051 2052 2053 2054 2055 2056 2057
        case 'InputNumber':
          cm = <span>{obj[dataColumn.base52]}</span>;

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

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

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

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

          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
2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146
            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
2147
          } else {
2148
            cm = '';
徐立's avatar
徐立 committed
2149
          }
徐立's avatar
徐立 committed
2150
          title = title ? title : '起止时间';
徐立's avatar
徐立 committed
2151 2152 2153 2154
          break;
        case 'DatePicker':
          if (obj[dataColumn.base52] && obj[dataColumn.base52].indexOf('-') === -1) {
            cm = (
2155 2156 2157 2158 2159
              <span>
                {moment(parseInt(obj[dataColumn.base52])).format(
                  json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                )}
              </span>
徐立's avatar
徐立 committed
2160 2161 2162
            );
          } else {
            cm = (
2163 2164 2165
              <span>
                {obj[dataColumn.base52]
                  ? moment(+new Date(obj[dataColumn.base52])).format(
tb53863844's avatar
tb53863844 committed
2166 2167
                    json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                  )
2168 2169
                  : ''}
              </span>
徐立's avatar
徐立 committed
2170 2171 2172 2173 2174 2175 2176 2177 2178 2179
            );
          }

          break;

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

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

            </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]}
2288
                style={{width: json.width, height: json.height}}
2289 2290 2291 2292 2293 2294 2295 2296 2297
              />
            );
          }

          break;
        case 'VideoUploadCom':
          if (obj[dataColumn.base52] == null || obj[dataColumn.base52] == '') {
            cm = <div style={{
              width: json.width,
2298 2299
              height: json.height
            }}>
2300 2301

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

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

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

          cm = (
            <ChildForm
2348 2349

              setRealTimeValues={this.props.setRealTimeValues}
chscls@163.com's avatar
chscls@163.com committed
2350
              modalInit={modalInit}
tb53863844's avatar
tb53863844 committed
2351
              trees={this.props.trees}
chlolch's avatar
chlolch committed
2352
              isPreview={isPreview}
tb53863844's avatar
tb53863844 committed
2353 2354 2355 2356
              hfInstance={this.props.hfInstance}
              getCurrentFormTitle={this.props.getCurrentFormTitle}
              getCellValue={getCellValue}

2357 2358 2359 2360 2361 2362 2363 2364
              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
2365 2366
              formCode={this.props.formCode}
              formId={this.props.formId}
2367 2368 2369 2370 2371 2372 2373 2374
              base52={dataColumn.base52}
              mapData={mapData}
              datas={datas ? datas[json.childFormKey] : null}
              defaultValues={defaultValues}
              sqlData={sqlData}
              form={this.props.form}
            />
          );
徐立's avatar
徐立 committed
2375 2376
          break;
        case 'Button':
2377
          let events = {};
徐立's avatar
徐立 committed
2378 2379

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

徐立's avatar
徐立 committed
2396 2397
          break;
        case 'LocationCom':
2398 2399 2400 2401 2402
          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
2403 2404 2405
          break;

        case 'Table':
2406 2407
          if (json.objCode == null || json.objCode == '') {
            cm = <></>;
徐立's avatar
徐立 committed
2408
          }
2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423
          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
2424 2425
          break;
        default:
2426
          cm = <span>缺乏字段{json.comName}的匹配项</span>;
徐立's avatar
徐立 committed
2427 2428 2429 2430 2431
          break;
      }
    } else {
      if (json.vlds && json.vlds.length > 0) {
        for (let i in json.vlds) {
2432
          if (json.vlds[i].validatorFunc && json.vlds[i].validatorFunc != '') {
徐立's avatar
徐立 committed
2433
            try {
2434 2435
              let fn = new Function('rule', 'value', 'callback', json.vlds[i].validatorFunc);
              json.vlds[i].validator = fn;
徐立's avatar
徐立 committed
2436
            } catch (e) {
2437
              console.log(e);
徐立's avatar
徐立 committed
2438 2439 2440 2441 2442 2443
            }
          }
        }
      }
      switch (json.comName) {
        case 'Button':
2444
          let events = {};
徐立's avatar
徐立 committed
2445 2446

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

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

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

          break;
2580

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

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

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

2724
            break;
徐立's avatar
徐立 committed
2725 2726 2727 2728
          }

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

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

tb53863844's avatar
tb53863844 committed
2810 2811 2812 2813 2814 2815 2816 2817 2818 2819
          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}
2820 2821 2822 2823 2824
                       allowClear
                       showSearch
                       disabled={disabled}
                       placeholder={json.placeholder}
                       style={{width: json.width}}/>);
tb53863844's avatar
tb53863844 committed
2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844
          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
2845 2846 2847 2848 2849
          break;
        case 'TableSelect':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue || {},

2850 2851 2852 2853
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [
tb53863844's avatar
tb53863844 committed
2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865
                  {
                    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);
2866
                    },
tb53863844's avatar
tb53863844 committed
2867 2868 2869
                    required: required,
                  },
                ],
2870 2871 2872 2873 2874 2875 2876 2877
          })(
            <TableSelect
              get={get}
              json={json}
              dataColumn={dataColumn}
              columns={this.state.columns}
              dataSource={this.state.dataSource}
              sqlModel={this.state.sqlModel}
2878
              resetSearchText={this.resetSearchText}
2879
            />,
徐立's avatar
徐立 committed
2880
          );
徐立's avatar
徐立 committed
2881 2882 2883 2884 2885 2886
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
2887
            cm = (
徐立's avatar
徐立 committed
2888 2889
              <MobileItem
                isPreview={isPreview}
2890 2891
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
2892 2893 2894
                label={title}
              >
                {cm}
徐立's avatar
徐立 committed
2895
              </MobileItem>
2896
            );
徐立's avatar
徐立 committed
2897 2898 2899 2900 2901 2902 2903
          }
          break;

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

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

              setRealTimeValues={this.props.setRealTimeValues}
3144
              rights={json.rights || []}
tb53863844's avatar
tb53863844 committed
3145 3146 3147
              hfInstance={this.props.hfInstance}
              getCurrentFormTitle={this.props.getCurrentFormTitle}
              getCellValue={getCellValue}
3148
              isMobile={get === 'mobile'}
tb53863844's avatar
tb53863844 committed
3149
              trees={this.props.trees}
tb53863844's avatar
tb53863844 committed
3150
              fatherObj={obj}
chlolch's avatar
chlolch committed
3151
              isPreview={isPreview}
3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164
              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}
3165 3166
            />,
          );
徐立's avatar
徐立 committed
3167

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

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

3345
        if (!isEdit) {
徐立's avatar
徐立 committed
3346 3347
          return (
            <Row
徐立's avatar
徐立 committed
3348
              style={{
3349 3350
                minHeight: 40,
                lineHeight: '40px',
徐立's avatar
徐立 committed
3351
              }}
3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363
            >
              <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
3364 3365
              >
                {title}
3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385
                {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
3386 3387
              >
                {cm}
3388 3389 3390
              </Col>
              {modalCode ? (
                <FormModal
徐立's avatar
徐立 committed
3391
                  {...modalProps}
tb53863844's avatar
tb53863844 committed
3392
                  visible={this.props.DataColumn.isShowModal[modalCode]}
3393
                  handleCancel={this.closeModal.bind(this, modalCode)}
3394 3395 3396
                  title={modalTitle}
                >
                  <ZdyTable
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 3434
                    taskAssignee={taskAssignee}
                    userId={userId}
tb53863844's avatar
tb53863844 committed
3435
                    trees={this.props.trees}
3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452
                    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>
              ) : (
3453 3454
                ''
              )}
3455
              <Form.Item
3456 3457
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
3458 3459 3460 3461 3462 3463
                label={title}
              >
                {cm}
              </Form.Item>
            </>
          );
徐立's avatar
徐立 committed
3464
        }
徐立's avatar
徐立 committed
3465
      } else {
3466 3467 3468 3469
        return (
          <>
            {modalCode ? (
              <FormModal
3470
                {...modalProps}
tb53863844's avatar
tb53863844 committed
3471
                visible={this.props.DataColumn.isShowModal[modalCode]}
3472
                handleCancel={this.closeModal.bind(this, modalCode)}
3473 3474 3475
                title={modalTitle}
              >
                <ZdyTable
3476 3477
                  taskAssignee={taskAssignee}
                  userId={userId}
3478
                  modalInit={modalInit}
tb53863844's avatar
tb53863844 committed
3479
                  trees={this.props.trees}
3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495
                  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>
            ) : (
3496 3497
              ''
            )}
3498 3499 3500
            {cm}
          </>
        );
徐立's avatar
徐立 committed
3501 3502
      }
    } else {
chscls@163.com's avatar
chscls@163.com committed
3503
      return (
3504 3505 3506
        <>
          {modalCode ? (
            <FormModal
徐立's avatar
徐立 committed
3507
              {...modalProps}
tb53863844's avatar
tb53863844 committed
3508
              visible={this.props.DataColumn.isShowModal[modalCode]}
3509
              handleCancel={this.closeModal.bind(this, modalCode)}
3510 3511 3512
              title={modalTitle}
            >
              <ZdyTable
3513 3514
                taskAssignee={taskAssignee}
                userId={userId}
tb53863844's avatar
tb53863844 committed
3515
                trees={this.props.trees}
3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532
                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>
          ) : (
3533 3534
            ''
          )}
3535
          {json.isMobileLabel && !isEdit && get == 'mobile' ? (
徐立's avatar
徐立 committed
3536 3537
            <MobileItem
              isPreview={isPreview}
3538 3539
              labelCol={{span: json.labelSpan}}
              wrapperCol={{span: json.wrapperSpan}}
3540 3541 3542 3543
              label={title}
            >
              {cm}
            </MobileItem>
徐立's avatar
徐立 committed
3544 3545 3546
          ) : isEdit && get == 'web' ? (
            json.isLabel ? (
              <Form.Item
3547 3548
                labelCol={{span: json.labelSpan}}
                wrapperCol={{span: json.wrapperSpan}}
徐立's avatar
徐立 committed
3549 3550
                label={title}
              >
chlolch's avatar
chlolch committed
3551
                {cm}
徐立's avatar
徐立 committed
3552 3553
              </Form.Item>
            ) : (
3554 3555
              <Form.Item>{cm}</Form.Item>
            )
徐立's avatar
徐立 committed
3556
          ) : (
3557 3558
            cm
          )}
3559
        </>
chscls@163.com's avatar
chscls@163.com committed
3560
      );
徐立's avatar
徐立 committed
3561 3562 3563
    }
  }
}