/* eslint-disable */
import React, { Component } from 'react';
import { Modal, message } 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';


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,
      } = 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 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 slaveConfig = formData.length > 1 ? 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 ? 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 ? 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 ? 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 ? 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 ? 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);
        const slaveOtherConfigArr =  [];
        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;
            }
          });
          addOtherState.slaveOtherConfigArr = slaveOtherConfigArr;
        }


        config.masterConfig = masterConfig;

        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 {
          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);
        }
        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,
          ...addOtherState
        });
      }
    }

    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) => {
      const { currentId, app } = this.props; /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || '';
      const { sModelsId, masterData, sModelsType, slaveSelectedRowKeys } = this.props;
      await this.props.handleGetDataOne({ name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick });
      let addStateSlave = {};
      if (!commonUtils.isEmptyObject(slaveConfig)) {
        addStateSlave = await this.props.handleGetDataSet({
          name: 'slave', configData: slaveConfig, condition: { sSqlCondition: { 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;
              }

            }
          }
        }

        if (commonUtils.isNotEmptyStr(addStateSlave.slaveData)) {
          const selectRowKey = addStateSlave.slaveData[0].sId;
          const selectRowKeyArr = [];
          selectRowKeyArr.push(selectRowKey);
          this.handleTableSelectRowChange('slave', selectRowKeyArr, addStateSlave.slaveData);
        }


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

      let addStateSlave0 = {};
      if (!commonUtils.isEmptyObject(slave0Config)) {
        addStateSlave0 = await this.props.handleGetDataSet({
          name: 'slave0', configData: slave0Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });
        // 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)) {
        addStateSlave2 = await this.props.handleGetDataSet({
          name: 'slave2', configData: slave2Config, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
      let addStateSlave3 = {};
      if (!commonUtils.isEmptyObject(slave3Config)) {
        addStateSlave3 = await this.props.handleGetDataSet({
          name: 'slave3', configData: slave3Config, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
      let addStateSlave4 = {};
      if (!commonUtils.isEmptyObject(slave4Config)) {
        addStateSlave4 = await this.props.handleGetDataSet({
          name: 'slave4', configData: slave4Config, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
      let addStateSlave5 = {};
      if (!commonUtils.isEmptyObject(slave5Config)) {
        addStateSlave5 = await this.props.handleGetDataSet({
          name: 'slave5', configData: slave5Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave6 = {};
      if (!commonUtils.isEmptyObject(slave6Config)) {
        addStateSlave6 = await this.props.handleGetDataSet({
          name: 'slave6', configData: slave6Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave7 = {};
      if (!commonUtils.isEmptyObject(slave7Config)) {
        addStateSlave7 = await this.props.handleGetDataSet({
          name: 'slave7', configData: slave7Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave8 = {};
      if (!commonUtils.isEmptyObject(slave8Config)) {
        addStateSlave8 = await this.props.handleGetDataSet({
          name: 'slave8', configData: slave8Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave9 = {};
      if (!commonUtils.isEmptyObject(slave9Config)) {
        addStateSlave9 = await this.props.handleGetDataSet({
          name: 'slave9', configData: slave9Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });
      }
      let addStateSlave10 = {};
      if (!commonUtils.isEmptyObject(slave10Config)) {
        addStateSlave10 = await this.props.handleGetDataSet({
          name: 'slave10', configData: slave10Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        });
      }
      this.props.onSaveState({
        pageLoading: false, ...addStateSlave, ...addStateSlave0, ...addStateSlave1,  ...addStateSlave2, ...addStateSlave3, ...addStateSlave4,
        ...addStateSlave5, ...addStateSlave6, ...addStateSlave7, ...addStateSlave8, ...addStateSlave9, ...addStateSlave10,
        viewDragRefreshTime: commonUtils.createSid(),
      });

    };
    /* 获取表数据 */
    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: { sParentId: sId } }, isWait: true,
      }) : '';
      const addStateSlave0 = slave0Config ? await this.props.handleGetDataSet({
        name: 'slave0', configData: slave0Config, condition: { sSqlCondition: { sParentId: sId } },
      }) : '';
      const addStateSlave1 = slave1Config ? await this.props.handleGetDataSet({
        name: 'slave1', configData: slave1Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
      }) : '';
      const addStateslave2 = slave2Config ? await this.props.handleGetDataSet({
        name: 'slave2', configData: slave2Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
      }) : '';
      const addStateslave3 = slave3Config ? await this.props.handleGetDataSet({
        name: 'slave3', configData: slave3Config, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
      }) : '';
      const addStateslave4 = slave4Config ? await this.props.handleGetDataSet({
        name: 'slave4', configData: slave4Config, condition: { sSqlCondition: { 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: { 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;
                  let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo); // 取默认值
                  slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo) };
                  slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                  slaveRow.handleType = 'add';
                  slaveRow.sId = commonUtils.createSid();
                  slaveRow.sParentId = masterData.sId;
                  slaveData.push(slaveRow);
                });
              }
            }

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

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

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

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

            if(slave4AssignField) {
              if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                returnData.slave4.forEach((slave4Item) => {
                  newCopyTo.slave4 = slave4Item;
                  let slave4Row = commonFunc.getDefaultData(config.slave4Config, newCopyTo); // 取默认值
                  slave4Row = { ...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo) }; // 取赋值字段
                  slave4Row.handleType = 'add';
                  slave4Row.sId = commonUtils.createSid();
                  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;
                  let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo); // 取默认值
                  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 = commonUtils.createSid();
                  slaveRow.sParentId = masterData.sId;
                  slaveData.push(slaveRow);
                });
              }

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

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

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

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

              if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                returnData.slave4.forEach((slave4Item) => {
                  newCopyTo.slave4 = slave4Item;
                  let slave4Row = commonFunc.getDefaultData(config.slave4Config, newCopyTo); // 取默认值
                  slave4Row = {...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo)}; // 取赋值字段
                  slave4Row.handleType = 'add';
                  slave4Row.sId = commonUtils.createSid();
                  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;
                let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo); // 取默认值
                slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo) };
                slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                slaveRow.handleType = 'add';
                slaveRow.sId = commonUtils.createSid();
                slaveRow.sParentId = masterData.sId;
                slaveData.push(slaveRow);
              });
            }
          }

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

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

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

          if(slave4AssignField) {
            if (commonUtils.isNotEmptyArr(returnData.slave4)) {
              returnData.slave4.forEach((slave4Item) => {
                newCopyTo.slave4 = slave4Item;
                let slave4Row = commonFunc.getDefaultData(config.slave4Config, newCopyTo); // 取默认值
                slave4Row = { ...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo) }; // 取赋值字段
                slave4Row.handleType = 'add';
                slave4Row.sId = commonUtils.createSid();
                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 tableDataRowAdd = commonFunc.getDefaultData(configNew.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;
        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: [],
        ...this.handleGetParam('sProcess', {}),
        ...this.handleGetParam('sReport', {}),
        ...this.handleGetParam('sWorkOrder', {}),
        ...this.handleGetParam('sNorm', {}),
        ...this.handleGetParam('sTest', {}),
      };
      state.sUseInfo = '';
      if (isWait) {
        return state;
      } else {
        this.props.onSaveState(state);
        return true;
      }
    };
    /**   点击修改按钮操作   */
    handleEdit = async () => {
      const {
        masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, currentId, app, masterData, dispatch,
      } = this.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, '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') {
          await this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, 'update');
          this.props.onSaveState({ enabled: true, loading: false });
          const { slaveData } = this.props;
          if (commonUtils.isNotEmptyArr(slaveData)) {
            const selectRowKey = slaveData[0].sId;
            const selectRowKeyArr = [];
            selectRowKeyArr.push(selectRowKey);
            this.handleTableSelectRowChange('slave', selectRowKeyArr, slaveData);
          }
        }
      };
      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,
      } = 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);
          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 = (name, sActiveId) => {
      /*   待用数据声明   */
      const {
        dispatch, masterConfig, slave1Data, masterData, slaveData, slave2lData, slave0Data, slave3lData, slave4lData,
      } = 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;
      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,
      } = 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;
      }

      const value = {
        sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages.total,
      };
      this.props.onSaveState({ loading: true });
      const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`;
      /*   接收返回值   */
      const { data } = await commonServices.postValueService(token, value, url);
      /*   接收返回值   */
      /*   成功的话刷新页面(同步主表和从表数据),不成功就弹出错误提示   */
      if (data.code === 1) {
        /*   数据查询成功   */
        const returnData = data.dataset.rows[0];
        this.props.onSaveState({
          currentIndexFlag: true,
          currentPageNo: returnData.currentPosition,
          currentId: returnData.sId,
          searchUpDownData: {},
          slaveSelectedRowKeys: [],
        });
        this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config);
        return true;
      } else { /*   失败   */
        this.props.getServiceError(data);
        return false;
      }
    };

    /*   取消操作  */
    handleCancel = (obj) => {
      /*   待用数据声明   */
      const {
        currentId, masterConfig, slaveConfig, slave1Config, app, masterData,
      } = this.props;
      const that = this;
      const { userinfo } = app;
      const onSendSocketMessage = this.props.handleSendSocketMessage;
      const onGetDataOk = this.handleGetData;
      const onSaveStateOk = this.props.onSaveState;
      const { copyTo } = app.currentPane;
      confirm({
        title: obj.title,
        onOk() {
          const bChanged =  commonBusiness.handleGetChanged(that.props) ;
          if(bChanged) {
            onGetDataOk(masterConfig, slaveConfig, slave1Config);
          }
          onSaveStateOk({ enabled: false });
          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;
      let { [`${name}Data`]: tableData } = 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 (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] });
      }
    };

    /**   复制   */
    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,
      } = 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 {
        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;
                  let controlRow = commonFunc.getDefaultData(controlConfig, newCopyTo); // 取默认值
                  controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
                  controlRow.handleType = 'add';
                  controlRow.sId = commonUtils.createSid();
                  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;
                      let slave0Row = commonFunc.getDefaultData(slave0Config, newCopyTo); // 取默认值
                      slave0Row = { ...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo) }; // 取赋值字段
                      slave0Row.handleType = 'add';
                      slave0Row.sId = commonUtils.createSid();
                      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;
                      let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
                      processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                      processRow.handleType = 'add';
                      processRow.sId = commonUtils.createSid();
                      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;
                  let slave0Row = commonFunc.getDefaultData(slave0Config, newCopyTo); // 取默认值
                  slave0Row = { ...slave0Row, ...commonFunc.getAssignFieldValue(slave0AssignField, slave0Item, newCopyTo) }; // 取赋值字段
                  slave0Row.handleType = 'add';
                  slave0Row.sId = commonUtils.createSid();
                  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;
                  let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
                  processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                  processRow.handleType = 'add';
                  processRow.sId = commonUtils.createSid();
                  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`]: [] };
    };

    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 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;
          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) => {
            let tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData);
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(slaveAssignField, item, newCopyTo) }; //  取赋值字段
            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;
            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) => {
            let tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData);
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(slaveAssignField, item, newCopyTo) }; //  取赋值字段
            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;
            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 (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;
                  let slaveRow = commonFunc.getDefaultData(allConfig.slaveConfig, newCopyTo); // 取默认值
                  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 = commonUtils.createSid();
                  slaveRow.sParentId = masterData.sId;
                  slaveData.push(slaveRow);
                });
              }

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

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

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

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

              if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                returnData.slave4.forEach((slave4Item) => {
                  newCopyTo.slave4 = slave4Item;
                  let slave4Row = commonFunc.getDefaultData(allConfig.slave4Config, newCopyTo); // 取默认值
                  slave4Row = { ...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo) }; // 取赋值字段
                  slave4Row.handleType = 'add';
                  slave4Row.sId = commonUtils.createSid();
                  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')) { /* 实现通用计算功能 */
        const { masterConfig, masterData, sModelsId, } = this.props;
        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)) {
                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)) {
                  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;
              console.log('66666', allReturnMap);
            }
            this.props.onSaveState({ ...allReturnMap });
          } else { /*   失败   */
            this.props.getServiceError(dataReturn);
          }

        }
      }
    };

    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 {
        masterData, masterConfig, token, sModelsId
      } = this.props;
      const _props = this.props;
      const _this = this;
      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 = {};
      async function fetchData() {
        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;
                let mixData = commonFunc.getDefaultData(_props[`${key}Config`] || {}, newCopyTo); // 取默认值
                mixData = { ...mixData, ...commonFunc.getAssignFieldValue(config || copyConfig, item, newCopyTo) }; // 取赋值字段
                mixData.handleType = 'add';
                mixData.sId = commonUtils.createSid();
                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);
          }
        }
      }
      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 } = 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 {
        this.props.onDropDownBlur(name, sFieldName, record, tableConfig);
      }
    };

    handleTableSelectRowChange = (name, selectedRowKeys, newData) => { /* 表格行选择 */
      this.props.onTableSelectRowChange(name, selectedRowKeys);
      if (name === 'slave') { /* 选择工序 从表表 */
        const { [`${name}Data`]: tableData } = this.props;
        let slaveSelectOneData = {};
        if(commonUtils.isNotEmptyArr(selectedRowKeys)) {
          let slaveNewData = commonUtils.isNotEmptyArr(newData) ? newData : tableData;
          if(commonUtils.isNotEmptyArr(slaveNewData)) {
            const iIndex = slaveNewData.findIndex( item => selectedRowKeys.includes(item.sId));
            if(iIndex > -1) {
              slaveSelectOneData =  slaveNewData[iIndex];
            }
          }
        }

        this.props.onSaveState({
          ...this.handleGetParam('sProcess', slaveSelectOneData),
          ...this.handleGetParam('sReport', slaveSelectOneData),
          ...this.handleGetParam('sWorkOrder', slaveSelectOneData),
          ...this.handleGetParam('sNorm', slaveSelectOneData),
          ...this.handleGetParam('sTest', slaveSelectOneData),
        });
      }
    }

    handleGetParam = (name, slaveSelectOneData) => {
      let paramsConfig = {};
      let paramData ={};
      let paramListConfig ={};
      let paramListData = [];
      const addState ={};
      paramsConfig.gdsconfigformslave  = [];
      const sType = name +'Param';
      const bTable = 'b'+ name.replace('s','').trim() + 'ParamTable';
      const paramType = commonUtils.isNotEmptyObject(slaveSelectOneData) ? slaveSelectOneData[sType] : '';
      if (commonUtils.isNotEmptyObject(paramType) && !slaveSelectOneData[bTable]) {
        paramData = { ...paramData, ...commonUtils.convertStrToObj(paramType) };
        paramData.sId = commonUtils.createSid();
        const gdsconfigformslaveSid = {} ;
        gdsconfigformslaveSid.sName = 'sId';
        gdsconfigformslaveSid.showName = 'sId';
        gdsconfigformslaveSid.bVisible = false;
        paramsConfig.gdsconfigformslave.push(gdsconfigformslaveSid);
        const bMustFieldName = ['12710101117313076578090', '12710101117054908553170'].includes(this.props.sModelsId) || ['/indexPage/commonCostomTabBill'].includes(this.props.formRoute) ? 'sParamNotFirstEmpty' : 'sParamNotEmpty';
        if (commonUtils.isNotEmptyObject(paramType)) {
          for (const key of Object.keys(paramData)) {
            const num = key.replace('sParam', '').trim();
            const sParamColumnConfig = 'sParamColumnConfig' + num;
            if(key.includes('sParam') && (commonUtils.isEmptyObject(paramData[sParamColumnConfig]) || key.includes('sParamColumnConfig'))
              && !key.includes('sParamDropDown') && !key.includes('sParamDefault')
              && !key.includes(bMustFieldName) && !key.includes('sParamReadOnly') && !key.includes('sParamAssFieldName')
              && !key.includes('sParamFieldName') && !key.includes('sParamNotZero') && !key.includes('sParamDropDownType')
              && !key.includes('sParamSqlCondition') && !key.includes('sParamKeyUpFilter')) {
              const gdsconfigformslave = {} ;
              const num = Number(key.replace('sParam',''));
              gdsconfigformslave.sName = key;
              gdsconfigformslave.sNameParam = commonUtils.isEmpty(paramData['sParamFieldName' + num]) ? key : paramData['sParamFieldName' + num];
              gdsconfigformslave.showName = paramData[key];
              gdsconfigformslave.bVisible = true;
              gdsconfigformslave.sAssignField = commonUtils.isEmpty(paramData['sParamAssignField' + num]) ? '' : paramData['sParamAssignField' + num];
              if (paramData['sParamNotZero' + num]) {
                gdsconfigformslave.bNotZero = true;
              }
              /* 判断是否是sql下拉 */
              const sqlDrownName = 'sParamDropDown'+ num;
              if (!commonUtils.isEmpty(paramData[sqlDrownName])) {
                if (paramData['sParamDropDownType' + num] === 'sql') {
                  gdsconfigformslave.sDropDownType = 'sql';
                  gdsconfigformslave.showDropDown = paramData[sqlDrownName];
                  gdsconfigformslave.sSqlCondition = paramData['sParamSqlCondition' + num];
                  gdsconfigformslave.sKeyUpFilter = paramData['sParamKeyUpFilter' + num]
                } else {
                  gdsconfigformslave.sDropDownType = 'const';
                  const conStr = JSON.stringify(paramData[sqlDrownName]);
                  gdsconfigformslave.showDropDown =  conStr;
                }
              }

              if(key.includes('sParamColumnConfig')) {
                let sParamNum = key.replace('sParamColumnConfig','').trim(); /* 不同参数的表格名称，通过序号区分 */
                const sParamTableName = 'param'+ sParamNum +  'List';
                const sParamTableConfig = 'param'+ sParamNum +  'ListConfig';
                const sParamTableColumn = 'param'+ sParamNum +  'ListColumn';
                const sParamColumnConfigStr =  paramData[key];
                const paramListConfig = commonUtils.isJSON(sParamColumnConfigStr) ? JSON.parse(sParamColumnConfigStr) : {};
                let paramListColumn = [];
                if (commonUtils.isNotEmptyObject(paramListConfig)) {
                  paramListColumn = commonFunc.getHeaderConfig(paramListConfig);
                  addState[sParamTableName] = sParamTableName;
                  addState[sParamTableConfig] = paramListConfig;
                  addState[sParamTableColumn] = sParamTableColumn;
                }
              }

              paramsConfig.gdsconfigformslave.push(gdsconfigformslave);
            }
          }
        }
        addState[`b${name}ParamTable`] = false;
      }else if (commonUtils.isNotEmptyObject(paramType) && slaveSelectOneData[bTable]){
        /* 工序参数以表格形式展示 列 */
        // let paramListData = [];
         paramListConfig = {
          bisMutiSelect: false,
          bMutiSelect: false,
        };
        const gdsconfigformslave = [{
          sId: commonUtils.createSid(),
          sName: 'sId',
          showName: '主键',
          bVisible: false,
          iFitWidth: 200,
        }, {
          sId: commonUtils.createSid(),
          sName: 'bSelfCbx',
          showName: '选择',
          bVisible: true,
          iFitWidth: 37,
        }, {
          sId: commonUtils.createSid(),
          sName: 'sParamKey',
          showName: '参数主键',
          bVisible: false,
          iFitWidth: 200,
        }, {
          sId: commonUtils.createSid(),
          sName: 'sParamName',
          showName: '参数名',
          bVisible: true,
          iFitWidth: 230,
        }, {
          sId: commonUtils.createSid(),
          sName: 'sParamValue',
          showName: '参数值',
          bVisible: true,
        }];
        paramListConfig.gdsconfigformslave = gdsconfigformslave;
        const paramListColumn = commonFunc.getHeaderConfig(paramListConfig);
        if (commonUtils.isNotEmptyObject(paramType)) {
          /* 要把数据以表格的形式显示出来 */
          const sParamJsonObj = JSON.parse(paramType);
          for (const key of Object.keys(sParamJsonObj)) {
            if (key.includes('sParam') && !key.includes('DropDown') && !key.includes('Default')) {
              const obj = {};
              obj.sId = commonUtils.createSid();
              obj.sParamKey = key;
              obj.sParamName = sParamJsonObj[key];
              /* 找到数字 找到下拉数据源 */
              const num = key.replace(/[^\d]/g, '').trim();
              if (Number(num)) {
                const number = Number(num);
                const sParamDropDownKey = `sParamDropDown${number}`;
                obj.sDropDownData = sParamJsonObj[sParamDropDownKey]; /* 下拉 */
                const sParamDefaultKey = `sParamDefault${number}`;
                obj.sParamValue = sParamJsonObj[sParamDefaultKey]; /* 默认值 */
              }
             paramListData.push(obj);
            }
          }
        }
        addState[`${name}ParamListConfig`] = paramListConfig;
        addState[`${name}ParamListColumn`] = paramListColumn;
        addState[`${name}ParamListData`] = paramListData;
        addState[`b${name}ParamTable`] = true; /* 是否已表格显示 */
        console.log('addState', addState);
        paramsConfig = paramListConfig;
      } else {
        paramsConfig.gdsconfigformslave  = [];
        paramData = {};
        addState[`b${name}ParamTable`]= false;
      }
      return {
        [`${name}ParamConfig`]: paramsConfig,
        [`${name}ParamData`]: commonUtils.isNotEmptyArr(paramListData) ? paramListData : [ paramData ],
        ...addState,
      };
    }

    /* 动态参数标题选择框 全选/取消全选 */
    handleCheckParamChange = (name) => {
      const {
        processData,
        processRecord,
        processConfig,
        sParamData,
        sParamColumn,
        enabled,
      } = this.props;
      /* 全选 取消全选功能 */
      if(commonUtils.isNotEmptyArr(sParamData)) {
        /* 标题bSelfCbx加标识 */
        const iIndex = sParamColumn.findIndex(item=>item.dataIndex ==='bSelfCbx');
        if(iIndex > -1) {
          let bSelfCbx = false;
          if(sParamColumn[iIndex].bCheckAll) {
            bSelfCbx = false;
          } else {
            bSelfCbx = true;
          }
          sParamColumn[iIndex] = {...sParamColumn[iIndex],bCheckAll:bSelfCbx}
          sParamData.forEach((item, index) => {
            sParamData[index] = { ...sParamData[index], bSelfCbx: bSelfCbx };
          })
        }
        this.props.onSaveState({
          sParamData,
          sParamColumn
        })
      }
    }

    render() {
      const { masterData, sModelsType, app } = this.props;
      const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app);
      return (
        <ChildComponent
          {...this.props}
          {...this.state}
          onAdd={this.handleAdd}
          onEdit={this.handleEdit}
          onSubmit={this.handleValidateSave}
          onSaveData={this.handleSaveData}
          onSelectRowChange={this.handleSelectRowChange}
          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}
          onFilfileManageOk={this.handleFilfileManageOk}
          onCancelProductProcessInfoChooseModal={this.handleCloseProductProcessInfoChooseModal}
          onDropDownBlur={this.handleTableBlur}
          onTableSelectRowChange={this.handleTableSelectRowChange}
          onCheckParamChange ={this.handleCheckParamChange}
        />
      );
    }
  };
};
