/* eslint-disable */
import React, { Component } from 'react';
import { Modal, message, Progress } from 'antd-v4';
// import moment from 'moment';
import * as commonUtils from '@/utils/utils'; /* 通用方法 */
import * as commonBusiness from '@/components/Common/commonBusiness'; /* 单据业务功能 */
import * as commonServices from '@/services/services'; /*   服务类   */
import commonConfig from '@/utils/config';
import * as commonFunc from '@/components/Common/commonFunc';
import styles from '@/components/Common/ToolBar/index.less';


const { confirm } = Modal;

export default (ChildComponent) => {
  return class extends Component {
    constructor(props) {
      super(props);
      this.state = {
        initSId: ''
      }
      // this.state = {
      //   masterConfig: {}, /* 主表配置 */
      //   slaveConfig: {}, /* 从表配置 */
      //   slaveColumn: [], /* 显示的从表表头 */
      //   checkConfig: {}, /* 审核配置 */
      //   checkColumn: [], /* 显示的审核表表头 */
      //
      //   billnosetting: {}, /* 是否自动审核 */
      //   report: [], /* 打印模板 */
      //   masterData: {}, /* 主表数据 */
      //   slaveData: [], /* 从表数据 */
      //   dataTotal: {}, /* 合计字段 */
      //   checkData: [], /* 审核表数据 */
      //   masterFlag: false, /* 是否获取主表数据 */
      //   slaveFlag: false, /* 是否获取从表数据 */
      //   checkFlag: false, /* 是否获取审核表数据 */
      //   sId: '', /* 数据Id */
      //   enabled: false, /* 页面是否可编辑 */
      //   slaveSelectedRowKeys: [], /*   已选择的数据行(数据格式:数组)   */
      //   slaveDelData: [], /*   已删除的数据集合,保存的时候会与从表一并传给服务器(数据格式:数组)   */
      //   expand: false, /* 默认主表只显示2行 */
      //   imgSrc: '', /* Avatar组件中的img中src的资源路径 */
      //   currentIndexFlag: false, /* 默认不显示当前的数据在主表页的位置序号 */
      // };
      this.form = {}; /*   表单对象   */
      this.copyName = '';
      const { sModelsId, sModelsType } = props;
      if (sModelsType.includes('cashier/')) {
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerName', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyName', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyName', []);
      }
      commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sSrcNo', []);
    }
    async componentWillReceiveProps(nextProps) {
      const {
        formData, currentId, formRoute,
      } = nextProps;
      const { masterConfig: masterConfigOld, app } = nextProps;
      if (commonUtils.isEmptyObject(masterConfigOld) && formData.length > 0) {
        const sId = currentId || nextProps.masterData?.sId || '';
        const masterConfig = formData.filter(item => !item.bGrd)[0];

        const sReasonTitle = commonUtils.isNotEmptyObject(commonFunc.showMessage(app.commonConst, 'sReason'))?
          commonFunc.showMessage(app.commonConst, 'sReason') : '报错原因';/* 导入报错原因 */

        /* 导入错误配置 */
        let importConfig = {};
        let importFilterData =  formData.filter(item => item.bReportData && item.sGrd === 'importTemplate');
        if(commonUtils.isNotEmptyArr(importFilterData)) {
          importConfig = formData.filter(item => item.bReportData && item.sGrd === 'importTemplate')[0];
          const iIndex = importConfig.gdsconfigformslave.findIndex(item => item.sName === 'sReason');
          if(iIndex === -1) {
            importConfig.gdsconfigformslave.push({
              bCanInput: false,
              bEntireLine: false,
              bFilter: false,
              bFind: false,
              bFirstEmpty: false,
              bIsOther: false,
              bMultipleChoice: false,
              bNewRecord: false,
              bNotEmpty: false,
              bNotRepeat: false,
              bReadonly: false,
              bSum: false,
              bTree: false,
              bVisible: true,
              iColValue: 1,
              iFitWidth: 200,
              /* iIncrement: 26154, */
              iOrder: 1,
              iTag: 0,
              iVisCount: 0,
              iconName: 'menu-unfold',
              sActiveKey: '',
              sAssignField: '',
              sBig5: '',
              sBig5DropDown: '',
              sBrandsId: '1111111111',
              sChinese: '报错原因',
              sChineseDropDown: '',
              sColor: '',
              sColorTerms: '',
              sControlName: '',
              sDateFormat: '',
              sDefault: '',
              sDropDownType: '',
              sEnglish: '',
              sEnglishDropDown: '',
              sFilterSql: '',
              /* sId: '19211681019715580740769130', */
              sKeyUpFilter: '',
              sMaxValue: '',
              sMinValue: '',
              sName: 'sReason',
              sNotRepeatColumn: '',
              /* sParentId: '19211681019715428730724240', */
              sRelation: '',
              sSelectRelation: '',
              sSqlCondition: '',
              sSubsidiaryId: '1111111111',
              showDropDown: '',
              showName: sReasonTitle,
            });
          }
        }
        let importColumn = [];
        if (commonUtils.isNotEmptyObject(importConfig)) {
          importColumn = commonFunc.getHeaderConfig(importConfig);
        }

        const config = {};
        let addState = {};
        let addOtherState = {};
        let configArr = [];
        let onlySlave = false;
        let onlySlave0 = false;
        let onlySlave1 = false;
        let onlyslave2 = false;
        let onlyslave3 = false;
        let onlyslave4 = false;
        let slaveColumn = [];
        let slave0Column = [];
        let slave1Column = [];
        let slave2Column = [];
        let slave3Column = [];
        let slave4Column = [];

        const getSlaveConfig = (config) => {
          if (config && config.sGrd && config.sGrd.includes('_')) {
            return {};
          } else {
            return config;
          }
        }

        const slaveConfig = formData.length > 1 ? getSlaveConfig(formData[1]) : {};
        if (!commonUtils.isEmptyObject(slaveConfig) && slaveConfig.bGrdVisible) {
          config.slaveConfig = slaveConfig;
          slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
          onlySlave = true;
          const slavePageSize = commonUtils.isNotEmptyObject(slaveConfig) && commonUtils.isNotEmptyNumber(slaveConfig.iPageSize) && slaveConfig.iPageSize !== 0 ?
            slaveConfig.iPageSize : commonConfig.pageSize;
          addOtherState.slavePageSize = slavePageSize;
        }
        const slave0Config = formData.length > 2 ? getSlaveConfig(formData[2]) : {};
        if (!commonUtils.isEmptyObject(slave0Config) && slave0Config.bGrdVisible) {
          config.slave0Config = slave0Config;
          slave0Column = commonFunc.getHeaderConfig(slave0Config);
          onlySlave0 = true;
          const slave0PageSize = commonUtils.isNotEmptyObject(slave0Config) && commonUtils.isNotEmptyNumber(slave0Config.iPageSize) && slave0Config.iPageSize !== 0 ?
            slave0Config.iPageSize : commonConfig.pageSize;
          addOtherState.slave0PageSize = slave0PageSize;

        }
        const slave1Config = formData.length > 3 ? getSlaveConfig(formData[3]) : {};
        if (!commonUtils.isEmptyObject(slave1Config) && slave1Config.bGrdVisible) {
          config.slave1Config = slave1Config;
          slave1Column = commonFunc.getHeaderConfig(slave1Config);
          onlySlave1 = true;
          const slave1PageSize = commonUtils.isNotEmptyObject(slave1Config) && commonUtils.isNotEmptyNumber(slave1Config.iPageSize) && slave1Config.iPageSize !== 0 ?
            slave1Config.iPageSize : commonConfig.pageSize;
          addOtherState.slave0PageSize = slave1PageSize;
        }
        const slave2Config = formData.length > 4 ? getSlaveConfig(formData[4]) : {};
        if (!commonUtils.isEmptyObject(slave2Config) && slave2Config.bGrdVisible) {
          config.slave2Config = slave2Config;
          slave2Column = commonFunc.getHeaderConfig(slave2Config);
          onlyslave2 = true;
          const slave2PageSize = commonUtils.isNotEmptyObject(slave2Config) && commonUtils.isNotEmptyNumber(slave2Config.iPageSize) && slave2Config.iPageSize !== 0 ?
            slave2Config.iPageSize : commonConfig.pageSize;
          addOtherState.slave2PageSize = slave2PageSize;
        }
        const slave3Config = formData.length > 5 ? getSlaveConfig(formData[5]) : {};
        if (!commonUtils.isEmptyObject(slave3Config) && slave3Config.bGrdVisible) {
          config.slave3Config = slave3Config;
          slave3Column = commonFunc.getHeaderConfig(slave3Config);
          onlyslave3 = true;
          const slave3PageSize = commonUtils.isNotEmptyObject(slave3Config) && commonUtils.isNotEmptyNumber(slave3Config.iPageSize) && slave3Config.iPageSize !== 0 ?
            slave3Config.iPageSize : commonConfig.pageSize;
          addOtherState.slave3PageSize = slave3PageSize;
        }
        const slave4Config = formData.length > 6 ? getSlaveConfig(formData[6]) : {};
        if (!commonUtils.isEmptyObject(slave4Config) && slave4Config.bGrdVisible) {
          config.slave4Config = slave4Config;
          slave4Column = commonFunc.getHeaderConfig(slave4Config);
          onlyslave4 = true;
          const slave4PageSize = commonUtils.isNotEmptyObject(slave4Config) && commonUtils.isNotEmptyNumber(slave4Config.iPageSize) && slave4Config.iPageSize !== 0 ?
            slave4Config.iPageSize : commonConfig.pageSize;
          addOtherState.slave4PageSize = slave4PageSize;
        }
        /* commonNewBill 可以一带N表  */
        const tableConfigArr =  formData.filter(item => item.bGrd && item.bGrdVisible && !(item.sGrd && item.sGrd.split('_').length > 2));
        const slaveOtherConfigArr =  [];

        let  slaveInfoList = ['slave'];  /* 父表格名配置集合 */
        let  slaveChildInfoList = []; /* 子表格名配置集合 */
        const addStateConfig ={}; /* 所有表格配置集合 */
        addStateConfig['slaveConfig'] = slaveConfig;

        let addStateMap ={}; /* 所有表格配置集合 */

        if(commonUtils.isNotEmptyArr(tableConfigArr)) {
          tableConfigArr.forEach((item, iIndex) => {
            if(iIndex > 5) {
              const iSlaveTag = iIndex - 1;
              item.slaveNameTag = iSlaveTag;
              slaveOtherConfigArr.push(item);
              const slaveOtherConfigName =  'slave' + iSlaveTag + 'Config';
              let slaveOtherColumnName =  'slave' + iSlaveTag + 'Column';
              const onlyslaveTag= 'onlyslave' + iSlaveTag;
              const slavePageSizeTag =  'slave' + iSlaveTag + 'PageSize';
              const slaveOtherColumn = commonFunc.getHeaderConfig(item);
              addOtherState[slaveOtherConfigName] = item;
              addOtherState[slaveOtherColumnName] = slaveOtherColumn;
              addOtherState[onlyslaveTag] = true;
              const slavePageSize = commonUtils.isNotEmptyObject(item) && commonUtils.isNotEmptyNumber(item.iPageSize) && item.iPageSize !== 0 ?
                item.iPageSize : commonConfig.pageSize;
              addOtherState[slavePageSizeTag] = slavePageSize;
            }
            /* 封装父级表格 */
            let num = 0;
            if(iIndex > 0) {
               num = iIndex -1;
              slaveInfoList.push(`slave${num}`);
              addStateConfig[`slave${num}Config`] = item;
            }
            /* 找到父级页签下面的子级页签数据集 */
            const childFormData =  formData.filter(child =>  !child.bGrdVisible && child.sGrd &&  item.sChildTableName && item.sChildTableName.includes(child.sGrd) && child.sGrd !== 'slave' );
            if(commonUtils.isNotEmptyArr(childFormData)) {
              childFormData.forEach((child, tag) => {
                addOtherState[`slave${num}Child${tag}Config`] = child;
                addStateConfig[`slave${num}Child${tag}Config`] = child;
                addOtherState[`slave${num}Child${tag}Column`] = commonFunc.getHeaderConfig(child);
                const sChildName = child.showName;
                slaveChildInfoList.push(`slave${num}Child${tag}-${sChildName}`);
              });
            }

          });
          addStateMap = addStateConfig;

          addOtherState.slaveOtherConfigArr = slaveOtherConfigArr;
        }


        config.masterConfig = masterConfig;

        const slaveTopConfig = formData.find(item => item.sGrd === 'slave');
        if (slaveTopConfig) {
          addOtherState.bShowSlaveTop = true;
          addOtherState.slaveTopConfig = slaveTopConfig;
          addOtherState.slaveTopColumn = commonFunc.getHeaderConfig(slaveTopConfig);
        }

        /* 取材料组配置放在数组 */
        const addState2 ={}; /* 存储材料数据集 */
        let  materialsInfoList = [];
        let  materialsChildInfoList = [];
        const materialsFormData = formData.filter(item =>  item.sGrd && item.sGrd.includes('materials') &&  item.sGrd.split('_').length <3 );
        // const materialsFormData = formData.filter(item => item.sTbName !== 'mftworkordermaterials' && item.sGrd && item.sGrd.includes('materials') && item.bGrdVisible );
        /* 找到除了材料，成品材料外的其他所有父级材料 */

        if(commonUtils.isNotEmptyArr(materialsFormData)) {
          materialsInfoList.push('materials');
          materialsFormData.forEach((item, index) => {
            if(index > 0) {
              addState2[`materials${index}Config`] = item;
              addStateConfig[`materials${index}Config`] = item;
              addState2[`materials${index}Column`] = commonFunc.getHeaderConfig(item);
              /* 找到该配置的子从表 */
              const childFormData = formData.filter(child => child.sGrd === item.sChildTableName && child.sGrd && child.sGrd.includes('materials'));
              if (commonUtils.isNotEmptyArr(childFormData)) {
                childFormData.forEach((child, num) => {
                  addState2[`materials${index}ChildConfig`] = child;
                  addStateConfig[`materials${index}ChildConfig`] = child;
                  addState2[`materials${index}ChildColumn`] = commonFunc.getHeaderConfig(child);
                  // materialsInfoList.push(child.showName);
                  const sChildName = item.showName + num + 1;
                  materialsChildInfoList.push(`materials${index}Child`);
                });
              }
              materialsInfoList.push(`materials${index}`);
            }else {
              const childFormData = formData.filter(child => child.sGrd === item.sChildTableName && child.sGrd && child.sGrd.includes('materials'));
              if (commonUtils.isNotEmptyArr(childFormData)) {
                childFormData.forEach((child, num) => {
                  addState2[`materialsChildConfig`] = child;
                  addStateConfig[`materialsChildConfig`] = child;
                  addState2[`materialsChildColumn`] = commonFunc.getHeaderConfig(child);
                  // materialsInfoList.push(child.showName);
                  const sChildName = item.showName + num + 1;
                  materialsChildInfoList.push(`materialsChild`);
                });
              }
            }
          });
        }

        if (sId === '') {
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
          // 如果配置了bEmptyAddLine， 默认不添加空数据
          formData.forEach((item, index) => {
            if (index > 0) {
              const tempConfig = formData[index];
              const i = index === 1 ? '' : index - 2;
              if (commonUtils.isNotEmptyObject(tempConfig) && tempConfig.bGrdVisible) {
                const bEmptyAddLine = tempConfig.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
                if (commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible) {
                  addState[`slave${i}Data`] = [];
                }
              }
            }
          });
        } else {
          if (formRoute === '/indexPage/commonCostomTabBill') {
             configArr = [
              ['master', masterConfig],
              ['slave', slaveConfig],
              ['slave0', slave0Config],
              ['slave1', slave1Config],
              ['slave2', slave2Config],
              ['slave3', slave3Config],
              ['slave4', slave4Config],
            ].concat(
              Object.keys(addOtherState)
                .filter(key => key.includes('Config') && !key.includes('Arr'))
                .map(key => [key.replace('Config', ''), addOtherState[key]])
            );

            const queryConfigArr = configArr.filter(([_, config]) => config.sSqlStr !== 'noQuery');
            addState.queryConfigArr = queryConfigArr;

            this.handleGetData1(queryConfigArr, undefined, { type: 'init' });

            const dataRelationJson = {};
            const noQueryConfigArr = configArr.filter(([_, config]) => config.sSqlStr === 'noQuery');
            noQueryConfigArr.forEach(item => {
              const [name, config] = item;
              const { sTbName } = config;
              const iIndex = queryConfigArr.findIndex(item => item[1].sTbName === sTbName);
              if (iIndex !== -1) {
                dataRelationJson[name] = queryConfigArr[iIndex][0];
              }
            });
            /* 上批数据逻辑处理 */
            const childNoQueryConfigArr = formData.filter(item => item.sSqlStr === 'noQuery' && (item.showName.includes("对比") || item.showName.includes("上批"))) || [];
            if(commonUtils.isNotEmptyArr(childNoQueryConfigArr)) {
              childNoQueryConfigArr.forEach(itemChild => {
                const { sTbName } = itemChild;
                const iIndex = queryConfigArr.findIndex(item => item[1].sTbName === sTbName);
                if (iIndex !== -1) {
                  const arr = itemChild.sGrd.split('_');
                  const num = arr.length > 0 && Number(arr[1]) -1;
                  const name = arr[0]+'Child'+ num +'Child0';
                  dataRelationJson[name] = queryConfigArr[iIndex][0];
                }
              });
            }
            addState.dataRelationJson = dataRelationJson;
          } else {
            this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, null,
              commonUtils.isNotEmptyObject(addOtherState)? addOtherState.slave5Config : null,
              commonUtils.isNotEmptyObject(addOtherState)? addOtherState.slave6Config : null,
              commonUtils.isNotEmptyObject(addOtherState)? addOtherState.slave7Config : null,
              commonUtils.isNotEmptyObject(addOtherState)? addOtherState.slave8Config : null,
              commonUtils.isNotEmptyObject(addOtherState)? addOtherState.slave9Config : null,
              commonUtils.isNotEmptyObject(addOtherState)? addOtherState.slave10Config : null,
              Object.keys(addOtherState)
                .filter(key => key.includes('Child') && key.includes('Config') || key === 'slaveTopConfig')
                .map(key => ({ name: key.replace('Config', ''), config: addOtherState[key] })),
            );
          }
        }
        this.props.onSaveState({
          masterConfig,
          sId,
          pageLoading: false,
          ...addState,
          slaveConfig,
          slaveColumn,
          slave0Config,
          slave0Column,
          slave1Config,
          slave1Column,
          slave2Config,
          slave2Column,
          slave3Config,
          slave3Column,
          slave4Config,
          slave4Column,
          onlySlave,
          onlySlave0,
          onlySlave1,
          onlyslave2,
          onlyslave3,
          onlyslave4,
          importConfig,
          importColumn,
          addStateMap,
          slaveInfoList,
          slaveChildInfoList,
          ...addOtherState,
          configArr,
          ...addState2,
          materialsInfoList,
          materialsChildInfoList,
        });
      }
    }

    shouldComponentUpdate(nextProps) {
      const { slaveColumn, masterConfig } = nextProps;
      return commonUtils.isNotEmptyArr(slaveColumn) || commonUtils.isNotEmptyObject(masterConfig);
    }

    /**   获取应收账款   */
    getCustomerReceipt = async (masterData) => {
      const { sModelsId } = this.props;
      if (!commonUtils.isEmpty(masterData.sCustomerId)) {
        const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
        const value = { sProName: 'Sp_Receivables_AR', paramsMap: { sStatistics: masterData.sCustomerId } };
        const dataReturn = (await commonServices.postValueService(this.props.app.token, value, url)).data;
        if (dataReturn.code === 1) {
          /*   数据查询成功   */
          const [returnData] = dataReturn.dataset.rows[0].dataSet.outData;
          const masterDataNew = {
            ...masterData,
            dNoReceiptMoney: returnData.dNoReceiptMoney,
            dDueReceiptMoney: returnData.dNoReceiptMoney,
          };
          this.props.onSaveState({ masterData: masterDataNew });
        } else { /*   失败   */
          this.props.getServiceError(dataReturn);
        }
      }
    };

    /**   获取上查下查数据   */
    getSearchUpDownData = async (showConfig) => {
      const { sModelsId } = this.props;
      const url = `${commonConfig.server_host}searchupdown/getSearchUpDown/${showConfig.sId}?sModelsId=${sModelsId}`;
      const conditonValues = this.props.getSqlCondition(showConfig);
      if (commonUtils.isNotEmptyObject(conditonValues)) {
        const iIndex = Object.keys(conditonValues).findIndex(item => commonUtils.isEmpty(conditonValues[item]));
        if (iIndex === -1) {
          /*   调用后台接口   */
          const body = {
            sSqlCondition: commonUtils.isEmptyObject(conditonValues) ? '' : conditonValues, /*   查询条件   */
          };
          const dataReturn = (await commonServices.postValueService(this.props.app.token, body, url)).data;
          if (dataReturn.code === 1) {
            /*   数据查询成功   */
            return dataReturn.dataset.rows;
          } else { /*   失败   */
            this.props.getServiceError(dataReturn);
            return [];
          }
        }
      }
    };

    sortData = (tableData, processData) => {
      processData.sort((g1, g2) => {
        const iIndex1 = tableData.findIndex(item => item.sId === g1.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g1.sControlId);
        let sPartOrder1 = `0000${iIndex1}`;
        sPartOrder1 = sPartOrder1.substring(sPartOrder1.length - 3);
        let sOrder1 = `000${g1.iOrder}`;
        sOrder1 = sOrder1.substring(sOrder1.length - 3);

        const iIndex2 = tableData.findIndex(item => item.sId === g2.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g2.sControlId);
        let sPartOrder2 = `0000${iIndex2}`;
        sPartOrder2 = sPartOrder2.substring(sPartOrder2.length - 3);
        let sOrder2 = `000${g2.iOrder}`;
        sOrder2 = sOrder2.substring(sOrder2.length - 3);
        return parseInt(sPartOrder1 + g1.sType + sOrder1, 10) - parseInt(sPartOrder2 + g2.sType + sOrder2, 10);
      });
      return processData;
    };

    /**   获取主表、从表、审核表数据   */
    handleGetData = async (masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, bEditClick, slave5Config, slave6Config, slave7Config, slave8Config, slave9Config, slave10Config, slaveChildConfigArr) => {
      if (this.props.queryConfigArr) {
        this.handleGetData1(this.props.queryConfigArr, bEditClick);
        return;
      }

      const { currentId, app } = this.props; /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      const { sModelsId, masterData, sModelsType, slaveSelectedRowKeys } = this.props;
      const conditonValues = this.handleGetSqlConditionValues(masterConfig)
      await this.props.handleGetDataOne({ name: 'master', configData: masterConfig, condition: { sSqlCondition: { ...conditonValues }, sId, pageSize: '', pageNum: '' }, bEditClick });
      let addStateSlave = {};
      if (!commonUtils.isEmptyObject(slaveConfig)) {
        const conditonValues = this.handleGetSqlConditionValues(slaveConfig);
        addStateSlave = await this.props.handleGetDataSet({
          name: 'slave', configData: slaveConfig, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
        // if (sModelsType === 'cost/cosInsert' && commonUtils.isNotEmptyObject(addStateSlave) && commonUtils.isNotEmptyArr(addStateSlave.slaveData)) {
        //   let slaveDelData = [];
        //   addStateSlave.slaveData.forEach((item) => {
        //     item.handleType = 'del';
        //     slaveDelData.push(item);
        //   });
        //   addStateSlave.slaveData = []
        //   let sDepartNameDropDown;
        //   const allTableData = {};
        //   const masterIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sDepartName');
        //   if (masterIndex > -1) {
        //     const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[masterIndex]);
        //     sDepartNameDropDown = sqlDropDownData.dropDownData;
        //     sDepartNameDropDown.forEach((item) => {
        //       const tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData);
        //       tableDataRowAdd.handleType = 'add';
        //       tableDataRowAdd.sId = commonUtils.createSid();
        //       tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
        //       tableDataRowAdd.key = tableDataRowAdd.sId;
        //       tableDataRowAdd.bDefault = false;
        //       tableDataRowAdd.iOrder = 0;
        //       tableDataRowAdd.sDepartName = item.sName;
        //       addStateSlave.slaveData.push(tableDataRowAdd);
        //     });
        //   }
        if (app) {
          const { currentPane } = app;
          if (currentPane) {
            const temp = addStateSlave.slaveData.find(item =>
              item.sName === app.currentPane.sName
            )
            if (temp && bEditClick!=='update') {
              addStateSlave.slaveSelectedRowKeys = [ temp.sId ];
              this.setState({
                initSId: temp.sId
              })
            } else if (temp && bEditClick === 'update') {
              /* 修改后 选中行不要消失 */
              if(commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
                addStateSlave.slaveSelectedRowKeys = slaveSelectedRowKeys;
              }

            }
          }
        }
      }
      let addStateSlave1 = {};
      if (!commonUtils.isEmptyObject(slave1Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave1Config);
        addStateSlave1 = await this.props.handleGetDataSet({
          name: 'slave1', configData: slave1Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
      }

      let addStateSlave0 = {};
      if (!commonUtils.isEmptyObject(slave0Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave0Config);
        addStateSlave0 = await this.props.handleGetDataSet({
          name: 'slave0', configData: slave0Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });

        if (commonUtils.isNotEmptyArr(addStateSlave0.slave0Data)) {
          addStateSlave0.slave0SelectedRowKeys = [addStateSlave0.slave0Data[0].sId];
        }


        // if (sModelsType === 'cost/cosInsert' && commonUtils.isNotEmptyObject(addStateSlave0) && commonUtils.isNotEmptyArr(addStateSlave0.slave0Data)) {
        //   let slave0DelData = []
        //   addStateSlave0.slave0Data.forEach((item) => {
        //     item.handleType = 'del';
        //     slave0DelData.push(item);
        //   });
        //   addStateSlave0.slave0Data = [];
        //
        //   let sWorkCenterNameDropDown;
        //   const allTableData = {};
        //   const master1Index = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sWorkCenterName');
        //   if (master1Index > -1) {
        //     const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[master1Index]);
        //     sWorkCenterNameDropDown = sqlDropDownData.dropDownData;
        //     console.log(sWorkCenterNameDropDown);
        //     sWorkCenterNameDropDown.forEach((item) => {
        //       const tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData);
        //       tableDataRowAdd.handleType = 'add';
        //       tableDataRowAdd.sId = commonUtils.createSid();
        //       tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
        //       tableDataRowAdd.key = tableDataRowAdd.sId;
        //       tableDataRowAdd.bDefault = false;
        //       tableDataRowAdd.iOrder = 1;
        //       tableDataRowAdd.sDepartName = item.sName;
        //       item.sDepartName = item.sName;
        //       addStateSlave0.slave0Data.push(item);
        //     })
        //   }
        // }
      }

      let addStateSlave2 = {};
      if (!commonUtils.isEmptyObject(slave2Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave2Config);
        addStateSlave2 = await this.props.handleGetDataSet({
          name: 'slave2', configData: slave2Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } },
        });
      }
      let addStateSlave3 = {};
      if (!commonUtils.isEmptyObject(slave3Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave3Config);
        addStateSlave3 = await this.props.handleGetDataSet({
          name: 'slave3', configData: slave3Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } },
        });
      }
      let addStateSlave4 = {};
      if (!commonUtils.isEmptyObject(slave4Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave4Config);
        addStateSlave4 = await this.props.handleGetDataSet({
          name: 'slave4', configData: slave4Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } },
        });
      }
      let addStateSlave5 = {};
      if (!commonUtils.isEmptyObject(slave5Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave5Config);
        addStateSlave5 = await this.props.handleGetDataSet({
          name: 'slave5', configData: slave5Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave6 = {};
      if (!commonUtils.isEmptyObject(slave6Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave6Config);
        addStateSlave6 = await this.props.handleGetDataSet({
          name: 'slave6', configData: slave6Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave7 = {};
      if (!commonUtils.isEmptyObject(slave7Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave7Config);
        addStateSlave7 = await this.props.handleGetDataSet({
          name: 'slave7', configData: slave7Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave8 = {};
      if (!commonUtils.isEmptyObject(slave8Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave8Config);
        addStateSlave8 = await this.props.handleGetDataSet({
          name: 'slave8', configData: slave8Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave9 = {};
      if (!commonUtils.isEmptyObject(slave9Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave9Config);
        addStateSlave9 = await this.props.handleGetDataSet({
          name: 'slave9', configData: slave9Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave10 = {};
      if (!commonUtils.isEmptyObject(slave10Config)) {
        const conditonValues = this.handleGetSqlConditionValues(slave10Config);
        addStateSlave10 = await this.props.handleGetDataSet({
          name: 'slave10', configData: slave10Config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
        });
      }

      let addState = {};
      if (commonUtils.isNotEmptyArr(slaveChildConfigArr)) {
        for (let i = 0; i < slaveChildConfigArr.length; i++) {
          const { name, config } = slaveChildConfigArr[i];
          const conditonValues = this.handleGetSqlConditionValues(config);
          const returnData = await this.props.handleGetDataSet({
            name, configData: config, condition: { sSqlCondition: { ...conditonValues, sParentId: sId } }, isWait: true,
          });
          addState = { ...addState, ...returnData };
        }
      }

      this.props.onSaveState({
        pageLoading: false, ...addStateSlave, ...addStateSlave0, ...addStateSlave1,  ...addStateSlave2, ...addStateSlave3, ...addStateSlave4,
        ...addStateSlave5, ...addStateSlave6, ...addStateSlave7, ...addStateSlave8, ...addStateSlave9, ...addStateSlave10,
        ...addState,
      });

    };

    handleGetData1 = async (configArr, bEditClick, other, isWait) => {
      const { currentId } = this.props; /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';

      let addState = {};

      const masterConfig = configArr[0][1];
      const conditonValues = this.handleGetSqlConditionValues(masterConfig)
      const masterDataReturn = await this.props.handleGetDataOne({
        name: 'master',
        configData: masterConfig,
        condition: { sSqlCondition: { ...conditonValues }, sId, pageSize: '', pageNum: '' },
        bEditClick,
        isWait: true,
      });
      const masterData= masterDataReturn?.masterData;
      addState.masterData = masterData;
      for (let i = 1; i < configArr.length; i++) {
        const item = configArr[i];
        const [name, config] = item;
        if (commonUtils.isNotEmptyObject(config) && config.sSqlStr !== "noQuery") {
          const conditonValues = this.handleGetSqlConditionValues(config, masterData);
          let returnData = await this.props.handleGetDataSet({
            name,
            configData: config,
            condition: { sSqlCondition: { ...conditonValues, sParentId: sId } },
            isWait: true,
          });
          if(commonUtils.isNotEmptyObject(returnData)) {
            returnData =  JSON.parse(JSON.stringify(returnData))
          }
          const defaultSelectedRowKeys = [];

          if (commonUtils.isNotEmptyObject(returnData)) {
            const data = returnData[`${name}Data`];
            if (commonUtils.isNotEmptyArr(data)) {
              if (name === 'slave0Child1' && commonUtils.isNotEmptyArr(addState.slaveSelectedRowKeys)) {
                const iSlaveIndex = addState.slaveData.findIndex(item => item.sId === addState.slaveSelectedRowKeys[0]);
                if (iSlaveIndex > -1) {
                  const iControlIndex = data.findIndex(item => item.sProductCardId === addState.slaveData[iSlaveIndex].sBomId && item.sCombinedMemo.includes(addState.slaveData[iSlaveIndex].sProductNo));
                  if (iControlIndex > -1) {
                    defaultSelectedRowKeys.push(data[iControlIndex].sId);
                  }
                }
              } else {
                defaultSelectedRowKeys.push(data[0].sId);
              }
            }
          }

          addState = { ...addState, ...returnData, [`${name}SelectedRowKeys`]: defaultSelectedRowKeys };
          if (other?.type !== 'init') {
            addState.bRefreshTime = new Date().getTime();
            delete addState.slave0Child1SelectedRowKeys;
            if(!bEditClick) {
              delete addState.slaveSelectedRowKeys; /* 非加载、修改模式下 不重置从表选中 */
            }
          }
          addState.processCardUpdate = true;
        }
      }

      if(isWait){
        return  addState;
      } else {
        this.props.onSaveState(addState);
      }

    }

    // 额外加载表格
    handleGetTableData = async (props, sGrdName) => {
      const { formData, currentId, queryConfigArr, dataRelationJson } = props;
      const sId = currentId !== undefined ? currentId : "";
      const config = formData.find(item => item.sGrd === sGrdName);
      if (config) {
        const name = sGrdName;
        let addState = {};
        if (config.sSqlStr !== "noQuery") {
          const conditonValues = this.handleGetSqlConditionValues(config);
          addState =
            (await props.handleGetDataSet({
              name,
              configData: config,
              condition: {
                sSqlCondition: { ...conditonValues, sParentId: sId }
              },
              isWait: true
            })) || {};
        } else {
          const { sTbName } = config;
          const iIndex = queryConfigArr.findIndex(
            item => item[1].sTbName === sTbName
          );
          if (iIndex !== -1) {
            addState.dataRelationJson = {
              ...dataRelationJson,
              [name]: queryConfigArr[iIndex][0]
            };
          }
        }
        addState[`${name}Config`] = config;
        addState[`${name}Column`] = commonFunc.getHeaderConfig(config);
        addState[`${name}PageSize`] =
          commonUtils.isNotEmptyNumber(config.iPageSize) && config.iPageSize !== 0
            ? config.iPageSize
            : commonConfig.pageSize;
        props.onSaveState(addState);
      }
    };


    // 获取sqlCondition值
    handleGetSqlConditionValues = (config, record) => {
      let conditonValues = {};
      const { sSqlCondition } = config;
      if (commonUtils.isNotEmptyObject(sSqlCondition)) {
        const tableName = sSqlCondition.split('.')[0];
        if (tableName === 'master') {
          conditonValues = this.props.getSqlCondition(config, 'master', this.props.masterData || record);
        } else {
          let tableDataRow = {};
          const selectedRowKeys = this.props[`${tableName}SelectedRowKeys`];
          const tableData = this.props[`${tableName}Data`] || [];
          if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(tableData)) {
            tableDataRow = tableData.find(item => item.sId === selectedRowKeys[0]) || {};
          } else {
            tableDataRow = tableData[0] || {};
          }
          conditonValues = this.props.getSqlCondition(config, tableName, tableDataRow);
        }
      }

      const { app = {} } = this.props;
      const { currentPane = {} } = app;
      const { sSqlConditionValues = {} } = currentPane;
      return { ...sSqlConditionValues, ...conditonValues };
    }


    /* 获取表数据 */
    handleGetMemoData = async (slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config) => {
      const { currentId } = this.props; /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || ''; /* 数据Id */
      const addStateSlave = slaveConfig ? await this.props.handleGetDataSet({
        name: 'slave', configData: slaveConfig, condition: { sSqlCondition: { ...this.handleGetSqlConditionValues(slaveConfig), sParentId: sId } }, isWait: true,
      }) : '';
      const addStateSlave0 = slave0Config ? await this.props.handleGetDataSet({
        name: 'slave0', configData: slave0Config, condition: { sSqlCondition: { ...this.handleGetSqlConditionValues(slave0Config), sParentId: sId } },
      }) : '';
      const addStateSlave1 = slave1Config ? await this.props.handleGetDataSet({
        name: 'slave1', configData: slave1Config, condition: { sSqlCondition: { ...this.handleGetSqlConditionValues(slave1Config), sParentId: sId } }, isWait: true,
      }) : '';
      const addStateslave2 = slave2Config ? await this.props.handleGetDataSet({
        name: 'slave2', configData: slave2Config, condition: { sSqlCondition: { ...this.handleGetSqlConditionValues(slave2Config), sParentId: sId } }, isWait: true,
      }) : '';
      const addStateslave3 = slave3Config ? await this.props.handleGetDataSet({
        name: 'slave3', configData: slave3Config, condition: { sSqlCondition: { ...this.handleGetSqlConditionValues(slave3Config), sParentId: sId } }, isWait: true,
      }) : '';
      const addStateslave4 = slave4Config ? await this.props.handleGetDataSet({
        name: 'slave4', configData: slave4Config, condition: { sSqlCondition: { ...this.handleGetSqlConditionValues(slave4Config), sParentId: sId } }, isWait: true,
      }) : '';
      // addStateProcess.processData = this.sortData(addStateControl.controlData, addStateProcess.processData);
      this.props.onSaveState({
        pageLoading: false,
        ...addStateSlave,
        ...addStateSlave0,
        ...addStateSlave1,
        ...addStateslave2,
        ...addStateslave3,
        ...addStateslave4,

      });
    };
    /* 获取单张表数据 */
    handleGetOneMemoData = (memoName, memoConfig) => {
      const { currentId } = this.props; /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || ''; /* 数据Id */
      if (commonUtils.isNotEmptyObject(sId)) { /* 解决detail数据没有问题 */
        this.props.handleGetDataSet({
          name: memoName, configData: memoConfig, condition: { sSqlCondition: { ...this.handleGetSqlConditionValues(memoConfig), sParentId: sId } },
        });
      }
    };
    /**  点击新增按钮   */
    handleAdd = async (config, copyTo, isWait) => {
      /*   外置处理业务   */
      const {
        sModelsId, sModelsType, token,
      } = this.props;
      if (sModelsType.includes('cashier/')) {
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerName', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyName', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyName', []);
      }
      let masterConfig = commonUtils.isEmptyObject(config) ? {} : config.masterConfig;
      if (!isWait) {
        masterConfig = this.props.masterConfig;
      }
      let configNew = {};
      if (commonUtils.isEmptyObject(config)) {
        const { slaveConfig } = this.props;
        configNew.slaveConfig = slaveConfig;
      } else {
        configNew = config;
      }
      let masterData = commonFunc.getDefaultData(masterConfig);
      masterData.handleType = 'add';
      masterData.sId = commonUtils.createSid();
      masterData.sFormId = sModelsId;
      masterData.maxBillNo = 'sBillNo';
      /* 新增产品/印件，如果是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;
          }
        }
      }
      let slaveData = [];
      let slave1Data = [];
      let slave0Data = [];
      let slave2Data = [];
      let slave3Data = [];
      let slave4Data = [];

      // const slaveTotal = [];
      // const tableDataTotal = {};
      if (commonUtils.isNotEmptyObject(copyTo)) {
        const copyToMasterConfig = copyTo.config.filter(item => item.sControlName === copyTo.name);
        const masterAssignField = commonUtils.isNotEmptyArr(copyToMasterConfig) ? copyToMasterConfig[0].sAssignField : '';
        const newCopyTo = {};
        newCopyTo.master = copyTo.masterData;
        newCopyTo.slave = commonUtils.isEmpty(copyTo.slaveData) ? [] : copyTo.slaveData[0];
        masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterAssignField, copyTo.masterData, newCopyTo) };
        masterData.tGetPayDate = commonBusiness.getGeyPayDate(masterData);

        if (sModelsType === 'semigoodsStock/matchbill') {
          const sConfigformId = commonUtils.isEmpty(copyTo.config[0]) ? '' : copyTo.config[0].sParentId;
          const sControlName = copyTo.name;
          const sSqlCondition = { sProductId: copyTo.slaveData[0].sProductId, sId: copyTo.masterData.sId };
          const condition = { sConfigformId, sControlName, sSqlCondition };
          const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfo/?sModelsId=${sModelsId}`;
          const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
          if (dataReturn.code === 1) {
            const returnData = dataReturn.dataset.rows[0];
            const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.masterdetail`.toLowerCase());
            const copyToSlaveConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
            const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slavedetail`.toLowerCase());
            const copyToSlave1Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave1`.toLowerCase());
            const copyToSlave0Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave0`.toLowerCase());
            const copyToSlave2Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave2`.toLowerCase());
            const copyToSlava3Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava3`.toLowerCase());
            const copyToSlava4Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava4`.toLowerCase());
            const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
            const salveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
            const salveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
            const slave1AssignField = commonUtils.isNotEmptyArr(copyToSlave1Config) ? copyToSlave1Config[0].sAssignField : '';
            const slave0AssignField = commonUtils.isNotEmptyArr(copyToSlave0Config) ? copyToSlave0Config[0].sAssignField : '';
            const slave2AssignField = commonUtils.isNotEmptyArr(copyToSlave2Config) ? copyToSlave2Config[0].sAssignField : '';
            const slave3AssignField = commonUtils.isNotEmptyArr(copyToSlava3Config) ? copyToSlava3Config[0].sAssignField : '';
            const slave4AssignField = commonUtils.isNotEmptyArr(copyToSlava4Config) ? copyToSlava4Config[0].sAssignField : '';
            if (commonUtils.isNotEmptyArr(returnData.master)) {
              masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.master[0], newCopyTo) };
            }
            if(salveAssignField) {
              if (commonUtils.isNotEmptyArr(returnData.slave)) {
                returnData.slave.forEach((slaveItem) => {
                  newCopyTo.slave = slaveItem;
                  const newSid = commonUtils.createSid();
                  let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo, { newSid }); // 取默认值
                  slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo) };
                  slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                  slaveRow.handleType = 'add';
                  slaveRow.sId = newSid;
                  slaveRow.sParentId = masterData.sId;
                  slaveData.push(slaveRow);
                });
              }
            }

            if(slave0AssignField) {
              if (commonUtils.isNotEmptyArr(returnData.slave0)) {
                returnData.slave0.forEach((slave0Item) => {
                  newCopyTo.slave0 = slave0Item;
                  const newSid = commonUtils.createSid();
                  let slave0Row = commonFunc.getDefaultData(config.slave0Config, newCopyTo, { newSid }); // 取默认值
                  slave0Row = { ...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo) }; // 取赋值字段
                  slave0Row.handleType = 'add';
                  slave0Row.sId = newSid;
                  slave0Row.sParentId = masterData.sId;
                  slave0Data.push(slave0Row);
                });
              }
            }

            if(slave1AssignField) {
              if (commonUtils.isNotEmptyArr(returnData.slave1)) {
                returnData.slave1.forEach((slave1Item) => {
                  newCopyTo.slave1 = slave1Item;
                  const newSid = commonUtils.createSid();
                  let slave1Row = commonFunc.getDefaultData(config.slave1Config, newCopyTo, { newSid }); // 取默认值
                  slave1Row = { ...slave1Row, ...commonFunc.getAssignFieldValue(slave1AssignField, slave1Item, newCopyTo) }; // 取赋值字段
                  slave1Row.handleType = 'add';
                  slave1Row.sId = newSid;
                  slave1Row.sParentId = masterData.sId;
                  slave1Data.push(slave1Row);
                });
              }
            }

            if(slave2AssignField) {
              if (commonUtils.isNotEmptyArr(returnData.slave2)) {
                returnData.slave2.forEach((slave2Item) => {
                  newCopyTo.slave2 = slave2Item;
                  const newSid = commonUtils.createSid();
                  let slave2Row = commonFunc.getDefaultData(config.slave2Config, newCopyTo, { newSid }); // 取默认值
                  slave2Row = { ...slave2Row, ...commonFunc.getAssignFieldValue(slave2AssignField, slave2Item, newCopyTo) }; // 取赋值字段
                  slave2Row.handleType = 'add';
                  slave2Row.sId = newSid;
                  slave2Row.sParentId = masterData.sId;
                  slave2Data.push(slave2Row);
                });
              }
            }

            if(slave3AssignField) {
              if (commonUtils.isNotEmptyArr(returnData.slave3)) {
                returnData.slave3.forEach((slave3Item) => {
                  newCopyTo.slave3 = slave3Item;
                  const newSid = commonUtils.createSid();
                  let slave3Row = commonFunc.getDefaultData(config.slave3Config, newCopyTo, { newSid }); // 取默认值
                  slave3Row = { ...slave3Row, ...commonFunc.getAssignFieldValue(slave3AssignField, slave3Item, newCopyTo) }; // 取赋值字段
                  slave3Row.handleType = 'add';
                  slave3Row.sId = newSid;
                  slave3Row.sParentId = masterData.sId;
                  slave3Data.push(slave3Row);
                });
              }
            }

            if(slave4AssignField) {
              if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                returnData.slave4.forEach((slave4Item) => {
                  newCopyTo.slave4 = slave4Item;
                  const newSid = commonUtils.createSid();
                  let slave4Row = commonFunc.getDefaultData(config.slave4Config, newCopyTo, { newSid }); // 取默认值
                  slave4Row = { ...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo) }; // 取赋值字段
                  slave4Row.handleType = 'add';
                  slave4Row.sId = newSid;
                  slave4Row.sParentId = masterData.sId;
                  slave4Data.push(slave4Row);
                });
              }
            }
          } else {
            this.props.getServiceError(dataReturn);
          }
        } else if(commonUtils.isNotEmptyArr(copyTo.config) && copyTo.config.filter(item => item.sControlName && item.sControlName.includes('TmpInfoBySql')).length> 1){
          const sTmpInfoConfig = copyTo.config.filter(item =>  item.sControlName && item.sControlName.includes('TmpInfoBySql'))[0];
          const sControlName = sTmpInfoConfig.sControlName;
          const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
          const sConfigformId = commonUtils.isEmpty(sTmpInfoConfig) ? '' : sTmpInfoConfig.sParentId;
          if (commonUtils.isNotEmptyArr( copyTo.slaveData)) {
            const sRowData = copyTo.slaveData;
            const condition = { sConfigformId, sControlName, sRowData };
            const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
            if (dataReturn.code === 1) {
              const returnData = dataReturn.dataset.rows[0];
              const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.masterdetail`.toLowerCase());
              const copyToSlaveConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
              const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slavedetail`.toLowerCase());
              const copyToSlave1Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave1`.toLowerCase());
              const copyToSlave0Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave0`.toLowerCase());
              const copyToSlave2Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave2`.toLowerCase());
              const copyToSlava3Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava3`.toLowerCase());
              const copyToSlava4Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava4`.toLowerCase());
              const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
              const salveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
              const salveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
              const slave1AssignField = commonUtils.isNotEmptyArr(copyToSlave1Config) ? copyToSlave1Config[0].sAssignField : '';
              const slave0AssignField = commonUtils.isNotEmptyArr(copyToSlave0Config) ? copyToSlave0Config[0].sAssignField : '';
              const slave2AssignField = commonUtils.isNotEmptyArr(copyToSlave2Config) ? copyToSlave2Config[0].sAssignField : '';
              const slave3AssignField = commonUtils.isNotEmptyArr(copyToSlava3Config) ? copyToSlava3Config[0].sAssignField : '';
              const slave4AssignField = commonUtils.isNotEmptyArr(copyToSlava4Config) ? copyToSlava4Config[0].sAssignField : '';
              if (commonUtils.isNotEmptyArr(returnData.master) && masterDetailAssignField) {
                masterData = {...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.master[0], newCopyTo)};
              }
              if (commonUtils.isNotEmptyArr(returnData.slave)) {
                returnData.slave.forEach((slaveItem) => {
                  newCopyTo.slave = slaveItem;
                  const newSid = commonUtils.createSid();
                  let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo, { newSid }); // 取默认值
                  if(salveDetailAssignField) {
                    slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo)};
                  } else if(salveAssignField) {
                    slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo)}; // 取赋值字段
                  }
                  slaveRow.handleType = 'add';
                  slaveRow.sId = newSid;
                  slaveRow.sParentId = masterData.sId;
                  slaveData.push(slaveRow);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave0)) {
                returnData.slave0.forEach((slave0Item) => {
                  newCopyTo.slave0 = slave0Item;
                  const newSid = commonUtils.createSid();
                  let slave0Row = commonFunc.getDefaultData(config.slave0Config, newCopyTo, { newSid }); // 取默认值
                  slave0Row = {...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo)}; // 取赋值字段
                  slave0Row.handleType = 'add';
                  slave0Row.sId = newSid;
                  slave0Row.sParentId = masterData.sId;
                  slave0Data.push(slave0Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave1)) {
                returnData.slave1.forEach((slave1Item) => {
                  newCopyTo.slave1 = slave1Item;
                  const newSid = commonUtils.createSid();
                  let slave1Row = commonFunc.getDefaultData(config.slave1Config, newCopyTo, { newSid }); // 取默认值
                  slave1Row = {...slave1Row, ...commonFunc.getAssignFieldValue(slave1AssignField, slave1Item, newCopyTo)}; // 取赋值字段
                  slave1Row.handleType = 'add';
                  slave1Row.sId = newSid;
                  slave1Row.sParentId = masterData.sId;
                  slave1Data.push(slave1Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave2)) {
                returnData.slave2.forEach((slave2Item) => {
                  newCopyTo.slave2 = slave2Item;
                  const newSid = commonUtils.createSid();
                  let slave2Row = commonFunc.getDefaultData(config.slave2Config, newCopyTo, { newSid }); // 取默认值
                  slave2Row = {...slave2Row, ...commonFunc.getAssignFieldValue(slave2AssignField, slave2Item, newCopyTo)}; // 取赋值字段
                  slave2Row.handleType = 'add';
                  slave2Row.sId = newSid;
                  slave2Row.sParentId = masterData.sId;
                  slave2Data.push(slave2Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave3)) {
                returnData.slave3.forEach((slave3Item) => {
                  newCopyTo.slave3 = slave3Item;
                  const newSid = commonUtils.createSid();
                  let slave3Row = commonFunc.getDefaultData(config.slave3Config, newCopyTo, { newSid }); // 取默认值
                  slave3Row = {...slave3Row, ...commonFunc.getAssignFieldValue(slave3AssignField, slave3Item, newCopyTo)}; // 取赋值字段
                  slave3Row.handleType = 'add';
                  slave3Row.sId = newSid;
                  slave3Row.sParentId = masterData.sId;
                  slave3Data.push(slave3Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                returnData.slave4.forEach((slave4Item) => {
                  newCopyTo.slave4 = slave4Item;
                  const newSid = commonUtils.createSid();
                  let slave4Row = commonFunc.getDefaultData(config.slave4Config, newCopyTo, { newSid }); // 取默认值
                  slave4Row = {...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo)}; // 取赋值字段
                  slave4Row.handleType = 'add';
                  slave4Row.sId = newSid;
                  slave4Row.sParentId = masterData.sId;
                  slave4Data.push(slave4Row);
                });
              }
            } else {
              this.props.getServiceError(dataReturn);
            }
          } else {
            message.error('请正确配置参数！');
          }
        } else {  /* 走copyTo数据源 */
          const returnData = {
            masterData : copyTo.masterData,
            slave :  commonUtils.isNotEmptyArr(copyTo.slaveData) ? copyTo.slaveData : [],
            slave0 : commonUtils.isNotEmptyArr(copyTo.slave0Data) ? copyTo.slave0Data : [],
            slave1 : commonUtils.isNotEmptyArr(copyTo.slave1Data) ? copyTo.slave1Data : [],
            slave2 : commonUtils.isNotEmptyArr(copyTo.slave2Data) ? copyTo.slave2Data : [],
            slave3 : commonUtils.isNotEmptyArr(copyTo.slave3Data) ? copyTo.slave3Data : [],
            slave4 : commonUtils.isNotEmptyArr(copyTo.slave4Data) ? copyTo.slave4Data : [],
          };
          const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}`.toLowerCase());
          const copyToSlaveConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
          const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slavedetail`.toLowerCase());
          const copyToSlave1Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave1`.toLowerCase());
          const copyToSlave0Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave0`.toLowerCase());
          const copyToSlave2Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave2`.toLowerCase());
          const copyToSlava3Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava3`.toLowerCase());
          const copyToSlava4Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava4`.toLowerCase());
          const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
          const salveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
          const salveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
          const slave1AssignField = commonUtils.isNotEmptyArr(copyToSlave1Config) ? copyToSlave1Config[0].sAssignField : '';
          const slave0AssignField = commonUtils.isNotEmptyArr(copyToSlave0Config) ? copyToSlave0Config[0].sAssignField : '';
          const slave2AssignField = commonUtils.isNotEmptyArr(copyToSlave2Config) ? copyToSlave2Config[0].sAssignField : '';
          const slave3AssignField = commonUtils.isNotEmptyArr(copyToSlava3Config) ? copyToSlava3Config[0].sAssignField : '';
          const slave4AssignField = commonUtils.isNotEmptyArr(copyToSlava4Config) ? copyToSlava4Config[0].sAssignField : '';
          if (commonUtils.isNotEmptyArr(returnData.master)) {
            masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.master[0], newCopyTo) };
          }
          if(salveAssignField) {
            if (commonUtils.isNotEmptyArr(returnData.slave)) {
              returnData.slave.forEach((slaveItem) => {
                newCopyTo.slave = slaveItem;
                const newSid = commonUtils.createSid();
                let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo, { newSid }); // 取默认值
                slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo) };
                slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                slaveRow.handleType = 'add';
                slaveRow.sId = newSid;
                slaveRow.sParentId = masterData.sId;
                slaveData.push(slaveRow);
              });
            }
          }

          if(slave0AssignField) {
            if (commonUtils.isNotEmptyArr(returnData.slave0)) {
              returnData.slave0.forEach((slave0Item) => {
                newCopyTo.slave0 = slave0Item;
                const newSid = commonUtils.createSid();
                let slave0Row = commonFunc.getDefaultData(config.slave0Config, newCopyTo, { newSid }); // 取默认值
                slave0Row = { ...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo) }; // 取赋值字段
                slave0Row.handleType = 'add';
                slave0Row.sId = newSid;
                slave0Row.sParentId = masterData.sId;
                slave0Data.push(slave0Row);
              });
            }
          }

          if(slave1AssignField) {
            if (commonUtils.isNotEmptyArr(returnData.slave1)) {
              returnData.slave1.forEach((slave1Item) => {
                newCopyTo.slave1 = slave1Item;
                const newSid = commonUtils.createSid();
                let slave1Row = commonFunc.getDefaultData(config.slave1Config, newCopyTo, { newSid }); // 取默认值
                slave1Row = { ...slave1Row, ...commonFunc.getAssignFieldValue(slave1AssignField, slave1Item, newCopyTo) }; // 取赋值字段
                slave1Row.handleType = 'add';
                slave1Row.sId = newSid;
                slave1Row.sParentId = masterData.sId;
                slave1Data.push(slave1Row);
              });
            }
          }
          if(slave2AssignField) {
            if (commonUtils.isNotEmptyArr(returnData.slave2)) {
              returnData.slave2.forEach((slave2Item) => {
                newCopyTo.slave2 = slave2Item;
                const newSid = commonUtils.createSid();
                let slave2Row = commonFunc.getDefaultData(config.slave2Config, newCopyTo, { newSid }); // 取默认值
                slave2Row = { ...slave2Row, ...commonFunc.getAssignFieldValue(slave2AssignField, slave2Item, newCopyTo) }; // 取赋值字段
                slave2Row.handleType = 'add';
                slave2Row.sId = newSid;
                slave2Row.sParentId = masterData.sId;
                slave2Data.push(slave2Row);
              });
            }
          }

          if(slave3AssignField) {
            if (commonUtils.isNotEmptyArr(returnData.slave3)) {
              returnData.slave3.forEach((slave3Item) => {
                newCopyTo.slave3 = slave3Item;
                const newSid = commonUtils.createSid();
                let slave3Row = commonFunc.getDefaultData(config.slave3Config, newCopyTo, { newSid }); // 取默认值
                slave3Row = { ...slave3Row, ...commonFunc.getAssignFieldValue(slave3AssignField, slave3Item, newCopyTo) }; // 取赋值字段
                slave3Row.handleType = 'add';
                slave3Row.sId = newSid;
                slave3Row.sParentId = masterData.sId;
                slave3Data.push(slave3Row);
              });
            }
          }

          if(slave4AssignField) {
            if (commonUtils.isNotEmptyArr(returnData.slave4)) {
              returnData.slave4.forEach((slave4Item) => {
                newCopyTo.slave4 = slave4Item;
                const newSid = commonUtils.createSid();
                let slave4Row = commonFunc.getDefaultData(config.slave4Config, newCopyTo, { newSid }); // 取默认值
                slave4Row = { ...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo) }; // 取赋值字段
                slave4Row.handleType = 'add';
                slave4Row.sId = newSid;
                slave4Row.sParentId = masterData.sId;
                slave4Data.push(slave4Row);
              });
            }
          }

        }
      }
      // /* 剔除订单到收款单新增空行 */
      let bUpload = false;
      /* 图片文件不要新增空行 */
      if(commonUtils.isNotEmptyObject(configNew.slaveConfig)) {
        const filterData =  configNew.slaveConfig.gdsconfigformslave.filter(item => item.sControlName.includes('BtnUpload') && item.bVisible);
        if(commonUtils.isNotEmptyArr(filterData) && filterData.length > 0) {
          bUpload = true;
        }
      }
      if (slaveData.length === 0 && !bUpload && commonUtils.isNotEmptyObject(configNew.slaveConfig) && this.props.sModelsType !== 'cashier/receipt' && this.props.sModelsType !== 'cashier/payment') {
        const allTableData = {};
        allTableData.master = masterData;
        allTableData.slave = slaveData;
        const newSid = commonUtils.createSid();
        const tableDataRowAdd = commonFunc.getDefaultData(configNew.slaveConfig, allTableData, { newSid });
        tableDataRowAdd.handleType = 'add';
        tableDataRowAdd.sId = newSid;
        tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
        tableDataRowAdd.key = tableDataRowAdd.sId;
        tableDataRowAdd.bDefault = false;
        tableDataRowAdd.iOrder = 1;
        slaveData.push(tableDataRowAdd);
      }
      if(commonUtils.isNotEmptyObject(copyTo) && copyTo.masterData) {
        /* 重新塞入copyTo.masterData */
        copyTo.masterData = masterData;
      }

      if(commonUtils.isNotEmptyObject(copyTo) && copyTo.masterData) {
        /* 重新塞入copyTo.masterData */
        copyTo.masterData = masterData;
      }

      const { slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config } = this.props;
      if (commonUtils.isNotEmptyObject(slaveConfig) && slaveConfig.bGrdVisible) {
        const bEmptyAddLine = slaveConfig.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
        if (commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible) {
          slaveData = [];
        }
      }

      if (commonUtils.isNotEmptyObject(slave0Config) && slave0Config.bGrdVisible) {
        const bEmptyAddLine = slave0Config.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
        if (commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible) {
          slave0Data = [];
        }
      }

      if (commonUtils.isNotEmptyObject(slave1Config) && slave1Config.bGrdVisible) {
        const bEmptyAddLine = slave1Config.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
        if (commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible) {
          slave1Data = [];
        }
      }

      if (commonUtils.isNotEmptyObject(slave2Config) && slave2Config.bGrdVisible) {
        const bEmptyAddLine = slave2Config.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
        if (commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible) {
          slave2Data = [];
        }
      }

      if (commonUtils.isNotEmptyObject(slave3Config) && slave3Config.bGrdVisible) {
        const bEmptyAddLine = slave3Config.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
        if (commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible) {
          slave3Data = [];
        }
      }

      if (commonUtils.isNotEmptyObject(slave4Config) && slave4Config.bGrdVisible) {
        const bEmptyAddLine = slave4Config.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
        if (commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible) {
          slave4Data = [];
        }
      }

      const { slavePagination = {} } = this.props;
      const slavePaginationNew = {
        ...slavePagination,
        total: commonUtils.isEmptyArr(slaveData) ? 0 : slaveData.length,
        current: 999,
      };
      masterData.enabled = true;

      const state = {
        masterData,
        slaveData,
        slavePagination: slavePaginationNew,
        slaveTotal: [],
        slaveSelectedRowKeys: [],
        slave1SelectedRowKeys: [],
        searchUpDownData: {},
        enabled: true,
        slave0Data,
        slave1Data,
        slave2Data,
        slave3Data,
        slave4Data,
        processSelectedRowKeys: [],
        controlSelectedRowKeys: [],
        slave0SelectedRowKeys: [],
      };
      state.sUseInfo = '';
      if (isWait) {
        return state;
      } else {
        this.props.onSaveState(state);
        return true;
      }
    };
    /**   点击修改按钮操作   */
    handleEdit = async () => {
      const { sModelsId } = this.props;
      const {
        masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, currentId, app, masterData, dispatch, formRoute, formData, configArr,
      } = this.props;
      const addState ={};
      let addReturn ={};
      const specialModelsIds = [
        "12710101117055581460260",
        "12710101117120232946320",
        "12710101117120233168500",
        "12710101117170330526240",
        "12710101117190388194910",
        "12710101117190384474730",
        "12710101117190384977550",
        "12710101117190385855980"
      ];

      // 可以多人同时操作
      if (specialModelsIds.includes(sModelsId)) {
        if (formRoute === '/indexPage/commonCostomTabBill') {
          if(commonUtils.isNotEmptyArr(configArr)) {
            const queryConfigArr = configArr.filter(([_, config]) => config.sSqlStr !== 'noQuery');
            addState.queryConfigArr = queryConfigArr;
            addReturn = this.handleGetData1(queryConfigArr,undefined, { type: 'init'}, true);
            const materialsConfigArr = formData.filter(item => item.sTbName === 'salsalesordermaterials' &&
              (item.showName === "工序物料" || item.showName === "全部材料")) || [];
            /* 获取物料数据 */
            if(commonUtils.isNotEmptyArr(materialsConfigArr)) {
              this.handleGetTableData(this.props, 'materials');
            }
            const revisionArr = formData.filter(item => item.sTbName === 'salsalesorderrevision' && item.showName === "改版处") || [];
            /* 获取物料数据 */
            if(commonUtils.isNotEmptyArr(revisionArr)) {
              this.handleGetTableData(this.props, 'revision');
            }
            const dataRelationJson = {};
            const relateRelationJson = {};
            const noQueryConfigArr = configArr.filter(([_, config]) => config.sSqlStr === 'noQuery');
            noQueryConfigArr.forEach(item => {
              const [name, config] = item;
              const { sTbName } = config;
              const iIndex = queryConfigArr.findIndex(item => item[1].sTbName === sTbName);
              if (iIndex !== -1) {
                dataRelationJson[name] = queryConfigArr[iIndex][0];
              }
            });
            const childMaterialsInfoArr = formData.filter(item => item.sSqlStr === 'noQuery' && item.showName.includes("物料信息") )|| [];
            if(commonUtils.isNotEmptyArr(childMaterialsInfoArr)) {
               relateRelationJson['slave3Child0'] = 'materials';
            }
            /* 上批数据逻辑处理 */
            const childNoQueryConfigArr = formData.filter(item => item.sSqlStr === 'noQuery' && (item.showName.includes("对比") || item.showName.includes("上批"))) || [];
            if(commonUtils.isNotEmptyArr(childNoQueryConfigArr)) {
              childNoQueryConfigArr.forEach(itemChild => {
                const { sTbName } = itemChild;
                const iIndex = queryConfigArr.findIndex(item => item[1].sTbName === sTbName);
                if (iIndex !== -1) {
                  const arr = itemChild.sGrd.split('_');
                  const num = arr.length > 0 && Number(arr[1]) -1;
                  const name = arr[0]+'Child'+ num +'Child0';
                  dataRelationJson[name] = queryConfigArr[iIndex][0];
                }
              });
            }
            addState.dataRelationJson = dataRelationJson;
            addState.relateRelationJson = relateRelationJson;
            addState.processCardUpdate = true;
            // addState.slave3Child0InfoData = [];
          }
         }else {
          await this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, 'update');
        }
        this.props.onSaveState({ enabled: true, loading: false , ...addReturn,  ...addState });
        return;
      }

      const { userinfo, systemData } = app;
      const { sMakePerson } = masterData; /* 本单据制单人 */
      const { sUserName, sType } = userinfo;/* 登录用户 */
      const iIndex = systemData.findIndex(item => item.sName === 'CkxModifyBillNoMakePerson');
      if (iIndex > -1) {
        const sValue = systemData[iIndex].sValue;
        if (sValue === '0') { /* 系统未启用非制单人修改单据，普通用户非制单人不可以修改制单人的单据 */
          if (sType !== 'sysadmin' && sUserName !== sMakePerson) {
            message.error(commonFunc.showMessage(app.commonConst, 'NoUpdateByNoMakePerson'));
            this.props.onSaveState({
              loading: false,
            });
            return;
          }
        }
      }
      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') {
          if (formRoute === '/indexPage/commonCostomTabBill') {
            if(commonUtils.isNotEmptyArr(configArr)) {
              const queryConfigArr = configArr.filter(([_, config]) => config.sSqlStr !== 'noQuery');
              addState.queryConfigArr = queryConfigArr;
              addReturn = this.handleGetData1(queryConfigArr,undefined, { type: 'init'}, true);
              const materialsConfigArr = formData.filter(item => item.sTbName === 'salsalesordermaterials' &&
                (item.showName === "工序物料" || item.showName === "全部材料")) || [];
              /* 获取物料数据 */
              if(commonUtils.isNotEmptyArr(materialsConfigArr)) {
                this.handleGetTableData(this.props, 'materials');
              }
              const revisionArr = formData.filter(item => item.sTbName === 'salsalesorderrevision' && item.showName === "改版处") || [];
              /* 获取物料数据 */
              if(commonUtils.isNotEmptyArr(revisionArr)) {
                this.handleGetTableData(this.props, 'revision');
              }
              const dataRelationJson = {};
              const relateRelationJson = {};
              const noQueryConfigArr = configArr.filter(([_, config]) => config.sSqlStr === 'noQuery');
              noQueryConfigArr.forEach(item => {
                const [name, config] = item;
                const { sTbName } = config;
                const iIndex = queryConfigArr.findIndex(item => item[1].sTbName === sTbName);
                if (iIndex !== -1) {
                  dataRelationJson[name] = queryConfigArr[iIndex][0];
                }
              });
              const childMaterialsInfoArr = formData.filter(item => item.sSqlStr === 'noQuery' && item.showName.includes("物料信息") )|| [];
              if(commonUtils.isNotEmptyArr(childMaterialsInfoArr)) {
                  relateRelationJson['slave3Child0'] = 'materials';
              }
              /* 上批数据逻辑处理 */
              const childNoQueryConfigArr = formData.filter(item => item.sSqlStr === 'noQuery' && (item.showName.includes("对比") || item.showName.includes("上批"))) || [];
              if(commonUtils.isNotEmptyArr(childNoQueryConfigArr)) {
                childNoQueryConfigArr.forEach(itemChild => {
                  const { sTbName } = itemChild;
                  const iIndex = queryConfigArr.findIndex(item => item[1].sTbName === sTbName);
                  if (iIndex !== -1) {
                    const arr = itemChild.sGrd.split('_');
                    const num = arr.length > 0 && Number(arr[1]) -1;
                    const name = arr[0]+'Child'+ num +'Child0';
                    dataRelationJson[name] = queryConfigArr[iIndex][0];
                  }
                });
              }
              addState.dataRelationJson = dataRelationJson;
              addState.relateRelationJson = relateRelationJson;
              addState.processCardUpdate = true;
              // addState.slave3Child0InfoData = [];
            }
            }else {
            await this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, 'update');
          }
          this.props.onSaveState({ enabled: true, loading: false , ...addReturn,  ...addState });
        }
      };
      this.props.handleSendSocketMessage('update', 'showMsg', currentId, userinfo.sId, null, null);
    };

    /**   表单回带   */
    handleForm = (form) => {
      this.form = form;
    };

    /**   toolbar审核(消审)   */
    handleAudit = async (flag) => {
      /*   待用数据声明   */
      const { masterData, gdsformconst } = this.props;
      /*   作废订单不能审核   */
      if (masterData.bInvalid) {
        message.warning(gdsformconst.filter(item => (item.sName === 'sToVoid'))[0].showName);
        return '';
      }
      /**   数据审核   */
      await this.dataAudit(flag);
    };

    /**   数据审核   */
    dataAudit = async (flag, tmpCheck, isWait) => {
      message.destroy();
      /*   待用数据声明   */
      const {
        sModelsId, masterData, app, masterConfig, slaveConfig, slave2Config, slave1Config, token, sModelsType, slave4Config, slave0Config, slave3Config, slaveData, orderDetailConfig,
      } = this.props;
      const sSlaveIdArray = [];
      if (commonUtils.isNotEmptyArr(slaveData)) {
        slaveData.forEach((item) => {
          sSlaveIdArray.push(commonUtils.isNotEmptyObject(item.sId) ? item.sId : item.sSlaveId);
        });
      }
      const slaveId = sSlaveIdArray.toString();
      /*   数据参数   */
      const value = {
        sClientType: '1',
        paramsMap: {
          iFlag: flag,
          iTmpCheck: commonUtils.isEmptyNumber(tmpCheck) ? 0 : tmpCheck,
          sFormGuid: sModelsId,
          sGuid: masterData.sId,
          sSlaveId: slaveId,
          sBillNo: commonUtils.isNotEmptyObject(masterData.sBillNo) ? masterData.sBillNo : '',
        },
      };
      let clearFlag = false;
      if (sModelsType === 'sales/salesOrder' || sModelsType === 'manufacture/workOrder') {
        for (const item of slaveData) {
          if (commonUtils.isNotEmptyStr(item.sProductInfo)) {
            clearFlag = true;
            break;
          }
        }
      }
      /*   数据审核   */
      const url = `${commonConfig.server_host}business/doExamine?sModelsId=${sModelsId}`;
      const returnData = (await commonServices.postValueService(app.token, value, url)).data;
      if (isWait) {
        return returnData;
      } else {
        /*   接收返回值   */
        await this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config);
        const check = commonFunc.showMessage(app.commonConst, 'BtnExamine');/* 审核 */
        const BtnCancelExamine = commonFunc.showMessage(app.commonConst, 'BtnCancelExamine');/* 销审 */
        if ((sModelsType === 'sales/salesOrder' || sModelsType === 'manufacture/workOrder3') && !commonUtils.isEmpty(slave3Config)) {
          await this.handleGetMemoData(slave4Config, slave0Config, slave3Config);
        } else if (sModelsType === 'purchase/purchaseOrder') {
          await this.handleGetOneMemoData('orderDetail', orderDetailConfig);
        }
        if (this.props.app.currentPane.refresh !== undefined) {
          this.props.app.currentPane.refresh();
        }
        if (returnData.code === 1) { /*   成功   */
          this.props.onSaveState({
            loading: false,
          });
          if (flag === 1) {
            /*   审核   */
            if (clearFlag && (sModelsType === 'sales/salesOrder' || sModelsType === 'manufacture/workOrder')) {
              commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductId', []);
              commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductNo', []);
              commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductName', []);
            }
            const { outData } = returnData.dataset.rows[0].dataSet;
            if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
              const sReturnArray = outData[0].sReturn.split('|');
              if (outData[0].sReturn.split('-').length < 2) {
                // 正常业务提示，非审核模板
                // if (this.props.app.currentPane.refresh !== undefined) {
                //   this.props.app.currentPane.refresh();
                // }
                message.error(check + outData[0].sReturn);
                return;
              }
              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: check + dataReturn });
                }
              }
            } else {
              message.success(check + returnData.msg);
            }
          } else {
            /*   消审   */
            const { outData } = returnData.dataset.rows[0].dataSet;
            if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
              message.error(outData[0].sReturn);
            } else {
              // if (this.props.app.currentPane.refresh !== undefined) {
              //   this.props.app.currentPane.refresh();
              // }
              message.success(BtnCancelExamine + returnData.msg);
            }
          }
        } else { /*   失败   */
          this.props.getServiceError(returnData);
          this.props.onSaveState({
            loading: false,
          });
        }
        return true;
      }
    };

    /**   toolbar保存   */
    handleSaveData = async (params) => {
      const {
        token,
        sModelsId,
        currentId,
        masterData,
        masterConfig,
        slaveConfig,
        slave1Config,
        billnosetting,
        app,
        // eslint-disable-next-line no-unused-vars
        sModelsType,
        // eslint-disable-next-line no-unused-vars
        slave0Config,
        // eslint-disable-next-line no-unused-vars
        slave2Config,
        // eslint-disable-next-line no-unused-vars
        slave3Config,
        // eslint-disable-next-line no-unused-vars
        slave4Config,
        dispatch,
        formData,
      } = this.props;
      const { userinfo } = app;
      const { copyTo } = app.currentPane;
      const onSendSocketMessage = this.props.handleSendSocketMessage;
      const BtnSave = commonFunc.showMessage(app.commonConst, 'BtnSave');/* 保存 */
      params.optName = BtnSave;
      const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
      if (commonUtils.isNotEmptyObject(returnData)) {
        if (commonUtils.isNotEmptyObject(copyTo)) {
          const sIdArray = [];
          if(commonUtils.isNotEmptyArr(copyTo.slaveData)) {
            const { slaveData } = copyTo;
            slaveData.forEach((item) => {
              const redisKey = item.sSlaveId;
              sIdArray.push(redisKey);
            });
          }
          /* 处理只有单主表解锁问题 */
          if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sSrcSlaveId)) {
            sIdArray.push(masterData.sSrcSlaveId);
          }

          const sId = sIdArray.toString();
          onSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
        }
        onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
        this.props.onSaveState({
          enabled: false, currentId: 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;
        dispatch({ type: 'app/savePanesAndCurrentPane', payload: { panes: app.panes, currentPane: app.currentPane } });

        /* 新记录时，关闭后能自动带值  */
        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) {
          await this.handleAudit(1);
        } else {
          await this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config);
          const materialsConfigArr = formData.filter(item => item.sTbName === 'salsalesordermaterials' &&
            (item.showName === "工序物料" || item.showName === "全部材料")) || [];
          /* 获取物料数据 */
          if(commonUtils.isNotEmptyArr(materialsConfigArr)) {
            this.handleGetTableData(this.props, 'materials');
          }
          if (this.props.app.currentPane.refresh !== undefined) {
            this.props.app.currentPane.refresh();
          }
        }
        this.props.onSaveState({
          loading: false,
        });
        return true;
      } else {
        this.props.onSaveState({
          loading: false,
        });
        return false;
      }
    };
    /**   toolbar校验保存   */
    handleValidateSave = () => {
      this.form.validateFields(async (err) => {
        /*   验证通过与不通过走不同的流程    */
        if (err) { /*   验证失败   */
          /*   直接渲染显示错误提示   */
          for (const key of Object.keys(err)) {
            message.error(err[key].errors[0].message);
          }
          this.props.onSaveState({
            loading: false,
          });
        } else { /*   验证成功   */
          const {
            masterConfig,
            slaveConfig,
            slaveData,
            slaveDelData,
            app,
            sModelsType,
            slave0Config,
            slaveColumn,
            slave0Data,
            slave0Column,
            slave0DelData,
            slave1Config,
            slave1Column,
            slave1Data,
            slave1DelData,
            slave2Config,
            slave2Column,
            slave2Data,
            slave2DelData,
            slave3Config,
            slave3Column,
            slave3Data,
            slave3DelData,
            slave4Config,
            slave4Column,
            slave4Data,
            slave4DelData,
          } = this.props;
          let { masterData } = this.props;
          // if (commonUtils.isEmptyArr(slaveData) && !sModelsType.includes('sales/salesInvoice') && !sModelsType.includes('purchase/purchaseInvoice') && sModelsType !== 'cashier/financialTransfer' && sModelsType !== 'cashier/financialAdjustment'
          //   && !sModelsType.includes('cashier/receipt') && !sModelsType.includes('cashier/payment') && !sModelsType.includes('purchase/purchaseEnquiry') || !commonBusiness.validateTable(slave0Config, materialsData, this.props)) {
          //   message.error(commonFunc.showMessage(app.commonConst, 'slaveNotNull')); // 从表不能为空！
          //   this.props.onSaveState({
          //     loading: false,
          //   });
          //   return;
          // }
          if (!commonBusiness.validateMaster(masterConfig, masterData, this.props) || !commonBusiness.validateTable(slaveConfig, slaveData, this.props) || !commonBusiness.validateTable(slave1Config, slave1Data, this.props) ||
            (!commonBusiness.validateTable(slave0Config, slave0Data, this.props)) || !commonBusiness.validateTable(slave2Config, slave2Data, this.props) ||
            !commonBusiness.validateTable(slave3Config, slave3Data, this.props) || !commonBusiness.validateTable(slave4Config, slave4Data, this.props)) {
            this.props.onSaveState({
              loading: false,
            });
            return;
          }

          /* 根据配置校验 表格内容是否为空 */
          if(commonUtils.isNotEmptyObject(this.props)) {
            for (const key of Object.keys(this.props)) {
              if(key.includes('Config') && !key.includes('onGet') && !key.includes('report')) {
                const tablename =  key.replace('Config', '').trim();
                const tableConfigName = key;
                const tableDataName = tablename +'Data';
                const tableConfig = this.props[tableConfigName];
                const tableData = this.props[tableDataName];
                if(tableConfig && tableConfig.bNotCanEmpty){
                  if(commonUtils.isEmptyArr(tableData) ){
                    message.error(commonFunc.showMessage(app.commonConst, 'slaveNotNull')); // 表格不能为空！
                    this.props.onSaveState({
                      loading: false,
                    });
                    return;
                  }
                }
              }
            }
          }

          // && sModelsType === 'materialsStock/productionmaterialsadjust'
          if (commonUtils.isNotEmptyArr(slaveData)) {
            let flag = true;
            for (const item of slaveData) {
              if (sModelsType === 'materialsStock/productionmaterialsadjust') {
                if (commonUtils.isNotEmptyStr(item.sWareHouseId)) {
                  if (masterData.sWareHouseId === item.sWareHouseId) {
                    message.error(commonFunc.showMessage(app.commonConst, 'NotSameMateMaterialWarehouse'));/* 材料调拨原仓库与调入仓库不能一致 */
                    flag = false;
                    break;
                  }
                }
              }
              // {"paper":"纸张","finished":"成品","half_finished":"半成品","accessories":"辅料","corrugated":"瓦楞"}
              if (commonUtils.isNotEmptyObject(item.sMaterialsType) && item.sMaterialsType === 'paper' && commonUtils.isEmptyObject(item.sMaterialsStyle)) {
                message.error(item.sMaterialsName + commonFunc.showMessage(app.commonConst, 'NoStyle'));/* 请填写"${item.sMaterialsName}"的规格 */
                flag = false;
                break;
              }
            }
            if (!flag) {
              this.props.onSaveState({
                loading: false,
              });
              return;
            }
          }
          if (!commonBusiness.validateTable(slaveConfig, slaveData, this.props)) {
            this.props.onSaveState({
              loading: false,
            });
            return;
          }
          if (commonUtils.isNotEmptyArr(slaveData) && sModelsType === 'materialsStock/productionmaterials') {
            const flag = await this.handleEleMaterialsStoreCurrQty(slaveData);
            if (!flag) {
              this.props.onSaveState({
                loading: false,
              });
              return;
            }
          }
          if (sModelsType === 'purchase/purchaseEnquiry') {
            delete masterData.maxBillNo;
          }
          if (sModelsType === 'cashier/receipt' || sModelsType === 'cashier/payment') {
            let flag = true;
            if (masterData.sSettlementId === 'bank') {
              if (commonUtils.isEmptyStr(masterData.sBankId) || commonUtils.isEmptyStr(masterData.sBankAccount)) {
                message.error(commonFunc.showMessage(app.commonConst, 'requiredsBankAccount'));/* 收/付款条件为银行时，银行、银行账号为必填项 */
                flag = false;
              }
            }
            if (masterData.sSettlementId === 'bill') {
              if (commonUtils.isEmptyStr(masterData.sBankId) || commonUtils.isEmptyStr(masterData.sInvoiceNo)) {
                message.error(commonFunc.showMessage(app.commonConst, 'requiredsInvoiceNo'));/* 收/付款条件为票据时，银行、票据号码为必填项 */
                flag = false;
              }
            }
            let dslaveTotalMoney = 0;
            for (const item of slaveData) {
              if (item.handleType !== 'del') {
                if (commonUtils.isNotEmptyNumber(item.dTotalMoney)) {
                  dslaveTotalMoney += item.dTotalMoney;
                }
              }
            }
            const dPmoney = this.props.getFloatNum('dProductMoney');
            dslaveTotalMoney = commonUtils.convertFixNum(dslaveTotalMoney, dPmoney);/* 取系统设定小数位 */
            if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyNumber(masterData.dTotalMoney) && commonUtils.isNotEmptyNumber(masterData.dAdvanceMoney) && commonUtils.convertFixNum(masterData.dTotalMoney - masterData.dAdvanceMoney, dPmoney) !== dslaveTotalMoney) {
              message.error(commonFunc.showMessage(app.commonConst, 'NotSameTotalMoney'));/* 主从表总金额不一致 */
              flag = false;
            }
            /* 收付款保存前，看到从表没数据，预收勾上时，自动调用一下分摊 */
            if (commonUtils.isEmptyArr(slaveData)) {
              masterData = this.handleShare();
            }
            if (!flag) {
              this.props.onSaveState({
                loading: false,
              });
              return;
            }
          }
          const data = [];
          data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
          if (slaveConfig && commonUtils.isNotEmptyArr(slaveColumn)) {
            data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
          }
          if (slave0Config && commonUtils.isNotEmptyArr(slave0Column) && slave0Config.sTbName !== 'sysbillcheckresult') {
            data.push(commonBusiness.mergeData('slave0', slave0Config.sTbName, slave0Data, slave0DelData));
          }
          if (slave1Config && commonUtils.isNotEmptyArr(slave1Column) && slave1Config.sTbName !== 'sysbillcheckresult') {
            data.push(commonBusiness.mergeData('slave1', slave1Config.sTbName, slave1Data, slave1DelData));
          }
          if (slave2Config && commonUtils.isNotEmptyArr(slave2Column) && slave2Config.sTbName !== 'sysbillcheckresult') {
            data.push(commonBusiness.mergeData('slave2', slave2Config.sTbName, slave2Data, slave2DelData));
          }
          if (slave3Config && commonUtils.isNotEmptyArr(slave3Column) && slave3Config.sTbName !== 'sysbillcheckresult') {
            data.push(commonBusiness.mergeData('slave3', slave3Config.sTbName, slave3Data, slave3DelData));
          }
          if (slave4Config && commonUtils.isNotEmptyArr(slave4Column) && slave4Config.sTbName !== 'sysbillcheckresult') {
            data.push(commonBusiness.mergeData('slave4', slave4Config.sTbName, slave4Data, slave4DelData));
          }
          this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId });
        }
      });
    };

    /* 切换作废状态 */
    handleOkChangeInvaild = async (props) => {
      const {
        sModelsId, masterData, masterConfig, handleType,
      } = props;
      const value = {
        sClientType: '1',
        sId: [masterData.sId],
        sTableName: masterConfig.sTbName,
        handleType,
      };
      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();
        }
      } 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() {
        },
      });
    };

    /*   单据页上查下查跳转页面   */
    handleSearchUpDown = async (sId, sActiveId) => {
      /*   待用数据声明   */
      const { dispatch, sTabId } = this.props;
      dispatch({
        type: 'content/onRouter',
        payload: {
          url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}`, /*   接口地址   */
          sParentId: sTabId, /*   父页面编号   */
          checkedId: sId,
        },
      });
    };

    /*   上查下查三级菜单  在上一条下一条时必须清除searchUpDownData  */
    handleSearchUpDownThird = async (upDownKey) => {
      /*   待用数据声明   */
      const { masterConfig, searchUpDownData: searchUpDownDataOld } = this.props;
      /**   获取sqlCondition参数：{sSqlCondition,sId}   */
      const searchUpDownData = commonUtils.isEmptyObject(searchUpDownDataOld) ? {} : { ...searchUpDownDataOld };
      if (commonUtils.isNotEmptyObject(masterConfig)) {
        const searchUpDownConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes(`${upDownKey}`));
        for (const item of searchUpDownConfig) {
          if (commonUtils.isEmptyArr(searchUpDownData[item.sControlName])) {
            searchUpDownData[item.sControlName] = await this.getSearchUpDownData(item);
          }
        }
        this.props.onSaveState({ searchUpDownData });
      }
    };

    /*   单据页复制到   */
    handleCopyTo = async (name, sActiveId) => {
      /*   待用数据声明   */
      const {
        dispatch, masterConfig, slave1Data, masterData, slaveData, slave2lData, slave0Data, slave3lData, slave4lData, sModelsId, app,
        token,
        formRoute,
      } = this.props;

      // 从表有sCopyToCondition则不能复制，并提示
      if (commonUtils.isNotEmptyArr(slaveData) && name.includes('.')) {
        const sCopyToConditionIndex = slaveData.findIndex(item => item.sCopyToCondition);
        if (sCopyToConditionIndex !== -1) {
          message.warning(slaveData[sCopyToConditionIndex].sCopyToCondition);
          return;
        }
      }

      const copyTo = {};
      const copyToConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes(name));
      copyTo.name = name;
      copyTo.config = copyToConfig;
      copyTo.masterData = masterData;
      copyTo.slaveData = slaveData;
      copyTo.slave1Data = slave1Data;
      copyTo.slave0Data = slave0Data;
      copyTo.slave2lData = slave2lData;
      copyTo.slave3lData = slave3lData;
      copyTo.slave4lData = slave4lData;

      let sId = '';
      if (!commonUtils.isEmpty(slaveData)) {
        sId = slaveData[0].sId;
      }

      if (commonUtils.isNotEmptyObject(name) && name.toLowerCase().includes('btncopyto.tmpinfobysql')) { /* 根据配置下拉sql获取数据源 */
        const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
        const sConfigformId = commonUtils.isEmpty(copyToConfig) ? '' : copyToConfig[0].sParentId;
        const sControlName = commonUtils.isNotEmptyObject(name) ? name : 'BtnCopyTo.TmpInfoBySql';
        const sRowData = masterData;
        const values = { sConfigformId, sControlName, sRowData };
        const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
        if (dataReturn.code === 1) {
          const returnData = dataReturn.dataset.rows[0];
          if (commonUtils.isNotEmptyObject(returnData)) {
            for (const key of Object.keys(returnData)) {
              const sName = `${key}Data`;
              const masterName = name.replace('BtnCopyTo.','').trim();
              if(key === masterName) {
                copyTo.masterData = returnData[key][0];
              }else {
                copyTo[sName] = returnData[key];
              }
            }
            if (commonUtils.isNotEmptyArr(copyTo.masterData) && Array.isArray(copyTo.masterData)) {
              copyTo.masterData = copyTo.masterData[0];
            }
          }
        } else {
          this.props.getServiceError(dataReturn);
        }
      }

      const tbSuffix = '';
      const dataUrl = `${commonConfig.server_host}bill/billCopyToCheck/?sModelsId=${sModelsId}&sActiveId=${sActiveId}&tbSuffix=${tbSuffix}&sName=${formRoute}`;
      const values = { sSlaveId: sId };
      const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
      if (dataReturn.code === 1) {
        this.props.onSaveState({
          loading: false,
        });
        // eslint-disable-next-line no-underscore-dangle
        const _this = this; // 解决confirm中this指向问题；
        if (dataReturn.dataset.rows.length > 0) {
          confirm({
            title: commonFunc.showMessage(app.commonConst, 'beUsedToNew'), /* 单据已存在，是否填写新单据 */
            onOk() {
              dispatch({
                type: 'content/onRouter',
                payload: {
                  url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}`, /*   接口地址   */
                  copyTo,
                },
              });
            },
            onCancel() {
            },
          });
        } else {
          dispatch({
            type: 'content/onRouter',
            payload: {
              url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}`, /*   接口地址   */
              copyTo,
            },
          });
        }
      }


    };

    handleCopyFrom = async (obj) => {
      // const {
      //   slaveData, masterData, masterConfig,
      // } = this.props;
      /* 根据sql条件进行判断 */
      // const buttonConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === '' && item.showName !== '' && item.sControlName === obj.copyFromKey);
      // if (commonUtils.isNotEmptyArr(buttonConfig) && commonUtils.isNotEmptyObject(buttonConfig[0].sSqlCondition) && buttonConfig[0].sSqlCondition.includes('slave.')) {
      //   if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isEmptyStr(slaveData[0].sCustomerId) && commonUtils.isEmptyStr(masterData.sCustomerId)) {
      //     message.error(commonFunc.showMessage(this.props.app.commonConst, 'pleaseInputCustomer'));/* 请填写客户 */
      //     return;
      //   }
      // }
      this.copyName = obj.name;
      const { token } = this.props;
      const url = `${commonConfig.server_host}/gdsmodule/getGdsmoduleById/${obj.copyFromSActiveId}?sModelsId=${obj.copyFromSActiveId}`;
      const dataReturn = (await commonServices.getService(token, url)).data;
      if (dataReturn.code === 1) {
        const returnData = dataReturn.dataset.rows[0];
        if (obj.copyFromKey.includes('customizeFormInfo')) { /* 复制从自定义窗体 */
          this.props.onSaveState({ copyFromChooseVisible: true, copyFromChooseData: returnData, copyFromKey: obj.copyFromKey });
        } else {
          this.props.onSaveState({ productProcessInfoChooseVisible: true, productProcessInfoChooseData: returnData, productProcessInfoCopyFromKey: obj.copyFromKey });
        }
      } else {
        this.props.getServiceError(dataReturn);
      }
    };

    /*  上一条、下一条、首条、末条 */
    handleSearchData = async (handleType) => {
      const {
        sModelsId, app, currentIndexFlag, currentPageNo, masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, formData,
      } = this.props;
      const { currentPane, token } = app;
      const {
        pages, sFilterOrderBy, bFilter, sListFormmasterId, currentIndex,
      } = currentPane;
      let currentPosition = currentIndexFlag ? currentPageNo : commonUtils.isEmptyObject(pages) ? 1 : (((pages.current - 1) * commonConfig.pageSize) + Number.parseInt(currentIndex, 10)) + 1;
      if (currentIndex === undefined) {
        currentPosition = 1;
      }
      if (handleType === 'first') {
        currentPosition = 1;
      } else if (handleType === 'end') {
        currentPosition = pages.total;
      }
      if (!commonUtils.isNum(currentPosition)) { // 如果是列表直接点增加，就跳到第一条去
        currentPosition = 1;
      }
      this.props.onSaveState({ loading: true });
      const value = {
        sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages.total,
      };
      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];
        this.props.onSaveState({
          currentIndexFlag: true,
          currentPageNo: returnData.currentPosition,
          currentId: returnData.sId,
          searchUpDownData: {},
          slaveSelectedRowKeys: [],
        });
        this.handleGetData1(this.props.queryConfigArr, undefined, { type: 'init' });
        // this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config);
        const materialsConfigArr = formData.filter(item => item.sTbName === 'salsalesordermaterials' &&
          (item.showName === "工序物料" || item.showName === "全部材料")) || [];
        /* 获取物料数据 */
        if(commonUtils.isNotEmptyArr(materialsConfigArr)) {
          this.handleGetTableData(this.props, 'materials');
        }
        return true;
      } else { /*   失败   */
        this.props.getServiceError(data);
        return false;
      }
    };

    /*   取消操作  */
    handleCancel = (obj) => {
      /*   待用数据声明   */
      const {
        currentId, masterConfig, slaveConfig, slave1Config, app, masterData,
        slave0Config, slave2Config, slave3Config, slave4Config, formData, configArr
      } = this.props;
      const that = this;
      const { userinfo } = app;
      const onSendSocketMessage = this.props.handleSendSocketMessage;
      const onGetDataOk = this.handleGetData;
      const onGetData1 = this.handleGetData1;
      const onGetTableData = this.handleGetTableData;
      const onSaveStateOk = this.props.onSaveState;
      const { copyTo } = app.currentPane;
      const materialsConfigArr = formData.filter(item => item.sTbName === 'salsalesordermaterials' &&
        (item.showName === "工序物料" || item.showName === "全部材料")) || [];
      let queryConfigArr = [];
      if(commonUtils.isNotEmptyArr(configArr)) {
         queryConfigArr = configArr.filter(([_, config]) => config.sSqlStr !== 'noQuery');
      }
      const addState ={};
      confirm({
        title: obj.title,
        onOk() {
          if(commonUtils.isNotEmptyArr(queryConfigArr)) {
            addState.queryConfigArr = queryConfigArr;
            onGetData1(queryConfigArr,undefined, { type: 'init'});
            addState.processCardUpdate = true;
            addState.bReset = true;
            // addState.slave3Child0InfoData = [];
          }
          // onGetDataOk(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config);
          const bChanged =  commonBusiness.handleGetChanged(that.props) ;
          if(bChanged) {
            /* 获取物料数据 */
            if(commonUtils.isNotEmptyArr(materialsConfigArr)) {
              onGetTableData(that.props, 'materials');
            }
          }
          onSaveStateOk({ enabled: false, ...addState });
          if (commonUtils.isNotEmptyObject(copyTo)) {
            const { slaveData } = copyTo;
            const sIdArray = [];
            if(commonUtils.isNotEmptyArr(slaveData)) {
              slaveData.forEach((item) => {
                const redisKey = item.sSlaveId;
                sIdArray.push(redisKey);
              });
            }
            /* 处理只有单主表解锁问题 */
            if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sSrcSlaveId)) {
              sIdArray.push(masterData.sSrcSlaveId);
            }
            const sId = sIdArray.toString();
            onSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
          }
          onSendSocketMessage('release', 'noAction', currentId, userinfo.sId, null, null);
        },
        onCancel() {
        },
      });
    };

    /* 删除 */
    handleDel = (obj) => {
      const props = { ...this.props, ...this.state };
      const onOkDel = this.handleOkDel;
      confirm({
        title: obj.title,
        onOk() {
          onOkDel(props);
        },
        onCancel() {
        },
      });
    };

    /* 确定要删除 */
    handleOkDel = async (props) => {
      /*   数据参数   */
      const {
        token, sModelsId, sModelsType, masterConfig, masterData, slaveConfig, slave1Config, orderDetailConfig, app, formData,
      } = props;
      const { userinfo, systemData } = app;
      const { sMakePerson } = masterData; /* 本单据制单人 */
      const { sUserName, sType } = userinfo;/* 登录用户 */
      const iIndex = systemData.findIndex(item => item.sName === 'CkxModifyBillNoMakePerson');
      if (iIndex > -1) {
        const sValue = systemData[iIndex].sValue;
        if (sValue === '0') { /* 系统未启用非制单人修改单据，普通用户非制单人不可以修改制单人的单据 */
          if (sType !== 'sysadmin' && sUserName !== sMakePerson) {
            message.error(commonFunc.showMessage(app.commonConst, 'NoDelByNoMakePerson'));
            return;
          }
        }
      }
      const value = {
        sClientType: '1',
        data: {
          sMasterTable: masterConfig.sTbName,
          sId: [masterData.sId],
        },
      };
      const sSlaveTable = [];
      if (commonUtils.isNotEmptyObject(slaveConfig)) {
        sSlaveTable.push({
          tableName: slaveConfig.sTbName,
          relationName: 'sParentId',
        });
      }
      if (commonUtils.isNotEmptyObject(slave1Config)) {
        sSlaveTable.push({
          tableName: slave1Config.sTbName,
          relationName: 'sParentId',
        });
      }
      if (sModelsType === 'purchase/purchaseOrder') {
        let orderDetailConfig ={};
        let orderDetailConfigArr = formData.filter(item => item.bGrd && item.sTbName === 'purpurchaseorderDetail');
        if(commonUtils.isNotEmptyArr(orderDetailConfigArr)) {
          orderDetailConfig = orderDetailConfigArr[0];
        }

        if(commonUtils.isNotEmptyObject(orderDetailConfig)) {
          sSlaveTable.push({
            tableName: orderDetailConfig.sTbName,
            relationName: 'sParentId',
          });
        }

      }
      value.sSlaveTable = sSlaveTable;
      const { sBillNo, sId } = masterData || {};
      const url = `${commonConfig.server_host}business/delMasSlaBusinessData?sModelsId=${sModelsId}&sBillNo=${sBillNo}&sSysLogSrcId=${sId}`;
      /*   接收返回值   */
      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);
    };

    /**   添加表格空行   */
    handleTableAdd = (name, isWait) => {
      /*   从CommonBase获取默认参数   */
      const {
        masterData, masterConfig, sModelsType, app,
      } = this.props;
      const addState ={};
      let { [`${name}Data`]: tableData , [`${name}Config`]: tableConfig } = this.props;
      tableData = commonUtils.isEmptyObject(tableData) ? [] : tableData;
      const 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.sName === 'sCustomerNo' || item.sName === 'sCustomerName') && item.bVisible));
          if (iIndex > -1) {
            const { showName } = masterConfig.gdsconfigformslave[iIndex];
            message.warn(showName + commonFunc.showMessage(app.commonConst, 'isNotNull')); // 不能为空
            return;
          }
        }
      }
      tableDataRow.sWareHouseId = masterData.sWareHouseId;
      tableDataRow.sWareHouseNo = masterData.sWareHouseNo;
      tableDataRow.sWareHouseName = masterData.sWareHouseName;
      tableDataRow.sLocationId = masterData.sLocationId;
      tableDataRow.sLocationNo = masterData.sLocationNo;
      tableDataRow.sLocationName = masterData.sLocationName;
      tableDataRow.sWareHouseLocationId = masterData.sWareHouseLocationId;
      tableDataRow.sWareHouseLocationNo = masterData.sWareHouseLocationNo;
      tableDataRow.sWareHouseLocationName = masterData.sWareHouseLocationName;
      if(commonUtils.isNotEmptyObject(tableConfig) && tableConfig.showName === '非标材料') { /* 非标材料数据插入到材料表 */
        tableDataRow.sNons = '非标';
        const { slave0Child1Data:controlData, slaveData, slaveSelectedRowKeys, currentProductCardId }= this.props;
        let { materialsData }= this.props;
        if(commonUtils.isEmptyArr(materialsData)) {
          materialsData = [];
        }
        const currentSelectedSlaveData = this.props.currentSelectedSlaveData || this.props.slaveData[0];
        let controlSeletedRowKeys = [];
        if(commonUtils.isNotEmptyObject(currentSelectedSlaveData) && commonUtils.isNotEmptyArr(controlData)) {
          let iSlaveIndex = 0;
          if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
            iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
          }
          const iIndex = controlData.findIndex(controlItem => {
            const sCombinedMemoArr = JSON.parse(controlItem.sCombinedMemo);
            const sCombinedMemoFilterArr = sCombinedMemoArr.filter(item => item.dCombineQty > 0 && item.sProductNo === slaveData[iSlaveIndex].sProductNo);
            return controlItem.sProductCardId === slaveData[0].sBomId &&
              commonUtils.isNotEmptyArr(sCombinedMemoFilterArr)
          });
          // const iIndex = controlData.findIndex(item => item.sProductCardId === slaveRow.sBomId);
          if(iIndex > -1) {
            controlSeletedRowKeys = [controlData[iIndex].sId];
            console.log('部件表',[controlData[iIndex].sId]);
          }
        }
        if(commonUtils.isNotEmptyArr(controlSeletedRowKeys)) {
          tableDataRow.sControlId = commonUtils.isNotEmptyArr(controlSeletedRowKeys) ? controlSeletedRowKeys[0] : '';
          tableDataRow.sProductCardId = slaveData[0].sBomId;
          materialsData.push(tableDataRow);
         }else {
          message.error('请选择对应的部件！');
        }
        addState.materialsData = materialsData;

      } else if(commonUtils.isNotEmptyObject(tableConfig) && name !=='materialsChild'  && name === 'slave3Child0Child1') { /* 新增替代料 */
        const { slave3Child0SelectedRowKeys: tableSelectedRowKeys, currentProductCardId,  materialsData : tableInfo =[] } = this.props;
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          message.error('请选择替代料的父级！');
          return;
        }
        name = 'materails';
        const tableDataRow = this.props.onDataRowAdd(name, true);
        tableDataRow.sParentMaterialsId = tableSelectedRowKeys[0];
        tableDataRow.sProductCardId = currentProductCardId;
        tableInfo.push(tableDataRow);
        addState.materialsData = tableInfo;
      } else if(commonUtils.isNotEmptyObject(tableConfig) && tableConfig.showName === '更换材料') { /* 新增替代料 */
        const { slave3Child0SelectedRowKeys: tableSelectedRowKeys, currentProductCardId,  materialsData : tableInfo =[] } = this.props;
        if (this.props.bSecondMainMaterials) {
          message.error('二级材料不能增加替代料！');
          return;
        }
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          message.error('请选择替代料的父级！');
          return;
        }
        const sOriginalName = name;
        name = 'materials';
        const tableDataRow = this.props.onDataRowAdd(name, true);
        tableDataRow.sParentMaterialsId = tableSelectedRowKeys[0];
        tableDataRow.sNons = '替代料';
        tableDataRow.sProductCardId = currentProductCardId;
        tableInfo.push(tableDataRow);
        addState.materialsData = tableInfo;
        addState[`${sOriginalName}SelectedRowKeys`]=[tableDataRow.sId];
      } else if(commonUtils.isNotEmptyObject(tableConfig) && tableConfig.showName === '工单物资评审') { /* 树形 */
        const { slave3Child0SelectedRowKeys: tableSelectedRowKeys, slave3Child0Data : tableSum =[] } = this.props;
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          message.error('请选择数据！');
        }
        const iIndex = tableSum.findIndex(item => tableSelectedRowKeys.includes(item.sId));
        if(iIndex > -1) {
          tableDataRow.sMaterialsId = tableSum[iIndex].sMaterialsId;
          tableDataRow.sMaterialsName= tableSum[iIndex].sMaterialsName;
          tableDataRow.sMaterialsStyle = tableSum[iIndex].sMaterialsStyle;
        }
      }else if(name === 'slave0Child1' && tableConfig.showName === '合格率评审'){
        const { slaveData ,slaveSelectedRowKeys, currentSelectType,currentProductCardId, currentProductTechnologyVer}= this.props;
        let slaveRow = {};
        if(commonUtils.isNotEmptyArr(slaveData)) {
          if(commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
            const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId));
            if(iIndex > -1) {
              slaveRow = slaveData[iIndex];
            }
          }

        }


        tableDataRow.sProductTechnologyVer = currentProductTechnologyVer;
        tableDataRow.sProductCardId = currentProductCardId;
        tableDataRow.sProductCardNo = currentProductTechnologyVer;
        tableDataRow.currentSelectType = currentSelectType;
        tableDataRow.sSlaveId = commonUtils.isNotEmptyObject(slaveRow) ? slaveRow.sId : '';
        tableDataRow.iOrder = currentSelectType.includes('preVersion') ? tableData.length + 1000 : tableData.length+10;

        if(commonUtils.isNotEmptyObject(slaveRow)) {
          const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty,sCombinePartsName  }= slaveRow;
          const tableCombineSelectedData =[];
          const jsonObj = {};
          jsonObj.sId = sId;
          jsonObj.sProductNo = sProductNo; /* 产品编号 */
          jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 1; /* 排版数 */
          jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
          jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
          jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
          tableCombineSelectedData.push(jsonObj);
          const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) ? JSON.stringify(tableCombineSelectedData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
          tableDataRow.sCombinedMemo =commonUtils.isNotEmptyObject(sCombinedMemo)? sCombinedMemo: '合版信息';
        }
      } else if(name === 'slave0Child3') { /* 改版处 */
        const { currentProductCardId }= this.props;
        const slaveRow = this.handleGetSelectedData(this.props, 'slave');
        tableDataRow.sProductCardId = currentProductCardId;
        tableDataRow.sSlaveId = slaveRow?.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 }, [`${name}SelectedRowKeys`]: [tableDataRow.sId], ...addState });
      }
    };

    /**   复制   */
    handleTableCopy = (name, isWait) => {
      const {
        [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
      } = this.props;
      if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(this.props.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;
            if (commonUtils.isNotEmptyObject(tableDataRow.sMaterialsMemo)) {
              tableDataRow.sMaterialsMemo = '';
            }
            if (commonUtils.isNotEmptyObject(tableDataRow.sProcessMemo)) {
              tableDataRow.sProcessMemo = '';
            }
            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 } });
            }
          }
        }
      }
    };

    handleTableCopyTo = (name, toname, isWait) => {
      const {
        [`${name}Data`]: tableData, [`${toname}Data`]: tablePersonData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
      } = this.props;
      if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(this.props.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)) {
              if (commonUtils.isNotEmptyObject(toname)) {
                tablePersonData.push(tableDataRow);
                this.props.onSaveState({ [`${toname}Data`]: tablePersonData, [`${toname}Pagination`]: { total: tablePersonData.length, current: 9999 } });
                message.success('操作成功！');
              } else {
                tableData.push(tableDataRow);
                this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}Pagination`]: { total: tableData.length, current: 9999 } });
              }
            }
          }
        }
      }
    };

    /**   复制全部   */
    handleTableCopyAll = (name, isWait) => {
      const {
        slaveData, controlData, slaveSelectedRowKeys, slave0Data,
      } = this.props;
      let { processData } = this.props;
      if (name === 'slave') {
        if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
          message.warn(commonFunc.showMessage(this.props.app.commonConst, 'pleaseChooseCopyData'));/* 请选择复制数据 */
        } else {
          for (const sId of slaveSelectedRowKeys) {
            const slaveDataIndex = slaveData.findIndex(item => item.sId === sId);
            if (slaveDataIndex > -1) {
              const slaveDataRow = JSON.parse(JSON.stringify(slaveData[slaveDataIndex]));
              slaveDataRow.sId = commonUtils.createSid();
              slaveDataRow.handleType = 'add';
              slaveDataRow.key = slaveDataRow.sId;
              slaveData.push(slaveDataRow);
              if (commonUtils.isNotEmptyArr(controlData)) {
                controlData.filter(itemControl => itemControl.sSlaveId === sId).forEach((itemControl) => {
                  const tableDataRow = JSON.parse(JSON.stringify(itemControl));
                  tableDataRow.sId = commonUtils.createSid();
                  tableDataRow.handleType = 'add';
                  tableDataRow.key = tableDataRow.sId;
                  tableDataRow.sSlaveId = slaveDataRow.sId;
                  controlData.push(tableDataRow);
                  /* 部件表复制其材料表、工序表 */
                  slave0Data.filter(item => item.sControlId === itemControl.sId && item.sType !== '2').forEach((item) => {
                    const slave0Row = JSON.parse(JSON.stringify(item));
                    slave0Row.sId = commonUtils.createSid();
                    slave0Row.handleType = 'add';
                    slave0Row.sControlId = tableDataRow.sId;
                    slave0Row.sPartsName = tableDataRow.sPartsName;
                    slave0Row.sSlaveId = tableDataRow.sSlaveId;
                    slave0Data.push(slave0Row);
                  });
                  processData.filter(item => item.sControlId === itemControl.sId && item.sType !== '3').forEach((item) => {
                    const processRow = JSON.parse(JSON.stringify(item));
                    processRow.sId = commonUtils.createSid();
                    processRow.handleType = 'add';
                    processRow.sControlId = tableDataRow.sId;
                    processRow.sPartsName = tableDataRow.sPartsName;
                    processRow.sSlaveId = tableDataRow.sSlaveId;
                    processData.push(processRow);
                  });
                  processData = this.sortData(controlData, processData);
                });
              }
              if (commonUtils.isNotEmptyArr(slave0Data)) { /* 订单从表复制全部 复制成品材料 */
                slave0Data.filter(item => item.sSlaveId === sId && item.sType === '2').forEach((slave0Item) => {
                  const slave0Row = JSON.parse(JSON.stringify(slave0Item));
                  slave0Row.handleType = 'add';
                  slave0Row.sId = commonUtils.createSid();
                  slave0Row.sSlaveId = slaveDataRow.sId;
                  slave0Data.push(slave0Row);
                });
              }

              if (commonUtils.isNotEmptyArr(processData)) { /* 订单从表复制全部 复制成品工序 */
                processData.filter(item => item.sSlaveId === sId && item.sType === '3').forEach((processItem) => {
                  const processRow = JSON.parse(JSON.stringify(processItem));
                  processRow.handleType = 'add';
                  processRow.sId = commonUtils.createSid();
                  processRow.sSlaveId = slaveDataRow.sId;
                  processData.push(processRow);
                });
              }
            }
            this.props.onSaveState({
              slaveData,
              [`${name}Pagination`]: { total: slaveData.length, current: 9999 },
              controlData,
              slave0Data,
              processData,
            });
          }
        }
      } else if (name === 'control') {
        const {
          [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
        } = this.props;
        if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          message.warn(commonFunc.showMessage(this.props.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);
                /* 部件表复制其材料表、工序表 */
                slave0Data.filter(item => item.sControlId === sId && item.sType !== '2').forEach((item) => {
                  const slave0Row = JSON.parse(JSON.stringify(item));
                  slave0Row.sId = commonUtils.createSid();
                  slave0Row.handleType = 'add';
                  slave0Row.sControlId = tableDataRow.sId;
                  slave0Row.sPartsName = tableDataRow.sPartsName;
                  slave0Data.push(slave0Row);
                });
                processData.filter(item => item.sControlId === sId && item.sType !== '3').forEach((item) => {
                  const processRow = JSON.parse(JSON.stringify(item));
                  processRow.sId = commonUtils.createSid();
                  processRow.handleType = 'add';
                  processRow.sControlId = tableDataRow.sId;
                  processRow.sPartsName = tableDataRow.sPartsName;
                  processData.push(processRow);
                });
                processData = this.sortData(tableData, processData);
                this.props.onSaveState({
                  [`${name}Data`]: tableData,
                  [`${name}Pagination`]: { total: tableData.length, current: 9999 },
                  slave0Data,
                  processData,
                });
              }
            }
          }
        }
      }
    };

    handleCloseProductProcessInfoChooseModal = () => {
      this.props.onSaveState({
        productProcessInfoChooseVisible: false
      })
    }

    singlePQtyChange = (tableDataRow) => {
      const bZfZf = tableDataRow.iPrintMode === 2; // 正反版
      const bSample = tableDataRow.dSumPQty >= 4; // 样本
      tableDataRow.iPrintModePo = tableDataRow.iPrintMode <= 2 ? 2 : tableDataRow.iPrintMode === 3 ? 0 : -1;

      if (bSample) {
        if (tableDataRow.dSinglePQty > 0) {
          tableDataRow.dPlateQty = Math.ceil(tableDataRow.dSumPQty / tableDataRow.dSinglePQty);
        }

        if (bZfZf && (tableDataRow.iPrintModePo === 2)) { // 双面样本，正反
          if (tableDataRow.dPlateQty < 2) { // 不管建议放正自翻版了，点方式什么是什么
            tableDataRow.dPlateQty = 2;
            tableDataRow.iStick = Math.ceil(commonUtils.isNull(tableDataRow.dPlateQty, 0) / 2);
            tableDataRow.dSumPlateQty = tableDataRow.iStick * (
              commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
              commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
              commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
              commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
          } else {
            if (tableDataRow.iPrintModePo !== 2) { // 单面样本
              tableDataRow.dPlateQty = (commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty;
              tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty);
              tableDataRow.dSumPlateQty = tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
                commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
            } else {
              tableDataRow.dPlateQty = commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1);
              tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty / 2);
            }
            tableDataRow.dSumPlateQty = tableDataRow.iStick * (
              commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
              commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
              commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
              commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
          }
        } else {
          if (tableDataRow.iPrintModePo !== 2) { // 单面样本
            tableDataRow.dPlateQty = (commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty;
          } else {
            tableDataRow.dPlateQty = commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1);
          }
          tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty);
          tableDataRow.dSumPlateQty = tableDataRow.iStick * (
            commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
            commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
        }
        if (tableDataRow.iStick > 0 && tableDataRow.dSinglePQty > 0) {
          tableDataRow.dMachineQty = commonUtils.convertFixNum((commonUtils.isNull(tableDataRow.dPartsQty, 0) * commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty / tableDataRow.iStick, 0);
          tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick;
        }
      } else {
        tableDataRow.iStick = 1;
        tableDataRow.dSumPlateQty = tableDataRow.iStick * (
          commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
          commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
          commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
          commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
        if (bZfZf && tableDataRow.iPrintModePo === 2) {
          tableDataRow.dPlateQty = 2;
          tableDataRow.dSumPlateQty = tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
            commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) + commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
            commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
        } else {
          tableDataRow.dPlateQty = 1;
          tableDataRow.dSumPlateQty = tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
            commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
        }

        if (tableDataRow.dSinglePQty > 0) {
          if (tableDataRow.iPage > 1) { // 笔记本  用 非样本 来做， 倍率是每页都一样才可以用      原先 /2 是指页数， 现在直接按张数
            tableDataRow.dMachineQty = commonUtils.convertFixNum((tableDataRow.dPartsQty * tableDataRow.iPage) / tableDataRow.dSinglePQty, 0);
          } else {
            tableDataRow.dMachineQty = commonUtils.convertFixNum(commonUtils.isNull(tableDataRow.dPartsQty, 0) / tableDataRow.dSinglePQty, 0);
            tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick;
          }
        }
      }
      return tableDataRow;
    };

    /** 表格数据更改 */
    // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
    handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData, isWait) => {
      /*   从CommonBase获取默认参数   */
      const {
        [`${name}Data`]: tableData, sModelsType, sModelsId, token, app, slaveConfig, slave0Data, slaveData,  [`${name}Config`]: tableConfig,
      } = this.props;
      const { dNetMoney, dNetPrice } = app.decimals;
      if (name === 'control' && sModelsType === 'sales/salesOrder') {
        const { [`${name}Data`]: tableData, slave0Data: slave0DataOld, slave2Data: slave2DataOld } = this.props;
        let tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
        if (tableDataRow === undefined) return;
        if (sFieldName === 'dSinglePQty' || sFieldName === 'dSumPQty' || sFieldName === 'iPrintModePo' || sFieldName === 'iPrintMode' || sFieldName === 'iPrintModePo' || sFieldName === 'iPositiveColor' ||
          sFieldName === 'iPositiveSpecialColor' || sFieldName === 'iOppositeColor' || sFieldName === 'iOppositeSpecialColor') {
          if (sFieldName === 'iPrintModePo') {
            if (tableDataRow.iPrintModePo === 0) {
              tableDataRow.iPrintMode = 3;
              if (tableDataRow.iPositiveColor === 0) {
                tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
                tableDataRow.iOppositeColor = 0;
                tableDataRow.iOppositeSpecialColor = 0;
              } else {
                tableDataRow.iOppositeColor = 0;
                tableDataRow.iOppositeSpecialColor = 0;
              }
            } else if (tableDataRow.iPrintModePo === 1) {
              tableDataRow.iPrintMode = 3;
              if (tableDataRow.iPositiveColor === 0) {
                tableDataRow.iPositiveColor = 0;
                tableDataRow.iPositiveSpecialColor = 0;
                tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? 4 : tableDataRow.iOppositeColor;
              } else {
                tableDataRow.iPositiveColor = 0;
                tableDataRow.iPositiveSpecialColor = 0;
              }
            } else {
              tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
              tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
            }
          } else if (sFieldName === 'iPrintMode') {
            if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
              tableDataRow.iPositiveColor = commonUtils.isEmpty(tableDataRow.iPositiveColor) || tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
              tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
              tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
            } else if (tableDataRow.iPrintMode === 2) {
              tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
              tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
            } else if (tableDataRow.iPrintMode === 3) {
              tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
              tableDataRow.iOppositeColor = 0;
              tableDataRow.iOppositeSpecialColor = 0;
            } else if (tableDataRow.iPrintMode === 4) {
              tableDataRow.iPositiveColor = 0;
              tableDataRow.iPositiveSpecialColor = 0;
              tableDataRow.iOppositeColor = 0;
              tableDataRow.iOppositeSpecialColor = 0;
            }
          } else if (sFieldName === 'iPositiveColor' || sFieldName === 'iPositiveSpecialColor') {
            if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
              tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
              tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
            }
          }
          tableDataRow = this.singlePQtyChange(tableDataRow);
        }
        const slave0Data = [];
        const slave2Data = [];
        slave0DataOld.forEach((item) => {
          const itemNew = { ...item };
          if (itemNew.sControlId === sId) {
            itemNew.sPartsName = tableDataRow.sPartsName;
          }
          slave0Data.push(itemNew);
        });
        slave2DataOld.forEach((item) => {
          const itemNew = { ...item };
          if (itemNew.sControlId === sId) {
            itemNew.sPartsName = tableDataRow.sPartsName;
          }
          slave2Data.push(itemNew);
        });
        const slave0DataNew = this.sortData(tableData, slave0Data);
        const slave2DataNew = this.sortData(tableData, slave2Data);

        const iIndex = tableData.findIndex(item => item.sId === sId);
        tableData[iIndex] = tableDataRow;
        this.props.onSaveState({ [`${name}Data`]: tableData, slave0Data: slave0DataNew, slave2Data: slave2DataNew });
      } else if(commonUtils.isNotEmptyObject(tableConfig) && tableConfig.showName === '非标材料') {
        const { materialsData } = this.props;
        const addState = {};
        let tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
        if (tableDataRow === undefined) return;
        if(commonUtils.isNotEmptyArr(materialsData)) {
          const iMIndex = materialsData.findIndex(item => item.sId === tableDataRow.sId );
          if(iMIndex > -1) {
            let { handleType } = materialsData[iMIndex];
            handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
            materialsData[iMIndex] = {...materialsData[iMIndex], ...changeValue, handleType};
          }
          addState.materialsData = materialsData;
        }
        const iIndex = tableData.findIndex(item => item.sId === sId);
        tableData[iIndex] = tableDataRow;
        this.props.onSaveState({ [`${name}Data`]: tableData, ...addState });
      }else if(commonUtils.isNotEmptyObject(tableConfig) && (tableConfig.showName === '物料信息' )) {
        name = 'materials';
        const {
          [`${name}Data`]: tableData,
        } = this.props;
        const tableDataRow = await this.props.onDataChange('materials', sFieldName, changeValue, sId, dropDownData, true);
        if (tableDataRow === undefined) return;

        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          tableData[iIndex] = tableDataRow;
        }
        this.props.onSaveState({ [`${name}Data`]: tableData });
      }else if(commonUtils.isNotEmptyObject(tableConfig) && name !== 'materialsChild' && ( name === 'slave3Child0Child1'  || tableConfig.showName === '更换材料')) {
        name = 'materials';
        const {
          [`${name}Data`]: tableData, masterData, slave3Child0SelectedRowKeys,
        } = this.props;
        let tableDataRow = await this.props.onDataChange('materials', sFieldName, changeValue, sId, dropDownData, true);
        if (tableDataRow === undefined) return;
        /* 各种金额，税额，价格计算 */
        const models = name === 'materials' ? 'Materials' :
          sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') || sModelsType.includes('semigoodsStock/') ? 'Product' : 'Materials';
        if (sFieldName.includes('Qty')) {
          tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models);
        }
        /* 叠加用量 */
        if(commonUtils.isEmptyArr(slave3Child0SelectedRowKeys)) {
          message.error('请选择物料！');
          return;
        }
        let dAuxiliarySumQty = 0;
        const filterData = tableData.filter(item => item.sParentMaterialsId && slave3Child0SelectedRowKeys.includes(item.sParentMaterialsId) && item.sNons === '替代料'
        && item.sMaterialsType !== '2');
        if(commonUtils.isNotEmptyArr(filterData)) {
          filterData.forEach(item => {
            if(item.sId !== sId) {
              dAuxiliarySumQty += commonUtils.convertToNum(commonUtils.isNull(item.dAuxiliaryQty, 0), 2);
            } else {
              dAuxiliarySumQty += commonUtils.convertToNum(commonUtils.isNull(tableDataRow.dAuxiliaryQty, 0), 2);
            }
          });
          const iFatherIndex = tableData.findIndex(item => slave3Child0SelectedRowKeys.includes(item.sId) );
          if(false && iFatherIndex > -1) { // 20240926 杭需求 替代料数量变化时，物料信息替代料数据不要变化，点击MRP计算后会自动带出
            const addState = {};
            addState.dReplaceStockAuxiliaryQty =  dAuxiliarySumQty;
            addState.handleType =  commonUtils.isEmpty(tableData[iFatherIndex].handleType) ? 'update' : tableData[iFatherIndex].handleType;
            tableData[iFatherIndex] ={...tableData[iFatherIndex], ...addState};
          }
        }

        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          tableData[iIndex] = tableDataRow;
        }
        this.props.onSaveState({ [`${name}Data`]: tableData });
      } else if(commonUtils.isNotEmptyObject(tableConfig) && (tableConfig.showName === '生管评审' || tableConfig.showName === '子件信息') ) {
        name = 'slave';
        const {
          [`${name}Data`]: tableData, controlData, controlSelectedRowKeys, materials0Data, materials0SelectedRowKeys,
        } = this.props;
        const tableDataRow = await this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
        if (tableDataRow === undefined) return;

        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          tableData[iIndex] = tableDataRow;
        }
        this.props.onSaveState({ [`${name}Data`]: tableData });
      } else if (name === 'materials1' || name === 'materials2'  || name === 'materials3' || name === 'materialsChild' || name === 'materials1Child') {
        name = 'materials';
        const { [`${name}Data`]: tableData} = this.props;
        // let oldRowMap = {};
        // if(sFieldName === 'sInkBOM') {
        //   const iOldIndex = tableData.findIndex(item => item.sId === sId);
        //   if(iOldIndex > -1) {
        //     const tableDataOldRow = JSON.parse(JSON.stringify(tableData[iOldIndex]));
        //     oldRowMap ={
        //       sInkBOMId : tableDataOldRow.sInkBOMId,
        //       sInkBOMsSlaveId : tableDataOldRow.sInkBOMsSlaveId,
        //       sInkBOMsMaterialsId : tableDataOldRow.sInkBOMsMaterialsId,
        //       sProcessTbId : tableDataOldRow.sProcessTbId,
        //       sProcessId : tableDataOldRow.sProcessId,
        //       sControlId : tableDataOldRow.sControlId,
        //     }
        //   }
        // }
        const tableDataRow = await this.props.onDataChange('materials', sFieldName, changeValue, sId, dropDownData, true);
        if (tableDataRow === undefined) return;
        // tableDataRow.oldRowMap = oldRowMap;
        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          tableData[iIndex] = tableDataRow;
        }
        this.props.onSaveState({ [`${name}Data`]: tableData });
      } else {
        let { masterData } = this.props;
        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (sFieldName.substring(0, 1) === 'd' && commonUtils.convertToNum(tableData[iIndex][sFieldName]) === commonUtils.convertToNum(changeValue[sFieldName])) {
          if (!(tableData[iIndex][sFieldName] === undefined && commonUtils.convertToNum(changeValue[sFieldName]) === 0)) return;
        }
        if (sFieldName === 'sProductName' && name === 'slave' && (sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder') || sModelsType.includes('quotation/quotation'))) {
          if (commonUtils.isNotEmptyObject(changeValue) && Object.keys(changeValue).length === 1 && Object.keys(changeValue)[0] === sFieldName) {
            changeValue.sProductId = changeValue.sProductName;
          }
        }
        let tableDataRow = this.props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
        if ((sFieldName === 'sProductId' || sFieldName === 'sProductName' || sFieldName === 'sProductStyle' || sFieldName === 'sProductUnit' || sFieldName === 'sProductNo'
          || sFieldName === 'sCustomerProductNo' || sFieldName === 'sProductClassifyId' || sFieldName === 'sProductClassifyName') && !commonUtils.isEmpty(tableDataRow.sProductId)) {
          // const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', sFieldName);
          let productIdDropDown;
          const slaveIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sFieldName);
          if (slaveIndex > -1) {
            const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[slaveIndex]);
            productIdDropDown = sqlDropDownData.dropDownData;
          }
          const iProductIdIndex = commonUtils.isEmptyArr(productIdDropDown) ? -1 : productIdDropDown.findIndex(item => item.sId === tableDataRow.sProductId);
          if (iProductIdIndex === -1) {
            tableDataRow.sProductInfo = JSON.stringify({
              sProductId: tableDataRow.sProductName,
              sProductName: tableDataRow.sProductName,
              sProductStyle: tableDataRow.sProductStyle,
              sProductUnit: tableDataRow.sProductUnit,
              sProductNo: tableDataRow.sProductNo,
              sCustomerProductNo: tableDataRow.sCustomerProductNo,
              sProductClassifyId: tableDataRow.sProductClassifyId,
              sProductClassifyName: tableDataRow.sProductClassifyName,
            });
          } else {
            tableDataRow.sProductInfo = '';
          }
          if ((sFieldName === 'sProductId' || sFieldName === 'sProductName' || sFieldName === 'sProductNo') && !commonUtils.isEmpty(changeValue.sProductId)) {
            const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
            const value = {
              sProName: 'Sp_Cashier_GetProductPrice',
              paramsMap: {
                sProductGuid: changeValue.sProductId,
              },
            };
            const returnData = (await commonServices.postValueService(app.token, value, url)).data;
            if (returnData.code === 1) {
              tableDataRow.dProductPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice;
            }
            // else {
            //   this.props.getServiceError(returnData);
            // }
          }
        } else if (sModelsType === 'sales/salesOrder' && (sFieldName === 'sProductClassifyId' || sFieldName === 'sProductClassifyName') && name === 'slave') {
          const { controlData } = this.props;
          if (controlData !== undefined && !commonUtils.isEmpty(tableData.sProductInfo)) {
            const controlDataFilter = controlData.filter(item => item.sSlaveId === tableData[iIndex].sId);
            const tableSelectedRowKeys = [];
            controlDataFilter.forEach((item) => {
              tableSelectedRowKeys.push(item.sId);
            });
            const slave0ReturnData = this.otherTableDel('slave0', tableSelectedRowKeys);
            const slave2ReturnData = this.otherTableDel('slave2', tableSelectedRowKeys);
            const slave3ReturnData = this.props.onDataRowDel('slave3', true, tableSelectedRowKeys);
            this.props.onSaveState({
              ...slave0ReturnData,
              ...slave2ReturnData,
              ...slave3ReturnData,
            });
          }
        } else if (sModelsType.includes('cashier/') && sFieldName === 'dTotalMoney') { /* 付款单、收款单，从表付款/收款金额改变，会自动汇总到主表付款金额中 */
          const addStata = {};
          addStata.dTotalMoney = 0;
          if (iIndex > -1) { /* 选中行 */
            let dMoney = commonUtils.isNotEmptyNumber(tableDataRow.dTotalMoney) ? tableDataRow.dTotalMoney : 0;
            dMoney = commonUtils.convertStrToNumber(dMoney);
            addStata.dTotalMoney = dMoney + commonUtils.convertStrToNumber(addStata.dTotalMoney);
          }
          tableData.forEach((item, index) => { /* 非选中行 */
            if (index !== iIndex) {
              const dMoney = commonUtils.isNotEmptyNumber(item.dTotalMoney) ? item.dTotalMoney : 0;
              addStata.dTotalMoney = commonUtils.convertFixNum(dMoney, 6) + commonUtils.convertFixNum(addStata.dTotalMoney, 6);
            }
          });
          masterData = { ...masterData, ...addStata };
          this.props.onSaveState({ masterData });
        }
        // 取工艺卡数据
        if (sModelsType === 'sales/salesOrder' && (sFieldName === 'sProductId' || sFieldName === 'sProductNo' || sFieldName === 'sProductName') && name === 'slave') {
          const {
            controlConfig, slave0Config, processConfig,
          } = this.props;
          let { controlData, slave0Data, processData } = this.props;
          const sId = tableData[iIndex].sId;
          const bCkxCopyFromTechnology = app.systemData.filter(item => item.sName === 'CkxCopyFromTechnology')[0].sValue;
          if (bCkxCopyFromTechnology === '1' && tableDataRow.sProductId !== tableDataRow.sProductName) {
            const controlSelectedData = controlData.filter(item => item.sSlaveId === sId);
            if (commonUtils.isNotEmptyObject(controlSelectedData)) {
              const slave0ReturnData = this.otherTableDel('slave0', controlSelectedData);
              const processReturnData = this.otherTableDel('process', controlSelectedData);
              const controlReturnData = this.props.onDataRowDel('control', true, controlSelectedData);
              controlData = controlReturnData.controlData;
              slave0Data = slave0ReturnData.slave0Data;
              processData = processReturnData.processData;
              this.props.onSaveState({
                ...slave0ReturnData,
                ...processReturnData,
                ...controlReturnData,
              });
            }
            const sCustomerId = masterData.sCustomerId;
            const sProductId = changeValue.sProductId;
            const sProductIdArray = [];
            sProductIdArray.push(sProductId);
            const sProductIds = sProductIdArray.toString();
            const condition = { sCustomerId, sProductIds };
            const dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataByCustomIdProductId/?sModelsId=${sModelsId}`;
            const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
            const config = this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes('BtnCopyFrom.ActProcessCard'));
            if (dataReturn.code === 1) {
              const returnData = dataReturn.dataset.rows[0];
              const copyToControlConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Control'.toLowerCase());
              const copyToSlave0Config = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Slave0'.toLowerCase());
              const copyToProcessConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Process'.toLowerCase());
              const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
              const slave0AssignField = commonUtils.isNotEmptyArr(copyToSlave0Config) ? copyToSlave0Config[0].sAssignField : '';
              const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
              const newCopyTo = {};
              newCopyTo.master = masterData;
              newCopyTo.slave = commonUtils.isEmptyArr(tableData) ? {} : tableData;
              if (commonUtils.isNotEmptyArr(returnData.controlData)) {
                // eslint-disable-next-line no-loop-func
                returnData.controlData.forEach((controlItem) => {
                  newCopyTo.control = controlItem;
                  const newSid = commonUtils.createSid();
                  let controlRow = commonFunc.getDefaultData(controlConfig, newCopyTo, { newSid }); // 取默认值
                  controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
                  controlRow.handleType = 'add';
                  controlRow.sId = newSid;
                  controlRow.sSlaveId = tableDataRow.sId;
                  controlRow.sParentId = masterData.sId;
                  controlData.push(controlRow);

                  if (commonUtils.isNotEmptyArr(returnData.slave0Data)) {
                    returnData.slave0Data.filter(item => item.sControlId === controlItem.sId).forEach((slave0Item) => {
                      newCopyTo.slave0 = slave0Item;
                      const newSid = commonUtils.createSid();
                      let slave0Row = commonFunc.getDefaultData(slave0Config, newCopyTo, { newSid }); // 取默认值
                      slave0Row = { ...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo) }; // 取赋值字段
                      slave0Row.handleType = 'add';
                      slave0Row.sId = newSid;
                      slave0Row.sSlaveId = tableDataRow.sId;
                      slave0Row.sParentId = masterData.sId;
                      slave0Row.sControlId = controlRow.sId;
                      slave0Row.sPartsName = controlRow.sPartsName;
                      slave0Data.push(slave0Row);
                    });
                  }

                  if (commonUtils.isNotEmptyArr(returnData.processData)) {
                    returnData.processData.filter(item => item.sControlId === controlItem.sId).forEach((processItem) => {
                      newCopyTo.process = processItem;
                      const newSid = commonUtils.createSid();
                      let processRow = commonFunc.getDefaultData(processConfig, newCopyTo, { newSid }); // 取默认值
                      processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                      processRow.handleType = 'add';
                      processRow.sId = newSid;
                      processRow.sSlaveId = tableDataRow.sId;
                      processRow.sParentId = masterData.sId;
                      processRow.sControlId = controlRow.sId;
                      processRow.sPartsName = controlRow.sPartsName;
                      processData.push(processRow);
                    });
                  }
                });
              }
              if (commonUtils.isNotEmptyArr(returnData.slave0Data)) {
                // eslint-disable-next-line no-loop-func
                returnData.slave0Data.filter(item => item.sType === '2').forEach((slave0Item) => {
                  newCopyTo.slave0 = slave0Item;
                  const newSid = commonUtils.createSid();
                  let slave0Row = commonFunc.getDefaultData(slave0Config, newCopyTo, { newSid }); // 取默认值
                  slave0Row = { ...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo) }; // 取赋值字段
                  slave0Row.handleType = 'add';
                  slave0Row.sId = newSid;
                  slave0Row.sSlaveId = tableDataRow.sId;
                  slave0Row.sParentId = masterData.sId;
                  slave0Data.push(slave0Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.processData)) {
                // eslint-disable-next-line no-loop-func
                returnData.processData.filter(item => item.sType === '3').forEach((processItem) => {
                  newCopyTo.process = processItem;
                  const newSid = commonUtils.createSid();
                  let processRow = commonFunc.getDefaultData(processConfig, newCopyTo, { newSid }); // 取默认值
                  processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                  processRow.handleType = 'add';
                  processRow.sId = newSid;
                  processRow.sSlaveId = tableDataRow.sId;
                  processRow.sParentId = masterData.sId;
                  processData.push(processRow);
                });
              }
              this.props.onSaveState({ controlData, slave0Data, processData });
            }
          }
        } else if (sModelsType === 'sales/salesOrder' && (sFieldName === 'dProductQty' || sFieldName === 'dGiveQty' || sFieldName === 'dStockupQty') && name === 'slave') {
          const {
            controlData, slaveSelectedRowKeys,
          } = this.props;
          const controlSelectedData = controlData.filter(item => item.sSlaveId === slaveSelectedRowKeys[0]);
          for (const one of controlSelectedData) {
            one.dPartsQty = commonUtils.isNull(tableDataRow.dProductQty, 0) + commonUtils.isNull(tableDataRow.dGiveQty, 0);
          }
          this.props.onSaveState({ controlData });
        } else if (sModelsType.includes('purchase/') && (sFieldName === 'sMaterialsId' || sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName') && name === 'slave') {
          const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
          const value = {
            sProName: 'Sp_Cashier_GetMaterialsPrice',
            paramsMap: {
              sMaterialsGuid: changeValue.sMaterialsId,
              sSupplyGuid: masterData.sSupplyId,
            },
          };
          const returnData = (await commonServices.postValueService(app.token, value, url)).data;
          if (returnData.code === 1) {
            tableDataRow.dMaterialsPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice;
          }
          // else {
          //   this.props.getServiceError(returnData);
          // }
        } else if (sModelsType === 'sales/salesCheck' && sFieldName === 'dLossMoney' && name === 'slave') {
          if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcMoney) && commonUtils.isNotEmptyNumber(tableDataRow.dLossMoney)) {
            const dPprice = this.props.getFloatNum('dProductPrice'); /* 获取系统设定小数位 */
            tableDataRow.dProductMoney = commonUtils.convertFixNum(tableDataRow.dSrcMoney - tableDataRow.dLossMoney, dPprice);
          } else if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcMoney) && commonUtils.isEmptyNumber(tableDataRow.dLossMoney)) {
            tableDataRow.dProductMoney = tableDataRow.dSrcMoney;
            tableDataRow.dLossMoney = 0;
          }
        }
        /* 各种金额，税额，价格计算 */
        const models = name === 'materials' ? 'Materials' :
          sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') || sModelsType.includes('semigoodsStock/') ? 'Product' : 'Materials';
        if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/') || sModelsType.includes('semigoodsStock/')) {
          tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models);
        }

        tableDataRow = commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, tableDataRow);

        let dMaterialsMoney = '';
        if (sModelsType.includes('outside/')) { /* 工序发外 && (sFieldName === 'sSupplyName' || sFieldName === 'sProcessName' || sFieldName === 'dAuxiliaryQty') */
          let sComputeId = {};
          const sSupplyId = masterData.sSupplyId;
          const sProcessId = tableDataRow.sProcessId;
          if (commonUtils.isNotEmptyObject(sProcessId)) {
            /* 根据客户id,工序id获取公式ID */
            sComputeId = await commonBusiness.getOutSideProcessFormula({
              token, sModelsId, sSupplyId, sProcessId,
            });
            if (!commonUtils.isEmpty(sComputeId)) {
              dMaterialsMoney = await commonBusiness.getFormulaValue({
                token, sModelsId, masterData, tableDataRow, sComputeId,
              });
              tableDataRow.dMaterialsMoney = dMaterialsMoney;
              tableDataRow = commonBusiness.getCalculateMoney(app, masterData, tableDataRow, 'Materials');
            }
          }

          /* 在detail表（加工工序）中将每一个工序都填写单价，算出金额，几个工序金额应该汇总到slave表（回厂信息）最后一道工序金额中，并要自动算单价 */
          // /* 将改变数量、金额 汇总到slave0回厂信息表 */
          const iSlave0ProductIndex = slave0Data.findIndex(item => commonUtils.isNotEmptyObject(item.sCombineProcessIds) &&  item.sCombineProcessIds.split(',').includes(tableDataRow.sSrcSlaveId));
          if(iSlave0ProductIndex > -1) {
            const addState ={};
            let dMaterialsProductMoneyAll = 0;
            let dMaterialsProductPrice = 0;
            const slaveORow = slave0Data[iSlave0ProductIndex];
            /* 合计该组金额 */
            const slaveFilterData = tableData.filter(item => commonUtils.isNotEmptyObject(slaveORow.sCombineProcessIds) && slaveORow.sCombineProcessIds.split(',').includes(item.sSrcSlaveId));
            if(commonUtils.isNotEmptyArr(slaveFilterData)) {
              for (const one of slaveFilterData) {
                if(one.sId === tableDataRow.sId) {
                  dMaterialsProductMoneyAll += tableDataRow.dMaterialsMoney;
                } else {
                  dMaterialsProductMoneyAll += commonUtils.isNull(one.dMaterialsMoney, 0);
                }
              }
            }
            // /* 更新数量 */
            // if(slaveORow.sCombineProcessIds){
            //   const sFirstId =commonUtils.isNotEmptyArr(slaveORow.sCombineProcessIds.split(',')) ? slaveORow.sCombineProcessIds.split(',')[0] : '' ; /* 找到第一条 */
            //   if(sFirstId === tableDataRow.sSrcSlaveId) {
            //     addState.dAuxiliaryQty = tableDataRow.dAuxiliaryQty;
            //     addState.dMaterialsQty = tableDataRow.dMaterialsQty;
            //   }
            // }

            /* 更新数量（取同一部件，工序名称相同项数据的数量） */
            if(slaveORow.sCombineProcessIds){
              const sCombineProcessIdsArr = slaveORow.sCombineProcessIds.split(',');
              if (tableDataRow.sProcessName === slaveORow.sProcessName && sCombineProcessIdsArr.includes(tableDataRow.sSrcSlaveId)) {
                addState.dAuxiliaryQty = tableDataRow.dAuxiliaryQty;
                addState.dMaterialsQty = tableDataRow.dMaterialsQty;
              }
            }
            if(dMaterialsProductMoneyAll !==0) {
              if(tableDataRow.dAuxiliaryQty !== 0 ) {
                dMaterialsProductPrice = commonUtils.convertFixNum(dMaterialsProductMoneyAll / slaveORow.dMaterialsQty, dNetPrice);
              }
              addState.dMaterialsMoney = dMaterialsProductMoneyAll;
              addState.dMaterialsPrice = dMaterialsProductPrice;
            }
            addState.handleType = commonUtils.isEmpty(slave0Data[iSlave0ProductIndex].handleType) ? 'update' : slave0Data[iSlave0ProductIndex].handleType;
            slave0Data[iSlave0ProductIndex] = { ...slave0Data[iSlave0ProductIndex], ... addState};
            slave0Data[iSlave0ProductIndex] = commonBusiness.getCalculateMoney(app, masterData, slave0Data[iSlave0ProductIndex], 'Materials');
          }
          this.props.onSaveState({ slave0Data, slaveData });
        } else if (sModelsType === 'outside/outsideprocess1' && (sFieldName === 'sSupplyName' || sFieldName === 'sProcessName' || sFieldName === 'dAuxiliaryQty')) { /* 工序发外 */
          tableDataRow = commonBusiness.getCalculateMoney(app, masterData, tableDataRow, 'Materials');
        }
        if (isWait) {
          return tableDataRow;
        } else {
          tableData[iIndex] = tableDataRow;
          this.props.onSaveState({ [`${name}Data`]: tableData, enabled: true });
        }
      }
    };

    /**   删除表格数据   */
    otherTableDel = (name, tableSelectedRowKeys) => {
      const tableData = this.props[`${name}Data`];
      let tableDelData = this.props[`${name}DelData`];
      tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData;
      for (const sId of tableSelectedRowKeys) {
        /*   看看删除集合和从表中是否都存在该条数据   */
        let tableDataIndex = tableData.findIndex(item => item.sControlId === sId);
        while (tableDataIndex > -1) {
          /*   删除从表中的数据并存入删除集合中   */
          const slaveDataFilter = tableData[tableDataIndex];
          tableData.splice(tableDataIndex, 1);
          slaveDataFilter.handleType = 'del';
          tableDelData.push(slaveDataFilter);
          tableDataIndex = tableData.findIndex(item => item.sControlId === sId);
        }
      }
      return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: [] };
    };

    otherCommonTableDel = (name, tableSelectedRowKeys, sKey) => {
      const tableData = this.props[`${name}Data`];
      let tableDelData = this.props[`${name}DelData`];
      tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData;
      for (const sId of tableSelectedRowKeys) {
        /*   看看删除集合和从表中是否都存在该条数据  */
        let tableDataIndex = commonUtils.isNotEmptyArr(tableData) ?  tableData.findIndex(item => item[sKey] === sId) :  -1;
        while (tableDataIndex > -1) {
          /*   删除从表中的数据并存入删除集合中   */
          const slaveDataFilter = tableData[tableDataIndex];
          tableData.splice(tableDataIndex, 1);
          slaveDataFilter.handleType = 'del';
          tableDelData.push(slaveDataFilter);
          tableDataIndex = tableData.findIndex(item => item[sId] === sId);
        }
      }
      return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: [] };
    };
    handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => {
      const { sComputeId, sConversionComputeId, sReConversionComputeId } = tableDataRow;
      if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || sFieldName === 'dAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle') {
        if (commonUtils.isEmpty(sComputeId)) {
          tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, sFieldName === 'dConversionQty' ? 'dConversionQty' : 'dAuxiliaryQty', 'dMaterialsQty');
        } else {
          tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId,
          });
        }
        if (sFieldName !== 'dConversionQty' && !commonUtils.isEmpty(sConversionComputeId)) {
          tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId: sConversionComputeId,
          });
        }
      } else if (sFieldName === 'dMaterialsQty') {
        const { sReComputeId } = tableDataRow;
        if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) {
          tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryQty');
        } else if (tableDataRow.bInverse) {
          tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId: sReComputeId,
          });
        }
        if (!commonUtils.isEmpty(sReConversionComputeId)) {
          tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId: sReConversionComputeId,
          });
        }
      } else if (sFieldName === 'dAuxiliaryLossQty') {
        if (commonUtils.isEmpty(sComputeId)) {
          tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, sFieldName, 'dLossQty');
        } else {
          tableDataRow.dLossQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId,
          });
        }
        if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) {
          tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty;
          tableDataRow.dMaterialsQty = commonUtils.convertFixNum(tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty, 6);
        }
      } else if (sFieldName === 'dLossQty') {
        const { sReComputeId } = tableDataRow;
        if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) {
          tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryLossQty');
        } else if (tableDataRow.bInverse) {
          tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId: sReComputeId,
          });
        }
        if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) {
          tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty;
          tableDataRow.dMaterialsQty = tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty;
        }
      } else if (sFieldName === 'sProcessId' || sFieldName === 'sProcessNo' || sFieldName === 'sProcessName') {
        const sProcessId = changeValue.sProcessId;
        const url = `${commonConfig.server_host}process/outsideprocess?sModelsId=${sModelsId}&sProcessId=${sProcessId}`;
        const dataReturn = (await commonServices.getService(token, url)).data;
        if (dataReturn.code === 1) {
          if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows)) {
            tableDataRow.dMaterialsPrice = dataReturn.dataset.rows[0].dMaterialsPrice;
          }
          tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dMaterialsPrice', masterData, tableDataRow);
        }
      }
      return tableDataRow;
    }

    handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew) => {
      const {
        sModelsId, sModelsType, masterData: masterDataOld,app, masterConfig, slaveConfig, token,
      } = this.props;
      let { slaveData, slave0Data } = this.props;
      const addState = {};
      const masterData = masterDataNew === undefined ? masterDataOld === undefined ? {} : masterDataOld : masterDataNew;
      let bNewSlaveData = false;

      if ( sModelsType && (sModelsType.includes('sales/') || sModelsType.includes('productStock/')) && ( sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName')) {
        if (commonUtils.isNotEmptyArr(slaveData)) {
          // 从表有数据，请删除后修改客户！不能去掉
          if (slaveData.length === 1 && commonUtils.isEmpty(slaveData[0].sProductId)) {
            bNewSlaveData = true;
          } else {
            message.warn(commonFunc.showMessage(app.commonConst, 'slaveHasDataPleaseDel'));
            return;
          }
        }
        changeValue.tGetPayDate = commonBusiness.getGeyPayDate({ ...masterData, ...changeValue });
        // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductId', []);
        // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductNo', []);
        // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductName', []);
        //
        // commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductId', []);
        // commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductNo', []);
        // commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductName', []);
      } if (sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName') {
        changeValue.tGetPayDate = commonBusiness.getGeyPayDate({ ...masterData, ...changeValue });
      } else if (sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') {
        commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sMaterialsId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sMaterialsNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sMaterialsName', []);
        if (sModelsType === 'materialsStock/materialsCheck' || sModelsType === 'productStock/productCheck') {
          let value = {};
          if (sModelsType === 'materialsStock/materialsCheck') {
            value = {
              sProName: 'Sp_System_AccountSquareCheck',
              paramsMap: {
                iType2: 1,
                sWareHouseGuid: commonUtils.isNotEmptyObject(changeValue.sWareHouseId) ? changeValue.sWareHouseId : '',
              },
            };
          } else if (sModelsType === 'productStock/productCheck') {
            value = {
              sProName: 'Sp_System_AccountSquareCheck',
              paramsMap: {
                iType2: 2,
                sWareHouseGuid: commonUtils.isNotEmptyObject(changeValue.sWareHouseId) ? changeValue.sWareHouseId : '',
              },
            };
          }
          const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
          const returnData = (await commonServices.postValueService(app.token, value, url)).data;
          if (returnData.code === 1) {
            const outData = returnData.dataset.rows[0].dataSet.outData[0];
            if (outData.sCode === -1) {
              message.error(outData.sReturn);
              return;
            }
          } else {
            this.props.getServiceError(returnData);
            return;
          }
        }
      } else if (sModelsType.includes('cashier/') && sFieldName === 'sBillType') {
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sCustomerName', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sSupplyName', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyId', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyNo', []);
        commonUtils.setStoreDropDownData(sModelsId, 'master', 'sFamilyName', []);
        changeValue.sCustomerId = '';
        const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sCustomerId');
        if (iIndex > -1) {
          masterConfig.gdsconfigformslave[iIndex].bReGetDropDown = true;
        }
        changeValue.sSupplyId = '';
        const iSupplyIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sSupplyId');
        if (iSupplyIndex > -1) {
          masterConfig.gdsconfigformslave[iSupplyIndex].bReGetDropDown = true;
        }
        /* 财务调整中切换调整类型后，对象名称清空 */
        const sBillTypeIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sFamilyName');
        if (sBillTypeIndex > -1) {
          masterData.sFamilyName = '';
        }
        this.props.onSaveState({ masterConfig });
      } else if (sFieldName === 'sGetPayId') {
        changeValue.tGetPayDate = commonBusiness.getGeyPayDate({ ...masterData, ...changeValue });
      } else if (sFieldName === 'sSettlementId') {
        if (changeValue.sSettlementId === 'cash') {
          const sBankAccountIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankAccount');
          if (sBankAccountIndex > -1) {
            masterConfig.gdsconfigformslave[sBankAccountIndex].iTag = 1;
            masterData.sBankAccount = '';
          }
          const sInvoiceNoIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sInvoiceNo');
          if (sInvoiceNoIndex > -1) {
            masterConfig.gdsconfigformslave[sInvoiceNoIndex].iTag = 1;
            masterData.sInvoiceNo = '';
          }
          const sBankIdIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankId' || item.sName === 'sBankName');
          if (sBankIdIndex > -1) {
            masterConfig.gdsconfigformslave[sBankIdIndex].iTag = 1;
            masterData.sBankId = '';
            masterData.sBankName = '';
          }
          const tDueDateIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tDueDate');
          if (tDueDateIndex > -1) {
            masterConfig.gdsconfigformslave[tDueDateIndex].iTag = 1;
            delete masterData.tDueDate;
          }
        }
        if (changeValue.sSettlementId === 'bank') {
          const sInvoiceNoIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sInvoiceNo');
          if (sInvoiceNoIndex > -1) {
            masterConfig.gdsconfigformslave[sInvoiceNoIndex].iTag = 1;
            masterData.sInvoiceNo = '';
          }
          const sBankAccountIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankAccount');
          if (sBankAccountIndex > -1) {
            masterConfig.gdsconfigformslave[sBankAccountIndex].iTag = 0;
          }
          const sBankIdIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankId' || item.sName === 'sBankName');
          if (sBankIdIndex > -1) {
            masterConfig.gdsconfigformslave[sBankIdIndex].iTag = 0;
          }
          const tDueDateIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tDueDate');
          if (tDueDateIndex > -1) {
            masterConfig.gdsconfigformslave[tDueDateIndex].iTag = 1;
            delete masterData.tDueDate;
          }
        }
        if (changeValue.sSettlementId === 'bill') {
          const sBankAccountIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankAccount');
          if (sBankAccountIndex > -1) {
            masterConfig.gdsconfigformslave[sBankAccountIndex].iTag = 1;
            masterData.sBankAccount = '';
          }
          const sInvoiceNoIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sInvoiceNo');
          if (sInvoiceNoIndex > -1) {
            masterConfig.gdsconfigformslave[sInvoiceNoIndex].iTag = 0;
          }
          const sBankIdIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sBankId');
          if (sBankIdIndex > -1) {
            masterConfig.gdsconfigformslave[sBankIdIndex].iTag = 0;
          }
          const tDueDateIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tDueDate');
          if (tDueDateIndex > -1) {
            masterConfig.gdsconfigformslave[tDueDateIndex].iTag = 0;
          }
        }
      }
      let returnData = this.props.onChange(name, sFieldName, changeValue, sId, dropDownData, true, masterData);
      const masterDataAfter = commonBusiness.getKeyUpEvent(name, sFieldName, masterConfig, returnData.masterData, {}, true);
      if (commonUtils.isNotEmptyObject(masterDataAfter)) {
        returnData.masterData = masterDataAfter;
      }
      if (sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName' || sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' || sFieldName === 'tDeliverDate') {
        const slaveDataNew = [];
        for (const item of slaveData) {
          let tableDataRow = ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') && (sModelsType.includes('materialsStock/productionmaterialsadjust'))) ?
            { ...item } : { ...item, [sFieldName]: changeValue[sFieldName] };
          if (sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName') {
            tableDataRow.sTaxId = changeValue.sTaxId;
            tableDataRow.sTaxNo = changeValue.sTaxNo;
            tableDataRow.sTaxName = changeValue.sTaxName;
            tableDataRow.dTaxRate = changeValue.dTaxRate;
            tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
            const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') || sModelsType.includes('semigoodsStock/') ? 'Product' : 'Materials';
            let dMaterialsMoney = '';
            if (sModelsType && sModelsType.includes('outside/')) { /* 工序发外 */
              let sComputeId = '';
              const sSupplyId = changeValue.sSupplyId;
              const sProcessId = tableDataRow.sProcessId;
              /* 根据客户id,工序id获取公式ID */
              if (commonUtils.isNotEmptyObject(sSupplyId) && commonUtils.isNotEmptyObject(sProcessId)) {
                sComputeId = await commonBusiness.getOutSideProcessFormula({
                  token, sModelsId, sSupplyId, sProcessId,
                });
                console.log('sComputeId', sComputeId);
                if (commonUtils.isNotEmptyObject(sComputeId)) {
                  dMaterialsMoney = await commonBusiness.getFormulaValue({
                    token, sModelsId, masterData: returnData.masterData, tableDataRow, sComputeId,
                  });
                  console.log('dMaterialsMoney', dMaterialsMoney);
                  tableDataRow.dMaterialsMoney = dMaterialsMoney;
                  tableDataRow = commonBusiness.getCalculateMoney(app, returnData.masterData, tableDataRow, 'Materials');
                }
                // else {
                //   tableDataRow.dMaterialsPrice = 0;
                //   tableDataRow.dMaterialsMoney = 0;
                // }
              }
            } else {
              tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'sTaxId', returnData.masterData, tableDataRow);
            }
          } else if (sFieldName === 'sCurrency' || sFieldName === 'dCurrencyRate') {
            tableDataRow = commonBusiness.getCalculateAllMoney(app, models, `dN${models}Money`, returnData.masterData, tableDataRow);
            tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
          }
          if ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') && (!sModelsType.includes('materialsStock/productionmaterialsadjust'))) {
            tableDataRow.sWareHouseId = changeValue.sWareHouseId;
            tableDataRow.sWareHouseNo = changeValue.sWareHouseNo;
            tableDataRow.sWareHouseName = changeValue.sWareHouseName;
            tableDataRow.sLocationId = changeValue.sLocationId;
            tableDataRow.sLocationNo = changeValue.sLocationNo;
            tableDataRow.sLocationName = changeValue.sLocationName;
            tableDataRow.sWareHouseLocationId = changeValue.sWareHouseLocationId;
            tableDataRow.sWareHouseLocationNo = changeValue.sWareHouseLocationNo;
            tableDataRow.sWareHouseLocationName = changeValue.sWareHouseLocationName;
            tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
          }
          slaveDataNew.push(tableDataRow);
        }
        addState.slaveData = slaveDataNew;
        // this.props.onSaveState({ slaveData: slaveDataNew });

        if (sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName') {
          const slave0DataNew = [];
          for (const item of slave0Data) {
            let tableDataRow = { ...item };
            tableDataRow.sTaxId = changeValue.sTaxId;
            tableDataRow.sTaxNo = changeValue.sTaxNo;
            tableDataRow.sTaxName = changeValue.sTaxName;
            tableDataRow.dTaxRate = changeValue.dTaxRate;
            tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
            tableDataRow = commonBusiness.getCalculateMoney(app, returnData.masterData, tableDataRow, 'Materials');
            slave0DataNew.push(tableDataRow);
          }
          addState.slave0Data = slave0DataNew;
        }
      } else if ((sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName')) {
        if (bNewSlaveData && commonUtils.isEmptyArr(slaveData)) {
          const slaveDataNew = [];
          const allTableData = {};
          allTableData.master = returnData.masterData;
          const newSid = commonUtils.createSid();
          const tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData, { newSid });
          tableDataRowAdd.handleType = 'add';
          tableDataRowAdd.sId = newSid;
          tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
          tableDataRowAdd.key = tableDataRowAdd.sId;
          tableDataRowAdd.bDefault = false;
          tableDataRowAdd.iOrder = 0;
          slaveDataNew.push(tableDataRowAdd);
          addState.slaveData = slaveDataNew;
          // this.props.onSaveState({ slaveData: slaveDataNew });
        } else if (sModelsType.includes('sales/') || sModelsType.includes('cashier/') || sModelsType.includes('manufacture/')) { // 获取应收款
          if (commonUtils.isNotEmptyObject(masterData)) {
            this.getCustomerReceipt({ masterData: returnData.masterData });
          }
        }
      } else if (sFieldName === 'sExpenseeName') {
        let { slaveDelData, slave0DelData}= this.props;
        const allTableData = {};
        allTableData.master = returnData.masterData;
        const newCopyTo = {};
        newCopyTo.master = masterData;
        const slaveDataNew = [];
        const slave0DataNew = [];
        if(commonUtils.isEmptyArr(slaveDelData)) {
          slaveDelData = [];
        }
        if(commonUtils.isEmptyArr(slave0DelData)) {
          slave0DelData = [];
        }
        //获取部门名称数据
        let sDepartNameDropDown;
        const masterIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sDepartName');
        slaveData.forEach((item) => {
          item.handleType = 'del';
          slaveDelData.push(item);
        });
        if (masterIndex > -1) {
          const config = masterConfig.gdsconfigformslave[masterIndex];
          const slaveAssignField = config.sAssignField || '';
          const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[masterIndex], returnData.masterData);
          sDepartNameDropDown = sqlDropDownData.dropDownData;
          sDepartNameDropDown.forEach((item) => {
            const newSid = commonUtils.createSid();
            let tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData, { newSid });
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(slaveAssignField, item, newCopyTo) }; //  取赋值字段
            tableDataRowAdd.handleType = 'add';
            tableDataRowAdd.sId = newSid;
            tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
            tableDataRowAdd.key = tableDataRowAdd.sId;
            tableDataRowAdd.bDefault = false;
            tableDataRowAdd.iOrder = 0;
            slaveDataNew.push(tableDataRowAdd);
          });
        }
        // 获取工作中心数据
        let sWorkCenterNameDropDown;
        const master1Index = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sWorkCenterName');
        slave0Data.forEach((item) => {
          item.handleType = 'del';
          slave0DelData.push(item);
        });
        if (master1Index > -1) {
          const config = masterConfig.gdsconfigformslave[master1Index];
          const slaveAssignField = config.sAssignField || '';
          const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[master1Index], returnData.masterData);
          sWorkCenterNameDropDown = sqlDropDownData.dropDownData;
          sWorkCenterNameDropDown.forEach((item) => {
            const newSid = commonUtils.createSid();
            let tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData, { newSid });
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(slaveAssignField, item, newCopyTo) }; //  取赋值字段
            tableDataRowAdd.handleType = 'add';
            tableDataRowAdd.sId = newSid;
            tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
            tableDataRowAdd.key = tableDataRowAdd.sId;
            tableDataRowAdd.bDefault = false;
            tableDataRowAdd.iOrder = 1;
            slave0DataNew.push(tableDataRowAdd);
          })
        }
        addState.slaveData = slaveDataNew;
        addState.slaveDelData = slaveDelData;
        addState.slave0Data = slave0DataNew;
        addState.slave0DelData = slave0DelData;
      }
      const models = name === 'materials' ? 'Materials' :
        sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') || sModelsType.includes('semigoodsStock/') ? 'Product' : 'Materials';
      if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/') || sModelsType.includes('semigoodsStock/')) {
        const masterData = await this.handleMaterialsChange(returnData.masterData, sModelsId, masterData, changeValue, sFieldName, app, token, models);
        returnData = { ...returnData, masterData };
      }

      /* 将改变数量、金额 汇总到slave0回厂信息表 */
      if (commonUtils.isNotEmptyArr(addState.slaveData) && commonUtils.isNotEmptyArr(addState.slave0Data)) {
        const { dNetPrice } = app.decimals;
        for (const tableDataRow of addState.slaveData) {
          const iSlave0ProductIndex = addState.slave0Data.findIndex(item => commonUtils.isNotEmptyObject(item.sCombineProcessIds) &&  item.sCombineProcessIds.split(',').includes(tableDataRow.sSrcSlaveId));
          if(iSlave0ProductIndex > -1) {
            const addState1 = {};
            let dMaterialsProductMoneyAll = 0;
            let dMaterialsProductPrice = 0;
            const slaveORow = slave0Data[iSlave0ProductIndex];
            /* 合计该组金额 */
            const slaveFilterData = addState.slaveData.filter(item => commonUtils.isNotEmptyObject(slaveORow.sCombineProcessIds) && slaveORow.sCombineProcessIds.split(',').includes(item.sSrcSlaveId));
            if(commonUtils.isNotEmptyArr(slaveFilterData)) {
              for (const one of slaveFilterData) {
                if(one.sId === tableDataRow.sId) {
                  dMaterialsProductMoneyAll += commonUtils.isNull(tableDataRow.dMaterialsMoney, 0);
                } else {
                  dMaterialsProductMoneyAll += commonUtils.isNull(one.dMaterialsMoney, 0);
                }
              }
            }

            /* 更新数量（取同一部件，工序名称相同项数据的数量） */
            if(slaveORow.sCombineProcessIds){
              const sCombineProcessIdsArr = slaveORow.sCombineProcessIds.split(',');
              if (tableDataRow.sProcessName === slaveORow.sProcessName && sCombineProcessIdsArr.includes(tableDataRow.sSrcSlaveId)) {
                addState1.dAuxiliaryQty = tableDataRow.dAuxiliaryQty;
                addState1.dMaterialsQty = tableDataRow.dMaterialsQty;
              }
            }
            if(dMaterialsProductMoneyAll !==0) {
              if(tableDataRow.dAuxiliaryQty !== 0) {
                dMaterialsProductPrice = commonUtils.convertFixNum(dMaterialsProductMoneyAll / slaveORow.dMaterialsQty, dNetPrice);
              }
              addState1.dMaterialsMoney = dMaterialsProductMoneyAll;
              addState1.dMaterialsPrice = dMaterialsProductPrice;
            }
            addState1.handleType = commonUtils.isEmpty(addState.slave0Data[iSlave0ProductIndex].handleType) ? 'update' : addState.slave0Data[iSlave0ProductIndex].handleType;
            addState.slave0Data[iSlave0ProductIndex] = { ...addState.slave0Data[iSlave0ProductIndex], ... addState1};
            addState.slave0Data[iSlave0ProductIndex] = commonBusiness.getCalculateMoney(app, masterData, addState.slave0Data[iSlave0ProductIndex], 'Materials');
          }
        }
      }

      if (isWait) {
        return { ...returnData, ...addState };
      } else {
        this.props.onSaveState({ ...returnData, ...addState });
        return returnData;
      }
    }

    handleBtnPrint =async (sActiveId, checked, eKey) => {
      const {
        app, sModelsId, masterConfig, masterData, slaveConfig, sModelsType, reportData, menuChildData, formRoute, controlConfig,
      } = this.props;
      if (sModelsType === 'manufacture/workOrder') {
        this.handleUpdateProduction();
      }
      const { token } = app;
      const queryFilter = {};
      queryFilter[masterConfig.sId] = { sId: masterData.sId };
      if (commonUtils.isNotEmptyObject(slaveConfig)) {
        queryFilter[slaveConfig.sId] = { sSqlCondition: { sParentId: masterData.sId } };
      }
      const queryFilterJson = JSON.stringify(queryFilter);
      // const masterDataJson = JSON.stringify(masterData);
      /* 拿到打印报表名称 */
      let printReportName = 'report';
      let printCustomerReportName = 'report';
      if (commonUtils.isNotEmptyArr(reportData)) {
        const iIndex = reportData.findIndex(item => item.sId === sActiveId);
        if (iIndex > -1) {
          printReportName = reportData[iIndex].sReportName;
        }
      }
      if (commonUtils.isNotEmptyArr(menuChildData)) {
        const iIndex = menuChildData.findIndex(item => item.sId === sActiveId);
        if (iIndex > -1) {
          printCustomerReportName = menuChildData[iIndex].sReportName;
        }
      }
      let urlPrint = '';
      if (formRoute === '/indexPage/printlabel') {
        if (commonUtils.isNotEmptyObject(masterData) && masterData.dTrunkQty !== undefined && masterData.dFractionQty !== undefined && masterData.dPackQty !== undefined) { // masterData中必填的三个字段
          // const param = masterDataJson;
          /* 把masterData放在数组中 */
          const ListData = [];
          ListData.push(masterData);
          const param = JSON.stringify(ListData);
          if (eKey.indexOf('BtnPrint.') > -1) {
            urlPrint = `${commonConfig.file_host}printReport/printPdf/${sActiveId}/${printReportName}.pdf?${checked ? 'fileType=.xlsx&' : ''}printType=noquery&sModelsId=${sModelsId}&token=${encodeURIComponent(token)}`;
          } else if (eKey.indexOf('BtnPrintCus.') > -1) {
            urlPrint = `${commonConfig.file_host}printReport/printPdf/${printCustomerReportName}?${checked ? 'fileType=.xlsx&' : ''}printType=noquery&sModelsId=${sModelsId}&token=${encodeURIComponent(token)}`;
          }
          /* Get提交地址栏参数过多,更改Get提交为Post提交 */
          this.handleOpenPost(urlPrint, param);
        } else {
          const dTrunkQtyName = masterConfig.gdsconfigformslave.filter(item => item.sName === 'dTrunkQty');
          const dFractionQtyName = masterConfig.gdsconfigformslave.filter(item => item.sName === 'dFractionQty');
          const dPackQtyName = masterConfig.gdsconfigformslave.filter(item => item.sName === 'dPackQty');
          if (masterData.dTrunkQty === undefined && commonUtils.isNotEmptyObject(dTrunkQtyName)) {
            message.error(`${dTrunkQtyName[0].showName} 必填项！`);
          } else if (masterData.dFractionQty === undefined && commonUtils.isNotEmptyObject(dFractionQtyName)) {
            message.error(`${dFractionQtyName[0].showName} 必填项！`);
          } else if (masterData.dPackQty === undefined && commonUtils.isNotEmptyObject(dPackQtyName)) {
            message.error(`${dPackQtyName[0].showName} 必填项！`);
          }
          return;
        }
      } else if (eKey.indexOf('BtnPrint.') > -1) {
        let { controlSelectedRowKeys } = this.props;
        /* 不出现选择框，则打印全部；出现选择框，则打印勾选的 */
        let bisMutiSelect = false;
        if (commonUtils.isNotEmptyObject(controlConfig) && commonUtils.isNotEmptyArr(controlConfig.gdsconfigformslave)) {
          const filterData = controlConfig.gdsconfigformslave.filter(item => item.sControlName === 'bisMutiSelect');
          if (commonUtils.isNotEmptyArr(filterData)) {
            bisMutiSelect = filterData[0].bVisible;
          }
        }
        if (bisMutiSelect === false || bisMutiSelect === undefined) {
          controlSelectedRowKeys = [];
        }
        urlPrint = `${commonConfig.file_host}printReport/printPdf/${sActiveId}/${printReportName}.pdf?${checked ? 'fileType=.xlsx&' : ''}sModelsId=${sModelsId}&sMaintableId=${masterConfig.sId}&sControlIds=${commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlSelectedRowKeys : []}`;
      } else if (eKey.indexOf('BtnPrintCus.') > -1) {
        urlPrint = `${commonConfig.file_host}printReport/printPdf/${printCustomerReportName}?${checked ? 'fileType=.xlsx&' : ''}sModelsId=${sModelsId}&sMaintableId=${masterConfig.sId}`;
      }
      if (formRoute !== '/indexPage/printlabel') {
        window.open(`${encodeURI(`${urlPrint}&queryFilter=${queryFilterJson}`)}&token=${encodeURIComponent(token)}`);
      }
    };

    handleOpenPost= (url, params) => {
      const newWin = window.open();
      let formStr = '';
      formStr = `<form style="visibility:hidden;" method="POST" action="${url}">` +
        `<input type="hidden" name="masterData" value='${params}' />` +
        '</form>';
      newWin.document.body.innerHTML = formStr;
      newWin.document.forms[0].submit();
      return newWin;
    }

    handleUpdateProduction = async () => {
      const { sModelsId, masterData } = this.props;
      const { sBillNo, sId } = masterData || {};
      const dataUrl = `${commonConfig.server_host}business/addUpdateDelBusinessData?sModelsId=${sModelsId}&sBillNo=${sBillNo}&sSysLogSrcId=${sId}`;
      const value = {
        data: [{
          sTable: 'mftworkordermaster',
          column: [{ handleType: 'update', sId: masterData.sId, bProduction: 1 }],
        }],
        sClientType: '1',
      };
      const dataReturn = (await commonServices.postValueService(this.props.app.token, value, dataUrl)).data;
      if (dataReturn.code === 1) {
        message.success(dataReturn.msg);
      } else {
        this.props.getServiceError(dataReturn);
      }
    };

    handleTitleChange = (name, slavePagination) => {
      this.props.onSaveState({ [`${name}Pagination`]: slavePagination });
    };

    /* 工单、工艺卡、报价单控制表回带图片地址 */
    handleFilfileManageOk= async (controlFilfileData, controlFilfileDelData, sSrcSlaveId) => {
      const {
        controlData: tableData, app, sModelsId, token, controlConfig,
      } = this.props;
      if (commonUtils.isNotEmptyObject(sSrcSlaveId)) {
        if (commonUtils.isNotEmptyArr(controlFilfileDelData)) {
          const addState = {};
          const iIndex = tableData.findIndex(item => item.sId === sSrcSlaveId);
          if (iIndex > -1) {
            const tableDataNewRow = tableData[iIndex];
            const { sMaterialsPicturePath, sMachinePicturePath } = tableDataNewRow;
            const controlsMaterialsPictureDelData = controlFilfileDelData.filter(item => item.sType === '3'); /* 开料 */
            if (commonUtils.isNotEmptyArr(controlsMaterialsPictureDelData)) {
              controlsMaterialsPictureDelData.forEach((slaveItem) => {
                if (slaveItem.sPicturePath === sMaterialsPicturePath) {
                  addState.sMaterialsPicturePath = '';
                }
              });
            }
            const sMachinePictureDelPath = controlFilfileDelData.filter(item => item.sType === '4'); /* 联版 */
            if (commonUtils.isNotEmptyArr(sMachinePictureDelPath)) {
              sMachinePictureDelPath.forEach((slaveItem) => {
                if (slaveItem.sPicturePath === sMachinePicturePath) {
                  addState.sMachinePicturePath = '';
                }
              });
            }
            if (commonUtils.isNotEmptyObject(addState) && (addState.sMachinePicturePath === '' || addState.sMaterialsPicturePath === '')) {
              tableData[iIndex] = { ...tableDataNewRow, ...addState };
              const data = [];
              const updataData = {};
              const updateWhere = {};
              const column = {};
              if (addState.sMaterialsPicturePath === '') {
                column.sMaterialsPicturePath = addState.sMaterialsPicturePath;
              }
              if (addState.sMachinePicturePath === '') {
                column.sMachinePicturePath = addState.sMachinePicturePath;
              }
              if (commonUtils.isNotEmptyObject(tableDataNewRow.sId) && commonUtils.isNotEmptyObject(column)) {
                updateWhere.sId = tableDataNewRow.sId;
                updataData.sTable = controlConfig.sTbName;
                updataData.sWhere = updateWhere;
                updataData.column = column;
                data.push(updataData);
                /* 调用接口将图片地址存入控制表 */
                const configUrl = `${commonConfig.server_host}business/updateBusinessData?sModelsId=${sModelsId}`;
                const value = {
                  data,
                  sClientType: '1',
                };
                const dataReturn = (await commonServices.postValueService(token, value, configUrl)).data;
                if (dataReturn.code === 1) {
                  /* 刷新 */
                  if (this.props.app.currentPane.refresh !== undefined) {
                    this.props.app.currentPane.refresh();
                  }
                } else {
                  this.getServiceError(dataReturn);
                }
              }
            }
          }
        }
        if (commonUtils.isNotEmptyArr(controlFilfileData)) {
          const addState = {};
          const iIndex = tableData.findIndex(item => item.sId === sSrcSlaveId);
          if (iIndex > -1) {
            const tableDataNewRow = tableData[iIndex];
            const { sMaterialsPicturePath, sMachinePicturePath } = tableDataNewRow;
            const controlsMaterialsPictureData = controlFilfileData.filter(item => item.sType === '3');
            if (commonUtils.isNotEmptyArr(controlsMaterialsPictureData)) {
              addState.sMaterialsPicturePath = commonUtils.isNotEmptyObject(controlsMaterialsPictureData[0].sPicturePath) ? controlsMaterialsPictureData[0].sPicturePath : ''; /* 上机默认取上传图片的第一条 */
            }
            const controlsMachinePictureData = controlFilfileData.filter(item => item.sType === '4');
            if (commonUtils.isNotEmptyArr(controlsMachinePictureData)) {
              addState.sMachinePicturePath = commonUtils.isNotEmptyObject(controlsMachinePictureData[0].sPicturePath) ? controlsMachinePictureData[0].sPicturePath : '';
            }
            if (commonUtils.isNotEmptyObject(addState)) {
              tableData[iIndex] = { ...tableDataNewRow, ...addState };
              const data = [];
              const updataData = {};
              const updateWhere = {};
              const column = {};
              if (commonUtils.isNotEmptyObject(addState.sMaterialsPicturePath) && addState.sMaterialsPicturePath !== sMaterialsPicturePath) {
                column.sMaterialsPicturePath = addState.sMaterialsPicturePath;
              }
              if (commonUtils.isNotEmptyObject(addState.sMachinePicturePath) && addState.sMachinePicturePath !== sMachinePicturePath) {
                column.sMachinePicturePath = addState.sMachinePicturePath;
              }
              if (commonUtils.isNotEmptyObject(tableDataNewRow.sId) && commonUtils.isNotEmptyObject(column)) {
                updateWhere.sId = tableDataNewRow.sId;
                updataData.sTable = controlConfig.sTbName;
                updataData.sWhere = updateWhere;
                updataData.column = column;
                data.push(updataData);
                /* 调用接口将图片地址存入控制表 */
                const configUrl = `${commonConfig.server_host}business/updateBusinessData?sModelsId=${sModelsId}`;
                const value = {
                  data,
                  sClientType: '1',
                };
                const dataReturn = (await commonServices.postValueService(token, value, configUrl)).data;
                if (dataReturn.code === 1) {
                  this.props.onSaveState({ tableData });
                  /* 刷新 */
                  if (this.props.app.currentPane.refresh !== undefined) {
                    this.props.app.currentPane.refresh();
                  }
                } else {
                  this.getServiceError(dataReturn);
                }
              }
            }
          }
        }
      } else {
        return message.warning(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));
      }
    }
    // 收付款分摊
    handleShare = () => {
      /* 分摊 */
      const { masterData: masterDataOld, slaveData: slaveDataOld, app } = this.props;
      const { dNetMoney } = app.decimals;
      const masterData = { ...masterDataOld };
      const slaveData = [];
      slaveDataOld.forEach((item) => {
        slaveData.push({ ...item });
      });

      const dTotalMoney = masterData.dTotalMoney !== undefined ? masterData.dTotalMoney : 0;
      let minusSum = 0; /* 负数求和 */
      let minusRoundingSum = 0; /* 负数舍入求和 */
      const minusData = []; /* 负数集 */
      let positiveSum = 0; /* 正数求和 */
      let positiveRoundingSum = 0; /* 正数舍入求和 */
      const positiveData = []; /* 正数集 */
      slaveData.forEach((child) => {
        child.dTotalMoney = 0;
        child.dRoundingMoney = commonUtils.isNum(child.dRoundingMoney) ? child.dRoundingMoney : 0;
        if (child.dBalanceMoney < 0) {
          minusSum -= Math.abs(child.dBalanceMoney);
          minusRoundingSum -= Math.abs(child.dRoundingMoney);
          minusData.push(child);
        } else {
          positiveSum += child.dBalanceMoney;
          positiveRoundingSum += child.dRoundingMoney;
          positiveData.push(child);
        }
      });
      if (commonUtils.convertFixNum(((minusSum - minusRoundingSum) + (positiveSum - positiveRoundingSum)) - dTotalMoney, dNetMoney) <= 0) {
        /* 够扣 */
        positiveSum -= minusRoundingSum;
        positiveSum -= positiveRoundingSum;
        positiveSum -= dTotalMoney; /* 去除分摊金额 */
        if (positiveSum >= 0) {
          for (let i = 0; i < minusData.length; i += 1) {
            /* 负数遍历 */
            const dBalanceMoney = Math.abs(minusData[i].dBalanceMoney); /* 余额正数 */
            const dRoundingMoney = minusData[i].dRoundingMoney !== undefined
              ? minusData[i].dRoundingMoney
              : 0;
            if (positiveSum <= dBalanceMoney) {
              minusData[i].dTotalMoney = commonUtils.convertFixNum(-(positiveSum) - (dRoundingMoney * 1), dNetMoney);
              if (minusData[i].handleType === undefined) {
                minusData[i].handleType = commonUtils.isEmpty(minusData[i].handleType) ? 'update' : minusData[i].handleType;
              }
              break;
            } else {
              minusData[i].dTotalMoney = commonUtils.convertFixNum(-(dBalanceMoney * 1) - (dRoundingMoney * 1), dNetMoney);
              positiveSum -= dBalanceMoney - (dRoundingMoney * 1);
              if (minusData[i].handleType === undefined) {
                minusData[i].handleType = commonUtils.isEmpty(minusData[i].handleType) ? 'update' : minusData[i].handleType;
              }
            }
          }
          for (let i = 0; i < positiveData.length; i += 1) {
            /* 正数遍历 */
            const { dBalanceMoney } = positiveData[i]; /* 余额正数 */
            const dRoundingMoney = positiveData[i].dRoundingMoney !== undefined
              ? positiveData[i].dRoundingMoney
              : 0;
            positiveData[i].dTotalMoney = commonUtils.convertFixNum((dBalanceMoney * 1) - (dRoundingMoney * 1), dNetMoney);
            if (positiveData[i].handleType === undefined) {
              positiveData[i].handleType = commonUtils.isEmpty(positiveData[i].handleType) ? 'update' : positiveData[i].handleType;
            }
          }
          masterData.dAdvanceMoney = 0;
          masterData.bAdvance = false;
        } else {
          /* 有预收 */
          for (let i = 0; i < positiveData.length; i += 1) {
            /* 正数遍历 */
            const { dBalanceMoney } = positiveData[i]; /* 余额正数 */
            const dRoundingMoney = positiveData[i].dRoundingMoney !== undefined
              ? positiveData[i].dRoundingMoney
              : 0;
            positiveData[i].dTotalMoney = commonUtils.convertFixNum((dBalanceMoney * 1) - (dRoundingMoney * 1), dNetMoney);
            positiveData[i].handleType = commonUtils.isEmpty(positiveData[i].handleType) ? 'update' : positiveData[i].handleType;
          }
          for (let i = 0; i < minusData.length; i += 1) {
            /* 负数遍历 */
            minusData[i].dRoundingMoney = 0;
            minusData[i].handleType = commonUtils.isEmpty(minusData[i].handleType) ? 'update' : minusData[i].handleType;
          }
          masterData.dAdvanceMoney = commonUtils.convertFixNum(Math.abs(positiveSum), dNetMoney);
          masterData.bAdvance = true;
        }
        masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
        this.props.onSaveState({ masterData, slaveData });
      } else if (((minusSum - minusRoundingSum) + (positiveSum - positiveRoundingSum)) - dTotalMoney > 0) {
        /* 不够扣情况 */
        minusSum -= minusRoundingSum;
        minusSum -= positiveRoundingSum;
        minusSum -= dTotalMoney; /* 去除分摊金额 */
        for (let i = 0; i < minusData.length; i += 1) {
          /* 负数遍历 */
          const dBalanceMoney = Math.abs(minusData[i].dBalanceMoney); /* 余额正数 */
          const dRoundingMoney = minusData[i].dRoundingMoney !== undefined
            ? minusData[i].dRoundingMoney
            : 0;
          minusData[i].dTotalMoney = commonUtils.convertFixNum(-(dBalanceMoney * 1) - (dRoundingMoney * 1), dNetMoney);
          minusData[i].handleType = commonUtils.isEmpty(minusData[i].handleType) ? 'update' : minusData[i].handleType;
        }
        for (let i = 0; i < positiveData.length; i += 1) {
          /* 正数遍历 */
          const { dBalanceMoney } = positiveData[i]; /* 余额正数 */
          const dRoundingMoney = positiveData[i].dRoundingMoney !== undefined
            ? positiveData[i].dRoundingMoney
            : 0;
          if (Math.abs(minusSum) <= dBalanceMoney) {
            positiveData[i].dTotalMoney = commonUtils.convertFixNum(Math.abs(minusSum) - (dRoundingMoney * 1), dNetMoney);
            positiveData[i].handleType = commonUtils.isEmpty(positiveData[i].handleType) ? 'update' : positiveData[i].handleType;
            break;
          } else {
            positiveData[i].dTotalMoney = commonUtils.convertFixNum((dBalanceMoney * 1) - (dRoundingMoney * 1), dNetMoney);
            minusSum = -(Math.abs(minusSum) - (dBalanceMoney * 1) - (dRoundingMoney * 1));
            positiveData[i].handleType = commonUtils.isEmpty(positiveData[i].handleType) ? 'update' : positiveData[i].handleType;
          }
        }
        masterData.dAdvanceMoney = 0;
        masterData.bAdvance = false;
        masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
        this.props.onSaveState({ masterData, slaveData });
      }
      // let allTotalMoney = 0;
      // let allRoundingMoney = 0;
      // slaveData.forEach((child) => {
      //   if (child.dTotalMoney !== undefined) {
      //     allTotalMoney += child.dTotalMoney * 1;
      //   }
      //   if (child.dRoundingMoney !== undefined) {
      //     allRoundingMoney += child.dRoundingMoney * 1;
      //   }
      // });
      // this.props.onSaveState({ allTotalMoney, allRoundingMoney });
      return masterData;
    };

    handleImport = async () => {
      const {
        sModelsId, sModelsType, masterConfig, masterData, slaveData, slaveDelData: slaveDelDataOld, app,
      } = this.props;
      if (commonUtils.isEmpty(masterData.sWareHouseId)) {
        message.error(commonFunc.getConfigShowName(masterConfig, 'sWareHouseId') + commonFunc.showMessage(app.commonConst, 'isNotNull')); // 不能为空！
        return;
      }
      let url;
      if (sModelsType.includes('productStock/')) {
        url = `${commonConfig.server_host}eleProductStock/getEleProductStock?sModelsId=${sModelsId}&sWareHouseId=${masterData.sWareHouseId}`;
      } else {
        url = `${commonConfig.server_host}eleMaterialsStock/getEleMaterialsStock?sModelsId=${sModelsId}&sWareHouseId=${masterData.sWareHouseId}`;
      }

      const dataReturn = (await commonServices.getService(this.props.app.token, url)).data;
      if (dataReturn.code === 1) {
        const returnData = dataReturn.dataset.rows;
        const slaveDelData = commonUtils.isEmptyArr(slaveDelDataOld) ? [] : slaveDelDataOld;
        slaveData.forEach((item) => {
          item.handleType = 'del';
          slaveDelData.push({ ...item });
        });
        returnData.forEach((item) => {
          item.handleType = 'add';
          item.sParentId = masterData.sId;
        });
        this.props.onSaveState({ slaveData: returnData, slaveDelData });
      } else {
        this.props.getServiceError(dataReturn);
      }
    };

    handleOutTemplate = async () => {
      const {
        token, formData,
      } = this.props;
      const slaveConfig = formData.filter(item => item.sGrd === 'importTemplate')[0];
      window.location.href = `${commonConfig.server_host}import/exportTemplet?gdsconfigformmasterId=${slaveConfig.sId}&token=${token}`;
    };
    handleDesignFunction = () => {
      this.props.onSaveState({ visibleStatement: true });
    };
    handleBatchPriceUpdate = () => {
      const { slaveData, slaveSelectedRowKeys, app } = this.props;
      if (slaveSelectedRowKeys === undefined || slaveSelectedRowKeys.length !== 1) {
        return message.warning(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请选择一条数据进行操作 */
      } else {
        const batchPriceUpdateData = slaveData.filter(item => item.sId === slaveSelectedRowKeys[0]);
        this.props.onSaveState({ batchPriceUpdateData, visibleBatchPriceUpdate: true });
      }
    };
    /** 按钮操作事件 */
    handleButtonClick = async (name) => {
      if (['BtnOut'].includes(name)) { /* 导出模版数据 */
        this.handleOut();
        return;
      }
      if (name === 'BtnDesignFunction') {
        this.handleDesignFunction();
      } else if (name === 'BtnBatchPriceUpdate') {
        this.handleBatchPriceUpdate();
      }
      const { sModelsType, masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config } = this.props;
      if (name === 'BtnRefresh') {
        if (this.props.app.currentPane.refresh !== undefined) {
          this.props.app.currentPane.refresh();
        }
        this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config);
      } else if (sModelsType.includes('cashier/') || sModelsType.includes('sales/') || sModelsType.includes('purchase/')) {
        // 收付款分摊
        if (name === 'BtnShare') {
          this.handleShare();
        }
        if (sModelsType.includes('sales/') && name === 'BtnOutTemplate') {
          this.handleOutTemplate();
        }
      } else if (sModelsType.includes('materialsStock/') || sModelsType.includes('productStock/')) {
        if (name === 'BtnImport') {
          this.handleImport();
        }
      } else if(name && name.includes('BtnTempSql')) { /* 通过BtnTempSql按钮 自定义调用Sql 并将数据回填到界面上 */
        const { masterConfig, slaveConfig, sModelsId, token } = this.props;
        let {  masterData,slaveData } = this.props;
        const slave0Data = [];
        const slave1Data = [];
        const slave2Data = [];
        const slave3Data = [];
        const slave4Data = [];
        const copyTo ={};
        copyTo.name = name;
        copyTo.slaveData = slaveData;
        const buttonConfigArr = masterConfig &&  masterConfig.gdsconfigformslave.filter(item => item.sControlName && item.sControlName.includes('BtnTempSql'));
        const allConfig = {
          slaveConfig, masterConfig,
        };
        if(commonUtils.isNotEmptyArr(buttonConfigArr)) {
          copyTo.config = buttonConfigArr;
          const sTmpInfoConfig = buttonConfigArr.filter(item => item.sControlName && item.sControlName.includes('BtnTempSql'))[0];
          const sControlName = sTmpInfoConfig.sControlName;
          const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
          const sConfigformId = commonUtils.isEmpty(sTmpInfoConfig) ? '' : sTmpInfoConfig.sParentId;
          if (commonUtils.isNotEmptyObject(sTmpInfoConfig)) {
            const newCopyTo = {};
            newCopyTo.master = copyTo.masterData;
            newCopyTo.slave = commonUtils.isEmpty(copyTo.slaveData) ? [] : copyTo.slaveData[0];
            // const sRowData = copyTo.slaveData;
            const sRowData = [masterData];
            const condition = { sConfigformId, sControlName, sRowData };
            const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
            if (dataReturn.code === 1) {
              slaveData = [];
              const returnData = dataReturn.dataset.rows[0];
              const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.masterdetail`.toLowerCase());
              const copyToSlaveConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
              const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slavedetail`.toLowerCase());
              const copyToSlave1Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave1`.toLowerCase());
              const copyToSlave0Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave0`.toLowerCase());
              const copyToSlave2Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave2`.toLowerCase());
              const copyToSlava3Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava3`.toLowerCase());
              const copyToSlava4Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava4`.toLowerCase());
              const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
              const salveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
              const salveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
              const slave1AssignField = commonUtils.isNotEmptyArr(copyToSlave1Config) ? copyToSlave1Config[0].sAssignField : '';
              const slave0AssignField = commonUtils.isNotEmptyArr(copyToSlave0Config) ? copyToSlave0Config[0].sAssignField : '';
              const slave2AssignField = commonUtils.isNotEmptyArr(copyToSlave2Config) ? copyToSlave2Config[0].sAssignField : '';
              const slave3AssignField = commonUtils.isNotEmptyArr(copyToSlava3Config) ? copyToSlava3Config[0].sAssignField : '';
              const slave4AssignField = commonUtils.isNotEmptyArr(copyToSlava4Config) ? copyToSlava4Config[0].sAssignField : '';
              if (commonUtils.isNotEmptyArr(returnData.master) && masterDetailAssignField) {
                masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.master[0], newCopyTo) };
              }
              if (commonUtils.isNotEmptyArr(returnData.slave)) {
                returnData.slave.forEach((slaveItem) => {
                  newCopyTo.slave = slaveItem;
                  const newSid = commonUtils.createSid();
                  let slaveRow = commonFunc.getDefaultData(allConfig.slaveConfig, newCopyTo, { newSid }); // 取默认值
                  if (salveDetailAssignField) {
                    slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo) };
                  } else if (salveAssignField) {
                    slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                  }
                  slaveRow.handleType = 'add';
                  slaveRow.sId = newSid;
                  slaveRow.sParentId = masterData.sId;
                  slaveData.push(slaveRow);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave0)) {
                returnData.slave0.forEach((slave0Item) => {
                  newCopyTo.slave0 = slave0Item;
                  const newSid = commonUtils.createSid();
                  let slave0Row = commonFunc.getDefaultData(allConfig.slave0Config, newCopyTo, { newSid }); // 取默认值
                  slave0Row = { ...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo) }; // 取赋值字段
                  slave0Row.handleType = 'add';
                  slave0Row.sId = newSid;
                  slave0Row.sParentId = masterData.sId;
                  slave0Data.push(slave0Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave1)) {
                returnData.slave1.forEach((slave1Item) => {
                  newCopyTo.slave1 = slave1Item;
                  const newSid = commonUtils.createSid();
                  let slave1Row = commonFunc.getDefaultData(allConfig.slave1Config, newCopyTo, { newSid }); // 取默认值
                  slave1Row = { ...slave1Row, ...commonFunc.getAssignFieldValue(slave1AssignField, slave1Item, newCopyTo) }; // 取赋值字段
                  slave1Row.handleType = 'add';
                  slave1Row.sId = newSid;
                  slave1Row.sParentId = masterData.sId;
                  slave1Data.push(slave1Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave2)) {
                returnData.slave2.forEach((slave2Item) => {
                  newCopyTo.slave2 = slave2Item;
                  const newSid = commonUtils.createSid();
                  let slave2Row = commonFunc.getDefaultData(allConfig.slave2Config, newCopyTo, { newSid }); // 取默认值
                  slave2Row = { ...slave2Row, ...commonFunc.getAssignFieldValue(slave2AssignField, slave2Item, newCopyTo) }; // 取赋值字段
                  slave2Row.handleType = 'add';
                  slave2Row.sId = newSid;
                  slave2Row.sParentId = masterData.sId;
                  slave2Data.push(slave2Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave3)) {
                returnData.slave3.forEach((slave3Item) => {
                  newCopyTo.slave3 = slave3Item;
                  const newSid = commonUtils.createSid();
                  let slave3Row = commonFunc.getDefaultData(allConfig.slave3Config, newCopyTo, { newSid }); // 取默认值
                  slave3Row = { ...slave3Row, ...commonFunc.getAssignFieldValue(slave3AssignField, slave3Item, newCopyTo) }; // 取赋值字段
                  slave3Row.handleType = 'add';
                  slave3Row.sId = newSid;
                  slave3Row.sParentId = masterData.sId;
                  slave3Data.push(slave3Row);
                });
              }

              if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                returnData.slave4.forEach((slave4Item) => {
                  newCopyTo.slave4 = slave4Item;
                  const newSid = commonUtils.createSid();
                  let slave4Row = commonFunc.getDefaultData(allConfig.slave4Config, newCopyTo, { newSid }); // 取默认值
                  slave4Row = { ...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo) }; // 取赋值字段
                  slave4Row.handleType = 'add';
                  slave4Row.sId = newSid;
                  slave4Row.sParentId = masterData.sId;
                  slave4Data.push(slave4Row);
                });
              }
              this.props.onSaveState({ slaveData, slave1Data, slave2Data, slave3Data, slave4Data});
            } else {
              this.props.getServiceError(dataReturn);
            }
          }
        } else {
          message.error('请正确配置自定义按钮！');
        }
      }else if (name && name.includes('BtnCalc')) { /* 实现通用计算功能 */
        if(name === 'BtnCalcPassRate') {
          this.handleBtnCalcByRate(name);
        }else {
          this.handleBtnCalc(name);
        }
      } else if (name && name.includes('BtnLookSwitch')) { /* 查看二级物料1 dSumCompleteConsumptionStockQty */
        const addState = {};
       //  const { slave3Child0Config } = this.props;
       //  const tableConfigArr = slave3Child0Config?.gdsconfigformslave;
       // if(commonUtils.isNotEmptyArr(tableConfigArr)) {
       //   const filterData = tableConfigArr.filter(item => item.sName === 'dSumCompleteConsumptionStockQty');
       //   if(commonUtils.isNotEmptyArr(filterData)) {
       //     filterData.forEach((row, index) =>  {
       //       const iIndex = tableConfigArr.findIndex(item => item.sName === row.sName);
       //       if(iIndex > -1) {
       //         tableConfigArr[iIndex].bVisible = true;
       //       }
       //     })
       //   }
       //
       //   const iHideIndex = tableConfigArr.findIndex(item => item.sName === 'dSumCompleteAvailableStockQty');
       //   if(iHideIndex > -1) {
       //     slave3Child0Config.gdsconfigformslave[iHideIndex].bVisible = false;
       //   }
       //
       // }
       //  addState.slave3Child0Config = slave3Child0Config;
        this.props.onSaveState({ bSecondMainMaterials: true, ...addState }, () => {
          this.handleTableScroll();
        });
      } else if (name && name.includes('BtnLook')) { /* 查看全部 */
        const addState = {};
        // const { slave3Child0Config } = this.props;
        // const tableConfigArr = slave3Child0Config?.gdsconfigformslave;
        // if(commonUtils.isNotEmptyArr(tableConfigArr)) {
        //   const iIndex = tableConfigArr.findIndex(item => item.sName === 'dSumCompleteAvailableStockQty');
        //   if(iIndex > -1) {
        //     slave3Child0Config.gdsconfigformslave[iIndex].bVisible = true;
        //   }
        //   const filterData = tableConfigArr.filter(item => item.sName === 'dSumCompleteConsumptionStockQty');
        //   if(commonUtils.isNotEmptyArr(filterData)) {
        //     filterData.forEach((row, index) =>  {
        //       const iIndex = tableConfigArr.findIndex(item => item.sName === row.sName);
        //       if(iIndex > -1) {
        //         tableConfigArr[iIndex].bVisible = false;
        //       }
        //     })
        //   }
        // }
        //
        // addState.slave3Child0Config = slave3Child0Config;
        this.props.onSaveState({ slave3Child0SelectedRowKeys: [], slave3Child0Child1SelectedRowKeys: [], bSecondMainMaterials: false, ...addState }, () => {
          this.handleTableScroll();
        });
      }
    };
    /**
     * 表头滚动问题
     */
    handleTableScroll = () => {
      const scrollParent = document?.querySelector('.scrollInfo');
      const bodyScroll = scrollParent?.querySelector('.ant-table-body');
      const headScroll = scrollParent?.querySelector('.ant-table-header');
      bodyScroll?.scrollTo(0, 0);
      headScroll?.scrollTo(0, 0);
    }

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

      /* 导出使用Post提交 */
      const url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.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;
    }

    /* 通用计算 */
    handleBtnCalc = async (name) => {
      const { masterConfig, masterData, sModelsId, } = this.props;
      this.props.onSaveState({ pageLoading:true });
      const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))) ?
        masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))[0] : {};// sButtonEnabled  sButtonParam
      if(commonUtils.isNotEmptyObject(btnConfig)) {
        /* 组装allTableData */
        const allTableMap ={};
        const allReturnMap ={};
        const  slaveNameList = [];
        /* 从props找到 所有的Config */
        if(commonUtils.isNotEmptyArr(this.props)) {
          for (const key of Object.keys(this.props)) {
            if(key.includes('Config') && !key.includes('onGet') && !key.includes('report')) {
              const tablename =  key.replace('Config', '').trim();
              slaveNameList.push(tablename);
            }
          }
        }

        if (commonUtils.isNotEmptyArr(slaveNameList)) {
          slaveNameList.forEach((name, index) => {
            const tableConfig = this.props[name +'Config']; /* 动态配置 */
            const tableData = this.props[name +'Data']; /* 动态配置 */
            const tableSelectedRowKeys  = this.props[name + 'SelectedRowKeys']; /* 选中Key */
            if(commonUtils.isNotEmptyObject(tableConfig) && tableConfig.sSqlStr!=='noQuery') {
              allTableMap[name +'.'+ tableConfig.sTbName]  = tableData
            }

          })
          const masterTbName = masterConfig.sTbName;
          allTableMap['master.'+ masterTbName] = masterData;
        }
        const sButtonParam = btnConfig.sButtonParam;
        const btn = commonUtils.isJSON(sButtonParam) ?  JSON.parse(sButtonParam) : '';
        const sProName = btn.sproName;
        const url = `${commonConfig.server_host}calcprocedure/calc?sModelsId=${sModelsId}`;
        const value = {
          sProName,
          sButtonParam,
          allTableMap
        };
        const dataReturn = (await commonServices.postValueService(this.props.app.token, value, url)).data;
        if (dataReturn.code === 1) {
          /*   数据操作 数据回传页面   */
          message.success('操作成功！');
          const returnData = dataReturn.dataset.rows[0];
          if (commonUtils.isNotEmptyArr(slaveNameList) && commonUtils.isNotEmptyObject(returnData)) {
            slaveNameList.forEach((name, index) => {
              const tableConfig = this.props[name +'Config']; /* 动态配置 */
              let tableDelData =  this.props[name +'DelData'];
              if(commonUtils.isEmptyArr(tableDelData)) {
                tableDelData = [];
              }
              let tableDelDataNew = []
              let tableData = [];
              if(commonUtils.isNotEmptyObject(tableConfig)) {
                if (name === 'slave3Child0') {
                  // console.log('slaveNameList', name, tableConfig.sTbName);
                  tableData = returnData[name +'.MaterialsSum']; /* 动态配置 */
                  if(commonUtils.isNotEmptyArr(tableData) && Array.isArray(tableData)) {
                    tableDelDataNew = tableData.filter(item => item.handleType === 'del');
                    tableData = tableData.filter(item => item.handleType !== 'del');
                    tableDelData = tableDelData.concat(tableDelDataNew);
                  }
                } else {
                  tableData = returnData[name +'.'+ tableConfig.sTbName]; /* 动态配置 */
                  if(commonUtils.isNotEmptyArr(tableData) && Array.isArray(tableData)) {
                    tableDelDataNew = tableData.filter(item => item.handleType === 'del');
                    tableData = tableData.filter(item => item.handleType !== 'del');
                    tableDelData = tableDelData.concat(tableDelDataNew);
                  }
                }
              }
              allReturnMap[name +'Data'] = tableData;
              allReturnMap[name +'DelData'] = tableDelData;
            });
            const masterTbName = masterConfig.sTbName;
            allReturnMap.masterData = returnData['master.'+ masterTbName];
            allReturnMap.masterData.enabled = true;
            allReturnMap.pageLoading = false;
          }
          this.props.onSaveState({ ...allReturnMap });
        } else { /*   失败   */
          this.props.getServiceError(dataReturn);
          this.props.onSaveState({  pageLoading:false });
        }

      }
    }

    /* 合格率评审计算 */
    handleBtnCalcByRate = async (name, addMap) => {
      const { masterConfig, masterData, sModelsId, } = this.props;
      this.props.onSaveState({ pageLoading:true });
      const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))) ?
        masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))[0] : {};// sButtonEnabled  sButtonParam
      if(commonUtils.isNotEmptyObject(btnConfig)) {
        /* 组装allTableData */
        const allTableMap ={};
        const allReturnMap ={};
        const  slaveNameList = [];
        /* 从props找到 所有的Config */
        if(commonUtils.isNotEmptyArr(this.props)) {
          for (const key of Object.keys(this.props)) {
            if(key.includes('Config') && !key.includes('onGet') && !key.includes('report')) {
              const tablename =  key.replace('Config', '').trim();
              slaveNameList.push(tablename);
            }
          }
        }
        if (commonUtils.isNotEmptyArr(slaveNameList)) {
          slaveNameList.forEach((name, index) => {
            const tableConfig = this.props[name +'Config']; /* 动态配置 */
            const tableData = this.props[name +'Data']; /* 动态配置 */
            const tableSelectedRowKeys  = this.props[name + 'SelectedRowKeys']; /* 选中Key */
            if(commonUtils.isNotEmptyObject(tableConfig)) {
              if(name === 'slave' || name ==='slave0Child1' || name === 'materials' || name ==='slave0') {
                allTableMap[name +'.'+ tableConfig.sTbName]  = tableData;
              }

            }

          })
          // const masterTbName = masterConfig.sTbName;
          // allTableMap['master.'+ masterTbName] = masterData;
        }
        const sButtonParam = btnConfig.sButtonParam;
        const btn = commonUtils.isJSON(sButtonParam) ?  JSON.parse(sButtonParam) : '';
        const sProName = btn.sproName;
        const url = `${commonConfig.server_host}calcprocedure/calc?sModelsId=${sModelsId}`;
        const value = {
          sProName,
          sButtonParam,
          allTableMap
        };
        const dataReturn = (await commonServices.postValueService(this.props.app.token, value, url)).data;
        if (dataReturn.code === 1) {
          /*   数据操作 数据回传页面   */
          message.success('操作成功！');
          const returnData = dataReturn.dataset.rows[0];
          if (commonUtils.isNotEmptyArr(slaveNameList) && commonUtils.isNotEmptyObject(returnData)) {
            slaveNameList.forEach((name, index) => {
              if(name === 'slave' || name ==='slave0Child1' || name === 'materials' || name ==='slave0') {
                const tableConfig = this.props[name + 'Config']; /* 动态配置 */
                let tableDelData = this.props[name + 'DelData'];
                if (commonUtils.isEmptyArr(tableDelData)) {
                  tableDelData = [];
                }
                let tableDelDataNew = []
                let tableData = [];
                if (commonUtils.isNotEmptyObject(tableConfig)) {
                  tableData = returnData[name + '.' + tableConfig.sTbName]; /* 动态配置 */
                  if (commonUtils.isNotEmptyArr(tableData) && Array.isArray(tableData)) {
                    tableDelDataNew = tableData.filter(item => item.handleType === 'del');
                    tableData = tableData.filter(item => item.handleType !== 'del');
                    tableDelData = tableDelData.concat(tableDelDataNew);
                  }

                }
                allReturnMap[name + 'Data'] = tableData;
                allReturnMap[name + 'DelData'] = tableDelData;
              }
            });
            const masterTbName = masterConfig.sTbName;
            allReturnMap.masterData = returnData['master.'+ masterTbName];
            allReturnMap.masterData = masterData;
            if(commonUtils.isNotEmptyObject(allReturnMap.masterData)){
              allReturnMap.masterData.enabled = true;
            }
            allReturnMap.pageLoading = false;
            console.log('计算结果返回', allReturnMap);
          }
          this.props.onSaveState({ ...allReturnMap });
        } else { /*   失败   */
          this.props.getServiceError(dataReturn);
          this.props.onSaveState({  pageLoading:false });
        }

      }
    }

    handleBtnChoose = async (name, sControlName, chooseConfig) => {
      const { token } = this.props;
      const url = `${commonConfig.server_host}/gdsmodule/getGdsmoduleById/${chooseConfig.sActiveId}?sModelsId=${chooseConfig.sActiveId}`;
      const dataReturn = (await commonServices.getService(token, url)).data;
      if (dataReturn.code === 1) {
        const [returnData] = dataReturn.dataset.rows;
        this.props.onSaveState({ [`${name}ChooseVisible`]: true, [`${name}ChooseData`]: returnData });
      } else {
        this.props.getServiceError(dataReturn);
      }
    };
    handleViewClick = (name, sName, record, index , myConfig) => {
      if (name === 'process' && sName === 'sProcessParamStr') { // process sProcessParam
        const { processConfig, enabled, sModelsType } = this.props;
        const slaveSelectOneData = record;
        let modalVisible = false;
        const sProcessParamsSelects = [];
        let paramType = '';
        if (commonUtils.isNotEmptyObject(slaveSelectOneData)) {
          if (sModelsType.includes('manufacture/')) {
            paramType = slaveSelectOneData.sWorkOrderParam;
          } else if (sModelsType.includes('quotation/')) {
            paramType = slaveSelectOneData.sProcessParam;
          }
        }
        if (commonUtils.isNotEmptyObject(paramType) && enabled) {
          const sProcessParam = JSON.parse(paramType);
          modalVisible = true;
          // eslint-disable-next-line no-plusplus
          for (let i = 1; i < 7; i++) {
            const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
            if (iIndex > -1 && !commonUtils.isEmpty(sProcessParam[`sParam${i.toString()}`])) {
              processConfig.gdsconfigformslave[iIndex].showName = sProcessParam[`sParam${i.toString()}`];
              processConfig.gdsconfigformslave[iIndex].bVisible = !sProcessParam[`sParam${i.toString()}`].includes('参数值');
              record[`sParam${i.toString()}`] = sProcessParam[`sParam${i.toString()}`];
              sProcessParamsSelects.push(processConfig.gdsconfigformslave[iIndex]);
            } else if (iIndex > -1) {
              // processConfig.gdsconfigformslave[iIndex].showName = `sParamValue${i.toString()}`;
              processConfig.gdsconfigformslave[iIndex].bVisible = true;
            }
          }

          /* Begin 找到除了工艺参数以外的额外参数 通过对应字段找到该字段配置 */
          for (const key of Object.keys(slaveSelectOneData)) {
            if (key.includes('sParam')) {
              const iIndexOther = processConfig.gdsconfigformslave.findIndex(item => item.sName === key.replace('sParam', '').trim());
              if (iIndexOther > -1 && !commonUtils.isEmpty(slaveSelectOneData[key])) {
                const fieldConfig = processConfig.gdsconfigformslave[iIndexOther];
                if (fieldConfig) {
                  const sFieldName = fieldConfig.sName; /* 字段名 */
                  const bSrcName = `bParamConfig${fieldConfig.sName}`;
                  const bSrc = slaveSelectOneData[bSrcName];
                  /* 如果不原配置 则同参数配置雷同 */
                  if (!bSrc) {
                    processConfig.gdsconfigformslave[iIndexOther].sFieldToContent = '1'; /* 从工序配置的DropDownData中拿数据 */
                  } else { /* 走原配置读取数据源 */
                    processConfig.gdsconfigformslave[iIndexOther].sFieldToContent = ''; /* 从工序配置的DropDownData中拿数据 */
                  }
                  processConfig.gdsconfigformslave[iIndexOther].bParam = true; /* 增加参数字段标识 */
                  processConfig.gdsconfigformslave[iIndexOther].showName = sProcessParam[`sParam${sFieldName.toString()}`];
                  sProcessParamsSelects.push(processConfig.gdsconfigformslave[iIndexOther]);
                }
              }
            }
          }
          /* END */
        } else {
          modalVisible = false;
          // eslint-disable-next-line no-plusplus
          for (let i = 1; i < 7; i++) {
            const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
            if (iIndex > -1) {
              processConfig.gdsconfigformslave[iIndex].bVisible = true;
            }
          }
        }
        this.props.onSaveState({
          processRecord: record,
          sProcessParamsSelects,
          sProcessParamsModalVisible: modalVisible,
        });
      } else if (name === 'process' && sName === 'sParams' && commonUtils.isNotEmptyObject(record.sParams)) { // process sProcessParam
        const { processConfig, enabled, sModelsType } = this.props;
        const slaveSelectOneData = record;
        let modalVisible = false;
        const sProcessParamsSelects = [];
        let sParamData = [];
        let paramType = '';
        if (commonUtils.isNotEmptyObject(slaveSelectOneData)) {
          if (sModelsType.includes('manufacture/')) {
            paramType = slaveSelectOneData.sWorkOrderParam;
          } else if (sModelsType.includes('quotation/')) {
            paramType = slaveSelectOneData.sProcessParam;
          }
        }
        /* 工序参数以表格形式展示 列 */
        const sParamConfig = {
          bisMutiSelect: true,
          bMutiSelect: false,
        };
        const gdsconfigformslave = [{
          sId: commonUtils.createSid(),
          sName: 'sId',
          showName: '主键',
          bVisible: false,
          iFitWidth: 200,
        }, {
          sId: commonUtils.createSid(),
          sName: 'bSelfCbx',
          showName: '选择',
          bVisible: true,
          iFitWidth: 45,
        }, {
          sId: commonUtils.createSid(),
          sName: 'sParamKey',
          showName: '参数主键',
          bVisible: true,
          iFitWidth: 200,
        }, {
          sId: commonUtils.createSid(),
          sName: 'sParamName',
          showName: '参数名',
          bVisible: true,
          iFitWidth: 400,
        }, {
          sId: commonUtils.createSid(),
          sName: 'sParamValue',
          showName: '参数值',
          bVisible: true,
        }];
        sParamConfig.gdsconfigformslave = gdsconfigformslave;
        const sParamColumn = commonFunc.getHeaderConfig(sParamConfig);
        if (commonUtils.isNotEmptyObject(paramType) && enabled) {
          /* 将sParam1中的数据 还原到sParamData数据中 */
          sParamData = JSON.parse(record.sParams);
        }
        this.props.onSaveState({
          processRecord: record,
          sProcessParamsSelects,
          sParamsModalVisible: true,
          sParamConfig,
          sParamColumn,
          sParamData
        });
      } else {
        if(sName === 'myTableConfig') {
          this.handleQuickViewClick(name, sName, record, index, myConfig );
        } else {
          this.props.onViewClick(name, sName, record, index, myConfig );
        }
      }
    };

    /* 获取表格数据 */
    handleGetTableConfig = async (name, sModelsId) => {
      if(commonUtils.isNotEmptyObject(sModelsId)) {
        const newConfig = await this.props.onGetTableConfig(name, sModelsId);
        if(commonUtils.isNotEmptyObject(newConfig)) {
          const newColumn = commonFunc.getHeaderConfig(newConfig);
          this.props.onSaveState({[`${[name]}Config`]: newConfig, [`${[name]}Column`]: newColumn })
        }
      }
    }

    /* 快捷键跳转 */
    handleQuickViewClick = async (name, sName, record, index , myConfigArr) => {
      const {
        slaveConfig,
        slaveData,
        dispatch,
        slaveFilterCondition,
        slavePagination,
        slaveOrderBy,
        sModelsType,
        formRoute,
        treeFilterCondition,
        app,
        iPageSize,
        sModelsId,
        // slaveSelectedData,
        // masterData,
        // employeeConfig,
      } = this.props;
      console.log('myConfigArr',myConfigArr)
      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,
          },
        });
      }
    };

    handleSelect = async (name, selectConfig, selectData) => {
      const {
        masterConfig, token, sModelsId, currentSelectType, currentVersionInfo
      } = this.props;
      const _props = this.props;
      const _this = this;
      /* slave0Child1 - control */
      /* slave0 - process */
      /* materials - materials */
      let { masterData, slaveSelectedRowKeys ,slaveData, slave0Child1Data: controlDataOld, materialsData: materialsDataOld, slave0Data: processDataOld, colorData: colorDataOld,
        slave0ChildDelData: controlDelDataOld, materialsDelData: materialsDelDataOld, slave0DelData: processDelDataOld, colorDelData: colorDelDataOld,
        slaveConfig, slave0Child1Config:controlConfig, materialsConfig,slave0Config:processConfig, colorConfig, packConfig,} = this.props;
      async function fetchData() {
        const addState ={};
        for (let i = 0; i < selectData.length; i++) {
          const sSqlCondition = { sProductId: selectData[i].sProductId, sId: selectData[i].sId };
          const condition = { sConfigformId, sControlName, sSqlCondition };
          const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
          if (dataReturn.code === 1) {
            const returnData = dataReturn.dataset.rows[0];
            for (const key in returnData) {
              let arr = JSON.parse(JSON.stringify(returnData[key]));
              arr.forEach((item, idx) => {
                const newCopyTo = {};
                newCopyTo.master = masterData;
                let config = masterConfig.gdsconfigformslave.filter(item => item.sControlName.split('.').length === 3 && item.sControlName.includes(_this.copyName + '.' + key))[0];
                config = config ? config.sAssignField : copyConfig.sAssignField;
                const newSid = commonUtils.createSid();
                let mixData = commonFunc.getDefaultData(_props[`${key}Config`] || {}, newCopyTo, { newSid }); // 取默认值
                mixData = { ...mixData, ...commonFunc.getAssignFieldValue(config || copyConfig, item, newCopyTo) }; // 取赋值字段
                mixData.handleType = 'add';
                mixData.sId = newSid;
                mixData.sParentId = masterData.sId;
                if (key === 'master') {
                  mixData.sFormId = _this.props.masterData.sFormId;
                  mixData.sId = _this.props.masterData.sId;
                  mixData.maxBillNo = 'sBillNo';
                  arr[idx] = mixData;
                } else {
                  mixData.sParentId = _this.props.masterData.sId;
                  arr[idx] = mixData;
                }
              })
              if (addState[`${key}Data`] === undefined) {
                addState[`${key}Data`] = [];
              }
              addState[`${key}Data`] = addState[`${key}Data`].concat(arr);
            }
          } else {
            _this.props.getServiceError(dataReturn);
          }
        }
      }

      if(selectConfig && selectConfig.sControlName && selectConfig.sControlName.includes('_choose')) {
        if (commonUtils.isNotEmptyArr(selectData)) {
          const { currentProductCardId, currentProductTechnologyVer, currentSelectType }= this.props;
          let controlData = commonUtils.isNotEmptyArr(controlDataOld) ? JSON.parse(JSON.stringify(controlDataOld)): [];
          let materialsData = commonUtils.isNotEmptyArr(materialsDataOld) ? JSON.parse(JSON.stringify(materialsDataOld)): [];
          let processData = commonUtils.isNotEmptyArr(processDataOld) ? JSON.parse(JSON.stringify(processDataOld)): [];
          let colorData = [];
          let packData = [];
          let slave0Child2Data = [];
          const addState = {};
          const { slave0Child1DelData, slave0DelData } = this.props;
          const controlDelData = commonUtils.isEmptyArr(slave0Child1DelData) ? [] : slave0Child1DelData;
          const materialsDelData = commonUtils.isEmptyArr(materialsDelDataOld) ? [] : materialsDelDataOld;
          const processDelData = commonUtils.isEmptyArr(slave0DelData) ? [] : slave0DelData;

          if(commonUtils.isNotEmptyArr(controlData)) {
            const iIndex = controlData.findIndex(item => item.sProductCardId === selectData[0].sProductCardId);
            if(iIndex > -1 && currentProductCardId !== controlData[iIndex].sProductCardId) {
              message.error('当前工艺路线已存在，请勿重复选择！');
              return ;
            }
          }
          /* 根据选中的版本号，先删除在插入 */
          if(commonUtils.isNotEmptyArr(controlData)){
            const controlFilterData = controlData.filter(item=> item.sProductCardId === currentProductCardId && item.sProductTechnologyVer === currentProductTechnologyVer);
            if(commonUtils.isNotEmptyArr(controlFilterData)) {
              controlFilterData.forEach((item) => {
                item.handleType = 'del';
                controlDelData.push(item);
                const iDelIndex = controlData.findIndex(itemDel => itemDel.sId  === item.sId);
                if(iDelIndex > -1) {
                  controlData.splice(iDelIndex, 1);
                }

                /* 删除材料、工序 */
                const processFilterData  = processData.filter(itemDel=> itemDel.sControlId === item.sId);
                if(commonUtils.isNotEmptyArr(processFilterData)) {
                  processFilterData.forEach((item) => {
                    item.handleType = 'del';
                    processDelData.push(item);
                    const iDelIndex = processData.findIndex(itemDel => itemDel.sId === item.sId);
                    if (iDelIndex > -1) {
                      processData.splice(iDelIndex, 1);
                    }
                  });
                }

                const materialsFilterData  = materialsData.filter(itemDel=> itemDel.sControlId === item.sId);
                if(commonUtils.isNotEmptyArr(materialsFilterData)) {
                  materialsFilterData.forEach((item) => {
                    item.handleType = 'del';
                    materialsDelData.push(item);
                    const iDelIndex = materialsData.findIndex(itemDel => itemDel.sId === item.sId);
                    if (iDelIndex > -1) {
                      materialsData.splice(iDelIndex, 1);
                    }
                  });
                }
              });

            }
          }
          addState.slave0Child1DelData = controlDelData;
          addState.slave0DelData = processDelData;
          addState.materialsDelData = materialsDelData;

          const config = {};
          config.masterConfig = masterConfig;
          config.slaveConfig = slaveConfig;
          config.controlConfig = controlConfig;
          config.materialsConfig = materialsConfig;
          config.processConfig = processConfig;
          config.colorConfig = colorConfig;
          config.packConfig = packConfig;
          let iSlaveIndex = -1;
          if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
            slaveSelectedRowKeys = commonUtils.isNotEmptyArr(slaveData) ? slaveData[0].sId : [];
          }
          if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
            iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
          }
          let condition = '';
          let dataUrl = '';
          if(selectConfig.sControlName.includes('choosePBOM')) {
            dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataByCustomIdProductId/?sModelsId=${sModelsId}`
            condition = { sCardId: selectData[0].sId, sRowData: slaveData };
          }else if(selectConfig.sControlName.includes('chooseTicket')) {
            dataUrl= `${commonConfig.server_host}salesorder/getPartsInfo?sModelsId=${sModelsId}`;
            condition = { sSlaveId: selectData[0].sSlaveId, sRowData: slaveData };
          }
          /* 复制从工单功能 */
          const { productProcessInfoCopyFromKey } = this.props;
          let bCopyFromWorkOrder = false;
          if (commonUtils.isNotEmptyObject(productProcessInfoCopyFromKey) && productProcessInfoCopyFromKey.includes('BtnCopyFrom.sworkorder')) {
            // bCopyFromWorkOrder = true;
            condition = { sWorkOrderId: selectData[0].sId, slaveData };
            // dataUrl = `${commonConfig.server_host}salesorder/getCopyFromWorkOrder/?sModelsId=${sModelsId}`;
            dataUrl = `${commonConfig.server_host}salesorder/getWorkOrderToWorkOrder/?sModelsId=${sModelsId}`;
          }

          const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
          if (!bCopyFromWorkOrder && dataReturn.code === 1) {
            const copyTo = { config: processConfig.gdsconfigformslave, name: selectConfig.sControlName };
            const returnData = dataReturn.dataset.rows[0];
            const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}`.toLowerCase());
            const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
            const copyToControlConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.control`.toLowerCase());
            const copyToControlDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.controldetail`.toLowerCase());
            const copyToMaterialsConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.materials`.toLowerCase());
            const copyToProcessConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.process`.toLowerCase());
            const copyToColorConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.param`.toLowerCase());
            const copyToPackConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.pack`.toLowerCase());
            const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
            const slaveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
            const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
            const controlDetailAssignField = commonUtils.isNotEmptyArr(copyToControlDetailConfig) ? copyToControlDetailConfig[0].sAssignField : '';
            const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
            const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
            const colorAssignField = commonUtils.isNotEmptyArr(copyToColorConfig) ? copyToColorConfig[0].sAssignField : '';
            const packAssignField = commonUtils.isNotEmptyArr(copyToPackConfig) ? copyToPackConfig[0].sAssignField : '';

            let contorlDetailData = [];
            if (!commonUtils.isEmpty(controlDetailAssignField)) {
              const dataUrl = `${commonConfig.server_host}business/getSelectLimit/${copyToControlDetailConfig[0].sId}?sModelsId=${this.props.sModelsId}&sName=`;
              const conditonValues = this.props.getSqlCondition(copyToControlDetailConfig[0], '', {});
              const body = {
                sSqlCondition: commonUtils.isEmptyObject(conditonValues) ? '' : conditonValues, /*   查询条件   */
              };
              const json = await commonServices.postValueService(this.props.app.token, body, dataUrl);
              const { rows } = json.data.dataset;
              if (rows) {
                contorlDetailData = rows;
              }
            }

            const newCopyTo = {};
            newCopyTo.master = copyTo.masterData;
            newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];

            if (iSlaveIndex > -1) {
              slaveData[iSlaveIndex] = { ...slaveData[iSlaveIndex], ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, selectData[0], newCopyTo) }; // 取赋值字段
            }

            const bProcessAssort = false;
            let returnProcessAssort = [];
            let processAssignAssort = '';
            let dropDownDataProcessName;
            if (bProcessAssort) {
              const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
              const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
              if (dataProcessAssort.code === 1) {
                returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
                const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
                if (iIndex > -1) {
                  const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', config.processConfig.gdsconfigformslave[iIndex]);
                  dropDownDataProcessName = sqlDropDownData.dropDownData;
                  processAssignAssort = config.processConfig.gdsconfigformslave[iIndex].sAssignField;
                }
              }
            }
            /* 从表数据赋值 */
            /* 将首选、备选方案选择的值 更新到从表中 */
            if( commonUtils.isNotEmptyObject(slaveData)) {
              let addState = {};
              // slaveData[0] ={...slaveData[0], ...addState};

              //树型数据时修改
              const iSlave0Index = slaveData.findIndex(item => commonUtils.isEmpty(item.sFatherSlaveId));
              slaveData.forEach((slaveItem, iIndex) => {
                // 暂时先使用主工艺卡id
                addState.sBomId = selectData[0].sProductCardId;
                addState.sProductTechnologyVer = selectData[0].sProductTechnologyVer;
                addState.sSelectType = currentSelectType;
                addState.handleType = commonUtils.isEmpty(slaveItem.handleType) ? 'update' : slaveItem.handleType;
                if (currentSelectType === "mainVersion") {
                  addState.sMainProductTechnologyId = selectData[0].sProductCardId;
                } else if (currentSelectType === "preVersion") {
                  addState.sSpareProductTechnologyId = selectData[0].sProductCardId;
                }
                if (commonUtils.isNotEmptyArr(returnData.slaveData)) {
                  const iReturnSlaveIndex = returnData.slaveData.findIndex(item => item.sProductId === slaveItem.sProductId);
                  addState = {...addState, ...commonFunc.getAssignFieldValue(slaveDetailAssignField, iReturnSlaveIndex > -1 ? returnData.slaveData[iReturnSlaveIndex] : returnData.slaveData[0], newCopyTo) };

                  if (iSlave0Index > -1 && slaveData.length > 1 && slaveData.findIndex(item => item.sFatherSlaveId !== '') > -1 && slaveData[iSlave0Index].sProductId !== slaveData[iIndex].sProductId) {
                    addState.dProductQty = (slaveData[iSlave0Index].dProductQty - slaveData[iSlave0Index].dRealQty) * (addState.dCombineCoefficient && addState.dCombineCoefficient > 0 ? addState.dCombineCoefficient : 1);
                  }
                } else {
                  addState = {...addState, ...commonFunc.getAssignFieldValue(slaveDetailAssignField, selectData[0], newCopyTo)};
                }

                // const iSrcIndex = returnData.slaveData.findIndex(item => item.sProductId === slaveData[iIndex].sProductId);
                // if (iSrcIndex > -1) {
                //   addState.sBomId = returnData.slaveData[iSrcIndex].sSlaveId;
                //   addState.sProductTechnologyVer = returnData.slaveData[iSrcIndex].sProductTechnologyVer;
                //   if (currentSelectType === "mainVersion") {
                //     addState.sMainProductTechnologyId = returnData.slaveData[iSrcIndex].sSlaveId;
                //   } else if (currentSelectType === "preVersion") {
                //     addState.sSpareProductTechnologyId = returnData.slaveData[iSrcIndex].sSlaveId;
                //   }
                // }
                slaveData[iIndex] = { ...slaveItem, ...addState };
              });
            }

            // 新赋值后，要重新给。
            newCopyTo.master = copyTo.masterData;
            newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];

            if (commonUtils.isNotEmptyArr(returnData.controlData)) {
              let dProductQty = 0;
              /* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */
              let bProductQtySelf = false;
              if (commonUtils.isNotEmptyObject(this.props.masterConfig) && commonUtils.isNotEmptyArr(this.props.masterConfig.gdsconfigformslave)) {
                const iIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bProductQtySelf');
                if (iIndex > -1) {
                  bProductQtySelf = true;
                }
              }
              if (commonUtils.isNotEmptyArr(returnData.slaveData)) {
                masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.slaveData[0], newCopyTo) }; // 取赋值字段
              } else {
                masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, selectData[0], newCopyTo) }; // 取赋值字段
              }
              const treeCopyNodes = new Map();
              returnData.controlData.forEach((controlItem) => {
                newCopyTo.control = controlItem;
                const newSid = commonUtils.createSid();
                let controlRow = commonFunc.getDefaultData(config.controlConfig, newCopyTo, { newSid }); // 取默认值
                controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
                if (!commonUtils.isEmpty(controlDetailAssignField) && commonUtils.isNotEmptyArr(contorlDetailData)) {
                  const iDetailIndex = contorlDetailData.findIndex(item => controlRow.sCombinedMemo.includes(item.sProductNo));
                  if (iDetailIndex > -1) {
                    controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlDetailAssignField, contorlDetailData[iDetailIndex], newCopyTo) }; // 取赋值字段
                  }
                }

                controlRow.handleType = 'add';
                controlRow.sId = newSid;
                controlRow.sParentId = masterData.sId;
                controlRow.dPartsQty = dProductQty;
                controlRow.sOriginalId = controlItem.sId;
                const sAllOldId = controlItem.sAllId;
                controlRow.sProductTechnologyVer = selectData[0].sProductTechnologyVer;
                controlRow.sProductCardId = selectData[0].sProductCardId;
                controlRow.sProductCardNo = selectData[0].sProductCardNo;
                controlRow.currentSelectType = currentSelectType;
                controlRow.sSlaveId = commonUtils.isNotEmptyArr(slaveData) && slaveData[0].sId ?  slaveData[0].sId : '';
                controlRow.iOrder = currentSelectType.includes('preVersion') ? 1000 : 10;
                let arr = [];
                if (commonUtils.isNotEmptyObject(sAllOldId)) {
                  arr = sAllOldId.split(',');
                }
                const newId = controlRow.sId;
                let sOldParentId = '';
                let sNewParentAllId = '';
                if (arr.length < 2) { /* 根节点复制 */
                  controlRow.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(',');
                  controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
                  sNewParentAllId = `${sNewParentAllId},${newId}`;
                  controlRow.sAllId = sNewParentAllId;
                }
                treeCopyNodes.set(controlItem.sId, sNewParentAllId);
                controlData.push(controlRow);
                controlData.sort((a, b) => a.iOrder - b.iOrder); /* 按照序号排序 */

                /* 增加合版表 */
                if (commonUtils.isNotEmptyArr(returnData.packData) && false) {
                  returnData.packData.filter(item => item.sControlId === controlItem.sId).forEach(async (packItem) => {
                    newCopyTo.pack = packItem;
                    let packRow = commonFunc.getDefaultData(config.packConfig, newCopyTo); // 取默认值
                    packRow = { ...packRow, ...commonFunc.getAssignFieldValue(packAssignField, packItem, newCopyTo) }; // 取赋值字段
                    packRow.sOriginalId = packItem.sId;/* 翻单前的sId */
                    /* sSlaveId赋值 */
                    const iSlaveIndex = slaveData.findIndex(item => item.sOriginalId === packItem.sSlaveId);
                    if (iSlaveIndex > -1) {
                      const slaveDataRow = slaveData[iSlaveIndex];
                      const packRowAdd = this.handlePackDataAdd(slaveDataRow, 0, controlRow.sId, 'add');
                      if (commonUtils.isNotEmptyObject(packRowAdd)) {
                        packRow = { ...packRow, ...packRowAdd };
                        /* 将控制表中的合版备注sId为新的sId */
                        let JsonData = [];
                        const jsonStr = controlRow.sCombinedMemo;
                        if (commonUtils.isNotEmptyObject(jsonStr) && commonUtils.isJSON(jsonStr)) {
                          JsonData = JSON.parse(jsonStr);
                          if (commonUtils.isNotEmptyArr(JsonData)) {
                            let sCombinedMemoNew = '';
                            JsonData.forEach((item, index) => {
                              if (item.sId === packItem.sId) {
                                JsonData[index].sId = packRow.sId;
                              }
                            });
                            sCombinedMemoNew = JSON.stringify(JsonData);
                            controlRow.sCombinedMemo = sCombinedMemoNew;
                            const icontrolIndex = controlData.findIndex(item => item.sId === controlRow.sId);
                            if (icontrolIndex) {
                              controlData[icontrolIndex] = { ...controlData[icontrolIndex], sCombinedMemo: sCombinedMemoNew };
                            }
                          }
                        }
                        packData.push(packRow);
                      }
                    }
                  });
                }

                if (commonUtils.isNotEmptyArr(returnData.processData)) {
                  returnData.processData.filter(item => item.sControlId === controlItem.sId && item.sType !== '3').forEach((processItem) => {
                    newCopyTo.process = processItem;
                    const newSid = commonUtils.createSid();
                    let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo, { newSid }); // 取默认值
                    processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                    processRow.handleType = 'add';
                    processRow.sId = newSid;
                    processRow.sParentId = masterData.sId;
                    processRow.sControlId = controlRow.sId;
                    processRow.sPartsName = controlRow.sPartsName;
                    processRow.sSlaveId = commonUtils.isNotEmptyArr(slaveData) && slaveData[0].sId ?  slaveData[0].sId : '';
                    processRow.sProductCardId = selectData[0].sProductCardId;
                    /* 根据合版表的源sOriginalId找到新sId */
                    let sNewIds = '';
                    let sNewNames = '';
                    const sOldIds = processItem.sCombinePartsName;
                    if (commonUtils.isNotEmptyObject(sOldIds)) {
                      const sOldArr = sOldIds.split(',');
                      for (const sId of sOldArr) {
                        const index = packData.findIndex(item => item.sOriginalId === sId);
                        if (index > -1) {
                          const tableDataRow = packData[index];
                          sNewIds += `${tableDataRow.sId},`;
                          sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName}-${tableDataRow.sCombinePartsName},`;
                        }
                      }
                      sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
                      sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
                    }
                    processRow.sCombinePartsName = sNewIds;
                    processRow.sCombinePartsNameNew = sNewNames;
                    processData.push(processRow);

                    // 配套工序
                    if (bProcessAssort) {
                      returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
                        const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
                        const iProcessIndex = returnData.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlItem.sId);
                        const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlRow.sId);
                        if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
                          const newSid = commonUtils.createSid();
                          let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo, { newSid }); // 取默认值
                          processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
                          processRow.handleType = 'add';
                          processRow.sId = newSid;
                          processRow.sParentId = masterData.sId;
                          processRow.sControlId = controlRow.sId;
                          processRow.sPartsName = controlRow.sPartsName;
                          processRow.sType = dropDownDataProcessName[iIndex].sType;
                          processData.push(processRow);
                        }
                      }));
                    }
                  });
                }

                if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
                  returnData.materialsData.filter(item => item.sControlId === controlItem.sId && item.sType !== '2').forEach((materialsItem) => {
                    newCopyTo.materials = materialsItem;
                    const newSid = commonUtils.createSid();
                    let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo, { newSid }); // 取默认值
                    materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                    materialsRow.handleType = 'add';
                    materialsRow.sId = newSid;
                    materialsRow.sParentId = masterData.sId;
                    materialsRow.sControlId = controlRow.sId;
                    materialsRow.sPartsName = controlRow.sPartsName;
                    materialsRow.sSlaveId = commonUtils.isNotEmptyArr(slaveData) && slaveData[0].sId ?  slaveData[0].sId : '';
                    materialsRow.sOriginalId = materialsItem.sId;
                    materialsRow.sProductCardId = selectData[0].sProductCardId;
                    materialsRow.sZmldlt = materialsItem.sZmldlt;
                    materialsRow.sInkFatherMaterialsTbId = materialsItem.sInkFatherMaterialsTbId;
                    // 材料对应工序的ID要变化
                    if (commonUtils.isNotEmptyArr(returnData.processData)) {
                      const iProcessIndex = processData.findIndex(item => item.sControlId === controlRow.sId && item.sSrcProcessTbId === materialsItem.sProcessTbId);
                      if (iProcessIndex > -1) {
                        materialsRow.sProcessTbId = processData[iProcessIndex].sId;
                      }
                    }
                    materialsData.push(materialsRow);
                  });
                }

                /* 将 materialsData中sParentMaterialsId替换为最新的sid */
                if(commonUtils.isNotEmptyArr(materialsData)) {
                  const materialsFilterData = materialsData.filter(item => commonUtils.isNotEmptyObject(item.sParentMaterialsId));
                  if(commonUtils.isNotEmptyArr(materialsFilterData)) {
                    materialsFilterData.forEach((filterItem, index) => {
                      const iIndex = materialsData.findIndex(item => item.sOriginalId === filterItem.sParentMaterialsId);
                      if(iIndex > -1) {
                        const iNexIndex = materialsData.findIndex(item => item.sId === filterItem.sId);
                        if (iNexIndex > -1) {
                          const addState = {};
                          addState.sMaterialsNo1 = materialsData[iIndex].sMaterialsNo; /* 原材料编号 */
                          addState.sMaterialsName1 = materialsData[iIndex].sMaterialsName;  /* 原材料名称 */
                          addState.bAlternative = true;
                          addState.sParentMaterialsId = materialsData[iIndex].sId;
                          materialsData[iNexIndex] = { ...materialsData[iNexIndex], ...addState};
                        }
                      }

                    });
                  }

                  const materialsInkFilterData = materialsData.filter(item => commonUtils.isNotEmptyObject(item.sInkFatherMaterialsTbId));
                  if(commonUtils.isNotEmptyArr(materialsInkFilterData)) {
                    materialsInkFilterData.forEach((filterItem, index) => {
                      const iIndex = materialsData.findIndex(item => item.sOriginalId === filterItem.sInkFatherMaterialsTbId);
                      if(iIndex > -1) {
                        const iNexIndex = materialsData.findIndex(item => item.sId === filterItem.sId);
                        if(iNexIndex > -1) {
                          materialsData[iNexIndex] = { ...materialsData[iNexIndex], sInkFatherMaterialsTbId: materialsData[iIndex].sId}
                        }
                      }
                    });
                  }
                }

              });
            }
            if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
              returnData.materialsData.filter(item => item.sType === '2').forEach((materialsItem) => {
                newCopyTo.materials = materialsItem;
                const newSid = commonUtils.createSid();
                let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo, { newSid }); // 取默认值
                materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                materialsRow.handleType = 'add';
                materialsRow.sId = newSid;
                materialsRow.sParentId = masterData.sId;
                materialsRow.sSlaveId = slaveData[0].sId ?  slaveData[0].sId : '';
                /* 根据从表源sOriginalId找到新sId */
                let sNewIds = '';
                let sNewNames = '';
                const sOldIds = materialsItem.sCombinePartsName;
                if (commonUtils.isNotEmptyObject(sOldIds)) {
                  const sOldArr = sOldIds.split(',');
                  for (const sId of sOldArr) {
                    const index = slaveData.findIndex(item => item.sOriginalId === sId);
                    if (index > -1) {
                      const tableDataRow = slaveData[index];
                      sNewIds += `${tableDataRow.sId},`;
                      sNewNames += `${tableDataRow.sProductName},`;
                    }
                  }
                  sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
                  sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
                }
                materialsRow.sCombinePartsName = sNewIds;
                materialsRow.sCombinePartsNameNew = sNewNames;
                materialsData.push(materialsRow);
              });
            }

            if (commonUtils.isNotEmptyArr(returnData.processData)) {
              returnData.processData.filter(item => item.sType === '3').forEach((processItem) => {
                newCopyTo.process = processItem;
                const newSid = commonUtils.createSid();
                let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo, { newSid }); // 取默认值
                processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                processRow.handleType = 'add';
                processRow.sId = newSid;
                processRow.sParentId = masterData.sId;
                processRow.sOriginalId = processItem.sId;
                processRow.sSlaveId = commonUtils.isNotEmptyArr(slaveData) && slaveData[0].sId ?  slaveData[0].sId : '';
                /* 根据合版表的源sOriginalId找到新sId */
                let sNewIds = '';
                let sNewNames = '';
                const sOldIds = processItem.sCombinePartsName;
                if (commonUtils.isNotEmptyObject(sOldIds)) {
                  const sOldArr = sOldIds.split(',');
                  for (const sId of sOldArr) {
                    const index = slaveData.findIndex(item => item.sOriginalId === sId);
                    if (index > -1) {
                      const tableDataRow = slaveData[index];
                      sNewIds += `${tableDataRow.sId},`;
                      sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName},`;
                    }
                  }
                }
                sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
                sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
                processRow.sCombinePartsName = sNewIds;
                processRow.sCombinePartsNameNew = sNewNames;
                processData.push(processRow);

                // 成品配套工序
                if (bProcessAssort) {
                  returnProcessAssort.filter(item => item.sParentId === processRow.sProcessId).forEach(((itemProcessAssort) => {
                    const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
                    const iProcessIndex = returnData.processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
                    const iNewProcessIndex = processData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId);
                    if (iIndex > -1 && iProcessIndex < 0 && iNewProcessIndex < 0) {
                      if (itemProcessAssort.sType === 'single') {
                        const newSid = commonUtils.createSid();
                        let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo, { newSid }); // 取默认值
                        processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
                        processRow.handleType = 'add';
                        processRow.sId = newSid;
                        processRow.sParentId = masterData.sId;
                        processRow.sType = dropDownDataProcessName[iIndex].sType;
                        processData.push(processRow);
                      } else if (itemProcessAssort.sType === 'all') {
                        controlData.forEach((controlItem) => {
                          const newSid = commonUtils.createSid();
                          let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo, { newSid }); // 取默认值
                          processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
                          processRow.handleType = 'add';
                          processRow.sId = newSid;
                          processRow.sParentId = masterData.sId;
                          processRow.sControlId = controlItem.sId;
                          processRow.sPartsName = controlItem.sPartsName;
                          processRow.sType = dropDownDataProcessName[iIndex].sType;
                          processData.push(processRow);
                        });
                      }
                    }
                  }));
                }
              });
            }
            /* 处理非标产品 */
            slave0Child2Data = materialsData.filter(item => item.sZmldlt === '非标' && item.sProductCardId === currentProductCardId);
            addState.materials0DelData = materialsDelData;
            addState.materials0Data = materialsData;
            addState.slave0Child2Data = slave0Child2Data;
            console.log('slave0Child1Data部件表', controlData);
            console.log('slave0Child1Data材料表', materialsData);
            console.log('slave0Child1Data工序表', processData);

            /* 自动调用合格率计算 */
            if(false) {
              const addStateMap ={
                slave0Child1Data:controlData,
                slaveData:slaveData,
                slave0Data: processData,
                materialsData,
              }
              this.handleBtnCalcByRate('BtnCalcPassRate', addStateMap); /* 调用合格率计算 */
            }else {
              this.props.onSaveState({
                [`${name}ChooseVisible`]: false,
                slave0Data: processData,
                materialsData,
                slave0Child1Data:controlData,
                slave3Data:controlData,
                processCardUpdate: true,
                packData,
                masterData,
                tableSelectedNewRowKeys: commonUtils.isEmptyArr(controlData) ? [] : [controlData[0].sId],
                controlSelectedRowKeys: commonUtils.isEmptyArr(controlData) ? [] : [controlData[0].sId],
                materialsSelectedRowKeys: [],
                processSelectedRowKeys: [],
                ...addState,
              });
            }
          } else {
            this.props.getServiceError(dataReturn.msg);
          }
        }
      }else {
        const copyConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName.split('.').length === 2 && item.sControlName.includes(this.copyName))[0];
        const sConfigformId = commonUtils.isEmpty(copyConfig) ? '' : copyConfig.sParentId;
        const sControlName = this.copyName;
        const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfo/?sModelsId=${sModelsId}`;
        const addState = {};
        await fetchData();
        if (addState.masterData) {
          [addState.masterData] = addState.masterData;
        }
        if (Object.keys(addState).length) {
          this.props.onSaveState({...addState});
        }
      }
    };

    handleSelectCancel = (name) => {
      this.props.onSaveState({ [`${name}ChooseVisible`]: false });
    };
    /* 双击弹出Memo */
    // handleGetMemo = (name, sValue, sMemoFiled, sRecord) => {
    //   const { sCurrMemoProps } = this.props;
    //   let { [`${name}Data`]: tableData } = this.props;
    //   const addStata = { [`${sMemoFiled}`]: sValue };
    //   if (name !== 'master') {
    //     const iIndex = tableData.findIndex(item => item.sId === sRecord.sId);
    //     let handleType = tableData[iIndex].handleType;/* 获取操作类型 */
    //     handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
    //     addStata.handleType = handleType;
    //     tableData[iIndex] = { ...tableData[iIndex], ...addStata };
    //   } else {
    //     let handleType = tableData.handleType;/* 获取操作类型 */
    //     handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
    //     addStata.handleType = handleType;
    //     tableData = { ...tableData, ...addStata };
    //   }
    //   sCurrMemoProps.bVisibleMemo = false;
    //   this.props.onSaveState({ ...sCurrMemoProps, [`${name}Data`]: tableData });
    // };
    // handleGetMemoCancel = () => {
    //   const { sCurrMemoProps } = this.props;
    //   sCurrMemoProps.bVisibleMemo = false;
    //   this.props.onSaveState({ ...sCurrMemoProps });
    // };
    // async await
    handleEleMaterialsStoreCurrQty = async (slaveData) => {
      const { sModelsId, app } = this.props;
      let flag = true;
      const InsufficientInventory = commonFunc.showMessage(app.commonConst, 'InsufficientInventory');/* 库存不足，不能领料 */
      const MateriaTransferQuantityVerificationFailed = commonFunc.showMessage(app.commonConst, 'MateriaTransferQuantityVerificationFailed');/* 材料调拨数量校验失败，请稍后操作 */
      const url = `${commonConfig.server_host}eleMaterialsStock/getEleMaterialsStoreCurrQty?sModelsId=${sModelsId}`;
      for (const item of slaveData) {
        const body = {
          sMaterialsId: item.sMaterialsId, /*   查询条件   */
          sMaterialsStyle: item.sMaterialsStyle,
          sWareHouseId: item.sWareHouseId,
        };
        if (commonUtils.isNotEmptyStr(item.sLocationId)) {
          body.sLocationId = item.sLocationId;
        }
        if (commonUtils.isNotEmptyStr(item.sWarehouseLocationId)) {
          body.sWarehouseLocationId = item.sWarehouseLocationId;
        }
        if (commonUtils.isNotEmptyStr(item.sDefineNo)) {
          body.sDefineNo = item.sDefineNo;
        }
        if (commonUtils.isNotEmptyStr(item.sDefineNo2)) {
          body.sDefineNo2 = item.sDefineNo2;
        }
        const dataReturn = (await commonServices.postValueService(this.props.app.token, body, url)).data;
        if (dataReturn.code === 1) {
          if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows)) {
            const materials = dataReturn.dataset.rows[0];
            if (materials.dAuxiliaryQty < item.dAuxiliaryQty) {
              message.error(`[${item.sMaterialsName}${item.sMaterialsStyle}], ${InsufficientInventory}`);
              flag = false;
              break;
            }
          } else {
            const sMaterialsName = commonUtils.isEmpty(item.sMaterialsName) ? item.sMaterialsName1 : item.sMaterialsName;
            message.error(`[${sMaterialsName}${item.sMaterialsStyle}], ${InsufficientInventory}`);
            flag = false;
            break;
          }
        } else {
          message.error(MateriaTransferQuantityVerificationFailed);
          flag = false;
          break;
        }
      }
      return flag;
    }
    handleBtnExportSql = () => {

    }

    componentDidUpdate() {
      if (this.state.initSId) {
        this.slaveTablePositon();
      }
    }

    slaveTablePositon() {
      if (!this.state.initSId) return;
      const oSelectedTr = document.querySelector(`#dataBox tr[data-row-key='${this.state.initSId}']`);
      if (oSelectedTr) {
        const oTbody = oSelectedTr.parentNode.parentNode.parentNode;
        if (oSelectedTr && oTbody) {
          oTbody.scrollTop = oSelectedTr.offsetTop;
          this.setState({
            initSId: '',
          });
        }
      }
    }

    handleTableBlur = async (name, sFieldName, record, tableConfig) => {
      const { sModelsId, app, token, sModelsType, [`${name}Data`]: tableData, [`${name}Data`]: tableSelectedRowKeys, masterData , [`${name}Config`]: tempConfig  } = this.props;
      const models = name === 'materials' ? 'Materials' :
        sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('print/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
      let tableDataRow = {};
      if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || sFieldName === 'dAuxiliaryQty' || sFieldName === 'dReelAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle') {
        let iIndex = -1;
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          iIndex = 0;
        } else {
          tableData.findIndex(item => item.sId === tableSelectedRowKeys.toString())
        }
        tableDataRow = await this.handleMaterialsChange(record, sModelsId, masterData, {}, sFieldName, app, token, models);
        if(iIndex > -1) {
          tableData[iIndex] = tableDataRow;
        }
        this.props.onSaveState({ [`${name}Data`]: tableData})
      }else if(commonUtils.isNotEmptyObject(tableConfig) && commonUtils.isNotEmptyObject(tableConfig.sButtonParam) && sFieldName === 'sInkBOM') {
        let { materialsData:materials0Data, materialsDelData:materials0DelData, currentProductCardId } = this.props;
        if(commonUtils.isEmptyArr(materials0Data)) {
          materials0Data = [];
        }
        if(commonUtils.isEmptyArr(materials0DelData)) {
          materials0DelData = [];
        }

        const controlRow = this.handleGetSelectedData(this.props, 'slave0Child1');
        const processRow = this.handleGetSelectedData(this.props, 'slave0');
        const sTmpInfoConfig = tableConfig;
        const sButtonParam = tableConfig.sButtonParam;
        const btn = commonUtils.isNotEmptyObject(sButtonParam) && commonUtils.isJSON(sButtonParam)?  JSON.parse(sButtonParam) : {};;
        const sProName = commonUtils.isNotEmptyObject(btn) ?  btn.sproName : '';
        const sTmpInfoBySqlBtnName = commonUtils.isNotEmptyObject(btn) ? btn.sControlName : '';
        const sActiveKey = sTmpInfoConfig.sActiveKey;
        if (commonUtils.isNotEmptyObject(sTmpInfoConfig) && sTmpInfoBySqlBtnName.includes('sTmpInfoBySql')) {
          const newCopyTo = {};
          newCopyTo.master = masterData;
          newCopyTo.process = processRow;
          newCopyTo.control = controlRow;
          /* 找到自定义TempInfo配置 */

          const btnConfig = tempConfig.gdsconfigformslave.filter(item => item.sControlName.includes(sTmpInfoBySqlBtnName));
          const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
          const sConfigformId = commonUtils.isEmpty(btnConfig) ? '' : btnConfig[0].sParentId;
          const sControlName = commonUtils.isNotEmptyObject(sTmpInfoBySqlBtnName) ? sTmpInfoBySqlBtnName : 'TmpInfoBySql';
          const sAssignField = btnConfig[0].sAssignField;
          const sActiveKeyNew = btnConfig[0].sActiveKey;
          const sRowData = [record];
          const values = { sConfigformId, sControlName, sRowData };
          if (true){
            const dataReturn = (await commonServices.postValueService(app.token, values, dataUrl)).data;
            const allReturnMap = {};
            if (dataReturn.code === 1) {
              const returnData = dataReturn.dataset.rows[0];
              if (commonUtils.isNotEmptyObject(returnData)) {
                for (const key of Object.keys(returnData)) {
                  console.log('key', key);
                  const sName = `${key}Data`;
                  const sDelName = `${key}DelData`;
                  // allReturnMap[sName] = returnData[key];
                  let {[`${key}Data`]: oldData, [`${key}DelData`]: oldDelData } = this.state;
                  if(commonUtils.isEmptyArr(oldDelData)) {
                    oldDelData = [];
                  }
                  if(commonUtils.isEmptyArr(oldData)) {
                    oldData = [];
                  }
                  if(sTmpInfoBySqlBtnName.includes('_edit')) { /* 替换 根据对应字段对比 相同的不管 不同的插入  */
                    /* 对应字段 */
                    const sActiveKey = sTmpInfoConfig.sActiveKey;
                    const keyData = returnData[key];
                    let newData = [];
                    if(commonUtils.isNotEmptyArr(keyData)) {
                      keyData.forEach((child) => {
                        const filterData = oldData.filter(item => item[sActiveKeyNew] !== child[sActiveKeyNew]);
                        if(commonUtils.isNotEmptyArr(filterData)) {
                          const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111
                          tableRow.sId = commonUtils.createSid();
                          tableRow.sParentId = masterData.sId;
                          newData.push(tableRow);
                        }
                      });
                      newData = oldData.concat(newData)
                    }

                  }else if(sTmpInfoBySqlBtnName.includes('_del')) { /* 替换 根据对应字段对比 相同的不管 不同的插入  */
                    /* 对应字段 */
                    const keyData = returnData[key];
                    if(commonUtils.isEmptyArr(keyData))  {
                      return ;
                    }
                    const sActiveKey = sTmpInfoConfig.sActiveKey;
                    const oldFilterData = oldData.filter(old => old.sParentMaterialsId === record.sId);
                    oldFilterData.forEach((child) => {
                      child.handleType ='del';
                      oldDelData.push(child);
                    });

                    /* 找到老数据的oldRowMap sInkBOMId 信息 */
                    // const recordOldRow = record.oldRowMap;
                    // if(commonUtils.isEmptyObject(recordOldRow)) {
                    //   return ;
                    // }

                    const oldMFilterData = materials0Data.filter(old => old.sInkFatherMaterialsTbId === record.sId);
                    // const oldMFilterData = materials0Data.filter(old => commonUtils.isNotEmptyObject(old.sInkBOMId) && commonUtils.isNotEmptyObject(old.sInkBOMsSlaveId)
                    //   && old.sInkBOMId === recordOldRow.sInkBOMId && old.sInkBOMsSlaveId === recordOldRow.sInkBOMsSlaveId && commonUtils.isEmpty(old.sInkBOMsMaterialsId)
                    //   && old.sProcessTbId === recordOldRow.sProcessTbId  && old.sProcessId === recordOldRow.sProcessId  && old.sControlId === recordOldRow.sControlId
                    // );
                    console.log('删除之前油墨', oldMFilterData);
                    oldMFilterData.forEach((child) => {
                      child.handleType ='del';
                      const iIndex = materials0Data.findIndex(item => item.sId === child.sId);
                      if(iIndex > -1 ) {
                        materials0Data.splice(iIndex, 1);
                      }
                      materials0DelData.push(child);
                    });

                    allReturnMap[sDelName] = oldDelData;
                    oldData = [];

                    if(commonUtils.isNotEmptyArr(keyData)) {
                      keyData.forEach((child) => {
                        const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child, newCopyTo) }; // 取赋值字段111
                        tableRow.sId = commonUtils.createSid();
                        tableRow.sParentId = masterData.sId;
                        tableRow.handleType = 'add';
                        tableRow.sInkFatherMaterialsTbId = record.sId;
                        tableRow.sProductCardId = currentProductCardId;
                        tableRow.sProcessTbId = processRow?.sId;
                        tableRow.sProcessId = processRow?.sProcessId;
                        tableRow.sControlId = controlRow?.sId;
                        // tableRow.sBclassifyName ='油墨';
                        oldData.push(tableRow);
                        materials0Data.push(tableRow);
                      });
                    }
                    // allReturnMap[sName] = oldData;
                    allReturnMap.materialsData = materials0Data;
                    allReturnMap.materialsDelData = materials0DelData;
                  } else {
                    allReturnMap[sName] = returnData[key];
                  }

                }
                if (commonUtils.isNotEmptyArr(allReturnMap.masterData) && Array.isArray(allReturnMap.masterData)) {
                  allReturnMap.masterData = allReturnMap.masterData[0];
                }
                console.log('油墨', allReturnMap);
                this.props.onSaveState({ ...allReturnMap });
              }
            } else {
              this.getServiceError(dataReturn);
            }
          }

        }
      } else {
        this.props.onDropDownBlur(name, sFieldName, record, tableConfig);
      }
    };


    /**   删除表格数据   */
    handleTableDel = (name, isWait, tableSelectedRowKeys) => {
      const {[`${name}Config`]: tableConfig , [`${name}Data`]: tableData  } = this.props;
      if(commonUtils.isNotEmptyObject(tableConfig) && tableConfig.showName === '非标材料') { /* 非标材料删除 */
        const { materialsData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, } = this.props;
        if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
          let materialsReturnData = {};
          const iMIndex = materialsData.findIndex(item => tableSelectedRowKeys.includes(item.sId) );
          if(iMIndex > -1) {
            const newTableSelectedRowKeys = [materialsData[iMIndex].sId];
            materialsReturnData = this.props.onDataRowDel('materials', true, newTableSelectedRowKeys);
          }
          const tableDataIndex = tableData.findIndex(item => tableSelectedRowKeys.includes(item.sId));
          if(tableDataIndex > -1) {
            tableData.splice(tableDataIndex, 1);
          }
          this.props.onSaveState({ ...materialsReturnData,  [`${name}Data`]: tableData   });
        } else {
          message.error('请选择非标材料！');
        }
      } else if(commonUtils.isNotEmptyObject(tableConfig) && (name === 'slave3Child0Child1' || tableConfig.showName === '更换材料') ) { /* 替代料材料删除 */
         return this.handleTableDelTdl(name, isWait, tableSelectedRowKeys);
      } else if(name ==='materials1'){ /* 删除油墨时 同时删除油墨子集 */
         /* 从全部材料里 找到对应数据 进行更改 */
         const {
           sModelsId, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, [`${name}Data`]: tableData, materialsConfig, materialsData: materials0Data, token,
         } = this.props;
         if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
           message.error('请选择数据！');
           return ;
         }
         if(commonUtils.isNotEmptyArr(materials0Data)) {
           const iIndex = materials0Data.findIndex(item => tableSelectedRowKeys.includes(item.sId) );
           let materials1Row = {};
           if(iIndex > -1) {
             materials1Row =  materials0Data[iIndex];
           }
           // const controlRow = this.handleGetSelectedData(this.props, 'slave0Child1');
           // const processRow = this.handleGetSelectedData(this.props, 'slave0');
           const materials0ChildData  = materials0Data.filter(item => item.sInkFatherMaterialsTbId === materials1Row.sId);

           // const materials0ChildData  = materials0Data.filter(item => commonUtils.isNotEmptyObject(item.sInkBOMId) && item.sInkBOMId === materials1Row.sInkBOMId
           //   &&  commonUtils.isNotEmptyObject(item.sInkBOMsSlaveId) && item.sInkBOMsSlaveId === materials1Row.sInkBOMsSlaveId &&
           //   item.sProcessTbId === materials1Row.sProcessTbId && item.sProcessId === materials1Row?.sProcessId  && item.sControlId === materials1Row?.sControlId &&
           //   commonUtils.isEmptyObject(item.sInkBOMsMaterialsId));
           console.log('删除油墨子集2', materials0ChildData);
           if(commonUtils.isNotEmptyArr(materials0ChildData)) {
             materials0ChildData.forEach((item, index) => {
               tableSelectedRowKeys.push(item.sId);
             });
           }
           const { materialsData, materialsDelData } = this.props.onDataRowDel('materials', true, tableSelectedRowKeys);
           const addState = { materialsData, materialsDelData };
           this.props.onSaveState(addState);

         }
      } else if(name === 'materials2' || name === 'materials3'  ||  name === 'materials1Child'||  name === 'materialsChild'){ /* 删除电化铝、油墨子集 */
       /* 从全部材料里 找到对应数据 进行删除 */
       const {
         sModelsId, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, [`${name}Data`]: tableData, materialsConfig, materialsData : materials0Data, token,
       } = this.props;
       if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
         message.error('请选择数据！');
         return ;
       }
       const { materialsData, materialsDelData } = this.props.onDataRowDel('materials', true, tableSelectedRowKeys);
       const addState = { materialsData, materialsDelData };
       console.log('111111111111111112', addState);
       this.props.onSaveState(addState);
      } else if (name === 'slave0Child1') { /* 删除部件的同时 删除工序 材料 */
         const {
           [`${name}SelectedRowKeys`]: tableSelectedRowKeys, app,
         } = this.props;
         if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
           const materialsReturnData = this.otherTableDel('materials', tableSelectedRowKeys);
           const processReturnData = this.otherTableDel('slave0', tableSelectedRowKeys);
           const controlReturnData = this.props.onDataRowDel(name, true, tableSelectedRowKeys);

           this.props.onSaveState({
             ...materialsReturnData,
             ...processReturnData,
             ...controlReturnData,
           });
         } else {
           message.warn(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请选择数据 */
           return false;
         }
      } else if (name === 'slave0') { /* 删除工序的同时 删除材料 */
         const {
           [`${name}SelectedRowKeys`]: tableSelectedRowKeys,  [`${name}Data`]: tableData, app, materialsData=[], materialsDelData =[],
         } = this.props;
         if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
           let tableRow = {};
           const iProcessIndex = this.handleGetSelectedIndex(this.props, 'slave0');
           if(iProcessIndex > -1) {
             tableRow = tableData[iProcessIndex];
           }
           const materialsFilterDelData = materialsData.filter(item  => tableSelectedRowKeys.includes(item.sProcessTbId) &&
             item.sProcessId === tableRow.sProcessId );
           let materialsSelectedDelRowKeys = [];
           if(commonUtils.isNotEmptyArr(materialsFilterDelData)) {
             materialsFilterDelData.forEach((item) =>{
               materialsSelectedDelRowKeys.push(item.sId);
             })
           }
           const materialsReturnData = this.otherCommonTableDel('materials', materialsSelectedDelRowKeys, 'sId'); /* 全部材料删除 */
           const processReturnData = this.props.onDataRowDel(name, true, tableSelectedRowKeys);
           this.props.onSaveState({
             ...materialsReturnData,
             ...processReturnData,
           });
        } else {
         message.warn(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请选择数据 */
         return false;
        }
      } else if (name === "materials") { // 删除全部材料时 删除替代料
        const { materialsData = [] } = this.props;
        const materialsChildFilter = materialsData.filter(item => item.sParentMaterialsId === tableSelectedRowKeys[0]);
        const tableSelectedRowKeysAdd = materialsChildFilter.filter(item => !tableSelectedRowKeys.includes(item.sId)).map(item => item.sId);
        return this.props.onDataRowDel(name, isWait, [...tableSelectedRowKeys, ...tableSelectedRowKeysAdd]);
      } else {
        return this.props.onDataRowDel(name, isWait, tableSelectedRowKeys);
      }
    };

    // 替代料删除
    handleTableDelTdl = (tableName) => {
      const {
        masterData, [`${tableName}SelectedRowKeys`]: selectedRowKeys = [], slave3Child0SelectedRowKeys
      } = this.props;

      // 替代料删除处理
      if (['slave3Child0Child2'].includes(tableName)) {
        const { materialsData } = this.props;
        const materialsOriginSNonsId = materialsData?.map(i => {
          if (i && Object.prototype.hasOwnProperty.call(i, 'originSNonsId') && selectedRowKeys.includes(i.sId)) {
            return i.originSNonsId;
          }
        })?.filter(Boolean);
        if (materialsOriginSNonsId?.find(Boolean)) {
          materialsData?.forEach(i =>
            {
              if (i && materialsOriginSNonsId.includes(i.sId)) {
                i.sHasReplace = 0;
            }
          })
        }
      }

      const { materialsData, materialsDelData } = this.props.onDataRowDel('materials', true, selectedRowKeys);

      /* 叠加用量 */
      if(commonUtils.isEmptyArr(slave3Child0SelectedRowKeys)) {
        message.error('请选择物料！');
        return;
      }
      let dAuxiliarySumQty = 0;
      const filterData = materialsData.filter(item => item.sParentMaterialsId && slave3Child0SelectedRowKeys.includes(item.sParentMaterialsId) && item.sNons === '替代料'
        && item.sMaterialsType !== '2');
      if(commonUtils.isNotEmptyArr(filterData)) {
        filterData.forEach(item => {
          dAuxiliarySumQty += commonUtils.convertToNum(commonUtils.isNull(item.dAuxiliaryQty, 0), 2);
        });
      }
      const iFatherIndex = materialsData.findIndex(item => slave3Child0SelectedRowKeys.includes(item.sId) );
      if(iFatherIndex > -1) {
        const addState = {};
        addState.dReplaceStockAuxiliaryQty = dAuxiliarySumQty;
        addState.handleType =  commonUtils.isEmpty(materialsData[iFatherIndex].handleType) ? 'update' : materialsData[iFatherIndex].handleType;
        materialsData[iFatherIndex] = {...materialsData[iFatherIndex], ...addState};
      }
      const masterDataNew = { ...masterData, bMrpCalc: false };
      const addState = { masterData: masterDataNew, materialsData, materialsDelData };
      this.props.onSaveState(addState);
    }

    handleSelectCommonPopup = (currentPaneName, selectConfig, selectData, tbName) => {
      console.log('sddsds', currentPaneName, selectConfig, tbName);
      const {
        [`${tbName}Data`]: tableData, [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData, slaveSelectedRowKeys,
        slave0Child1SelectedRowKeys: controlSelectedRowKeys, currentProductCardId,
    } = this.props;
      if (selectConfig && selectConfig.sControlName && selectConfig.sControlName.includes('BtnPopupReplaceMaterials')) {
        const {
          slave3Child0SelectedRowKeys: tableSelectedRowKeys, slave3Child0Child2SelectedRowKeys, materialsData : tableInfoOld =[], masterData,  [`${tbName}Data`]: tableData =[],
        } = this.props;
        let tableInfo = [...tableInfoOld];
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          message.error('请选择替代料的父级！');
        }
        if (commonUtils.isNotEmptyArr(selectData)) {
          // 删除空数据
          // tableInfo = tableInfo.filter(item => !(item.handleType === 'add' && !item.sMaterialsId));

          // slaveInfo选中数据
          const iIndex = tableInfo.findIndex(item => tableSelectedRowKeys.includes(item.sId) );
          const iChildIndex = tableInfo.findIndex(item => slave3Child0Child2SelectedRowKeys.includes(item.sId) );
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            const newCopyTo = {};
            newCopyTo.master = masterData;
            if (iChildIndex > -1 && commonUtils.isEmpty(tableInfo[iChildIndex].sMaterialsId)) {
              tableInfo[iChildIndex] = { ...tableInfo[iChildIndex], ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) };
            } else {
              let tableDataRowAdd = this.handleTableAdd('materials', true);
              tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = tableInfo[iIndex].sParentId;
              tableDataRowAdd.sParentMaterialsId = tableSelectedRowKeys[0];
              tableDataRowAdd.sProductCardId = currentProductCardId;
              tableDataRowAdd.sControlId = tableInfo[iIndex].sControlId;
              if(tbName ==='slave3Child0Child2') {
                tableDataRowAdd.sNons = '替代料';
              }
              tableInfo.push(tableDataRowAdd);
            }
          });
        }
        this.props.onSaveState({ materialsData: tableInfo });
      } else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopupMaterialsWorkOrder') { /* 工序表放大镜选择材料 */
        const { slave0Config:processConfig, slave0Data: processData, slave0SelectedRowKeys: processSelectedRowKeys} = this.props;
        let { materialsData, materials1Data, materials1Config,  materials2Data, materials2Config, } = this.props;
        if(commonUtils.isEmptyArr(materialsData)){
          materialsData = [];
        }
        /* 找到放大镜复制到配置 */
        const copyToConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials`.toLowerCase());
        const copyToAssignField = commonUtils.isNotEmptyArr(copyToConfig) ? copyToConfig[0].sAssignField : ''; /* 材料大类 */

        const addState ={};
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        if (commonUtils.isNotEmptyArr(selectData)) {
          const selectFilterDataAll =  selectData; /* 除了油墨,专色墨,电化铝之外的物料大类 */
          /* 全部材料 */
          if(commonUtils.isNotEmptyArr(selectFilterDataAll)) {
            selectFilterDataAll.forEach((item, index) => {
              const newCopyTo = {};
              newCopyTo.master = masterData;
              if (iIndex > -1) {
                newCopyTo.materials = item;
              }
              let tableDataRowAdd = this.handleTableAdd('materials', true);
              item.handleType = 'add';
              // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
              tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField, item) }; // 取赋值字段
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = masterData.sId;
              // tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
              tableDataRowAdd.sControlId = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlSelectedRowKeys[0] :'';
              tableDataRowAdd.sProductCardId = currentProductCardId;
              materialsData.push(tableDataRowAdd);
            });
          }
          this.props.onSaveState({  materialsData, ...addState });
        }
      } else if(selectConfig.sControlName && (selectConfig.sControlName.includes('BtnPopupProcess') ||  selectConfig.sControlName.includes('BtnChooseProcess') )) { /* 控制表放大镜选择工序 */
        const { slave0Config:processConfig, slave0Data: processData, slave0Child1Data: controlData,  slave0SelectedRowKeys: processSelectedRowKeys,
          slave0Child1Config: controlConfig,} = this.props;
        let { materialsData, materials1Data, materials1Config,  materials2Data, materials2Config, } = this.props;
        if(commonUtils.isEmptyArr(materialsData)){
          materialsData = [];
        }
        /* 找到放大镜复制到配置 */
        const copyToConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials`.toLowerCase());
        const copyToAssignField = commonUtils.isNotEmptyObject(selectConfig) ? selectConfig.sAssignField : ''; /* 材料大类 */

        const addState ={};
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        if (commonUtils.isNotEmptyArr(selectData)) {
          const selectFilterDataAll =  selectData;
          if(commonUtils.isNotEmptyArr(selectFilterDataAll)) {
            selectFilterDataAll.forEach((item, index) => {
              const newCopyTo = {};
              newCopyTo.master = masterData;
              if (iIndex > -1) {
                newCopyTo.materials = item;
              }
              let tableDataRowAdd = this.handleTableAdd('slave0', true);
              item.handleType = 'add';
              // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
              tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField, item) }; // 取赋值字段
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = masterData.sId;
              // tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
              tableDataRowAdd.sControlId = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlSelectedRowKeys[0] :'';
              tableDataRowAdd.sProductCardId = currentProductCardId;

              // 将工单参数的默认值保存到sParams中
              const sWorkOrderParam = commonUtils.convertStrToObj(tableDataRowAdd.sWorkOrderParam, {});
              const sWorkOrderParamDefaultValues = Object.keys(sWorkOrderParam).filter(
                item => item.startsWith('sParamDefault') && commonUtils.isNotEmptyObject(sWorkOrderParam[item])
              ).reduce((result, item) => {
                const sParamsName = item.replace('Default', '');
                result[sParamsName] = sWorkOrderParam[item];
                return result;
              }, {});

              const sParams = commonUtils.convertStrToObj(item.sParams, []);
              const sWorkOrderJsonIndex = sParams.findIndex(item => item.sParamType === 'sWorkOrder');
              if (sWorkOrderJsonIndex === -1) {
                sParams.push({
                  sParamType: 'sWorkOrder',
                  data: sWorkOrderParamDefaultValues
                });
              } else {
                const { data: sWorkOrderData = {} } = sParams[sWorkOrderJsonIndex];
                sParams[sWorkOrderJsonIndex].data = { ...sWorkOrderData, ...sWorkOrderParamDefaultValues };
              }
              tableDataRowAdd.sParams = JSON.stringify(sParams);

              processData.push(tableDataRowAdd);
            });
          }
          addState.slave0Data = processData;
          this.props.onSaveState({ ...addState });
        }
      }else if(selectConfig.sControlName && (selectConfig.sControlName === 'BtnPopupMaterials1Child' || selectConfig.sControlName.includes('BtnHeadPopup') )) { /* 头部放大镜选择替代料 */
        const { materialsSelectedRowKeys, materials1SelectedRowKeys, materials2SelectedRowKeys} = this.props; /* 油墨数据选中行 */
        let { materialsData } = this.props;
        let fatherRow = {};
         if(tbName === 'materialsChild') {
          const iIndex = commonUtils.isNotEmptyArr(materialsSelectedRowKeys) ? materialsData.findIndex(item => item.sId === materialsSelectedRowKeys[0]) : -1;
          if(iIndex  === -1) {
            message.error('请选择左侧选择行！');
            return;
          }
          fatherRow =  materialsData[iIndex];
        }
         const fatherName = 'materials';
        let { [`${fatherName}Data`]: tableData } = this.props;
        if(commonUtils.isEmptyArr(tableData)) {
          tableData = [];
        }
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            const newCopyTo = {};
            newCopyTo.master = masterData;
            let tableDataRowAdd = this.handleTableAdd(tbName, true);
            item.handleType = 'add';
            tableDataRowAdd = {...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item)}; // 取赋值字段
            tableDataRowAdd.handleType = 'add';
            tableDataRowAdd.sId = commonUtils.createSid();
            tableDataRowAdd.sParentId = masterData.sId;
            tableDataRowAdd.sParentMaterialsId = fatherRow.sId; /* 选中从表的sId */
            tableDataRowAdd.sProcessId = fatherRow.sProcessId; /* 工序ID */
            tableDataRowAdd.sProcessTbId = fatherRow.sProcessTbId; /* 工序表格ID */
            if(tbName === 'materialsChild') { /* 替代料 */
              tableDataRowAdd.sMaterialsNo1 = fatherRow.sMaterialsNo; /* 原材料编号 */
              tableDataRowAdd.sMaterialsName1 = fatherRow.sMaterialsName;  /* 原材料名称 */
              tableDataRowAdd.bAlternative = true;
            }
            tableDataRowAdd.sProductCardId = currentProductCardId;
            tableData.push(tableDataRowAdd);
          });
          this.props.onSaveState({ materialsData:tableData });
        }
      }else if(selectConfig.sName && selectConfig.sName === 'sAlumiteBomBillNo') { /* 电化铝Bom选择数据后，数据带入到电化铝 */
        let {  materialsData:materials0Data,  materialsDelData  } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(materials0Data)){
          materials0Data = [];
        }
        if(commonUtils.isEmptyArr(materialsDelData)){
          materialsDelData = [];
        }
        if (commonUtils.isNotEmptyArr(selectData)) {
          if (commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyArr(tableData)) {
            const iProcessIndex = tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]);
            if(iProcessIndex > -1) {
              tableData[iProcessIndex].handleType = commonUtils.isEmpty(tableData[iProcessIndex].handleType) ? 'update' : tableData[iProcessIndex].handleType;
              tableData[iProcessIndex].sAlumiteBomBillNo = selectData[0].sVersionNum;
              addState[`${tbName}Data`] = tableData;

              /* 移除该工序下的所有电化铝 */
              const filterDelData  =  materials0Data.filter(row => row.sProcessId === tableData[iProcessIndex].sProcessId &&
                row.sProcessTbId === tableData[iProcessIndex].sId && row.sBclassifyName === '电化铝');
              console.log('筛选的电化铝', filterDelData);
              if(commonUtils.isNotEmptyArr(filterDelData)) {
                filterDelData.forEach((item, index) => {
                  const iIndex = materials0Data.findIndex(row => row.sId === item.sId);
                  if(iIndex > -1) {
                    const delRow = materials0Data[iIndex];
                    delRow.handleType = 'del';
                    materials0Data.splice(iIndex, 1);
                    materialsDelData.push(delRow);
                  }
                })
              }
            }

          }
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            /* 先移除相同批次版本的电化铝 在插入 */
            // const iIndex = materials0Data.findIndex(row => row.sAluminumBomId === item.sId && row.sAluminumBomSlaveId === item.sSlaveId);
            // if(iIndex > -1) {
            //   const delRow = materials0Data[iIndex];
            //   delRow.handleType = 'del';
            //   materials0Data.splice(iIndex, 1);
            //   materialsDelData.push(delRow);
            // }
            const newCopyTo = {};
            newCopyTo.master = masterData;
            let tableDataRowAdd = this.handleTableAdd('materials', true);
            item.handleType = 'add';
            tableDataRowAdd = {...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item)}; // 取赋值字段
            tableDataRowAdd.sId = commonUtils.createSid();
            tableDataRowAdd.sParentId = masterData.sId;
            tableDataRowAdd.sProductCardId = currentProductCardId;
            materials0Data.push(tableDataRowAdd);

            /* 替代料对应的材料id重新刷一遍 */
            const tdlFilterData = materials0Data.filter(item => commonUtils.isNotEmptyObject(item.sParentMaterialsId) &&
              item.sMaterialsNo1 === tableDataRowAdd.sMaterialsNo);
            if(commonUtils.isNotEmptyObject(tdlFilterData)){
              tdlFilterData.forEach((item, index) => {
                const iFIndex = materials0Data.findIndex(child => child.sId ===item.sId);
                if(iFIndex > -1) {
                  const addState = {};
                  addState.sParentMaterialsId =  tableDataRowAdd.sId;
                  addState.handleType = commonUtils.isEmpty(materials0Data[iFIndex].handleType) ? 'update' : materials0Data[iFIndex].handleType;
                  materials0Data[iFIndex] ={...materials0Data[iFIndex], ...addState};
                }
              });
            }

          });
          addState.materialsData = materials0Data;
          addState.materialsDelData = materialsDelData;

          const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
          if (commonUtils.isJSON(selectData[0].sParams) && iIndex > -1) {
            const paramsNewData = JSON.parse(selectData[0].sParams);
            if (commonUtils.isJSON(tableData[iIndex].sParams)) {
              const paramsOldData = JSON.parse(tableData[iIndex].sParams);
              const iNewIndex = paramsNewData.findIndex(item => item.sParamType === 'sWorkOrder');
              if (iNewIndex > -1) {
                const iOldIndex = paramsOldData.findIndex(item => item.sParamType === 'sWorkOrder');
                if (iOldIndex > -1) {
                  paramsOldData[iOldIndex].data = {...paramsOldData[iOldIndex].data, ...paramsNewData[iNewIndex].data};
                } else {
                  paramsOldData.push(paramsNewData[iNewIndex]);
                }
                tableData[iIndex].sParams = JSON.stringify(paramsOldData);
              }
            } else {
              tableData[iIndex].sParams = selectData[0].sParams;
            }
            addState[`${tbName}Data`] = tableData;
          }

          this.props.onSaveState({ ...addState });
        }
      }else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopup.dMergeProductionQty') { /* 合并生产逻辑 */
        let { slaveData, slaveSelectedRowKeys } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(slaveData)){
          slaveData = [];
        }
        const iIndex = this.handleGetSelectedIndex(this.props, 'slave');
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0);
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0;
            jsonData.push(obj);
          });
          addState.dMergeProductionQty = dModifyProductQty;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sMergeProduction = jsonStr;
            addState.dSplitworkQty = commonUtils.convertToNum(dModifyProductQty +  commonUtils.isNull(tableData[iIndex].dQdismantledQty, 0));
          }
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        } else {
          addState.dMergeProductionQty = 0;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          addState.sMergeProduction = '';
          addState.dSplitworkQty = 0;
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        }
      } else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopup.dWorkPeriodQty') { /* 在制品数量 */
        let { slaveData, slaveSelectedRowKeys } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(slaveData)){
          slaveData = [];
        }
        const iIndex = this.handleGetSelectedIndex(this.props, 'slave');
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0);
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0;
            jsonData.push(obj);
          });
          addState.dWorkPeriodQty = dModifyProductQty;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sWorkProduct = jsonStr;
          }
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        } else {
          addState.dWorkPeriodQty = 0;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          addState.sWorkProduct = '';
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        }
      }else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopup.dSplitworkQty') { /* 拆分工单 */
        let { slaveData, slaveSelectedRowKeys } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(slaveData)){
          slaveData = [];
        }
        const iIndex = this.handleGetSelectedIndex(this.props, 'slave');
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0);
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.sId = item.sId;
            obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0;
            jsonData.push(obj);
          });
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sSplitQty = jsonStr;
            addState.dSplitworkQty = dModifyProductQty;
          }
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        } else {
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          addState.sSplitQty = '';
          addState.dSplitworkQty = commonUtils.convertToNum(commonUtils.isNull(tableData[iIndex].dQdismantledQty, 0) +  commonUtils.isNull(tableData[iIndex].dMergeProductionQty, 0));
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        }
      }else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopup.dPreMatProductQty') { /* 消耗备料 */
        let { slaveData, slaveSelectedRowKeys } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(slaveData)){
          slaveData = [];
        }
        const iIndex = this.handleGetSelectedIndex(this.props, 'slave');
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0);
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0;
            jsonData.push(obj);
          });
          addState.dPreMatProductQty = dModifyProductQty;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sPreMatProduct = jsonStr;
          }
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        } else {
          addState.dPreMatProductQty = 0;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          addState.sPreMatProduct = '';
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        }
      }else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopup.dCombinedQty') { /* 合版订单 */
        let { slaveData, slaveSelectedRowKeys } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(slaveData)){
          slaveData = [];
        }
        const iIndex = this.handleGetSelectedIndex(this.props, 'slave');
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0);
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0;
            for (const key of Object.keys(item)) {
              if(key !== 'sSlaveId' && key !=='dModifyProductQty' && key!== 'sPartNameStatus') {
                obj[key] = item[key];
              }
            }
            jsonData.push(obj);
          });
          addState.dCombinedQty = dModifyProductQty;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sCombinedMemo = jsonStr;
          }
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        } else {
          addState.dCombinedQty = 0;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          addState.sCombinedMemo = '';
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        }
      }else if(selectConfig.sName && selectConfig.sName === 'dStockAuxiliaryQty') { /* 合并生产逻辑 */
        let {  slave3Child0SelectedRowKeys = [], materialsData: tableData, [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(tableData)){
          tableData = [];
        }
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)){
          tableSelectedRowKeys = [];
        }
        const iIndex = tableData.findIndex(item => tableSelectedRowKeys.includes(item.sId));
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            dModifyProductQty += commonUtils.isNull(item.dAuxiliaryQty, 0);
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.bExclude = item.bExclude;
            jsonData.push(obj);
          });
          // addState.dMergeProductionQty = dModifyProductQty;
          addState.handleType = commonUtils.isNotEmptyArr(tableData)  && commonUtils.isEmpty(tableData[iIndex].handleType)
            ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sAvailableExclude = jsonStr;
            const dStockAuxiliaryQty = commonUtils.convertToNum(commonUtils.isNull(tableData[iIndex].dStockAuxiliaryQty, 0) -  dModifyProductQty);
            const dApplyNoAuxiliaryQty =  commonUtils.convertToNum(commonUtils.isNull(tableData[iIndex].dApplyNoAuxiliaryQty, 0));
            const dPurchaseNoAuxiliaryQty =  commonUtils.convertToNum(commonUtils.isNull(tableData[iIndex].dPurchaseNoAuxiliaryQty, 0));
            const dWorkOrderUpAuxiliaryQty =  commonUtils.convertToNum(commonUtils.isNull(tableData[iIndex].dWorkOrderUpAuxiliaryQty, 0));
            const dAvailableAuxiliaryQty =  commonUtils.convertFixNum(dStockAuxiliaryQty +
              dApplyNoAuxiliaryQty +
              dPurchaseNoAuxiliaryQty -
              dWorkOrderUpAuxiliaryQty, 6);
            addState.dStockAuxiliaryQty = dStockAuxiliaryQty < 0 ? 0 : dStockAuxiliaryQty;
            addState.dAvailableAuxiliaryQty = dAvailableAuxiliaryQty  < 0 ? 0 : dAvailableAuxiliaryQty;

          }
          if(iIndex > -1) {
            tableData[iIndex] = { ...tableData[iIndex], ...addState };
          }
          addState.materialsData = tableData;
          console.log('可用数量', addState);
          this.props.onSaveState({ ...addState });
        }
      } else {
        this.props.onSelectCommonPopup(currentPaneName, selectConfig, selectData, tbName);
      }

    };

    onExecInstructSet = (type) => {
      const { slave3Child0Config } = this.props;
      let showConfig = {};
      const iIndex = slave3Child0Config.gdsconfigformslave.findIndex(item => item.sName === 'dAdjustAuxiliaryQty');
      if (iIndex > -1) {
        showConfig = slave3Child0Config.gdsconfigformslave[iIndex];
      }
      const { sInstruct: sInstructStr, showName, sOnChangeInstruct } = showConfig;
      const sInstruct = commonUtils.convertStrToObj(sInstructStr, {});
      let { [type]: instructType } = sInstruct;
      if (type === 'change') {
        const onChangeNew = commonUtils.convertStrToObj(sOnChangeInstruct, {});
        instructType = onChangeNew[type];
      }
      if (instructType) {
        if (this.props.onExecInstructSet) {
          this.props.onExecInstructSet({
            type,
            sInstruct: instructType,
            showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`,
          });
        } else {
          message.error('未定义调用指令集事件！');
        }
        return true;
      }
      return false;
    }

    handleRightArrow = (name, sName, record, index, showConfig) => {
      /* 将该行的dAdjustAuxiliaryQty:dNeedAuxiliaryQty */
      if (!this.props.enabled) return;
      const { materialsData }= this.props;
      const sId = record?.sId;
      const iIndex =  commonUtils.isNotEmptyArr(materialsData)? materialsData.findIndex(item => item.sId === sId) : -1;
      if(iIndex > -1) {
        const tableDataRow = materialsData[iIndex];
        const handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
        const addState ={
          dAdjustAuxiliaryQty : tableDataRow.dNeedAuxiliaryQty,
          handleType,
        }
        materialsData[iIndex] ={...materialsData[iIndex], ...addState};
        this.onExecInstructSet( 'change');
        this.props.onSaveState({ materialsData })
      }

    }

    handleGetSelectedIndex = (props, tableName) => {
      const selectedRowKeys = props[`${tableName}SelectedRowKeys`] || [];
      let selectedDataIndex = -1;
      const tableData = props[`${tableName}Data`];
      if (commonUtils.isNotEmptyArr(tableData)) {
        if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
          selectedDataIndex = tableData.findIndex(
            item => item.sId === selectedRowKeys[0]
          );
        } else {
          selectedDataIndex = 0;
        }
      }
     return selectedDataIndex;
    };

    handleDrag = (data, tableName) => {
      let { slave0Child1SelectedRowKeys: controlSelectedRowKeys, controlData, slave0Data: processData, enabled } = this.props;
      if(enabled && commonUtils.isNotEmptyArr(controlSelectedRowKeys)) {
        if(tableName === 'slave0') {
          if(commonUtils.isNotEmptyArr(data)) {
            let allData = processData.slice(0);
            /* 控制表选中行 移动排序 */
            const filterData =  data.filter(item => item.sType !== '3' && item.sControlId === controlSelectedRowKeys[0]);
            if(commonUtils.isNotEmptyArr(filterData)) {
              filterData.forEach((item, iIndex) => {
                item.iOrder = iIndex + 1;
                const iFilterIndex = commonUtils.isNotEmptyArr(allData) ? allData.findIndex(row => item.sId === row.sId) : -1;
                if(iFilterIndex > -1) {
                  allData[iFilterIndex] = {...item, iOrder: iIndex + 1}
                }
              });
            }

            /* 找到所属控制表的iOrder * 10000 */
            allData.forEach((item, iIndex) => {
              const iControlIndex = commonUtils.isNotEmptyArr(controlData) ? controlData.findIndex(row => item.sControlId === row.sId) : -1;
              if(iControlIndex > -1) {
                const iControlOrder =  controlData[iControlIndex].iOrder * 10000;
                allData[iIndex].iControlOrder = iControlOrder;
                allData[iIndex].iOrder = iControlOrder + item.iOrder;
              }
            });

            allData = allData.sort((a, b) => a.iOrder - b.iOrder);
            // allData.forEach((item, iIndex) => {
            //   allData[iIndex] = {...item, handleType : commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType};
            // });
            this.props.onSaveState({ slave0Data: allData });
          }

        }
      }
    }

    handleReplaceRow = (tableName, record) => {
      /* 将替代料里的数据 复制到更换材料里 */
      const{ masterData, [`${tableName}SelectedRowKeys`]: tableSelectedRowKeys,[`${tableName}Config`]: tableConfig,  materialsData= [], currentProductCardId } = this.props;
      if(commonUtils.isEmpty(record)) {
        message.error('请选择数据');
        return;
      }
      if(record.sHasReplace === 1) {
        message.error('材料已经被提取!');
        return;
      }
      const btnConfig = tableConfig?.gdsconfigformslave.filter(item => item.sControlName.includes('BtnReplace'));
      let sAssignField = '';
      if(commonUtils.isNotEmptyArr(btnConfig)) {
        sAssignField = btnConfig[0].sAssignField;
      }
      const newCopyTo = {};
      newCopyTo.master = masterData;
      newCopyTo.slave3Child0Child1 = record;
      let tableDataRow = this.props.onDataRowAdd('materials', true);
      tableDataRow = {...tableDataRow, ...commonFunc.getAssignFieldValue(sAssignField, record)}; // 取赋值字段
      tableDataRow.sId = commonUtils.createSid();
      tableDataRow.handleType = 'add';
      tableDataRow.bMainMaterials = 1;
      tableDataRow.sParentId = masterData.sId;
      tableDataRow.sProductCardId = currentProductCardId;
      tableDataRow.sNons = '替代料';
      tableDataRow.sParentMaterialsId = record.sParentMaterialsId;
      tableDataRow.originSNonsId = record.sId;
      materialsData.push(tableDataRow);

      const selectRowIndex = materialsData?.findIndex(i => i && i.sId === record?.sId);
      if (selectRowIndex > -1) {
        materialsData[selectRowIndex] = { ...record, sHasReplace: 1 };
      }
      const masterDataNew = { ...masterData, bMrpCalc: false };
      this.props.onSaveState({ masterData: masterDataNew, materialsData,  slave3Child0Child2SelectedRowKeys: [tableDataRow.sId]  });
      message.info("提取成功！");
    }

    handleGetSelectedData = (props, tableName) => {
      const selectedRowKeys = props[`${tableName}SelectedRowKeys`] || [];
      let selectedDataIndex = -1;
      const tableData = props[`${tableName}Data`];
      if (commonUtils.isNotEmptyArr(tableData)) {
        if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
          selectedDataIndex = tableData.findIndex(
            item => item.sId === selectedRowKeys[0]
          );
        } else {
          selectedDataIndex = 0;
        }
      }
      if( selectedDataIndex > -1) {
        return props[`${tableName}Data`][selectedDataIndex];
      } else {
        return {};
      }
    };

    handleTableSelectRowChange = (name, selectedKeys, isWait) => {
      const { materialsData } = this.props;
      if (name === 'slave3Child0Child2' || name === 'slave3Child0Child1') {
        let addState = this.props.onTableSelectRowChange(name, selectedKeys, true);
        if (commonUtils.isNotEmptyArr(selectedKeys)) {
          const iIndex = materialsData.findIndex(item => item.sId === selectedKeys[0]);
          if (iIndex > -1) {
            addState.slave3Child0SelectedRowKeys = [materialsData[iIndex].sParentMaterialsId];
          }
        }
        if (isWait) {
          return addState;
        } else {
          this.props.onSaveState(addState);
        }
      } else {
        if (isWait) {
          return this.props.onTableSelectRowChange(name, selectedKeys, true);
        } else {
          return this.props.onTableSelectRowChange(name, selectedKeys);
        }

      }

    };

    /** 键盘事件监听 */
    onKeyDown = (e, record, sName, name, tableData) => {
      const { [`${name}Column`]: tableColumn } = this.props;
      // 以下if条件为 为解决bug2031问题入口 需求：收款单里输入的收款金额，上下键操作把加减金额改为选择上下行（通过上下方向键切换行数）
      const move = (keyCode, cursortPosition, columnIndex) => {
        if (keyCode === 37 && columnIndex > 0 && cursortPosition < 1) { // 左移 则 列下标必须大于0, 且光标在最左侧
          const lastId = `${tableColumn[columnIndex - 1].dataIndex}${record.sId}`;
          if (!commonUtils.focus(lastId, e)) move(keyCode, cursortPosition, columnIndex - 1); // 递归
        }
        if (keyCode === 39 && columnIndex < tableColumn.length - 1) { // 右移 则 列下标必须小于列数量-1
          if (!record[sName] || cursortPosition >= record[sName].toString().length) { // 当前列为空 或 光标位置不小于当前值的长度
            const nextId = `${tableColumn[columnIndex + 1].dataIndex}${record.sId}`;
            if (!commonUtils.focus(nextId, e)) move(keyCode, cursortPosition, columnIndex + 1); // 递归
          }
        }
      };
      if ([38, 40].includes(e.keyCode)) { // 上键、下键
        e.preventDefault();
        if (tableData.length > 1) { // 当从表行数大于一行时才有上下移动的意义
          const index = tableData.findIndex(item => item.sId === record.sId); // 获取当前编辑行的下标
          if (index > -1) {
            if (e.keyCode === 38 && index > 0) { // 方向键上键 且 当前编辑行下标大于0时，为0时无法向上
              const lastSid = tableData[index - 1].sId; // 获取上一个id
              this.props.onSaveState({ [`${name}SelectedRowKeys`]: [lastSid] }, () => commonUtils.focus(`${sName}${lastSid}`));
            }
            if (e.keyCode === 40 && index < tableData.length - 1) { // 方向键下键 且 当前编辑行下标小于最大值时，为最大值时无法向下
              const nextSid = tableData[index + 1].sId; // 获取下一个id
              this.props.onSaveState({ [`${name}SelectedRowKeys`]: [nextSid] }, () => commonUtils.focus(`${sName}${nextSid}`));
            }
          }
        }
      } else if ([37, 39].includes(e.keyCode)) { // 左键、右键
        const currentElement = document.getElementById(`${sName}${record.sId}`); // 当前编辑框对象
        if (currentElement) {
          const cursortPosition = commonUtils.getCursortPosition(currentElement); // 光标位置
          const columnIndex = tableColumn.findIndex(item => item.dataIndex === sName); // 当前列下标
          move(e.keyCode, cursortPosition, columnIndex);
        }
      }
    }
    /* 单击右键全部更新，弹出窗选择后，更新此列所有数据 （只更新非只读字段） */
    onContextMenu = (e, record, showConfig, tbName) => {
      const contextMenuConfig = [];
      console.log('单击右键全部更新', showConfig);
      const showConfigNew = JSON.parse(JSON.stringify(showConfig)); /* 深拷贝配置 */
      contextMenuConfig.push(showConfigNew);
      this.props.onSaveState({
        contextMenuModalVisible: true, /* 右击全部更新弹窗 */
        contextMenuConfig, /* 右击字段配置 数组形式 */
        contextMenuRecord: record, /* 右击数据 */
        contextMenuName: showConfig.showName, /* 右击字段 */
        contextMenuTbName: tbName, /* 右击字段 */
      });
    }

    /* 单据字段单击右键全部更新，弹出窗选择后，更新此列所有数据。（只更新非只读字段） */
    handleContextMenuOk= async (contextMenuValue, contextMenuData, contextMenuType) => {
      const {
        contextMenuConfig, contextMenuTbName, [`${contextMenuTbName}Data`]: tableData, [`${contextMenuTbName}SelectedRowKeys`]: selectedRowKeys,
      } = this.props;
      console.log('111', contextMenuTbName);
      if (commonUtils.isNotEmptyObject(contextMenuTbName) && commonUtils.isNotEmptyArr(tableData)) {
        if (commonUtils.isNotEmptyArr(contextMenuConfig) && commonUtils.isNotEmptyObject(contextMenuConfig[0])) {
          const tableConfig = contextMenuConfig[0];
          const tableFilterData = tableData.filter(item => selectedRowKeys.includes(item.sId));
          if (commonUtils.isNotEmptyArr(tableFilterData)) {
            let changeData = [];
            const chooseType =  commonUtils.isNotEmptyNumber(contextMenuType) ? contextMenuType : 1;
            if(chooseType === 1) {
              changeData = tableData;
            } else if(chooseType === 2) {
              const iIndex = tableData.findIndex(item => selectedRowKeys.includes(item.sId));
              changeData = tableData.filter((_, index) => index >= iIndex);
            }
            // const tableDataRow = tableFilterData[0];
            if (commonUtils.isNotEmptyArr(changeData) && commonUtils.isNotEmptyObject(tableConfig.sName) && !commonUtils.isEmpty(contextMenuValue)) {
              const sName = tableConfig.sName;
              for (let i = 0; i < changeData.length; i++) {
                const child = changeData[i];
                const addState = {};
                addState[sName] = contextMenuValue;
                const iIndex = tableData.findIndex(row => row.sId === child.sId);
                const bShowProcess = [
                  'sMaterialsNo',
                  'sMaterialsName',
                  'dAuxiliaryQty',
                  'dReelAuxiliaryQty',
                  'dConversionQty',
                  'sMaterialsStyle',
                  'sMaterialsStyle',
                  'dMaterialsQty',
                  'dAuxiliaryLossQty',
                  'dLossQty',
                  'sProcessId',
                  'sProcessNo',
                  'sProcessName'
                ].includes(sName);
                bShowProcess && message.loading({ content: <Progress percent={0} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess});
                if(iIndex > -1) {
                  addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
                  tableData[iIndex] = { ...tableData[iIndex], ...addState, ...contextMenuData };
                  const changeValue = { ...contextMenuData };
                  changeValue[sName] = contextMenuValue;
                  this.xlyProcessPercent = ((i + 1) / changeData.length * 100).toFixed(2);
                  const duration = i ===  changeData.length - 1 ? 1 : 0;
                  bShowProcess && message.loading({ content: <Progress percent={this.xlyProcessPercent} />, key: "xlyProcess", duration, className: styles.xlyProcess});

                  /* 手动触发改变事件 */
                  const result = await this.handleTableChange(contextMenuTbName, sName, changeValue, child.sId, [], true);
                  tableData[iIndex] = { ...tableData[iIndex], ...result };
                }
              }
            }
          }
        }
      }
      this.props.onSaveState({
        [`${contextMenuTbName}Data`]: tableData,
        contextMenuModalVisible: false, /* 右击全部更新弹窗 */
      });
    }

    render() {
      const { masterData, sModelsType, app } = this.props;
      const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app);
      const imgPersonSrc = commonBusiness.handleCheckIcon(masterData, sModelsType, app);
      return (
        <ChildComponent
          {...this.props}
          {...this.state}
          onKeyDown={this.onKeyDown}
          onAdd={this.handleAdd}
          onEdit={this.handleEdit}
          onSubmit={this.handleValidateSave}
          onSaveData={this.handleSaveData}
          onTableSelectRowChange={this.handleTableSelectRowChange}
          onReturnForm={this.handleForm}
          onChangeInvalid={this.handleInvalid}
          onBtnExamine={this.handleAudit.bind(this, 1)}
          onBtnCancelExamine={this.handleAudit.bind(this, 0)}
          onCopyTo={this.handleCopyTo}
          onCopyFrom={this.handleCopyFrom}
          onSearchData={this.handleSearchData}
          onNext={this.handleSearchData.bind(this, 'next')}
          onBtnPrior={this.handleSearchData.bind(this, 'up')}
          onBtnFirst={this.handleSearchData.bind(this, 'first')}
          onBtnLast={this.handleSearchData.bind(this, 'end')}
          onSearchUpDown={this.handleSearchUpDown}
          onGetData={this.handleGetData}
          onCancel={this.handleCancel}
          onDel={this.handleDel}
          onSearchUpDownThird={this.handleSearchUpDownThird}
          onDataRowAdd={this.handleTableAdd}
          onDataRowCopy={this.handleTableCopy}
          onDataRowCopyAll={this.handleTableCopyAll}
          onDataChange={this.handleTableChange}
          onBtnPrint={this.handleBtnPrint}
          onChange={this.handleMasterChange}
          onTitleChange={this.handleTitleChange}
          onButtonClick={this.handleButtonClick}
          onBtnChoose={this.handleBtnChoose}
          onSelect={this.handleSelect}
          onSelectCancel={this.handleSelectCancel}
          onViewClick={this.handleViewClick}
          // onGetMemo={this.handleGetMemo}
          // onGetMemoCancel={this.handleGetMemoCancel}
          onDelDataSuccess={this.handleDelDataSuccess}
          onMaterialsChange={this.handleMaterialsChange}
          onDataAudit={this.dataAudit}
          onCopyRow={this.handleTableCopyTo}
          imgSrc={imgSrc}
          imgPersonSrc={imgPersonSrc}
          onFilfileManageOk={this.handleFilfileManageOk}
          onCancelProductProcessInfoChooseModal={this.handleCloseProductProcessInfoChooseModal}
          onDropDownBlur={this.handleTableBlur}
          onGetSqlConditionValues={this.handleGetSqlConditionValues}
          GetTableData ={this.handleGetTableData}
          onDataRowDel={this.handleTableDel}
          onSelectCommonPopup={this.handleSelectCommonPopup}
          onRightArrow = {this.handleRightArrow}
          onDrag={this.handleDrag}
          onReplaceRow ={this.handleReplaceRow}
          onContextMenu={this.onContextMenu}
          onContextMenuOk={this.handleContextMenuOk}
        />
      );
    }
  };
};
