/**
 * 徐立
 * 2019年9月22日
 * 动态表格组件返回对应的组件
 */
import React, { Component } from 'react';
import md5 from 'js-md5';
import FormModal from './FormModal';
import {
  message,
  Icon,
  Input,
  InputNumber,
  Button,
  Checkbox,
  DatePicker,
  Radio,
  Switch,
  Modal,
  TimePicker,
  Row,
  Col,
  Select,
  Upload,
  Form,
  Table,
  notification,
} from 'antd';
import UUID from 'react-native-uuid';
import QRCode from 'qrcode.react';
import { EditorState, Editor } from 'draft-js';
import MyBlockRenderer from '../App/MyBlockRender';
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 Neo4jD3Com from '../libs/Neo4jD3Com';
import ImgUploadCom from '../libs/ImgUploadCom';
import moment from 'moment';
import router from 'umi/router';
import TableList from '../libs/TableList';
import styles from './style.less';
import config from '@/webPublic/one_stop_public/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';
import Signature from '../Signature';
import baseX from 'base-x';
import { changeToDraftState } from '../utils/myutils';
const Bs64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const base64 = baseX(Bs64);
import { Base16Encode } from '../Base16/index';
import { getToken } from '../utils/token';
import { formulaList } from '../excelInitFuc/functionList';
import FilePreview from '../filePreview';
import DraftEditorCom from '../App/DraftEditorCom';
import MobileItem from './MobileItem';
const Item = MobileList.Item;
const Brief = Item.Brief;
function getBase64(value) {
  return value ? base64.encode(new Buffer(value)) : null;
}
const codeMessage = {
  200: '服务器成功返回请求的数据。',
  201: '新建或修改数据成功。',
  202: '一个请求已经进入后台排队（异步任务）。',
  204: '删除数据成功。',
  400: '发出的请求有错误，服务器没有进行新建或修改数据的操作。',
  401: '登录已过期，请重新登录',
  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;

  if (response && response.status) {
    const errorText = codeMessage[response.status] || response.statusText;

    message.error(`请求错误${errorText}`);
    if (response.status === 401) {
      return window.g_app._store.dispatch({
        type: 'login/loginout',
      });
    }
  } else {
    message.error(`网络故障,请检查网络链接或联系管理员`);
  }
};

@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,
    modalProps: {},
    modalTitle: '',
    modalInit: {},
    modalCode: null,
    dataSource: {
      list: [],
      pagination: false,
    },
  };
  excludeKeys = ['defaultValues', ''];
  closeModal = callback => {
    const { dispatch } = this.props;

    dispatch({
      type: 'DataColumn/showModal',
      payload: { isShowModal: false },
      callback: callback,
    });
  };
  showModal = (fk, title, data, modalProps) => {
    const { dispatch } = this.props;
    dispatch({
      type: 'DataColumn/showModal',
      payload: { isShowModal: true },
      callback: () => {
        this.setState({
          modalInit: data,
          modalTitle: title,
          modalCode: fk,
          modalProps: modalProps,
        });
      },
    });
  };

  equal = (obj1, obj2, json, sqlContent, depth) => {
    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;
      }

      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;
      }

      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))
      ) {
        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++) {
            if (!this.equal(obj1[key][i], obj2[key][i], json, sqlContent, depth + 1)) {
              xx = false;
              break;
            }
          }

          if (!xx) {
            res = false;
            break;
          }
        }
      } else if (obj1[key] instanceof Object) {
        const x = this.equal(obj1[key], obj2[key], json, sqlContent, depth + 1);

        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 == 'p') return <p {...props} />;
    if (com == 'ul') return <ul {...props} />;
    if (com == 'li') return <li {...props} />;
    if (com == 'video') return <video {...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} />;
    if (com == 'iframe') return <iframe {...props} />;
    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} />;
    }
  };

  /**
   * 判断传入值是否为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;
      }
    }

  };
  /**
   * 上传文件输入
   * 使用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();

    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 || this.props.safe) {
      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();
    const bb = this.equal(this.obj, obj2, json, this.state.sqlContent, 1);
    let bb2 = true;
    let childObj2 = {};
    if (props.fatherCode) {
      if (obj2 != null && obj2[props.fatherCode]) {
        childObj2 = obj2[props.fatherCode][props.index];

        bb2 = this.equal(this.childObj, childObj2, json, this.state.sqlContent, 1);
      }
    }

    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.currentFormTitle} ${this.props.formKey} ${json.comName}第${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;
    }

    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.isEdit && this.props.fatherCode) {
      if (bindObj != null) {
        dataColumn.base52 = bindObj.base52;
      } else {
        dataColumn.base52 = this.props.uuid;
      }
    }

    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':
          if (json.funcs != null && json.funcs != '') {
            let enu;

            try {
              this.getFunctionValue(json.funcs, { base52: this.props.uuid }, json, () => {
                if (init != null && Object.keys(init).length > 0) {
                  let base52 = dataColumn.base52;
                  let vlu = this.props.form.getFieldValue(base52);
                  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) {
                  let base52 = dataColumn.base52;

                  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 });
                }
              });
            } catch (e) {
              message.error('公式选项配置存在问题');
            }
          }
          break;
      }
    }
  };

  setValues = (base52, json, values) => {
    try {
      this.props.form.setFieldsValue(values);
    } catch (e) {
      console.log(
        `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
        1}列:公式配置有误,回调函数内部错误,`,
        e,
      );
    }
  };
  reqUtil = (base52, json, orgCallback, url, method, params, callback, options = {}) => {
    //查缓存
    var isChange = true;
    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;
    }

    if (!isChange) {
      if (callback) {
        const data = reqUrls[url].data;

        if (json.optionType && json.optionType == 'func') {
          const res = callback(data);

          if (res != null && !(typeof res === 'function')) {
            this.setState({ options: res, selectDis: false }, () => {
              if (orgCallback) orgCallback();
            });
          }
        } else if (json.comName == 'Button') {
          try {
            callback(data);
          } catch (e) {
            console.log(
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
              1}列:公式配置有误,回调函数内部错误,`,
              e,
            );
            //message.error(`页面${this.props.formKey}第${this.props.i + 1}行,第${this.props.j + 1}列:公式配置有误,回调函数内部错误${e}`, 10)
          }
        } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
          try {
            const x = callback(data);
            if (x != null) {
              this.setState({ option: x });
            }
          } catch (e) {
            console.log(
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
              1}列:公式配置有误,回调函数内部错误,`,
              e,
            );
          }
        } 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} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          }
        }
      }
      return 'norefeshxxxxxxxxxxxxxxxxxxxx';
    }

    for (let i in params) {
      if (params[i] == null) {
        delete params[i];
      }
    }

    if (getToken() != null) {
      params.token = getToken();
    }

    const requestParams = params;
    const umiRequest = extend({
      errorHandler, // 默认错误处理
      credentials: 'omit', // 默认请求是否带上cookie
      mode: 'cors',
      ...options,
    });
    umiRequest(url, {
      data: requestParams,
      method: method,
      requestType: 'form',
    }).then(data => {
      const { reqUrls } = this.state;
      reqUrls[url].data = data;
      this.setState({ res: data, reqUrls }, () => {
        if (callback) {
          if (json.optionType && json.optionType == 'func') {
            const res = callback(data);

            if (res != null && !(typeof res === 'function')) {
              this.setState({ options: res, selectDis: false }, () => {
                if (orgCallback) orgCallback();
              });
            }
          } else if (json.comName == 'Button') {
            try {
              callback(data);
            } catch (e) {
              console.log(
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
            try {
              const x = callback(data);
              if (x != null) {
                this.setState({ option: x });
              }
            } catch (e) {
              console.log(
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          } 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.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                  1}列:公式配置有误,回调函数内部错误,`,
                  e,
                );
              }
            }
          }
        }
      });
    });


    return 'norefeshxxxxxxxxxxxxxxxxxxxx';
  };
  sqlUtil = (base52, json, orgCallback, sqlKey, params, callback, options = {}) => {
    //查缓存
    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;
          }
        }
      }
      if (!isChange) {
        const os = sqlKeys[sqlKey].options;
        if (Object.keys(options).length != Object.keys(os).length) {
          isChange = true;
        } else {
          for (var k in options) {
            if (os[k] == null || options[k] != os[k]) {
              isChange = true;
              break;
            }
          }
        }
      }


    } else {
      sqlKeys[sqlKey] = { params: params, options: options };
      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')) {
            this.setState({ options: res, selectDis: false }, () => {
              if (orgCallback) orgCallback();
            });
          }
        } else if (json.comName == 'Button') {
          try {
            callback(data);
          } catch (e) {
            console.log(
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
              1}列:公式配置有误,回调函数内部错误,`,
              e,
            );
          }
        } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
          try {
            const x = callback(data);
            if (x != null) {
              this.setState({ option: x });
            }
          } catch (e) {
            console.log(
              `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
              1}列:公式配置有误,回调函数内部错误,`,
              e,
            );
          }
        } 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.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          }
        }
      }
      return 'norefeshxxxxxxxxxxxxxxxxxxxx';
    }



    const url = queryApiActionPath() + '/DataColumnApi/getSqlData';
    this.setState({ sqlKeys }, () => {
      const umiRequest = extend({
        errorHandler, // 默认错误处理
        credentials: options.credentials || 'omit', // 默认请求是否带上cookie
        mode: options.mode || 'cors'
      });
      const allValues = JSON.stringify({
        ...this.props.obj,
        ...this.props.form.getFieldsValue(),
        ...this.props.defaultValues[this.props.formKey],
        ...options
      });
      const pp = { sqlKey: Base16Encode(sqlKey), params, allValues: Base16Encode(allValues) };
      if (getToken() != null) {
        pp.token = getToken();
      }

      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') {
            const res = callback(data);

            if (res != null && !(typeof res === 'function')) {
              this.setState({ options: res, selectDis: false }, () => {
                if (orgCallback) orgCallback();
              });
            }
          } else if (json.comName == 'Button') {
            try {
              callback(data);
            } catch (e) {
              console.log(
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == "Graph") {
            try {
              const x = callback(data);
              if (x != null) {
                this.setState({ option: x });
              }
            } catch (e) {
              console.log(
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,回调函数内部错误,`,
                e,
              );
            }
          } 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.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                  1}列:公式配置有误,回调函数内部错误,`,
                  e,
                );
              }
            }
          }
        }
      });
    });

    return 'norefeshxxxxxxxxxxxxxxxxxxxx';
  };

  getFunctionValue = (fun, column, json, callback) => {
    if (this.props.safe) return
    const base52 = column.base52;

    /**
     * 中台函数库注入
     * 动态生成表单配置函数所使用
     */
    let functionObj = {};
    formulaList.map(item => {
      item.children.map(arr => {
        functionObj[arr.callKey] = arr.function;
      });
    });
    try {
      var fun1 = new Function(
        'obj',
        'init',
        'modalInit',
        'defaultValues',
        'env',
        'index',
        'fatherCode',
        'utils',
        '$',
        'routerState',
        'shareData',
        'sceneRouter',
        fun,
      );
      let obj;

      if (!this.props.isEdit && this.props.fatherCode) {
        obj = {
          ...this.props.fatherObj,
          ...this.props.form.getFieldsValue(),
          ...this.props.defaultValues[this.props.formKey],
        };
      } else {
        obj = {
          ...(this.props.fatherObj ? this.props.fatherObj : {}),
          ...this.props.obj,
          ...this.props.form.getFieldsValue(),
          ...this.props.defaultValues[this.props.formKey],
        };
      }

      const value = fun1(
        obj,
        this.props.init,
        this.props.modalInit,
        this.props.defaultValues,
        {
          clientType: this.props.get,
          formCode: this.props.formCode,
          formId: this.props.formId,
          isEdit: this.props.isEdit,
          taskAssignee: this.props.taskAssignee,
          userId: this.props.userId,
        },
        this.props.index,
        this.props.fatherCode,
        {
          moment: moment,
          sql: this.sqlUtil.bind(this, base52, json, callback),
          message: message,
          importExcel: this.props.importExcel,
          router: router,
          uuid: UUID,
          setValues: this.setValues.bind(this, base52, json),
          req: this.reqUtil.bind(this, base52, json, callback),
          md5: md5,
          showModal: this.showModal,
          closeModal: this.closeModal,
          render: this.getRender,
          base64: getBase64,
          form: this.props.form,
        },
        functionObj,
        this.props.routerState,
        this.props.messageData,
        this.props.concealModel,
      );

      if (base52) {
        if (value != null && value == 'norefeshxxxxxxxxxxxxxxxxxxxx') {
        } else {
          /**
           * 会出现重复调用2次,然后NAN造成无限循环
           */
          if (isNaN(value)) {
            return;
          }
          if (json.comName == 'Button') {
            return value;
          } else if (json.optionType && json.optionType == 'func') {
            if (value != null && !(typeof value === 'function')) {
              this.setState({ options: value, selectDis: false }, () => {
                if (callback) callback();
              });
            }
          } else if (json.comName == 'Echart' || json.comName == 'QRCode' || json.comName == 'Graph') {
            this.setState({ option: value });
          } else {
            try {
              this.props.form.setFieldsValue({ [base52]: value });
            } catch {
              console.log(
                `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
                1}列:公式配置有误,函数内部错误,`,
                e,
              );
            }
          }
        }
      }
    } catch (e) {
      console.log(
        `页面${this.props.currentFormTitle} ${this.props.formKey} ${json.comName}第${this.props.i + 1}行,第${this.props.j +
        1}列:公式配置有误,暂存失败,`,
        e,
      );
    }
  };
  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 });
        },
      });
    }

    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.isEdit && this.props.fatherCode) {
      if (bindObj != null) {
        dataColumn.base52 = bindObj.base52;
      } else {
        dataColumn.base52 = this.props.uuid;
      }
    }

    this.getData(json, dataColumn, obj);
    if (json.formula != null && json.formula != '' && !this.props.safe) {
      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],
            });
          }

          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) {
      let base52 = dataColumn.base52;
      if (this.props.fatherCode) {
        const x = base52.split('.');
        base52 = x[x.length - 1];
      }
      if (obj[base52]) {
        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],
            });
          }

          if (!isExist && vl != null && options.length > 0) {
            //console.log("isExist",optionsx,vl,isExist)
            this.props.form.setFieldsValue({ [base52]: null });
          }

          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
    ) {
      return null;
    }

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

    return dataColumn;
  };

  render() {
    /**
     * json为申请表单
     * obj为查看详情用户输入值
     */
    let {
      json,
      obj,
      mapData,
      init,
      sqlData,
      defaultValues,
      get,
      formKey,
      isEdit,
      datas,
      taskAssignee,
      userId, i,
      j,
      isPreview,
      currentFormTitle,
      getCellValue
    } = this.props;
    const { options, labels, selectDis, modalCode, modalTitle, modalInit, modalProps } = this.state;
    const { getFieldDecorator, getFieldError, getFieldProps } = this.props.form;
    const disabled = json != null ? json.disabled : false;
    const permRank = json != null ? (json.permRank != null ? json.permRank : 0) : 0;
    if (json == null) {
      return <></>;
    }
    //私有
    if (!isEdit && permRank == 1 && taskAssignee != userId) {
      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 == 'Graph') {
      return (
        <Neo4jD3Com
          key={this.props.uuid}
          json={json}
          option={this.state.option || []} />
      );
    }


    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
            hfInstance={this.props.hfInstance}
            currentFormTitle={this.props.getCurrentFormTitle ? this.props.getCurrentFormTitle(fk) : null}
            getCellValue={getCellValue}
            taskAssignee={taskAssignee}
            isWebPrint={this.props.isWebPrint || false}
            userId={userId}
            key={fk}
            isPreview={isPreview}
            modalInit={modalInit}
            datas={datas}
            trees={this.props.trees}
            get={get}
            isChild={true}
            currentFormKey={fk}
            isEdit={isEdit}
            obj={obj}
            init={init}
            formCode={this.props.formCode}
            formId={this.props.formId}
            form={this.props.form}
            mapData={mapData}
            sqlData={sqlData}
            {...datas[fk]}
            defaultValues={defaultValues}
          />
        </>
      );
    }
    if (json.comName == 'Excel') {
      const value = getCellValue(i, j, currentFormTitle)
      const xx = <div style={{ textAlign: "center", height: value == null ? 20 : null }}>{value}</div>
      return xx;
    }
    if (json.comName == 'Label') {
      let uid;
      if (this.props.fatherCode != null) {
        uid = `${this.props.fatherCode}.[${this.props.index}].${this.props.uuid}`;
      } else {
        uid = this.props.uuid;
      }
      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,
              })(<Input type="hidden" />)}
              <span
                style={{

                  fontWeight: get == 'mobile' ? 'bold' : '',
                  marginRight: get == 'mobile' ? 12 : '',
                }}
                {...json.props}
              >
                {obj[this.props.uuid] || json.initialValue}
              </span>
            </>
          );
        } else {
          return (
            <>
              {this.props.form.getFieldDecorator(uid, {
                initialValue: this.props.form.getFieldValue(uid) || json.initialValue,
              })(<Input type="hidden" />)}
              <span
                style={{

                  fontWeight: get == 'mobile' ? 'bold' : '',
                  marginRight: get == 'mobile' ? 12 : '',
                }}
                {...json.props}
              >
                {this.props.form.getFieldValue(uid)}
              </span>
            </>
          );
        }
      }
    }

    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 (
                    !this.props.isPrint &&
                    (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':
          if (value == null || value == '') {
            cm = <div style={{ width: json.width, height: json.height }}></div>;
          } else {
            cm = (
              <>
                <img
                  src={config.httpServer + value}
                  style={{ width: json.width, height: json.height }}
                />
                {get === 'mobile' ? <br /> : ''}
              </>
            );
          }

          break;
      }
      if (get === 'mobile') {
        if (
          (json.isMobileLabel != null && json.isMobileLabel) ||
          (json.isMobileLabel == null && json.isLabel)
        ) {
          if (obj && obj.defaultValues && obj.defaultValues[formKey]) {
            return (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ''}
              >
                {cm}
              </MobileItem>
            );
          } else {
            return (
              <>
                <MobileItem
                  isPreview={isPreview}
                  labelCol={{ span: json.labelSpan }}
                  wrapperCol={{ span: json.wrapperSpan }}
                  label={json.label ? json.label : sqlData[key] ? sqlData[key].title : ''}
                >
                  {cm}
                </MobileItem>
                {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" />)}
              </>
            );
          }
        }
      } else {
        if (json.isLabel) {
          if (obj && obj.defaultValues && obj.defaultValues[formKey]) {
            if (!isEdit) {
              return (
                <Row
                  style={{
                    minHeight: 40,
                    lineHeight: '40px',
                  }}
                >
                  <Col
                    className={json.label ? json.label : sqlData[key] ? styles.row_col_div : ''}
                    span={json.labelSpan}
                    style={{
                      textAlign: json.labelSpan === 24 ? 'left' : 'right',
                      lineHeight: '40px',
                      whiteSpace: 'nowrap',
                      overflow: 'hidden',
                      fontSize: 14,
                      color: 'rgba(0,0,0,0.85)',
                    }}
                  >
                    {json.label ? (
                      <>
                        {json.label}
                        <span
                          style={{
                            position: 'relative',
                            top: '-0.5px',
                            margin: '0 8px 0 2px',
                          }}
                        >
                          :
                        </span>
                      </>
                    ) : sqlData[key] ? (
                      <>
                        {sqlData[key].title}
                        <span
                          style={{
                            position: 'relative',
                            top: '-0.5px',
                            margin: '0 8px 0 2px',
                          }}
                        >
                          :
                        </span>
                      </>
                    ) : (
                          ''
                        )}
                  </Col>
                  <Col
                    span={json.wrapperSpan}
                    style={{
                      position: 'relative',
                      lineHeight: '40px',
                      zoom: 1,
                      fontSize: 14,
                    }}
                  >
                    {cm}
                  </Col>
                </Row>
              );
            } else {
              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 {
            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;
    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 (dataColumn.isNull != null && !dataColumn.isNull) {
      required = true;
    }

    var title = json.label || (dataColumn && dataColumn.title);
    var initValue;
    const objinit = { ...init, ...obj };

    if (objinit != null) {
      if (this.props.fatherCode != null) {
        initValue =
          objinit[this.props.index] != null
            ? objinit[this.props.index][bindObj ? bindObj.base52 : this.props.uuid]
            : null;
      } else {
        initValue = objinit[dataColumn.base52];
      }
    } else {
      if (json.initialValue != null) {
        try {
          initValue = JSON.parse(json.initialValue);
        } catch (e) {
          initValue = null;
        }
      }
    }

    if (!isEdit) {
      if (this.props.fatherCode) {
        if (bindObj != null) {
          dataColumn.base52 = bindObj.base52;
        } else {
          dataColumn.base52 = this.props.uuid;
        }
      }

      switch (json.comName) {
        // 电子签章展示
        // case 'Signature':
        //   cm = <img  src={queryApiActionPath()+obj[dataColumn.base52]} />
        //   break;
        case 'RichText':
          cm = (
            <Editor
              key={dataColumn.base52}
              readOnly={true}
              blockRendererFn={MyBlockRenderer.bind(this, true, null, null, null)}
              editorState={changeToDraftState(obj[dataColumn.base52])}
            />
          );
          break;
        case 'TextArea':
          cm = (
            <span
              style={{
                wordBreak: 'break-all',
              }}
            >
              {obj[dataColumn.base52]}
            </span>
          );
          break;
        case 'Switch':
          cm = <span>{obj[dataColumn.base52]}</span>;

          break;
        case 'Input':
          cm = (
            <span
              style={{
                wordBreak: 'break-all',
              }}
            >
              {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
                get={get}
                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 (!obj[begin.base52]) {
              cm = <span>暂无</span>;
            } else {
              cm = (
                <span>
                  {moment(parseInt(obj[begin.base52])).format(
                    json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                  )}{' '}
                  至{' '}
                  {moment(parseInt(obj[end.base52])).format(
                    json.format ? json.format : 'YYYY-MM-DD HH:mm:ss',
                  )}
                </span>
              );
            }
          } else {
            cm = '';
          }
          title = title ? 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}
                    //     />
                    //   );
                    // }
                    if (get === 'web' && !this.props.isPrint) {
                      return (
                        <li key={index2}>
                          <FilePreview path={queryApiActionPath() + f.path} pathName={f.name} />
                        </li>
                      );
                    }
                    return (
                      <li key={index2}>
                        <a target="_blank" key={f.path} href={queryApiActionPath() + f.path}>
                          {f.name}
                        </a>
                      </li>
                    );
                  })}
                </ul>
              );
            } else {
              const files = !isEmpty(ary) ? ary : [];
              cm = (
                <ul>
                  {Array.isArray(files) &&
                    files.map((f, index2) => {
                      // if (f.filePath.indexOf('.png') != -1 || f.filePath.indexOf('.jpg') != -1) {
                      //   return (
                      //     <img
                      //       key={index2}
                      //       style={{ width: 100, height: 100 }}
                      //       src={queryApiActionPath() + f.filePath}
                      //     />
                      //   );
                      // }
                      if (get === 'web' || !this.props.isPrint) {
                        return (
                          <li key={index2}>
                            <FilePreview path={queryApiActionPath() + f.path} pathName={f.name} />
                          </li>
                        );
                      }
                      return (
                        <li key={index2}>
                          <a
                            target="_blank"
                            key={f.filePath}
                            href={queryApiActionPath() + f.filePath}
                          >
                            {f.fileName}
                          </a>
                        </li>
                      );
                    })}
                </ul>
              );
            }
          } else {
            cm = (
              <span style={{ display: 'inline-block', width: '100%', textAlign: 'center' }}>
                暂无附件
              </span>
            );
          }

          break;
        case 'ImgUploadCom':
          if (obj[dataColumn.base52] == null || obj[dataColumn.base52] == '') {
            cm = <div style={{ width: json.width, height: json.height }}></div>;
          } else {
            cm = FilePreview ? (
              <FilePreview
                path={config.httpServer + obj[dataColumn.base52]}
                pathName={obj[dataColumn.base52]}
                width={json.width}
                height={json.height}
              />
            ) : (
                <img
                  src={config.httpServer + obj[dataColumn.base52]}
                  style={{ width: json.width, height: json.height }}
                />
              );
          }

          break;
        case 'Signature':
          cm = (
            <img
              src={config.httpServer + obj[dataColumn.base52]}
              style={{
                marginLeft: 5,
                width:
                  get === 'mobile'
                    ? document.documentElement.clientWidth - 10 || document.body.clientWidth - 10
                    : json.width,
                height: get === 'mobile' ? '' : json.height,
              }}
            />
          );

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

          cm = (
            <ChildForm
              modalInit={modalInit}
              trees={this.props.trees}
              isPreview={isPreview}
              hfInstance={this.props.hfInstance}
              getCurrentFormTitle={this.props.getCurrentFormTitle}
              getCellValue={getCellValue}

              fatherObj={obj}
              json={json}
              rights={json.rights || ['add', 'delete']}
              isMobile={get === 'mobile'}
              value={xxxxx}
              deleteName={json.deleteName}
              addName={json.addName}
              isEdit={isEdit}
              formCode={this.props.formCode}
              formId={this.props.formId}
              base52={dataColumn.base52}
              mapData={mapData}
              datas={datas ? datas[json.childFormKey] : null}
              defaultValues={defaultValues}
              sqlData={sqlData}
              form={this.props.form}
            />
          );
          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} />;
            }
          }

          break;
        case 'LocationCom':
          cm = <span></span>;
          break;

        case 'Table':
          if (json.objCode == null || json.objCode == '') {
            cm = <></>;
          }
          cm = (
            <TableList
              get={get}
              isTree={json.isTree}
              json={json}
              loading={this.props.loading}
              showHeader={json.showHeader}
              isHiddenPage={json.isHiddenPage}
              pageSize={json.pageSize}
              value={obj[dataColumn.base52 || this.props.uuid] || {}}
              objCode={json.objCode}
              sql={json.filterSql}
              rights={json.rights}
            />
          );
          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} />;
            }
          }

          break;
        case 'TextArea':
          if (get === 'mobile') {
            cm = getFieldDecorator(dataColumn.base52, {
              initialValue: initValue,
              rules:
                json.vlds && json.vlds.length > 0
                  ? json.vlds
                  : [{ required: required, message: '请输入' + title }],
            })(
              <TextArea
                autosize={{ minRows: 4 }}
                disabled={disabled}
                placeholder={json.placeholder}
              />,
            );
            /*  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.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && 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
                autosize={{ minRows: 4 }}
                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.isMobileLabel != null && json.isMobileLabel) ||
                  (json.isMobileLabel == null && 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':
          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}
            />,
          );
          if (get == 'mobile') {
            cm = <div>{cm}</div>;
            if (
              ((json.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
              cm = (
                <MobileItem
                  isPreview={isPreview}
                  labelCol={{ span: json.labelSpan }}
                  wrapperCol={{ span: json.wrapperSpan }}
                  label={title}
                >
                  {cm}
                </MobileItem>
              );
            }
          }
          break;
        case 'InputHidden':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
          })(<Input type="hidden" />);
          break;
        case 'InputNumber':
          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.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
              cm = (
                <MobileItem
                  isPreview={isPreview}
                  labelCol={{ span: json.labelSpan }}
                  wrapperCol={{ span: json.wrapperSpan }}
                  label={title}
                >
                  {cm}
                </MobileItem>
              );
            }
          }
          break;

        /**
         * 为Radio为单选
         */
        case 'Radio':
          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.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
              cm = (
                <MobileItem
                  isPreview={isPreview}
                  labelCol={{ span: json.labelSpan }}
                  wrapperCol={{ span: json.wrapperSpan }}
                  label={title}
                >
                  {cm}
                </MobileItem>
              );
            }
          }
          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.isMobileLabel != null && json.isMobileLabel) ||
                (json.isMobileLabel == null && json.isLabel)) &&
              title
            ) {
              cm = (
                <MobileItem
                  isPreview={isPreview}
                  labelCol={{ span: json.labelSpan }}
                  wrapperCol={{ span: json.wrapperSpan }}
                  label={title}
                >
                  {cm}
                </MobileItem>
              );
            }

            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"
              getPopupContainer={
                this.props.isDynamic && document.querySelector('#dynamic_div')
                  ? () => {
                    return document.querySelector('#dynamic_div');
                  }
                  : ''
              }
              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');
                        //   })
                        // });
                      });
                    }
                  })
                  : 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.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          } else if (get === 'mobile') {
            cm = <div>{cm}</div>;
          }

          break;
        case 'TableSelect':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue || {},

            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [
                  {
                    validator: (rule, value, callback) => {
                      if (
                        (Object.keys(value).length == 0 ||
                          Object.keys(value.selects).length == 0) &&
                        required != null &&
                        required
                      ) {
                        var errors = [];
                        errors.push(new Error('请选择至少一个', rule.field));
                      }
                      callback(errors);
                    },
                    required: required,
                  },
                ],
          })(
            <TableSelect
              get={get}
              json={json}
              dataColumn={dataColumn}
              columns={this.state.columns}
              dataSource={this.state.dataSource}
              sqlModel={this.state.sqlModel}
            />,
          );
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          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} formate={json.format} />);
              if (
                ((json.isMobileLabel != null && json.isMobileLabel) ||
                  (json.isMobileLabel == null && json.isLabel)) &&
                title
              ) {
                cm = (
                  <MobileItem
                    isPreview={isPreview}
                    labelCol={{ span: json.labelSpan }}
                    wrapperCol={{ span: json.wrapperSpan }}
                    label={title}
                  >
                    {cm}
                  </MobileItem>
                );
              }
              break;
            }
            cm = getFieldDecorator(begin.base52 + '$' + end.base52, {
              initialValue: ivs,
              rules:
                json.vlds && json.vlds.length > 0
                  ? json.vlds
                  : [{ required: required, message: '请选择起止时间' }],
            })(
              <RangePicker
                showTime={json.showTime != null ? json.showTime : true}
                format={json.format ? json.format : 'YYYY-MM-DD HH:mm:ss'}
                disabled={disabled}
              />,
            );
          }
          if (json.label == null) title = '起止时间';
          break;
        case 'DatePicker':
          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: '请选择起止时间' }],
          })(
            <DatePicker
              disabled={disabled}
              showTime={json.showTime != null ? json.showTime : true}
              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.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          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.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          break;
        case 'RichText':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [{ required: required, message: '请输入' }],
          })(<DraftEditorCom placeholder={json.placeholder} />);
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          break;
        case 'LocationCom':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: {},
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [{ required: required, message: '请进行定位' }],
          })(
            <LocationCom
              get={get}
              btnName={json.btnName}
              btnSucName={json.btnSucName}
              width={json.width}
              showMap={json.showMap}
            />,
          );
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          break;
        case 'ChildForm':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue || {},
          })(
            <ChildForm
              rights={json.rights || []}
              hfInstance={this.props.hfInstance}
              getCurrentFormTitle={this.props.getCurrentFormTitle}
              getCellValue={getCellValue}
              isMobile={get === 'mobile'}
              trees={this.props.trees}
              fatherObj={obj}
              isPreview={isPreview}
              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.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          break;
        case 'ImgUploadCom':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [{ required: required, message: '请上传图片' }],
          })(<ImgUploadCom json={json} disabled={disabled} />);
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          break;
        case 'Signature':
          cm = getFieldDecorator(dataColumn.base52, {
            initialValue: initValue,
            rules:
              json.vlds && json.vlds.length > 0
                ? json.vlds
                : [{ required: required, message: '请进行签名' }],
          })(
            <Signature
              width={
                get === 'mobile'
                  ? document.documentElement.clientWidth - 10 || document.body.clientWidth - 10
                  : json.width
              }
              height={json.height}
            />,
          );
          if (
            get === 'mobile' &&
            ((json.isMobileLabel != null && json.isMobileLabel) ||
              (json.isMobileLabel == null && json.isLabel)) &&
            title
          ) {
            cm = (
              <MobileItem
                isPreview={isPreview}
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </MobileItem>
            );
          }
          break;
        case 'Table':
          if (json.objCode == null || json.objCode == '') {
            cm = <></>;
          } else {
            cm = (
              <>
                {getFieldDecorator(dataColumn.base52 || this.props.uuid, {
                  initialValue: initValue || {},
                })(
                  <TableList
                    json={json}
                    isTree={json.isTree}
                    isHiddenPage={json.isHiddenPage}
                    showHeader={json.showHeader}
                    loading={this.props.loading}
                    pageSize={json.pageSize}
                    objCode={json.objCode}
                    sql={json.filterSql}
                    rights={json.rights}
                    get={get}
                  />,
                )}
              </>
            );
          }
          break;
      }
    }

    if (json.isLabel) {
      if (get === 'mobile' && !this.props.isEdit) {
        return (
          <Card style={{ margin: 5, border: '1px solid #ccc' }}>
            {modalCode ? (
              <FormModal
                {...modalProps}
                visible={this.props.DataColumn.isShowModal}
                handleCancel={this.closeModal}
                title={modalTitle}
              >
                <ZdyTable
                  taskAssignee={taskAssignee}
                  userId={userId}
                  trees={this.props.trees}
                  modalInit={modalInit}
                  key={modalCode}
                  datas={datas}
                  get={get}
                  isChild={true}
                  currentFormKey={modalCode}
                  isEdit={isEdit}
                  obj={obj}
                  init={init}
                  form={this.props.form}
                  mapData={mapData}
                  sqlData={sqlData}
                  {...datas[modalCode]}
                  defaultValues={defaultValues}
                />
              </FormModal>
            ) : (
                ''
              )}
            <Card.Header title={<span style={{ fontSize: 14 }}>{title}:</span>} />
            <Card.Body>{cm}</Card.Body>
          </Card>
        );
      }
      if (get === 'web') {

        if (!isEdit) {
          return (
            <Row
              style={{
                minHeight: 40,
                lineHeight: '40px',
              }}
            >
              <Col
                className={title ? styles.row_col_div : ''}
                span={json.labelSpan}
                style={{
                  textAlign: json.labelSpan === 24 ? 'left' : 'right',
                  lineHeight: '40px',
                  whiteSpace: 'nowrap',
                  overflow: 'hidden',
                  fontSize: 14,
                  color: 'rgba(0,0,0,0.85)',
                }}
              >
                {title}
                {title && (
                  <span
                    style={{
                      position: 'relative',
                      top: '-0.5px',
                      margin: '0 8px 0 2px',
                    }}
                  >
                    :
                  </span>
                )}
              </Col>
              <Col
                span={json.wrapperSpan}
                style={{
                  position: 'relative',
                  lineHeight: '40px',
                  zoom: 1,
                  fontSize: 14,
                }}
              >
                {cm}
              </Col>
              {modalCode ? (
                <FormModal
                  {...modalProps}
                  visible={this.props.DataColumn.isShowModal}
                  handleCancel={this.closeModal}
                  title={modalTitle}
                >
                  <ZdyTable
                    taskAssignee={taskAssignee}
                    userId={userId}
                    trees={this.props.trees}
                    modalInit={modalInit}
                    key={modalCode}
                    datas={datas}
                    get={get}
                    isChild={true}
                    currentFormKey={modalCode}
                    isEdit={isEdit}
                    obj={obj}
                    init={init}
                    form={this.props.form}
                    mapData={mapData}
                    sqlData={sqlData}
                    {...datas[modalCode]}
                    defaultValues={defaultValues}
                  />
                </FormModal>
              ) : (
                  ''
                )}
            </Row>
          );
        } else {

          return (
            <>
              {modalCode ? (
                <FormModal
                  {...modalProps}
                  visible={this.props.DataColumn.isShowModal}
                  handleCancel={this.closeModal}
                  title={modalTitle}
                >
                  <ZdyTable
                    taskAssignee={taskAssignee}
                    userId={userId}
                    trees={this.props.trees}
                    modalInit={modalInit}
                    key={modalCode}
                    datas={datas}
                    get={get}
                    isChild={true}
                    currentFormKey={modalCode}
                    isEdit={isEdit}
                    obj={obj}
                    init={init}
                    form={this.props.form}
                    mapData={mapData}
                    sqlData={sqlData}
                    {...datas[modalCode]}
                    defaultValues={defaultValues}
                  />
                </FormModal>
              ) : (
                  ''
                )}
              <Form.Item
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </Form.Item>
            </>
          );
        }
      } else {
        return (
          <>
            {modalCode ? (
              <FormModal
                {...modalProps}
                visible={this.props.DataColumn.isShowModal}
                handleCancel={this.closeModal}
                title={modalTitle}
              >
                <ZdyTable
                  taskAssignee={taskAssignee}
                  userId={userId}
                  modalInit={modalInit}
                  trees={this.props.trees}
                  key={modalCode}
                  datas={datas}
                  get={get}
                  isChild={true}
                  currentFormKey={modalCode}
                  isEdit={isEdit}
                  obj={obj}
                  init={init}
                  form={this.props.form}
                  mapData={mapData}
                  sqlData={sqlData}
                  {...datas[modalCode]}
                  defaultValues={defaultValues}
                />
              </FormModal>
            ) : (
                ''
              )}
            {cm}
          </>
        );
      }
    } else {
      return (
        <>
          {modalCode ? (
            <FormModal
              {...modalProps}
              visible={this.props.DataColumn.isShowModal}
              handleCancel={this.closeModal}
              title={modalTitle}
            >
              <ZdyTable
                taskAssignee={taskAssignee}
                userId={userId}
                trees={this.props.trees}
                modalInit={modalInit}
                key={modalCode}
                datas={datas}
                get={get}
                isChild={true}
                currentFormKey={modalCode}
                isEdit={isEdit}
                obj={obj}
                init={init}
                form={this.props.form}
                mapData={mapData}
                sqlData={sqlData}
                {...datas[modalCode]}
                defaultValues={defaultValues}
              />
            </FormModal>
          ) : (
              ''
            )}
          {json.isMobileLabel && !isEdit && get == 'mobile' ? (
            <MobileItem
              isPreview={isPreview}
              labelCol={{ span: json.labelSpan }}
              wrapperCol={{ span: json.wrapperSpan }}
              label={title}
            >
              {cm}
            </MobileItem>
          ) : isEdit && get == 'web' ? (
            json.isLabel ? (
              <Form.Item
                labelCol={{ span: json.labelSpan }}
                wrapperCol={{ span: json.wrapperSpan }}
                label={title}
              >
                {cm}
              </Form.Item>
            ) : (
                <Form.Item>{cm}</Form.Item>
              )
          ) : (
                cm
              )}
        </>
      );
    }
  }
}
