index.jsx 82.1 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/**
 * 徐立
 * 2019年9月22日
 * 动态表格组件返回对应的组件
 */
import React, { Component } from 'react';
import md5 from 'js-md5';
import {
  message,
  Icon,
  Input,
  InputNumber,
  Button,
  Checkbox,
  DatePicker,
  Radio,
  Switch,
  Modal,
  TimePicker,
  Row,
  Col,
  Select,
  Upload,
  Form,
  Table,
徐立's avatar
徐立 committed
26
  notification,
徐立's avatar
徐立 committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
} from 'antd';
import QRCode from 'qrcode.react';
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';
import ZdyTable from '../Table/index'
import { connect } from 'dva';
import UploadCom from '../libs/UploadCom';
import TableSelect from '../libs/TableSelect';
import LocationCom from '../libs/LocationCom'
import MobileDate from '../libs/MobileDate';
import ChildForm from '../libs/ChildForm';
import moment from 'moment';
import router from 'umi/router';
import TableList from '../libs/TableList';
import styles from './style.less';
import config from '../config/config';
import { isEmpty, isNaN, cloneDeep } from 'lodash'
import { queryApiActionPath } from "../utils/queryConfig";
import { extend } from 'umi-request';
import { date } from '../libs/formList/config';
import Highlighter from 'react-highlight-words';
徐立's avatar
徐立 committed
61
import Signature from '../Signature';
徐立's avatar
徐立 committed
62 63 64 65 66
import baseX from 'base-x'
const Bs64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
const base64 = baseX(Bs64)
import {Base16Encode} from "../Base16/index"
import { getToken } from '../utils/token';
徐立's avatar
徐立 committed
67
// import FilePreview from '../filePreview';
徐立's avatar
徐立 committed
68 69
function getBase64(value){
  return value?base64.encode(new Buffer(value)):null;
徐立's avatar
徐立 committed
70

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

  const { response } = error;
徐立's avatar
徐立 committed
97 98


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

徐立's avatar
徐立 committed
102
    message.error(`请求错误${errorText}`)
chscls@163.com's avatar
chscls@163.com committed
103 104 105 106 107 108
    if (response.status === 401) {
      return window.g_app._store.dispatch({
        type: 'login/loginout',
      });

    }
徐立's avatar
徐立 committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
  } else {
    message.error(`网络故障,请检查网络链接或联系管理员`)
  }
};

let oldProps = {}
const normFile = (e) => {
  if (Array.isArray(e)) {
    return e;
  }
  return e && e.fileList[0];
}
@connect(({ DataColumn, SqlManageEntity,formList, loading }) => ({
  DataColumn, SqlManageEntity,formList,
  loading: loading.models.DataColumn || loading.models.SqlManageEntity||loading.models.formList
}))
export default class tableCom extends Component {
  state = {
    options: this.props.options || [],
    labels: [],
    url: null,
    selectDis: true,// 让下拉框在获取到数据前失效,防止网络卡顿用户点击时造成页面白屏
    isDate: true,// 避免重复调用
    sqlKeys: {},
    searchText: '',
    reqUrls: {},
    res: null,
    option: {},
    sqlModel: {},
    columns: [],
    sqlContent: null,
    dataSource: {
      list: [],
      pagination: false
    },
  };
  excludeKeys = ["defaultValues", ""]


chscls@163.com's avatar
chscls@163.com committed
148
  equal = (obj1, obj2, json, sqlContent, depth) => {
徐立's avatar
徐立 committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197


    if (obj1 == null && obj2 != null) {
      return false
    }
    if (obj1 != null && obj2 == null) {
      return false
    }
    if (obj1 == null && obj2 == null) {
      return true
    }

    if (obj1 instanceof Date) {

      if (obj1.valueOf() != obj2.valueOf()) {
        return false
      }

    } else if (obj1 instanceof moment) {

      if (obj1.valueOf() != obj2.valueOf()) {

        return false

      }

    } else if (typeof obj1 == 'function') {

      if (obj1.toString() != obj2.toString()) {

        return false

      }
    }

    const keys = new Set()
    if (obj2 != null) {
      Object.keys(obj2).forEach((k) => { if (k != "") keys.add(k) })
    }
    if (obj1 != null) {
      Object.keys(obj1).forEach((k) => { if (k != "") keys.add(k) })
    }

    let res = true

    for (let key of keys) {
      if (key == "") {
        continue
      }
徐立's avatar
徐立 committed
198

徐立's avatar
徐立 committed
199 200 201 202 203 204 205 206 207 208 209 210
      if (this.excludeKeys.includes(key)) {
        continue
      }

      if (obj1[key] == null && obj2[key] != null) {
        res = false
        break;
      }
      if (obj1[key] != null && obj2[key] == null) {
        res = false
        break;
      }
徐立's avatar
徐立 committed
211

chscls@163.com's avatar
chscls@163.com committed
212 213 214
      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)&&(json.funcs != null && json.funcs.indexOf(key) == -1))
       )) {
徐立's avatar
徐立 committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245

        this.excludeKeys.push(key)

        continue
      }


      if (obj1[key] == null && obj2[key] == null) {
        continue

      }
      if (isNaN(obj1[key]) && isNaN(obj2[key])) {
        continue
      }
      /*  if (this.typeOf(obj1[key]) != this.typeOf(obj1[key])) {

         res = false
         break;
       } */

      if (obj1[key] instanceof Array) {

        if (obj1[key].length != obj2[key].length) {

          res = false
          break;
        } else {
          var xx = true

          for (var i = 0; i < obj1[key].length; i++) {

chscls@163.com's avatar
chscls@163.com committed
246
            if (!this.equal(obj1[key][i], obj2[key][i], json, sqlContent, depth + 1)) {
徐立's avatar
徐立 committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260

              xx = false
              break;
            }
          }

          if (!xx) {
            res = false
            break;
          }
        }

      } else if (obj1[key] instanceof Object) {

chscls@163.com's avatar
chscls@163.com committed
261
        const x = this.equal(obj1[key], obj2[key], json, sqlContent, depth + 1)
徐立's avatar
徐立 committed
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299


        if (!x) {

          res = false
          break;
        }

      } else if (typeof obj1[key] == "function") {
        if (obj1[key].toString() != obj2[key].toString()) {
          res = false
          break;
        }


      } else {
        if (obj1[key] != obj2[key]) {

          res = false
          break;
        }
      }




    }



    return res;
  };

  getRender= (com,props) => {
    if(com=="span") return <span {...props}/>
    if(com=="a") return <a {...props}/>
    if(com=="div") return <div {...props}/>
    if(com=="canvas") return <canvas {...props}/>
300
    if(com=="iframe") return <iframe {...props}/>
徐立's avatar
徐立 committed
301 302 303 304 305 306
    if(com=="img") {
      const src=props.src!=null?(props.src.indexOf("http")>-1?props.src:config.httpServer+props.src):null
      const pp={...props,src:src}
      return <img {...pp}/>
    }
    }
徐立's avatar
徐立 committed
307

徐立's avatar
徐立 committed
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
  /**
   * 判断传入值是否为JSON文本
   */
  isJSON = (str) => {
    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;
      }
    }
    console.log('这不是个字符串')
  }
  /**
   * 上传文件输入
   * 使用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();
徐立's avatar
徐立 committed
353

徐立's avatar
徐立 committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
    this.setState({ searchText: selectedKeys[0] });
  };

  handleReset = clearFilters => {
    clearFilters();
    this.setState({ searchText: '' });
  };

  getColumnSearchProps = (dataIndex, title) => ({
    filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
      <div style={{ padding: 8 }}>
        <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)}
          style={{ width: 188, marginBottom: 8, display: 'block' }}
        />
        <Button
          type="primary"
          onClick={() => this.handleSearch(selectedKeys, confirm)}
          icon="search"
          loading={this.props.loading}
          size="small"
          style={{ width: 90, marginRight: 8 }}
        >
          搜索
        </Button>
        <Button loading={this.props.loading} onClick={() => this.handleReset(clearFilters)} size="small" style={{ width: 90 }}>
          重置
        </Button>
      </div>
    ),
    filterIcon: filtered => (
      <Icon type="search" style={{ color: filtered ? '#1890ff' : "red" }} />
    ),
    onFilter: (value, record) => record[dataIndex] ?
      record[dataIndex]
        .toString()
        .toLowerCase()
        .includes(value.toLowerCase()) : "",
    onFilterDropdownVisibleChange: visible => {
      if (visible) {
        setTimeout(() => this.searchInput.select());
      }
    },
    render: text => {
      if (text != null) {
        return <Highlighter
          highlightStyle={{ backgroundColor: '#ffc069', padding: 0 }}
          searchWords={[this.state.searchText]}
          autoEscape
          textToHighlight={text.toString()}
        />
      } else {
        return ""
      }

    },
  });

  componentWillReceiveProps(props) {
    const { json, mapData, obj } = props;
    if (json == null) {
      return;
    }
    if(!(this.dataFilter.includes(json.comName) || json.comName == "TableSelect")&&json.isFormulaOnce){
      return;
    }
    if (!(this.dataFilter.includes(json.comName) || json.comName == "TableSelect" || (json.formula != null && json.formula != ""))) {
      return;
    }
    const obj2 = props.form.getFieldsValue()
chscls@163.com's avatar
chscls@163.com committed
430
    const bb = this.equal(this.obj, obj2, json, this.state.sqlContent, 1)
徐立's avatar
徐立 committed
431 432 433 434 435
    let bb2 = true
    let childObj2 = {}
    if (props.fatherCode) {
      if (obj2 != null && obj2[props.fatherCode]) {
        childObj2 = obj2[props.fatherCode][props.index];
徐立's avatar
徐立 committed
436

chscls@163.com's avatar
chscls@163.com committed
437
        bb2 = this.equal(this.childObj, childObj2, json, this.state.sqlContent, 1)
徐立's avatar
徐立 committed
438

徐立's avatar
徐立 committed
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
      }


    }


    if (!(bb && bb2)) {
      const now = new Date().valueOf()

      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) {
        this.count.splice(0, j)
      }
      if (this.count.length > 10) {
        console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:存在循环风险,1秒内执行超过10次,现已停止执行,请检查,`)

        return;
      }
      if (!bb) {
        this.obj = cloneDeep(obj2)
      }
      if (!bb2) {

        this.childObj = cloneDeep(childObj2)
      }
      this.count.push(now)


    } else {
      return
    }

chscls@163.com's avatar
chscls@163.com committed
482 483 484 485 486 487 488 489 490
    const bindObj=this.getColumn('c1');

   let dataColumn = this.props.fatherCode != null ? (bindObj?{...bindObj,base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`}:

    { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` })

    : bindObj;
    if (this.props.fatherCode == null&&dataColumn == null)   dataColumn = { base52: this.props.uuid }
/*     if (this.props.fatherCode != null) {
徐立's avatar
徐立 committed
491 492 493 494 495 496 497 498 499 500 501 502 503
      dataColumn = { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
    } else {
      dataColumn = { base52: this.props.uuid }
      if (Object.keys(mapData).length > 0) {
        const columnIds = json.columnIds;

        if (columnIds && columnIds['c1']) {
          const columnId = columnIds['c1'][columnIds['c1'].length - 1];
          if (mapData[columnId] != null) {
            dataColumn = mapData[columnId]
          }
        }
      }
chscls@163.com's avatar
chscls@163.com committed
504 505 506 507 508 509 510 511 512 513 514
    } */
    if (!this.props.isEdit&&this.props.fatherCode) {
  
      if(bindObj!=null){
        dataColumn.base52 = bindObj.base52
      }else{
        dataColumn.base52 = this.props.uuid
      }
    
  }
    
徐立's avatar
徐立 committed
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
    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)
    }
    if (json.formula != null && json.formula != ""&&!json.isFormulaOnce) {
      this.getFunctionValue(json.formula, dataColumn, json)
    }
  }
  dataFilter = ["Select", "Radio", "Checkbox"]

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

    const allValues = JSON.stringify(obj)


    if (json.comName == "TableSelect") {
      const { dispatch } = this.props
      const { sqlKey, optionType } = json
      if (optionType == "sql") {
        dispatch({
          type: 'SqlManageEntity/find',
          payload: { sqlKey: sqlKey },
          callback: sqlModel => {
            this.setState({ sqlModel })
            if (sqlModel.dataObjId) {
              dispatch({
                type: 'formList/getHead',
                payload: { dataObjId: sqlModel.dataObjId },
                callback: datas => {

                  if (datas) {
                    const columns = []
                    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)) {
                          column.render = val => moment(val)
                            .format('YYYY-MM-DD HH:mm:ss');
                        }
                        columns.push(column);

                      } else {
                        break
                      }
                    }
                    this.setState({ columns })
                  }
                }
              })
            } else {
              const cols = sqlModel.cols
              if (cols != null || cols.length > 0) {
                const columns = []
                const cll = JSON.parse(cols)
                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)) {
                    var ff = 'YYYY-MM-DD HH:mm:ss'
                    switch (cll[k].type) {
                      case 'DATE': ff = 'YYYY-MM-DD'; break;
                      case 'YEAR': ff = 'YYYY'; break;
                      case 'TIME': ff = 'HH:mm:ss'; break;
                    }

                    column.render = val => moment(parseInt(val))
                      .format(ff);
                  }
                  if (cll[k].isQuery) {
                    column = {
                      ...this.getColumnSearchProps(cll[k].name, cll[k].title),
                      ...column,

                    }
                  }

                  columns.push(column);
                }
                this.setState({ columns })
              }

              dispatch({
                type: 'DataColumn/getSqlData',
                payload: { sqlKey, allValues },
                callback: list => {
                  const x = {
                    list: list,
                    pagination: false
                  }
                  this.setState({ dataSource: x })
                }
              })
            }
          }
        })
      }else if(optionType == "reference"&&dataColumn.referenceObjId){
        dispatch({
          type: 'formList/getHead',
          payload: { dataObjId: dataColumn.referenceObjId},
          callback: datas => {

            if (datas) {
              const columns = []
              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)) {
                    column.render = val => moment(val)
                      .format('YYYY-MM-DD HH:mm:ss');
                  }
                  columns.push(column);

                } else {
                  break
                }
              }
              this.setState({ columns })
            }
          }
        })


      }
    }



    if (json.optionType != null && this.dataFilter.includes(json.comName)) {

      switch (json.optionType) {
        case "reference":
          if (dataColumn.referenceObjId != null) {

            this.fetchData(obj, dataColumn, init, json.filterSql, allValues)
          }
          break;
        case "enum":

          if (json.enums != null && json.enums != "") {
            var enu;
            try {
              enu = JSON.parse(json.enums)
            } catch (e) {
              message.error("枚举json格式存在问题")
              enu = []
            }

            this.changeEnum(obj, dataColumn, enu)
          }
          break;
        case "sql":
          if (json.sqlKey != null && json.sqlKey != "") {

            this.fetchData3(obj, dataColumn, init, json.sqlKey, json.labelName, json.valueName, allValues)
          }
          break;
        case "func":
chscls@163.com's avatar
chscls@163.com committed
677
          
徐立's avatar
徐立 committed
678 679
          if (json.funcs != null && json.funcs != "") {
            let enu;
chscls@163.com's avatar
chscls@163.com committed
680
            
徐立's avatar
徐立 committed
681
            try {
chscls@163.com's avatar
chscls@163.com committed
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705
              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)
                  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;
                      }
                    }
                  }
              
                  this.setState({labels:labs})
               }else if (!this.props.isEdit && Object.keys(obj).length > 0) {
chscls@163.com's avatar
chscls@163.com committed
706
               
chscls@163.com's avatar
chscls@163.com committed
707
                 let base52 = dataColumn.base52
chscls@163.com's avatar
chscls@163.com committed
708 709
                 
                
chscls@163.com's avatar
chscls@163.com committed
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
                 const vlu=obj[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;
                     }
                   }
                 }
             
                 this.setState({labels:labs})
   
               }
              }) ;
chscls@163.com's avatar
chscls@163.com committed
735 736 737 738 739
             
           } catch (e) {
             message.error("公式选项配置存在问题")
           
           }
chscls@163.com's avatar
chscls@163.com committed
740
         
chscls@163.com's avatar
chscls@163.com committed
741
          
徐立's avatar
徐立 committed
742

徐立's avatar
徐立 committed
743

徐立's avatar
徐立 committed
744 745 746 747 748 749 750 751 752 753 754 755
          }
          break;
      }
    }
  }

  setValues = (base52, json, values) => {

    try {
      this.props.form.setFieldsValue(values)
    } catch (e) {
      console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
756
      //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
757 758 759
    }

  }
chscls@163.com's avatar
chscls@163.com committed
760
  reqUtil = (base52, json,orgCallback, url, method, params, callback, options = {}) => {
徐立's avatar
徐立 committed
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
    //查缓存
    var isChange = false;
    if(url.indexOf("http")===-1){
      url=config.httpServer+url
    }
    const { reqUrls } = this.state
    if (reqUrls[url] != null) {

      const ps = reqUrls[url].params

      if (Object.keys(params).length != Object.keys(ps).length) {
        isChange = true
      } else {
        for (var key in params) {
          if (params[key] == null && ps[key] != null) {
            isChange = true
            break;
          } else if (params[key] != null && ps[key] == null) {
            isChange = true
            break;
          } else {
            if (params[key] != ps[key]) {
              isChange = true
              break
            }
          }
        }
      }
    } else {
      reqUrls[url] = { params: params }
      isChange = true
    }
徐立's avatar
徐立 committed
793

徐立's avatar
徐立 committed
794 795 796
    if (!isChange) {
      if (callback) {
        const data = reqUrls[url].data
徐立's avatar
徐立 committed
797

徐立's avatar
徐立 committed
798
        if(json.optionType&&json.optionType=="func"){
徐立's avatar
徐立 committed
799

徐立's avatar
徐立 committed
800
          const res=callback(data)
徐立's avatar
徐立 committed
801

徐立's avatar
徐立 committed
802
          if(res!=null&&!(typeof res === "function")){
chscls@163.com's avatar
chscls@163.com committed
803 804 805
            this.setState({ options: res , selectDis: false },()=>{
             if(orgCallback) orgCallback()
            });
徐立's avatar
徐立 committed
806
          }
徐立's avatar
徐立 committed
807

徐立's avatar
徐立 committed
808 809 810 811 812 813
        }else if (json.comName == "Button") {
          try {
            callback(data)

          } catch (e) {
            console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
814
            //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
815 816 817 818 819 820 821 822 823 824
          }

        } else if (json.comName == "Echart" || json.comName == "QRCode") {
          try {
            const x = callback(data)
            if (x != null) {
              this.setState({ option: x })
            }
          } catch (e) {
            console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
825
            //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
826 827 828 829 830 831 832 833 834 835 836
          }

        } else {
          if (base52) {

            try {
              const x = callback(data)
              if (x == null || x != "NaN") this.props.form.setFieldsValue({ [base52]: x })

            } catch (e) {
              console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
837
              //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856
            }




          }
        }
      }
      return "norefeshxxxxxxxxxxxxxxxxxxxx"
    }
    this.setState({ reqUrls }, () => {
      for(let i in params){
        if(params[i]==null){
          delete params[i]
        }
      }
      if(getToken()!=null){
        params.token=getToken()
      }
徐立's avatar
徐立 committed
857

徐立's avatar
徐立 committed
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877
      const requestParams = params
      const umiRequest = extend({
        errorHandler, // 默认错误处理
        credentials: 'omit', // 默认请求是否带上cookie
        mode: 'cors',
        ...options,

      });
      umiRequest(url, {

        data: requestParams,
        method: method,
        requestType: "form"
      }).then(data => {
        this.setState({ res: data }, () => {
          const { reqUrls } = this.state
          reqUrls[url].data = data
          this.setState({ reqUrls })
          if (callback) {
            if(json.optionType&&json.optionType=="func"){
徐立's avatar
徐立 committed
878

徐立's avatar
徐立 committed
879
              const res=callback(data)
徐立's avatar
徐立 committed
880

徐立's avatar
徐立 committed
881
              if(res!=null&&!(typeof res === "function")){
chscls@163.com's avatar
chscls@163.com committed
882 883 884
                this.setState({ options: res , selectDis: false },()=>{
                  if(orgCallback) orgCallback()
                });
徐立's avatar
徐立 committed
885
              }
徐立's avatar
徐立 committed
886

徐立's avatar
徐立 committed
887 888 889 890 891 892
            }else   if (json.comName == "Button") {
              try {
                callback(data)

              } catch (e) {
                console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
893
                //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
894 895 896 897 898 899 900 901 902 903
              }

            } else if (json.comName == "Echart" || json.comName == "QRCode") {
              try {
                const x = callback(data)
                if (x != null) {
                  this.setState({ option: x })
                }
              } catch (e) {
                console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
904
                //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
905 906 907 908 909 910 911 912 913 914
              }

            } else {
              if (base52) {

                try {
                  const x = callback(data)
                  if (x == null || x != "NaN") this.props.form.setFieldsValue({ [base52]: x })
                } catch (e) {
                  console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
915
                  //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
                }



              }
            }


          }
        })


      })

    })





    return "norefeshxxxxxxxxxxxxxxxxxxxx"


  }
chscls@163.com's avatar
chscls@163.com committed
940
  sqlUtil = (base52, json,orgCallback, sqlKey, params, callback, options = {}) => {
chscls@163.com's avatar
chscls@163.com committed
941
   
徐立's avatar
徐立 committed
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970
    //查缓存
    var isChange = false;
    const { sqlKeys } = this.state

    if (sqlKeys[sqlKey] != null) {

      const ps = sqlKeys[sqlKey].params

      if (params.length != ps.length) {
        isChange = true
      } else {
        for (var i = 0; i < params.length; i++) {
          if (params[i] != ps[i]) {
            isChange = true
            break;
          }
        }
      }
    } else {
      sqlKeys[sqlKey] = { params: params }
      isChange = true
    }
    if (!isChange) {

      if (callback) {
        const data = sqlKeys[sqlKey].data
        if(json.optionType&&json.optionType=="func"){
          const res=callback(data)
          if(res!=null&&!(typeof res === "function")){
chscls@163.com's avatar
chscls@163.com committed
971 972 973
            this.setState({ options: res , selectDis: false },()=>{
              if(orgCallback)orgCallback()
            });
徐立's avatar
徐立 committed
974 975 976 977 978 979 980
          }
        }else if (json.comName == "Button") {
          try {
            callback(data)

          } catch (e) {
            console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
981
            //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
982 983 984 985 986 987 988 989 990 991
          }

        } else if (json.comName == "Echart" || json.comName == "QRCode") {
          try {
            const x = callback(data)
            if (x != null) {
              this.setState({ option: x })
            }
          } catch (e) {
            console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
992
            //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
993 994 995 996 997 998 999 1000 1001 1002
          }

        } else {
          if (base52) {

            try {
              const x = callback(data)
              if (x == null || x != "NaN") this.props.form.setFieldsValue({ [base52]: x })
            } catch (e) {
              console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
1003
              //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
            }




          }
        }
      }
      return "norefeshxxxxxxxxxxxxxxxxxxxx"
    }

    const allValues = JSON.stringify({ ...this.props.obj, ...this.props.form.getFieldsValue(), ...this.props.defaultValues[this.props.formKey] })

    const url = queryApiActionPath() + "/DataColumnApi/getSqlData"
    this.setState({ sqlKeys }, () => {



徐立's avatar
徐立 committed
1022

徐立's avatar
徐立 committed
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
      const pp = { sqlKey: Base16Encode(sqlKey), params,allValues: Base16Encode(allValues) }
      if(getToken()!=null){
        pp.token=getToken()
      }
      const umiRequest = extend({
        errorHandler, // 默认错误处理
        credentials: 'omit', // 默认请求是否带上cookie
        mode: 'cors',
        ...options,
      });
      umiRequest(url, {

        data: pp ,
        method: 'POST',
        requestType: "form"
      }).then(data => {
        const { sqlKeys } = this.state
        sqlKeys[sqlKey].data = data
        this.setState({ sqlKeys })
        if (data == null) {
          return
        }

        if (callback) {
          if(json.optionType&&json.optionType=="func"){
徐立's avatar
徐立 committed
1048

徐立's avatar
徐立 committed
1049
            const res=callback(data)
徐立's avatar
徐立 committed
1050

徐立's avatar
徐立 committed
1051
            if(res!=null&&!(typeof res === "function")){
chscls@163.com's avatar
chscls@163.com committed
1052 1053 1054
              this.setState({ options: res , selectDis: false },()=>{
                if(orgCallback) orgCallback()
              });
徐立's avatar
徐立 committed
1055
            }
徐立's avatar
徐立 committed
1056

徐立's avatar
徐立 committed
1057 1058 1059 1060 1061 1062
          }else if (json.comName == "Button") {
            try {
              callback(data)

            } catch (e) {
              console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
1063
              //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
            }

          } else if (json.comName == "Echart" || json.comName == "QRCode") {
            try {
              const x = callback(data)
              if (x != null) {
                this.setState({ option: x })
              }
            } catch (e) {
              console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
1074
              //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
            }

          } else {
            if (base52) {

              try {
                const x = callback(data)
                if (x == null || x != "NaN") this.props.form.setFieldsValue({ [base52]: x })
              } catch (e) {
                console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误,`, e)
1085
                //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
              }




            }
          }


        }



      })

    })





    return "norefeshxxxxxxxxxxxxxxxxxxxx"
  }

chscls@163.com's avatar
chscls@163.com committed
1110
  getFunctionValue = (fun, column, json,callback) => {
徐立's avatar
徐立 committed
1111 1112 1113 1114 1115

    /*  if (!this.props.isEdit) {
       return
     } */
    const base52 = column.base52
chscls@163.com's avatar
chscls@163.com committed
1116
    
徐立's avatar
徐立 committed
1117 1118
    try {
      var fun1 = new Function("obj","init", "defaultValues", "env", "index", "fatherCode", "utils", fun);
chscls@163.com's avatar
chscls@163.com committed
1119 1120 1121 1122 1123 1124 1125 1126 1127
      let obj 
      if(!this.props.isEdit&&this.props.fatherCode){
       
        obj = { ...this.props.fatherObj, ...this.props.form.getFieldsValue(), ...this.props.defaultValues[this.props.formKey] }
        console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxttttttttt",this.props.fatherObj)
      }else{
        obj = { ...this.props.obj, ...this.props.form.getFieldsValue(), ...this.props.defaultValues[this.props.formKey] }
      }
    
徐立's avatar
徐立 committed
1128

chscls@163.com's avatar
chscls@163.com committed
1129
    
chscls@163.com's avatar
chscls@163.com committed
1130
      const value = fun1(obj,this.props.init, this.props.defaultValues, { clientType: this.props.get,formCode:this.props.formCode,formId:this.props.formId }, this.props.index, this.props.fatherCode,
徐立's avatar
徐立 committed
1131
        { 
徐立's avatar
徐立 committed
1132
          moment: moment,
chscls@163.com's avatar
chscls@163.com committed
1133
          sql: this.sqlUtil.bind(this, base52, json,callback),
徐立's avatar
徐立 committed
1134
          message: message,router:router,
徐立's avatar
徐立 committed
1135
          setValues: this.setValues.bind(this, base52, json),
chscls@163.com's avatar
chscls@163.com committed
1136
          req: this.reqUtil.bind(this, base52, json,callback), 
徐立's avatar
徐立 committed
1137
          md5: md5,
徐立's avatar
徐立 committed
1138 1139 1140 1141
          render:this.getRender,base64:getBase64
        },

      )
徐立's avatar
徐立 committed
1142

徐立's avatar
徐立 committed
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155
      if (base52) {
        if (value != null && value == "norefeshxxxxxxxxxxxxxxxxxxxx") {

        } else {
          /**
           * 会出现重复调用2次,然后NAN造成无限循环
           */
          if (isNaN(value)) {
            return
          }
          if (json.comName == "Button") {

            return value
chscls@163.com's avatar
chscls@163.com committed
1156
          } else if(json.optionType&&json.optionType=="func"){
徐立's avatar
徐立 committed
1157 1158


chscls@163.com's avatar
chscls@163.com committed
1159
            if(value!=null&&!(typeof value === "function")){
chscls@163.com's avatar
chscls@163.com committed
1160 1161 1162
              this.setState({ options: value , selectDis: false },()=>{
                if(callback) callback()
              });
chscls@163.com's avatar
chscls@163.com committed
1163
            }
徐立's avatar
徐立 committed
1164

徐立's avatar
徐立 committed
1165 1166 1167 1168 1169 1170 1171
          } else if (json.comName == "Echart" || json.comName == "QRCode") {
            this.setState({ option: value })
          } else {
            try {
              this.props.form.setFieldsValue({ [base52]: value })
            } catch{
              console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,函数内部错误,`, e)
1172
              //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,函数内部错误${e}`, 10)
徐立's avatar
徐立 committed
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184
            }
          }
        }



      }


    } catch (e) {

      console.log(`页面${this.props.formKey}${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,暂存失败,`, e)
1185
      //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,暂存失败${e}`, 10)
徐立's avatar
徐立 committed
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205


    }
  }
  componentDidMount() {
    const { json, mapData, obj, init } = this.props;
    if (json == null) {
      return
    }
    if (json.sqlKey != null && json.sqlKey != "") {
      const { dispatch } = this.props
      dispatch({
        type: 'SqlManageEntity/find',
        payload: { sqlKey: json.sqlKey },
        callback: res => {

          this.setState({ sqlContent: res.sql })
        }
      })
    }
chscls@163.com's avatar
chscls@163.com committed
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215
  
    const bindObj=this.getColumn('c1');

    let dataColumn = this.props.fatherCode != null ? (bindObj?{...bindObj,base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`}:
 
     { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` })
 
     : bindObj;
     if (this.props.fatherCode == null&&dataColumn == null)   dataColumn = { base52: this.props.uuid }
  /*   if (this.props.fatherCode != null) {
徐立's avatar
徐立 committed
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228
      dataColumn = { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` }
    } else {
      dataColumn = { base52: this.props.uuid }
      if (Object.keys(mapData).length > 0) {
        const columnIds = json.columnIds;

        if (columnIds && columnIds['c1']) {
          const columnId = columnIds['c1'][columnIds['c1'].length - 1];
          if (mapData[columnId] != null) {
            dataColumn = mapData[columnId]
          }
        }
      }
chscls@163.com's avatar
chscls@163.com committed
1229 1230 1231 1232 1233 1234 1235 1236 1237
    } */
    if (!this.props.isEdit&&this.props.fatherCode) {
  
        if(bindObj!=null){
          dataColumn.base52 = bindObj.base52
        }else{
          dataColumn.base52 = this.props.uuid
        }
      
徐立's avatar
徐立 committed
1238
    }
chscls@163.com's avatar
chscls@163.com committed
1239
 
徐立's avatar
徐立 committed
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268
    this.getData(json, dataColumn, obj)
    if (json.formula != null && json.formula != "") {
      this.getFunctionValue(json.formula, dataColumn, json)
    }


  }
  fetchData3 = (obj, dataColumn, init, sqlKey, labelName, valueName, allValues) => {
    const { dispatch } = this.props;


    if (init != null && Object.keys(init).length > 0) {
      dispatch({
        type: 'DataColumn/getSqlOptions',
        payload: { sqlKey, allValues },
        callback: options => {
          const optionsx = [];
          let base52 = dataColumn.base52
          let vl=this.props.form.getFieldValue(base52)
          let isExist=false;
          for (var i = 0; i < options.length; i++) {
            if(vl== options[i][valueName]&&!isExist){
              isExist=true;
            }
            optionsx.push({
              label: options[i][labelName],
              value: options[i][valueName],
            });
          }
徐立's avatar
徐立 committed
1269

徐立's avatar
徐立 committed
1270 1271 1272 1273 1274 1275 1276 1277
          if(!isExist&&vl!=null&&options.length>0){
            this.props.form.setFieldsValue({[base52]:null})
          }
          this.setState({ options: optionsx, selectDis: false });
        },
      });

    } else if (!this.props.isEdit && Object.keys(obj).length > 0) {
chscls@163.com's avatar
chscls@163.com committed
1278
     
徐立's avatar
徐立 committed
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
      let base52 = dataColumn.base52
      if (this.props.fatherCode) {
        const x = base52.split(".")
        base52 = x[x.length - 1]
      }
      dispatch({
        type: 'DataColumn/getSqlLabels',
        payload: { sqlKey, values: obj[base52], labelName, valueName, allValues },
        callback: labels => {

          this.setState({ labels, selectDis: false });
        },
      });
    } else {
      dispatch({
        type: 'DataColumn/getSqlOptions',
        payload: { sqlKey, allValues },
        callback: options => {
          let base52 = dataColumn.base52
          let vl=this.props.form.getFieldValue(base52)
          const optionsx = [];
          let isExist=false;
          for (var i = 0; i < options.length; i++) {
            if(vl== options[i][valueName]&&!isExist){
              isExist=true;
            }
            optionsx.push({
              label: options[i][labelName],
              value: options[i][valueName],
            });
          }
徐立's avatar
徐立 committed
1310

徐立's avatar
徐立 committed
1311 1312 1313 1314
          if(!isExist&&vl!=null&&options.length>0){
            //console.log("isExist",optionsx,vl,isExist)
              this.props.form.setFieldsValue({[base52]:null})
            }
徐立's avatar
徐立 committed
1315

徐立's avatar
徐立 committed
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413
          this.setState({ options: optionsx, selectDis: false });
        },
      });

    }


  }
  changeEnum = (obj, dataColumn, options) => {
    if (!this.props.isEdit && Object.keys(obj).length > 0) {
      const values = obj[dataColumn.base52];
      const labels = []
      if (values != null) {

        if (values instanceof Array) {
          for (var i = 0; i < options.length; i++) {
            if (values.includes(options[i].value)) {
              labels.push(options[i].label)
              // break;
            }
          }
        } else {

          for (var i = 0; i < options.length; i++) {
            if (values == options[i].value) {
              labels.push(options[i].label)
              // break;
            }

          }
        }
      }

      this.setState({ labels: labels, selectDis: false });
    } else {
      this.setState({ options: options, selectDis: false });
    }

  }
  fetchData = (obj, dataColumn, init, filterSql, allValues) => {
    const { dispatch } = this.props;

    if (init != null && Object.keys(init).length > 0) {

      dispatch({
        type: 'DataColumn/getOptions',
        payload: { id: dataColumn.id, filterSql, allValues },
        callback: options => {
          const optionsx = [];
          for (var i = 0; i < options.length; i++) {
            optionsx.push({
              label: options[i][dataColumn.referenceNameName],
              value: options[i][dataColumn.referenceCodeName],
            });
          }
          this.setState({ options: optionsx, selectDis: false });
        },
      });

    } else if (!this.props.isEdit && Object.keys(obj).length > 0) {
      if (obj[dataColumn.base52]) {
        dispatch({
          type: 'DataColumn/getLabels',
          payload: { id: dataColumn.id, values: obj[dataColumn.base52], filterSql, allValues },
          callback: labels => {
            this.setState({ labels, selectDis: false });
          },
        });
      }
    } else {
      dispatch({
        type: 'DataColumn/getOptions',
        payload: { id: dataColumn.id, filterSql, allValues },
        callback: options => {
          const optionsx = [];
          for (var i = 0; i < options.length; i++) {
            optionsx.push({
              label: options[i][dataColumn.referenceNameName],
              value: options[i][dataColumn.referenceCodeName],
            });
          }
          this.setState({ options: optionsx, selectDis: false });
        },
      });

    }
  }
  getColumn = key => {
    let { mapData, json } = this.props;

    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
1414
      return null;
徐立's avatar
徐立 committed
1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478
    }

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

    return dataColumn;
  };
  changeUrl = (info, key) => {

    if (info.file.status === 'done') {
      message.success(`图片上传成功`);
      this.setState({ url: info.file.response })

    } else if (info.file.status === 'error') {
      message.error(`图片上传失败`);
    }
  }
  render() {
    /**
     * json为申请表单
     * obj为查看详情用户输入值
     */
    let { json, obj, mapData, init, sqlData, defaultValues, get, formKey, isEdit, datas } = this.props;
    const { options, labels, selectDis } = this.state;
    const { getFieldDecorator, getFieldError, getFieldProps } = this.props.form;
    const disabled = json != null ? json.disabled : false

    if (json == null) {
      return <></>;
    }
    if (json.comName == 'QRCode') {
      if (this.state.option == null || this.state.option.value == null || this.state.option.value == null) return <></>;
      return <QRCode {...this.state.option} key={this.props.uuid} />

    }

    if (json.comName == 'Echart') {

      return <ReactEcharts style={{ height: json.height || 500 }} key={this.props.uuid}
        option={this.state.option || {}}
        notMerge={true}
        lazyUpdate={true}
        theme={"theme_name"}
        onEvents={{}} />

    }
    if (json.comName == 'PartForm') {

      const fk = this.props.form.getFieldValue(this.props.uuid) || json.childFormKey

      if (fk == null) {

        return <></>
      }
      if (formKey == fk) {
        return <>片段表单key不能和自身相同</>;
      }
      return <>{this.props.form.getFieldDecorator(this.props.uuid, {
        initialValue: fk

      })(<Input type="hidden" />)} <ZdyTable key={fk} datas={datas} get={get} isChild={true} currentFormKey={fk} isEdit={isEdit} obj={obj} init={init} form={this.props.form} mapData={mapData} sqlData={sqlData} {...datas[fk]} defaultValues={defaultValues} /></>
    }
    if (json.comName == 'Label') {
      let uid
      if (this.props.fatherCode != null) {
徐立's avatar
徐立 committed
1479
        uid=`${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`
徐立's avatar
徐立 committed
1480
      } else {
徐立's avatar
徐立 committed
1481
        uid= this.props.uuid
徐立's avatar
徐立 committed
1482
      }
徐立's avatar
徐立 committed
1483

徐立's avatar
徐立 committed
1484 1485 1486 1487 1488 1489 1490
      if (!isEdit) {
        return obj[this.props.uuid] || json.initialValue || ""
      } else {
        if (this.props.fatherCode != null) {

            return <>{this.props.form.getFieldDecorator(uid, {
              initialValue: obj[this.props.uuid]||json.initialValue
徐立's avatar
徐立 committed
1491

chscls@163.com's avatar
chscls@163.com committed
1492
            })(<Input type="hidden" />)}<span style={{ fontWeight: get == 'mobile' ? 'bold' : '', marginRight: get == 'mobile' ? 12 : '' }} {...json.props}>{obj[this.props.uuid]||json.initialValue}</span></>
徐立's avatar
徐立 committed
1493

徐立's avatar
徐立 committed
1494 1495 1496
          }else{
            return <>{this.props.form.getFieldDecorator(uid, {
              initialValue: this.props.form.getFieldValue(uid)||json.initialValue
徐立's avatar
徐立 committed
1497

徐立's avatar
徐立 committed
1498
            })(<Input type="hidden" />)}<span style={{ fontWeight: get == 'mobile' ? 'bold' : '', marginRight: get == 'mobile' ? 12 : '' }} {...json.props}>{this.props.form.getFieldValue(uid)}</span></>
徐立's avatar
徐立 committed
1499

徐立's avatar
徐立 committed
1500
          }
徐立's avatar
徐立 committed
1501 1502 1503



徐立's avatar
徐立 committed
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608
      }
    }

    if (json.comName == 'Description') {
      const key = json.sqls[json.sqls.length - 1]
      var cm = "";
      var value;

      if (obj != null && obj.defaultValues) {
        if (obj.defaultValues[formKey]) {
          value = obj.defaultValues[formKey][key]
        } else if (defaultValues) {
          value = defaultValues[key]
        }
      } else if (defaultValues) {
        value = defaultValues[key]
      }
      switch (json.viewName) {
        case 'TextArea':
          cm = <span>
            {value}
            {
              get === 'mobile' ?
                <br />
                : ''
            }
          </span>;
          break;
        case 'Switch':

          cm = <span>
            {value}
            {
              get === 'mobile' ?
                <br />
                : ''
            }
          </span>;

          break;
        case 'Input':
          cm = <span style={{ paddingRight: get == 'mobile' ? 8 : '' }}>
            {value}
            {
              get === 'mobile' ?
                <br />
                : ''
            }
          </span>;

          break;
        case 'InputNumber':

          cm = <span>
            {value}
            {
              get === 'mobile' ?
                <br />
                : ''
            }
          </span>;

          break;
        case 'DatePicker':
          cm = (
            value ? <span>
              {moment(parseInt(value)).format('YYYY-MM-DD HH:mm:ss')}
              {
                get === 'mobile' ?
                  <br />
                  : ''
              }
            </span> : ""
          );

          break;
        case 'UploadCom':


          const files = value.files || []
          cm = (
            <>
              <ul>
                {files.map((f, index2) => {
                  if (f.path.indexOf('.png') != -1 || f.path.indexOf('.jpg') != -1) {
                    return <img key={index2} style={{ width: 100, height: 100 }} src={queryApiActionPath() + f.path} />
                  }
                  return <li key={index2}>
                    <a target="_blank" key={f.path} href={queryApiActionPath() + f.path}>
                      {f.name}
                    </a>
                  </li>
                })}
              </ul>
              {
                get === 'mobile' ?
                  <br />
                  : ''
              }
            </>
          );

          break;
        case 'ImgUploadCom':

chscls@163.com's avatar
chscls@163.com committed
1609
              if(value==null||value==""){
1610
                cm=<div style={{ width: json.width, height: json.height }}></div>
chscls@163.com's avatar
chscls@163.com committed
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620
              }else{
                cm = <>
                <img src={config.httpServer + value} style={{ width: json.width, height: json.height }} />
                {
                  get === 'mobile' ?
                    <br />
                    : ''
                }
              </>;
              }
徐立's avatar
徐立 committed
1621 1622


徐立's avatar
徐立 committed
1623

徐立's avatar
徐立 committed
1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691

          break;

      }




      if (json.isLabel) {
        if (!isEdit && obj.defaultValues && obj.defaultValues[formKey]) {
          return (
            <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ""}
            >
              {cm}
            </Form.Item>
          );
        } else {
          if (get === 'mobile') {
            /**
             * 列表类型
             */
            return (<>{this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
              initialValue: value
            })(<MobileList id='MobileList'>
              <MobileList.Item extra={cm}>
                <span style={{ fontSize: 14 }}>{json.label ? json.label : sqlData[key] ? sqlData[key].title : ""}</span>
              </MobileList.Item>
            </MobileList>)
            }</>)
            // return <div><span style={{marginRight:12}}>{json.label?json.label:sqlData[key] ? sqlData[key].title : ""}:</span><span>{cm}</span></div>
          }
          return <><Form.Item
            labelCol={{ span: json.labelSpan }}
            wrapperCol={{ span: json.wrapperSpan }}
            label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ""}
          >
            {cm}
          </Form.Item>
            {this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
              initialValue: value

            })(<Input type="hidden" />)
            }</>
        }
      } else {
        if (!isEdit && obj.defaultValues && obj.defaultValues[formKey]) {
          return cm
        } else {
          return <>{cm}{this.props.form.getFieldDecorator(`defaultValues.${formKey}.${key}`, {
            initialValue: value

          })(<Input type="hidden" />)
          }</>

        }

      }
    }





    var cm;
    var required = false;
chscls@163.com's avatar
chscls@163.com committed
1692
    const bindObj=this.getColumn('c1');
徐立's avatar
徐立 committed
1693

chscls@163.com's avatar
chscls@163.com committed
1694
    let dataColumn = this.props.fatherCode != null ? (bindObj?{...bindObj,base52: `${this.props.fatherCode}.[${this.props.index}].${bindObj.base52}`}:
徐立's avatar
徐立 committed
1695

chscls@163.com's avatar
chscls@163.com committed
1696
    { base52: `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}` })
徐立's avatar
徐立 committed
1697

chscls@163.com's avatar
chscls@163.com committed
1698
    : bindObj;
徐立's avatar
徐立 committed
1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717



    if (this.props.fatherCode == null) {
      if (dataColumn == null) {
        dataColumn = { base52: this.props.uuid }
        required = false;
      } else {
        if (!dataColumn.isNull) {
          required = true;
        }
      }
    }


    var title = json.label || (dataColumn && dataColumn.title)
    var initValue;
    if (init != null) {
      if (this.props.fatherCode != null) {
chscls@163.com's avatar
chscls@163.com committed
1718
        initValue = init[this.props.index] != null ? init[this.props.index][bindObj?bindObj.base52:this.props.uuid] : null;
徐立's avatar
徐立 committed
1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735

      } else {
        initValue = init[dataColumn.base52];
      }


    } else {
      if (json.initialValue != null) {
        try {
          initValue = JSON.parse(json.initialValue)
        } catch (e) {
          initValue = null
        }

      }
    }
    if (!isEdit) {
chscls@163.com's avatar
chscls@163.com committed
1736
     
徐立's avatar
徐立 committed
1737
      if (this.props.fatherCode) {
chscls@163.com's avatar
chscls@163.com committed
1738 1739 1740 1741 1742 1743 1744
        if(bindObj!=null){
          dataColumn.base52 = bindObj.base52
        }else{
          dataColumn.base52 = this.props.uuid
        }
      
       
徐立's avatar
徐立 committed
1745 1746 1747 1748 1749 1750 1751 1752 1753
      }


      switch (json.comName) {
        // 电子签章展示
        // case 'Signature':
        //   cm = <img  src={queryApiActionPath()+obj[dataColumn.base52]} />
        //   break;
        case 'TextArea':
徐立's avatar
徐立 committed
1754
          cm = <span>{obj[dataColumn.base52]}</span>;
徐立's avatar
徐立 committed
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872
          break;
        case 'Switch':

          cm = <span>{obj[dataColumn.base52]}</span>;

          break;
        case 'Input':
          cm = <span>{obj[dataColumn.base52]}</span>;

          break;
          case 'InputHidden':

            cm = <></>;

            break;
        case 'InputNumber':

          cm = <span>{obj[dataColumn.base52]}</span>;

          break;
        /**
         * 为Radio为单选
         */
        case 'Radio':

          cm = <span>{labels != null && labels.length > 0 ? Object.values(labels[0]) : ""}</span>;

          break;
        /**
         * 为Checked为多选
         * 该组件需要调用请求
         */
        case 'Checkbox':
          cm = <span>{labels != null ? labels.map((r, i) => i == 0 ? typeof r == 'string' ? <span>{r}</span> : Object.values(r) : typeof r == 'string' ? <span style={{ marginLeft: 12 }}>{r}</span> : "," + Object.values(r)) : ""}</span>;

          break;
        case 'Select':

          cm = <span>{labels != null && labels.length > 0 ? Object.values(labels[0]) : ""}</span>;

          break;
        case 'TableSelect':
          const ds = obj[dataColumn.base52] && obj[dataColumn.base52].selects ? Object.values(obj[dataColumn.base52].selects) : []

          if (json.showTable) {

            cm = <Table columns={this.state.columns} size="small" dataSource={ds} pagination={false} />;

          } else {
            cm = <span>{ds.map((r, i) => i == 0 ? r[json.labelName] : "," + r[json.labelName])}</span>;
          }

          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) {
            if (!isEdit) {
              r:
              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>

            } else {
              cm = getFieldDecorator(begin.base52 + '_' + end.base52, {
                initialValue: ivs,
                rules: [{ required: required, message: '请选择起止时间' }],
              })(<RangePicker showTime />);
            }
          } else {
            cm = ""
          }
          title = '起止时间';
          break;
        case 'DatePicker':
          if (obj[dataColumn.base52] && obj[dataColumn.base52].indexOf('-') === -1) {
            cm = (
              <span>{moment(parseInt(obj[dataColumn.base52])).format(json.format ? json.format : 'YYYY-MM-DD HH:mm:ss')}</span>
            );
          } else {
            cm = (
              <span>{obj[dataColumn.base52] ? moment(+new Date(obj[dataColumn.base52])).format(json.format ? json.format : 'YYYY-MM-DD HH:mm:ss') : ""}</span>
            );
          }

          break;


        case 'UploadCom':
          /**
           * 查找不到数据 添加判断
           * 只有一个附件返回的是一个对象不是数组,暂时使用2个判断
           */
          if (!isEmpty(obj[dataColumn.base52])) { // 首先判断是否为空对象
            let ary
            /**
             * 判断返回值是否为JSON字符串,不是则直接使用
             */
            if (this.isJSON(obj[dataColumn.base52])) {
              ary = JSON.parse(obj[dataColumn.base52])
            } else {
              ary = obj[dataColumn.base52]
            }
            if (!!ary.files) { // 然后判断存在多个附件的数组是否存在
              const files = !isEmpty(ary) ? ary.files : [];
              cm = (
                <ul>
                  {files.map((f, index2) => {
                    if (f.path.indexOf('.png') != -1 || f.path.indexOf('.jpg') != -1) {
                      return <img key={index2} style={{ width: 100, height: 100 }} src={queryApiActionPath() + f.path} />
                    }
徐立's avatar
徐立 committed
1873
                    // if(get === 'web'){
徐立's avatar
徐立 committed
1874
                    //   return <li key={index2}><FilePreview
徐立's avatar
徐立 committed
1875 1876 1877 1878
                    //                 path={queryApiActionPath() + f.path}
                    //                 pathName={f.name}
                    //                 /></li>
                    // }
徐立's avatar
徐立 committed
1879 1880
                    return <li key={index2}><a target="_blank" key={f.path} href={queryApiActionPath() + f.path}>
                      {f.name}
徐立's avatar
徐立 committed
1881

徐立's avatar
徐立 committed
1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893
                    </a></li>
                  })}
                </ul>
              );
            } else {
              const files = !isEmpty(ary) ? ary : [];
              cm = (
                <ul>
                  {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} />
                    }
徐立's avatar
徐立 committed
1894
                    // if(get === 'web'){
徐立's avatar
徐立 committed
1895
                    //   return <li key={index2}><FilePreview
徐立's avatar
徐立 committed
1896 1897 1898 1899
                    //                 path={queryApiActionPath() + f.path}
                    //                 pathName={f.name}
                    //                 /></li>
                    // }
徐立's avatar
徐立 committed
1900 1901 1902 1903 1904 1905 1906 1907
                    return <li key={index2}><a target="_blank" key={f.filePath} href={queryApiActionPath() + f.filePath}>
                      {f.fileName}
                    </a></li>
                  })}
                </ul>
              );
            }
          } else {
徐立's avatar
徐立 committed
1908
            cm = <span style={{display:'inline-block',width:'100%',textAlign:'center'}}>暂无附件</span>
徐立's avatar
徐立 committed
1909 1910 1911 1912 1913 1914 1915
          }


          break;
        case 'ImgUploadCom':


chscls@163.com's avatar
1  
chscls@163.com committed
1916 1917 1918 1919 1920
          if(obj[dataColumn.base52]==null||obj[dataColumn.base52]==""){
            cm=<div style={{ width: json.width, height: json.height }}></div>
          }else{
            cm = <img src={config.httpServer + obj[dataColumn.base52]} style={{ width: json.width, height: json.height }} />;
          }
徐立's avatar
徐立 committed
1921

徐立's avatar
徐立 committed
1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939


          break;
        case 'Signature':

          cm = <img src={config.httpServer + obj[dataColumn.base52]} style={{ width: get === 'mobile' ? document.documentElement.clientWidth - 39 || document.body.clientWidth - 39 : json.width, height: get === 'mobile' ? '' : json.height }} />;

          break;
        case 'ChildForm':
          const xxxxx = obj[dataColumn.base52]
          if (xxxxx == null) {
            cm = <></>
            break;
          }
          if (Object.keys(xxxxx).length > 0) {
            delete xxxxx[""]
          }

chscls@163.com's avatar
chscls@163.com committed
1940
          cm = <ChildForm fatherObj={obj} json={json} rights={json.rights || ["add", "delete"]} isMobile={get === 'mobile'} value={xxxxx} 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} />
徐立's avatar
徐立 committed
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961
          break;
        case 'Button':

          let events = {}

          if (json.events != null) {
            events = this.getFunctionValue(json.events, { base52: this.props.uuid }, json)
          }
          if(events&&events.dom){
            cm=events.dom
          }else{
            const ev = {
              children:json.initialValue,
              ...events
            }
            if(json.isLink){
              cm = <a {...ev}/>
            }else{
              cm = <Button loading={this.props.loading} type="primary" {...ev}/>
            }
          }
徐立's avatar
徐立 committed
1962 1963 1964 1965




徐立's avatar
徐立 committed
1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
          break;
        case 'LocationCom':
          cm = <span></span>
          break;


        case 'Table':
          if (json.objCode == null || json.objCode == "") {
            cm = <></>
          }
徐立's avatar
徐立 committed
1976 1977 1978 1979 1980 1981 1982 1983 1984
          cm = <TableList 
                    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
1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
          break;
        default:
          cm = <span>缺乏字段{json.comName}的匹配项</span>
          break;

      }
    } else {
      if (json.vlds && json.vlds.length > 0) {
        for (let i in json.vlds) {
          if (json.vlds[i].validatorFunc && json.vlds[i].validatorFunc != "") {
            try {
              let fn = new Function("rule", "value", "callback", json.vlds[i].validatorFunc);
              json.vlds[i].validator = fn
            } catch (e) {
              console.log(e)
            }
          }
        }
      }
      switch (json.comName) {
        case 'Button':

          let events = {}

          if (json.events != null) {
            events = this.getFunctionValue(json.events, { base52: this.props.uuid }, json)
          }
          if(events&&events.dom){
            cm=events.dom
          }else{
            const ev = {
              children:json.initialValue,
              ...events
            }
            if(json.isLink){
              cm = <a {...ev}/>
            }else{
              cm = <Button loading={this.props.loading} type="primary" {...ev}/>
            }
          }
徐立's avatar
徐立 committed
2025 2026


徐立's avatar
徐立 committed
2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282
          break;
        case 'TextArea':
          if (get === 'mobile') {

            cm = (

              <MobileTextareaItem
                {...getFieldProps(dataColumn.base52, {
                  initialValue: initValue,
                  rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请输入' + title }],
                })}
                //disabled={disabled}
                style={{ fontSize: 14 }}

                clear
                autoHeight
                // title={<span className={styles.text}>{dataColumn.title}</span>}
                placeholder={json.placeholder}
              />
            )
            if (json.isLabel && title) {
              cm = <Form.Item
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </Form.Item>
            }
          } else {

            cm = getFieldDecorator(dataColumn.base52, {
              initialValue: initValue,
              rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请输入' + title }],
            })(<TextArea disabled={disabled} rows={4} placeholder={json.placeholder} />);
          }
          break;
        case 'Switch':
          if (get === 'mobile') {
            if (dataColumn == null || json.formula != null) { cm = this.props.form.getFieldValue(this.props.uuid); break }
            cm = (
              <MobileList.Item
                extra={<MobileSwitch
                  {...getFieldProps(dataColumn.base52, {
                    initialValue: initValue,
                    rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择' + title }],
                  })}
                  disabled={disabled}
                  onClick={(checked) => {
                    // set new value
                    this.props.form.setFieldsValue({
                      [dataColumn.base52]: checked,
                    });
                  }}
                />}
              >{json.isLabel ? title : ""}</MobileList.Item>
            )
            break
          }

          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            valuePropName: 'checked',
            rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择' + title }],
          })(<Switch disabled={disabled} checkedChildren={json.checkedChildren} unCheckedChildren={json.unCheckedChildren} />);

          break;
        case 'Input':
          if (get === 'mobile') {
            cm = (<div className={styles.form}><MobileInputItem
              type={'text'}
              className="mobile-form-input-left"
              {...getFieldProps(dataColumn.base52, {
                initialValue: initValue, // 默认值
                rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{
                  required: required,
                  message: '请输入' + title,
                }],
              })}
              clear
              disabled={disabled}
              placeholder={json.placeholder ? json.placeholder : '请输入' + (title ? title : '')}
            >
              {json.isLabel ?
                title ?
                  <span className={styles.text}>
                    {required ? must : ''}
                    {title}</span>
                  : ''
                : get === 'mobile' ?
                  <span className={styles.text}>{required ? must : ''}请输入:
                          {/* {title} */}
                  </span>
                  : ''}
            </MobileInputItem></div>)
            break
          }
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请输入' + title }],
          })(<Input disabled={disabled} style={{ width: json.width }} placeholder={json.placeholder} />);
          break;
          case 'InputHidden':

            cm = getFieldDecorator(dataColumn.base52, {
              initialValue: initValue
            })(<Input type="hidden" />);
          break;
        case 'InputNumber':
            /* if (get === 'mobile') {

          cm = (<div className={styles.form}><MobileInputItem
              type={'digit'}
              className="mobile-form-input-left"
              {...getFieldProps(dataColumn.base52, {
                initialValue: initValue, // 默认值
                rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{
                  required: required,
                  message: '请输入',
                }],
              })}
              clear
              disabled={disabled}
              placeholder={json.placeholder ? json.placeholder : '请输入' + (title ? title : '')}
            >{json.isLabel ? title ? <span className={styles.text}>{title}</span> : '' : ''}</MobileInputItem></div>)
            break
          } */

          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请输入' + title }],
          })(<InputNumber disabled={disabled} placeholder={json.placeholder} max={json.max} min={json.min} precision={json.precision} step={json.step} />);
          if (get == 'mobile') {
            cm = <div>{cm}</div>
            if (json.isLabel && title) {
              cm = <Form.Item
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </Form.Item>
            }
          }
          break;

        /**
         * 为Radio为单选
         */
        case 'Radio':
          // if (get === 'mobile') {
          //   cm = (
          //     <MobilePicker
          //       cascade
          //       extra={<span className={styles.placeholder}>{required ? must : ''}{'请选择' + dataColumn.title}</span>}
          //       title={dataColumn.title}
          //       {...getFieldProps(dataColumn.base52, {
          //         initialValue: initValue, // 默认值
          //         rules: [{ required: required, message: '请选择' + dataColumn.title }],
          //       })}
          //       cols={1}
          //       disabled={disabled}
          //       data={options}
          //     >
          //       <MobileList.Item arrow="horizontal">
          //         <span className={styles.text}>
          //             {/* {dataColumn.title} */}
          //             请选择
          //         </span>
          //       </MobileList.Item>
          //     </MobilePicker>
          //   )
          //   break;
          // }
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择' + dataColumn.title }],
          })(<Radio.Group options={options} disabled={disabled} />);
          if (get == 'mobile') {
            cm = <div>{cm}</div>
            if (json.isLabel && title) {
              cm = <Form.Item
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </Form.Item>
            }
          }
          break;
        /**
         * 为Checked为多选
         * 该组件需要调用请求
         */
        case 'Checkbox':
          if (get === 'mobile') {
            cm = (
              <Flex
                direction='column'
                align='start'
              >
                {
                  getFieldDecorator(dataColumn.base52, {
                    initialValue: initValue, // 默认值
                    rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择' + dataColumn.title }],
                  })(
                    <Checkbox.Group options={options} disabled={disabled} />
                  )
                }
              </Flex>
            )

            if (json.isLabel && title) {
              cm = <Form.Item
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </Form.Item>
            }

            break
          }

          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择' + dataColumn.title }],
          })(<Checkbox.Group options={options} disabled={disabled} />);

          break;
        case 'Select':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择' + dataColumn.title }],
          })(
            <Select
              allowClear
              showSearch
              disabled={selectDis || disabled}
              placeholder={json.placeholder}
              style={{ width: json.width }}
              optionFilterProp="children"
              onFocus= {()=>{
                get === 'mobile'?// 移动端取消输入键盘弹出
                setTimeout(() => {
                  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');
                        //   })
                        // });
徐立's avatar
徐立 committed
2283

徐立's avatar
徐立 committed
2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433
                      })
                    }
                  })
                :null
              }}
              filterOption={(input, option) =>
                option ? option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 : false
              }
            >
              {options ? options.map(r => (
                <Option key={r.value} value={r.value}>
                  {r.label}
                </Option>
              )) : ""}
            </Select>
          );
          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          } else if (get === 'mobile') {
            cm = <div>{cm}</div>
          }

          break;
        case 'TableSelect':

          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue || {},

            rules: [{
              validator: (rule, value, callback) => {
                if (Object.keys(value).length == 0 && required != null && required) {
                  var errors = []
                  errors.push(new Error('请选择至少一个', rule.field))
                }
                callback(errors)
              }
              , required: required
            }]
          }

          )(
            <TableSelect json={json} dataColumn={dataColumn} columns={this.state.columns} dataSource={this.state.dataSource} sqlModel={this.state.sqlModel} />
          );
          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          }
          break;

        case 'RangePicker':

          const begin = dataColumn;
          var end = this.getColumn('c2');
          if (end == null) {
            end = { base52: this.props.uuid + "_2" }
          }
          const ivs = [];
          if (initValue != null && init != null) {
            ivs.push(moment(parseInt(initValue)));
            ivs.push(moment(parseInt(init[end.base52])));
          }
          if (!isEdit) {
            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>
            );
          } else {
            if (get === 'mobile') {

              cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
                initialValue: ivs,
                rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }],
              })(<MobileDate disabled={disabled} />);
              if (json.isLabel && title) {
                cm = <Form.Item
                  labelCol={{ span: json.labelSpan }}
                  wrapperCol={{ span: json.wrapperSpan }}
                  label={title}
                >
                  {cm}
                </Form.Item>
              }
              break
            }
            cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
              initialValue: ivs,
              rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }],
            })(<RangePicker showTime disabled={disabled} />);
          }
          if (json.label == null) title = '起止时间';
          break;
        case 'DatePicker':
          // if (get === 'mobile') {
          //   var iv = null;
          //   if (initValue != null) {
          //     iv = moment(initValue);
          //   }
          //   cm = getFieldDecorator(dataColumn.base52, {
          //     initialValue: iv,
          //     rules: json.vlds && json.vlds.length > 0 ?json.vlds: [{ required: required, message: '请选择起止时间' }],
          //   })(<div><DatePicker disabled={disabled} showTime format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'} /></div>);
          //   if (get === 'mobile' && json.isLabel && title) {
          //     cm = <Form.Item
          //       labelCol={{ span: json.labelSpan }}
          //       wrapperCol={{ span: json.wrapperSpan }}
          //       label={title}
          //     >
          //       {cm}
          //     </Form.Item>
          //   }
            // cm = (
            //   <MobileDatePicker
            //     mode={'date'}
            //     disabled={disabled}
            //     locale={{ okText: "确定", dismissText: '取消' }}
            //     extra={<span className={styles.placeholder}>{!!initValue ? moment(initValue).format('YYYY-MM-DD') : '请选择日期'}</span>}
            //     {...getFieldProps(dataColumn.base52, {
            //       initialValue: +moment(initValue).format('YYYY-MM-DD'), // 默认值
            //       rules: [
            //         { required: required, message: '请选择日期' },
            //         // { validator: this.validateDatePicker },
            //       ]
            //     })}
            //   >
            //     <MobileList.Item arrow="horizontal"><span className={styles.text}>{required ? must : ''}{dataColumn.title}</span></MobileList.Item>
            //   </MobileDatePicker>
            // )
          //   break
          // }
          var iv = null;
          if (initValue != null) {
            iv = moment(typeof initValue === 'string'?+initValue:initValue);
          }
          // console.log(iv,json.format)
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: iv,
            rules: json.vlds && json.vlds.length > 0 ? json.vlds : [{ required: required, message: '请选择起止时间' }],
徐立's avatar
徐立 committed
2434 2435 2436
          })(<DatePicker
              disabled={disabled}
              showTime
徐立's avatar
徐立 committed
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621
              onOpenChange = { get === 'mobile'?() => { // 取消唤起移动端小键盘
                setTimeout(() => {
                if(document.querySelector('.ant-calendar-input ')){
                    document.querySelector('.ant-calendar-input ').setAttribute('readonly', 'readonly');
                    setTimeout(() => {
                      document.querySelector('.ant-calendar-input ').removeAttribute('readonly');
                    });
                  }
                });
              }:()=>{}}
              format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'} />);
          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          }
          break;


        case 'UploadCom':
          let files = [];
          // if (initValue != null) {
          if (initValue != null && !isEmpty(initValue.files)) {
            files = initValue.files;
          }
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: { files: files },
            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: '请选择附件'
            }],
          })(<UploadCom />);
          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          }
          break;
        case 'LocationCom':


          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: {},

          })(<LocationCom get={get} btnName={json.btnName} btnSucName={json.btnSucName} width={json.width} showMap={json.showMap} />);
          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          }
          break;
        case 'ChildForm':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue || {},
          })(<ChildForm rights={json.rights || []} isMobile={get === 'mobile'} 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} />)

          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          }
          break;
        case 'ImgUploadCom':

          cm = getFieldDecorator("img$" + dataColumn.base52, {
            valuePropName: 'fileList[0]',
            getValueFromEvent: normFile,
          })(<Upload.Dragger disabled={disabled} accept={"image/*"} url={this.state.url || initValue} showUploadList={false} name="file" action={config.uploadUrl} onChange={info => this.changeUrl(info, dataColumn.base52)} multiple={false} style={{ padding: 0 }}>
            {this.state.url || initValue ? <img src={config.httpServer + (this.state.url || initValue)} style={{ height: json.height, width: json.width }} /> : <div style={{ height: json.height, width: json.width }}>

            </div>}

          </Upload.Dragger>);
          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          }
          break;
        case 'Signature':

          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules: [{ required: required, message: '请进行签名' }],
          })(<Signature width={get === 'mobile' ? document.documentElement.clientWidth - 39 || document.body.clientWidth - 39 : json.width} height={json.height} />);
          if (get === 'mobile' && json.isLabel && title) {
            cm = <Form.Item
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </Form.Item>
          }
          break;
        case 'Table':

          if (json.objCode == null || json.objCode == "") {
            cm = <></>

          } else {
            cm = <>{getFieldDecorator(dataColumn.base52||this.props.uuid , {
              initialValue: initValue || {}

            })(<TableList isHiddenPage={json.isHiddenPage}  showHeader={json.showHeader} loading={this.props.loading} pageSize={json.pageSize} objCode={json.objCode} sql={json.filterSql} rights={json.rights} />)}</>

          }
          break;
      }


    }



    if (json.isLabel) {
      if (get === 'mobile' && !this.props.isEdit) {

        /**
         * 列表类型
         */
        // return (<MobileList>
        //   <MobileList.Item extra={cm}>
        //   <span style={{fontSize:14}}>{title}:</span>
        //   </MobileList.Item>
        // </MobileList>)
        /**
         * 卡片类型
         */
        return (<Card style={{ margin: 5, border: '1px solid #ccc' }}>
          <Card.Header title={<span style={{ fontSize: 14 }}>{title}:</span>} />
          <Card.Body>
            {cm}
          </Card.Body>
        </Card>)
        // return <Flex direction='column'>
        //   <Flex.Item style={{width:'100%'}}>{title}:</Flex.Item>
        //   <Flex.Item style={{width:'100%',padding:'10px'}}>{cm}</Flex.Item>
        //   </Flex>
        // return <Row><Col span={6}>{title}:</Col><Col span={18}>{cm}</Col></Row>
      }
      if (get === 'web') {
        return (
          <Form.Item
            labelCol={{ span: json.labelSpan }}
            wrapperCol={{ span: json.wrapperSpan }}
            label={title}
          >
            {cm}
          </Form.Item>
        );
      } else {
        return cm
      }
    } else {
      return cm;
    }
  }
}