/* eslint-disable no-cond-assign */
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable prettier/prettier */
/* eslint-disable guard-for-in */
/* eslint-disable eqeqeq */
/* eslint-disable no-lonely-if */
/* eslint-disable no-restricted-syntax */
/* eslint-disable indent */
/* eslint-disable prefer-destructuring */
/* eslint-disable import/order */
/* eslint-disable default-case */
/* eslint-disable one-var */
/* eslint-disable no-unused-expressions */
/* eslint-disable no-case-declarations */
import React, { useState, useEffect } from 'react';
import {
  Form,
  Modal,
  Input,
  Select,
  Radio,
  Checkbox,
  notification,
  Tooltip,
  Drawer,
  Space,
  Button,
  Empty,
  Col,
  Row,
  TreeSelect,
  Image,
  Switch,
} from 'antd';
import AllImage from '@/assets/images/title/All.png';
import TreeImage from '@/assets/images/title/Tree.png';
import partImage from '@/assets/images/title/part.png';
import {
  getField,
  loadTableFields,
  LoadEventFields,
  LoadEventType,
  UpdateFields,
  reloadTableFields,
} from '@/services/tablemanager/tablemanager';
import {
  PlusSquareOutlined,
  UnorderedListOutlined,
  FontColorsOutlined,
  InfoCircleOutlined,
  MinusCircleOutlined,
  PlusOutlined,
  SwapOutlined,
  CodeSandboxCircleFilled,
} from '@ant-design/icons';

import styles from './index.less';
import VerifyModal from './VerifyModal';
import Tree from '@/components/ExpendableTree';
import RuleConfig from '@/components/RuleConfig';
import Things from '../../../../../assets/images/icons/时间.svg';
import logo from '@/assets/images/icons/值映射.png';
import AddForm from '../../../../productCenter/webConfig/menuconfig/AddForm';
const AddModal = props => {
  const {
    callBackSubmit = () => { },
    isType,
    itemData,
    isVisible,
    formObj1,
    onCancel,
    treeData,
    keepTreeFirst,
    keepStandingBook,
    keepTreeData,
    keepTree,
  } = props;
  const [loading, setLoading] = useState(false);
  const [fieldName, setFieldName] = useState([]); // 弹窗
  const [eventList, setEventList] = useState([]); // 事件
  const [filed, setFiled] = useState({}); // 事件
  const [treeValue, setTreeValue] = useState([]);
  const [verification, setVerification] = useState([]);
  const [Shape, setShape] = useState('');
  const [treeSelectValue, setTreeSelectValue] = useState(undefined);
  const [pep, setPep] = useState(false);
  const [cho, setCho] = useState(false);
  const [site, setSite] = useState(false);
  const [flag, setFlag] = useState(false);
  const [saveBtnLoading, setSaveBtnLoading] = useState(false);

  const [characteristics1, setCharacteristics1] = useState([
    {
      name: '文本类',
      ID: 0,
      children: [
        '文本',
        '唯一值文本',
        '多行文本',
        '本人部门',
        '本人姓名',
        '数值',
        '地址',
        '设备二维码',
        // '本人ID',
        '富文本',
        '编码',
      ],
    },
    {
      name: '选择器类',
      ID: 1,
      children: [
        '选择器',
        '搜索选择器',
        '值选择器',
        '可编辑值选择器',
        '站点选择器',
        '人员选择器',
        '城市选择器',
        '台账选择器',
        '业务选择器',
        '部门选择器',
      ],
    },
    {
      name: '附件类',
      ID: 2,
      children: ['附件', '图片', '录音', '视频'],
    },
    {
      name: '时间类',
      ID: 3,
      children: ['日期时间', '日期', '日期月份', '日期年份', '日期周', '时分秒'],
    },
    {
      name: '地图类',
      ID: 4,
      children: ['坐标控件', '设备选择', '区域控件', '路径控件', '位置坐标'],
    },
    // {
    //   name: '台账专有类',
    //   ID: 5,
    //   children: ['智能抄表'],
    // },
    {
      name: '高级控件',
      ID: 5,
      children: ['关联表单'],
    },
  ]);
  const [visible, setVisible] = useState(false); // 弹窗
  const [isShow, setIsShow] = useState(false); // 弹窗
  const [type, setType] = useState(''); // 弹窗类型
  const [formObj, setFormObj] = useState({ rule: [], numerical: '' });
  const [characterValue, setCharacterValue] = useState('');
  const [show, setShow] = useState('block');
  const [hide, setHide] = useState(false);
  const [pramData, setPramData] = useState({
    Unit: '',
    ExceptionEvent: '',
    Group: '',
    RowSpan: '',
    ColSpan: '',
    ReadOnly: '',
    EditableLater: '',
    ExceptionValue: '',
    Preset: '',
    picture: '',
    must: '',
    coordinates: '',
  });
  const [currentSelectOrg, setCurrentSelectOrg] = useState([]);
  const [checkedList, setCheckedList] = useState([]); // 选中的复选框内容
  const [expendKey, setExpendKey] = useState(''); // 保存默认展开项
  const [valueData, setValueData] = useState([]); // 保存所有修改数据
  const [keep, setKeep] = useState();
  const [chee, setChee] = useState('');
  const [cheestyle, setCheestyle] = useState('');
  const [radio, setRadio] = useState('');
  const [radiostyle, setRadiostyle] = useState('');
  const [radio1, setRadio1] = useState('');
  const [radio3, setRadio3] = useState('');
  const [detail, setDetail] = useState('');
  const [checkboxAll1, setCheckboxAll1] = useState('');
  const [checkboxAllID1, setCheckboxAllID1] = useState('');
  const { TextArea } = Input;
  const [form] = Form.useForm();
  const { Item } = Form;
  const { TreeNode } = TreeSelect;
  const [timeData, setTimeData] = useState('');
  const { Option } = Select;
  const [synchronization, setSynchronization] = useState('');
  const [popeleShape, setPopeleShape] = useState('');
  const [gl, setGl] = useState('');
  const [cse, setCse] = useState('');
  const [view, setView] = useState(true);
  const [preView, setPreView] = useState(true);
  const [viewMuise, setViewMuise] = useState(true);
  const [preViewVideo, setPreViewVideo] = useState(true);
  const [visibleChecked, setVisibleChecked] = useState(true);
  const [formAdd] = Form.useForm();
  const [showRule, setShowRule] = useState(false);
  const [fieldList, setFieldList] = useState([]);
  const [fieldValue, setFeildValue] = useState([]); // 保存关联表单形态，字段名下拉框数据
  const [mapFieldValue, setMapFeildValue] = useState([]); // 保存关联表单形态，映射字段名下拉框数据
  const [standbookData, setStandbookData] = useState([]);
  const [fieldshineChecked, setFieldshineChecked] = useState(false);
  const [standFiledData, setStandFiledData] = useState([]);

  const change = e => {
    console.log(e);
    setVisibleChecked(e);
  };
  const fieldshineChange = e => {
    console.log(e);
    setFieldshineChecked(e);
    setCho(false);
    form.setFieldsValue({ fieldName: '' });
  };
  const onChangeView = e => {
    setView(e.target.checked);
  };

  const onChangePreView = e => {
    setPreView(e.target.checked);
  };

  const onChangePreViewMuise = e => {
    setViewMuise(e.target.checked);
  };

  const onChangePreViewVideo = e => {
    setPreViewVideo(e.target.checked);
  };

  // 提交
  const onSubmit = () => {
    setSaveBtnLoading(true);
    // 不切换树
    if (valueData.length == 0) {
      formAdd.validateFields().then(validate1 => {
        if (validate1) {
          form.validateFields().then(validate => {
            if (validate) {
              setLoading(true);
              let obj = form.getFieldsValue();
              let aa = '';
              if (synchronization == true) {
                aa = 1;
              } else {
                aa = 0;
              }
              console.log(Shape);
              let data = [
                {
                  Unit: obj.Unit || '',
                  StoreType: pramData.StoreType,
                  Group: pramData.Group || '',
                  Shape,
                  ExceptionEvent: pramData.ExceptionEvent || '',
                  RowSpan: Number(obj.RowSpan) || 0,
                  ColSpan: pramData.ColSpan || 0,
                  ReadOnly: pramData.ReadOnly || false,
                  EditableLater: pramData.EditableLater || false,
                  ExceptionValue: pramData.ExceptionValue || '',
                  Preset: pramData.Preset || '',
                  ID: pramData.ID,
                  Order: pramData.Order,
                  Name: obj.Name,
                  Alias: obj.Alias,
                  SyncEvent: aa,
                  ValidationRule: obj.ValidationRule,
                  ExceptionEventFields: characterValue,
                },
              ];
              console.log(data);
              switch (Shape) {
                case '本人部门':
                  if (checkboxAllID1 == true) {
                    data[0].Config = `ID存储`;
                  } else {
                    data[0].Config = '';
                  }
                  break;
                case '本人姓名':
                  if (checkboxAllID1 == true) {
                    data[0].Config = `ID存储`;
                  } else {
                    data[0].Config = '';
                  }
                  break;
                case '编码':
                  data[0].Config = `${obj.code}.${obj.prefix ? obj.prefix : ''}`;
                  break;
                case '坐标控件':
                  pramData.coordinates ? (data[0].Config = '当前坐标') : (data[0].Config = '');
                  break;
                case '图片':
                case '可预览图片':
                  // data[0].Config = pramData.picture ? '拍照相册' : '';
                  data[0].Config = pramData.picture ? '拍照相册' : '';
                  data[0].ValidationRule = pramData.must ? 'required' : '';
                  break;
                case '值选择器':
                  if (obj.Config.endsWith('.n')) {
                    data[0].Config = obj.Config;
                  } else if (radiostyle == 1) {
                    // 平铺值选择器
                    data[0].Config = cho ? `${obj.Config}.n` : `${obj.Config}`;
                  } else {
                    data[0].Config = obj.Config;
                  }
                  break;

                case '搜索选择器':
                  if (obj.Config.endsWith('.n')) {
                    data[0].Config = obj.Config;
                  } else {
                    // 平铺值选择器
                    data[0].Config = radio == 0 ? `${obj.Config}` : `${obj.Config}.n`;
                  }
                  break;
                case '部门选择器':
                  if (checkboxAllID1 == true) {
                    data[0].Config = cho ? `.n+ID存储` : `+ID存储`;
                  } else {
                    data[0].Config = cho ? `.n` : '';
                  }
                  break;
                case '唯一值文本':
                  data[0].Config = obj.fieldName
                    ? `${obj.tableName}.${obj.fieldName}`
                    : `${obj.tableName}`;
                  break;
                case '站点选择器':
                  if (checkboxAllID1 == true) {
                    data[0].Config = pep
                      ? `本人${cho ? '.n' : ''}+ID存储`
                      : `全部${cho ? '.n' : ''}+ID存储`;
                  } else {
                    data[0].Config = pep ? `本人${cho ? '.n' : ''}` : `全部${cho ? '.n' : ''}`;
                  }
                  break;
                case '业务选择器':
                  if (obj.fieldName.endsWith('.n')) {
                    data[0].Config = obj.fieldName
                      ? `${obj.tableName}.${obj.fieldName}`
                      : `${obj.tableName}`;
                  } else if (obj.fieldName) {
                    data[0].Config =
                      radio == 0
                        ? `${obj.tableName}.${obj.fieldName}`
                        : `${obj.tableName}.${obj.fieldName}.n`;
                  } else {
                    data[0].Config = radio == 0 ? `${obj.tableName}` : `${obj.tableName}.n`;
                  }
                  break;
                case '台账选择器':
                  let arr = {};
                  arr.fromField = obj.workOrder;
                  arr.toField = obj.eventOrder;
                  let li = [];
                  if (formAdd.getFieldValue('parmars')) {
                    li = [...formAdd.getFieldValue('parmars')];
                  }
                  li.push(arr);
                  let result = {};
                  result.siteJurisdiction = !!site;
                  result.fieldshine = li;
                  console.log(result);
                  let standData = fieldshineChecked ? JSON.stringify(result) : obj.fieldName;
                  console.log(JSON.stringify(result));
                  console.log(standData);
                  if (obj.fieldName && obj.fieldName.endsWith('.n')) {
                    data[0].Config = `${obj.standingBook}.${obj.fieldName}`;
                  } else if (standData) {
                    data[0].Config = cho
                      ? `${obj.standingBook}.${standData}.n`
                      : `${obj.standingBook}.${standData}`;
                  }
                  if (obj.filterName) {
                    data[0].Config = `${data[0].Config}?${obj.filterName}`;
                  } else {
                    data[0].Config = `${data[0].Config}`;
                  }
                  console.log(data[0].Config);
                  break;
                case '关联表单':
                  let aalist = {};
                  aalist.台账名称 = obj.standingBook;
                  aalist.默认显示 = visibleChecked || false;
                  aalist.控制规则 = obj.configName;

                  let arrlist = {};
                  arrlist.fromField = obj.workOrder;
                  arrlist.toField = obj.eventOrder;
                  let lii = [];
                  if (formAdd.getFieldValue('parmars')) {
                    lii = [...formAdd.getFieldValue('parmars')];
                  }
                  console.log(lii);
                  lii.push(arrlist);
                  aalist.映射字段 = lii;
                  data[0].Config = JSON.stringify(aalist);
                  break;
                case '选择器':
                  if (cse) {
                    let str = cho
                      ? `${obj.farter}.${obj.farterData}.n`
                      : `${obj.farter}.${obj.farterData}`;
                    data[0].Config = str;
                  } else {
                    console.log(obj.Config);
                    let str = cho ? `${obj.Config}.n` : `${obj.Config}`;
                    data[0].Config = str;
                  }
                  break;
                case '人员选择器':
                  if (popeleShape == '分组模态') {
                    if (checkboxAllID1 == true) {
                      if (obj.ConfigName) {
                        let str = cho
                          ? `全部.${obj.ConfigName}.n+ID存储`
                          : `全部.${obj.ConfigName}+ID存储`;
                        data[0].Config = str;
                      } else {
                        let str = cho ? `全部.n+ID存储` : `全部+ID存储`;
                        data[0].Config = str;
                      }
                    } else if (obj.ConfigName) {
                      let str = cho ? `全部.${obj.ConfigName}.n` : `全部.${obj.ConfigName}`;
                      data[0].Config = str;
                    } else {
                      let str = cho ? `全部.n` : `全部`;
                      data[0].Config = str;
                    }
                  } else if (popeleShape == '下拉框') {
                    if (checkboxAllID1 == true) {
                      let str = cho ? `${obj.Config}.n+ID存储` : `${obj.Config}+ID存储`;
                      data[0].Config = str;
                    } else {
                      let str = cho ? `${obj.Config}.n` : `${obj.Config}`;
                      data[0].Config = str;
                    }
                  } else if (popeleShape == '树形模态') {
                    if (gl) {
                      if (checkboxAllID1 == true) {
                        let str = cho ? `tree.多选|站点+ID存储` : `tree.单选|站点+ID存储`;
                        data[0].Config = str;
                      } else {
                        let str = cho ? `tree.多选|站点` : `tree.单选|站点`;
                        data[0].Config = str;
                      }
                    } else {
                      if (checkboxAllID1 == true) {
                        let str = cho ? `tree.多选|非站点+ID存储` : `tree.单选|非站点+ID存储`;
                        data[0].Config = str;
                      } else {
                        let str = cho ? `tree.多选|非站点` : `tree.单选|非站点`;
                        data[0].Config = str;
                      }
                    }
                  }
                  break;
                default:
                  data[0].Config = obj.Config;
              }
              console.log(data);
              if (Shape == '图片') {
                if (view) {
                  data[0].Shape = '可预览图片';
                } else {
                  data[0].Shape = '图片';
                }
              }
              if (Shape == '附件') {
                if (preView) {
                  data[0].Shape = '可预览附件';
                } else {
                  data[0].Shape = '附件';
                }
              }
              if (Shape == '值选择器') {
                if (radiostyle == 0) {
                  if (!cho) {
                    data[0].Shape = '值选择器';
                  } else {
                    data[0].Shape = '值复选器';
                  }
                } else {
                  data[0].Shape = '平铺值选择器';
                }
              }
              console.log(data);
              UpdateFields(data).then(res => {
                setLoading(false);
                if (res.msg === 'Ok' || res.msg === '') {
                  form.resetFields();
                  callBackSubmit();
                  notification.success({
                    message: '提示',
                    duration: 3,
                    description: '修改成功',
                  });
                } else {
                  notification.error({
                    message: '提示',
                    duration: 3,
                    description: res.msg,
                  });
                }
                setSaveBtnLoading(false);
              });
            }
          });
        }
      });
    } else {
      formAdd.validateFields().then(validate1 => {
        if (validate1) {
          form.validateFields().then(validate => {
            if (validate) {
              onSelect(1.14, keep);
            }
          });
        }
      });
    }
  };

  const getData = () => {
    console.log(keepTree);
    let last = [];
    let aa = ['工单编号', '事件编号']; // 固定分组数据
    let kk = [];
    keepTree.map((i, j) => {
      if (i != '工单编号' && i != '事件编号') {
        // let kk = {};
        // kk.name = i;
        // kk.ID = j + 1;
        // last.push(kk);
        kk.push(i);
      }
    });
    let bb = {}; // 内置字段对象
    bb.name = '内置字段';
    bb.ID = 0;
    bb.children = aa;
    last.push(bb);
    let dd = {}; // 附加字段对象
    dd.name = '附加字段';
    dd.ID = 1;
    dd.children = kk;
    last.push(dd);
    console.log(last);
    setFeildValue(last);

    // let cc = [];
    // cc.push(bb);
    // console.log(cc.concat(last));
    // if (aa.length > 0) {
    //   setFeildValue(cc.concat(last));
    // } else {
    //   setFeildValue(last);
    // }
    // 编辑时过滤下拉框初始数据
  };

  useEffect(() => {
    if (isVisible) {
      console.log(keepTree);
      getStandData();
      getData();
      setFieldList(keepTreeData);
      // 用于判断分组名与字段名重复时提示当前未选中字段
      if (keepTreeFirst.indexOf(itemData.name) != -1 && itemData.children) {
        setShow('none');
      } else {
        setShow('block');
      }
      console.log(treeData);
      setTreeValue(treeData);
      setValueData([]);
      setExpendKey(itemData.ID);
      setCurrentSelectOrg(itemData.ID);
      console.log(treeData);
      if (isType != '') {
        let req1 = getField({ fieldID: itemData.ID });
        let req2 = loadTableFields({ tableName: formObj1 });
        let req3 = LoadEventType({});
        Promise.all([req1, req2, req3]).then(res => {
          res[1].msg === 'Ok' && setFieldName(res[1].data.root);
          res[2].msg === 'Ok' && setEventList(res[2].data.root);
          if (res[0].msg === 'Ok') {
            form.setFieldsValue({ ...res[0].data.root });
            if (res[0].data.root.ExceptionEventFields === '') {
              setCharacterValue('');
              setCheckedList([]);
              setIsShow(false);
            } else {
              setIsShow(true);
              setCharacterValue(res[0].data.root.ExceptionEventFields);
              setCheckedList(res[0].data.root.ExceptionEventFields.split(','));
            }
            if (res[0].data.root.SyncEvent === 1) {
              form.setFieldsValue({ SyncEvent: true });
              setSynchronization(true);
            } else {
              form.setFieldsValue({ SyncEvent: false });
              setSynchronization(false);
            }
            console.log(res[0].data.root.Shape);
            if (res[0].data.root.StoreType == 'datetime') {
              setCharacteristics1([
                {
                  name: '时间类',
                  ID: 3,
                  children: ['日期时间', '日期', '日期月份', '日期年份', '日期周', '时分秒'],
                },
              ]);
            } else {
              setCharacteristics1([
                {
                  name: '文本类',
                  ID: 0,
                  children: [
                    '文本',
                    '唯一值文本',
                    '多行文本',
                    '本人部门',
                    '本人姓名',
                    '数值',
                    '地址',
                    '设备二维码',
                    // '本人ID',
                    '富文本',
                    '编码',
                  ],
                },
                {
                  name: '选择器类',
                  ID: 1,
                  children: [
                    '选择器',
                    '搜索选择器',
                    '值选择器',
                    '可编辑值选择器',
                    '站点选择器',
                    '人员选择器',
                    '城市选择器',
                    '台账选择器',
                    '业务选择器',
                    '部门选择器',
                  ],
                },
                {
                  name: '附件类',
                  ID: 2,
                  children: ['附件', '图片', '录音', '视频'],
                },
                {
                  name: '时间类',
                  ID: 3,
                  children: ['日期时间', '日期', '日期月份', '日期年份', '日期周', '时分秒'],
                },
                {
                  name: '地图类',
                  ID: 4,
                  children: ['坐标控件', '设备选择', '区域控件', '路径控件', '位置坐标'],
                },
                {
                  name: '高级控件',
                  ID: 5,
                  children: ['关联表单'],
                },
              ]);
            }

            if (res[0].data.root.Shape == '文本') {
              setDetail('输入内容将显示在前端输入框提示信息中');
            } else if (res[0].data.root.Shape == '多行文本') {
              setDetail('输入内容将显示在前端输入框提示信息中');
            } else if (res[0].data.root.Shape == '数值') {
              setDetail('输入内容将显示在前端输入框提示信息中');
            } else if (res[0].data.root.Shape == '设备二维码') {
              setDetail('输入内容将显示在前端输入框提示信息中');
            } else if (res[0].data.root.Shape == '选择器') {
              setDetail('数据字典名称');
            } else if (
              res[0].data.root.Shape == '值选择器' ||
              res[0].data.root.Shape == '值复选器'
            ) {
              setDetail('用英文逗号分隔自定义的值，可设置初始值');
            } else if (res[0].data.root.Shape == '可编辑值选择器') {
              setDetail('用英文逗号分隔自定义的值，可编辑，可设置初始值');
            } else if (res[0].data.root.Shape == '平铺值选择器') {
              setDetail('用英文逗号分隔自定义的值，勾选，可设置初始值值后加.n可调整为复选');
            } else {
              setDetail('');
            }

            let coordinates = false;
            let picture = false;
            let must = false;

            switch (res[0].data.root.Shape) {
              case '坐标控件':
                res[0].data.root.Config === '当前坐标'
                  ? (coordinates = true)
                  : (coordinates = false);
                break;
              case '日期时间':
              case '日期':
              case '日期月份':
              case '日期年份':
              case '日期周':
              case '时分秒':
                if (res[0].data.root.Config === '默认为空') {
                  form.setFieldsValue({
                    Config: '默认为空',
                  });
                } else if (res[0].data.root.Config === '锁定为当前时间') {
                  form.setFieldsValue({
                    Config: '不可选择',
                  });
                } else if (res[0].data.root.Config === '默认为当前时间') {
                  form.setFieldsValue({
                    Config: '默认为当前时间',
                  });
                } else if (res[0].data.root.Config === '不超过当前时间') {
                  form.setFieldsValue({
                    Config: '不超过当前时间',
                  });
                }
                break;
              case '图片':
                // res[0].data.root.Config === '拍照相册' ? (picture = true) : (picture = false);
                res[0].data.root.Config === '拍照相册' ? (picture = true) : (picture = false);
                res[0].data.root.ValidationRule === 'required' ? (must = true) : (must = false);
                break;
              case '可预览图片':
                // res[0].data.root.Config === '拍照相册' ? (picture = true) : (picture = false);
                res[0].data.root.Config === '拍照相册' ? (picture = true) : (picture = false);
                res[0].data.root.ValidationRule === 'required' ? (must = true) : (must = false);
                break;
              case '编码':
                let code = res[0].data.root.Config.split('.');
                form.setFieldsValue({
                  code: code[0] || '',
                  prefix: code[1] === 'undefined' ? '' : code[1],
                });
                break;
              case '本人部门':
                let depart = res[0].data.root.Config;
                form.setFieldsValue({ AllID1: !!depart });
                setCheckboxAllID1(!!depart);
                break;
              case '本人姓名':
                let name = res[0].data.root.Config;
                form.setFieldsValue({ AllID1: !!name });
                setCheckboxAllID1(!!name);
                break;
              case '站点选择器':
                let siteId = res[0].data.root.Config.split('+');
                let site = siteId[0].split('.');
                if (site[0] == '本人') {
                  if (res[0].data.root.Config.indexOf('.n') !== -1) {
                    form.setFieldsValue({
                      pepole: true,
                      choose: true,
                      AllID1: !!siteId[1],
                    });
                    setPep(true);
                    setCho(true);
                  } else {
                    form.setFieldsValue({
                      pepole: true,
                      choose: false,
                      AllID1: !!siteId[1],
                    });
                    setPep(true);
                    setCho(false);
                  }
                } else if (site[0] == '全部') {
                  if (res[0].data.root.Config.indexOf('.n') !== -1) {
                    form.setFieldsValue({
                      pepole: false,
                      choose: true,
                      AllID1: !!siteId[1],
                    });
                    setPep(false);
                    setCho(true);
                  } else {
                    form.setFieldsValue({
                      pepole: false,
                      choose: false,
                      AllID1: !!siteId[1],
                    });
                    setPep(false);
                    setCho(false);
                  }
                }
                setCheckboxAllID1(!!siteId[1]);
                break;
              case '搜索选择器':
                let data = res[0].data.root.Config.split('.');
                form.setFieldsValue({
                  Config: data[0] || '',
                });
                if (res[0].data.root.Config.endsWith('.n')) {
                  form.setFieldsValue({
                    check: 1,
                  });
                  setRadio(1);
                } else {
                  form.setFieldsValue({
                    check: 0,
                  });
                  setRadio(0);
                }
                break;
              case '平铺值选择器':
                let dataa = res[0].data.root.Config.split('.');
                form.setFieldsValue({
                  Config: dataa[0] || '',
                });
                if (res[0].data.root.Config.endsWith('.n')) {
                  form.setFieldsValue({
                    check: 1,
                    choose: true,
                  });
                  setCho(true);
                  setRadio(1);
                } else {
                  form.setFieldsValue({
                    check: 0,
                    choose: false,
                  });
                  setCho(false);
                  setRadio(0);
                }
                form.setFieldsValue({
                  style: 1,
                });
                setRadiostyle(1);
                break;
              case '唯一值文本':
                let arr = res[0].data.root.Config.split('.');
                form.setFieldsValue({
                  tableName: arr[0] || '',
                  fieldName: arr[1] || '',
                });
                break;
              case '业务选择器':
                let list = res[0].data.root.Config.split('.');
                console.log(list);
                form.setFieldsValue({
                  tableName: list[0] || '',
                  fieldName: list[1] || '',
                });
                if (res[0].data.root.Config.endsWith('.n')) {
                  form.setFieldsValue({
                    check: 1,
                  });
                  setRadio(1);
                } else {
                  form.setFieldsValue({
                    check: 0,
                  });
                  setRadio(0);
                }
                break;
              case '部门选择器':
                let department = res[0].data.root.Config.split('+');
                if (department[0] == '.n') {
                  form.setFieldsValue({ choose: true, AllID1: !!department[1] });
                  setCho(true);
                } else {
                  form.setFieldsValue({ choose: false, AllID1: !!department[1] });
                  setCho(false);
                }
                setCheckboxAllID1(!!department[1]);
                break;
              case '台账选择器':
                let book = res[0].data.root.Config.split('.');
                let rueslt1 = keepStandingBook.find(i => i.name == book[0]);
                if (!rueslt1) {
                  notification.error({
                    message: '提示',
                    duration: 3,
                    description: `没有匹配到台账名【${book[0]}】，请检查配置！`,
                  });
                } else {
                  getMapFelidValue(rueslt1?.tableName);
                }
                let bb = book[1].split('?');
                if (bb[0].indexOf('[') !== -1) {
                  let filedname = JSON.parse(bb[0]);
                  form.setFieldsValue({
                    standingBook: book[0] || '',
                    fieldName: bb[0] || '',
                    workOrder:
                      filedname.fieldshine != undefined
                        ? filedname.fieldshine[filedname.fieldshine.length - 1].fromField
                        : filedname[filedname.length - 1].fromField,
                    eventOrder:
                      filedname.fieldshine != undefined
                        ? filedname.fieldshine[filedname.fieldshine.length - 1].toField
                        : filedname[filedname.length - 1].toField,
                    siteJurisdiction:
                      filedname.siteJurisdiction != undefined ? filedname.siteJurisdiction : false,
                    fieldshine: true,
                  });
                  setSite(
                    filedname.siteJurisdiction != undefined ? filedname.siteJurisdiction : false,
                  );
                  // 映射字段
                  if (filedname.fieldshine != undefined) {
                    if (Array.isArray(filedname.fieldshine)) {
                      let gg = [...filedname.fieldshine];
                      let a11 = [];
                      gg.length > 0 &&
                        gg.map((i, j) => {
                          if (j !== gg.length - 1) {
                            a11.push(i);
                          }
                        });
                      formAdd.setFieldsValue({ parmars: a11 });
                      setFieldshineChecked(true);
                    }
                  } else {
                    if (Array.isArray(filedname)) {
                      let gg = [...filedname];
                      let a11 = [];
                      gg.length > 0 &&
                        gg.map((i, j) => {
                          if (j !== gg.length - 1) {
                            a11.push(i);
                          }
                        });
                      formAdd.setFieldsValue({ parmars: a11 });
                      setFieldshineChecked(true);
                    }
                  }
                } else {
                  form.setFieldsValue({
                    standingBook: book[0] || '',
                    fieldName: bb[0] || '',
                    fieldshine: false,
                  });
                  setFieldshineChecked(false);
                }

                let book1 = res[0].data.root.Config.split('?');
                if (book1[1]) {
                  form.setFieldsValue({
                    filterName: book1[1],
                  });
                }
                if (book1[0].endsWith('.n')) {
                  form.setFieldsValue({
                    check: true,
                  });
                  setCho(true);
                } else {
                  form.setFieldsValue({
                    check: false,
                  });
                  setCho(false);
                }
                break;
              case '关联表单':
                console.log(keepStandingBook);
                let data11 = JSON.parse(res[0].data.root.Config);
                let rueslt = keepStandingBook.find(i => i.name == data11.台账名称);
                console.log(rueslt.tableName);
                if (!rueslt1) {
                  notification.error({
                    message: '提示',
                    duration: 3,
                    description: `没有匹配到台账名【${book[0]}】，请检查配置！`,
                  });
                } else {
                  getMapFelidValue(rueslt1?.tableName);
                }
                form.setFieldsValue({
                  standingBook: data11.台账名称,
                  workOrder: data11.映射字段[data11.映射字段.length - 1].fromField,
                  eventOrder: data11.映射字段[data11.映射字段.length - 1].toField,
                  configName: data11.控制规则,
                });
                let gg = [...data11.映射字段];
                let a11 = [];
                gg.length > 0 &&
                  gg.map((i, j) => {
                    if (j !== gg.length - 1) {
                      a11.push(i);
                    }
                  });
                formAdd.setFieldsValue({ parmars: a11 });
                setVisibleChecked(data11.默认显示);
                break;
              case '选择器':
                let sele = res[0].data.root.Config.split('.');
                console.log(sele[0]);
                console.log(sele[1]);
                if (sele[1] && sele[1] != 'n') {
                  form.setFieldsValue({
                    Association: true,
                    farter: sele[0],
                    farterData: sele[1],
                  });
                  setCse(true);
                } else {
                  console.log(sele[0]);
                  form.setFieldsValue({
                    Association: false,
                    Config: sele[0],
                  });
                  setCse(false);
                }
                if (res[0].data.root.Config.endsWith('.n')) {
                  form.setFieldsValue({ choose: true });
                  setCho(true);
                } else {
                  form.setFieldsValue({ choose: false });
                  setCho(false);
                }
                break;
              case '人员选择器':
                let pepole = res[0].data.root.Config.split('.');
                let id = res[0].data.root.Config.split('+');
                form.setFieldsValue({ ShowConfig: res[0].data.root.Config });
                if (pepole[0] == '全部') {
                  setHide(false);
                  setFlag(true);
                  setCheckboxAll1(true);
                  if (pepole[1] && pepole[1] != 'n') {
                    let aa = pepole[1].split('+');
                    form.setFieldsValue({
                      PeShape: '分组模态',
                      All1: true,
                      AllID1: !!id[1],
                      ConfigName: aa[0] !== 'n' ? aa[0] : '',
                    });
                  } else {
                    form.setFieldsValue({
                      PeShape: '分组模态',
                      All1: true,
                      AllID1: !!id[1],
                      ConfigName: '',
                    });
                  }
                  setCheckboxAllID1(!!id[1]);
                  if (res[0].data.root.Config.indexOf('.n') !== -1) {
                    form.setFieldsValue({ choose: true });
                    setCho(true);
                  } else {
                    form.setFieldsValue({ choose: false });
                    setCho(false);
                  }
                  setPopeleShape('分组模态');
                } else if (pepole[0] == 'tree') {
                  setCheckboxAll1(false);
                  setHide(true);
                  setFlag(1);
                  let tree = pepole[1].split('|');
                  let treeId = tree[1].split('+');
                  if (tree[0] == '多选') {
                    if (treeId[0] == '站点') {
                      form.setFieldsValue({
                        PeShape: '树形模态',
                        All1: true,
                        AllID1: !!id[1],
                        guolv: true,
                        choose: true,
                      });
                      setGl(true);
                      setCho(true);
                    } else {
                      form.setFieldsValue({
                        PeShape: '树形模态',
                        All1: true,
                        AllID1: !!id[1],
                        guolv: false,
                        choose: true,
                      });
                      setGl(false);
                      setCho(true);
                    }
                  } else if (treeId[0] == '站点') {
                    form.setFieldsValue({
                      PeShape: '树形模态',
                      All1: true,
                      AllID1: !!id[1],
                      guolv: true,
                      choose: false,
                    });
                    setGl(true);
                    setCho(false);
                  } else {
                    form.setFieldsValue({
                      PeShape: '树形模态',
                      All1: true,
                      AllID1: !!id[1],
                      guolv: false,
                      choose: false,
                    });
                    setGl(false);
                    setCho(false);
                  }
                  setCheckboxAllID1(!!id[1]);
                  setPopeleShape('树形模态');
                } else {
                  setCheckboxAll1(false);
                  setCheckboxAllID1(!!id[1]);
                  setHide(true);
                  setFlag(false);
                  let aa = pepole[0].split('+');
                  form.setFieldsValue({
                    All1: false,
                    PeShape: '下拉框',
                    AllID1: !!id[1],
                    Config: aa[0],
                  });
                  if (res[0].data.root.Config.indexOf('.n') !== -1) {
                    form.setFieldsValue({ choose: true });
                    setCho(true);
                  } else {
                    form.setFieldsValue({ choose: false });
                    setCho(false);
                  }
                  setPopeleShape('下拉框');
                }

                break;
            }
            if (res[0].data.root.Shape == '可预览图片') {
              setView(true);
            } else if (res[0].data.root.Shape == '图片') {
              setView(false);
            } else if (res[0].data.root.Shape == '可预览附件') {
              setPreView(true);
            } else if (res[0].data.root.Shape == '附件') {
              setPreView(false);
            } else if (res[0].data.root.Shape == '值选择器') {
              setRadiostyle(0);

              setCho(false);
              form.setFieldsValue({ style: 0, choose: false });
            } else if (res[0].data.root.Shape == '值复选器') {
              setRadiostyle(0);

              setCho(true);
              form.setFieldsValue({ style: 0, choose: true });
            }

            if (res[0].data.root.Shape == '可预览图片') {
              setShape('图片');
            } else if (res[0].data.root.Shape == '可预览附件') {
              setShape('附件');
            } else if (res[0].data.root.Shape == '平铺值选择器') {
              setShape('值选择器');
            } else if (res[0].data.root.Shape == '值复选器') {
              setShape('值选择器');
            } else {
              setShape(res[0].data.root.Shape);
            }
            if (!res[0].data.root.Shape) {
              console.log(1111);
              if (res[0].data.root.StoreType == 'datetime') {
                setShape('日期时间');
              } else if (
                res[0].data.root.StoreType == 'int' ||
                res[0].data.root.StoreType == 'float' ||
                res[0].data.root.StoreType == 'bigint' ||
                (res[0].data.root.StoreType == 'int') == 'decimal'
              ) {
                setShape('数值');
              } else {
                console.log(1111122222);
                setShape('文本');
              }
            }
            setPramData({ ...res[0].data.root, coordinates, must, picture });
            // if (
            //   res[0].data.root.Shape == '多行文本' ||
            //   res[0].data.root.Shape == '附件' ||
            //   res[0].data.root.Shape == '可预览附件' ||
            //   res[0].data.root.Shape == '图片' ||
            //   res[0].data.root.Shape == '可预览图片' ||
            //   res[0].data.root.Shape == '录音' ||
            //   res[0].data.root.Shape == '视频'
            // ) {
            //   form.setFieldsValue({ RowSpan: 6 });
            // } else {
            //   if (res[0].data.root.RowSpan !== 0) {
            //     form.setFieldsValue({ RowSpan: res[0].data.root.RowSpan });
            //   } else {
            //     form.setFieldsValue({ RowSpan: 1 });
            //   }
            // }
            // 清空表单数据
            let index = res[2].data.root.find(item => item.Name == res[0].data.root.ExceptionEvent);
            console.log(index);
            // getFieldData(index.TableName);
          }
        });
      }
    } else {
      setPopeleShape('');
      setGl('');
      setCse('');
      setPramData([]);
      form.resetFields();
      formAdd.resetFields();
      setChee('');
      setCheestyle('');
      setRadio('');
      setRadiostyle('');
      setRadio1('');
      setRadio3('');
      setPep('');
      setCho('');
      setSite('');
      setCheckboxAll1('');
      setCheckboxAllID1('');
      setFlag(false);
      setPopeleShape('下拉框');
      setHide(true);
      setSynchronization(false);
    }
  }, [isVisible]);

  // 获取关联表单形态字段映射下拉框数据
  const getMapFelidValue = e => {
    console.log(e);
    reloadTableFields({
      tableName: e,
    }).then(res => {
      if (res.msg === 'Ok') {
        // 编辑时过滤下l拉框初始数据
        setMapFeildValue(res.data.root);
        let data = [];
        let list = {};
        let datalist = [];
        list.ID = 0;
        list.name = e;
        res.data.root.map(i => {
          datalist.push(i.name);
        });
        list.children = datalist;
        data.push(list);
        setStandbookData(data);
      }
    });
  };

  const getStandData = () => {
    let data = [];
    let list = {};
    let datalist = [];
    datalist = [...keepTree];
    list.ID = 0;
    list.name = formObj1;
    list.children = datalist;
    data.push(list);
    setStandFiledData(data);
  };

  const seach = e => {
    let rueslt = keepStandingBook.find(i => i.name == e);
    getMapFelidValue(rueslt.tableName);
    formAdd.resetFields();
    form.setFieldsValue({ workOrder: undefined, eventOrder: undefined });
  };

  const handleChange = value => {
    form.setFieldsValue({ schemename: value });
  };

  const onOK = prop => {
    console.log(prop, 'prop');
    setVisible(false);
    if (type === 'rule') {
      form.setFieldsValue({ ValidationRule: prop });
    } else {
      setCheckedList(prop.checkedList);
      setCharacterValue(prop.str);
    }
  };
  const add1 = aa => {
    let obj = form.getFieldsValue();
    let data = { numerical: '', rule: [] };
    console.log(obj.ValidationRule, 'ValidationRule');
    if (obj.ValidationRule) {
      let arr = obj.ValidationRule.split(',');
      arr.forEach(item => {
        let value;
        if (item.indexOf('maxLength') !== -1) {
          value = 'maxLength';
        } else {
          value = item;
        }
        switch (value) {
          case 'required':
            data.rule.push(item);
            break;
          case 'emphasis':
            data.rule.push(item);
            break;
          case 'sensitive':
            data.rule.push(item);
            break;
          case 'maxLength':
            data.rule.push(item);
            break;
          default:
            data.numerical = item;
        }
      });
    } else {
      data = { rule: [], numerical: '' };
    }
    setType(aa);
    setFormObj(data);
    setVisible(true);
  };

  const handleEvent = (value, e) => {
    let data = { ...pramData };
    data.ExceptionEvent = e.name;
    if (e.tablename) {
      getFieldData(e.tablename);
      setPramData(data);
    } else {
      setIsShow(false);
      setFiled({});
      setCharacterValue('');
      setCheckedList([]);
    }
  };
  const getFieldData = value => {
    LoadEventFields({ eventTableName: value, distinctFields: '' }).then(res => {
      if (res.msg === 'Ok') {
        console.log(res.data.root);
        setFiled(formateArrDataA(res.data.root, 'group'));
        setIsShow(true);
      }
    });
  };

  const formateArrDataA = (initialArr, name) => {
    // 判定传参是否符合规则
    if (!(initialArr instanceof Array)) {
      return '请传入正确格式的数组';
    }
    if (!name) {
      return '请传入对象属性';
    }
    // 先获取一下这个数组中有多少个"name"
    let nameArr = [];
    for (let i in initialArr) {
      if (nameArr.indexOf(initialArr[i][`${name}`]) === -1) {
        nameArr.push(initialArr[i][`${name}`]);
      }
    }
    // 新建一个包含多个list的结果对象
    let tempObj = {};
    // 根据不同的"name"生成多个数组
    for (let k in nameArr) {
      for (let j in initialArr) {
        if (initialArr[j][`${name}`] == nameArr[k]) {
          // 每次外循环时新建一个对应"name"的数组, 内循环时当前数组不变
          tempObj[nameArr[k]] = tempObj[nameArr[k]] || [];
          tempObj[nameArr[k]].push(initialArr[j]);
        }
      }
    }
    for (let key in tempObj) {
      let arr = [];
      tempObj[key].map(item => {
        tempObj[key] = arr;
        arr.push(item.fieldName);
      });
    }
    return tempObj;
  };
  const handleCharacteristics = value => {
    if (
      value == '日期' ||
      value == '日期时间' ||
      value == '日期月份' ||
      value == '日期年份' ||
      value == '日期周' ||
      value == '时分秒'
    ) {
      console.log(123);
      form.setFieldsValue({ Config: '默认为当前时间' });
      setTimeData('默认为当前时间');
    } else {
      form.setFieldsValue({
        Config: '',
        guolv: '',
        ConfigName: '',
        tableName: '',
        fieldName: '',
        filterName: '',
        filterValue: '',
        standingBook: undefined,
        check: 0,
        style: 0,
        AllID: '0',
        All: '0',
        AllID1: '',
        All1: '',
        ShowConfig: '',
        pepole: '',
        choose: '',
        PeShape: '',
        Association: '',
        farter: '',
        farterData: '',
        workOrder: undefined,
        eventOrder: undefined,
        configName: '',
      });
    }
    formAdd.resetFields();
    setVisibleChecked(true);
    setView(true);
    setPreView(true);
    setViewMuise(true);
    setPreViewVideo(true);
    setCse('');
    setPopeleShape('');
    setRadio(0);
    setRadiostyle(0);
    setRadio3('0');
    setRadio1('0');
    setGl('');
    setPep('');
    setCho('');
    setSite('');
    setCheckboxAll1('');
    setCheckboxAllID1('');
    setFlag(false);
    setPopeleShape('下拉框');
    setHide(true);
    setFieldshineChecked(false);
    formAdd.resetFields();
    console.log(value);
    if (value == '文本') {
      setDetail('输入内容将显示在前端输入框提示信息中');
    } else if (value == '多行文本') {
      setDetail('输入内容将显示在前端输入框提示信息中');
    } else if (value == '数值') {
      setDetail('输入内容将显示在前端输入框提示信息中');
    } else if (value == '设备二维码') {
      setDetail('输入内容将显示在前端输入框提示信息中');
    } else if (value == '选择器') {
      setDetail('数据字典名称');
    } else if (value == '值选择器' || value == '值复选器') {
      setDetail('用英文逗号分隔自定义的值，可设置初始值');
    } else if (value == '可编辑值选择器') {
      setDetail('用英文逗号分隔自定义的值，可编辑，可设置初始值');
    } else if (value == '平铺值选择器') {
      setDetail('用英文逗号分隔自定义的值，勾选，可设置初始值值后加.n可调整为复选');
    } else {
      setDetail('');
    }

    if (
      value == '多行文本' ||
      value == '富文本' ||
      value == '附件' ||
      value == '可预览附件' ||
      value == '图片' ||
      value == '可预览图片' ||
      value == '录音' ||
      value == '视频' ||
      value == '关联表单'
    ) {
      form.setFieldsValue({ RowSpan: 6 });
    } else {
      if (pramData.RowSpan) {
        form.setFieldsValue({ RowSpan: pramData.RowSpan });
      }
      form.setFieldsValue({ RowSpan: 1 });
    }
    let data = { ...pramData };
    setShape(value);
    data.must = false;
    data.coordinates = false;
    data.picture = false;
    data.Preset = '';
    setPramData(data);
    form.setFieldsValue({ ValidationRule: '' });
    // if (value.indexOf('日期') != -1 || value === '时分秒') {
    //   form.setFieldsValue({ Config: undefined });
    // }
  };
  const onCharacterValue = e => {
    setCharacterValue(e.target.value);
  };
  const onChangeReady = (e, str) => {
    let data = { ...pramData };
    switch (str) {
      case 'ReadOnly':
        data.ReadOnly = e.target.checked;
        break;
      case 'EditableLater':
        data.EditableLater = e.target.checked;
        break;
      case 'must':
        data.must = e.target.checked;
        break;
      case 'picture':
        data.picture = e.target.checked;
        break;
      case 'coordinates':
        data.coordinates = e.target.checked;
        break;
    }
    setPramData(data);
  };
  const handleInput = (e, str) => {
    let data = { ...pramData };
    switch (str) {
      case 'Unit':
        data.Unit = e.target.value;
        break;
      case 'RowSpan':
        data.RowSpan = e.target.value;
        break;
      case 'Preset':
        data.Preset = e.target.value;
        break;
      case 'ExceptionValue':
        data.ExceptionValue = e.target.value;
        break;
      default:
        break;
    }
    setPramData(data);
  };
  const handleSeparator = value => {
    let data = { ...pramData };
    switch (value) {
      case '6':
        data.Preset = '是';
        form.setFieldsValue({ Config: '是,否' });
        break;
      case '7':
        data.Preset = '否';
        form.setFieldsValue({ Config: '是,否' });
        break;
      case '8':
        data.Preset = '否';
        form.setFieldsValue({ Config: '否,是' });
        break;
    }
    setPramData(data);
  };

  const mapTree = org => {
    const haveChildren = Array.isArray(org.children) && org.children.length > 0;
    if (org.storeType == 'datetime') {
      return {
        title: (
          <span className={styles.titleText}>
            {org.children ? (
              <UnorderedListOutlined style={{ color: '#1890FF' }} />
            ) : (
              <img src={Things} style={{ height: '14px' }} alt="" />
            )}
            <span style={{ marginLeft: '5px' }}>{org.name}</span>
          </span>
        ),
        key: org.ID,
        // 判断它是否存在子集，若果存在就进行再次进行遍历操作，知道不存在子集便对其他的元素进行操作
        children: haveChildren ? org.children.map(i => mapTree(i)) : [],
        org,
      };
    }
    return {
      title: (
        <span className={styles.titleText}>
          {org.children ? (
            <UnorderedListOutlined style={{ color: '#1890FF' }} />
          ) : (
            <FontColorsOutlined style={{ color: '#1890FF' }} />
          )}
          <span style={{ marginLeft: '5px' }}>{org.name}</span>
        </span>
      ),
      key: org.ID,
      // 判断它是否存在子集，若果存在就进行再次进行遍历操作，知道不存在子集便对其他的元素进行操作
      children: haveChildren ? org.children.map(i => mapTree(i)) : [],
      org,
    };
  };
  const onSelect = (i, e) => {
    console.log(i);
    console.log(e);
    setMapFeildValue([]);
    if (e.node.org.storeType && e.node.org.storeType == 'datetime') {
      setCharacteristics1([
        {
          name: '时间类',
          ID: 3,
          children: ['日期时间', '日期', '日期月份', '日期年份', '日期周', '时分秒'],
        },
      ]);
    } else if (e.node.org.storeType && e.node.org.storeType != 'datetime') {
      setCharacteristics1([
        {
          name: '文本类',
          ID: 0,
          children: [
            '文本',
            '唯一值文本',
            '多行文本',
            '本人部门',
            '本人姓名',
            '数值',
            '地址',
            '设备二维码',
            // '本人ID',
            '富文本',
            '编码',
          ],
        },
        {
          name: '选择器类',
          ID: 1,
          children: [
            '选择器',
            '搜索选择器',
            '值选择器',
            '可编辑值选择器',
            '站点选择器',
            '人员选择器',
            '城市选择器',
            '台账选择器',
            '业务选择器',
            '部门选择器',
          ],
        },
        {
          name: '附件类',
          ID: 2,
          children: ['附件', '图片', '录音', '视频'],
        },
        {
          name: '时间类',
          ID: 3,
          children: ['日期时间', '日期', '日期月份', '日期年份', '日期周', '时分秒'],
        },
        {
          name: '地图类',
          ID: 4,
          children: ['坐标控件', '设备选择', '区域控件', '路径控件', '位置坐标'],
        },
        {
          name: '高级控件',
          ID: 5,
          children: ['关联表单'],
        },
      ]);
    }
    if (e && !e.node.org.children) {
      setKeep(e);
      if (e.node) {
        setCurrentSelectOrg(e.node.org.ID);
      } else {
        setCurrentSelectOrg(e.ID);
      }
      if (e.node && keepTreeFirst.indexOf(e.node.org.name) != -1 && e.node.children.length > 0) {
        setShow('none');
      } else {
        setShow('block');
      }
      if (isType != '') {
        let req1 = getField({ fieldID: e.node.org.ID });
        let req2 = loadTableFields({ tableName: formObj1 });
        let req3 = LoadEventType({});
        let bb = [];
        valueData.map(i => {
          bb.push(i.ID.toString());
        });
        if (bb.indexOf(e.node.org.ID) != -1) {
          let aa = valueData.find(i => i.ID == e.node.org.ID);
          Promise.all([req1, req2, req3]).then(res => {
            res[1].msg === 'Ok' && setFieldName(res[1].data.root);
            res[2].msg === 'Ok' && setEventList(res[2].data.root);
            if (res[0].msg === 'Ok') {
              if (aa.Shape == '可预览图片') {
                setView(true);
              } else if (aa.Shape == '图片') {
                setView(false);
              } else if (aa.Shape == '可预览附件') {
                setPreView(true);
              } else if (aa.Shape == '附件') {
                setPreView(false);
              } else if (aa.Shape == '值选择器') {
                setRadiostyle(0);
                setCho(false);
                form.setFieldsValue({ style: 0, choose: false });
              } else if (aa.Shape == '值复选器') {
                setRadiostyle(0);
                setCho(true);
                form.setFieldsValue({ style: 0, choose: true });
              }

              if (aa.Shape == '可预览图片') {
                setShape('图片');
              } else if (aa.Shape == '可预览附件') {
                setShape('附件');
              } else if (aa.Shape == '平铺值选择器') {
                setShape('值选择器');
              } else if (aa.Shape == '值复选器') {
                setShape('值选择器');
              } else {
                setShape(aa.Shape);
              }
              if (!aa.Shape) {
                console.log(1111);
                if (aa.StoreType == 'datetime') {
                  setShape('日期时间');
                } else if (
                  aa.StoreType == 'int' ||
                  aa.StoreType == 'float' ||
                  aa.StoreType == 'bigint' ||
                  (aa.StoreType == 'int') == 'decimal'
                ) {
                  setShape('数值');
                } else {
                  console.log(1111122222);
                  setShape('文本');
                }
              }
              form.setFieldsValue({ ...aa });
              if (aa.ExceptionEventFields === '') {
                setCharacterValue('');
                setCheckedList([]);
                setIsShow(false);
              } else {
                setIsShow(true);
                setCharacterValue(aa.ExceptionEventFields);
                setCheckedList(aa.ExceptionEventFields.split(','));
              }
              if (aa.SyncEvent === 1) {
                form.setFieldsValue({ SyncEvent: true });
                setSynchronization(true);
              } else {
                form.setFieldsValue({ SyncEvent: false });
                setSynchronization(false);
              }

              if (aa.Shape == '文本') {
                setDetail('输入内容将显示在前端输入框提示信息中');
              } else if (aa.Shape == '多行文本') {
                setDetail('输入内容将显示在前端输入框提示信息中');
              } else if (aa.Shape == '数值') {
                setDetail('输入内容将显示在前端输入框提示信息中');
              } else if (aa.Shape == '设备二维码') {
                setDetail('输入内容将显示在前端输入框提示信息中');
              } else if (aa.Shape == '选择器') {
                setDetail('数据字典名称');
              } else if (aa.Shape == '值选择器' || aa.Shape == '值复选器') {
                setDetail('用英文逗号分隔自定义的值，可设置初始值');
              } else if (aa.Shape == '可编辑值选择器') {
                setDetail('用英文逗号分隔自定义的值，可编辑，可设置初始值');
              } else if (aa.Shape == '平铺值选择器') {
                setDetail('用英文逗号分隔自定义的值，勾选，可设置初始值值后加.n可调整为复选');
              } else {
                setDetail('');
              }
              let coordinates = false;
              let picture = false;
              let must = false;

              switch (aa.Shape) {
                case '坐标控件':
                  aa.Config === '当前坐标' ? (coordinates = true) : (coordinates = false);
                  break;
                case '日期时间':
                case '日期':
                case '日期月份':
                case '日期年份':
                case '日期周':
                case '时分秒':
                  if (aa.Config === '默认为空') {
                    form.setFieldsValue({
                      Config: '默认为空',
                    });
                  } else if (aa.Config === '锁定为当前时间') {
                    form.setFieldsValue({
                      Config: '不可选择',
                    });
                  } else if (aa.Config === '默认为当前时间') {
                    form.setFieldsValue({
                      Config: '默认为当前时间',
                    });
                  } else if (aa.Config === '不超过当前时间') {
                    form.setFieldsValue({
                      Config: '不超过当前时间',
                    });
                  }
                  break;
                case '图片':
                case '可预览图片':
                  // aa.Config === '拍照相册' ? (picture = true) : (picture = false);
                  aa.Config === '拍照相册' ? (picture = true) : (picture = false);
                  aa.ValidationRule === 'required' ? (must = true) : (must = false);
                  break;
                case '编码':
                  let code = aa.Config.split('.');
                  form.setFieldsValue({
                    code: code[0] || '',
                    prefix: code[1] === 'undefined' ? '' : code[1],
                  });
                  break;
                case '本人部门':
                  let depart = aa.Config;
                  form.setFieldsValue({ AllID1: !!depart });
                  setCheckboxAllID1(!!depart);
                  break;
                case '本人姓名':
                  let name = aa.Config;
                  form.setFieldsValue({ AllID1: !!name });
                  setCheckboxAllID1(!!name);
                  break;
                case '搜索选择器':
                  let data = aa.Config.split('.');
                  form.setFieldsValue({
                    Config: data[0] || '',
                  });
                  if (aa.Config.endsWith('.n')) {
                    form.setFieldsValue({
                      check: 1,
                    });
                    setRadio(1);
                  } else {
                    form.setFieldsValue({
                      check: 0,
                    });
                    setRadio(0);
                  }
                  break;
                case '平铺值选择器':
                  let dataa = aa.Config.split('.');
                  form.setFieldsValue({
                    Config: dataa[0] || '',
                  });
                  if (aa.Config.endsWith('.n')) {
                    form.setFieldsValue({
                      choose: true,
                    });
                    setCho(true);
                  } else {
                    form.setFieldsValue({
                      choose: false,
                    });
                    setCho(false);
                  }
                  form.setFieldsValue({
                    style: 1,
                  });
                  setRadiostyle(1);
                  break;
                case '唯一值文本':
                  let arr = aa.Config.split('.');
                  form.setFieldsValue({
                    tableName: arr[0] || '',
                    fieldName: arr[1] || '',
                  });
                  break;
                case '业务选择器':
                  let list = aa.Config.split('.');
                  form.setFieldsValue({
                    tableName: list[0] || '',
                    fieldName: list[1] || '',
                  });
                  if (aa.Config.endsWith('.n')) {
                    form.setFieldsValue({
                      check: 1,
                    });
                    setRadio(1);
                  } else {
                    form.setFieldsValue({
                      check: 0,
                    });
                    setRadio(0);
                  }
                  break;
                case '站点选择器':
                  let siteId = aa.Config.split('+');
                  let site = siteId[0].split('.');
                  if (site[0] == '本人') {
                    if (aa.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({
                        pepole: true,
                        choose: true,
                        AllID1: !!siteId[1],
                      });
                      setPep(true);
                      setCho(true);
                    } else {
                      form.setFieldsValue({
                        pepole: true,
                        choose: false,
                        AllID1: !!siteId[1],
                      });
                      setPep(true);
                      setCho(false);
                    }
                  } else if (site[0] == '全部') {
                    if (aa.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({
                        pepole: false,
                        choose: true,
                        AllID1: !!siteId[1],
                      });
                      setPep(false);
                      setCho(true);
                    } else {
                      form.setFieldsValue({
                        pepole: false,
                        choose: false,
                        AllID1: !!siteId[1],
                      });
                      setPep(false);
                      setCho(false);
                    }
                  }
                  setCheckboxAllID1(!!siteId[1]);
                  break;
                case '部门选择器':
                  let department = aa.Config.split('+');
                  if (department[0] == '.n') {
                    form.setFieldsValue({ choose: true, AllID1: !!department[1] });
                    setCho(true);
                  } else {
                    form.setFieldsValue({ choose: false, AllID1: !!department[1] });
                    setCho(false);
                  }
                  setCheckboxAllID1(!!department[1]);
                  break;
                case '关联表单':
                  let data11 = JSON.parse(aa.Config);
                  let rueslt = keepStandingBook.find(i => i.name == data11.台账名称);
                  console.log(rueslt.tableName);
                  if (!rueslt1) {
                    notification.error({
                      message: '提示',
                      duration: 3,
                      description: `没有匹配到台账名【${book[0]}】，请检查配置！`,
                    });
                  } else {
                    getMapFelidValue(rueslt1?.tableName);
                  }
                  form.setFieldsValue({
                    standingBook: data11.台账名称,
                    workOrder: data11.映射字段[data11.映射字段.length - 1].fromField,
                    eventOrder: data11.映射字段[data11.映射字段.length - 1].toField,
                    configName: data11.控制规则,
                  });
                  let gg = [...data11.映射字段];
                  let a11 = [];
                  gg.length > 0 &&
                    gg.map((i, j) => {
                      if (j !== gg.length - 1) {
                        a11.push(i);
                      }
                    });
                  formAdd.setFieldsValue({ parmars: a11 });
                  setVisibleChecked(data11.默认显示);
                  break;
                case '台账选择器':
                  console.log(aa.Config);
                  let book = aa.Config.split('.');
                  let rueslt1 = keepStandingBook.find(j => j.name == book[0]);
                  if (!rueslt1) {
                    notification.error({
                      message: '提示',
                      duration: 3,
                      description: `没有匹配到台账名【${book[0]}】，请检查配置！`,
                    });
                  } else {
                    getMapFelidValue(rueslt1?.tableName);
                  }

                  let ad = book[1].split('?');
                  if (ad[0].indexOf('[') !== -1) {
                    let filedname = JSON.parse(ad[0]);
                    form.setFieldsValue({
                      standingBook: book[0] || '',
                      fieldName: ad[0] || '',
                      workOrder:
                        filedname.fieldshine != undefined
                          ? filedname.fieldshine[filedname.fieldshine.length - 1].fromField
                          : filedname[filedname.length - 1].fromField,
                      eventOrder:
                        filedname.fieldshine != undefined
                          ? filedname.fieldshine[filedname.fieldshine.length - 1].toField
                          : filedname[filedname.length - 1].toField,
                      siteJurisdiction:
                        filedname.siteJurisdiction != undefined
                          ? filedname.siteJurisdiction
                          : false,
                      fieldshine: true,
                    });
                    setSite(
                      filedname.siteJurisdiction != undefined ? filedname.siteJurisdiction : false,
                    );
                    // 映射字段
                    if (filedname.fieldshine != undefined) {
                      if (Array.isArray(filedname.fieldshine)) {
                        let g = [...filedname.fieldshine];
                        let a1 = [];
                        g.length > 0 &&
                          g.map((i, j) => {
                            if (j !== g.length - 1) {
                              a1.push(i);
                            }
                          });
                        formAdd.setFieldsValue({ parmars: a1 });
                        setFieldshineChecked(true);
                      }
                    } else {
                      if (Array.isArray(filedname)) {
                        let g = [...filedname];
                        let a1 = [];
                        g.length > 0 &&
                          g.map((i, j) => {
                            if (j !== g.length - 1) {
                              a1.push(i);
                            }
                          });
                        formAdd.setFieldsValue({ parmars: a1 });
                        setFieldshineChecked(true);
                      }
                    }
                  } else {
                    form.setFieldsValue({
                      standingBook: book[0] || '',
                      fieldName: ad[0] || '',
                      fieldshine: false,
                    });

                    setFieldshineChecked(false);
                  }
                  let book1 = aa.Config.split('?');
                  if (book1[1]) {
                    form.setFieldsValue({
                      filterName: book1[1],
                    });
                  }
                  if (book1[0].endsWith('.n')) {
                    form.setFieldsValue({
                      check: true,
                    });
                    setCho(true);
                  } else {
                    form.setFieldsValue({
                      check: false,
                    });
                    setCho(false);
                  }
                  break;
                case '选择器':
                  let sele = aa.Config.split('.');
                  if (sele[1] && sele[1] != 'n') {
                    form.setFieldsValue({
                      Association: true,
                      farter: sele[0],
                      farterData: sele[1],
                    });
                    setCse(true);
                  } else {
                    form.setFieldsValue({
                      Association: false,
                      Config: sele[0],
                    });
                    setCse(false);
                  }
                  if (aa.Config.endsWith('.n')) {
                    form.setFieldsValue({ check: true });
                    setCho(true);
                  } else {
                    form.setFieldsValue({ check: false });
                    setCho(false);
                  }
                  break;
                case '人员选择器':
                  let pepole = aa.Config.split('.');
                  console.log(pepole);
                  let id = aa.Config.split('+');
                  form.setFieldsValue({ ShowConfig: aa.Config });
                  if (pepole[0] == '全部') {
                    setHide(false);
                    setFlag(true);
                    setCheckboxAll1(true);
                    if (pepole[1] && pepole[1] != 'n') {
                      let config = pepole[1].split('+');
                      form.setFieldsValue({
                        PeShape: '分组模态',
                        All1: true,
                        AllID1: !!id[1],
                        ConfigName: config[0] !== 'n' ? config[0] : '',
                      });
                    } else {
                      form.setFieldsValue({
                        PeShape: '分组模态',
                        All1: true,
                        AllID1: !!id[1],
                        ConfigName: '',
                      });
                    }
                    setCheckboxAllID1(!!id[1]);
                    if (aa.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({ choose: true });
                      setCho(true);
                    } else {
                      form.setFieldsValue({ choose: false });
                      setCho(false);
                    }
                    setPopeleShape('分组模态');
                  } else if (pepole[0] == 'tree') {
                    setCheckboxAll1(false);
                    setHide(true);
                    setFlag(1);
                    let tree = pepole[1].split('|');
                    let treeId = tree[1].split('+');
                    if (tree[0] == '多选') {
                      if (treeId[0] == '站点') {
                        form.setFieldsValue({
                          PeShape: '树形模态',
                          All1: true,
                          AllID1: !!id[1],
                          guolv: true,
                          choose: true,
                        });
                        setGl(true);
                        setCho(true);
                      } else {
                        form.setFieldsValue({
                          PeShape: '树形模态',
                          All1: true,
                          AllID1: !!id[1],
                          guolv: false,
                          choose: true,
                        });
                        setGl(false);
                        setCho(true);
                      }
                    } else if (treeId[0] == '站点') {
                      form.setFieldsValue({
                        PeShape: '树形模态',
                        All1: true,
                        AllID1: !!id[1],
                        guolv: true,
                        choose: false,
                      });
                      setGl(true);
                      setCho(false);
                    } else {
                      form.setFieldsValue({
                        PeShape: '树形模态',
                        All1: true,
                        AllID1: !!id[1],
                        guolv: false,
                        choose: false,
                      });
                      setGl(false);
                      setCho(false);
                    }
                    setCheckboxAllID1(!!id[1]);
                    setPopeleShape('树形模态');
                  } else {
                    setCheckboxAll1(false);
                    setCheckboxAllID1(!!id[1]);
                    setHide(true);
                    setFlag(false);
                    let aaa = pepole[0].split('+');
                    form.setFieldsValue({
                      All1: false,
                      PeShape: '下拉框',
                      AllID1: !!id[1],
                      Config: aaa[0],
                    });
                    if (aa.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({ choose: true });
                      setCho(true);
                    } else {
                      form.setFieldsValue({ choose: false });
                      setCho(false);
                    }
                    setPopeleShape('下拉框');
                  }

                  break;
              }
              setValue1();
              setPramData({ ...aa, coordinates, must, picture });
              let index = res[2].data.root.find(item => item.Name == aa.ExceptionEvent);

              getFieldData(index.TableName);
            }
          });
        } else {
          Promise.all([req1, req2, req3]).then(res => {
            res[1].msg === 'Ok' && setFieldName(res[1].data.root);
            res[2].msg === 'Ok' && setEventList(res[2].data.root);
            if (res[0].msg === 'Ok') {
              console.log(res[0].data.root.Shape);
              if (res[0].data.root.Shape == '可预览图片') {
                setView(true);
              } else if (res[0].data.root.Shape == '图片') {
                setView(false);
              } else if (res[0].data.root.Shape == '可预览附件') {
                setPreView(true);
              } else if (res[0].data.root.Shape == '附件') {
                setPreView(false);
              } else if (res[0].data.root.Shape == '值选择器') {
                setRadiostyle(0);

                setCho(false);
                form.setFieldsValue({ check: 0, style: 0, choose: false });
              } else if (res[0].data.root.Shape == '值复选器') {
                setRadiostyle(0);

                setCho(true);
                form.setFieldsValue({ check: 1, style: 0, choose: true });
              }
              if (res[0].data.root.Shape == '可预览图片') {
                setShape('图片');
              } else if (res[0].data.root.Shape == '可预览附件') {
                setShape('附件');
              } else if (res[0].data.root.Shape == '平铺值选择器') {
                setShape('值选择器');
              } else if (res[0].data.root.Shape == '值复选器') {
                setShape('值选择器');
              } else {
                setShape(res[0].data.root.Shape);
              }
              console.log(res[0].data.root);
              if (!res[0].data.root.Shape) {
                console.log(1111);
                if (res[0].data.root.StoreType == 'datetime') {
                  setShape('日期时间');
                } else if (
                  res[0].data.root.StoreType == 'int' ||
                  res[0].data.root.StoreType == 'float' ||
                  res[0].data.root.StoreType == 'bigint' ||
                  (res[0].data.root.StoreType == 'int') == 'decimal'
                ) {
                  setShape('数值');
                } else {
                  setShape('文本');
                }
              }
              form.setFieldsValue({ ...res[0].data.root });
              if (res[0].data.root.ExceptionEventFields === '') {
                setCharacterValue('');
                setCheckedList([]);
                setIsShow(false);
              } else {
                setIsShow(true);
                setCharacterValue(res[0].data.root.ExceptionEventFields);
                setCheckedList(res[0].data.root.ExceptionEventFields.split(','));
              }
              if (res[0].data.root.SyncEvent === 1) {
                form.setFieldsValue({ SyncEvent: true });
                setSynchronization(true);
              } else {
                form.setFieldsValue({ SyncEvent: false });
                setSynchronization(false);
              }

              let coordinates = false;
              let picture = false;
              let must = false;
              switch (res[0].data.root.Shape) {
                case '坐标控件':
                  res[0].data.root.Config === '当前坐标'
                    ? (coordinates = true)
                    : (coordinates = false);
                  break;
                case '日期时间':
                case '日期':
                case '日期月份':
                case '日期年份':
                case '日期周':
                case '时分秒':
                  if (res[0].data.root.Config === '默认为空') {
                    form.setFieldsValue({
                      Config: '默认为空',
                    });
                  } else if (res[0].data.root.Config === '锁定为当前时间') {
                    form.setFieldsValue({
                      Config: '不可选择',
                    });
                  } else if (res[0].data.root.Config === '默认为当前时间') {
                    form.setFieldsValue({
                      Config: '默认为当前时间',
                    });
                  } else if (res[0].data.root.Config === '不超过当前时间') {
                    form.setFieldsValue({
                      Config: '不超过当前时间',
                    });
                  }
                  break;
                case '图片':
                case '可预览图片':
                  // res[0].data.root.Config === '拍照相册' ? (picture = true) : (picture = false);
                  res[0].data.root.Config === '拍照相册' ? (picture = true) : (picture = false);
                  res[0].data.root.ValidationRule === 'required' ? (must = true) : (must = false);
                  break;
                case '编码':
                  let code = res[0].data.root.Config.split('.');
                  form.setFieldsValue({
                    code: code[0] || '',
                    prefix: code[1] === 'undefined' ? '' : code[1],
                  });
                  break;
                case '本人部门':
                  let depart = res[0].data.root.Config;
                  form.setFieldsValue({ AllID1: !!depart });
                  setCheckboxAllID1(!!depart);
                  break;
                case '本人姓名':
                  let name = res[0].data.root.Config;
                  form.setFieldsValue({ AllID1: !!name });
                  setCheckboxAllID1(!!name);
                  break;
                case '搜索选择器':
                  let data = res[0].data.root.Config.split('.');
                  form.setFieldsValue({
                    Config: data[0] || '',
                  });
                  if (res[0].data.root.Config.endsWith('.n')) {
                    form.setFieldsValue({
                      check: 1,
                    });
                    setRadio(1);
                  } else {
                    form.setFieldsValue({
                      check: 0,
                    });
                    setRadio(0);
                  }
                  break;
                case '平铺值选择器':
                  let dataa = res[0].data.root.Config.split('.');
                  form.setFieldsValue({
                    Config: dataa[0] || '',
                  });
                  if (res[0].data.root.Config.endsWith('.n')) {
                    form.setFieldsValue({
                      choose: true,
                    });
                    setCho(true);
                  } else {
                    form.setFieldsValue({
                      choose: false,
                    });
                    setCho(false);
                  }
                  form.setFieldsValue({
                    style: 1,
                  });
                  setRadiostyle(1);
                  break;
                case '唯一值文本':
                  let arr = res[0].data.root.Config.split('.');
                  form.setFieldsValue({
                    tableName: arr[0] || '',
                    fieldName: arr[1] || '',
                  });
                  break;
                case '站点选择器':
                  let siteId = res[0].data.root.Config.split('+');
                  let site = siteId[0].split('.');
                  if (site[0] == '本人') {
                    if (res[0].data.root.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({
                        pepole: true,
                        choose: true,
                        AllID1: !!siteId[1],
                      });
                      setPep(true);
                      setCho(true);
                    } else {
                      form.setFieldsValue({
                        pepole: true,
                        choose: false,
                        AllID1: !!siteId[1],
                      });
                      setPep(true);
                      setCho(false);
                    }
                  } else if (site[0] == '全部') {
                    if (res[0].data.root.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({
                        pepole: false,
                        choose: true,
                        AllID1: !!siteId[1],
                      });
                      setPep(false);
                      setCho(true);
                    } else {
                      form.setFieldsValue({
                        pepole: false,
                        choose: false,
                        AllID1: !!siteId[1],
                      });
                      setPep(false);
                      setCho(false);
                    }
                  }
                  setCheckboxAllID1(!!siteId[1]);
                  break;
                case '业务选择器':
                  let list = res[0].data.root.Config.split('.');

                  form.setFieldsValue({
                    tableName: list[0] || '',
                    fieldName: list[1] || '',
                  });
                  if (res[0].data.root.Config.endsWith('.n')) {
                    form.setFieldsValue({
                      check: 1,
                    });
                    setRadio(1);
                  } else {
                    form.setFieldsValue({
                      check: 0,
                    });
                    setRadio(0);
                  }
                  break;
                case '部门选择器':
                  let department = res[0].data.root.Config.split('+');
                  if (department[0] == '.n') {
                    form.setFieldsValue({ choose: true, AllID1: !!department[1] });
                    setCho(true);
                  } else {
                    form.setFieldsValue({ choose: false, AllID1: !!department[1] });
                    setCho(false);
                  }
                  setCheckboxAllID1(!!department[1]);
                  break;

                case '关联表单':
                  let data11 = JSON.parse(res[0].data.root.Config);
                  let rueslt = keepStandingBook.find(i => i.name == data11.台账名称);
                  console.log(rueslt.tableName);
                  if (!rueslt1) {
                    notification.error({
                      message: '提示',
                      duration: 3,
                      description: `没有匹配到台账名【${book[0]}】，请检查配置！`,
                    });
                  } else {
                    getMapFelidValue(rueslt1?.tableName);
                  }
                  form.setFieldsValue({
                    standingBook: data11.台账名称,
                    workOrder: data11.映射字段[data11.映射字段.length - 1].fromField,
                    eventOrder: data11.映射字段[data11.映射字段.length - 1].toField,
                    configName: data11.控制规则,
                  });
                  let gg = [...data11.映射字段];
                  let a11 = [];
                  gg.length > 0 &&
                    gg.map((i, j) => {
                      if (j !== gg.length - 1) {
                        a11.push(i);
                      }
                    });
                  formAdd.setFieldsValue({ parmars: a11 });
                  setVisibleChecked(data11.默认显示);
                  break;
                case '台账选择器':
                  console.log(res[0].data.root.Config);
                  let book = res[0].data.root.Config.split('.');
                  let rueslt1 = keepStandingBook.find(i => i.name == book[0]);
                  console.log(rueslt1.tableName);
                  if (!rueslt1) {
                    notification.error({
                      message: '提示',
                      duration: 3,
                      description: `没有匹配到台账名【${book[0]}】，请检查配置！`,
                    });
                  } else {
                    getMapFelidValue(rueslt1?.tableName);
                  }

                  let ab = book[1].split('?');
                  console.log(ab);
                  if (ab[0].indexOf('[') !== -1) {
                    let filedname = JSON.parse(ab[0]);
                    console.log(filedname);
                    form.setFieldsValue({
                      standingBook: book[0] || '',
                      fieldName: ab[0] || '',
                      workOrder:
                        filedname.fieldshine != undefined
                          ? filedname.fieldshine[filedname.fieldshine.length - 1].fromField
                          : filedname[filedname.length - 1].fromField,
                      eventOrder:
                        filedname.fieldshine != undefined
                          ? filedname.fieldshine[filedname.fieldshine.length - 1].toField
                          : filedname[filedname.length - 1].toField,
                      siteJurisdiction:
                        filedname.siteJurisdiction != undefined
                          ? filedname.siteJurisdiction
                          : false,
                      fieldshine: true,
                    });
                    setSite(
                      filedname.siteJurisdiction != undefined ? filedname.siteJurisdiction : false,
                    );
                    // 映射字段
                    if (filedname.fieldshine != undefined) {
                      if (Array.isArray(filedname.fieldshine)) {
                        let g = [...filedname.fieldshine];
                        let a1 = [];
                        g.length > 0 &&
                          g.map((i, j) => {
                            if (j !== g.length - 1) {
                              a1.push(i);
                            }
                          });
                        formAdd.setFieldsValue({ parmars: a1 });
                        setFieldshineChecked(true);
                      }
                    } else {
                      if (Array.isArray(filedname)) {
                        let g = [...filedname];
                        let a1 = [];
                        g.length > 0 &&
                          g.map((i, j) => {
                            if (j !== g.length - 1) {
                              a1.push(i);
                            }
                          });
                        formAdd.setFieldsValue({ parmars: a1 });
                        setFieldshineChecked(true);
                      }
                    }
                  } else {
                    form.setFieldsValue({
                      standingBook: book[0] || '',
                      fieldName: ab[0] || '',
                      fieldshine: false,
                    });

                    setFieldshineChecked(false);
                  }

                  let book1 = res[0].data.root.Config.split('?');

                  if (book1[1]) {
                    form.setFieldsValue({
                      filterName: book1[1],
                    });
                  }
                  if (book1[0].endsWith('.n')) {
                    form.setFieldsValue({
                      check: true,
                    });
                    setCho(true);
                  } else {
                    form.setFieldsValue({
                      check: false,
                    });
                    setCho(false);
                  }
                  break;
                case '选择器':
                  let sele = res[0].data.root.Config.split('.');
                  if (sele[1] && sele[1] != 'n') {
                    form.setFieldsValue({
                      Association: true,
                      farter: sele[0],
                      farterData: sele[1],
                    });
                    setCse(true);
                  } else {
                    form.setFieldsValue({
                      Association: false,
                      Config: sele[0],
                    });
                    setCse(false);
                  }
                  if (res[0].data.root.Config.endsWith('.n')) {
                    form.setFieldsValue({ choose: true });
                    setCho(true);
                  } else {
                    form.setFieldsValue({ choose: false });
                    setCho(false);
                  }
                  break;
                case '人员选择器':
                  let pepole = res[0].data.root.Config.split('.');
                  let id = res[0].data.root.Config.split('+');
                  form.setFieldsValue({ ShowConfig: res[0].data.root.Config });
                  if (pepole[0] == '全部') {
                    setHide(false);
                    setFlag(true);
                    setCheckboxAll1(true);
                    if (pepole[1] && pepole[1] != 'n') {
                      let aa = pepole[1].split('+');
                      form.setFieldsValue({
                        PeShape: '分组模态',
                        All1: true,
                        AllID1: !!id[1],
                        ConfigName: aa[0] !== 'n' ? aa[0] : '',
                      });
                    } else {
                      form.setFieldsValue({
                        PeShape: '分组模态',
                        All1: true,
                        AllID1: !!id[1],
                        ConfigName: '',
                      });
                    }
                    setCheckboxAllID1(!!id[1]);
                    if (res[0].data.root.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({ choose: true });
                      setCho(true);
                    } else {
                      form.setFieldsValue({ choose: false });
                      setCho(false);
                    }
                    setPopeleShape('分组模态');
                  } else if (pepole[0] == 'tree') {
                    setCheckboxAll1(false);
                    setHide(true);
                    setFlag(1);
                    let tree = pepole[1].split('|');
                    let treeId = tree[1].split('+');
                    if (tree[0] == '多选') {
                      if (treeId[0] == '站点') {
                        form.setFieldsValue({
                          PeShape: '树形模态',
                          All1: true,
                          AllID1: !!id[1],
                          guolv: true,
                          choose: true,
                        });
                        setGl(true);
                        setCho(true);
                      } else {
                        form.setFieldsValue({
                          PeShape: '树形模态',
                          All1: true,
                          AllID1: !!id[1],
                          guolv: false,
                          choose: true,
                        });
                        setGl(false);
                        setCho(true);
                      }
                    } else if (treeId[0] == '站点') {
                      form.setFieldsValue({
                        PeShape: '树形模态',
                        All1: true,
                        AllID1: !!id[1],
                        guolv: true,
                        choose: false,
                      });
                      setGl(true);
                      setCho(false);
                    } else {
                      form.setFieldsValue({
                        PeShape: '树形模态',
                        All1: true,
                        AllID1: !!id[1],
                        guolv: false,
                        choose: false,
                      });
                      setGl(false);
                      setCho(false);
                    }
                    setCheckboxAllID1(!!id[1]);
                    setPopeleShape('树形模态');
                  } else {
                    setCheckboxAll1(false);
                    setCheckboxAllID1(!!id[1]);
                    setHide(true);
                    setFlag(false);
                    let aa = pepole[0].split('+');
                    form.setFieldsValue({
                      All1: false,
                      PeShape: '下拉框',
                      AllID1: !!id[1],
                      Config: aa[0],
                    });
                    if (res[0].data.root.Config.indexOf('.n') !== -1) {
                      form.setFieldsValue({ choose: true });
                      setCho(true);
                    } else {
                      form.setFieldsValue({ choose: false });
                      setCho(false);
                    }
                    setPopeleShape('下拉框');
                  }
                  break;
              }
              setValue1();
              setPramData({ ...res[0].data.root, coordinates, must, picture });
              let index = res[2].data.root.find(
                item => item.Name == res[0].data.root.ExceptionEvent,
              );

              getFieldData(index.TableName);
            }
          });
        }
      }
    }

    // formAdd.validateFields().then(validate1 => {
    // if(validate1){
    form.validateFields().then(validate => {
      if (validate) {
        setLoading(true);
        let obj = form.getFieldsValue();
        let aa = '';
        if (synchronization == true) {
          aa = 1;
        } else {
          aa = 0;
        }
        console.log(obj);
        let data = [
          {
            Unit: obj.Unit || '',
            StoreType: pramData.StoreType,
            Group: pramData.Group || '',
            Shape,
            ExceptionEvent: pramData.ExceptionEvent || '',
            RowSpan: Number(obj.RowSpan) || 0,
            ColSpan: pramData.ColSpan || 0,
            ReadOnly: pramData.ReadOnly || false,
            EditableLater: pramData.EditableLater || false,
            ExceptionValue: pramData.ExceptionValue || '',
            Preset: pramData.Preset || '',
            ID: pramData.ID,
            Order: pramData.Order,
            Name: obj.Name,
            Alias: obj.Alias,
            SyncEvent: aa,
            ValidationRule: obj.ValidationRule,
            ExceptionEventFields: characterValue,
          },
        ];
        console.log(Shape);
        if (Shape == '图片') {
          if (view) {
            data[0].Shape = '可预览图片';
          } else {
            data[0].Shape = '图片';
          }
        }
        if (Shape == '附件') {
          if (preView) {
            data[0].Shape = '可预览附件';
          } else {
            data[0].Shape = '附件';
          }
        }

        if (Shape == '值选择器') {
          if (radiostyle == 0) {
            if (!cho) {
              data[0].Shape = '值选择器';
            } else {
              data[0].Shape = '值复选器';
            }
          } else {
            data[0].Shape = '平铺值选择器';
          }
        }

        switch (Shape) {
          case '本人部门':
            if (checkboxAllID1 == true) {
              data[0].Config = `ID存储`;
            } else {
              data[0].Config = '';
            }
            break;
          case '本人姓名':
            if (checkboxAllID1 == true) {
              data[0].Config = `ID存储`;
            } else {
              data[0].Config = '';
            }
            break;
          case '编码':
            data[0].Config = `${obj.code}.${obj.prefix ? obj.prefix : ''}`;
            break;
          case '坐标控件':
            pramData.coordinates ? (data[0].Config = '当前坐标') : (data[0].Config = '');
            break;
          case '图片':
          case '可预览图片':
            // data[0].Config = pramData.picture ? '拍照相册' : '';
            data[0].Config = pramData.picture ? '拍照相册' : '';
            data[0].ValidationRule = pramData.must ? 'required' : '';
            break;
          case '搜索选择器':
            if (obj.Config.endsWith('.n')) {
              data[0].Config = obj.Config;
            } else {
              data[0].Config = radio == 0 ? `${obj.Config}` : `${obj.Config}.n`;
            }
            break;
          case '唯一值文本':
            data[0].Config = obj.fieldName
              ? `${obj.tableName}.${obj.fieldName}`
              : `${obj.tableName}`;
            break;
          case '站点选择器':
            if (checkboxAllID1 == true) {
              data[0].Config = pep
                ? `本人${cho ? '.n' : ''}+ID存储`
                : `全部${cho ? '.n' : ''}+ID存储`;
            } else {
              data[0].Config = pep ? `本人${cho ? '.n' : ''}` : `全部${cho ? '.n' : ''}`;
            }
            break;
          case '业务选择器':
            if (obj.fieldName.endsWith('.n')) {
              data[0].Config = obj.fieldName
                ? `${obj.tableName}.${obj.fieldName}`
                : `${obj.tableName}`;
            } else if (obj.fieldName) {
              data[0].Config =
                radio == 0
                  ? `${obj.tableName}.${obj.fieldName}`
                  : `${obj.tableName}.${obj.fieldName}.n`;
            } else {
              data[0].Config = radio == 0 ? `${obj.tableName}` : `${obj.tableName}.n`;
            }
            break;
          case '部门选择器':
            if (checkboxAllID1 == true) {
              data[0].Config = cho ? `.n+ID存储` : `+ID存储`;
            } else {
              data[0].Config = cho ? `.n` : '';
            }
            break;
          case '台账选择器':
            let arr = {};
            arr.fromField = obj.workOrder;
            arr.toField = obj.eventOrder;
            let li = [];
            if (formAdd.getFieldValue('parmars')) {
              li = [...formAdd.getFieldValue('parmars')];
            }
            li.push(arr);
            let result = {};
            result.siteJurisdiction = !!site;
            result.fieldshine = li;
            let standData = fieldshineChecked ? JSON.stringify(result) : obj.fieldName;
            if (obj.fieldName && obj.fieldName.endsWith('.n')) {
              data[0].Config = `${obj.standingBook}.${obj.fieldName}`;
            } else if (standData) {
              data[0].Config = cho
                ? `${obj.standingBook}.${standData}.n`
                : `${obj.standingBook}.${standData}`;
            }
            if (obj.filterName) {
              data[0].Config = `${data[0].Config}?${obj.filterName}`;
            } else {
              data[0].Config = `${data[0].Config}`;
            }
            console.log(data[0].Config);
            break;
          case '关联表单':
            let aalist = {};
            let arrlist = {};
            aalist.台账名称 = obj.standingBook;
            arrlist.fromField = obj.workOrder;
            arrlist.toField = obj.eventOrder;
            aalist.默认显示 = visibleChecked || false;
            aalist.控制规则 = obj.configName;
            let lii = [];
            if (formAdd.getFieldValue('parmars')) {
              lii = [...formAdd.getFieldValue('parmars')];
            }
            console.log(lii);
            lii.push(arrlist);
            let lia = [];

            lii.length > 0 &&
              lii.map(i => {
                if (i) {
                  if (i.fromField && i.toField) {
                    lia.push(i);
                  }
                }
              });
            console.log(lia);
            aalist.映射字段 = lia;
            console.log(aalist);
            data[0].Config = JSON.stringify(aalist);
            break;
          case '选择器':
            if (cse) {
              let str = cho
                ? `${obj.farter}.${obj.farterData}.n`
                : `${obj.farter}.${obj.farterData}`;
              data[0].Config = str;
            } else {
              let str = cho ? `${obj.Config}.n` : `${obj.Config}`;
              data[0].Config = str;
            }
            break;
          case '值选择器':
            if (obj.Config.endsWith('.n')) {
              data[0].Config = obj.Config;
            } else if (radiostyle == 1) {
              // 平铺值选择器
              data[0].Config = cho ? `${obj.Config}.n` : `${obj.Config}`;
            } else {
              data[0].Config = obj.Config;
            }
            break;
          case '人员选择器':
            if (popeleShape == '分组模态') {
              if (checkboxAllID1 == true) {
                if (obj.ConfigName) {
                  let str = cho
                    ? `全部.${obj.ConfigName}.n+ID存储`
                    : `全部.${obj.ConfigName}+ID存储`;
                  data[0].Config = str;
                } else {
                  let str = cho ? `全部.n+ID存储` : `全部+ID存储`;
                  data[0].Config = str;
                }
              } else if (obj.ConfigName) {
                let str = cho ? `全部.${obj.ConfigName}.n` : `全部.${obj.ConfigName}`;
                data[0].Config = str;
              } else {
                let str = cho ? `全部.n` : `全部`;
                data[0].Config = str;
              }
            } else if (popeleShape == '下拉框') {
              if (checkboxAllID1 == true) {
                let str = cho ? `${obj.Config}.n+ID存储` : `${obj.Config}+ID存储`;
                data[0].Config = str;
              } else {
                let str = cho ? `${obj.Config}.n` : `${obj.Config}`;
                data[0].Config = str;
              }
            } else if (popeleShape == '树形模态') {
              if (gl) {
                if (checkboxAllID1 == true) {
                  let str = cho ? `tree.多选|站点+ID存储` : `tree.单选|站点+ID存储`;
                  data[0].Config = str;
                } else {
                  let str = cho ? `tree.多选|站点` : `tree.单选|站点`;
                  data[0].Config = str;
                }
              } else {
                if (checkboxAllID1 == true) {
                  let str = cho ? `tree.多选|非站点+ID存储` : `tree.单选|非站点+ID存储`;
                  data[0].Config = str;
                } else {
                  let str = cho ? `tree.多选|非站点` : `tree.单选|非站点`;
                  data[0].Config = str;
                }
              }
            }
            break;
          default:
            data[0].Config = obj.Config;
        }
        console.log(data[0]);
        let aadata = valueData;
        console.log(keepTreeFirst);
        // if (keepTreeFirst.indexOf(e.node.org.name) == -1) {
        if (aadata.length > 0) {
          let aa = [];
          aadata.map(i => {
            aa.push(i.ID);
          });
          if (aa.indexOf(data[0].ID) != -1) {
            aadata.map((i, j) => {
              if (i.ID == data[0].ID) {
                aadata[j] = data[0];
              }
            });
          } else {
            aadata.push(data[0]);
          }
        } else {
          aadata.push(data[0]);
        }
        // }
        console.log(valueData);

        console.log(aadata);
        setValueData(aadata);
        form.setFieldsValue({
          Association: '',
          Config: '',
          guolv: '',
          ConfigName: '',
          tableName: '',
          fieldName: '',
          filterName: '',
          filterValue: '',
          standingBook: '',
          check: 0,
          AllID: '0',
          All: '0',
          AllID1: '',
          All1: '',
          ShowConfig: '',
          pepole: '',
          choose: '',
          SyncEvent: '',
          PeShape: '',
          farter: '',
          farterData: '',
          workOrder: '',
          eventOrder: '',
          configName: '',
        });
        // setVisibleChecked(true);
        setCse('');
        setPopeleShape('');
        setRadio(0);
        setRadiostyle(0);
        setRadio3('0');
        setRadio1('0');
        setGl('');
        setPep('');
        setCho('');
        setSite('');
        setCheckboxAll1('');
        setCheckboxAllID1('');
        setSynchronization(false);
        setFieldshineChecked(false);
        setFlag(false);
        setPopeleShape('');
        setHide(true);
        formAdd.resetFields();
        if (i == 1.14) {
          console.log(valueData);
          UpdateFields(valueData).then(res => {
            setLoading(false);
            if (res.msg === 'Ok' || res.msg === '') {
              form.resetFields();
              callBackSubmit();
              notification.success({
                message: '提示',
                duration: 3,
                description: '修改成功',
              });
            } else {
              notification.error({
                message: '提示',
                duration: 3,
                description: res.msg,
              });
            }
            setSaveBtnLoading(false);
          });
        }
      }
    });
    // }
    // });
  };

  const mapTree1 = org => {
    if (org.children) {
      // 如果当前形态是关联表单 字段名过滤掉本形态字段名
      if (Shape === '关联表单') {
        org.children = org.children.filter(item => item !== pramData.Name)
      }
      return (
        <TreeNode value={org.name} title={org.name} disabled>
          {org.children.map(item => mapTreeSelect(item))}
        </TreeNode>
      );
    }
    if (org.name) {
      return <TreeNode value={org.name} title={org.name} />;
    }
    return <TreeNode value={org} title={org} key={org} />;
  };

  const mapTree2 = org => {
    console.log(123);
    console.log(org);
    if (org.children) {
      return (
        <TreeNode value={org.name} title={org.name} key={org.ID} disabled>
          {org.children.map(item => mapTreeSelect(item))}
        </TreeNode>
      );
    }
    return <TreeNode value={org} title={org} key={org} />;
  };

  const onChange2 = e => {
    setRadio(e.target.value);
    setValue1();
  };

  const onChangestyle = e => {
    setRadiostyle(e.target.value);
  };

  const timeDataOnVChange = e => {
    console.log(e.target.value);
    setTimeData(e.target.value);
  };

  const inputOnChange = e => {
    setValue1();
  };

  const inputOnchange = e => {
    setValue1();
  };

  const onChange3 = e => {
    setRadio3(e.target.value);
    setValue1();
  };

  const onChange1 = e => {
    let aa = form.getFieldsValue().ConfigName;
    let bb = form.getFieldsValue().Config;
    if (e.target.value == '全部') {
      form.setFieldsValue({ ConfigName: bb });
    } else {
      form.setFieldsValue({ Config: aa, AllID: '0' });
      setRadio3('0');
    }
    setRadio1(e.target.value);
    setValue();
  };

  const setValue = () => {
    let aa = form.getFieldsValue().ConfigName;
    let bb = form.getFieldsValue().Config;
    let cc = form.getFieldsValue().All;
    let dd = form.getFieldsValue().AllID;
    let ff = form.getFieldsValue().check;

    if (cc == '全部') {
      if (dd == '全部ID') {
        if (bb) {
          if (ff == 1) {
            form.setFieldsValue({ ShowConfig: `全部ID.${bb}.n` });
          } else {
            form.setFieldsValue({ ShowConfig: `全部ID.${bb}` });
          }
        } else if (ff == 1) {
          form.setFieldsValue({ ShowConfig: `全部ID.n` });
        } else {
          form.setFieldsValue({ ShowConfig: `全部ID` });
        }
      } else if (bb) {
        if (ff == 1) {
          form.setFieldsValue({ ShowConfig: `全部.${bb}.n` });
        } else {
          form.setFieldsValue({ ShowConfig: `全部.${bb}` });
        }
      } else if (ff == 1) {
        form.setFieldsValue({ ShowConfig: `全部.n` });
      } else {
        form.setFieldsValue({ ShowConfig: `全部` });
      }
    } else if (aa) {
      if (ff == 1) {
        form.setFieldsValue({ ShowConfig: `${aa}.n` });
      } else {
        form.setFieldsValue({ ShowConfig: `${aa}` });
      }
    } else if (ff == 1) {
      form.setFieldsValue({ ShowConfig: `.n` });
    } else {
      form.setFieldsValue({ ShowConfig: '' });
    }
  };

  const setValue1 = () => {
    let aa = form.getFieldsValue().ConfigName;
    let bb = form.getFieldsValue().Config;
    let cc = form.getFieldsValue().All;
    let dd = form.getFieldsValue().AllID;
    let ff = form.getFieldsValue().check;
    if (cc == '全部') {
      if (dd == '全部ID') {
        if (aa) {
          if (ff == 1) {
            form.setFieldsValue({ ShowConfig: `全部ID.${aa}.n` });
          } else {
            form.setFieldsValue({ ShowConfig: `全部ID.${aa}` });
          }
        } else if (ff == 1) {
          form.setFieldsValue({ ShowConfig: `全部ID.n` });
        } else {
          form.setFieldsValue({ ShowConfig: `全部ID` });
        }
      } else if (aa) {
        if (ff == 1) {
          form.setFieldsValue({ ShowConfig: `全部.${aa}.n` });
        } else {
          form.setFieldsValue({ ShowConfig: `全部.${aa}` });
        }
      } else if (ff == 1) {
        form.setFieldsValue({ ShowConfig: `全部.n` });
      } else {
        form.setFieldsValue({ ShowConfig: `全部` });
      }
    } else if (bb) {
      if (ff == 1) {
        form.setFieldsValue({ ShowConfig: `${bb}.n` });
      } else {
        form.setFieldsValue({ ShowConfig: `${bb}` });
      }
    } else if (ff == 1) {
      form.setFieldsValue({ ShowConfig: `.n` });
    } else {
      form.setFieldsValue({ ShowConfig: '' });
    }
  };

  const mapTreeSelect = org =>
    org.children ? (
      <TreeNode value={org.name} title={org.name} disabled>
        {org.children.map(item => mapTreeSelect(item))}
      </TreeNode>
    ) : (
      <TreeNode value={org} title={org} key={org} />
    );

  const changePepole = e => {
    setPep(e.target.checked);
  };

  const changeChoose = e => {
    setCho(e.target.checked);
  };

  const changeSite = e => {
    setSite(e.target.checked);
  };

  const changeGl = e => {
    console.log(e);
    setGl(e.target.checked);
  };

  const changeAll1 = e => {
    let aa = form.getFieldsValue().ConfigName;
    let bb = form.getFieldsValue().Config;
    setCheckboxAll1(e.target.checked);
    if (e.target.checked == true) {
      if (bb || bb == '' || bb == undefined) {
        form.setFieldsValue({ ConfigName: bb });
      }
      setHide(false);
      setFlag(true);
    } else {
      if (aa || aa == '' || bb == undefined) {
        form.setFieldsValue({ Config: aa });
      }
      setHide(true);
      setFlag(false);
      setCheckboxAllID1(false);
    }
  };

  const changeAllID1 = e => {
    setCheckboxAllID1(e.target.checked);
  };

  const changeSy = e => {
    setSynchronization(e.target.checked);
  };

  const popeleShapeOnChange = e => {
    form.setFieldsValue({ ConfigName: '', Config: '' });
    console.log(e);
    setPopeleShape(e.target.value);
    // let aa = form.getFieldsValue().ConfigName;
    // let bb = form.getFieldsValue().Config;
    if (e.target.value == '分组模态') {
      // if (bb || bb == '' || bb == undefined) {
      //   form.setFieldsValue({ ConfigName: bb });
      // }
      setHide(false);
      setFlag(true);
    } else if (e.target.value == '下拉框') {
      // if (aa || aa == '' || bb == undefined) {
      //   form.setFieldsValue({ Config: aa });
      // }
      setHide(true);
      setFlag(false);
      // setCheckboxAllID1(false);
    } else if (e.target.value == '树形模态') {
      setHide(true);
      setFlag(1);
      // setCheckboxAllID1(false);
    }
  };

  const changeCse = e => {
    form.setFieldsValue({ farter: '', farterData: '', Config: '' });
    setCse(e.target.checked);
  };

  const editRule = () => {
    setShowRule(true);
  };

  const saveRule = e => {
    form.setFieldsValue({ configName: e });
    setShowRule(false);
    console.log(e);
  };

  return (
    <>
      <Drawer
        title="修改"
        width="1000px"
        // {...props}
        visible={isVisible}
        onClose={onCancel}
        zIndex={99}
        destroyOnClose
        afterClose={() => {
          form.resetFields();
        }}
        footer={
          <Space>
            <Button onClick={onSubmit} loading={saveBtnLoading} type="primary">
              保存
            </Button>
          </Space>
        }
      >
        <div style={{ width: '100%', display: 'flex', justifyContent: 'flex-start' }}>
          <div
            style={{
              width: '300px',
              overflowY: 'scroll',
              height: 'calc(100vh - 160px)',
              borderRight: '1px solid #f0eded',
            }}
          >
            <Tree
              showIcon="true"
              blockNode
              autoExpandParent
              selectedKeys={[currentSelectOrg]}
              onSelect={onSelect}
              treeData={treeValue.map(t => mapTree(t))}
              expandedKeys={expendKey}
            />
          </div>
          {show == 'block' ? (
            <div style={{ width: '600px', overflowY: 'scroll', height: 'calc(100vh - 160px)' }}>
              {isVisible && (
                <Form form={form}>
                  <Item
                    label="字段名"
                    name="Name"
                    labelCol={{ span: 4 }}
                    rules={[{ required: true, message: '请输入表名' }]}
                  >
                    <Input placeholder="请输入别名" disabled />
                  </Item>
                  <Item label="别名" name="Alias" labelCol={{ span: 4 }}>
                    <Input placeholder="请输入别名" allowClear />
                  </Item>
                  <Item name="ReadOnly" label="属性" labelCol={{ span: 4 }}>
                    <div>
                      <Checkbox
                        checked={pramData.ReadOnly}
                        onChange={e => onChangeReady(e, 'ReadOnly')}
                      >
                        只读
                      </Checkbox>
                      <Checkbox
                        checked={pramData.EditableLater}
                        onChange={e => onChangeReady(e, 'EditableLater')}
                      >
                        允许补正(事后修改)
                      </Checkbox>
                    </div>
                  </Item>
                  <Item
                    label={
                      <Tooltip
                        title={
                          <>
                            <span>适合于分表办理，将信息由工单同步到事件</span>
                          </>
                        }
                      >
                        <InfoCircleOutlined
                          style={{
                            color: 'rgb(24 144 255)',
                            marginRight: '5px',
                          }}
                        />
                        <span>同步</span>
                      </Tooltip>
                    }
                    name="SyncEvent"
                    labelCol={{ span: 4 }}
                  >
                    <Checkbox checked={synchronization} onChange={changeSy}>
                      工单 → 事件
                    </Checkbox>
                    {/* <Radio.Group>
                      <Radio value={0} style={{ marginRight: '0.5rem' }}>
                        不同步
                      </Radio>
                      <Radio value={1} style={{ marginRight: '0.5rem' }}>
                        工单 → 事件
                      </Radio>
                     
                    </Radio.Group> */}
                    {/* <Radio value={2}>事件（上报时） → 工单</Radio> */}
                  </Item>
                  <Row>
                    {/* <Col span={1} /> */}
                    <Col span={16}>
                      <Item label="形态" labelCol={{ span: 6 }}>
                        <TreeSelect
                          style={{ width: '95%' }}
                          value={Shape}
                          onChange={handleCharacteristics}
                          showSearch
                          dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                          placeholder="请选择表名 "
                          allowClear
                          treeDefaultExpandAll
                          showCheckedStrategy
                        >
                          {characteristics1 ? (
                            characteristics1.map(i => mapTreeSelect(i))
                          ) : (
                            <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                          )}
                        </TreeSelect>
                      </Item>
                    </Col>

                    <Col span={5}>
                      <Item label="单位" name="Unit" labelCol={{ span: 10 }}>
                        <Input style={{ width: '95%' }} placeholder="" />
                      </Item>
                    </Col>
                    <Col span={3}>
                      <Item label="宽" name="RowSpan" labelCol={{ span: 8 }}>
                        <Input placeholder="" />
                      </Item>
                    </Col>
                  </Row>

                  {/* <div style={{ border: '1px dashed red' }}> */}
                  {(() => {
                    switch (Shape) {
                      case '编码':
                        return (
                          <>
                            <Item label="前缀" name="prefix" labelCol={{ span: 4 }}>
                              <Input placeholder="" allowClear />
                            </Item>
                            <Item label="编码方式" name="code" labelCol={{ span: 4 }}>
                              <Radio.Group>
                                <Radio value="年份编码" style={{ marginRight: '0.5rem' }}>
                                  XJ-2019-000001（前缀-年份-六位编码）
                                </Radio>
                                <Radio value="年月编码" style={{ marginRight: '0.5rem' }}>
                                  XJ-201909-000001（前缀-年份月份-六位编码）
                                </Radio>
                                <Radio value="一般编码" defaultChecked>
                                  XJ00000001（前缀 八位编码）
                                </Radio>
                              </Radio.Group>
                            </Item>
                          </>
                        );
                      // case '值选择器':
                      // case '值复选器':
                      //   return (
                      //     <>
                      //       {' '}
                      //       <Item label="可选值" name="Config" labelCol={{ span: 4 }}>
                      //         <TextArea
                      //           allowClear
                      //           placeholder="用英文逗号分隔自定义的值，可设置初始值"
                      //         />
                      //       </Item>
                      //       {/* <Item colon={false} label=" " labelCol={{ span: 3 }}>
                      //         {' '}
                      //         <div style={{ display: 'flex', alignItems: 'center' }}>
                      //           <span style={{ marginRight: '0.4rem' }}>
                      //             以英文逗号为分隔符填写，或其他分隔符粘贴：
                      //           </span>
                      //           <Select onChange={handleSeparator} style={{ width: '30.8%' }}>
                      //             <Select.Option value="0">以,分隔(英文逗号)</Select.Option>
                      //             <Select.Option value="1">以/分隔(正斜杠)</Select.Option>
                      //             <Select.Option value="2">以\\分隔(反斜杠)</Select.Option>
                      //             <Select.Option value="3">以、分隔(中文顿号)</Select.Option>
                      //             <Select.Option value="4">以;分隔(英文分号)</Select.Option>
                      //             <Select.Option value="5">以；分隔(中文分号)</Select.Option>
                      //             <Select.Option value="6">(是)/否</Select.Option>
                      //             <Select.Option value="7">是/(否)</Select.Option>
                      //             <Select.Option value="8">(否)/是</Select.Option>
                      //           </Select>
                      //         </div>
                      //       </Item> */}
                      //     </>
                      //   );
                      case '可编辑值选择器':
                        return (
                          <>
                            {' '}
                            <Item label="可选值" name="Config" labelCol={{ span: 4 }}>
                              <TextArea
                                allowClear
                                placeholder="用英文逗号分隔自定义的值，可编辑，可设置初始值"
                              />
                            </Item>
                          </>
                        );
                      case '值选择器':
                        return (
                          <>
                            {' '}
                            <Item label="可选值" name="Config" labelCol={{ span: 4 }}>
                              <TextArea
                                allowClear
                                placeholder="用英文逗号分隔自定义的值，勾选，可设置初始值"
                              />
                            </Item>
                            <Item
                              colon={false}
                              name="style"
                              label="交互方式:"
                              labelCol={{ span: 4 }}
                            >
                              <Radio.Group
                                onChange={onChangestyle}
                                value={radiostyle}
                                defaultValue={cheestyle}
                              >
                                <Radio value={0}>下拉框</Radio>
                                <Radio value={1}>平铺</Radio>
                              </Radio.Group>
                            </Item>
                            {/* <Item colon={false} name="check" label="配置:" labelCol={{ span: 4 }}>
                              <Radio.Group onChange={onChange2} value={radio} defaultValue={chee}>
                                <Radio value={0}>单选</Radio>
                                <Radio value={1}>多选</Radio>
                              </Radio.Group>
                            </Item> */}
                            <Item name="choose" label="配置:" labelCol={{ span: 4 }}>
                              <Checkbox
                                checked={cho}
                                onChange={changeChoose}
                                style={{ marginBottom: '0' }}
                              >
                                多选
                              </Checkbox>
                            </Item>
                          </>
                        );
                      case '图片':
                      case '可预览图片':
                        return (
                          <Item name="ReadOnly" label="配置" labelCol={{ span: 4 }}>
                            <div>
                              <Checkbox checked={view} onChange={onChangeView}>
                                可预览
                              </Checkbox>
                              <Checkbox
                                checked={pramData.must}
                                onChange={e => onChangeReady(e, 'must')}
                              >
                                必填字段
                              </Checkbox>
                              <Checkbox
                                checked={pramData.picture}
                                onChange={e => onChangeReady(e, 'picture')}
                              >
                                允许从相册选取
                              </Checkbox>
                            </div>
                          </Item>
                        );
                      case '附件':
                      case '可预览附件':
                        return (
                          <Item label="配置" labelCol={{ span: 4 }}>
                            <div>
                              <Checkbox checked={preView} onChange={onChangePreView}>
                                可预览
                              </Checkbox>
                            </div>
                          </Item>
                        );
                      case '唯一值文本':
                        return (
                          <Row>
                            <Col span={12}>
                              <Item
                                label="表名"
                                name="tableName"
                                labelCol={{ span: 8 }}
                                rules={[{ required: true, message: '请输入表名' }]}
                              >
                                <Input placeholder="请输入表名" />
                              </Item>
                            </Col>
                            <Col span={12}>
                              <Item
                                label="字段名"
                                name="fieldName"
                                labelCol={{ span: 9 }}
                                rules={[{ required: true, message: '请输入表名' }]}
                              >
                                <Input placeholder="请输入字段名" />
                              </Item>
                            </Col>
                          </Row>
                        );
                      case '业务选择器':
                        return (
                          <>
                            <Row>
                              <Col span={12}>
                                <Item
                                  label="表名"
                                  name="tableName"
                                  labelCol={{ span: 8 }}
                                  rules={[{ required: true, message: '请输入表名' }]}
                                >
                                  <Input placeholder="请输入表名" />
                                </Item>
                              </Col>
                              <Col span={12}>
                                <Item
                                  label="字段名"
                                  name="fieldName"
                                  labelCol={{ span: 7 }}
                                  rules={[{ required: true, message: '请输入表名' }]}
                                >
                                  <Input placeholder="请输入字段名" />
                                </Item>
                              </Col>
                            </Row>
                            <Item colon={false} name="check" label="配置:" labelCol={{ span: 4 }}>
                              <Radio.Group onChange={onChange2} value={radio} defaultValue={chee}>
                                <Radio value={0}>单选</Radio>
                                <Radio value={1}>多选</Radio>
                              </Radio.Group>
                            </Item>
                          </>
                        );
                      case '选择器':
                        return (
                          <>
                            <Item labelCol={{ span: 4 }} label="配置">
                              <div style={{ display: 'inline-block', marginRight: '10px' }}>
                                <Item
                                  name="Association"
                                  labelCol={{ span: 4 }}
                                  style={{ marginBottom: '0' }}
                                >
                                  <Checkbox
                                    checked={cse}
                                    onChange={changeCse}
                                    style={{ marginBottom: '0' }}
                                  >
                                    关联选择器
                                  </Checkbox>
                                </Item>
                              </div>
                              {/* <div style={{ display: 'inline-block', marginRight: '10px' }}>
                                <Item
                                  name="choose"
                                  labelCol={{ span: 4 }}
                                  style={{ marginBottom: '0' }}
                                >
                                  <Checkbox
                                    checked={cho}
                                    onChange={changeChoose}
                                    style={{ marginBottom: '0' }}
                                  >
                                    多选
                                  </Checkbox>
                                </Item>
                              </div> */}
                            </Item>
                            {cse ? (
                              <Row>
                                <Col span={12}>
                                  <Item
                                    label="父字段名"
                                    name="farter"
                                    labelCol={{ span: 8 }}
                                    rules={[{ required: true, message: '请输入父字段名' }]}
                                  >
                                    <Input placeholder="请输入父字段名称" />
                                  </Item>
                                </Col>
                                <Col span={12}>
                                  <Item
                                    label="数据字典"
                                    name="farterData"
                                    labelCol={{ span: 7 }}
                                    rules={[{ required: true, message: '请输入数据字典名称' }]}
                                  >
                                    <Input placeholder="请输入数据字典名称" />
                                  </Item>
                                </Col>
                              </Row>
                            ) : (
                              <Item label="数据字典" name="Config" labelCol={{ span: 4 }}>
                                <Input allowClear placeholder="请输入数据字典名称" />
                              </Item>
                            )}
                          </>
                        );
                      case '搜索选择器':
                        return (
                          <>
                            <Item
                              label="数据字典"
                              name="Config"
                              labelCol={{ span: 4 }}
                            // rules={[{ required: true, message: '请输入数据字典名称' }]}
                            >
                              <Input allowClear placeholder="请输入数据字典名称" />
                            </Item>
                            <Item colon={false} name="check" label="配置:" labelCol={{ span: 4 }}>
                              <Radio.Group onChange={onChange2} value={radio} defaultValue={chee}>
                                <Radio value={0}>单选</Radio>
                                <Radio value={1}>多选</Radio>
                              </Radio.Group>
                            </Item>
                          </>
                        );
                      case '部门选择器':
                        return (
                          <Item name="Config" labelCol={{ span: 4 }} label="配置">
                            <div style={{ display: 'inline-block' }}>
                              <Item name="choose" style={{ marginBottom: '0' }}>
                                <Checkbox
                                  checked={cho}
                                  onChange={changeChoose}
                                  style={{ marginBottom: '0' }}
                                >
                                  多选
                                </Checkbox>
                              </Item>
                            </div>
                            <div style={{ display: 'inline-block', marginRight: '10px' }}>
                              <Item name="AllID1" style={{ marginBottom: '0' }}>
                                <Checkbox
                                  checked={checkboxAllID1}
                                  onChange={changeAllID1}
                                  style={{ marginBottom: '0' }}
                                >
                                  ID存储
                                </Checkbox>
                              </Item>
                            </div>
                          </Item>
                        );
                      case '站点选择器':
                        return (
                          <Item name="Config" labelCol={{ span: 4 }} label="配置">
                            <div style={{ display: 'inline-block' }}>
                              <Item name="pepole" style={{ marginBottom: '0' }}>
                                <Checkbox
                                  checked={pep}
                                  onChange={changePepole}
                                  style={{ marginBottom: '0' }}
                                >
                                  本人
                                </Checkbox>
                              </Item>
                            </div>
                            <div style={{ display: 'inline-block', marginRight: '10px' }}>
                              <Item name="AllID1" style={{ marginBottom: '0' }}>
                                <Checkbox
                                  checked={checkboxAllID1}
                                  onChange={changeAllID1}
                                  style={{ marginBottom: '0' }}
                                >
                                  ID存储
                                </Checkbox>
                              </Item>
                            </div>
                            <div style={{ display: 'inline-block' }}>
                              <Item name="choose" style={{ marginBottom: '0' }}>
                                <Checkbox
                                  checked={cho}
                                  onChange={changeChoose}
                                  style={{ marginBottom: '0' }}
                                >
                                  多选
                                </Checkbox>
                              </Item>
                            </div>
                          </Item>
                        );
                      case '关联表单':
                        return (
                          <>
                            <Item
                              label="台账名"
                              name="standingBook"
                              labelCol={{ span: 4 }}
                              rules={[{ required: true, message: '请选择台账名' }]}
                            >
                              <Select
                                placeholder="请选择台账名"
                                showSearch
                                onChange={e => seach(e)}
                              >
                                {keepStandingBook
                                  ? keepStandingBook.map((item, index) => (
                                    <Option key={index} value={item.name}>
                                      {item.name}
                                    </Option>
                                  ))
                                  : ''}
                              </Select>
                            </Item>
                            <Item
                              style={{ marginBottom: '10px' }}
                              label={
                                <>
                                  <span
                                    style={{
                                      color: 'red',
                                      fontSize: '17px',
                                      marginRight: '5px',
                                      marginTop: '3px',
                                    }}
                                  >
                                    *
                                  </span>
                                  <span>映射字段</span>
                                </>
                              }
                              labelCol={{ span: 4 }}
                            >
                              <Row>
                                <Col span={11}>
                                  <Item
                                    name="workOrder"
                                    rules={[{ required: true, message: '请输入字段名' }]}
                                    style={{ marginBottom: 0 }}
                                  >
                                    <TreeSelect
                                      showSearch
                                      style={{ width: '208px' }}
                                      // value={treeSelectValue}
                                      dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                                      placeholder="请选择字段名 "
                                      allowClear
                                      treeDefaultExpandAll
                                      showCheckedStrategy
                                    // onChange={treeSelectOnchange}
                                    >
                                      {fieldValue ? (
                                        fieldValue.map(i => mapTree1(i))
                                      ) : (
                                        <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                                      )}
                                    </TreeSelect>
                                  </Item>
                                </Col>
                                <Col span={1} style={{ paddingTop: '3px' }}>
                                  {' '}
                                  <img
                                    src={logo}
                                    style={{ height: '24px', marginLeft: '-10px' }}
                                    alt=""
                                  />
                                </Col>
                                <Col span={11}>
                                  <Item
                                    name="eventOrder"
                                    rules={[{ required: true, message: '请输入映射字段名' }]}
                                    style={{ marginBottom: 0 }}
                                  >
                                    <Select
                                      placeholder="选择映射字段名"
                                      showSearch
                                      style={{ width: '208px' }}
                                    >
                                      {mapFieldValue.length > 0
                                        ? mapFieldValue.map((item, index) => (
                                          <>
                                            <Option key={item.name} value={item.name}>
                                              {item.name}
                                            </Option>
                                          </>
                                        ))
                                        : ''}
                                    </Select>
                                  </Item>
                                </Col>
                              </Row>
                            </Item>
                            <Form name="form" form={formAdd} labelCol={{ span: 7 }}>
                              <Form.List name="parmars">
                                {(fields, { add, remove }) => (
                                  <>
                                    {fields.map(({ key, name, fieldKey, ...restField }) => (
                                      <Space
                                        key={key}
                                        style={{
                                          display: 'flex',
                                          marginBottom: '5px',
                                          justifyContent: 'center',
                                        }}
                                        align="baseline"
                                      >
                                        <Form.Item
                                          {...restField}
                                          style={{ marginBottom: '5px' }}
                                          name={[name, 'fromField']}
                                          fieldKey={[fieldKey, 'key']}
                                          validateTrigger={['onChange', 'onBlur']}
                                          rules={[
                                            { required: true, message: '请填写字段名' },
                                            {
                                              validator: () => {
                                                let aa = formAdd.getFieldsValue().parmars;
                                                let data = [];
                                                aa.length > 0 &&
                                                  aa.map(i => {
                                                    if (i) {
                                                      data.push(i.fromField);
                                                    }
                                                  });
                                                let list = new Set(data);
                                                let ee = form.getFieldsValue().workOrder;
                                                if (
                                                  list.size !== data.length ||
                                                  data.indexOf(ee) != -1
                                                ) {
                                                  return Promise.reject(new Error('字段名重复'));
                                                }
                                                return Promise.resolve();
                                              },
                                            },
                                          ]}
                                        >
                                          <TreeSelect
                                            showSearch
                                            style={{ width: '208px', marginLeft: '98px' }}
                                            // value={treeSelectValue}
                                            dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                                            placeholder="请选择字段名 "
                                            allowClear
                                            treeDefaultExpandAll
                                            showCheckedStrategy
                                          // onChange={treeSelectOnchange}
                                          >
                                            {fieldValue ? (
                                              fieldValue.map(i => mapTree1(i))
                                            ) : (
                                              <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                                            )}
                                          </TreeSelect>
                                        </Form.Item>
                                        {/* <SwapOutlined style={{marginLeft:'4px'}}/> */}
                                        <img src={logo} style={{ height: '24px' }} alt="" />
                                        <Form.Item
                                          {...restField}
                                          style={{ marginBottom: '5px' }}
                                          name={[name, 'toField']}
                                          fieldKey={[fieldKey, 'key']}
                                          rules={[{ required: true, message: '请填写映射字段名' }]}
                                        >
                                          <Select
                                            placeholder="选择映射字段名"
                                            showSearch
                                            style={{ width: '208px' }}
                                          >
                                            {mapFieldValue.length > 0
                                              ? mapFieldValue.map((item, index) => (
                                                <>
                                                  <Option key={item.name} value={item.name}>
                                                    {item.name}
                                                  </Option>
                                                </>
                                              ))
                                              : ''}
                                          </Select>
                                        </Form.Item>
                                        <MinusCircleOutlined
                                          onClick={() => remove(name)}
                                          style={{ marginLeft: '10px', fontSize: '20px' }}
                                        />
                                      </Space>
                                    ))}
                                    <Form.Item>
                                      <Button
                                        style={{ width: '456px', marginLeft: '100px' }}
                                        type="dashed"
                                        onClick={() => add()}
                                        block
                                        icon={<PlusOutlined />}
                                      >
                                        添加映射
                                      </Button>
                                    </Form.Item>
                                  </>
                                )}
                              </Form.List>
                            </Form>
                            <Item label="默认显示" labelCol={{ span: 4 }}>
                              <Switch
                                checkedChildren="是"
                                unCheckedChildren="否"
                                checked={visibleChecked}
                                onChange={change}
                              //  style={{ marginLeft: '35px' }}
                              />
                            </Item>
                            <Item
                              label="控制规则"
                              name="configName"
                              labelCol={{ span: 4 }}
                            // rules={[{ required: true, message: '请输入控制规则' }]}
                            >
                              {/* <TextArea placeholder="示例:{表名.是否缴费} = ‘是’ and {表名.缴费金额} > 1000" /> */}
                              <div
                                style={{
                                  border: '2px solid #6A98FA',
                                  minHeight: '34px',
                                  lineHeight: '34px',
                                  textAlign: 'center',
                                }}
                                onClick={editRule}
                              >
                                <span>{form.getFieldsValue().configName}</span>
                              </div>
                            </Item>
                          </>
                        );

                      case '台账选择器':
                        return (
                          <>
                            <Item
                              label="台账名"
                              name="standingBook"
                              labelCol={{ span: 4 }}
                              rules={[{ required: true, message: '请选择台账名' }]}
                            >
                              <Select onChange={e => seach(e)} showSearch>
                                {keepStandingBook
                                  ? keepStandingBook.map((item, index) => (
                                    <Option key={index} value={item.name}>
                                      {item.name}
                                    </Option>
                                  ))
                                  : ''}
                              </Select>
                            </Item>
                            <Item label="字段映射" name="fieldshine" labelCol={{ span: 4 }}>
                              <Switch
                                checkedChildren="是"
                                unCheckedChildren="否"
                                checked={fieldshineChecked}
                                onChange={fieldshineChange}
                              />
                            </Item>
                            <Item label="配置" labelCol={{ span: 4 }}>
                              {fieldshineChecked && (
                                <div style={{ display: 'inline-block', marginRight: '20px' }}>
                                  <Item name="siteJurisdiction" style={{ marginBottom: '0px' }}>
                                    <Checkbox checked={site} onChange={changeSite}>
                                      站点过滤
                                    </Checkbox>
                                  </Item>
                                </div>
                              )}
                              {!fieldshineChecked && (
                                <div style={{ display: 'inline-block', marginRight: '20px' }}>
                                  <Item name="check" style={{ marginBottom: '0px' }}>
                                    <Checkbox
                                      checked={cho}
                                      onChange={changeChoose}
                                      style={{ marginBottom: '0' }}
                                    >
                                      多选
                                    </Checkbox>
                                  </Item>
                                </div>
                              )}
                            </Item>
                            {fieldshineChecked === false ? (
                              <Item
                                label="字段名"
                                name="fieldName"
                                labelCol={{ span: 4 }}
                                rules={[{ required: true, message: '请输入字段名' }]}
                              >
                                <Input placeholder="台账表中字段用于数据回显" />
                              </Item>
                            ) : (
                              <>
                                <Item
                                  style={{ marginBottom: '10px' }}
                                  label={
                                    <>
                                      <span
                                        style={{
                                          color: 'red',
                                          fontSize: '17px',
                                          marginRight: '5px',
                                          marginTop: '3px',
                                        }}
                                      >
                                        *
                                      </span>
                                      <span>映射字段</span>
                                    </>
                                  }
                                  labelCol={{ span: 4 }}
                                >
                                  <Row>
                                    <Col span={11}>
                                      <Item
                                        name="workOrder"
                                        rules={[{ required: true, message: '请输入字段名' }]}
                                        style={{ marginBottom: 0 }}
                                      >
                                        <TreeSelect
                                          showSearch
                                          style={{ width: '208px' }}
                                          dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                                          placeholder="请选择字段名 "
                                          allowClear
                                          treeDefaultExpandAll
                                        >
                                          {standbookData ? (
                                            standbookData.map(i => mapTree2(i))
                                          ) : (
                                            <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                                          )}
                                        </TreeSelect>
                                      </Item>
                                    </Col>
                                    <Col span={1} style={{ paddingTop: '3px' }}>
                                      {' '}
                                      <img
                                        src={logo}
                                        style={{ height: '24px', marginLeft: '-10px' }}
                                        alt=""
                                      />
                                    </Col>
                                    <Col span={11}>
                                      <Item
                                        name="eventOrder"
                                        rules={[{ required: true, message: '请输入映射字段名' }]}
                                        style={{ marginBottom: 0 }}
                                      >
                                        <TreeSelect
                                          showSearch
                                          style={{ width: '208px' }}
                                          dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                                          placeholder="请选择映射字段名"
                                          allowClear
                                          treeDefaultExpandAll
                                        >
                                          {standFiledData ? (
                                            standFiledData.map(i => mapTree2(i))
                                          ) : (
                                            <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                                          )}
                                        </TreeSelect>
                                      </Item>
                                    </Col>
                                  </Row>
                                </Item>
                                <Form name="form" form={formAdd} labelCol={{ span: 7 }}>
                                  <Form.List name="parmars">
                                    {(fields, { add, remove }) => (
                                      <>
                                        {fields.map(({ key, name, fieldKey, ...restField }) => (
                                          <Space
                                            key={key}
                                            style={{
                                              display: 'flex',
                                              marginBottom: '5px',
                                              justifyContent: 'center',
                                            }}
                                            align="baseline"
                                          >
                                            <Form.Item
                                              {...restField}
                                              style={{ marginBottom: '5px' }}
                                              name={[name, 'fromField']}
                                              fieldKey={[fieldKey, 'key']}
                                              validateTrigger={['onChange', 'onBlur']}
                                              rules={[{ required: true, message: '请填写字段名' }]}
                                            >
                                              <TreeSelect
                                                showSearch
                                                style={{ width: '208px', marginLeft: '98px' }}
                                                dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                                                placeholder="请选择字段名 "
                                                allowClear
                                                treeDefaultExpandAll
                                              >
                                                {standbookData ? (
                                                  standbookData.map(i => mapTree2(i))
                                                ) : (
                                                  <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                                                )}
                                              </TreeSelect>
                                            </Form.Item>
                                            <img src={logo} style={{ height: '24px' }} alt="" />
                                            <Form.Item
                                              {...restField}
                                              style={{ marginBottom: '5px' }}
                                              name={[name, 'toField']}
                                              fieldKey={[fieldKey, 'key']}
                                              rules={[
                                                { required: true, message: '请填写映射字段名' },
                                                {
                                                  validator: () => {
                                                    let aa = formAdd.getFieldsValue().parmars;
                                                    let data = [];
                                                    aa.length > 0 &&
                                                      aa.map(i => {
                                                        if (i) {
                                                          data.push(i.toField);
                                                        }
                                                      });
                                                    let list = new Set(data);
                                                    let ee = form.getFieldsValue().eventOrder;
                                                    if (
                                                      list.size !== data.length ||
                                                      data.indexOf(ee) != -1
                                                    ) {
                                                      return Promise.reject(
                                                        new Error('映射字段名重复'),
                                                      );
                                                    }
                                                    return Promise.resolve();
                                                  },
                                                },
                                              ]}
                                            >
                                              <TreeSelect
                                                showSearch
                                                style={{ width: '208px' }}
                                                dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                                                placeholder="请选择字段名 "
                                                allowClear
                                                treeDefaultExpandAll
                                              >
                                                {standFiledData ? (
                                                  standFiledData.map(i => mapTree2(i))
                                                ) : (
                                                  <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
                                                )}
                                              </TreeSelect>
                                            </Form.Item>
                                            <MinusCircleOutlined
                                              onClick={() => remove(name)}
                                              style={{ marginLeft: '10px', fontSize: '20px' }}
                                            />
                                          </Space>
                                        ))}
                                        <Form.Item>
                                          <Button
                                            style={{ width: '456px', marginLeft: '100px' }}
                                            type="dashed"
                                            onClick={() => add()}
                                            block
                                            icon={<PlusOutlined />}
                                          >
                                            添加映射
                                          </Button>
                                        </Form.Item>
                                      </>
                                    )}
                                  </Form.List>
                                </Form>
                              </>
                            )}

                            {/* <Col span={12}> */}
                            <Item label="SQL过滤" name="filterName" labelCol={{ span: 4 }}>
                              <TextArea placeholder="示例：部门='XX部门'" />
                            </Item>

                            {/* </Col> */}
                            {/* <Col span={2}>
                                <span style={{ marginLeft: '20px' }}>=</span>
                              </Col>
                              <Col span={9}>
                                <Item name="filterValue">
                                  <Input
                                    style={{ width: '89%', marginLeft: '12px' }}
                                    placeholder="请输入过滤条件"
                                  />
                                </Item>
                              </Col> */}
                          </>
                        );
                      case '人员选择器':
                        return (
                          <>
                            <Item labelCol={{ span: 4 }} label="交互方式" name="PeShape">
                              <div style={{ display: 'inline-block', marginRight: '10px' }}>
                                <Radio.Group
                                  style={{ marginTop: '0.3rem' }}
                                  value={popeleShape}
                                  onChange={popeleShapeOnChange}
                                >
                                  <Radio value="下拉框">下拉框</Radio>
                                  <Radio value="分组模态">
                                    {' '}
                                    <Tooltip
                                      title={
                                        <>
                                          <span>分组模态显示人员所属机构</span>
                                          <Image width={200} src={AllImage} />
                                        </>
                                      }
                                    >
                                      <InfoCircleOutlined
                                        style={{
                                          color: 'rgb(24 144 255)',
                                          marginRight: '5px',
                                          marginTop: '-8px',
                                        }}
                                      />
                                    </Tooltip>
                                    分组模态
                                  </Radio>

                                  {/* <Radio value="树形模态">
                                    <Tooltip
                                      title={
                                        <>
                                          <span>树形模态显示部门树</span>
                                          <Image width={200} src={TreeImage} />
                                        </>
                                      }
                                    >
                                      <InfoCircleOutlined
                                        style={{
                                          color: 'rgb(24 144 255)',
                                          marginRight: '5px',
                                          marginTop: '-8px',
                                        }}
                                      />
                                    </Tooltip>
                                    树形模态
                                  </Radio> */}
                                </Radio.Group>
                              </div>
                            </Item>
                            <Item labelCol={{ span: 4 }} label="配置">
                              {/* <div style={{ display: 'inline-block', marginRight: '10px' }}>
                                <Item name="All1" style={{ marginBottom: '0' }}>
                                  <Checkbox
                                    checked={checkboxAll1}
                                    onChange={changeAll1}
                                    style={{ marginBottom: '0' }}
                                  >
                                    弹窗
                                  </Checkbox>
                                </Item>
                              </div> */}
                              <div style={{ display: 'inline-block', marginRight: '10px' }}>
                                <Item name="choose" style={{ marginBottom: '0' }}>
                                  <Checkbox
                                    checked={cho}
                                    onChange={changeChoose}
                                    style={{ marginBottom: '0' }}
                                  >
                                    多选
                                  </Checkbox>
                                </Item>
                              </div>
                              <div style={{ display: 'inline-block', marginRight: '10px' }}>
                                <Item name="AllID1" style={{ marginBottom: '0' }}>
                                  <Checkbox
                                    checked={checkboxAllID1}
                                    onChange={changeAllID1}
                                    style={{ marginBottom: '0' }}
                                  // disabled={hide}
                                  >
                                    ID存储
                                  </Checkbox>
                                </Item>
                              </div>
                            </Item>
                            {(() => {
                              switch (flag) {
                                case true:
                                  return (
                                    <>
                                      <Item
                                        label="机构角色"
                                        name="ConfigName"
                                        labelCol={{ span: 4 }}
                                        rules={[
                                          {
                                            validator: (rule, value) => {
                                              let str = /[.]/g;
                                              if (str.test(form.getFieldValue().ConfigName)) {
                                                return Promise.reject('.作为分隔符,请勿输入');
                                              }
                                              return Promise.resolve();
                                            },
                                          },
                                        ]}
                                      >
                                        <Input
                                          allowClear
                                          placeholder="请输入角色或机构名称"
                                          onChange={inputOnChange}
                                        />
                                      </Item>
                                    </>
                                  );
                                case 1:
                                  return (
                                    <>
                                      <Item label="机构角色" name="guolv" labelCol={{ span: 4 }}>
                                        <Checkbox
                                          checked={gl}
                                          onChange={changeGl}
                                          style={{ marginBottom: '0' }}
                                        >
                                          本人站点
                                        </Checkbox>
                                      </Item>
                                    </>
                                  );
                                case false:
                                  return (
                                    <>
                                      <Item
                                        label="机构角色："
                                        name="Config"
                                        labelCol={{ span: 4 }}
                                        rules={[
                                          {
                                            required: true,
                                            message: '请输入角色或机构名称',
                                          },
                                          {
                                            validator: (rule, value) => {
                                              let str = /[.]/g;
                                              if (str.test(form.getFieldValue().Config)) {
                                                return Promise.reject('.作为分隔符,请勿输入');
                                              }
                                              return Promise.resolve();
                                            },
                                          },
                                        ]}
                                      >
                                        <Input
                                          allowClear
                                          placeholder="请输入角色或机构名称"
                                          onChange={inputOnchange}
                                        />
                                      </Item>
                                    </>
                                  );
                              }
                            })()}
                          </>
                        );

                      case '日期时间':
                      case '日期':
                      case '日期月份':
                      case '日期年份':
                      case '日期周':
                      case '时分秒':
                        return (
                          <Item label="选项" name="Config" labelCol={{ span: 4 }}>
                            <Radio.Group
                              style={{ marginTop: '0.3rem' }}
                              value={timeData}
                              onChange={timeDataOnVChange}
                            >
                              <Radio
                                value="默认为空"
                                style={{ width: '18rem', marginBottom: '0.5rem' }}
                              >
                                默认为空
                              </Radio>
                              <Radio value="默认为当前时间">默认为当前时间</Radio>
                              <Radio value="不可选择" style={{ width: '18rem' }}>
                                锁定为当前时间
                              </Radio>
                              <Radio value="不超过当前时间">不超过当前时间</Radio>
                            </Radio.Group>
                          </Item>
                        );
                      case '坐标控件':
                        return (
                          <Item label="选项" name="Config" labelCol={{ span: 4 }}>
                            <div>
                              <Checkbox
                                value="当前坐标"
                                style={{ marginRight: '0.2rem' }}
                                checked={pramData.coordinates}
                                onChange={e => onChangeReady(e, 'coordinates')}
                              />
                              锁定为当前位置坐标
                            </div>
                          </Item>
                        );
                      case '本人姓名':
                        return (
                          <Item name="Config" labelCol={{ span: 4 }} label="配置">
                            <div style={{ display: 'inline-block', marginRight: '10px' }}>
                              <Item name="AllID1" style={{ marginBottom: '0' }}>
                                <Checkbox
                                  checked={checkboxAllID1}
                                  onChange={changeAllID1}
                                  style={{ marginBottom: '0' }}
                                >
                                  ID存储
                                </Checkbox>
                              </Item>
                            </div>
                          </Item>
                        );
                      case '本人部门':
                        return (
                          <Item name="Config" labelCol={{ span: 4 }} label="配置">
                            <div style={{ display: 'inline-block', marginRight: '10px' }}>
                              <Item name="AllID1" style={{ marginBottom: '0' }}>
                                <Checkbox
                                  checked={checkboxAllID1}
                                  onChange={changeAllID1}
                                  style={{ marginBottom: '0' }}
                                >
                                  ID存储
                                </Checkbox>
                              </Item>
                            </div>
                          </Item>
                        );
                      // case '位置坐标':
                      //   return (
                      //     <Item label="字段名称" name="Config" labelCol={{ span: 4 }}>
                      //       <Input allowClear placeholder="请输入坐标位置" />
                      //     </Item>
                      //   );
                      case '视频':
                      case '录音':
                      case '地址':
                      case '城市选择器':
                      case '设备选择':
                      case '区域控件':
                      case '路径控件':
                      case '智能抄表':
                        // case '位置坐标':
                        return <></>;
                      default:
                        return (
                          <Item label="配置" name="Config" labelCol={{ span: 4 }}>
                            <TextArea allowClear placeholder={detail} />
                          </Item>
                        );
                    }
                  })()}
                  {/* </div> */}
                  {Shape === '图片' || Shape === '可预览图片' ? (
                    ''
                  ) : (
                    <Item labelCol={{ span: 4 }}>
                      {/* <div className={styles.listEvent}> */}
                      <Row>
                        <Col span={12}>
                          <Item label="预设值" labelCol={{ span: 8 }}>
                            <Input
                              // style={{ width: '41%', height: '1.8rem' }}
                              value={pramData.Preset}
                              onChange={e => handleInput(e, 'Preset')}
                              placeholder=""
                              allowClear
                            />
                          </Item>
                        </Col>
                        <Col span={11}>
                          <Item
                            style={{ marginLeft: '1rem' }}
                            label="验证"
                            labelCol={{ span: 7 }}
                            name="ValidationRule"
                          >
                            <Input style={{ width: '92%' }} placeholder="" allowClear />
                          </Item>
                        </Col>
                        <Col span={1}>
                          <Tooltip title="选择验证规则">
                            <PlusSquareOutlined
                              onClick={() => {
                                add1('rule');
                              }}
                              style={{
                                fontSize: '24px',
                                color: '#1890FF',
                                marginTop: '8px',
                                marginLeft: '-3px',
                              }}
                            />
                          </Tooltip>
                        </Col>
                      </Row>
                    </Item>
                  )}

                  {/* <Item label="异常值">
              <div className={styles.listEvent}>
                <Input
                  style={{ width: '40%', height: '1.8rem' }}
                  value={pramData.ExceptionValue}
                  onChange={e => handleInput(e, 'ExceptionValue')}
                  placeholder=""
                  allowClear
                />
                <Item
                  style={{ marginLeft: '1rem' }}
                  label="触发事件"
                  name="ExceptionEvent"
                  style={{ margin: '0 0 0 1rem' }}
                >
                  <Select style={{ width: '12rem' }} onChange={handleEvent}>
                    {eventList.length
                      ? eventList.map((item, index) => {
                          return (
                            <Select.Option
                              key={index}
                              tablename={item.TableName}
                              name={item.Name}
                              value={item.ID}
                            >
                              {item.Name}
                            </Select.Option>
                          );
                        })
                      : ''}
                  </Select>
                </Item>
              </div>
            </Item>
            <Item label="字段集">
              <div className={styles.listEvent}>
                <Input
                  style={{ width: '93%' }}
                  placeholder=""
                  disabled={!isShow}
                  onChange={onCharacterValue}
                  allowClear
                  value={characterValue}
                />
                <Tooltip title={!isShow ? '' : '字符集选择'}>
                  <PlusSquareOutlined
                    onClick={() => (!isShow ? '' : add('characteristics'))}
                    style={{
                      fontSize: '24px',
                      color: !isShow ? 'gray' : '#1890FF',
                      cursor: !isShow ? 'no-drop' : 'pointer',
                      display: 'flex',
                      alignItems: 'center',
                      marginLeft: '0.5rem',
                    }}
                  />
                </Tooltip>
              </div>
            </Item> */}
                </Form>
              )}
              {/* <ChangeAdd
          visible={visible}
          onCancel={() => setVisible(false)}
          callBackSubmit={onOK}
          newCheckedList={checkedList}
          isType={type}
          filed={filed}
          characterValue={characterValue}
          formObj={formObj}
        /> */}
              <VerifyModal
                visible={visible}
                onCancel={() => setVisible(false)}
                callBackSubmit={onOK}
                newCheckedList={checkedList}
                isType={type}
                filed={filed}
                characterValue={characterValue}
                formObj={formObj}
              />
            </div>
          ) : (
            <div style={{ margin: '0 auto' }}>
              <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="当前未选中字段" />
            </div>
          )}
        </div>
      </Drawer>
      <RuleConfig
        RuleContent={form.getFieldsValue().configName}
        fieldList={fieldList}
        visible={showRule}
        handleCancel={() => setShowRule(false)}
        onSubumit={e => saveRule(e)}
        flag={2}
      />
    </>
  );
};
export default AddModal;
