/* eslint-disable */
/* eslint-disable array-callback-return,no-undef,prefer-destructuring */
import React, { Component } from 'react';
import { Modal, message } from 'antd-v4';
import * as XLSX from 'xlsx';
import commonConfig from '../../utils/config';
import * as commonFunc from './commonFunc';
import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
import * as commonUtils from '../../utils/utils'; /* 通用方法 */
import * as commonServices from './../../services/services'; /*   服务类   */

const { confirm } = Modal;

export default (ChildComponent) => {
  return class extends Component {
    constructor(props) {
      super(props);
      this.state = {};
      this.form = {};
      /*   表单对象   */
    }

    async componentWillReceiveProps(nextProps) {
      const {
        formData, currentId, sModelsType, app,
      } = nextProps;
      let {
        employeeConfig, bReceived, masterConfig,
        sisproductclassifyProcessClassifyConfig, siscommonstyleproductclassifyConfig,
      } = nextProps;
      const {
        contactConfig: contactOldConfig, supplyConfig: supplyOldConfig, machineConfig: machineOldConfig,
        picFileConfig: picFileOldConfig, eleemployeeConfig: eleemployeeOldConfig, jurgroupConfig: jurgroupOldConfig,
        userConfig: userOldConfig, sischeckphaselogininfoConfig: sischeckphaselogininfoOldConfig, sysmsguserConfig: sysmsguserOldConfig,
        eleknifemouldproductConfig: eleknifemouldOldproductConfig, eleteststandarditemConfig: eleteststandardOlditemConfig,
      } = nextProps;
      if (commonUtils.isEmptyObject(contactOldConfig) && (sModelsType === 'element/supplyInfo' || sModelsType === 'element/customerInfo') && formData.length > 0) {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        if (sModelsType === 'element/customerInfo') {
          const contactConfig = formData.filter(item => item.bGrd && item.sTbName === 'elecustomercontacts')[0];
          const contactColumn = commonFunc.getHeaderConfig(contactConfig);
          const addressConfig = formData.filter(item => item.bGrd && item.sTbName === 'elecustomeraddress')[0];
          const addressColumn = commonFunc.getHeaderConfig(addressConfig);
          let addState = {};
          if (sId === '') {
            const config = {};
            config.masterConfig = masterConfig;
            config.contactConfig = contactConfig;
            config.addressConfig = addressConfig;
            addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
          } else {
            this.handleGetData(masterConfig, contactConfig, addressConfig);
          }
          this.props.onSaveState({
            masterConfig,
            contactConfig,
            contactColumn,
            addressConfig,
            addressColumn,
            sId,
            pageLoading: false,
            ...addState,
          });
        } else if (sModelsType === 'element/supplyInfo') {
          const contactConfig = formData.filter(item => item.bGrd && item.sTbName === 'elesupplycontacts')[0];
          const contactColumn = commonFunc.getHeaderConfig(contactConfig);
          const addressConfig = formData.filter(item => item.bGrd && item.sTbName === 'elesupplyaddress')[0];
          const addressColumn = commonFunc.getHeaderConfig(addressConfig);
          let addState = {};
          if (sId === '') {
            const config = {};
            config.masterConfig = masterConfig;
            config.contactConfig = contactConfig;
            config.addressConfig = addressConfig;
            addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
          } else {
            this.handleGetData(masterConfig, contactConfig, addressConfig);
          }
          this.props.onSaveState({
            masterConfig,
            contactConfig,
            contactColumn,
            addressConfig,
            addressColumn,
            sId,
            pageLoading: false,
            ...addState,
          });
        }
      }
      if (commonUtils.isEmptyObject(supplyOldConfig) && formData.length > 0 && sModelsType === 'element/materialsInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        const supplyConfig = formData.filter(item => item.bGrd && item.sTbName === 'elematerialssupply')[0];
        const supplyColumn = commonFunc.getHeaderConfig(supplyConfig);
        const stockConfig = formData.filter(item => item.bGrd && item.sTbName === 'elematerialsstock')[0];
        const stockColumn = commonFunc.getHeaderConfig(stockConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.supplyConfig = supplyConfig;
          config.stockConfig = stockConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetMaterialsData(masterConfig, supplyConfig, stockConfig);
        }
        this.props.onSaveState({
          masterConfig,
          supplyConfig,
          supplyColumn,
          stockConfig,
          stockColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      /*  印件分类 */
      if (commonUtils.isEmptyObject(sisproductclassifyProcessClassifyConfig) && formData.length > 0 && sModelsType === 'element/sisproductclassify') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        sisproductclassifyProcessClassifyConfig = formData.filter(item => item.bGrd && item.sTbName === 'sisproductclassifyProcessClassify')[0];
        const sisproductclassifyProcessClassifyColumn = commonFunc.getHeaderConfig(sisproductclassifyProcessClassifyConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.sisproductclassifyProcessClassifyConfig = sisproductclassifyProcessClassifyConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetProductclassifyData(masterConfig, sisproductclassifyProcessClassifyConfig);
        }
        this.props.onSaveState({
          masterConfig,
          sisproductclassifyProcessClassifyConfig,
          sisproductclassifyProcessClassifyColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (commonUtils.isEmptyObject(masterConfig) && formData.length > 0 && sModelsType === 'element/processInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        const machineConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'eleprocessmachine')) ? formData.filter(item => item.bGrd && item.sTbName === 'eleprocessmachine')[0] : {};
        let machineColumn = [];
        if (commonUtils.isNotEmptyObject(machineConfig)) {
          machineColumn = commonFunc.getHeaderConfig(machineConfig);
        }
        const assortConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'eleprocessloss')) ? formData.filter(item => item.bGrd && item.sTbName === 'eleprocessloss')[0] : {}; /* 劲嘉 配套工序不要使用，换成 装版损设置 */
        let assortColumn = [];
        if (commonUtils.isNotEmptyObject(assortConfig)) {
          assortColumn = commonFunc.getHeaderConfig(assortConfig);
        }
        const outsideConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'eleprocessoutside')) ? formData.filter(item => item.bGrd && item.sTbName === 'eleprocessoutside')[0] : {};
        let outsideColumn = [];
        if (commonUtils.isNotEmptyObject(outsideConfig)) {
          outsideColumn = commonFunc.getHeaderConfig(outsideConfig);
        }
        const processstyleConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'eleprocessoutside')) ? formData.filter(item => item.bGrd && item.sTbName === 'eleprocessstyle')[0] : {};
        let processstyleColumn = [];
        if (commonUtils.isNotEmptyObject(processstyleConfig)) {
          processstyleColumn = commonFunc.getHeaderConfig(processstyleConfig);
        }
        console.log('22221', formData, processstyleConfig);
        const processApsRuleConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'eleprocesssApsRule')) ? formData.filter(item => item.bGrd && item.sTbName === 'eleprocesssApsRule')[0] : {}; /* APS定义规则 */
        let processApsRuleColumn = [];
        if (commonUtils.isNotEmptyObject(processApsRuleConfig)) {
          processApsRuleColumn = commonFunc.getHeaderConfig(processApsRuleConfig);
        }
        const dynamicParamConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'eleprocessdynamic')) ? formData.filter(item => item.bGrd && item.sTbName === 'eleprocessdynamic')[0] : {}; /* 动态参数 */
        const dynamicParamColumn = commonUtils.isNotEmptyObject(dynamicParamConfig) ? commonFunc.getHeaderConfig(dynamicParamConfig) : [];

        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.machineConfig = machineConfig;
          config.assortConfig = assortConfig;
          config.outsideConfig = outsideConfig;
          config.processstyleConfig = processstyleConfig;
          config.processApsRuleConfig = processApsRuleConfig;
          config.dynamicParamConfig = dynamicParamConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetProcessData(masterConfig, machineConfig, assortConfig, outsideConfig, processstyleConfig, processApsRuleConfig, dynamicParamConfig);
        }
        this.props.onSaveState({
          masterConfig,
          machineConfig,
          machineColumn,
          assortConfig,
          assortColumn,
          outsideConfig,
          outsideColumn,
          processstyleConfig,
          processstyleColumn,
          processApsRuleConfig,
          processApsRuleColumn,
          dynamicParamConfig,
          dynamicParamColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (commonUtils.isEmptyObject(picFileOldConfig) && formData.length > 0 && sModelsType === 'element/printInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        const picFileConfig = formData.filter(item => item.bGrd && item.sTbName === 'eleproductfile')[0];
        const picFileColumn = commonFunc.getHeaderConfig(picFileConfig);
        const stockConfig = formData.filter(item => item.bGrd && item.sTbName === 'eleproductstock')[0];
        const stockColumn = commonFunc.getHeaderConfig(stockConfig);
        const customerInfoConfig = formData.filter(item => item.bGrd && item.sTbName === 'eleproductcustomer')[0];
        const customerInfoColumn = commonFunc.getHeaderConfig(customerInfoConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.picFileConfig = picFileConfig;
          config.stockConfig = stockConfig;
          config.customerInfoConfig = customerInfoConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetPrintData(masterConfig, picFileConfig, stockConfig, customerInfoConfig);
        }
        this.props.onSaveState({
          masterConfig,
          picFileConfig,
          picFileColumn,
          stockConfig,
          stockColumn,
          customerInfoConfig,
          customerInfoColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      // 常用规格信息  commonUtils.isEmptyArr(siscommonstyleproductclassifyColumn)
      if (commonUtils.isEmptyObject(siscommonstyleproductclassifyConfig) && formData.length > 0 && sModelsType === 'element/siscommonstyle') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        siscommonstyleproductclassifyConfig = formData.filter(item => item.bGrd && item.sTbName === 'siscommonstyleproductclassify')[0];
        const siscommonstyleproductclassifyColumn = commonFunc.getHeaderConfig(siscommonstyleproductclassifyConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.siscommonstyleproductclassifyConfig = siscommonstyleproductclassifyConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetStyleData(masterConfig, siscommonstyleproductclassifyConfig);
        }
        this.props.onSaveState({
          masterConfig,
          siscommonstyleproductclassifyConfig,
          siscommonstyleproductclassifyColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      // 班组信息
      if (commonUtils.isEmptyObject(eleemployeeOldConfig) && formData.length > 0 && sModelsType === 'element/teamInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'eleteam')[0];
        const eleemployeeConfig = formData.filter(item => item.bGrd && item.sTbName === 'eleteamemployee')[0];
        const eleemployeeColumn = commonFunc.getHeaderConfig(eleemployeeConfig);

        const elemachineConfig = formData.filter(item => item.bGrd && item.sTbName === 'eleteammachine')[0];
        const elemachineColumn = commonFunc.getHeaderConfig(elemachineConfig);

        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.eleemployeeConfig = eleemployeeConfig;
          config.elemachineConfig = elemachineConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetTeamData(masterConfig, eleemployeeConfig, elemachineConfig);
        }
        this.props.onSaveState({
          masterConfig,
          eleemployeeConfig,
          eleemployeeColumn,
          elemachineConfig,
          elemachineColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (commonUtils.isEmptyObject(jurgroupOldConfig) && formData.length > 0 && sModelsType === 'element/sftloginInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        const jurgroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfojurisdictiongroup')[0];
        const jurgroupColumn = commonFunc.getHeaderConfig(jurgroupConfig);
        const customergroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfocustomergroup')[0];
        const customergroupColumn = commonFunc.getHeaderConfig(customergroupConfig);
        const supplygroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfosupplygroup')[0];
        const supplygroupColumn = commonFunc.getHeaderConfig(supplygroupConfig);
        const persongroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfopersongroup')[0];
        const persongroupColumn = commonFunc.getHeaderConfig(persongroupConfig);
        const processgroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfoprocessgroup')[0];
        const processgroupColumn = commonFunc.getHeaderConfig(processgroupConfig);
        const drivergroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfodrivergroup')[0];
        const drivergroupColumn = commonFunc.getHeaderConfig(drivergroupConfig); /* 司机查看权限 */

        const departgroupConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfodepartgroup')) ?
          formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfodepartgroup')[0] : {};
        let departgroupColumn = [];
        if (commonUtils.isNotEmptyObject(departgroupConfig)) {
          departgroupColumn = commonFunc.getHeaderConfig(departgroupConfig); /* 供应商查看权限 */
        }

        const approveGroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfojurisApprovalgroup')[0];
        const approveGroupColumn = commonFunc.getHeaderConfig(approveGroupConfig); /* 审批组权限 */

        const brandgroupConfig = formData.filter(item => item.bGrd && item.sTbName === 'sftlogininfobrandgroup')[0];
        const brandgroupColumn = commonFunc.getHeaderConfig(brandgroupConfig); /* 分管公司 */

        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.jurgroupConfig = jurgroupConfig;
          config.customergroupConfig = customergroupConfig;
          config.supplygroupConfig = supplygroupConfig;
          config.persongroupConfig = persongroupConfig;
          config.processgroupConfig = processgroupConfig;
          config.drivergroupConfig = drivergroupConfig;
          config.departgroupConfig = departgroupConfig;
          config.approveGroupConfig = approveGroupConfig;
          config.brandgroupConfig = brandgroupConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          const flag = undefined;
          const isWait = true;
          const params = await this.handleGetSflLoginData(masterConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig, departgroupConfig, flag, isWait, undefined, { approveGroupConfig, brandgroupConfig });
          this.handleGetUserInfoData(params);
        }
        this.props.onSaveState({
          masterConfig,
          jurgroupConfig,
          jurgroupColumn,
          customergroupConfig,
          customergroupColumn,
          supplygroupConfig,
          supplygroupColumn,
          persongroupConfig,
          persongroupColumn,
          processgroupConfig,
          processgroupColumn,
          drivergroupConfig,
          drivergroupColumn,
          departgroupConfig,
          departgroupColumn,
          approveGroupConfig,
          approveGroupColumn,
          brandgroupConfig,
          brandgroupColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if ((bReceived === undefined || !bReceived) && formData.length > 0 && sModelsType === 'system/sisformulaInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'sisformula')[0];
        const paramConfig = formData.filter(item => item.bGrd && item.sTbName === 'sisformulaparam')[0];
        let customizeParamConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizeparam')) ? formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizeparam')[0] : {};
        /* 获取主表自定义列名为自定义变量配置 */
        const customizeParamConfigNew = this.handleGetCustomizeParamConfig({}, customizeParamConfig);
        if (commonUtils.isNotEmptyArr(customizeParamConfigNew.gdsconfigformslave)) {
          customizeParamConfig = customizeParamConfigNew;
        }

        /* 自定义参数 */
        let selfParamConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizevariable')) ?
          formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizevariable')[0] : {};
        let selfParamColumn = [];
        if(commonUtils.isNotEmptyArr(selfParamConfig)) {
          selfParamColumn = commonFunc.getHeaderConfig(selfParamConfig);
        }
        console.log('systemParamColumn', selfParamConfig, selfParamColumn);


        this.handleGetSlaveData('Set', 'param', paramConfig);
        this.handleGetSlaveData('Set', 'selfParam', selfParamConfig);
        let addState = {};
        let addStateMaster = {};

        const systemFunctionData = [];
        systemFunctionData.push({ value: 'Max(round(变量,0))', sName: commonFunc.showMessage(app.commonConst, 'sysMaxInteger') });
        systemFunctionData.push({ value: 'round(变量，小数位数)', sName: commonFunc.showMessage(app.commonConst, 'sysRounding') });
        systemFunctionData.push({ value: 'Min(round(变量,0))', sName: commonFunc.showMessage(app.commonConst, 'sysMinInteger') });

        const bussinessFunctionData = [];
        bussinessFunctionData.push({ value: '应收账款([客户名称])', sName: commonFunc.showMessage(app.commonConst, 'sysReceivable') });

        const customizeParamName = [];
        const userParamName = [];
        const addState1 = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.paramConfig = paramConfig;
          config.customizeParamConfig = customizeParamConfig;
          config.selfParamConfig = selfParamConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          addStateMaster = await this.handleGetSlaveData('One', undefined, masterConfig);
          /* 通过sId找到列表跳转行数据 */
          let masterDataNew =  {}
          if(commonUtils.isNotEmptyObject(addStateMaster) && commonUtils.isNotEmptyObject(addStateMaster.masterData) &&
            commonUtils.isNotEmptyObject(addStateMaster.masterData.sColTitleName)) {
            masterDataNew = addStateMaster.masterData;
          }

          let currentRecords = [];
          if (commonUtils.isNotEmptyArr(nextProps.app.currentPane.currentRecord)) {
            if (Array.isArray(nextProps.app.currentPane.currentRecord)) {
              currentRecords = nextProps.app.currentPane.currentRecord;
            } else {
              currentRecords = [nextProps.app.currentPane.currentRecord];
            }
          } else {
            currentRecords = [];
          }
          let currentRecordArr = commonUtils.isNotEmptyArr(currentRecords) ? currentRecords.filter(item => item.sId === sId) : [];

          if(commonUtils.isEmptyArr(currentRecordArr)  && commonUtils.isNotEmptyObject(masterDataNew)) {
            currentRecordArr = [masterDataNew];
          }
          if (commonUtils.isNotEmptyArr(currentRecordArr) && currentRecordArr[0].sColTitleName) {
            const currentRecord = currentRecordArr[0]; /* 找到列表选中行 */
            /* 取自定义列名 */
            const { sColTitleName } = currentRecord;
            if (commonUtils.isJSON(sColTitleName) && Array.isArray(JSON.parse(sColTitleName))) { // Array格式
              JSON.parse(sColTitleName).forEach((config, index) => {
                const paramIndex = index === 0 ? '' : index;
                const customizePanelName = config.panelName ? config.panelName : `变量设置${paramIndex}`;
                addState1[`customizePanelName${paramIndex}`] = customizePanelName;
                let customizeParamConfigNew = this.handleGetCustomizeParamConfig(currentRecord, config, index);
                customizeParamConfigNew = { ...customizeParamConfig, ...customizeParamConfigNew };
                if (commonUtils.isNotEmptyArr(customizeParamConfigNew.gdsconfigformslave)) {
                  customizeParamName.push(`customizeParam${paramIndex}`);
                  userParamName.push(`userParam${paramIndex}`);
                  addState1[`customizeParam${paramIndex}Config`] = customizeParamConfigNew;
                }
              });
              addState1.customizeParamName = customizeParamName;
              addState1.userParamName = userParamName;
            } else {
              const customizeParamConfigNew = this.handleGetCustomizeParamConfig(currentRecord, customizeParamConfig);
              if (commonUtils.isNotEmptyStr(customizeParamConfig.panelName)) {
                addState1.customizePanelName = customizeParamConfig.panelName;
              }
              if (commonUtils.isNotEmptyArr(customizeParamConfigNew.gdsconfigformslave)) {
                customizeParamConfig = customizeParamConfigNew;
              }
            }
          }
          if (commonUtils.isNotEmptyObject(customizeParamConfig)) {
            this.handleGetSlaveData('customizeParam', 'customizeParam', customizeParamConfig);
          }
          if (commonUtils.isNotEmptyObject(selfParamConfig)) {
            this.handleGetSlaveData('Set', 'selfParam', selfParamConfig);
          }
        }

        let customizeParamColumn = [];
        let userParamConfig = {};
        let userParamColumn = [];
        if (commonUtils.isNotEmptyArr(customizeParamName)) {
          customizeParamName.forEach((paramName, index) => {
            const config = addState1[`${paramName}Config`];
            if (commonUtils.isNotEmptyObject(config)) {
              addState1[`${paramName}Column`] = commonFunc.getHeaderConfig(config);

              const userParamConfig = JSON.parse(JSON.stringify(config));
              addState1[`${userParamName[index]}Config`] = userParamConfig;
              if (commonUtils.isNotEmptyArr(userParamConfig.gdsconfigformslave)) {
                userParamConfig.gdsconfigformslave.forEach((item) => {
                  // if (item.sName.indexOf('sValue') === -1) { /* 除了参数值 其他均不可修改 */
                  //   item.iTag = 1;
                  // }
                  if (item.sName === 'sParam') {
                    item.bVisible = false;
                  }
                });
              }
              addState1[`${userParamName[index]}Column`] = commonFunc.getHeaderConfig(userParamConfig);
            }
          });
        } else {
          if (commonUtils.isNotEmptyObject(customizeParamConfig)) {
            customizeParamColumn = commonFunc.getHeaderConfig(customizeParamConfig);
          }
          /* 用户模式 只有参数值可以修改 其他均不可修改 参数名不可见 */
          userParamColumn = customizeParamColumn;
          if (commonUtils.isNotEmptyObject(customizeParamConfig)) {
            userParamConfig = JSON.parse(JSON.stringify(customizeParamConfig));
            if (commonUtils.isNotEmptyArr(userParamConfig.gdsconfigformslave)) {
              userParamConfig.gdsconfigformslave.forEach((item) => {
                // if (item.sName.indexOf('sValue') === -1) { /* 除了参数值 其他均不可修改 */
                //   item.iTag = 1;
                // }
                if (item.sName === 'sParam') {
                  item.bVisible = false;
                }
              });
            }
            userParamColumn = commonFunc.getHeaderConfig(userParamConfig);
          }
        }


        bReceived = true;
        this.props.onSaveState({
          masterConfig,
          paramConfig,
          customizeParamConfig,
          customizeParamColumn,
          userParamConfig,
          userParamColumn,
          sId,
          systemFunctionData,
          bussinessFunctionData,
          bReceived,
          selfParamConfig,
          selfParamColumn,
          pageLoading: false,
          ...addState,
          ...addState1,
        });
      }
      if ((bReceived === undefined || !bReceived) && formData.length > 0 && sModelsType === 'element/machineInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'elemachine')[0];
        let addState = {};
        let slaveConfig = {};
        let slaveColumn = [];
        let iPlcNoConfig = {};
        let slave0Config = {};
        let slave0Column = [];
        const addState2 = {};
        const memoDataList = [];
        const slaveInfoList = [];
        const filterSlaveData = formData.filter(item => item.sTbName !== 'sysbillcheckresult' && item.bGrd && item.bGrdVisible);
        if (commonUtils.isNotEmptyArr(filterSlaveData)) {
          filterSlaveData.forEach((config, index) => {
            if (index > 1) {
              const slaveName = `slave${index === 0 ? '' : index - 1}`;
              if (index !== 0) {
                addState2[`${slaveName}Config`] = config;
                addState2[`${slaveName}Column`] = commonFunc.getHeaderConfig(config);
                memoDataList.push({
                  name: slaveName,
                  config,
                });
                slaveInfoList.push(slaveName);
              }
            }
          });
        }
        addState.slaveInfoList = slaveInfoList;
        addState.memoDataList = memoDataList;
        addState = { ...addState, ...addState2 };

        iPlcNoConfig = commonUtils.isNotEmptyObject(masterConfig.gdsconfigformslave) ? masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName === 'iPlcNo')[0] : {};
        if (commonUtils.isNotEmptyObject(iPlcNoConfig)) {
          slaveConfig = formData.filter(item => item.bGrd && item.sTbName === 'plc_currentmachinevalue')[0];
          slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
        }
        const slave0FilterData = formData.filter(item => item.bGrd && item.sTbName === 'eleprocessmachinesinstallarea');
        if (commonUtils.isNotEmptyArr(slave0FilterData)) {
          slave0Config = slave0FilterData[0];
          slave0Column = commonFunc.getHeaderConfig(slave0Config);
        }
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          // this.handleGetSlaveData('One', null, masterConfig);
          const addStateConfig = {
            slave0: slave0Config,
          };
          if (commonUtils.isNotEmptyArr(memoDataList)) {
            memoDataList.forEach((item) => {
              addStateConfig[item.name] = item.config;
            });
          }
          this.handleGetSlaveData('One', null, masterConfig, slaveConfig, iPlcNoConfig, false, addStateConfig);
        }
        bReceived = true;
        this.props.onSaveState({
          bReceived,
          expand: true,
          masterConfig,
          slaveConfig,
          slaveColumn,
          slave0Config,
          slave0Column,
          iPlcNoConfig,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (commonUtils.isEmptyObject(userOldConfig) && formData.length > 0 && sModelsType === 'element/checkModelInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'elecheckmodel')[0];
        /* bGrd代表是否是表格 */
        const userConfig = formData.filter(item => item.bGrd && item.sTbName === 'elecheckmodeluser')[0];
        const userColumn = commonFunc.getHeaderConfig(userConfig);
        const phaseConfig = formData.filter(item => item.bGrd && item.sTbName === 'elecheckmodelphase')[0];
        const phaseColumn = commonFunc.getHeaderConfig(phaseConfig);
        const conditionConfig = formData.filter(item => item.bGrd && item.sTbName === 'elecheckmodelcondition')[0];
        const conditionColumn = commonFunc.getHeaderConfig(conditionConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.userConfig = userConfig;
          config.phaseConfig = phaseConfig;
          config.conditionConfig = conditionConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetCheckModelData(masterConfig, userConfig, phaseConfig, conditionConfig);
        }
        this.props.onSaveState({
          masterConfig,
          userConfig,
          userColumn,
          phaseConfig,
          phaseColumn,
          conditionConfig,
          conditionColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (commonUtils.isEmptyObject(sischeckphaselogininfoOldConfig) && formData.length > 0 && sModelsType === 'element/checkPhaseInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'sischeckphase')[0];
        /* bGrd代表是否是表格 */
        const sischeckphaselogininfoConfig = formData.filter(item => item.bGrd && item.sTbName === 'sischeckphaselogininfo')[0];
        const sischeckphaselogininfoColumn = commonFunc.getHeaderConfig(sischeckphaselogininfoConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.sischeckphaselogininfoConfig = sischeckphaselogininfoConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetCheckPhaseData(masterConfig, sischeckphaselogininfoConfig);
        }
        this.props.onSaveState({
          masterConfig,
          sischeckphaselogininfoConfig,
          sischeckphaselogininfoColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if ((bReceived === undefined || !bReceived) && formData.length > 0 && sModelsType === 'sis/paymentTerms') {
        const sId = currentId || nextProps.masterData?.sId || '';
        const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'sispayment')[0];

        const firstRow = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName === 'sName');
        const secondRow = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName === 'sType');
        masterConfig.rowGdsconfig = [{ gdsconfigformslave: firstRow }, { gdsconfigformslave: secondRow }];

        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetSlaveData('One', null, masterConfig);
        }
        bReceived = true;
        this.props.onSaveState({
          bReceived,
          expand: true,
          masterConfig,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (commonUtils.isEmptyObject(employeeConfig) && formData.length > 0 && sModelsType === 'element/employeeInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        employeeConfig = masterConfig;
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetEleemployeeData(masterConfig);
        }
        this.props.onSaveState({
          masterConfig,
          employeeConfig,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (formData.length > 0 && commonUtils.isEmptyObject(sysmsguserOldConfig) && sModelsType === 'smg/sendMailMsg') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];

        const sysmsguserConfig = formData.filter(item => item.bGrd && item.sTbName === 'sysmsguser')[0];
        const sysmsguserColumn = commonFunc.getHeaderConfig(sysmsguserConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.sysmsguserConfig = sysmsguserConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetSysMsgData(masterConfig, sysmsguserConfig);
          // this.handleGetSlaveData('One', null, masterConfig);
        }

        this.props.onSaveState({
          masterConfig,
          sysmsguserConfig,
          sysmsguserColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      if (formData.length > 0 && commonUtils.isEmptyObject(masterConfig) && sModelsType === 'sis/monthEndingClosing') {
        const sId = currentId || nextProps.masterData?.sId || '';
        masterConfig = formData.filter(item => !item.bGrd)[0];

        const firstRow = masterConfig.gdsconfigformslave[0];
        const secondRow = masterConfig.gdsconfigformslave[1];
        masterConfig.rowGdsconfig = [
          { gdsconfigformslave: [{ ...firstRow }] },
          { gdsconfigformslave: [{ ...secondRow }] },
        ];

        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        }
        this.props.onSaveState({
          masterConfig, sId, pageLoading: false, ...addState,
        });
      }
      /* 刀模信息 */
      if (commonUtils.isEmptyObject(eleknifemouldOldproductConfig) && formData.length > 0 && sModelsType === 'element/knifemouldInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        const eleknifemouldproductConfig = formData.length > 0 ? formData.filter(item => item.bGrd)[0] : {};
        let eleknifemouldproductColumn = [];
        if (commonUtils.isNotEmptyObject(eleknifemouldproductConfig)) {
          eleknifemouldproductColumn = commonFunc.getHeaderConfig(eleknifemouldproductConfig);
        }
        const eleknifemouldfileConfig = formData.length > 1 ? formData.filter(item => item.bGrd)[1] : {};
        let eleknifemouldfileColumn = [];
        if (commonUtils.isNotEmptyObject(eleknifemouldfileConfig)) {
          eleknifemouldfileColumn = commonFunc.getHeaderConfig(eleknifemouldfileConfig);
        }
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.eleknifemouldproductConfig = eleknifemouldproductConfig;
          config.elekinfemouldfileConfig = eleknifemouldfileConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetEleKnifeMouldData(masterConfig, eleknifemouldproductConfig, eleknifemouldfileConfig);
        }
        this.props.onSaveState({
          masterConfig,
          eleknifemouldproductConfig,
          eleknifemouldproductColumn,
          eleknifemouldfileConfig,
          eleknifemouldfileColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
      /* 检验标准 */
      if (commonUtils.isEmptyObject(eleteststandardOlditemConfig) && formData.length > 0 && sModelsType === 'element/eleteststandInfo') {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        /* bGrd代表是否是表格 */
        const eleteststandarditemConfig = formData.filter(item => item.bGrd && item.sTbName === 'EleTestStandardItem')[0];
        const eleteststandarditemColumn = commonFunc.getHeaderConfig(eleteststandarditemConfig);
        let addState = {};
        if (sId === '') {
          const config = {};
          config.masterConfig = masterConfig;
          config.eleteststandarditemConfig = eleteststandarditemConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        } else {
          this.handleGetTestStandData(masterConfig, eleteststandarditemConfig);
        }
        this.props.onSaveState({
          masterConfig,
          eleteststandarditemConfig,
          eleteststandarditemColumn,
          sId,
          pageLoading: false,
          ...addState,
        });
      }
    }

    shouldComponentUpdate(nextProps, nextState) {
      const { masterConfig } = nextProps;
      let flag = true;
      /* 追加弹出框数值回填放行判断ppopupPane */
      if (nextProps.sTabId === nextProps.app.currentPane.key || ((nextProps.app.ppopupPane !== undefined
        && nextProps.app.ppopupPane.mainConfig !== undefined)
        ? nextProps.sTabId === nextProps.app.ppopupPane.mainConfig.key : false)) {
        if (nextState.disabled !== this.state.disabled) {
          return true;
        }
        flag = true;
        if (commonUtils.isNotEmptyObject(masterConfig)) {
          flag = true;
        } else {
          flag = false;
        }
      } else {
        flag = false;
      }
      return flag;
    }

    componentWillUpdate(nextProps) {
      const {
        masterData, sModelsType, elemachineData, contactData, addressData, masterConfig, sysmsguserData,
      } = nextProps;
      const sendSocketMessage = this.props.handleSendSocketMessage;
      if (sModelsType === 'element/teamInfo' && masterData !== undefined) {
        if (commonUtils.isNotEmptyObject(elemachineData)) {
          elemachineData.forEach((row, index) => {
            const addState = {};
            if (row.sMachineId === masterData.sMachineId) {
              addState.bDefault = true;
            } else {
              addState.bDefault = false;
            }
            elemachineData[index] = { ...elemachineData[index], ...addState };
          });
        }
      } else if (sModelsType === 'element/eleteststandInfo' && masterData !== undefined) { /* 检验类型为工序检验时，工序名称出现 */
        const { sTestType } = masterData;
        const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
        if (iIndex > -1) {
          if (sTestType !== '2') {
            masterConfig.gdsconfigformslave[iIndex].bVisible = false;
          } else {
            masterConfig.gdsconfigformslave[iIndex].bVisible = true;
          }
        }
      } else if ((sModelsType === 'element/customerInfo' || sModelsType === 'element/supplyInfo') && masterData !== undefined) {
        if (commonUtils.isNotEmptyObject(contactData)) {
          contactData.forEach((row, index) => {
            const addState = {};
            if (row.sContacts === masterData.sContacts) {
              addState.bDefault = true;
            } else {
              addState.bDefault = false;
            }
            contactData[index] = { ...contactData[index], ...addState };
          });
        }
        if (commonUtils.isNotEmptyObject(addressData)) {
          addressData.forEach((row, index) => {
            const addState = {};
            if (row.csProvince_sCity_sArea === masterData.csProvince_sCity_sArea && (row.sDetailAddress === masterData.sCompanyAddress || (row.sDetailAddress === undefined && masterData.sCompanyAddress === ''))) {
              addState.bDefault = true;
            } else {
              addState.bDefault = false;
            }
            addressData[index] = { ...addressData[index], ...addState };
          });
        }
      } else if (sModelsType === 'system/sisformulaInfo' && commonUtils.isNotEmptyObject(masterData)) {
        masterData.sFormulaMemo = masterData.sFormula;
        const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sColTitleName');
        const iIndexBtn = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnConfigCustomizeParam');
        masterData.bUserModel = nextProps.bUserModel;
        if (masterData.bUserModel === undefined || !masterData.bUserModel) { /* 用户模式 */
          if (iIndex > -1) { /* 用户模式：不显示自定义类名 */
            masterConfig.gdsconfigformslave[iIndex].bVisible = false;
          }
          if (iIndexBtn > -1) { /* 用户模式：不显示生成列配置按钮 */
            masterConfig.gdsconfigformslave[iIndexBtn].bVisible = false;
          }
        } else if (masterData.bUserModel) { /* 开发者模式 */
          if (iIndex > -1) { /* 显示自定义类名 */
            masterConfig.gdsconfigformslave[iIndex].bVisible = true;
          }
          if (iIndexBtn > -1) { /* 显示生成列配置按钮 */
            masterConfig.gdsconfigformslave[iIndexBtn].bVisible = true;
          }
        }
      } else if (sModelsType === 'sis/paymentTerms' && commonUtils.isNotEmptyObject(masterData)) {
        const { rowGdsconfig } = masterConfig;
        if (commonUtils.isNotEmptyArr(rowGdsconfig) && rowGdsconfig.length === 2) {
          if (masterData.sType === 'deliver') {
            const rows = {};
            const threeRows = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName === 'iAfterDeliverDay');
            rows.gdsconfigformslave = threeRows;
            rowGdsconfig.push(rows);
            this.props.onSaveState({ masterConfig });
          } else if (masterData.sType === 'month') {
            const rows = {};
            const threeRows = masterConfig.gdsconfigformslave.filter(item => item.bVisible && (item.sName === 'iMonth' || item.sName === 'iDay'));
            rows.gdsconfigformslave = threeRows;
            rowGdsconfig.push(rows);
            this.props.onSaveState({ masterConfig });
          }
        }
      } else if (sModelsType === 'smg/sendMailMsg' && commonUtils.isNotEmptyArr(sysmsguserData) && commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmptyObject(masterData.sUserIds)) {
        const { app } = this.props;
        const { userinfo } = app;
        const userId = [];
        sysmsguserData.forEach((tableDataRow) => {
          userId.push(tableDataRow.sUserId);
        });
        masterData.sUserIds = userId;
        sendSocketMessage('msgRead', 'noAction', masterData.sId, userinfo.sId, null, null);
        if (this.props.app.currentPane.refresh !== undefined) {
          this.props.app.currentPane.refresh();
        }
      } else if (sModelsType === 'element/materialsInfo' && commonUtils.isNotEmptyObject(masterData)) {
        const { sMaterialsType } = masterData;
        const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'dGramWeight');
        if (sMaterialsType === 'paper') { /* 物料类别为纸张的时候,克重必填 */
          masterConfig.gdsconfigformslave[iIndex].bNotEmpty = true;
        } else {
          masterConfig.gdsconfigformslave[iIndex].bNotEmpty = false;
        }
      }
      // else if (sModelsType === 'element/sisproductclassify' && commonUtils.isNotEmptyObject(masterData)) {
      //   const { sAllPartsName } = masterData;
      //   this.handleChangeProductParteName(sAllPartsName);
      // }
    }
    handleGetTableConfig = async (name, sModelsId) => {
      if (commonUtils.isNotEmptyObject(sModelsId)) {
        const newConfig = await this.props.onGetTableConfig(name, sModelsId);
        if (commonUtils.isNotEmptyObject(newConfig)) {
          this.props.onSaveState({ [`${[name]}Config`]: newConfig });
        }
      }
    }
    handleViewClick = (name, sName, record, index, myConfig) => {
      if (sName === 'myTableConfig') {
        this.handleQuickViewClick(name, sName, record, index, myConfig);
      } else {
        this.props.onViewClick(name, sName, record, index, myConfig);
      }
    }
    handleQuickViewClick = async (name, sName, record, index, myConfigArr) => {
      const {
        slaveData,
        // dispatch,
        slaveFilterCondition,
        slavePagination,
        // slaveOrderBy,
        // sModelsType,
        formRoute,
        // treeFilterCondition,
        // app,
        // iPageSize,
        sModelsId,
        // slaveSelectedData,
        // masterData,
        // employeeConfig,
      } = this.props;

      let picArr = [];
      if (commonUtils.isNotEmptyArr(myConfigArr)) {
        picArr = myConfigArr;
      }

      if (picArr.length > 0) {
        const getConfig = this.handleGetTableConfig;
        const tableDataRow = record;
        const iIndex = index;
        const [{ sActiveId }] = picArr;
        let [{ sActiveKey }] = picArr;
        const sFormId = sActiveId === '1' ? commonUtils.isEmpty(tableDataRow.sFormId) ? tableDataRow.sSrcFormId : tableDataRow.sFormId : sActiveId;
        if (commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes('.')) { /* 接口按钮跳转 如果有slave.对应字段 则需要取出对应字段 */
          const index = sActiveKey.lastIndexOf('.');
          sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length);
        }
        const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sFormId}?sModelsId=${sFormId}&sName=${formRoute}`;
        const filterCondition = [];
        const conditionValues = this.props.getSqlCondition(picArr[0], name, tableDataRow);
        if (!commonUtils.isEmpty(conditionValues)) {
          Object.keys(conditionValues).forEach((item) => {
            if ((item === 'tStartDate_pro' || item.substring(0, 1) === 'p')) {
              if (!commonUtils.isEmpty(conditionValues[item]) && conditionValues[item].length >= 2) {
                const tStartDate = moment(conditionValues[item][0]).format(this.sDateFormat);
                const tEndDate = moment(conditionValues[item][1]).add(1, 'days').format(this.sDateFormat);
                filterCondition.push({
                  bFilterName: item,
                  bFilterCondition: '=',
                  bFilterValue: `${tStartDate},${tEndDate}`,
                });
              }
            } else if ((item === 'mStartDate_pro' || item.substring(0, 1) === 'm')) {
              if (!commonUtils.isEmpty(conditionValues[item])) {
                const tStartDate = moment(conditionValues[item]).startOf('month').format(this.sDateFormat);
                const tEndDate = moment(conditionValues[item]).endOf('month').add(1, 'days').format(this.sDateFormat);
                filterCondition.push({
                  bFilterName: `t${item.substring(1, item.length)}`,
                  bFilterCondition: '=',
                  bFilterValue: `${tStartDate},${tEndDate}`,
                });
              }
            } else if (item.substring(0, 1) === 't') {
              filterCondition.push({
                bFilterName: item,
                bFilterCondition: '=',
                bFilterValue: moment(conditionValues[item]).format(this.sDateFormat),
              });
            } else {
              filterCondition.push({
                bFilterName: item,
                bFilterCondition: '=',
                bFilterValue: conditionValues[item],
              });
            }
          });
        }
        this.props.dispatch({
          type: 'content/onRouter',
          payload: {
            url: sNameUrl,
            refresh: getConfig.bind(this, name, sModelsId), /*   刷新方法   */
            sTabId: commonUtils.createSid(),
            sParentId: this.state.sTabId,
            urlDataType: 'newPane',
            checkedId: myConfigArr[0].sId,
            sName: myConfigArr[0].sName,
            bFilter: slaveFilterCondition,
            pageSize: commonConfig.pageSize,
            pages: slavePagination,
            currentData: slaveData,
            conditonValues: conditionValues,
            newKey: tableDataRow[sActiveKey],
            currentIndex: iIndex,
            filterCondition,
          },
        });
      }
    };
    /**   获取主表、联系人、地址表数据   */
    handleGetData = (masterConfig, contactConfig, addressConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'contact', configData: contactConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'address', configData: addressConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    handleGetSflLoginDataAll = async (masterConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig, departgroupConfig, { approveGroupConfig, brandgroupConfig }) => {
      const flag = undefined;
      const isWait = true;
      const params = await this.handleGetSflLoginData(masterConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig, departgroupConfig, flag, isWait, undefined, { approveGroupConfig, brandgroupConfig });
      this.handleGetUserInfoData(params);
    };
    /**   获取印件分类主表、从表   */
    handleGetProductclassifyData = async (masterConfig, sisproductclassifyProcessClassifyConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      const addState = await this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, isWait: true, bEditClick,
      });
      const addStateSlave = await this.props.handleGetDataSet({
        name: 'sisproductclassifyProcessClassify', configData: sisproductclassifyProcessClassifyConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
      });
      const { sAllPartsName } = addState.masterData;
      if (commonUtils.isNotEmptyObject(sAllPartsName)) {
        addState.sisproductclassifyProcessClassifyConfig = this.handleChangeProductParteName(sAllPartsName);
      } else {
        addState.sisproductclassifyProcessClassifyConfig = sisproductclassifyProcessClassifyConfig;
      }
      this.props.onSaveState({ ...addState, ...addStateSlave });
    };

    /**   获取主表、图片文件、仓库表数据   */
    handleGetPrintData = (masterConfig, picFileConfig, stockConfig, customerInfoConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'picFile', configData: picFileConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'stock', configData: stockConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'customerInfo', configData: customerInfoConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**   获取主表、制单日期、制单人数据   */
    handleGetStyleData = (masterConfig, siscommonstyleproductclassifyConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'siscommonstyleproductclassify', configData: siscommonstyleproductclassifyConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**   获取主表、创建者、审核阶段、审核条件数据   */
    handleGetCheckModelData = (masterConfig, userConfig, phaseConfig, conditionConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'user', configData: userConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'phase', configData: phaseConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'condition', configData: conditionConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**   获取员工数据   */
    handleGetEleemployeeData = (masterConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
    };
    /**   获取印件分类   */
    handleGetSisproductclassifyData = (masterConfig, sisproductclassifyProcessClassifyConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'sisproductclassifyProcessClassify', configData: sisproductclassifyProcessClassifyConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**   获取主表、审核人员数据   */
    handleGetCheckPhaseData = (masterConfig, sischeckphaselogininfoConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'sischeckphaselogininfo', configData: sischeckphaselogininfoConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };

    /**   获取主表、询价信息、仓库表数据   */
    handleGetMaterialsData = (masterConfig, supplyConfig, stockConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'supply', configData: supplyConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'stock', configData: stockConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };

    /**   获取用户信息数据   */
    handleGetSflLoginData = async (masterConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig, departgroupConfig, flag, isWait, bEditClick, { approveGroupConfig, brandgroupConfig }) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      const masterAddState = await this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick, isWait,
      });
      const jurgroupAddState = await this.props.handleGetDataSet({
        name: 'jurgroup', configData: jurgroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });
      const customergroupAddState = await this.props.handleGetDataSet({
        name: 'customergroup', configData: customergroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });
      const supplygroupAddState = await this.props.handleGetDataSet({
        name: 'supplygroup', configData: supplygroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });
      const persongroupAddState = await this.props.handleGetDataSet({
        name: 'persongroup', configData: persongroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });
      const processgroupAddState = await this.props.handleGetDataSet({
        name: 'processgroup', configData: processgroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });
      const drivergroupAddState = await this.props.handleGetDataSet({
        name: 'drivergroup', configData: drivergroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });
      let departgroupAddState = {};
      if (commonUtils.isNotEmptyObject(departgroupConfig)) {
        departgroupAddState = await this.props.handleGetDataSet({
          name: 'departgroup', configData: departgroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
        });
      }

      const approveGroupAddState = await this.props.handleGetDataSet({
        name: 'approveGroup', configData: approveGroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });

      const brandgroupAddState = await this.props.handleGetDataSet({
        name: 'brandgroup', configData: brandgroupConfig, condition: { sSqlCondition: { sParentId: sId } }, flag, isWait,
      });

      return {
        masterAddState, jurgroupAddState, customergroupAddState, supplygroupAddState, persongroupAddState, processgroupAddState, drivergroupAddState, departgroupAddState, approveGroupAddState, brandgroupAddState,
      };
    };

    /**   获取用户信息初始数据   */
    handleGetUserInfoData = async (params) => {
      const {
        sModelsId, token, app,
      } = this.props;
      const dataUrl = `${commonConfig.server_host}userinfo/getUserInfoData/?sModelsId=${sModelsId}`;
      const dataReturn = (await commonServices.postValueService(token, { sParentId: app?.currentPane?.currentRecord?.[0]?.sId }, dataUrl)).data;
      if (dataReturn.code === 1) {
        const returnData = dataReturn.dataset.rows[0];
        const {
          masterAddState = {}, jurgroupAddState, customergroupAddState, supplygroupAddState, persongroupAddState, processgroupAddState, drivergroupAddState, departgroupAddState, approveGroupAddState, brandgroupAddState,
        } = params;
        const { jurgroupData } = jurgroupAddState;
        const { customergroupData } = customergroupAddState;
        const { supplygroupData } = supplygroupAddState;
        const { persongroupData } = persongroupAddState;
        const { processgroupData } = processgroupAddState;
        const { drivergroupData } = drivergroupAddState;
        const { approveGroupData } = approveGroupAddState;
        const { brandgroupData } = brandgroupAddState;
        let departgroupData = [];
        if (commonUtils.isNotEmptyObject(departgroupAddState)) {
          departgroupData = departgroupAddState.departgroupData;
        }
        const jurgroupSelectedRowKeys = [];
        const customergroupSelectedRowKeys = [];
        const supplygroupSelectedRowKeys = [];
        const persongroupSelectedRowKeys = [];
        const processgroupSelectedRowKeys = [];
        const drivergroupSelectedRowKeys = [];
        const departgroupSelectedRowKeys = [];
        const approveGroupSelectedRowKeys = [];
        const brandgroupSelectedRowKeys = [];
        const jurgroupAllData = returnData.jurgroupData;
        const customergroupAllData = returnData.customergroupData;
        const supplygroupAllData = returnData.supplygroupData;
        const persongroupAllData = returnData.persongroupData;
        const processgroupAllData = returnData.processgroupData;
        const drivergroupAllData = returnData.drivergroupData;
        const departgroupAllData = returnData.departgroupData;
        const approveGroupAllData = returnData.sApprovalprocessData;
        const brandgroupAllData = returnData.sysbrandData.map(item => ({
          ...item,
          sCompanyName: item.sName,
          ...brandgroupData.find(x => x.sCompanyId === item.sCompanyId) || { sId: commonUtils.createSid(), handleType: 'add', sParentId: masterAddState.masterData.sId },
        }));

        if (commonUtils.isNotEmptyArr(jurgroupAllData)) {
          for (const itemAll of jurgroupAllData) {
            if (commonUtils.isNotEmptyArr(jurgroupData)) {
              for (const item of jurgroupData) {
                if (item.sJurisdictionClassifyId === itemAll.sJurisdictionClassifyId) {
                  jurgroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }
        if (commonUtils.isNotEmptyArr(customergroupAllData)) {
          for (const itemAll of customergroupAllData) {
            if (commonUtils.isNotEmptyArr(customergroupData)) {
              for (const item of customergroupData) {
                if (item.sSalesManId === itemAll.sSalesManId) {
                  customergroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }
        if (commonUtils.isNotEmptyArr(supplygroupAllData)) {
          for (const itemAll of supplygroupAllData) {
            if (commonUtils.isNotEmptyArr(supplygroupData)) {
              for (const item of supplygroupData) {
                if (item.sPurchaseManId === itemAll.sPurchaseManId) {
                  supplygroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }
        if (commonUtils.isNotEmptyArr(persongroupAllData)) {
          for (const itemAll of persongroupAllData) {
            if (commonUtils.isNotEmptyArr(persongroupData)) {
              for (const item of persongroupData) {
                if (item.sEmployeeId === itemAll.sEmployeeId) {
                  persongroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }
        if (commonUtils.isNotEmptyArr(processgroupAllData)) {
          for (const itemAll of processgroupAllData) {
            if (commonUtils.isNotEmptyArr(processgroupData)) {
              for (const item of processgroupData) {
                if (item.sProcessClassifyId === itemAll.sProcessClassifyId) {
                  processgroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }
        if (commonUtils.isNotEmptyArr(drivergroupAllData)) {
          for (const itemAll of drivergroupAllData) {
            if (commonUtils.isNotEmptyArr(drivergroupData)) {
              for (const item of drivergroupData) {
                if (item.sDriverId === itemAll.sDriverId) {
                  drivergroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }

        if (commonUtils.isNotEmptyArr(departgroupAllData)) {
          for (const itemAll of departgroupAllData) {
            if (commonUtils.isNotEmptyArr(departgroupAllData)) {
              for (const item of departgroupData) {
                if (item.sDepartId === itemAll.sDepartId) {
                  departgroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }

        if (commonUtils.isNotEmptyArr(approveGroupAllData)) {
          for (const itemAll of approveGroupAllData) {
            if (commonUtils.isNotEmptyArr(approveGroupData)) {
              for (const item of approveGroupData) {
                if (item.sJurisdictionClassifyId === itemAll.sJurisdictionClassifyId) {
                  approveGroupSelectedRowKeys.push(itemAll.sId);
                }
              }
            }
          }
        }

        if (commonUtils.isNotEmptyArr(brandgroupAllData)) {
          for (const itemAll of brandgroupAllData) {
            if (itemAll.iCheck) {
              brandgroupSelectedRowKeys.push(itemAll.sId);
            }
          }
        }

        this.props.onSaveState({
          ...masterAddState,
          jurgroupData: jurgroupAllData,
          jurgroupOldData: jurgroupData,
          customergroupData: customergroupAllData,
          customergroupOldData: customergroupData,
          supplygroupData: supplygroupAllData,
          supplygroupOldData: supplygroupData,
          persongroupData: persongroupAllData,
          persongroupOldData: persongroupData,
          processgroupData: processgroupAllData,
          processgroupOldData: processgroupData,
          drivergroupData: drivergroupAllData,
          drivergroupOldData: drivergroupData,
          departgroupData: departgroupAllData,
          departgroupOldData: departgroupData,
          approveGroupData: approveGroupAllData,
          approveGroupOldData: approveGroupData,
          brandgroupData: brandgroupAllData,
          brandgroupOldData: brandgroupAllData,
          jurgroupSelectedRowKeys,
          customergroupSelectedRowKeys,
          supplygroupSelectedRowKeys,
          persongroupSelectedRowKeys,
          processgroupSelectedRowKeys,
          drivergroupSelectedRowKeys,
          departgroupSelectedRowKeys,
          approveGroupSelectedRowKeys,
          brandgroupSelectedRowKeys,
        });
      }
    };

    /**   获取主表、对应机台、配套工序、发外公式、工序规格表数据   */
    handleGetProcessData = (masterConfig, machineConfig, assortConfig, outsideConfig, processstyleConfig, processApsRuleConfig, dynamicParamConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      if(commonUtils.isNotEmptyObject(machineConfig)) {
        this.props.handleGetDataSet({
          name: 'machine', configData: machineConfig, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
      if(commonUtils.isNotEmptyObject(assortConfig)) {
        this.props.handleGetDataSet({
          name: 'assort', configData: assortConfig, condition: {sSqlCondition: {sParentId: sId}},
        });
      }
      if(commonUtils.isNotEmptyObject(outsideConfig)) {
        this.props.handleGetDataSet({
          name: 'outside', configData: outsideConfig, condition: {sSqlCondition: {sParentId: sId}},
        });
      }
      if(commonUtils.isNotEmptyObject(processstyleConfig)) {
        this.props.handleGetDataSet({
          name: 'processstyle', configData: processstyleConfig, condition: {sSqlCondition: {sParentId: sId}},
        });
      }
      if(commonUtils.isNotEmptyObject(processApsRuleConfig)) {
        this.props.handleGetDataSet({
          name: 'processApsRule', configData: processApsRuleConfig, condition: {sSqlCondition: {sParentId: sId}},
        });
      }

      this.props.handleGetDataSet({
        name: 'dynamicParam', configData: dynamicParamConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**   获取班组主表、员工、机台表数据   */
    handleGetTeamData = (masterConfig, eleemployeeConfig, elemachineConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'eleemployee', configData: eleemployeeConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'elemachine', configData: elemachineConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**   获取刀模主表、从表  */
    handleGetEleKnifeMouldData = (masterConfig, knifemouldproductConfig, knifemouldfileConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'eleknifemouldproduct', configData: knifemouldproductConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
      this.props.handleGetDataSet({
        name: 'eleknifemouldfile', configData: knifemouldfileConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**   获取检验标准主表、从表  */
    handleGetTestStandData = (masterConfig, eleteststandarditemConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'eleteststandarditem', configData: eleteststandarditemConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };
    /**  消息发送数据   */
    handleGetSysMsgData = (masterConfig, sysmsguserConfig, bEditClick) => {
      const { currentId } = this.props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      this.props.handleGetDataOne({
        name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
      });
      this.props.handleGetDataSet({
        name: 'sysmsguser', configData: sysmsguserConfig, condition: { sSqlCondition: { sParentId: sId } },
      });
    };

    handleGetSisformulaData = (masterConfig) => {
      this.handleGetSlaveData('One', null, masterConfig);
    }

    handleGetSlaveData = async (getType, sName, currConfig, slaveConfig, iPlcNoConfig, bEditClick, addStateConfig) => {
      const { currentId, sModelsType } = this.props;
      /* 当前页签数据 */
      let addState = {};
      const sId = currentId || this.props.masterData?.sId || '';
      if (getType === 'One') {
        if(sModelsType === 'system/sisformulaInfo') {
          const addMaster = await  this.props.handleGetDataOne({
            name: 'master', configData: currConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick, isWait :true
          });
          this.props.onSaveState(addMaster);
          return addMaster;
        } else {
          this.props.handleGetDataOne({
            name: 'master', configData: currConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
          });
        }
        if (commonUtils.isNotEmptyObject(iPlcNoConfig) && commonUtils.isNotEmptyObject(slaveConfig)) {
          this.props.handleGetDataOne({
            name: 'master', configData: currConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick,
          });
          this.props.handleGetDataSet({
            name: 'slave', configData: slaveConfig, condition: { sSqlCondition: { sParentId: sId } },
          });
          if (commonUtils.isNotEmptyObject(addStateConfig)) {
            for (const name of Object.keys(addStateConfig)) {
              const returnData = await this.props.handleGetDataSet({
                name, configData: addStateConfig[name], condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
              });
              console.log('returnData', name, returnData);
              addState = { ...addState, ...returnData, [`${name}SelectedRowKeys`]: [] };
            }
          }
          this.props.onSaveState(addState);
          // const iPlcNo = commonUtils.isNotEmptyObject(iPlcNoData) ? iPlcNoData.masterData[iPlcNoConfig.sName] : '';
          // this.handleGetplcMachineData(iPlcNo);
        }
      }
      if (getType === 'Set') {
        this.props.handleGetDataSet({
          name: sName, configData: currConfig, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
      if (getType === 'customizeParam') {
        const returnData = await this.props.handleGetDataSet({
          name: sName, configData: currConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });

        if (commonUtils.isNotEmptyObject(returnData)) {
          const { customizeParamData = [] } = returnData;
          const addState = {};
          customizeParamData.forEach((item) => {
            const { sType = 'customizeParam' } = item;
            if (commonUtils.isNotEmptyArr(addState[`${sType}Data`])) {
              addState[`${sType}Data`].push(item);
            } else {
              addState[`${sType}Data`] = [item];
            }
          });
          this.props.onSaveState({ ...returnData, ...addState });
        }
      }
    }
    handleGetplcMachineData = async (iOrder) => {
      const { sModelsId, token, masterData } = this.props;
      if (iOrder !== 0) {
        if (commonUtils.isNotEmptyObject(masterData)) {
          const dataUrl = `${commonConfig.server_host}plc/getplcMachine/${iOrder}/${masterData.sId}?sModelsId=${sModelsId}`;
          const dataReturn = (await commonServices.getService(token, dataUrl)).data;
          if (dataReturn.code === 1) {
            const returnData = dataReturn.dataset.rows;
            this.props.onSaveState({
              slaveData: returnData,
            });
          }
        }
      }
    }

    /* 获取变量设置配置 */
    handleGetCustomizeParamConfig = (masterData, customizeParamConfig, sColTitleNameIndex) => {
      let customizeParamConfigNew = {};
      if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(customizeParamConfig)) {
        let sColTitleName = '{"sClassfiyName": "分类", "sName": "参数中文", "sValue": "参数值", "sValue1": "参数值1", "sValue2": "参数值2", "sValue3": "参数值3", "sValue4": "参数值4", "sValue5": "参数值5", "sValue6": "参数值6", "sValue7": "参数值7", "sValue8": "参数值9", "sValue9": "参数值9"  }';
        sColTitleName = masterData.sColTitleName;
        if (commonUtils.isJSON(sColTitleName)) {
          customizeParamConfigNew = JSON.parse(JSON.stringify(customizeParamConfig));
          const configObj = sColTitleNameIndex === undefined ? JSON.parse(sColTitleName) : JSON.parse(sColTitleName)[sColTitleNameIndex];
          const gdsconfigformslaveNew = [];
          if (commonUtils.isNotEmptyObject(configObj)) {
            const { extraConfig = {} } = configObj;
            for (const key of Object.keys(configObj)) {
              if (!['panelName', 'extraConfig'].includes(key)) {
                let configNew = {};
                configNew.sName = key;
                configNew.sChinese = configObj[key];
                configNew.bVisible = true;
                configNew.iFitWidth = 80;
                configNew.showName = configObj[key];
                configNew.bReadonly = false;
                if (extraConfig[key]) {
                  configNew = { ...configNew, ...extraConfig[key] };
                }
                gdsconfigformslaveNew.push(configNew);
              }
            }
          }
          const BtnArr = commonUtils.isNotEmptyArr(customizeParamConfig.gdsconfigformslave) ? customizeParamConfig.gdsconfigformslave.filter(item => item.sName === '' && commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.indexOf('Btn') > -1) : [];
          if (commonUtils.isNotEmptyArr(BtnArr)) {
            for (const item of BtnArr) {
              gdsconfigformslaveNew.push(item);
            }
          }
          if (commonUtils.isNotEmptyArr(gdsconfigformslaveNew)) {
            gdsconfigformslaveNew[0].bMergeCell = true;
            gdsconfigformslaveNew[0].iFitWidth = 100;
            customizeParamConfigNew.gdsconfigformslave = gdsconfigformslaveNew;
          }
        }
      }
      return customizeParamConfigNew;
    }
    /** 主表控件是否全部显示 */
    handleToggle = () => {
      const { expand } = this.props;
      this.props.onSaveState({ expand: !expand });
    };
    /*   取消操作  */
    handleCancel = (obj) => {
      /*   待用数据声明   */
      const {
        app, currentId, masterConfig, contactConfig, addressConfig, supplyConfig, stockConfig, customerInfoConfig, eleknifemouldproductConfig, eleknifemouldfileConfig, siscommonstyleproductclassifyConfig, sModelsType, machineConfig, assortConfig, outsideConfig, picFileConfig, userConfig, sischeckphaselogininfoConfig, phaseConfig, conditionConfig, eleemployeeConfig, elemachineConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig,
        eleteststandarditemConfig, processstyleConfig, processApsRuleConfig, dynamicParamConfig, bUserModel, departgroupConfig, approveGroupConfig, brandgroupConfig,
      } = this.props;
      const { userinfo } = app;
      const onSendSocketMessage = this.props.handleSendSocketMessage;
      if (sModelsType === 'element/customerInfo' || sModelsType === 'element/supplyInfo') {
        const onGetDataOk = this.handleGetData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, contactConfig, addressConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/materialsInfo') {
        const onGetDataOk = this.handleGetMaterialsData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, supplyConfig, stockConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/processInfo') {
        const onGetDataOk = this.handleGetProcessData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, machineConfig, assortConfig, outsideConfig, processstyleConfig, processApsRuleConfig, dynamicParamConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/printInfo') {
        const onGetDataOk = this.handleGetPrintData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, picFileConfig, stockConfig, customerInfoConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/knifemouldInfo') {
        const onGetDataOk = this.handleGetEleKnifeMouldData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, eleknifemouldproductConfig, eleknifemouldfileConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/eleteststandInfo') {
        const onGetDataOk = this.handleGetTestStandData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, eleteststandarditemConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/siscommonstyle') {
        const onGetDataOk = this.handleGetStyleData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, siscommonstyleproductclassifyConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/teamInfo') {
        const onGetDataOk = this.handleGetTeamData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, eleemployeeConfig, elemachineConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/sftloginInfo') {
        const onGetDataOk = this.handleGetSflLoginDataAll;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig, departgroupConfig, { approveGroupConfig, brandgroupConfig });
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'system/sisformulaInfo') {
        const onGetDataOk = this.handleGetSlaveData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk('One', null, masterConfig);
            onSaveStateOk({ enabled: false, bUserModel });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/machineInfo') {
        const onGetDataOk = this.handleGetSlaveData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk('One', null, masterConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/checkModelInfo') {
        const onGetDataOk = this.handleGetCheckModelData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, userConfig, phaseConfig, conditionConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/checkPhaseInfo') {
        const onGetDataOk = this.handleGetCheckPhaseData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig, sischeckphaselogininfoConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'sis/paymentTerms') {
        const onGetDataOk = this.handleGetSlaveData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk('One', null, masterConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/employeeInfo') {
        const onGetDataOk = this.handleGetEleemployeeData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'element/sisproductclassify') {
        const onGetDataOk = this.handleGetTableData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      } else if (sModelsType === 'smg/sendMailMsg') {
        const onGetDataOk = this.handleGetTableData;
        const onSaveStateOk = this.props.onSaveState;
        confirm({
          title: obj.title,
          onOk() {
            onGetDataOk(masterConfig);
            onSaveStateOk({ enabled: false });
            onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
          },
          onCancel() {
          },
        });
      }
    };
    handleGetTableData = async (bEditClick) => {
      const {
        sModelsType, masterConfig, slaveConfig, iPlcNoConfig, siscommonstyleproductclassifyConfig, contactConfig, addressConfig, machineConfig, assortConfig, outsideConfig, processstyleConfig, processApsRuleConfig, dynamicParamConfig, supplyConfig,
        stockConfig, customerInfoConfig, picFileConfig, eleemployeeConfig, elemachineConfig, jurgroupConfig, customergroupConfig, supplygroupConfig,
        persongroupConfig, processgroupConfig, drivergroupConfig, departgroupConfig, paramConfig, selfParamConfig, userConfig, phaseConfig, conditionConfig, sischeckphaselogininfoConfig,
        sisproductclassifyProcessClassifyConfig, sysmsguserConfig, eleknifemouldproductConfig, eleknifemouldfileConfig, eleteststandarditemConfig, formData, approveGroupConfig,
        brandgroupConfig, slave0Config, memoDataList,
      } = this.props;
      if (sModelsType === 'element/customerInfo' || sModelsType === 'element/supplyInfo') {
        this.handleGetData(masterConfig, contactConfig, addressConfig, bEditClick);
      } else if (sModelsType === 'element/processInfo') {
        this.handleGetProcessData(masterConfig, machineConfig, assortConfig, outsideConfig, processstyleConfig, processApsRuleConfig, dynamicParamConfig, bEditClick);
      } else if (sModelsType === 'element/materialsInfo') {
        this.handleGetMaterialsData(masterConfig, supplyConfig, stockConfig, bEditClick);
      } else if (sModelsType === 'element/printInfo') {
        this.handleGetPrintData(masterConfig, picFileConfig, stockConfig, customerInfoConfig, bEditClick);
      } else if (sModelsType === 'element/siscommonstyle') {
        this.handleGetStyleData(masterConfig, siscommonstyleproductclassifyConfig, bEditClick);
      } else if (sModelsType === 'element/teamInfo') {
        this.handleGetTeamData(masterConfig, eleemployeeConfig, elemachineConfig, bEditClick);
      } else if (sModelsType === 'element/knifemouldInfo') {
        this.handleGetEleKnifeMouldData(masterConfig, eleknifemouldproductConfig, eleknifemouldfileConfig, bEditClick);
      } else if (sModelsType === 'element/eleteststandInfo') {
        this.handleGetTestStandData(masterConfig, eleteststandarditemConfig, bEditClick);
      } else if (sModelsType === 'element/sftloginInfo') {
        const flag = undefined;
        const isWait = true;
        const params = await this.handleGetSflLoginData(masterConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig, departgroupConfig, flag, isWait, bEditClick, { approveGroupConfig, brandgroupConfig });
        this.handleGetUserInfoData(params);
      } else if (sModelsType === 'element/machineInfo') {
        const addStateConfig = {
          slave0: slave0Config,
        };
        if (commonUtils.isNotEmptyArr(memoDataList)) {
          memoDataList.forEach((item) => {
            addStateConfig[item.name] = item.config;
          });
        }
        this.handleGetSlaveData('One', null, masterConfig, slaveConfig, iPlcNoConfig, bEditClick, addStateConfig);
      } else if (sModelsType === 'sis/paymentTerms') {
        this.handleGetSlaveData('One', null, masterConfig, bEditClick);
      } else if (sModelsType === 'system/sisformulaInfo') {
        this.handleGetSlaveData('Set', 'param', paramConfig, bEditClick);
        this.handleGetSlaveData('Set', 'selfParam', selfParamConfig, bEditClick);
        this.handleGetSlaveData('One', undefined, masterConfig, bEditClick);
        let customizeParamConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizeparam')) ? formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizeparam')[0] : {};
        /* 获取主表自定义列名为自定义变量配置 */
        const customizeParamConfigNew = this.handleGetCustomizeParamConfig({}, customizeParamConfig);
        if (commonUtils.isNotEmptyArr(customizeParamConfigNew.gdsconfigformslave)) {
          customizeParamConfig = customizeParamConfigNew;
        }
        this.handleGetSlaveData('customizeParam', 'customizeParam', customizeParamConfig, bEditClick); /* 获取自定义变量参数数据集 */
      } else if (sModelsType === 'element/checkModelInfo') {
        this.handleGetCheckModelData(masterConfig, userConfig, phaseConfig, conditionConfig, bEditClick);
      } else if (sModelsType === 'element/checkPhaseInfo') {
        this.handleGetCheckPhaseData(masterConfig, sischeckphaselogininfoConfig, bEditClick);
      } else if (sModelsType === 'element/employeeInfo') {
        this.handleGetEleemployeeData(masterConfig, bEditClick);
      } else if (sModelsType === 'element/sisproductclassify') {
        this.handleGetSisproductclassifyData(masterConfig, sisproductclassifyProcessClassifyConfig, bEditClick);
      } else if (sModelsType === 'element/sisproductclassify') {
        this.handleGetSysMsgData(masterConfig, sysmsguserConfig, bEditClick);
      }
    };
    /**   点击修改按钮操作   */
    handleEdit = async () => {
      /*   数据参数   */
      // const {
      //   app, currentId, token, masterConfig, sModelsId,
      // } = this.props;
      // const sId = currentId || this.props.masterData?.sId || '';
      // const { userinfo } = app;
      // const value = {
      //   tableName: masterConfig.sTbName,
      //   sId: [sId],
      // };
      // this.props.onSaveState({ pageLoading: true });
      const { masterData, bUserModel } = this.props;
      this.props.app.webSocket.onmessageTmp = async (msg) => {
        const rtmsg = JSON.parse(msg.data);
        if (rtmsg.action === 'showMsg') {
          message.warning(rtmsg.msg);
          this.props.onSaveState({ loading: false });
        } else if (rtmsg.action === 'update') {
          await this.handleGetTableData('update');
          this.props.onSaveState({
            enabled: true,
            bUserModel,
            isEnabledPlcNo: (masterData?.iPlcNo === undefined || masterData?.iPlcNo === 0),
            loading: false,
          });
        }
      };
      this.props.handleSendSocketMessage('update', 'showMsg', this.props.currentId, this.props.app.userinfo.sId, null, null);
      // const url = `${commonConfig.server_host}business/addSysLocking?sModelsId=${sModelsId}`;
      // /*   接收返回值   */
      // const { data } = await commonServices.postValueService(token, value, url);
      // if (data.code === 1) {
      //   this.props.handleSendSocketMessage('update', 'showMsg', currentId, userinfo.sId, null, null);
      //   this.handleGetTableData();
      //   this.props.onSaveState({ enabled: true });
      // } else { /*   失败   */
      //   this.props.getServiceError(data);
      // }
    };
    /* 删除 */
    handleDel = (obj) => {
      const props = { ...this.props, ...this.state };
      const onOkDel = this.handleOkDel;
      confirm({
        title: obj.title,
        onOk() {
          onOkDel(props);
        },
        onCancel() {
        },
      });
    };
    /* 确定要删除 */
    handleOkDel = async (props) => {
      /*   数据参数   */
      const {
        currentId, token, sModelsId, masterConfig, contactConfig, addressConfig, supplyConfig, stockConfig, customerInfoConfig, eleknifemouldproductConfig, eleknifemouldfileConfig, eleteststandarditemConfig, siscommonstyleproductclassifyConfig, machineConfig, assortConfig, outsideConfig, picFileConfig, eleemployeeConfig, elemachineConfig, jurgroupConfig, customergroupConfig, supplygroupConfig, persongroupConfig, processgroupConfig, drivergroupConfig, userConfig, sischeckphaselogininfoConfig, phaseConfig, conditionConfig, sModelsType, sisproductclassifyProcessClassifyConfig,
        approveGroupConfig, brandgroupConfig,
      } = props;
      /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      let value = {};
      if (sModelsType === 'element/customerInfo' || sModelsType === 'element/supplyInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: contactConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: addressConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/materialsInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: supplyConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: stockConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/processInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: machineConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: assortConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: outsideConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/printInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: picFileConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: stockConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: customerInfoConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/knifemouldInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: eleknifemouldproductConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: eleknifemouldfileConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/eleteststandInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: eleteststandarditemConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/siscommonstyle') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: siscommonstyleproductclassifyConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/teamInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: eleemployeeConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: elemachineConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/sftloginInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: jurgroupConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: customergroupConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: supplygroupConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: persongroupConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: processgroupConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: drivergroupConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: approveGroupConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: brandgroupConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'system/sisformulaInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [],
          },
        };
      } else if (sModelsType === 'element/machineInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [],
          },
        };
      } else if (sModelsType === 'element/checkModelInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: userConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: phaseConfig.sTbName,
                relationName: 'sParentId',
              }, {
                tableName: conditionConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'element/checkPhaseInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: sischeckphaselogininfoConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      } else if (sModelsType === 'sis/paymentTerms') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [],
          },
        };
      } else if (sModelsType === 'element/employeeInfo') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [],
          },
        };
      } else if (sModelsType === 'element/sisproductclassify') {
        value = {
          sClientType: '1',
          data: {
            sMasterTable: masterConfig.sTbName,
            sId: [sId],
            sSlaveTable: [
              {
                tableName: sisproductclassifyProcessClassifyConfig.sTbName,
                relationName: 'sParentId',
              }],
          },
        };
      }
      const { sBillNo, sId: sIdMaster } = props.masterData || {};
      const url = `${commonConfig.server_host}business/delMasSlaBusinessData?sModelsId=${sModelsId}&sBillNo=${sBillNo}&sSysLogSrcId=${sIdMaster}`;
      /*   接收返回值   */
      const { data } = await commonServices.postValueService(token, value, url);
      if (data.code === 1) {
        /*   数据删除成功   */
        if (this.props.app.currentPane.refresh !== undefined) {
          this.props.app.currentPane.refresh();
        }
        this.handleDelDataSuccess(props);
      } else { /*   失败   */
        this.props.getServiceError(data);
      }
    };
    /* 数据删除成功跳转到新路由即pane */
    handleDelDataSuccess = (props) => {
      const { app } = props;
      let { panes, currentPane } = app;
      /* 删除单据后退出当前路由后,标签panes变化后的集合 */
      panes = panes.filter(pane => pane.key !== currentPane.key);
      /* 跳转到panes集合的最后一个路由，因为panes集合一定含有主页路由所以panes的集合大于等于1 */
      currentPane = panes[panes.length - 1];
      this.props.onRemovePane(panes, currentPane);
    };
    /**   toolbar校验保存   */
    handleValidateSave = async () => {
      const { masterConfig, sModelsType } = this.props;
      this.form.validateFields(async (err, values) => {
        /*   验证通过与不通过走不同的流程   */
        if (err) { /*   验证失败   */
          /*   直接渲染显示错误提示   */
          for (const key of Object.keys(err)) {
            message.warning(err[key].errors[0].message);
            if (sModelsType === 'element/machineInfo') {
              const notEmptyConfigData = masterConfig.gdsconfigformslave.filter(item => item.sName === err[key].errors[0].field && item.bNotEmpty && item.sName !== '' && item.sControlName.indexOf('_') !== -1);
              if (commonUtils.isNotEmptyArr(notEmptyConfigData)) {
                const activeKey = notEmptyConfigData[0].sControlName.split('_')[1].replace(/[^\d]/g, ' ');
                this.props.onSaveState({ activeKey });
              }
            }
          }
          this.props.onSaveState({
            loading: false,
          });
        } else { /*   验证成功   */
          const {
            masterConfig, masterData, slaveConfig, slaveData, slaveDelData, slave0Config, slave0Data, slave0DelData, supplyConfig, supplyData, supplyDelData, stockConfig, stockData, stockDelData, customerInfoConfig,
            contactConfig, contactData, contactDelData, addressConfig, addressData, addressDelData, sModelsType, machineConfig,
            machineData, machineDelData, assortConfig, sisproductclassifyProcessClassifyConfig, eleknifemouldproductConfig, eleknifemouldfileConfig, eleteststandarditemConfig,
            assortData, assortDelData, outsideConfig, outsideData, outsideDelData, processstyleConfig, processstyleData, processstyleDelData,
            processApsRuleConfig, dynamicParamConfig, processApsRuleData, processApsRuleDelData,
            picFileConfig, picFileData, picFileDelData, eleemployeeConfig, eleemployeeData, eleemployeeDelData, elemachineConfig,
            elemachineData, elemachineDelData, jurgroupConfig, jurgroupData, customergroupConfig, customergroupData,
            supplygroupConfig, supplygroupData, persongroupConfig, persongroupData, drivergroupConfig, drivergroupData, departgroupConfig, departgroupData,
            processgroupConfig, processgroupData, userConfig, sischeckphaselogininfoConfig,
            sischeckphaselogininfoData, sischeckphaselogininfoDelData, phaseConfig, conditionConfig, userData, phaseData, conditionData,
            userDelData, phaseDelData, conditionDelData, sisproductclassifyProcessClassifyData, sisproductclassifyProcessClassifyDelData,
            siscommonstyleproductclassifyConfig, siscommonstyleproductclassifyData, siscommonstyleproductclassifyDelData, customerInfoData,
            customerInfoDelData, sysmsguserConfig, customergroupOldData, customergroupOldDelData, supplygroupOldData, supplygroupOldDelData,
            selfParamConfig, selfParamData,selfParamDelData,
            processgroupOldData, processgroupOldDelData, jurgroupOldData, jurgroupOldDelData, persongroupOldData, persongroupOldDelData, drivergroupOldData, drivergroupOldDelData,
            eleknifemouldproductData, eleknifemouldproductDelData, eleknifemouldfileData, eleknifemouldfileDelData, eleteststandarditemData, eleteststandarditemDelData,
            customizeParamConfig, customizeParamData, customizeParamDelData, dynamicParamData, dynamicParamDelData, departgroupOldData, departgroupOldDelData, customizeParamName,
            approveGroupConfig, approveGroupData, approveGroupOldData, approveGroupOldDelData, brandgroupConfig, brandgroupData, brandgroupOldData = [], slaveInfoList,
          } = this.props;
          /*  app, const { webSocket, currentPane } = app;
          const { key } = currentPane; */
          if (!commonBusiness.validateField(values, this.props)) { /* 验证字段输入是否合规 */
            return;
          }
          const data = [];
          if (sModelsType === 'system/sisformulaInfo' && commonUtils.isNotEmptyObject(customizeParamConfig)) {
            let sFormulaSet = ''; /* 公式自定义部分 */
            if (commonUtils.isNotEmptyArr(customizeParamData)) {
              if (commonUtils.isNotEmptyObject(masterData.sColTitleName)) { /* 有自定义列名 则变量名代码生成 */
                const regex = /^customizeParam(?:\d+)?Data$/;
                Object.keys(this.props).filter(key => regex.test(key)).forEach((key) => {
                  const tableName = key.split('Data')[0];
                  const lastChar = tableName.charAt(tableName.length - 1);
                  const firstChar = this.handleGetFirstChar(lastChar);
                  const tempData = this.props[key];
                  tempData.forEach((item, index) => {
                    for (const key of Object.keys(item)) {
                      if (key.includes('sValue')) {
                        const sParam = `${firstChar}${index}_${key}`;
                        let keyValue = item[key];
                        if (commonUtils.isEmpty(keyValue)) {
                          keyValue = '0';
                        }
                        const sFormulaSetRow = `SET @${sParam}:=${keyValue};`;
                        sFormulaSet += sFormulaSetRow;
                      }
                    }
                  });
                });

                // customizeParamData.forEach((item, index) => {
                //   for (const key of Object.keys(item)) {
                //     if (key.includes('sValue')) {
                //       const sParam = `R${index}_${key}`;
                //       let keyValue = item[key];
                //       if (commonUtils.isEmpty(keyValue)) {
                //         keyValue = '0';
                //       }
                //       const sFormulaSetRow = `SET @${sParam}:=${keyValue};`;
                //       sFormulaSet += sFormulaSetRow;
                //     }
                //   }
                // });
              } else {
                customizeParamData.forEach((item) => { /* 没有自定义列名 维持原来 */
                  const sFormulaSetRow = `SET @${item.sParam}:=${item.sValue};`;
                  sFormulaSet += sFormulaSetRow;
                });
              }
            }
            masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
            masterData.sFormulaSet = sFormulaSet;
          }
          data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
          if (sModelsType === 'element/customerInfo' || sModelsType === 'element/supplyInfo') {
            if (!commonBusiness.validateTable(contactConfig, contactData, this.props, '2') || !commonBusiness.validateTable(addressConfig, addressData, this.props, '3')) {
              return;
            }
            data.push(commonBusiness.mergeData('contact', contactConfig.sTbName, contactData, contactDelData));
            data.push(commonBusiness.mergeData('address', addressConfig.sTbName, addressData, addressDelData));
          } else if (sModelsType === 'element/materialsInfo') {
            if (!commonBusiness.validateTable(supplyConfig, supplyData, this.props, '2') || !commonBusiness.validateTable(stockConfig, stockData, this.props, '3')) {
              return;
            }
            data.push(commonBusiness.mergeData('supply', supplyConfig.sTbName, supplyData, supplyDelData));
            data.push(commonBusiness.mergeData('stock', stockConfig.sTbName, stockData, stockDelData));
          } else if (sModelsType === 'element/processInfo') {
            if (!commonBusiness.validateTable(machineConfig, machineData, this.props, '2') || !commonBusiness.validateTable(assortConfig, assortData, this.props, '3') || !commonBusiness.validateTable(outsideConfig, outsideData, this.props, '4') || !commonBusiness.validateTable(processstyleConfig, processstyleData, this.props, '5')
              || !commonBusiness.validateTable(processApsRuleConfig, processApsRuleData, this.props, '6') || !commonBusiness.validateTable(dynamicParamConfig, dynamicParamData, this.props, '7')) {
              return;
            }
            const {
              sReportParam,
              sProcessParam,
              sWorkOrderParam,
              sNormParam,
              sTestParam,
            } = masterData;
            /* 工序信息保存时，验证上报参数设置、工艺参数设置、工单参数设置 JSON字符串格式是否正确 */
            if (commonUtils.isNotEmptyObject(masterData)) {
              // eslint-disable-next-line no-unused-vars
              let JsonData = [];
              let bjson = true;
              if (commonUtils.isNotEmptyObject(sReportParam)) {
                try {
                  JsonData = JSON.parse(sReportParam);
                } catch (e) {
                  message.error('上报参数JSON格式配置错误！');
                  bjson = false;
                }
              }
              if (commonUtils.isNotEmptyObject(sProcessParam)) {
                try {
                  JsonData = JSON.parse(sProcessParam);
                } catch (e) {
                  message.error('工艺参数JSON格式配置错误！');
                  bjson = false;
                }
              }
              if (commonUtils.isNotEmptyObject(sWorkOrderParam)) {
                try {
                  JsonData = JSON.parse(sWorkOrderParam);
                } catch (e) {
                  message.error('工单参数JSON格式配置错误');
                  bjson = false;
                }
              }
              if (commonUtils.isNotEmptyObject(sNormParam)) {
                try {
                  JsonData = JSON.parse(sNormParam);
                } catch (e) {
                  message.error('标准书参数JSON格式配置错误');
                  bjson = false;
                }
              }
              if (commonUtils.isNotEmptyObject(sTestParam)) {
                try {
                  JsonData = JSON.parse(sTestParam);
                } catch (e) {
                  message.error('测试参数JSON格式配置错误');
                  bjson = false;
                }
              }

              /* 若序号大于6 则进行提示 */
              // if (commonUtils.isNotEmptyArr(dynamicParamData)) {
              //   const filterData = dynamicParamData.filter(item => item.iOrder > 11);
              //   if (commonUtils.isNotEmptyArr(filterData)) {
              //     message.error('参数序号不能大于11');
              //     bjson = false;
              //   }
              // }

              if (!bjson) {
                this.props.onSaveState({
                  loading: false,
                });
                return;
              }
            }

            /* 动态参数表业务逻辑处理 */
            if (commonUtils.isNotEmptyArr(dynamicParamData)) {
              /* 先把动态参数按照大小顺序排序 */
              dynamicParamData.sort((g1, g2) => {
                return parseFloat(g1.iOrder) - parseFloat(g2.iOrder);
              });
              /* 动态参数 */
              let sReportParamStr = sReportParam; /* 上报参数字符串 */
              let sProcessParamStr = sProcessParam; /* 工艺参数字符串 */
              let sWorkOrderParamStr = sWorkOrderParam; /* 工单参数字符串 */
              let sNormParamStr = sNormParam; /* 标准书参数字符串 */
              let sTestParamStr = sTestParam; /* 测试参数字符串 */
              const jsonsReportParam = {};
              const jsonsProcessParam = {};
              const jsonsWorkOrderParam = {};
              const jsonsNormParam = {};
              const jsonsTestParam = {};
              dynamicParamData.forEach((item) => {
                const key = `sParam${item.iOrder}`; /* sParma1 */
                const sParamDefault = `sParamDefault${item.iOrder}`; /* sParmaDefault1 */
                const sParamNotEmpty = `sParamNotEmpty${item.iOrder}`;
                const sParamNotFirstEmpty = `sParamNotFirstEmpty${item.iOrder}`;
                const sParamReadOnly = `sParamReadOnly${item.iOrder}`;
                const sParamDropDownKey = `sParamDropDown${item.iOrder}`; /* sParamDropDown1 */
                const sParamsColumnConfig = `sParamColumnConfig${item.iOrder}`; /* sParamColumnConfig1 */
                const sParamAssFieldName = `sParamAssFieldName${item.iOrder}`;
                const sParamFieldName = `sParamFieldName${item.iOrder}`;
                const sParamNotZero = `sParamNotZero${item.iOrder}`;
                const sParamDropDownType = `sParamDropDownType${item.iOrder}`;
                const sParamAssignField = `sParamAssignField${item.iOrder}`;
                const sParamSqlCondition = `sParamSqlCondition${item.iOrder}`;
                const sParamKeyUpFilter = `sParamKeyUpFilter${item.iOrder}`;
                let dropDownSplitData = [];
                let childParamObj = {};
                /* 参数下拉字段逗号分割转换为数组 */
                if (commonUtils.isNotEmptyObject(item.sParamDropDown)) {
                  if (item.sDropDownType === 'sql') {
                    childParamObj = item.sParamDropDown;
                  } else {
                    dropDownSplitData = item.sParamDropDown.split(',');
                    for (const i of dropDownSplitData) {
                      const eachArr = i.split(':');
                      if (commonUtils.isNotEmptyArr(eachArr) && eachArr.length > 1) {
                        const skey = eachArr[0];
                        const sValue = eachArr[1];
                        childParamObj[skey] = sValue;
                      } else {
                        childParamObj[i] = i;
                      }
                    }
                  }
                }
                if (item.sType === '1') { /* 工单参数 */
                  jsonsReportParam[key] = item.sParam;
                  jsonsReportParam[sParamDefault] = item.sParamDefault; /* 默认值 */
                  jsonsReportParam[sParamNotEmpty] = item.bNotEmpty ? true : undefined;
                  jsonsReportParam[sParamNotFirstEmpty] = item.bNotFirstEmpty ? true : undefined;
                  jsonsReportParam[sParamReadOnly] = item.bReadonly ? true : undefined;
                  jsonsReportParam[sParamAssFieldName] = commonUtils.isNotEmptyStr(item.sAssFieldName) ? item.sAssFieldName : undefined;
                  jsonsReportParam[sParamFieldName] = commonUtils.isNotEmptyStr(item.sFieldName) ? item.sFieldName : undefined;
                  jsonsReportParam[sParamNotZero] = item.bNotZero ? true : undefined;
                  jsonsReportParam[sParamDropDownType] = commonUtils.isNotEmptyStr(item.sDropDownType) ? item.sDropDownType : undefined;
                  jsonsReportParam[sParamAssignField] = commonUtils.isNotEmptyStr(item.sAssignField) ? item.sAssignField : undefined;
                  jsonsReportParam[sParamSqlCondition] = commonUtils.isNotEmptyStr(item.sSqlCondition) ? item.sSqlCondition : undefined;
                  jsonsReportParam[sParamKeyUpFilter] = commonUtils.isNotEmptyStr(item.sKeyUpFilter) ? item.sKeyUpFilter : undefined;
                  if (commonUtils.isNotEmptyObject(childParamObj)) {
                    jsonsReportParam[sParamDropDownKey] = childParamObj;
                  }
                  jsonsReportParam[sParamsColumnConfig] = item.sColumnConfig; /* 表格配置 */
                } else if (item.sType === '2') { /* 报价参数 */
                  jsonsProcessParam[key] = item.sParam;
                  jsonsProcessParam[sParamDefault] = item.sParamDefault; /* 默认值 */
                  jsonsProcessParam[sParamNotEmpty] = item.bNotEmpty ? true : undefined;
                  jsonsProcessParam[sParamNotFirstEmpty] = item.bNotFirstEmpty ? true : undefined;
                  jsonsProcessParam[sParamReadOnly] = item.bReadonly ? true : undefined;
                  jsonsProcessParam[sParamAssFieldName] = commonUtils.isNotEmptyStr(item.sAssFieldName) ? item.sAssFieldName : undefined;
                  jsonsProcessParam[sParamFieldName] = commonUtils.isNotEmptyStr(item.sFieldName) ? item.sFieldName : undefined;
                  jsonsProcessParam[sParamNotZero] = item.bNotZero ? true : undefined;
                  jsonsProcessParam[sParamDropDownType] = commonUtils.isNotEmptyStr(item.sDropDownType) ? item.sDropDownType : undefined;
                  jsonsProcessParam[sParamAssignField] = commonUtils.isNotEmptyStr(item.sAssignField) ? item.sAssignField : undefined;
                  jsonsProcessParam[sParamSqlCondition] = commonUtils.isNotEmptyStr(item.sSqlCondition) ? item.sSqlCondition : undefined;
                  jsonsProcessParam[sParamKeyUpFilter] = commonUtils.isNotEmptyStr(item.sKeyUpFilter) ? item.sKeyUpFilter : undefined;
                  if (commonUtils.isNotEmptyObject(childParamObj)) {
                    jsonsProcessParam[sParamDropDownKey] = childParamObj;
                  }
                  jsonsProcessParam[sParamsColumnConfig] = item.sColumnConfig; /* 表格配置 */
                } else if (item.sType === '3') { /* 上报参数 */
                  jsonsWorkOrderParam[key] = item.sParam;
                  jsonsWorkOrderParam[sParamDefault] = item.sParamDefault; /* 默认值 */
                  jsonsWorkOrderParam[sParamNotEmpty] = item.bNotEmpty ? true : undefined;
                  jsonsWorkOrderParam[sParamNotFirstEmpty] = item.bNotFirstEmpty ? true : undefined;
                  jsonsWorkOrderParam[sParamReadOnly] = item.bReadonly ? true : undefined;
                  jsonsWorkOrderParam[sParamAssFieldName] = commonUtils.isNotEmptyStr(item.sAssFieldName) ? item.sAssFieldName : undefined;
                  jsonsWorkOrderParam[sParamFieldName] = commonUtils.isNotEmptyStr(item.sFieldName) ? item.sFieldName : undefined;
                  jsonsWorkOrderParam[sParamNotZero] = item.bNotZero ? true : undefined;
                  jsonsWorkOrderParam[sParamDropDownType] = commonUtils.isNotEmptyStr(item.sDropDownType) ? item.sDropDownType : undefined;
                  jsonsWorkOrderParam[sParamAssignField] = commonUtils.isNotEmptyStr(item.sAssignField) ? item.sAssignField : undefined;
                  jsonsWorkOrderParam[sParamSqlCondition] = commonUtils.isNotEmptyStr(item.sSqlCondition) ? item.sSqlCondition : undefined;
                  jsonsWorkOrderParam[sParamKeyUpFilter] = commonUtils.isNotEmptyStr(item.sKeyUpFilter) ? item.sKeyUpFilter : undefined;
                  if (commonUtils.isNotEmptyObject(childParamObj)) {
                    jsonsWorkOrderParam[sParamDropDownKey] = childParamObj;
                  }
                  jsonsWorkOrderParam[sParamsColumnConfig] = item.sColumnConfig; /* 表格配置 */
                } else if (item.sType === '4') { /* 标准书参数 */
                  jsonsNormParam[key] = item.sParam;
                  jsonsNormParam[sParamDefault] = item.sParamDefault; /* 默认值 */
                  jsonsNormParam[sParamNotEmpty] = item.bNotEmpty ? true : undefined;
                  jsonsNormParam[sParamNotFirstEmpty] = item.bNotFirstEmpty ? true : undefined;
                  jsonsNormParam[sParamReadOnly] = item.bReadonly ? true : undefined;
                  jsonsNormParam[sParamAssFieldName] = commonUtils.isNotEmptyStr(item.sAssFieldName) ? item.sAssFieldName : undefined;
                  jsonsNormParam[sParamFieldName] = commonUtils.isNotEmptyStr(item.sFieldName) ? item.sFieldName : undefined;
                  jsonsNormParam[sParamNotZero] = item.bNotZero ? true : undefined;
                  jsonsNormParam[sParamDropDownType] = commonUtils.isNotEmptyStr(item.sDropDownType) ? item.sDropDownType : undefined;
                  jsonsNormParam[sParamAssignField] = commonUtils.isNotEmptyStr(item.sAssignField) ? item.sAssignField : undefined;
                  jsonsNormParam[sParamSqlCondition] = commonUtils.isNotEmptyStr(item.sSqlCondition) ? item.sSqlCondition : undefined;
                  jsonsNormParam[sParamKeyUpFilter] = commonUtils.isNotEmptyStr(item.sKeyUpFilter) ? item.sKeyUpFilter : undefined;
                  if (commonUtils.isNotEmptyObject(childParamObj)) {
                    jsonsNormParam[sParamDropDownKey] = childParamObj;
                  }
                  jsonsNormParam[sParamsColumnConfig] = item.sColumnConfig; /* 表格配置 */
                } else if (item.sType === '5') { /* 测试参数 */
                  jsonsTestParam[key] = item.sParam;
                  jsonsTestParam[sParamDefault] = item.sParamDefault; /* 默认值 */
                  jsonsTestParam[sParamNotEmpty] = item.bNotEmpty ? true : undefined;
                  jsonsTestParam[sParamNotFirstEmpty] = item.bNotFirstEmpty ? true : undefined;
                  jsonsTestParam[sParamReadOnly] = item.bReadonly ? true : undefined;
                  jsonsTestParam[sParamAssFieldName] = commonUtils.isNotEmptyStr(item.sAssFieldName) ? item.sAssFieldName : undefined;
                  jsonsTestParam[sParamFieldName] = commonUtils.isNotEmptyStr(item.sFieldName) ? item.sFieldName : undefined;
                  jsonsTestParam[sParamNotZero] = item.bNotZero ? true : undefined;
                  jsonsTestParam[sParamDropDownType] = commonUtils.isNotEmptyStr(item.sDropDownType) ? item.sDropDownType : undefined;
                  jsonsTestParam[sParamAssignField] = commonUtils.isNotEmptyStr(item.sAssignField) ? item.sAssignField : undefined;
                  jsonsTestParam[sParamSqlCondition] = commonUtils.isNotEmptyStr(item.sSqlCondition) ? item.sSqlCondition : undefined;
                  jsonsTestParam[sParamKeyUpFilter] = commonUtils.isNotEmptyStr(item.sKeyUpFilter) ? item.sKeyUpFilter : undefined;
                  if (commonUtils.isNotEmptyObject(childParamObj)) {
                    jsonsTestParam[sParamDropDownKey] = childParamObj;
                  }
                  jsonsTestParam[sParamsColumnConfig] = item.sColumnConfig; /* 表格配置 */
                }
              });

              if (commonUtils.isNotEmptyObject(jsonsReportParam)) {
                sReportParamStr = JSON.stringify(jsonsReportParam);
                masterData.sReportParam = sReportParamStr;
                masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
              } else {
                masterData.sReportParam = '';
              }
              if (commonUtils.isNotEmptyObject(jsonsProcessParam)) {
                sProcessParamStr = JSON.stringify(jsonsProcessParam);
                masterData.sProcessParam = sProcessParamStr;
                masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
              } else {
                masterData.sProcessParam = '';
              }
              if (commonUtils.isNotEmptyObject(jsonsWorkOrderParam)) {
                sWorkOrderParamStr = JSON.stringify(jsonsWorkOrderParam);
                masterData.sWorkOrderParam = sWorkOrderParamStr;
                masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
              } else {
                masterData.sWorkOrderParam = '';
              }
              if (commonUtils.isNotEmptyObject(jsonsNormParam)) {
                sNormParamStr = JSON.stringify(jsonsNormParam);
                masterData.sNormParam = sNormParamStr;
                masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
              } else {
                masterData.sNormParam = '';
              }
              if (commonUtils.isNotEmptyObject(jsonsTestParam)) {
                sTestParamStr = JSON.stringify(jsonsTestParam);
                masterData.sTestParam = sTestParamStr;
                masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
              } else {
                masterData.sTestParam = '';
              }
              data.splice(0);
              data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
            }

            data.push(commonBusiness.mergeData('machine', machineConfig.sTbName, machineData, machineDelData));
            data.push(commonBusiness.mergeData('assort', assortConfig.sTbName, assortData, assortDelData));
            data.push(commonBusiness.mergeData('outside', outsideConfig.sTbName, outsideData, outsideDelData));
            data.push(commonBusiness.mergeData('processstyleConfig', processstyleConfig.sTbName, processstyleData, processstyleDelData));
            data.push(commonBusiness.mergeData('processApsRuleConfig', processApsRuleConfig.sTbName, processApsRuleData, processApsRuleDelData));
            data.push(commonBusiness.mergeData('dynamicParamConfig', dynamicParamConfig.sTbName, dynamicParamData, dynamicParamDelData));
          } else if (sModelsType === 'element/printInfo') {
            if (!commonBusiness.validateTable(picFileConfig, picFileData, this.props, '2') || !commonBusiness.validateTable(stockConfig, stockData, this.props, '3') || !commonBusiness.validateTable(customerInfoConfig, customerInfoData, this.props, '4')) {
              return;
            }
            data.push(commonBusiness.mergeData('picFile', picFileConfig.sTbName, picFileData, picFileDelData));
            data.push(commonBusiness.mergeData('stock', stockConfig.sTbName, stockData, stockDelData));
            data.push(commonBusiness.mergeData('customerInfo', customerInfoConfig.sTbName, customerInfoData, customerInfoDelData));
          } else if (sModelsType === 'element/knifemouldInfo') {
            if (!commonBusiness.validateTable(eleknifemouldproductConfig, eleknifemouldproductData, this.props, '2') || !commonBusiness.validateTable(eleknifemouldfileConfig, eleknifemouldfileData, this.props, '3')) {
              return;
            }
            data.push(commonBusiness.mergeData('eleknifemouldproduct', eleknifemouldproductConfig.sTbName, eleknifemouldproductData, eleknifemouldproductDelData));
            data.push(commonBusiness.mergeData('eleknifemouldfile', eleknifemouldfileConfig.sTbName, eleknifemouldfileData, eleknifemouldfileDelData));
          } else if (sModelsType === 'element/eleteststandInfo') {
            if (!commonBusiness.validateTable(eleteststandarditemConfig, eleteststandarditemData, this.props, '2')) {
              return;
            }
            data.push(commonBusiness.mergeData('eleteststandarditem', eleteststandarditemConfig.sTbName, eleteststandarditemData, eleteststandarditemDelData));
          } else if (sModelsType === 'element/siscommonstyle') {
            if (!commonBusiness.validateTable(siscommonstyleproductclassifyConfig, siscommonstyleproductclassifyData, this.props, '2')) {
              return;
            }
            data.push(commonBusiness.mergeData('siscommonstyleproductclassify', siscommonstyleproductclassifyConfig.sTbName, siscommonstyleproductclassifyData, siscommonstyleproductclassifyDelData));
          } else if (sModelsType === 'element/teamInfo') {
            if (!commonBusiness.validateTable(eleemployeeConfig, eleemployeeData, this.props, '2') || !commonBusiness.validateTable(elemachineConfig, elemachineData, this.props, '3')) {
              return;
            }
            data.push(commonBusiness.mergeData('eleemployee', eleemployeeConfig.sTbName, eleemployeeData, eleemployeeDelData));
            data.push(commonBusiness.mergeData('elemachine', elemachineConfig.sTbName, elemachineData, elemachineDelData));
          } else if (sModelsType === 'element/sftloginInfo') {
            if (!commonBusiness.validateTable(jurgroupConfig, jurgroupData, this.props, '2') || !commonBusiness.validateTable(customergroupConfig, customergroupData, this.props, '3') || !commonBusiness.validateTable(supplygroupConfig, supplygroupData, this.props, '4') || !commonBusiness.validateTable(persongroupConfig, persongroupData, this.props, '5') || !commonBusiness.validateTable(processgroupConfig, processgroupData, this.props, '6') || !commonBusiness.validateTable(drivergroupConfig, drivergroupData, this.props, '7')
              || !commonBusiness.validateTable(drivergroupConfig, departgroupData, this.props, '8') || !commonBusiness.validateTable(approveGroupConfig, approveGroupData, this.props, '9') || !commonBusiness.validateTable(brandgroupConfig, brandgroupData, this.props, '10')) {
              return;
            }
            data.push(commonBusiness.mergeData('jurgroup', jurgroupConfig.sTbName, jurgroupOldData, jurgroupOldDelData));
            data.push(commonBusiness.mergeData('customergroup', customergroupConfig.sTbName, customergroupOldData, customergroupOldDelData));
            data.push(commonBusiness.mergeData('supplygroup', supplygroupConfig.sTbName, supplygroupOldData, supplygroupOldDelData));
            data.push(commonBusiness.mergeData('persongroup', persongroupConfig.sTbName, persongroupOldData, persongroupOldDelData));
            data.push(commonBusiness.mergeData('processgroup', processgroupConfig.sTbName, processgroupOldData, processgroupOldDelData));
            data.push(commonBusiness.mergeData('drivergroup', drivergroupConfig.sTbName, drivergroupOldData, drivergroupOldDelData));
            data.push(commonBusiness.mergeData('departgroup', departgroupConfig.sTbName, departgroupOldData, departgroupOldDelData));
            data.push(commonBusiness.mergeData('approveGroup', approveGroupConfig.sTbName, approveGroupOldData, approveGroupOldDelData));
            data.push(commonBusiness.mergeData('brandgroup', brandgroupConfig.sTbName, brandgroupOldData.filter(item => item.iCheck), brandgroupOldData.filter(item => !item.iCheck).map(item => ({ ...item, handleType: 'del' }))));
          } else if (sModelsType === 'element/checkModelInfo') {
            if (!commonBusiness.validateTable(userConfig, userData, this.props, '2') || !commonBusiness.validateTable(phaseConfig, phaseData, this.props, '3') || !commonBusiness.validateTable(conditionConfig, conditionData, this.props, '4')) {
              return;
            }
            data.push(commonBusiness.mergeData('user', userConfig.sTbName, userData, userDelData));
            data.push(commonBusiness.mergeData('phase', phaseConfig.sTbName, phaseData, phaseDelData));
            data.push(commonBusiness.mergeData('condition', conditionConfig.sTbName, conditionData, conditionDelData));
          } else if (sModelsType === 'element/checkPhaseInfo') {
            if (!commonBusiness.validateTable(sischeckphaselogininfoConfig, userData, this.props, '2')) {
              return;
            }
            data.push(commonBusiness.mergeData('sischeckphaselogininfo', sischeckphaselogininfoConfig.sTbName, sischeckphaselogininfoData, sischeckphaselogininfoDelData));
          } else if (sModelsType === 'element/sisproductclassify') {
            if (!commonBusiness.validateTable(sisproductclassifyProcessClassifyConfig, sisproductclassifyProcessClassifyData, this.props, '2')) {
              return;
            }
            data.push(commonBusiness.mergeData('sisproductclassifyProcessClassify', sisproductclassifyProcessClassifyConfig.sTbName, sisproductclassifyProcessClassifyData, sisproductclassifyProcessClassifyDelData));
          } else if (sModelsType === 'system/sisformulaInfo') {
            const bResult = await this.handleField();
            if (!bResult) {
              this.props.onSaveState({
                loading: false,
              });
              return;
            }
            if (commonUtils.isNotEmptyArr(customizeParamName)) {
              let customizeParamDataNew = [];
              let customizeParamDelDataNew = [];
              customizeParamName.forEach((paramName) => {
                const { [`${paramName}Data`]: cpData = [], [`${paramName}DelData`]: cpdData = [] } = this.props;
                customizeParamDataNew = [...customizeParamDataNew, ...cpData];
                customizeParamDelDataNew = [...customizeParamDelDataNew, ...cpdData];
                if (paramName === 'customizeParam' && commonUtils.isEmptyObject(customizeParamConfig.sTbName)) {
                  customizeParamConfig.sTbName = 'sisformulacustomizeparam';
                }
              });
              data.push(commonBusiness.mergeData('customizeParam', customizeParamConfig.sTbName, customizeParamDataNew, customizeParamDelDataNew));
            } else if (commonUtils.isNotEmptyObject(customizeParamConfig)) {
              customizeParamConfig.sTbName = 'sisformulacustomizeparam';
              data.push(commonBusiness.mergeData('customizeParam', customizeParamConfig.sTbName, customizeParamData, customizeParamDelData));
            }
            if (commonUtils.isNotEmptyObject(selfParamConfig)) {
              data.push(commonBusiness.mergeData('selfParam', selfParamConfig.sTbName, selfParamData, selfParamDelData));
            }
          } else if (sModelsType === 'smg/sendMailMsg') {
            masterData.sContent = masterData.sContentMemo;
            masterData.sType = '1';
            // masterData.sCheckPerson = masterData.sUserIds;
            data.splice(0);
            data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
            let sUserIds;
            if (typeof masterData.sUserIds === 'string') {
              sUserIds = masterData.sUserIds.split(',');
            } else {
              sUserIds = masterData.sUserIds;
            }
            const sysmsguserData = [];
            if (commonUtils.isNotEmptyArr(sUserIds)) {
              const spid = masterData.sId;
              sUserIds.forEach((key) => {
                const smguserData = {};
                smguserData.sParentId = spid;
                smguserData.sId = commonUtils.createSid();
                smguserData.sUserId = key;
                smguserData.bReply = false;
                smguserData.bIsView = false;
                smguserData.handleType = 'add';
                sysmsguserData.push(smguserData);
              });
            }
            data.push(commonBusiness.mergeData('sysmsguser', sysmsguserConfig.sTbName, sysmsguserData, []));
            // commonFunc.sendWebSocketMessage(webSocket, key, 'sendMsg', 'reflush', this.props.app.userinfo.sId, null, null, sUserIds.join(','), null);
          } else if (sModelsType === 'element/machineInfo') {
            if (!commonBusiness.validateTable(slaveConfig, slaveData, this.props, '3')) {
              return;
            }
            data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
            data.push(commonBusiness.mergeData('slave0', slave0Config.sTbName, slave0Data, slave0DelData));
            if (commonUtils.isNotEmptyArr(slaveInfoList)) {
              slaveInfoList.forEach((name) => {
                const tbName = name.replace('Config', '');
                const { [`${tbName}Config`]: tableConfig, [`${tbName}Data`]: tableData, [`${tbName}DelData`]: tableDelData } = this.props;
                if (tableConfig && tableConfig.sTbName && tableConfig.sSqlStr !== 'noQuery') {
                  const tableDataNew = tbName === 'master' ? [tableData] : tableData;
                  data.push(commonBusiness.mergeData(tbName, tableConfig.sTbName, tableDataNew, tableDelData));
                }
              });
              console.log('data', data);
            }
            this.props.onSaveState({
              isEnabledPlcNo: false,
            });
          }
          this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId });
        }
      });
    };
    /**   toolbar保存   */
    handleSaveData = async (params) => {
      const {
        app, currentId, token, sModelsId, masterData, billnosetting, sModelsType, dispatch,
      } = this.props;
      const { webSocket, userinfo, currentPane } = app;
      const { key } = currentPane;
      const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
      if (commonUtils.isNotEmptyObject(returnData)) {
        // 释放数据操作权限
        commonFunc.sendWebSocketMessage(webSocket, key, 'release', 'noAction', userinfo.sId, null, currentId, userinfo.sId, null);
        this.props.onSaveState({
          enabled: false, currentId: masterData.sId === undefined ? masterData.sid : masterData.sId,
        });
        // 保存后更新panes,currentPane的checkedId，防止浏览器刷新时重新又变成新增。
        const iPaneIndex = app.panes.findIndex(item => item.key === app.currentPane.key);
        app.panes[iPaneIndex].checkedId = masterData.sId;
        app.currentPane.checkedId = masterData.sId;
        if (commonUtils.isNotEmptyArr(app.panes)) { /* 处理选择窗体通过新增 复制跳转到基础信息，保存后 选择窗体在基础信息界面显示 导致Modal关闭不掉bug  */
          for (const each of app.panes) {
            each.notCurrentPane = true;
          }
        }
        dispatch({ type: 'app/savePanesAndCurrentPane', payload: { panes: app.panes, currentPane: app.currentPane } });

        commonUtils.clearStoreDropDownData();
        /* 新记录时，关闭后能自动带值  */
        const callBackRecord = this.props.app.currentPane.newRecordMethod;
        if (callBackRecord !== undefined) {
          const sId = masterData.sId === undefined ? masterData.sid : masterData.sId;/* sId */
          /* 回调 传[新增的数据sId] */
          if (this.props.app.currentPane.newRecordMethod !== undefined) {
            this.props.app.currentPane.newRecordMethod(sId);
          }
        }
        if (billnosetting.bAutoCheck) {
          this.handleAudit(1);
        } else {
          this.handleGetTableData();
          if (this.props.app.currentPane.refresh !== undefined) {
            this.props.app.currentPane.refresh();
          }
        }
        if (sModelsType === 'smg/sendMailMsg') {
          this.props.handleSendSocketMessage('reflush', 'showImg', currentId, masterData.sUserIds, '您有消息待审核', null);
        }
        this.props.onSaveState({
          loading: false,
        });
        return true;
      } else {
        this.props.onSaveState({
          loading: false,
        });
        return false;
      }
    };
    /**   toolbar审核(消审)   */
    handleAudit = (flag) => {
      /*   待用数据声明   */
      const { masterData, gdsformconst } = this.props;
      /*   作废订单不能审核   */
      if (masterData.bInvalid) {
        message.warning(gdsformconst.filter(item => (item.sName === 'sToVoid'))[0].showName);
        return '';
      }
      /**   数据审核   */
      this.dataAudit(flag);
    };
    /**   数据审核   */
    dataAudit = async (flag, tmpCheck, isWait) => {
      message.destroy();
      /*   待用数据声明   */
      const {
        sModelsId, masterData, app, masterConfig, token, sModelsType, controlConfig, materialsConfig, processConfig,
        contactConfig, addressConfig,
      } = this.props;
      /*   数据参数   */
      const value = {
        sClientType: '1',
        paramsMap: {
          iFlag: flag,
          iTmpCheck: commonUtils.isEmptyNumber(tmpCheck) ? 0 : tmpCheck,
          sFormGuid: sModelsId,
          sGuid: masterData.sId,
        },
      };
      /*   数据审核   */
      const url = `${commonConfig.server_host}business/doExamine?sModelsId=${sModelsId}`;
      const returnData = (await commonServices.postValueService(app.token, value, url)).data;
      if (isWait) {
        return returnData;
      } else {
        /*   接收返回值   */
        if (returnData.code === 1) { /*   成功   */
          this.props.onSaveState({
            loading: false,
          });
          if (flag === 1) {
            /*   审核   */
            const { outData } = returnData.dataset.rows[0].dataSet;
            if (outData[0].sCode === -1) {
              message.error(commonFunc.showMessage(app.commonConst, 'BtnExamine') + outData[0].sReturn);/* 审核 */
              return;
            }
            if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
              const sReturnArray = outData[0].sReturn.split('|');
              const checkConditions = [];
              let checkPersonData = {};
              sReturnArray.forEach((item) => {
                const checkCondition = item.split('-')[2];
                checkConditions.push({
                  key: commonUtils.createSid(),
                  condition: checkCondition,
                });
              });
              const sCheckModelId = sReturnArray[0].split('-')[1];
              if (commonUtils.isNotEmptyStr(sCheckModelId)) {
                const urlCheck = `${commonConfig.server_host}checkModel/getUserListByModelId/${sCheckModelId}?sModelsId=${sModelsId}`;
                const dataReturn = (await commonServices.getService(token, urlCheck)).data;
                if (dataReturn.code === 1) {
                  checkPersonData = dataReturn.dataset.rows;
                  checkPersonData.forEach((item) => {
                    item.key = commonUtils.createSid();
                  });
                  this.props.onSaveState({
                    checkConditions, checkPersonData, sCheckModelId, visible: true,
                  });
                } else { /*   失败   */
                  this.props.getServiceError({ msg: commonFunc.showMessage(app.commonConst, 'BtnExamine') + dataReturn }); /* 审核 */
                }
              }
            } else {
              this.handleGetTableData();
              message.success(commonFunc.showMessage(app.commonConst, 'BtnExamine') + returnData.msg);/* 审核 */
            }
          } else {
            /*   消审   */
            // this.handleGetData(masterConfig, slaveConfig, checkConfig);
            if (sModelsType === 'element/customerInfo') { /* 客户审核、消审 */
              this.handleGetData(masterConfig, contactConfig, addressConfig);
            }
            if (sModelsType.includes('sales/salesOrder') && !commonUtils.isEmpty(controlConfig)) {
              this.handleGetMemoData(controlConfig, materialsConfig, processConfig);
            }
            const { outData } = returnData.dataset.rows[0].dataSet;
            if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
              message.error(outData[0].sReturn);
            } else {
              message.success(commonFunc.showMessage(app.commonConst, 'BtnCancelExamine') + returnData.msg); /* 消审 */
            }
          }
        } else { /*   失败   */
          this.props.getServiceError(returnData); /* 审核或消审 */
          this.props.onSaveState({
            loading: false,
          });
        }
        return true;
      }
    };
    /**   表单回带   */
    handleForm = (form) => {
      this.form = form;
    };
    /*  上一条、下一条、首条、末条 */
    handleSearchData = async (handleType) => {
      const {
        sModelsId, app, currentIndexFlag, currentPageNo, masterData, masterConfig, slaveConfig, checkConfig,
        sSrcModelsId,
      } = this.props;
      let { sBillIdsArray = []} = this.props;
      let { currentId } = this.props;

      const tipLast = commonFunc.showLocalMessage(this.props, 'tipLast', '当前已经是最后一条');
      const tipFirst = commonFunc.showLocalMessage(this.props, 'tipFirst', '当前已经是第一条');
      const noSearhData = commonFunc.showLocalMessage(this.props, 'noSearhData', '非单据列表跳转，无上一条下一条');
      const { currentPane, token } = app;
      const {
        pages, sFilterOrderBy, bFilter, sListFormmasterId, currentIndex,
      } = currentPane;
      console.log('22page2222s2', pages);
      let currentPosition = currentIndexFlag ? currentPageNo : commonUtils.isEmptyObject(pages) ? 1 : (((pages.current - 1) * commonConfig.pageSize) + Number.parseInt(currentIndex, 10)) + 1;
      if (currentIndex === undefined) {
        currentPosition = 1;
      }
      if (!commonUtils.isNum(currentPosition)) { // 如果是列表直接点增加，就跳到第一条去
        currentPosition = 1;
      }
      let  bExist = false;
      /* 如果sBillIdsArray已存在 则不请求 */
      if(commonUtils.isNotEmptyArr(sBillIdsArray) && sBillIdsArray.length > 0) {
        const index =  sBillIdsArray.indexOf(currentId);
        if(index > -1) {
          if ("next".includes(handleType)) {
            currentPosition = index + 1;
            if(currentPosition > sBillIdsArray.length - 1 ){
              message.warn(tipLast);
              return ;
            }
          } else if ("up".includes(handleType)) {
            if(index === 0){
              message.warn(tipFirst);
              return ;
            }
            currentPosition = index - 1;
          } else if ("first".includes(handleType)) {
            currentPosition = 0;
          } else if ("end".includes(handleType)) {
            currentPosition = sBillIdsArray.length - 1;
          }
          currentId = sBillIdsArray[currentPosition];
          currentPosition = currentPosition + 1;
          bExist = true;
        } else {
          bExist = false;
        }
      }
      /* 如果是第一次请求 */
      if(!bExist) {
        const bFromList = commonUtils.isEmptyObject(pages) ? true: false;
        if(bFromList) {
          if(handleType ==='next' || handleType ==='end') {
            message.warn(tipLast);
            return ;
          }else {
            message.warn(tipFirst);
            return ;
          }
        }
        const value = {
          sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages?.total,
          sUpId: masterData?.sId,  sParentModelId :sSrcModelsId,
        };
        this.props.onSaveState({ loading: true });
        const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`;
        /*   接收返回值   */
        const { data } = await commonServices.postValueService(token, value, url);
        /*   接收返回值   */
        /*   成功的话刷新页面(同步主表和从表数据),不成功就弹出错误提示   */
        if (data.code === 1) {
          /*   数据查询成功   */
          const returnData = data.dataset.rows[0];
          if(commonUtils.isNotEmptyObject(returnData) && (commonUtils.isEmpty(returnData?.sId) ||
            returnData?.sId === "")) {
            message.error(noSearhData);
            return;
          }
          /* 拿到接口返回的sBillids */
          console.log('returnData', returnData);
          const sBillIds = returnData?.sBillIds;
          if(commonUtils.isNotEmptyArr(sBillIds)) {
            sBillIdsArray =  sBillIds;
          }
          currentId = returnData?.sId;
          currentPosition = returnData?.currentPosition;
        } else { /*   失败   */
          this.props.getServiceError(data);
          return false;
        }

      }
      this.props.onSaveState({
        currentIndexFlag: true,
        currentPageNo: currentPosition,
        currentId,
        searchUpDownData: {},
        slaveSelectedRowKeys: [],
        sBillIdsArray,
        loading: true,
      }, () =>  this.handleGetTableData());
      return true;
    };
    /* 切换作废状态 */
    handleOkChangeInvaild = async (props) => {
      const {
        currentId, sModelsId, masterData, masterConfig, handleType,
      } = props;
      const sId = currentId || this.props.masterData?.sId || '';
      const value = {
        sClientType: '1',
        sId: [sId],
        sTableName: masterConfig.sTbName,
        handleType,
        sBooleanCheck: false,
      };
      const url = `${commonConfig.server_host}checkModel/updatebInvalid?sModelsId=${sModelsId}`;
      const { data } = await commonServices.postValueService(props.app.token, value, url);
      if (data.code === 1) {
        message.success(data.msg);
        masterData.bInvalid = handleType === 'toVoid'; /* 作废状态 */
        props.onSaveState({ masterData });
        /*  审核(消审)后刷新跳转路由数据（commonList）的数据 */
        if (props.app.currentPane.refresh !== undefined) {
          props.app.currentPane.refresh();
        }
        commonUtils.clearStoreDropDownData();/* 清除所有下拉框缓存 */
      } else {
        props.getServiceError(data);
      }
    };

    /* 作废、取消作废的公用函数 */
    handleInvalid = (obj) => {
      const props = { ...this.props, ...this.state, ...obj };
      const onOkInvaild = this.handleOkChangeInvaild;
      confirm({
        title: obj.title,
        onOk() {
          onOkInvaild(props);
        },
        onCancel() {
        },
      });
    };
    /**  点击新增按钮   */
    handleAdd = async (config, copyTo, isWait) => {
      /*   外置处理业务   */
      const { sModelsId, sModelsType } = this.props;
      let masterConfig = commonUtils.isEmptyObject(config) ? {} : config.masterConfig;
      if (!isWait) {
        masterConfig = this.props.masterConfig;
      }
      let masterData = commonFunc.getDefaultData(masterConfig);
      masterData.handleType = 'add';
      masterData.sId = commonUtils.createSid();
      masterData.sFormId = sModelsId;
      if (commonUtils.isNotEmptyObject(copyTo)) {
        const masterOldData = JSON.parse(JSON.stringify(copyTo.masterData));
        masterData = copyTo.masterData;
        delete masterData.tCreateDate;
        masterData.handleType = 'add';
        masterData.sId = commonUtils.createSid();
        masterData.sFormId = sModelsId;
        let state = {};
        if (sModelsType === 'element/materialsInfo') {
          masterData.maxBillNo = 'sMaterialsNo';
          delete masterData.sMaterialsNo;
          delete masterData.bCheck;
          const supplyData = copyTo.supplyData;
          supplyData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.key = tableDataRow.sId;
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
            tableDataRow.sMaterialsId = masterData.sId;
          });
          const stockData = copyTo.stockData;
          stockData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.key = tableDataRow.sId;
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
            tableDataRow.sMaterialsId = masterData.sId;
          });
          state = {
            masterData,
            supplyData,
            stockData,
            enabled: true,
          };
        } else if (sModelsType === 'element/customerInfo') {
          masterData.maxBillNo = 'sCustomerNo';
          delete masterData.sCustomerNo;
          delete masterData.bCheck;
          const contactData = copyTo.contactData;
          contactData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const addressData = copyTo.addressData;
          addressData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            contactData,
            addressData,
            enabled: true,
          };
        } else if (sModelsType === 'element/printInfo') {
          masterData.sSrcProductNo = masterOldData.sProductNo; /* 产品编号赋到原产品编号 */
          masterData.maxBillNo = 'sProductNo';
          delete masterData.sProductNo;
          delete masterData.bCheck;
          const picFileData = copyTo.picFileData;
          picFileData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
            tableDataRow.sProductId = masterData.sId;
            tableDataRow.sCustomerId = masterData.sCustomerId;
          });
          const stockData = copyTo.stockData;
          stockData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
            tableDataRow.sProductId = masterData.sId;
            tableDataRow.sCustomerId = masterData.sCustomerId;
          });
          const customerInfoData = copyTo.customerInfoData;
          customerInfoData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
            tableDataRow.sProductId = masterData.sId;
          });
          state = {
            masterData,
            picFileData,
            stockData,
            customerInfoData,
            enabled: true,
          };
        } else if (sModelsType === 'element/employeeInfo') {
          masterData.maxBillNo = 'sEmployeeNo';
          delete masterData.sEmployeeNo;
          delete masterData.bCheck;
          state = {
            masterData,
            enabled: true,
          };
        } else if (sModelsType === 'element/sisproductclassify') {
          masterData.maxBillNo = 'sNo';
          delete masterData.sNo;
          delete masterData.bCheck;
          const masterDataOld = copyTo.masterData;
          if (commonUtils.isNotEmptyObject(masterDataOld.sAllId)) {
            const treeCopyNodes = new Map();
            const sAllOldId = masterDataOld.sAllId;
            const arr = sAllOldId.split(',');
            const newId = masterData.sId;
            const sOldId = masterDataOld.sId;
            let sOldParentId = '';
            let sNewParentAllId = '';
            if (arr.length < 2) { /* 根节点复制 */
              masterData.sAllId = newId;
              sOldParentId = newId;
              sNewParentAllId = newId;
            } else {
              sOldParentId = arr[arr.length - 2];
              if (treeCopyNodes.has(sOldParentId)) {
                sNewParentAllId = treeCopyNodes.get(sOldParentId);
              } else {
                const obj = arr[arr.length - 1];
                sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
              }
              const sNewArr = sNewParentAllId.split(',');
              masterData.sControlParentId = sNewArr[sNewArr.length - 1];
              sNewParentAllId = `${sNewParentAllId},${newId}`;
              masterData.sAllId = sNewParentAllId;
            }
            treeCopyNodes.set(sOldId, sNewParentAllId);
          }
          const sisproductclassifyProcessClassifyData = copyTo.sisproductclassifyProcessClassifyData;
          if (commonUtils.isNotEmptyArr(sisproductclassifyProcessClassifyData)) {
            sisproductclassifyProcessClassifyData.forEach((tableDataRow) => {
              tableDataRow.handleType = 'add';
              tableDataRow.sId = commonUtils.createSid();
              tableDataRow.sParentId = masterData.sId;
              tableDataRow.sFormId = sModelsId;
            });
          }
          state = {
            masterData,
            sisproductclassifyProcessClassifyData,
            enabled: true,
          };
          if (commonUtils.isNotEmptyObject(masterData.sAllPartsName)) {
            state.sisproductclassifyProcessClassifyConfig = this.handleChangeProductParteName(masterData.sAllPartsName, config.sisproductclassifyProcessClassifyConfig);
          }
        } else if (sModelsType === 'element/processInfo') {
          masterData.maxBillNo = 'sProcessNo';
          delete masterData.sProcessNo;
          delete masterData.bCheck;
          const machineData = copyTo.machineData;
          machineData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const assortData = copyTo.assortData;
          assortData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const outsideData = copyTo.outsideData;
          outsideData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const processstyleData = copyTo.processstyleData;
          processstyleData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const processApsRuleData = copyTo.processApsRuleData;
          processApsRuleData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const dynamicParamData = copyTo.dynamicParamData;
          dynamicParamData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            machineData,
            assortData,
            outsideData,
            processstyleData,
            processApsRuleData,
            dynamicParamData,
            enabled: true,
          };
        } else if (sModelsType === 'element/supplyInfo') {
          masterData.maxBillNo = 'sSupplyNo';
          delete masterData.sSupplyNo;
          delete masterData.bCheck;
          const contactData = copyTo.contactData;
          contactData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const addressData = copyTo.addressData;
          addressData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            contactData,
            addressData,
            enabled: true,
          };
        } else if (sModelsType === 'element/machineInfo') {
          masterData.maxBillNo = 'sMachineNo';
          delete masterData.sMachineNo;
          delete masterData.bCheck;
          state = {
            masterData,
            enabled: true,
          };
        } else if (sModelsType === 'element/teamInfo') {
          masterData.maxBillNo = 'sTeamNo';
          delete masterData.sTeamNo;
          delete masterData.bCheck;
          const eleemployeeData = copyTo.eleemployeeData;
          eleemployeeData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const elemachineData = copyTo.elemachineData;
          elemachineData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            eleemployeeData,
            elemachineData,
            enabled: true,
          };
        } else if (sModelsType === 'sis/paymentTerms') {
          delete masterData.bCheck;
          state = {
            masterData,
            enabled: true,
          };
        } else if (sModelsType === 'smg/sendMailMsg') {
          masterData.maxBillNo = 'sNo';
          delete masterData.sNo;
          delete masterData.bCheck;
          const sysmsguserData = copyTo.sysmsguserData;
          sysmsguserData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            sysmsguserData,
            enabled: true,
          };
        } else if (sModelsType === 'element/knifemouldInfo') { /* 刀模信息 */
          masterData.maxBillNo = 'sKnifeMouldNo';
          delete masterData.bCheck;
          const eleknifemouldproductData = copyTo.eleknifemouldproductData;
          eleknifemouldproductData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          const eleknifemouldfileData = copyTo.eleknifemouldfileData;
          eleknifemouldfileData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            eleknifemouldproductData,
            eleknifemouldfileData,
            enabled: true,
          };
        } else if (sModelsType === 'element/eleteststandInfo') { /* 检验标准 */
          masterData.maxBillNo = 'sTestNo';
          delete masterData.bCheck;
          const eleteststandarditemData = copyTo.eleteststandarditemData;
          eleteststandarditemData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            eleteststandarditemData,
            enabled: true,
          };
        } else if (sModelsType === 'system/sisformulaInfo') { /* 计算方案 */
          // masterData.maxBillNo = 'sNo';
          delete masterData.bCheck;
          masterData.bUserModel = true;
          const customizeParamData = copyTo.customizeParamData;
          customizeParamData.forEach((tableDataRow) => {
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.sFormId = sModelsId;
          });
          state = {
            masterData,
            customizeParamData,
            enabled: true,
          };
        }
        state.sUseInfo = '';
        if (isWait) {
          return state;
        }
        this.props.onSaveState(state);
      }
      let state = {};
      if (sModelsType === 'element/customerInfo') {
        masterData.maxBillNo = 'sCustomerNo';
        state = {
          masterData,
          contactData: [],
          addressData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/supplyInfo') {
        masterData.maxBillNo = 'sSupplyNo';
        state = {
          masterData,
          contactData: [],
          addressData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/materialsInfo') {
        masterData.maxBillNo = 'sMaterialsNo';
        state = {
          masterData,
          supplyData: [],
          stockData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/processInfo') {
        masterData.maxBillNo = 'sProcessNo';
        state = {
          masterData,
          machineData: [],
          assortData: [],
          outsideData: [],
          processstyleData: [],
          processApsRuleData: [],
          dynamicParamData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/printInfo') {
        masterData.maxBillNo = 'sProductNo';
        /* 新增产品/印件，如果是newRecord过来的，则要获取关联的客户信息 */
        if (this.props.app.currentPane.newRecordRelation !== undefined) {
          const addStata = this.props.app.currentPane.newRecordRelation;
          if (commonUtils.isNotEmptyObject(addStata) && commonUtils.isNotEmptyObject(addStata.sCustomerId)) {
            masterData.sCustomerId = addStata.sCustomerId;
            masterData.sCustomerNo = addStata.sCustomerNo;
            masterData.sCustomerName = addStata.sCustomerName;
            /* newRecord新增产品，客户不可修改 */
            const ssCustomerNameIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sCustomerName');
            if (ssCustomerNameIndex > -1) {
              masterConfig.gdsconfigformslave[ssCustomerNameIndex].iTag = 1;
            }
          }
        }
        state = {
          masterData,
          picFileData: [],
          stockData: [],
          customerInfoData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/siscommonstyle') {
        state = {
          masterData,
          siscommonstyleproductclassifyData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/teamInfo') {
        masterData.maxBillNo = 'sTeamNo';
        state = {
          masterData,
          eleemployeeData: [],
          elemachineData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/sftloginInfo') {
        const {
          sModelsId, token,
        } = this.props;
        /* 当前页签数据 */
        const condition = { };
        const dataUrl = `${commonConfig.server_host}userinfo/getUserInfoData/?sModelsId=${sModelsId}`;
        const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
        if (dataReturn.code === 1) {
          const returnData = dataReturn.dataset.rows[0];
          state = {
            masterData,
            jurgroupData: returnData.jurgroupData,
            customergroupData: returnData.customergroupData,
            supplygroupData: returnData.supplygroupData,
            persongroupData: returnData.persongroupData,
            processgroupData: returnData.processgroupData,
            drivergroupData: returnData.drivergroupData,
            departgroupData: returnData.departgroupData,
            approveGroupData: returnData.sApprovalprocessData,
            jurgroupOldData: [],
            customergroupOldData: [],
            supplygroupOldData: [],
            persongroupOldData: [],
            processgroupOldData: [],
            drivergroupOldData: [],
            approveGroupOldData: [],
            jurgroupSelectedRowKeys: [],
            customergroupSelectedRowKeys: [],
            supplygroupSelectedRowKeys: [],
            persongroupSelectedRowKeys: [],
            processgroupSelectedRowKeys: [],
            drivergroupSelectedRowKeys: [],
            departgroupSelectedRowKeys: [],
            approveGroupSelectedRowKeys: [],
            enabled: true,
          };
        }
      } else if (sModelsType === 'system/sisformulaInfo') {
        const customizeParamData = [];
        let configNew = {};
        if (commonUtils.isEmptyObject(config)) {
          const { customizeParamConfig } = this.props;
          configNew.customizeParamConfig = customizeParamConfig;
        } else {
          configNew = config;
        }
        if (commonUtils.isNotEmptyObject(configNew.customizeParamConfig)) {
          const allTableData = {};
          masterData.bUserModel = true;
          allTableData.master = masterData;
          allTableData.customizeParam = customizeParamData;
          const tableDataRowAdd = commonFunc.getDefaultData(configNew.customizeParamConfig, allTableData);
          tableDataRowAdd.handleType = 'add';
          tableDataRowAdd.sId = commonUtils.createSid();
          tableDataRowAdd.sSlaveId = tableDataRowAdd.sId;
          tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
          tableDataRowAdd.key = tableDataRowAdd.sId;
          tableDataRowAdd.bDefault = false;
          tableDataRowAdd.iOrder = 1;
          customizeParamData.push(tableDataRowAdd);
        }

        let addState = {};

        // 在本页面新增时
        if (commonUtils.isEmptyObject(config)) {
          // 将customize/userParam开头的参数都置空
          addState = Object.keys(this.props)
            .filter(key => key?.startsWith('customize') || key?.startsWith('userParam'))
            .reduce((result, key) => {
              result[key] = undefined;
              return result;
            }, {});

          const sisformulacustomizeparamConfig = this.props.formData.find(item => item.bGrd && item.sTbName === 'sisformulacustomizeparam');
          const customizeParamConfig = sisformulacustomizeparamConfig || {};
          const customizeParamColumn = commonFunc.getHeaderConfig(customizeParamConfig);

          addState.customizeParamConfig = customizeParamConfig;
          addState.customizeParamColumn = customizeParamColumn;

          if (commonUtils.isNotEmptyObject(customizeParamConfig)) {
            const userParamConfig = JSON.parse(JSON.stringify(customizeParamConfig));
            if (commonUtils.isNotEmptyArr(userParamConfig.gdsconfigformslave)) {
              userParamConfig.gdsconfigformslave.forEach((item) => {
                // if (item.sName.indexOf('sValue') === -1) { /* 除了参数值 其他均不可修改 */
                //   item.iTag = 1;
                // }
                if (item.sName === 'sParam') {
                  item.bVisible = false;
                }
              });
            }
            const userParamColumn = commonFunc.getHeaderConfig(userParamConfig);
            addState.userParamConfig = userParamConfig;
            addState.userParamColumn = userParamColumn;
          }
        }

        state = {
          ...addState,
          masterData,
          enabled: true,
          customizeParamData,
        };
      } else if (sModelsType === 'element/machineInfo') {
        masterData.maxBillNo = 'sMachineNo';
        state = {
          masterData,
          enabled: true,
          isEnabledPlcNo: true,
        };
      } else if (sModelsType === 'sis/paymentTerms') {
        // masterData.maxBillNo = 'sMachineNo';
        state = {
          masterData,
          enabled: true,
        };
      } else if (sModelsType === 'element/checkModelInfo') {
        state = {
          masterData,
          userData: [],
          phaseData: [],
          conditionData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/checkPhaseInfo') {
        state = {
          masterData,
          sischeckphaselogininfoData: [],
          enabled: true,
        };
      } else if (sModelsType === 'sis/paymentTerms') {
        state = {
          masterData,
          enabled: true,
        };
      } else if (sModelsType === 'element/employeeInfo') {
        masterData.maxBillNo = 'sEmployeeNo';
        state = {
          masterData,
          enabled: true,
        };
      } else if (sModelsType === 'element/sisproductclassify') {
        masterData.maxBillNo = 'sNo';
        state = {
          masterData,
          sisproductclassifyProcessClassifyData: [],
          enabled: true,
        };
      } else if (sModelsType === 'smg/sendMailMsg') {
        // masterData.maxBillNo = 'sNo';
        state = {
          masterData,
          sysmsguserData: [],
          enabled: true,
        };
      } else if (sModelsType === 'sis/monthEndingClosing') {
        state = {
          masterData,
          enabled: true,
        };
      } else if (sModelsType === 'element/knifemouldInfo') { /* 刀模信息 */
        masterData.maxBillNo = 'sKnifeMouldNo';
        state = {
          masterData,
          eleknifemouldproductData: [],
          eleknifemouldfileData: [],
          enabled: true,
        };
      } else if (sModelsType === 'element/eleteststandInfo') { /* 检验标准 */
        masterData.maxBillNo = 'sTestNo';
        state = {
          masterData,
          eleteststandarditemData: [],
          enabled: true,
        };
      }
      state.sUseInfo = '';
      if (isWait) {
        return state;
      }
      this.props.onSaveState(state);
    };
    /** 表格数据更改 */
    // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
    handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
      /*   从CommonBase获取默认参数   */
      const {
        [`${name}Data`]: tableData, masterData: oldMasterData, sModelsType, app, sModelsId, token,
      } = this.props;
      let flag = true;
      const iIndex = tableData.findIndex(item => item.sId === sId);
      if (name === 'elemachine') {
        tableData.forEach((item, i) => {
          if (i !== iIndex && changeValue.sMachineId === item.sMachineId) {
            message.error(commonFunc.showMessage(app.commonConst, 'notMachineRepeat'));
            flag = false;
          }
        });
      }
      if (!flag) {
        return;
      }
      let tableDataRow = this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
      const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') ? 'Product' : 'Materials';
      tableData[iIndex] = commonBusiness.getCalculateAllMoney(app, models, sFieldName, oldMasterData, tableDataRow);
      const masterData = { ...oldMasterData };
      if (name === 'contact') {
        if (tableData[iIndex].bDefault === true) {
          if (commonUtils.isNotEmptyObject(tableData[iIndex].sContacts)) {
            masterData.sContacts = tableData[iIndex].sContacts;
          }
          if (commonUtils.isNotEmptyObject(tableData[iIndex].sPhone1)) {
            masterData.sPhone1 = tableData[iIndex].sPhone1;
          }
          if (commonUtils.isNotEmptyObject(tableData[iIndex].sMobile)) {
            masterData.sMobile = tableData[iIndex].sMobile;
          }
          if (commonUtils.isNotEmptyObject(tableData[iIndex].sEmail)) {
            masterData.sEmail = tableData[iIndex].sEmail;
          }
          masterData.handleType = masterData.handleType === 'add' ? 'add' : 'update';
          tableData.forEach((item, i) => {
            if (i !== iIndex) {
              tableData[i].bDefault = false;
            }
          });
        } else if (tableData[iIndex].bDefault === false) {
          masterData.handleType = masterData.handleType === 'add' ? 'add' : 'update';
        }
      } else if (name === 'address') {
        if (tableData[iIndex].bDefault === true) {
          masterData.csProvince_sCity_sArea = tableData[iIndex].csProvince_sCity_sArea;
          masterData.sCompanyAddress = tableData[iIndex].sDetailAddress;
          masterData.sProvince = tableData[iIndex].sProvince;
          masterData.sCity = tableData[iIndex].sCity;
          masterData.sArea = tableData[iIndex].sArea;
          masterData.handleType = masterData.handleType === 'add' ? 'add' : 'update';
          tableData.forEach((item, i) => {
            if (i !== iIndex) {
              tableData[i].bDefault = false;
            }
          });
        } else if (tableData[iIndex].bDefault === false) {
          masterData.handleType = masterData.handleType === 'add' ? 'add' : 'update';
        }
      } else if (name === 'elemachine') {
        if (tableData[iIndex].bDefault === true) {
          masterData.sMachineId = tableData[iIndex].sMachineId;
          masterData.handleType = masterData.handleType === 'add' ? 'add' : 'update';
        }
      } else if (name === 'stock') { /* 物料信息仓库中输入最大换算库存，最小换算库存时，调用handleMaterialsChange进行换算 */
        tableDataRow.dGramWeight = commonUtils.isNotEmptyNumber(masterData.dGramWeight) ? masterData.dGramWeight : 0;/* 拿到克重 */
        tableDataRow.dCoefficient = masterData.dCoefficient;/* 拿到换算系数 */
        tableDataRow.dGramWeight = commonUtils.isNotEmptyNumber(masterData.dGramWeight) ? masterData.dGramWeight : 0;/* 卷筒 */
        tableDataRow.bReel = masterData.bReel;
        tableDataRow.sMaterialsUnit = masterData.sMaterialsUnit;
        tableDataRow.sComputeId = masterData.sComputeId;
        tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models);
      } else if (name === 'brandgroup') {
        let { brandgroupOldData = [] } = this.props;
        const iIndex = brandgroupOldData.findIndex(item => item.sId === sId);
        if (iIndex !== -1) {
          brandgroupOldData[iIndex] = { ...brandgroupOldData[iIndex], ...tableDataRow };
          if (brandgroupOldData[iIndex].bDefault) {
            brandgroupOldData = brandgroupOldData.map((item, index) => {
              item.bDefault = index === iIndex;
              item.handleType = item.handleType || 'update';
              return item;
            });
          }
        }
        this.props.onSaveState({ brandgroupOldData, brandgroupData: brandgroupOldData });
        return;
      } else if (commonUtils.isNotEmptyStr(masterData.handleType)) {
        masterData.handleType = masterData.handleType === 'add' ? 'add' : 'update';
      }

      if (name.includes('customizeParam')) {
        tableData.forEach((item) => {
          item.sType = name;
        });
      }
      this.props.onSaveState({ [`${name}Data`]: tableData, masterData, enabled: true });
    };
    handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token) => {
      const { sComputeId } = tableDataRow;
      if (sFieldName === 'dMaxStockAuxiliaryQty' || sFieldName === 'sMaterialsStyle') {
        if (commonUtils.isEmpty(sComputeId)) {
          tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dMaxStockAuxiliaryQty', 'dMaxStock');
        } else {
          tableDataRow.dMaxStock = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId,
          });
        }
      }
      if (sFieldName === 'dMinStockAuxiliaryQty' || sFieldName === 'sMaterialsStyle') {
        if (commonUtils.isEmpty(sComputeId)) {
          tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dMinStockAuxiliaryQty', 'dMinStock');
        } else {
          tableDataRow.dMinStock = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId,
          });
        }
      }
      return tableDataRow;
    }

    /*  计算方案 计算公式设计点击事件  */
    handleButtonChange = (sName, value) => {
      /* 改变公示显示值 */
      const { masterData: masterDataOld } = this.props;
      const masterData = { ...masterDataOld };
      const sFormulaMemo = (Object.keys(masterData).length > 0 && masterData.sFormulaMemo !== undefined) ? masterData.sFormulaMemo : '';
      if (sName === 'systemFunction') {
        if (value === 'sysMaxInteger') {
          value = '最大整数(变量,0)';
        } else if (value === 'sysRounding') {
          value = '四舍五入(变量,0)';
        } else if (value === 'sysMinInteger') {
          value = '最小整数(变量,0)';
        }
      } else if (sName === 'bussinessFunction') {
        if (value === 'serviceMaterialsStocks') {
          value = '(材料名称,材料规格,仓库名称,自定义项)';
        } else if (value === 'serviceFinishedInventory') {
          value = '(成品名称,仓库名称,自定义项)';
        } else if (value === 'serviceMaterialCostPrice') {
          value = '(材料名称)';
        } else if (value === 'sysReceivable') {
          value = '应收账款([客户名称])';
        }
      }
      const changeFormula = `${sFormulaMemo}${value}`;
      masterData.sFormula = changeFormula;
      masterData.sFormulaMemo = changeFormula;
      masterData.handleType = masterData.handleType === 'add' ? 'add' : 'update';
      this.props.onSaveState({ masterData });
    };

    /** 修改主表数据 */
    handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData) => {
      const { sModelsType, masterConfig, formData } = this.props;
      const addState = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true);
      const masterDataAfter = commonBusiness.getKeyUpEvent(name, sFieldName, masterConfig, addState.masterData, {}, true);
      if (commonUtils.isNotEmptyObject(masterDataAfter)) {
        addState.masterData = masterDataAfter;
      }
      let { masterData } = addState;
      const { customerInfoData } = this.props;
      const { contactData } = this.props;
      if (sModelsType === 'system/sisformulaInfo') { // 计算方案信息
        if (sFieldName === 'sFormulaMemo') {
          masterData.sFormula = changeValue.sFormulaMemo;
        } else if (sFieldName === 'sColTitleName') {
          let { [sFieldName]: customizeParamConfig } = changeValue;
          if (commonUtils.isJSON(customizeParamConfig)) {
            customizeParamConfig = JSON.parse(customizeParamConfig);
            if (Array.isArray(customizeParamConfig)) { // 数组格式
              const customizeParamName = [];
              const userParamName = [];
              customizeParamConfig.forEach((config, index) => {
                const paramIndex = index === 0 ? '' : index;

                const customizePanelName = config.panelName ? config.panelName : `变量设置${paramIndex}`;
                addState[`customizePanelName${paramIndex}`] = customizePanelName;

                let customizeParamConfigNew = this.handleGetCustomizeParamConfig(masterData, config, index);
                customizeParamConfigNew = { ...customizeParamConfig, ...customizeParamConfigNew };
                if (commonUtils.isNotEmptyArr(customizeParamConfigNew)) {
                  addState[`customizeParam${paramIndex}Config`] = customizeParamConfigNew;
                  addState[`customizeParam${paramIndex}Column`] = commonFunc.getHeaderConfig(customizeParamConfigNew);
                  addState.tableKey = commonUtils.createSid();
                  customizeParamName.push(`customizeParam${paramIndex}`);
                  userParamName.push(`userParam${paramIndex}`);

                  const userParamConfig = JSON.parse(JSON.stringify(customizeParamConfigNew));
                  addState[`userParam${paramIndex}Config`] = userParamConfig;
                  if (commonUtils.isNotEmptyArr(userParamConfig.gdsconfigformslave)) {
                    userParamConfig.gdsconfigformslave.forEach((item) => {
                      // if (item.sName.indexOf('sValue') === -1) { /* 除了参数值 其他均不可修改 */
                      //   item.iTag = 1;
                      // }
                      if (item.sName === 'sParam') {
                        item.bVisible = false;
                      }
                    });
                  }
                  addState[`userParam${paramIndex}Column`] = commonFunc.getHeaderConfig(userParamConfig);
                }
              });
              addState.customizeParamName = customizeParamName;
              addState.userParamName = userParamName;
            } else { // json格式
              const customizeParamConfigNew = this.handleGetCustomizeParamConfig(masterData, customizeParamConfig);
              if (commonUtils.isNotEmptyObject(customizeParamConfigNew)) {
                if (commonUtils.isNotEmptyStr(customizeParamConfig.panelName)) {
                  addState.customizePanelName = customizeParamConfig.panelName;
                }
                addState.customizeParamConfig = customizeParamConfigNew;
                addState.customizeParamColumn = commonFunc.getHeaderConfig(customizeParamConfigNew);
                addState.tableKey = commonUtils.createSid();
                addState.customizeParamName = [];
                addState.userParamName = [];
              }
            }
          } else {
            addState.tableKey = commonUtils.createSid();
            addState.customizeParamName = [];
            addState.userParamName = [];
            addState.customizePanelName = '';
            customizeParamConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizeparam')) ? formData.filter(item => item.bGrd && item.sTbName === 'sisformulacustomizeparam')[0] : {};
            addState.customizeParamColumn = commonFunc.getHeaderConfig(customizeParamConfig);
          }

          // if (commonUtils.isNotEmptyObject(customizeParamConfig)) {
          //   customizeParamColumn = commonFunc.getHeaderConfig(customizeParamConfig);
          // }
        }
      } else if (sModelsType === 'sis/paymentTerms' && sFieldName === 'sType') {
        const { rowGdsconfig } = masterConfig;
        const newMasterData = {};
        newMasterData.handleType = masterData.handleType;
        newMasterData.sFormId = masterData.sFormId;
        newMasterData.sId = masterData.sId;
        newMasterData.sName = masterData.sName;
        newMasterData.sType = masterData.sType;

        if (changeValue.sType === 'deliver') {
          newMasterData.iAfterDeliverDay = masterData.iAfterDeliverDay;
          const threeRow = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName === 'iAfterDeliverDay');
          if (rowGdsconfig.length > 2) {
            rowGdsconfig.splice(2, 1, { gdsconfigformslave: threeRow });
          } else {
            rowGdsconfig.push({ gdsconfigformslave: threeRow });
          }
        } else if (changeValue.sType === 'month') {
          newMasterData.iDay = masterData.iDay;
          newMasterData.iMonth = masterData.iMonth;
          const threeRow = masterConfig.gdsconfigformslave.filter(item => item.bVisible && (item.sName === 'iMonth' || item.sName === 'iDay'));
          if (rowGdsconfig.length > 2) {
            rowGdsconfig.splice(2, 1, { gdsconfigformslave: threeRow });
          } else {
            rowGdsconfig.push({ gdsconfigformslave: threeRow });
          }
        } else if (rowGdsconfig.length > 2) {
          rowGdsconfig.splice(2, 1);
        }
        masterData = newMasterData;
      } else if (sModelsType === 'element/materialsInfo' && sFieldName === 'sMaterialsType') {
        const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'dGramWeight');
        if (changeValue[sFieldName] === 'paper') { /* 物料类别为纸张的时候,克重必填 */
          masterConfig.gdsconfigformslave[iIndex].bNotEmpty = true;
        } else {
          masterConfig.gdsconfigformslave[iIndex].bNotEmpty = false;
        }
      } else if (sModelsType === 'element/sisproductclassify' && sFieldName === 'sAllPartsName') {
        const sisproductclassifyProcessClassifyConfig = this.handleChangeProductParteName(changeValue.sAllPartsName);
        if (sisproductclassifyProcessClassifyConfig !== undefined) {
          addState.sisproductclassifyProcessClassifyConfig = sisproductclassifyProcessClassifyConfig;
        }
      } else if (sModelsType === 'element/printInfo' && sFieldName === 'sCustomerId') {
        if (customerInfoData.length === 1 && commonUtils.isEmptyArr(customerInfoData[0].sCustomerId)) {
          customerInfoData[0].sCustomerId = masterData.sCustomerId;
        }
      } else if (sModelsType === 'element/eleteststandInfo' && sFieldName === 'sTestType') { /* 检验类型选择工序检验时，工序名称出现 */
        const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
        if (iIndex > -1) {
          if (commonUtils.isNotEmptyObject(masterData[sFieldName]) && masterData[sFieldName] === '2') {
            masterConfig.gdsconfigformslave[iIndex].bVisible = true;
          } else {
            masterConfig.gdsconfigformslave[iIndex].bVisible = false;
          }
        }
      } else if (sModelsType === 'smg/sendMailMsg' && sFieldName === 'sDepartName') { /* 选择部门时，加载部门人员 */
        const { sModelsId } = this.props;
        const sDepartNameStr = changeValue.sDepartName;
        const sDepartNameArr = sDepartNameStr.split(',');
        // const dropdownData = commonUtils.getStoreDropDownData(sModelsId, name, 'sUserIds');/* 筛选所有人员 */
        let dropdownData;
        const slaveIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sUserIds');
        if (slaveIndex > -1) {
          const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, name, masterConfig.gdsconfigformslave[slaveIndex]);
          dropdownData = sqlDropDownData.dropDownData;
        }
        let sUserArrsTemp = [];
        const sUserArrs = [];
        if (commonUtils.isNotEmptyArr(sDepartNameArr)) {
          sDepartNameArr.forEach((sDepId) => {
            const filterData = dropdownData.filter(item => item.sDepartId === sDepId);
            sUserArrsTemp = filterData.concat(sUserArrsTemp);
          });
          sUserArrsTemp.forEach((item) => {
            sUserArrs.push(item.sId);
          });
          masterData.sUserIds = sUserArrs;
        }
      } else if (sModelsType === 'element/customerInfo' || sModelsType === 'element/supplyInfo') { /* 选择客户、供应商 */
        if (sFieldName === 'sContacts' || sFieldName === 'sPhone1' || sFieldName === 'sMobile' || sFieldName === 'sEmail') {
          if (commonUtils.isNotEmptyArr(contactData)) { /* 从表不为空，且有默认行 */
            const iIndex = contactData.findIndex(item => item.bDefault);
            if (iIndex > -1) {
              const tableDataRow = contactData[iIndex];
              if (sFieldName !== 'sContacts' && commonUtils.isEmptyObject(tableDataRow.sContacts)) {
                return;
              }
              if (commonUtils.isNotEmptyObject(tableDataRow)) {
                contactData[iIndex] = { ...tableDataRow, [sFieldName]: changeValue[sFieldName] };
              }
            }
          }
        }
      } else if (sModelsType === 'element/machineInfo' && sFieldName === 'iPlcNo') {
        this.handleGetplcMachineData(changeValue[sFieldName]);
      }
      this.props.onSaveState({
        masterData, masterConfig, customerInfoData, ...addState, contactData, enabled: sModelsType === 'system/sisformulaInfo' ? this.props.enabled : true, bUserModel: masterData.bUserModel,
      }, () => {
        this.masterChangeCb && this.masterChangeCb();
        this.masterChangeCb = null;
      });
    };
    handleChangeProductParteName = (sAllPartsName, sisproductclassifyProcessClassifyConfigNew) => {
      const { sisproductclassifyProcessClassifyConfig: sisproductclassifyProcessClassifyConfigOld } = this.props;
      if (commonUtils.isNotEmptyObject(sAllPartsName)) {
        let sisproductclassifyProcessClassifyConfig;
        if (commonUtils.isNotEmptyObject(sisproductclassifyProcessClassifyConfigNew)) {
          sisproductclassifyProcessClassifyConfig = JSON.parse(JSON.stringify(sisproductclassifyProcessClassifyConfigNew));
        } else {
          sisproductclassifyProcessClassifyConfig = JSON.parse(JSON.stringify(sisproductclassifyProcessClassifyConfigOld));
        }
        const sAllPartsArray = sAllPartsName.split(',');
        const gdsconfigformslave = sisproductclassifyProcessClassifyConfig.gdsconfigformslave;
        const iIndex = gdsconfigformslave.findIndex(item => item.sName === 'sPartsName');
        if (iIndex > -1) {
          const sAllPartsConfig = gdsconfigformslave.filter(item => item.sName === 'sPartsName')[0];
          if (commonUtils.isNotEmptyObject(sAllPartsConfig)) {
            const showDropDownNew = [];
            sAllPartsArray.forEach((item) => {
              showDropDownNew.push({ sId: item, value: item });
            });
            showDropDownNew.push({ sId: '', value: '全部组件' });
            // sisproductclassifyProcessClassifyConfig.gdsconfigformslave[iIndex].dropDownData = showDropDownNew;
            // return sisproductclassifyProcessClassifyConfig;
            sisproductclassifyProcessClassifyConfig.gdsconfigformslave[iIndex] = { ...sisproductclassifyProcessClassifyConfig.gdsconfigformslave[iIndex], dropDownData: showDropDownNew, showDropDown: showDropDownNew };
            return sisproductclassifyProcessClassifyConfig;
          }
        }
      }
    };
    /* 计算方案 校验公式 功能 */
    handleField = async () => {
      let bResult = true;
      const {
        sModelsId, masterData, sModelsType, customizeParamData,
      } = this.props;
      if (sModelsType === 'system/sisformulaInfo') {
        const { sType, sFormula } = masterData;
        /* 公式中，如果公式分类为放损公式时，公式中有 [投入数] 提示公式验证错误，不允许使用投入数 */
        if (commonUtils.isNotEmptyObject(sFormula) && sType === 'loss' && sFormula.includes('投入数')) {
          bResult = false;
          message.error('公式验证错误，不允许使用投入数!');
          return bResult;
        }
        let sFormulaSet = ''; /* 公式自定义部分 */
        if (commonUtils.isNotEmptyArr(customizeParamData)) {
          if (commonUtils.isNotEmptyObject(masterData.sColTitleName)) { /* 有自定义列名 则变量名代码生成 */
            const regex = /^customizeParam(?:\d+)?Data$/;
            Object.keys(this.props).filter(key => regex.test(key)).forEach((key) => {
              const tableName = key.split('Data')[0];
              const lastChar = tableName.charAt(tableName.length - 1);
              const firstChar = this.handleGetFirstChar(lastChar);
              const tempData = this.props[key];
              tempData.forEach((item, index) => {
                for (const key of Object.keys(item)) {
                  if (key.includes('sValue')) {
                    const sParam = `${firstChar}${index}_${key}`;
                    let keyValue = item[key];
                    if (commonUtils.isEmpty(keyValue)) {
                      keyValue = '0';
                    }
                    const sFormulaSetRow = `SET @${sParam}:=${keyValue};`;
                    sFormulaSet += sFormulaSetRow;
                  }
                }
              });
            });
            // customizeParamData.forEach((item, index) => {
            //   for (const key of Object.keys(item)) {
            //     if (key.includes('sValue')) {
            //       const sParam = `R${index}_${key}`;
            //       let keyValue = item[key];
            //       if (commonUtils.isEmpty(keyValue)) {
            //         keyValue = '0';
            //       }
            //       const sFormulaSetRow = `SET @${sParam}:=${keyValue};`;
            //       sFormulaSet += sFormulaSetRow;
            //     }
            //   }
            // });
          } else {
            customizeParamData.forEach((item) => { /* 没有自定义列名 维持原来 */
              const sFormulaSetRow = `SET @${item.sParam}:=${item.sValue};`;
              sFormulaSet += sFormulaSetRow;
            });
          }
        }
        const { token } = this.props.app;
        const value = {
          handleType: 'check',
          sFormulaText: masterData.sFormulaMemo,
          sisformulacustomizeparam: customizeParamData,
          sFormulaSet,
          sClientType: '1',

        };
        const dataUrl = `${commonConfig.server_host}replaceField/checkReplaceField?sModelsId=${sModelsId}`;
        const { data } = await commonServices.postValueService(token, value, dataUrl);
        if (data.code === 1) {
          message.success(data.msg);
          bResult = true;
        } else {
          this.props.getServiceError(data);
          bResult = false;
        }
      }
      return bResult;
    };

    handleGetFirstChar = (lastChar) => {
      let firstChar = 'R';
      switch (lastChar) {
        case '1':
          firstChar = 'S';
          break;
        case '2':
          firstChar = 'T';
          break;
        case '3':
          firstChar = 'U';
          break;
        case '4':
          firstChar = 'V';
          break;
        case '5':
          firstChar = 'W';
          break;
        case '6':
          firstChar = 'X';
          break;
        case '7':
          firstChar = 'Y';
          break;
        case '8':
          firstChar = 'Z';
          break;
        case '9':
          firstChar = 'A';
          break;
        case '0':
          firstChar = 'B';
          break;
        default:
          break;
      }
      return firstChar;
    }

    /**   添加表格空行   */
    handleTableAdd = (name, isWait) => {
      /*   从CommonBase获取默认参数   */
      const {
        masterData, masterConfig, sModelsType, gdsformconst,
      } = this.props;
      let { [`${name}Data`]: tableData } = this.props;
      let tableDataRow = this.props.onDataRowAdd(name, true);
      /*   添加行的业务处理拿出去   */
      if (sModelsType.includes('sales/')) {
        if (commonUtils.isEmptyStr(masterData.sCustomerId)) {
          const iIndex = masterConfig.gdsconfigformslave.findIndex(item => (item.sName === 'sCustomerId' && item.bVisible));
          if (iIndex > -1) {
            const { showName } = masterConfig.gdsconfigformslave[iIndex];
            message.warn(showName + commonFunc.showMessage(gdsformconst, 'isNotNull')); // 不能为空
            tableDataRow = {};
          }
        }
      }
      const { formId } = this.props.app.currentPane;
      if (sModelsType === 'element/materialsInfo') {
        tableDataRow.sFormId = formId;
        tableDataRow.sMaterialsId = masterData.sId;
      } else if (sModelsType === 'element/printInfo') {
        tableDataRow.sFormId = formId;
        tableDataRow.sProductId = masterData.sId;
        tableDataRow.sCustomerId = masterData.sCustomerId;
        /* 产品信息-客户信息页签新增第一行时，将主表客户添加到客户名称中 */
        if (name === 'customerInfo') {
          if (tableData.length === 0) {
            tableDataRow.sCustomerName = masterData.sCustomerName;
            tableDataRow.sCustomerNo = masterData.sCustomerNo;
          }
        }
      }
      if (name === 'report') {
        tableDataRow.sFormId = formId;
      }
      if (isWait) {
        return tableDataRow;
      } else if (commonUtils.isNotEmptyObject(tableDataRow)) {
        if (commonUtils.isEmptyArr(tableData)) {
          tableData = [];
        }
        tableData.push(tableDataRow);
        this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}Pagination`]: { total: tableData.length, current: 9999 } });
      }
    };
    /**   删除表格行   */
    handleTableDel = (name, flag, tableSelectedRowKeys) => {
      const { sModelsType } = this.props;
      let { masterData } = this.props;
      const masterNewData = {};
      const rtval = this.props.onDataRowDel(name, true, tableSelectedRowKeys);
      const { [`${name}DelData`]: tableDelData } = rtval;
      if (sModelsType === 'element/teamInfo') {
        if (name === 'elemachine' && commonUtils.isNotEmptyArr(tableDelData)) {
          for (const delData of tableDelData) {
            if (delData.bDefault && delData.sMachineId === masterData.sMachineId) {
              masterNewData.sMachineId = '';
              masterNewData.handleType = masterData.handleType !== 'add' ? 'update' : 'add';
              break;
            }
          }
        }
      } else if (sModelsType === 'element/customerInfo') {
        if (name === 'address' && commonUtils.isNotEmptyArr(tableDelData)) {
          const { [`${name}Data`]: tableData } = rtval;
          if (commonUtils.isNotEmptyArr(tableData) && tableData.length === 1) {
            const addState = {};
            addState.bDefault = true;
            masterNewData.csProvince_sCity_sArea = tableData[0].csProvince_sCity_sArea;
            masterNewData.sCompanyAddress = tableData[0].sDetailAddress;
            masterNewData.sProvince = tableData[0].sProvince;
            masterNewData.sCity = tableData[0].sCity;
            masterNewData.sArea = tableData[0].sArea;
            tableData[0] = { ...tableData[0], ...addState };/* 只有最后一行时，设置默认地址 */
          } else {
            masterNewData.csProvince_sCity_sArea = '';
            masterNewData.sCompanyAddress = '';
            masterNewData.sProvince = '';
            masterNewData.sCity = '';
            masterNewData.sArea = '';
          }
          masterNewData.handleType = masterData.handleType !== 'add' ? 'update' : 'add';
        }
      }
      masterData = { ...masterData, ...masterNewData };
      this.props.onSaveState({ ...rtval, masterData });
    };
    /*   基础信息复制到   */

    handleCopyTo = (name) => {
      /*   待用数据声明   */
      const {
        dispatch, masterConfig, masterData, sModelsId, sModelsType, contactData, addressData,
        sisproductclassifyProcessClassifyData, machineData, assortData, outsideData, processstyleData, processApsRuleData, dynamicParamData,
        eleemployeeData, elemachineData, eleknifemouldproductData, eleknifemouldfileData, eleteststandarditemData, app, customizeParamData,
      } = this.props;
      const { pages } = app.currentPane; /* 传递pages */
      const copyTo = {};
      const copyToConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes(name));
      copyTo.name = name;
      copyTo.config = copyToConfig;
      copyTo.masterData = masterData;
      if (sModelsType === 'element/materialsInfo') {
        copyTo.supplyData = [];
        copyTo.stockData = [];
      } else if (sModelsType === 'element/customerInfo') {
        const addStata = {};
        addStata.bCheck = true;
        copyTo.masterData = { ...masterData, ...addStata };
        copyTo.contactData = contactData;
        copyTo.addressData = addressData;
      } else if (sModelsType === 'element/printInfo') {
        copyTo.picFileData = [];
        copyTo.stockData = [];
        copyTo.customerInfoData = [];
      } else if (sModelsType === 'element/sisproductclassify') {
        if (commonUtils.isNotEmptyArr(sisproductclassifyProcessClassifyData)) {
          copyTo.sisproductclassifyProcessClassifyData = sisproductclassifyProcessClassifyData;
        }
      } else if (sModelsType === 'element/processInfo') {
        copyTo.machineData = machineData;
        copyTo.assortData = assortData;
        copyTo.outsideData = outsideData;
        copyTo.processstyleData = processstyleData;
        copyTo.processApsRuleData = processApsRuleData;
        copyTo.dynamicParamData = dynamicParamData;
      } else if (sModelsType === 'element/supplyInfo') {
        copyTo.contactData = contactData;
        copyTo.addressData = addressData;
      } else if (sModelsType === 'element/teamInfo') {
        copyTo.eleemployeeData = eleemployeeData;
        copyTo.elemachineData = elemachineData;
      } else if (sModelsType === 'element/knifemouldInfo') {
        copyTo.eleknifemouldproductData = eleknifemouldproductData;
        copyTo.eleknifemouldfileData = eleknifemouldfileData;
        /**
         * 修改日期：2021-04-23
         * 修改人：吕杰
         * 区域：以下 2 行
         * BUG：
         * 说明：孟总需求，刀版复制到不需要刀版编号，刀版编号赋值给原刀版编号（sSrcKnifeMouldNo）
         * 原代码：
         */
        copyTo.masterData.sSrcKnifeMouldNo = copyTo.masterData.sKnifeMouldNo;
        copyTo.masterData.sKnifeMouldNo = undefined;
      } else if (sModelsType === 'element/eleteststandInfo') {
        copyTo.eleteststandarditemData = eleteststandarditemData;
      } else if (sModelsType === 'system/sisformulaInfo') { /* 计算方案复制到功能 */
        copyTo.customizeParamData = customizeParamData;
      }
      dispatch({
        type: 'content/onRouter',
        payload: {
          url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sModelsId}?sModelsId=${sModelsId}`, /*   接口地址   */
          copyTo,
          pages,
        },
      });
    };
    handleTableSelectRowChange = (name, selectedRowKeys, bCheckBoxClick) => {
      const {
        sModelsType, [`${name}OldData`]: oldData, masterData, enabled,
      } = this.props;
      if (sModelsType === 'element/sftloginInfo') {
        if (!enabled) {
          message.warn('请先点击修改！');
          return;
        }
        if (name === 'brandgroup') {
          if (!bCheckBoxClick) return;
          let { brandgroupOldData = [] } = this.props;
          brandgroupOldData = brandgroupOldData.map((item) => {
            item.iCheck = selectedRowKeys.includes(item.sId);
            item.handleType = item.handleType || 'update';
            return item;
          });
          this.props.onSaveState({ brandgroupOldData, brandgroupData: brandgroupOldData, brandgroupSelectedRowKeys: selectedRowKeys });
          return;
        }
        const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true);
        const { [`${name}SelectedRowKeys`]: rowKeys } = addState;
        if (oldData.length > 0) {
          const allTableData = {};
          allTableData.master = masterData;
          // const tableDataRowOld = commonFunc.getDefaultData(tableConfig, allTableData);
          const delKeys = [];
          const addkeys = JSON.parse(JSON.stringify(rowKeys));
          for (const item of oldData) {
            let index = '';
            if (name === 'jurgroup') {
              index = addkeys.indexOf(item.sJurisdictionClassifyId);
            }
            if (name === 'customergroup') {
              index = addkeys.indexOf(item.sSalesManId);
            }
            if (name === 'supplygroup') {
              index = addkeys.indexOf(item.sPurchaseManId);
            }
            if (name === 'persongroup') {
              index = addkeys.indexOf(item.sEmployeeId);
            }
            if (name === 'processgroup') {
              index = addkeys.indexOf(item.sProcessClassifyId);
            }
            if (name === 'drivergroup') {
              index = addkeys.indexOf(item.sDriverId);
            }
            if (name === 'departgroup') {
              index = addkeys.indexOf(item.sDepartId);
            }
            if (name === 'approveGroup') {
              index = addkeys.indexOf(item.sJurisdictionClassifyId);
            }

            if (index === -1) {
              delKeys.push(item.sId);
            } else if (index > -1) {
              addkeys.splice(index, 1);
            }
          }
          if (commonUtils.isNotEmptyArr(delKeys)) {
            if (name === 'jurgroup') {
              this.handleTableDel('jurgroupOld', false, delKeys);
            }
            if (name === 'customergroup') {
              this.handleTableDel('customergroupOld', false, delKeys);
            }
            if (name === 'supplygroup') {
              this.handleTableDel('supplygroupOld', false, delKeys);
            }
            if (name === 'persongroup') {
              this.handleTableDel('persongroupOld', false, delKeys);
            }
            if (name === 'processgroup') {
              this.handleTableDel('processgroupOld', false, delKeys);
            }
            if (name === 'drivergroup') {
              this.handleTableDel('drivergroupOld', false, delKeys);
            }
            if (name === 'departgroup') {
              this.handleTableDel('departgroupOld', false, delKeys);
            }
            if (name === 'approveGroup') {
              this.handleTableDel('approveGroupOld', false, delKeys);
            }
          }
          if (commonUtils.isNotEmptyArr(addkeys)) {
            for (const key of addkeys) {
              const tableDataRow = {};
              tableDataRow.handleType = 'add';
              tableDataRow.sId = commonUtils.createSid();
              tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
              tableDataRow.key = tableDataRow.sId;
              tableDataRow.bDefault = false;
              tableDataRow.iOrder = oldData ? oldData.length : 0;
              tableDataRow.defaultAdded = oldData.length === 0;
              if (name === 'jurgroup') {
                tableDataRow.sJurisdictionClassifyId = key;
              }
              if (name === 'customergroup') {
                tableDataRow.sSalesManId = key;
              }
              if (name === 'supplygroup') {
                tableDataRow.sPurchaseManId = key;
              }
              if (name === 'persongroup') {
                tableDataRow.sEmployeeId = key;
              }
              if (name === 'processgroup') {
                tableDataRow.sProcessClassifyId = key;
              }
              if (name === 'drivergroup') {
                tableDataRow.sDriverId = key;
              }
              if (name === 'departgroup') {
                tableDataRow.sDepartId = key;
              }
              if (name === 'approveGroup') {
                tableDataRow.sJurisdictionClassifyId = key;
              }
              oldData.push(tableDataRow);
            }
          }
        }
        if (oldData.length === 0) {
          const allTableData = {};
          allTableData.master = masterData;
          // const tableDataRow = commonFunc.getDefaultData(tableConfig, allTableData);
          for (const item of rowKeys) {
            const tableDataRow = {};
            tableDataRow.handleType = 'add';
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
            tableDataRow.key = tableDataRow.sId;
            tableDataRow.bDefault = false;
            tableDataRow.iOrder = oldData ? oldData.length : 0;
            tableDataRow.defaultAdded = oldData.length === 0;
            tableDataRow.sJurisdictionClassifyId = item;
            if (name === 'jurgroup') {
              tableDataRow.sJurisdictionClassifyId = item;
            }
            if (name === 'customergroup') {
              tableDataRow.sSalesManId = item;
            }
            if (name === 'supplygroup') {
              tableDataRow.sPurchaseManId = item;
            }
            if (name === 'persongroup') {
              tableDataRow.sEmployeeId = item;
            }
            if (name === 'processgroup') {
              tableDataRow.sProcessClassifyId = item;
            }
            if (name === 'drivergroup') {
              tableDataRow.sDriverId = item;
            }
            if (name === 'departgroup') {
              tableDataRow.sDepartId = item;
            }
            if (name === 'approveGroup') {
              tableDataRow.sJurisdictionClassifyId = item;
            }
            oldData.push(tableDataRow);
          }
        }
        this.props.onSaveState(addState, oldData);
      } else {
        this.props.onTableSelectRowChange(name, selectedRowKeys);
      }
    };

    /**   复制   */
    handleTableCopy = (name, isWait) => {
      const {
        [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, app,
      } = this.props;
      if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseCopyData'));/* 请选择复制数据 */
      } else {
        for (const sId of tableSelectedRowKeys) {
          const tableDataIndex = tableData.findIndex(item => item.sId === sId);
          if (tableDataIndex > -1) {
            const tableDataRow = JSON.parse(JSON.stringify(tableData[tableDataIndex]));
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.handleType = 'add';
            tableDataRow.key = tableDataRow.sId;
            tableDataRow.sSrcSlaveId = '';
            tableDataRow.sSrcId = '';
            tableDataRow.dSrcQty = null;
            const iOrderArr = [];
            tableData.forEach((item) => {
              const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
              iOrderArr.push(iOrder);
            });
            const iOrderMax = Math.max(...iOrderArr);
            tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 1;
            if (isWait) {
              return tableDataRow;
            } else if (commonUtils.isNotEmptyObject(tableDataRow)) {
              tableData.push(tableDataRow);
              this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}Pagination`]: { total: tableData.length, current: 9999 } });
            }
          }
        }
      }
    };

    /**   复制全部   */
    handleTableCopyAll = (name, isWait) => {
      const {
        [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, app,
      } = this.props;
      if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseCopyData'));/* 请选择复制数据 */
      } else {
        for (const sId of tableSelectedRowKeys) {
          const tableDataIndex = tableData.findIndex(item => item.sId === sId);
          if (tableDataIndex > -1) {
            const tableDataRow = JSON.parse(JSON.stringify(tableData[tableDataIndex]));
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.handleType = 'add';
            tableDataRow.key = tableDataRow.sId;
            if (isWait) {
              return tableDataRow;
            } else if (commonUtils.isNotEmptyObject(tableDataRow)) {
              tableData.push(tableDataRow);
              this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}Pagination`]: { total: tableData.length, current: 9999 } });
            }
          }
        }
      }
    };

    /* 导出Excel */
    handleOut = async () => {
      const {
        eleemployeeConfig, formRoute, masterData,
      } = this.props;

      /* 导出使用Post提交 */
      const url = `${commonConfig.server_host}excel/export/${eleemployeeConfig.sId}?sModelsId=${eleemployeeConfig.sParentId}&sName=${formRoute}&token=${encodeURIComponent(this.props.app.token)}`;
      const conditionValuesStr = JSON.stringify({ sId: masterData?.sId, sBillNo: masterData?.sBillNo });
      this.handleOpenOut(url, '', '', undefined, conditionValuesStr);
    };

    /* Get提交地址栏参数过多,更改Get提交为Post提交 */
    handleOpenOut = (url, bFilter, slaveOrderBy, sGroupByList, conditionValues) => {
      const newWin = window.open();
      let formStr = '';
      // 设置样式为隐藏，打开新标签再跳转页面前，如果有可现实的表单选项，用户会看到表单内容数据
      formStr = `<form style="visibility:hidden;" method="POST" action="${url}">` +
        `<input type="hidden" name="bFilter" value='${bFilter}' />`;
      if (commonUtils.isNotEmptyObject(conditionValues)) {
        formStr += `<input type="hidden" name="sSqlCondition" value='${conditionValues}' />`;
      }
      formStr += '</form>';
      newWin.document.body.innerHTML = formStr;
      newWin.document.forms[0].submit();
      return newWin;
    }

    // 导入模版功能
    handleImportExcel = () => {
      const fileInput = document.createElement('input');
      fileInput.type = 'file';
      fileInput.accept = '.xlsx, .xls';
      fileInput.style.position = 'fixed';
      fileInput.style.left = '-9999px';
      document.body.appendChild(fileInput);

      fileInput.addEventListener('change', (e) => {
        const file = e.target.files[0];
        if (file) {
          if (!file) return;

          const reader = new FileReader();
          reader.readAsArrayBuffer(file);
          reader.onload = (evt) => {
            try {
              const data = evt.target.result;
              const workbook = XLSX.read(data, { type: 'binary' });
              const sColTitleName = [];
              workbook.SheetNames.forEach((sheetName, i) => {
                const sheet = workbook.Sheets[sheetName];
                const parsedData = XLSX.utils.sheet_to_json(sheet, { header: 1 });
                const [firstRow, ...restRows] = parsedData;
                sColTitleName.push(firstRow.reduce((pre, item, index) => {
                  if (index === 0) {
                    pre.sName = item.replace('sName', '');
                  } else if (item.endsWith('sName')) {
                    pre[`sName${index}`] = item.replace('sName', '');
                  } else {
                    pre[`sValue${index}`] = item;
                  }
                  return pre;
                }, { panelName: sheetName }));
              });
              this.masterChangeCb = () => {
                const addState = {};
                workbook.SheetNames.forEach((sheetName, i) => {
                  const sheet = workbook.Sheets[sheetName];
                  const parsedData = XLSX.utils.sheet_to_json(sheet, { header: 1 });
                  const [firstRow, ...restRows] = parsedData;
                  const tableName = `customizeParam${i || ''}`;
                  let { [`${tableName}Data`]: tableData = [], [`${tableName}DelData`]: tableDelData = [] } = this.props;
                  tableDelData = [...tableDelData, ...tableData.map(item => ({ ...item, handleType: 'del' }))];
                  tableData = restRows.map(item => {
                    const columnKeys = Object.keys(sColTitleName[i]);
                    columnKeys.shift();
                    return { ...this.handleTableAdd(tableName, true), ...item.reduce((pre, cur, index) => {
                      pre[columnKeys[index]] = cur;
                      return pre;
                    }, { sType: tableName }) };
                  });
                  addState[`${tableName}Data`] = tableData;
                  addState[`${tableName}DelData`] = tableDelData;
                });
                this.props.onSaveState(addState);
              };
              this.handleMasterChange('masterData', 'sColTitleName', { sColTitleName: JSON.stringify(sColTitleName) }, undefined, []);
            } catch (error) {
              console.log('=====err', error);
              message.error('文件格式错误');
            }
          };
        }

        document.body.removeChild(fileInput);
      });

      fileInput.click();
    }

    /* 按钮点击功能  */
    handleBtnClick = (e, btnName) => {
      if (btnName === 'BtnAccounts') {
        this.handleSettleSccounts();
      } else if (e === 'BtnDesignFunction') { /* 设计报表打印 */
        this.handleDesignFunction();
      } else if (e === 'BtnResetpwd') { /* 管理员重置密码 */
        this.handleResetPwd();
      } else if (e === 'BtnOut') {
        this.handleOut();
      } else if (e === 'BtnImportExcel') { // 导入Excel模版
        this.handleImportExcel();
      }
      // else if (e === 'BtnConfigCustomizeParam') { /* 生成变量设置 */
      //   const { masterData, customizeParamConfig } = this.props;
      //   const customizeParamConfigNew = this.handleGetCustomizeParamConfig(masterData, customizeParamConfig);
      //   if (commonUtils.isNotEmptyObject(customizeParamConfigNew)) {
      //     const customizeParamColumnNew = commonFunc.getHeaderConfig(customizeParamConfigNew);
      //     const userParamColumn = commonFunc.getHeaderConfig(customizeParamConfigNew);
      //     this.props.onSaveState({
      //       customizeParamConfig: customizeParamConfigNew, customizeParamColumn: customizeParamColumnNew, userParamConfig: customizeParamConfigNew, userParamColumn,
      //     });
      //   }
      // }
    };

    /**   获取应收账款   */
    handleSettleSccounts = async () => {
      const { sModelsId, masterData } = this.props;
      if (!commonUtils.isEmpty(masterData.mclosingDate)) {
        const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
        const value = { sProName: 'Sp_System_AutoMaterialsPriceSingle_new', paramsMap: { } };
        const dataReturn = (await commonServices.postValueService(this.props.app.token, value, url)).data;
        if (dataReturn.code === 1) {
          /* 数据查询成功 */
          this.props.onSaveState({ masterData: masterDataNew });
        } else { /*   失败   */
          this.props.getServiceError(dataReturn);
        }
      }
    };
    /* 设计报表功能 */
    handleDesignFunction = () => {
      this.props.onSaveState({ visibleStatement: true });
    };
    handleBtnPrint = (sActiveId) => {
      const {
        app, sModelsId, masterConfig, masterData, reportData,
      } = this.props;
      const { token } = app;
      const queryFilter = {};
      queryFilter[masterConfig.sId] = { sId: masterData.sId };
      queryFilter.getType = 'BaseReport';
      const queryFilterJson = escape(JSON.stringify(queryFilter));
      /* 拿到打印报表名称 */
      let printReportName = 'report';
      if (commonUtils.isNotEmptyArr(reportData)) {
        const iIndex = reportData.findIndex(item => item.sId === sActiveId);
        if (iIndex > -1) {
          printReportName = reportData[iIndex].sReportName;
        }
      }
      const urlPrint = `${commonConfig.file_host}printReport/printPdf/${sActiveId}/${printReportName}.pdf?queryFilter=${queryFilterJson}&sModelsId=${sModelsId}&sMaintableId=${masterConfig.sId}&token=${encodeURIComponent(token)}`;
      window.open(urlPrint);
    };
    /* 重置密码 重置人退出系统 */
    handleResetPwdOut = () => {
      const { masterData, dispatch } = this.props;
      const { sId } = masterData;
      if (commonUtils.isNotEmptyObject(sId)) {
        const url = `${commonConfig.server_host}sftlogininfo/updatePasswordUserName/reset?sModelsId=${100}&sId=${sId}`;
        const value = {};
        value.sId = sId;
        dispatch({ type: 'app/resetPwd', payload: { url, value } });
      }
    };

    /* 重置别人密码 重置人不退出系统 */
    handleResetPwd = async () => {
      const { masterData, app } = this.props;
      const { sId } = masterData;
      if (commonUtils.isNotEmptyObject(sId)) {
        const url = `${commonConfig.server_host}sftlogininfo/updatePasswordUserName/reset?sModelsId=${100}&sId=${sId}`;
        const value = {};
        value.sId = sId;
        const dataReturn = (await commonServices.postValueService(app.token, value, url)).data;
        if (dataReturn.code === 1) {
          message.success(dataReturn.msg);
        } else {
          this.props.getServiceError(dataReturn);
        }
      }
    };
    handleTitleChange = (slavePagination) => {
      this.props.onSaveState({ slavePagination });
    };
    render() {
      const { masterData, sModelsType, app  } = this.props;
      const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app );
      return (
        <ChildComponent
          {...this.props}
          {...this.state}
          onToggle={this.handleToggle}
          onAdd={this.handleAdd}
          onCancel={this.handleCancel}
          onEdit={this.handleEdit}
          onDel={this.handleDel}
          onSubmit={this.handleValidateSave}
          onReturnForm={this.handleForm}
          onTitleChange={this.handleTitleChange}
          onBtnFirst={this.handleSearchData.bind(this, 'first')}
          onBtnPrior={this.handleSearchData.bind(this, 'up')}
          onNext={this.handleSearchData.bind(this, 'next')}
          onBtnLast={this.handleSearchData.bind(this, 'end')}
          onChangeInvalid={this.handleInvalid}
          onViewClick={this.handleViewClick}
          onDataChange={this.handleTableChange}
          onButtonChange={this.handleButtonChange.bind(this)}
          onField={this.handleField.bind(this)}
          onChange={this.handleMasterChange}
          onDataRowAdd={this.handleTableAdd}
          onDataRowDel={this.handleTableDel}
          onCopyTo={this.handleCopyTo}
          onTableSelectRowChange={this.handleTableSelectRowChange}
          onBtnExamine={this.handleAudit.bind(this, 1)}
          onBtnCancelExamine={this.handleAudit.bind(this, 0)}
          onDataAudit={this.dataAudit}
          imgSrc={imgSrc}
          onDataRowCopy={this.handleTableCopy}
          onDataRowCopyAll={this.handleTableCopyAll}
          onBtnClick={this.handleBtnClick}
          onButtonClick={this.handleBtnClick}
          onMaterialsChange={this.handleMaterialsChange}
          onBtnPrint={this.handleBtnPrint}
          onGetFirstChar={this.handleGetFirstChar}
        />
      );
    }
  };
};
