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

const { confirm } = Modal;

const sMaterialsClassfiy = {
  youmo : '油墨',
  dhl : '电化铝',
  zsm : '自调专色墨'
}

export default (ChildComponent) => {
  return class extends Component {
    constructor(props) {
      super(props);
      // 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.state = {
        changleCustomerId: '',
        dPackQtyChange: 0,
      };
      this.form = {}; /*   表单对象   */
      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, sModelsType, formRoute, slaveSelectedRowKeys, slaveData, sModelsId,
      } = nextProps;
      const { slaveSelectedRowKeys: currentSlaveSelectedRowKeys } = this.props;
      const {
        slaveConfig: slaveConfigOld,
        masterConfig: masterConfigOld,
        app,
        employeeConfig: employeeConfigOld,
        slaveInfoList: slaveInfoListOld,
      } = nextProps;
      const { currentPane } =  app;
      const bHistoryView =  currentPane?.bHistoryView;
      if (commonUtils.isEmptyObject(slaveConfigOld) && formData.length > 0 && (sModelsId === '12710101117024321284220' || (sModelsType !== 'cashier/financialTransfer' && sModelsType !== 'cashier/financialAdjustment' && sModelsType !== 'quality/accident' && sModelsType !== 'purchase/purchaseEnquiry' && sModelsType !== 'complaint/complaint' && sModelsType !== 'print/printLabel' && sModelsType !== 'commonBill/onlyMaster' && (formRoute.indexOf('indexOee') === -1 || formRoute === '/indexOee/commonOeeBill')))) {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        const BtnDesignFunctionConfig = commonUtils.isNotEmptyObject(masterConfig) ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === 'BtnBsOperation.BtnDesignFunction') : {};
        const reportDesign = commonFunc.showMessage(app.commonConst, 'reportDesign');/* 报表设计 */
        const sReasonTitle = commonUtils.isNotEmptyObject(commonFunc.showMessage(app.commonConst, 'sReason'))?
          commonFunc.showMessage(app.commonConst, 'sReason') : '报错原因';/* 导入报错原因 */
        if (commonUtils.isEmptyObject(BtnDesignFunctionConfig)) {
          masterConfig.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: 120,
            /* iIncrement: 26154, */
            iOrder: 1,
            iTag: 0,
            iVisCount: 0,
            iconName: 'menu-unfold',
            sActiveKey: '',
            sAssignField: '',
            sBig5: '',
            sBig5DropDown: '',
            sBrandsId: '1111111111',
            sChinese: '报表设计',
            sChineseDropDown: '',
            sColor: '',
            sColorTerms: '',
            sControlName: 'BtnBsOperation.BtnDesignFunction',
            sDateFormat: '',
            sDefault: '',
            sDropDownType: '',
            sEnglish: '',
            sEnglishDropDown: '',
            sFilterSql: '',
            /* sId: '19211681019715580740769130', */
            sKeyUpFilter: '',
            sMaxValue: '',
            sMinValue: '',
            sName: '',
            sNotRepeatColumn: '',
            /* sParentId: '19211681019715428730724240', */
            sRelation: '',
            sSelectRelation: '',
            sSqlCondition: '',
            sSubsidiaryId: '1111111111',
            showDropDown: '',
            showName: reportDesign,
          });
        }
        /* bGrd代表是否是表格 */
        let slaveConfig = formData.filter(item => item.bGrd && item.sTbName && !item.sTbName.startsWith('sysbillcheckresult'))[0];
        let slaveColumn = commonFunc.getHeaderConfig(slaveConfig);

        let addOtherState = {};
        let  slaveInfoList = [];  /* 父表格名配置集合 */
        let  slaveChildInfoList = []; /* 子表格名配置集合 */

        const addStateMap ={}; /* 所有表格配置集合 */
        addStateMap['slaveConfig'] = slaveConfig;
        /* commonBill 可以一带N表  */
        const tableConfigArr =  formData.filter(item => item.bGrd && item.bGrdVisible  && !item.sGrd?.includes("_")
        && item.sTbName !== 'sysbillcheckresult');

        const slaveOtherConfigArr =  [];
        if(commonUtils.isNotEmptyArr(tableConfigArr)) {
          tableConfigArr.forEach((item, iIndex) => {
            if(iIndex > 0) { /* 去除第一个表， 第一个表是从表 */
              const iSlaveTag = iIndex - 1;
              item.slaveNameTag = iSlaveTag;
              slaveOtherConfigArr.push(item);
              const slaveOtherConfigName =  'slave' + iSlaveTag + 'Config';
              let slaveOtherColumnName =  'slave' + iSlaveTag + 'Column';
              const onlyslaveTag= 'onlyslave' + iSlaveTag;
              const slavePageSizeTag =  'slave' + iSlaveTag + 'PageSize';
              const slaveOtherColumn = commonFunc.getHeaderConfig(item);
              addOtherState[slaveOtherConfigName] = item;
              addOtherState[slaveOtherColumnName] = slaveOtherColumn;
              addOtherState[onlyslaveTag] = true;
              const slavePageSize = commonUtils.isNotEmptyObject(item) && commonUtils.isNotEmptyNumber(item.iPageSize) && item.iPageSize !== 0 ?
                item.iPageSize : commonConfig.pageSize;
              addOtherState[slavePageSizeTag] = slavePageSize;
            }

            /* 封装父级表格 */
            let num = 0;
            if(iIndex > 0) {
              num = iIndex -1;
              slaveInfoList.push(`slave${num}`);
              addStateMap[`slave${num}Config`] = item;
            }
            /* 找到父级页签下面的子级页签数据集 */
            const childFormData =  formData.filter(child =>  !child.bGrdVisible && child.sGrd &&  item.sChildTableName && item.sChildTableName.includes(child.sGrd) && child.sGrd !== 'slave' );
            if(commonUtils.isNotEmptyArr(childFormData)) {
              childFormData.forEach((child, tag) => {
                addOtherState[`slave${num}Child${tag}Config`] = child;
                addStateMap[`slave${num}Child${tag}Config`] = child;
                addOtherState[`slave${num}Child${tag}Column`] = commonFunc.getHeaderConfig(child);
                const sChildName = child.showName;
                slaveChildInfoList.push(`slave${num}Child${tag}-${sChildName}`);
              });
            }


          });
          addOtherState.slaveOtherConfigArr = slaveOtherConfigArr;
        }

        let checkConfig = {};
        if (formRoute === '/indexOee/commonOeeBill') { /* OEE单据没有审核表 */
          checkConfig = undefined;
        } else {
          checkConfig = formData.filter(item => item.bGrd && item.sTbName && item.sTbName.startsWith('sysbillcheckresult'))[0];
        }
        let checkColumn = [];
        if (commonUtils.isNotEmptyObject(checkConfig)) {
          checkColumn = commonFunc.getHeaderConfig(checkConfig);
        }

        /* 导入错误配置 */
        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);
        }


        let addState = {};
        addState.sTableType =  commonUtils.isNotEmptyObject(slaveConfig) && commonUtils.isNotEmptyObject(slaveConfig.sTableType) ? slaveConfig.sTableType : 'zero'; /* 获取表格类型 */
        if (formRoute === '/indexPage/commonBill' && sModelsType === 'cost/cosexpenseshare') {
          const { sModelsId } = this.props;
          const { sId, sParentId } = slaveConfig;
          let sAssignStandardConfig = {};
          const filterData = slaveConfig.gdsconfigformslave.filter(item => item.sName === 'sAssignStandard');
          if (commonUtils.isNotEmptyArr(filterData)) {
            sAssignStandardConfig = filterData[0];
          }
          const url = `${commonConfig.server_host}costCenter/getCostCenterConfig?sModelsId=${sModelsId}`;
          const body = {
            sId,
            sParentId,
            sAssignStandardConfig,
          };
          const dataReturn = (await commonServices.postValueService(app.token, body, url)).data;
          if (dataReturn.code === 1) {
            /*   获取数据集   */
            const { rows } = dataReturn.dataset;/* 获取费用分摊单据配置 */
            if (commonUtils.isNotEmptyArr(rows) && rows.length > 0) {
              slaveConfig = rows[0];
              slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
            }
          } else { /*   失败s   */
            this.props.getServiceError(dataReturn);
            return [];
          }
        }
        if (formRoute === '/indexPage/commonBill' || formRoute === '/indexPage/commonCheckBill' || formRoute === '/indexOee/commonOeeBill') {
          if (sId === '') {
            const config = {};
            let addState1 = {};
            if (sModelsType.includes('sales/salesOrder')) {
              const controlConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesordercontrol'.toUpperCase()
                || item.sTbName.toUpperCase() === 'salsalesorderchancecontrol'.toUpperCase() )[0];
              const controlColumn = commonFunc.getHeaderConfig(controlConfig);
              const materialsConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesordermaterials'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchancematerials'.toUpperCase()  )[0];
              const materialsColumn = commonFunc.getHeaderConfig(materialsConfig);
              const processConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesorderprocess'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchanceprocess'.toUpperCase())[0];
              const processColumn = commonFunc.getHeaderConfig(processConfig);
              const colorConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesorderparam'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchanceparam'.toUpperCase())[0];
              let colorColumn;
              if (commonUtils.isNotEmptyObject(colorConfig)) {
                colorColumn = commonFunc.getHeaderConfig(colorConfig);
              }
              const packConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesordercontrolcombine'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchancecontrolcombine')[0];
              let packColumn;
              if (commonUtils.isNotEmptyObject(packConfig)) {
                packColumn = commonFunc.getHeaderConfig(packConfig);
              }
              config.controlConfig = controlConfig;
              config.materialsConfig = materialsConfig;
              config.processConfig = processConfig;
              config.colorConfig = colorConfig;
              config.packConfig = packConfig;
              addState1 = {
                controlConfig,
                controlColumn,
                materialsConfig,
                materialsColumn,
                processConfig,
                processColumn,
                colorConfig,
                colorColumn,
                packConfig,
                packColumn,
              };
            } else if (sModelsType === 'purchase/purchaseOrder') {
              let orderDetailConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.sTbName.toUpperCase() === 'purpurchaseorderDetail'.toUpperCase()))  ?
                formData.filter(item => item.sTbName.toUpperCase() === 'purpurchaseorderDetail'.toUpperCase())[0] : {};
              if(commonUtils.isNotEmptyObject(orderDetailConfig)) {
                const orderDetailColumn = commonFunc.getHeaderConfig(orderDetailConfig);
                config.orderDetailConfig = orderDetailConfig;
                this.handleGetOneMemoData('orderDetail', orderDetailConfig);
                addState1 = {
                  orderDetailConfig,
                  orderDetailColumn,
                };
              }
            }else if (sModelsType === 'purchase/purchasecheck') {
              let orderDetailConfig = {};
              let  orderDetailColumn = [];
              const filterData = formData.filter(item => item.sTbName.toUpperCase() === 'purpurchasecheckingDetail'.toUpperCase());
              if(commonUtils.isNotEmptyArr(filterData)) {
                orderDetailConfig =  filterData[0];
              }
              if(commonUtils.isNotEmptyObject(orderDetailConfig)) {
                orderDetailColumn = commonFunc.getHeaderConfig(orderDetailConfig);
                config.orderDetailConfig = orderDetailConfig;
                this.handleGetOneMemoData('orderDetail', orderDetailConfig);
                addState1 = {
                  orderDetailConfig,
                  orderDetailColumn,
                };
              }
            } else if (sModelsType === 'purchase/purchaseApply') {
              let orderDetailConfig = {};
              let  orderDetailColumn = [];
              const filterData = formData.filter(item => item.sTbName.toUpperCase().indexOf('DETAIL') !== -1);
              if(commonUtils.isNotEmptyArr(filterData)) {
                orderDetailConfig =  filterData[0];
              }
              if(commonUtils.isNotEmptyObject(orderDetailConfig)) {
                orderDetailColumn = commonFunc.getHeaderConfig(orderDetailConfig);
                config.orderDetailConfig = orderDetailConfig;
                this.handleGetOneMemoData('orderDetail', orderDetailConfig);
                addState1 = {
                  orderDetailConfig,
                  orderDetailColumn,
                };
              }
            }
            config.masterConfig = masterConfig;
            config.slaveConfig = slaveConfig;
            addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
            addState = { ...addState, ...addState1 };
            // if (sModelsType.includes('sales/salesOrder') || sModelsType === 'purchase/purchaseOrder') {
            //   this.props.onSaveState(addState1);
            // }
          } else if(bHistoryView){
            this.handleGetDataOld();
          } else {
            this.handleGetData(masterConfig, slaveConfig, checkConfig);
            if (sModelsType.includes('sales/salesOrder')) {
              const controlConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesordercontrol'.toUpperCase()
              || item.sTbName.toUpperCase() === 'salsalesorderchancecontrol'.toUpperCase() )[0];
              const controlColumn = commonFunc.getHeaderConfig(controlConfig);
              const materialsConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesordermaterials'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchancematerials'.toUpperCase()  )[0];
              const materialsColumn = commonFunc.getHeaderConfig(materialsConfig);
              const processConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesorderprocess'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchanceprocess'.toUpperCase())[0];
              const processColumn = commonFunc.getHeaderConfig(processConfig);
              const colorConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesorderparam'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchanceparam'.toUpperCase())[0];
              let colorColumn;
              if (commonUtils.isNotEmptyObject(colorConfig)) {
                colorColumn = commonFunc.getHeaderConfig(colorConfig);
              }
              const packConfig = formData.filter(item => item.sTbName.toUpperCase() === 'salsalesordercontrolcombine'.toUpperCase() ||
                item.sTbName.toUpperCase() === 'salsalesorderchancecontrolcombine')[0];
              let packColumn;
              if (commonUtils.isNotEmptyObject(packConfig)) {
                packColumn = commonFunc.getHeaderConfig(packConfig);
              }
              this.handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig);

              if(commonUtils.isNotEmptyArr(slaveInfoList)) {
                slaveInfoList.forEach( async(name, index) =>  {
                  const tbName = name.replace('Config', '');

                  let {[`${tbName}Config`]: tableConfig } = this.props;
                  if (commonUtils.isEmptyObject(tableConfig)) {
                    tableConfig = addStateMap[tbName +'Config']
                  }
                  if (tableConfig && tableConfig.sTbName && tableConfig.sSqlStr !== "noQuery") {
                     this.handleGetOneMemoData(tbName, tableConfig);
                  }
                });
              }
              this.props.onSaveState({
                controlConfig,
                controlColumn,
                materialsConfig,
                materialsColumn,
                processConfig,
                processColumn,
                colorConfig,
                colorColumn,
                packConfig,
                packColumn,
              });
            } else if (sModelsType === 'manufacture/workOrder3') {
              const controlConfig = formData.filter(item => item.sTbName.toUpperCase() === 'mftproductcontrol'.toUpperCase())[0];
              const controlColumn = commonFunc.getHeaderConfig(controlConfig);
              const materialsConfig = formData.filter(item => item.sTbName.toUpperCase() === 'mftproductmaterials'.toUpperCase())[0];
              const materialsColumn = commonFunc.getHeaderConfig(materialsConfig);
              const processConfig = formData.filter(item => item.sTbName.toUpperCase() === 'mftproductprocess'.toUpperCase())[0];
              const processColumn = commonFunc.getHeaderConfig(processConfig);
              this.handleGetMemoData(controlConfig, materialsConfig, processConfig);
              this.props.onSaveState({
                controlConfig,
                controlColumn,
                materialsConfig,
                materialsColumn,
                processConfig,
                processColumn,
              });
            } else if (sModelsType === 'purchase/purchaseOrder') {
              let orderDetailConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.sTbName.toUpperCase() === 'purpurchaseorderDetail'.toUpperCase()))  ?
                formData.filter(item => item.sTbName.toUpperCase() === 'purpurchaseorderDetail'.toUpperCase())[0] : {};
              if(commonUtils.isNotEmptyObject(orderDetailConfig)) {
                const orderDetailColumn = commonFunc.getHeaderConfig(orderDetailConfig);
                this.handleGetOneMemoData('orderDetail', orderDetailConfig);
                this.props.onSaveState({
                  orderDetailConfig,
                  orderDetailColumn,
                });
              }
            }else if (sModelsType === 'purchase/purchasecheck') {
              let orderDetailConfig = {};
              let  orderDetailColumn = [];
              const filterData = formData.filter(item => item.sTbName.toUpperCase() === 'purpurchasecheckingDetail'.toUpperCase());
              if(commonUtils.isNotEmptyArr(filterData)) {
                orderDetailConfig =  filterData[0];
              }
              if(commonUtils.isNotEmptyObject(orderDetailConfig)) {
                const orderDetailColumn = commonFunc.getHeaderConfig(orderDetailConfig);
                this.handleGetOneMemoData('orderDetail', orderDetailConfig);
                this.props.onSaveState({
                  orderDetailConfig,
                  orderDetailColumn,
                });
              }
            }
          }
        }
        this.props.onSaveState({
          masterConfig, slaveConfig, slaveColumn, checkConfig, checkColumn, importConfig, importColumn, sId, pageLoading: false, ...addState,
          addStateMap, slaveInfoList, slaveChildInfoList,  ...addOtherState
        });
      } else if (commonUtils.isEmptyObject(masterConfigOld) && formData.length === 1 && (sModelsType === 'cashier/financialTransfer' || sModelsType === 'purchase/purchaseEnquiry' || sModelsType === 'cashier/financialAdjustment' || sModelsType === 'print/printLabel' || sModelsType === 'complaint/complaint' || sModelsType === 'commonBill/onlyMaster') && formRoute.indexOf('indexOee') === -1) {
        const config = {};
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        let addState = {};
        if (formRoute === '/indexPage/commonBill' || formRoute === '/indexPage/commonCheckBill') {
          if (sId === '') {
            const config = {};
            config.masterConfig = masterConfig;
            addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
          } else {
            this.handleGetData(masterConfig, undefined, undefined);
          }
        }
        addState.onlyMaster = true;
        if (formRoute === '/indexPage/printlabel') {
          config.masterConfig = masterConfig;
          addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
        }
        this.props.onSaveState({
          masterConfig, sId, pageLoading: false, ...addState,
        });
      } else if (commonUtils.isEmptyObject(slaveConfigOld) && commonUtils.isEmptyObject(masterConfigOld) && formData.length === 2 && (sModelsType === 'quality/accident') && formRoute.indexOf('indexOee') === -1) {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const masterConfig = formData.filter(item => !item.bGrd)[0];
        const slaveConfig = formData.filter(item => item.bGrd && item.sTbName === 'mftqualityaccidentSlave')[0];
        const slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
        let addState = {};
        if (formRoute === '/indexPage/commonBill' || formRoute === '/indexPage/commonCheckBill') {
          if (sId === '') {
            const config = {};
            config.masterConfig = masterConfig;
            config.slaveConfig = slaveConfig;
            addState = await this.handleAdd(config, nextProps.app.currentPane.copyTo, true);
          } else {
            this.handleGetData(masterConfig, slaveConfig, undefined);
          }
        }
        addState.onlyMaster = true;
        addState.onlyMasterAndSlave = true;
        this.props.onSaveState({
          masterConfig, sId, slaveConfig, slaveColumn, pageLoading: false, ...addState,
        });
      } else if (formRoute.indexOf('indexOee') > -1 && commonUtils.isEmptyObject(employeeConfigOld) && commonUtils.isEmptyObject(slaveConfigOld) && formData.length > 0) {
        // const employeeConfig = formData.filter(item => item.bGrd && item.sTbName === 'mftmachineworkemployee')[0];
        // const employeeColumn = commonFunc.getHeaderConfig(employeeConfig);
        // const masterConfig = formData.filter(item => item.bGrd && item.sTbName === 'MftMachineWork')[0];
        // const addState = (await this.props.handleGetDataOne({
        //   name: 'master', configData: masterConfig, condition: {}, isWait: true,
        // }));
        // if (commonUtils.isNotEmptyObject(addState.masterData)) {
        //   addState.masterData.handleType = 'update';
        // }
        // this.props.onSaveState({
        //   employeeConfig, employeeColumn, masterConfig, ...addState,
        // });
        if (formRoute === '/indexOee/labelPrint' && commonUtils.isEmpty(slaveConfigOld)) { /* 入库标签打印 */
          const sId = currentId || nextProps.masterData?.sId || '';
          /* 数据Id */
          const masterConfig = formData[0];
          const slaveConfig = formData[0];
          const slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
          // this.props.handleGetDataOne({ name: 'master', configData: masterConfig, condition: { sSqlCondition: { sParentId: sId } } });
          this.handleGetOneMemoData('slave', slaveConfig);
          this.props.onSaveState({
            masterConfig, sId, slaveConfig, slaveColumn, pageLoading: false,
          });
        }
      } else if (slaveInfoListOld === undefined && formRoute.indexOf('productionReport') !== -1 && commonUtils.isNotEmptyArr(slaveData)) {
        if (commonUtils.isEmptyArr(formData) || commonUtils.isEmptyArr(formData)) {
          return;
        }
        let addState = {}, slaveInfoList = [];
        // const slaveFormData = formData.filter(item => item.bGrd);
        const slaveFormData = formData.filter((item, index) => index >= 3);
        slaveFormData.forEach((item, index) => {
          addState[`slave${index}Config`] = item;
          addState[`slave${index}Column`] = commonFunc.getHeaderConfig(item);
          slaveInfoList.push(item.showName);
        });
        if (slaveInfoList.length) {
          addState = {...addState, ...await this.handleGetDataOne('slave0', addState.slave0Config, null, null, null, null, nextProps, true)};
        }
        this.props.onSaveState({
          slaveInfoList,
          ...addState,
        });
      } else if (formRoute.indexOf('productionReport') !== -1 && commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && JSON.stringify(slaveSelectedRowKeys) !== JSON.stringify(currentSlaveSelectedRowKeys)) {
        const addState = await this.handleGetDataOne('slave0', nextProps.slave0Config, null, null, null, null, nextProps, true);
        this.props.onSaveState({
          ...addState,
        });
      }
    }

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

    isSColorSerialMemo = React.createRef();

    /*
      修改日期：2021-03-18
      修改人：吕杰
      区域：以下onKeyDown函数
      需求变更：为解决bug 2031添加
    */
    /** 键盘事件监听 */
    onKeyDown = (e, record, sName, name) => {
      const { [`${name}Data`]: tableData, [`${name}Column`]: tableColumn, [`${name}Config`]: tableConfig } = this.props;

      let keyCode = e.keyCode;
      let firstName;
      let bEnter = false;
      if (keyCode === 13) {
        // 判断当前单元格是否是最后，不是则跳到下一格，是则跳到下一行第一格
        bEnter = true;
        const uniqueTableId = `table_${this.props.sModelsId}_${tableConfig.sId}`;
        const currentTable = document.getElementById(uniqueTableId);
        const currentTr = currentTable.querySelector(`tr[data-row-key="${record.sId}"]`);
        const allInput = currentTr.querySelectorAll(`input[id*="${record.sId}"]`);
        const iIndex = Array.from(allInput).findIndex(item => item.getAttribute('id') === `${sName}${record.sId}`);
        if (iIndex < allInput.length - 1) {
          keyCode = 39;
        } else {
          const oFirstInput = allInput[0];
          firstName = oFirstInput.getAttribute('id').replace(record.sId, '');
          keyCode = 40;
        }
      }

      // 以下if条件为 为解决bug2031问题入口 需求：收款单里输入的收款金额，上下键操作把加减金额改为选择上下行（通过上下方向键切换行数）
      if ([38, 40].includes(keyCode)) { // 上键、下键
        e.preventDefault();
        if (tableData.length > 1) { // 当从表行数大于一行时才有上下移动的意义
          const index = tableData.findIndex(item => item.sId === record.sId); // 获取当前编辑行的下标
          if (index > -1) {
            if (keyCode === 38 && index > 0) { // 方向键上键 且 当前编辑行下标大于0时，为0时无法向上
              const lastSid = tableData[index - 1].sId; // 获取上一个id
              this.props.onSaveState({ [`${name}SelectedRowKeys`]: [lastSid] }, () => commonUtils.focus(`${sName}${lastSid}`));
            }
            if (keyCode === 40 && index < tableData.length - 1) { // 方向键下键 且 当前编辑行下标小于最大值时，为最大值时无法向下
              const nextSid = tableData[index + 1].sId; // 获取下一个id
              this.props.onSaveState({ [`${name}SelectedRowKeys`]: [nextSid] }, () => commonUtils.focus(`${firstName || sName}${nextSid}`));
            }
          }
        }
      }
      const move = (keyCode, cursortPosition, columnIndex, currentElement) => {
        const inputType = currentElement.getAttribute('type');
        const value = currentElement.value;
        if (keyCode === 37 && columnIndex > 0 && cursortPosition < 1) { // 左移 则 列下标必须大于0, 且光标在最左侧
          const lastId = `${tableColumn[columnIndex - 1].dataIndex}${record.sId}`;
          if (!commonUtils.focus(lastId, e)) move(keyCode, cursortPosition, columnIndex - 1, currentElement); // 递归
        }
        if (keyCode === 39 && columnIndex < tableColumn.length - 1) { // 右移 则 列下标必须小于列数量-1
          if (!record[sName] || cursortPosition >= value.length || inputType === 'search' || bEnter) { // 当前列为空 或 光标位置不小于当前值的长度
            const nextId = `${tableColumn[columnIndex + 1].dataIndex}${record.sId}`;
            if (!commonUtils.focus(nextId, e)) move(keyCode, cursortPosition, columnIndex + 1, currentElement); // 递归
          }
        }
      };
      if ([37, 39].includes(keyCode)) { // 左键、右键
        const currentElement = document.getElementById(`${sName}${record.sId}`); // 当前编辑框对象
        if (currentElement) {
          const cursortPosition = commonUtils.getCursortPosition(currentElement); // 光标位置
          const columnIndex = tableColumn.findIndex(item => item.dataIndex === sName); // 当前列下标
          move(keyCode, cursortPosition, columnIndex, currentElement);
        }
      }
    }

    /* 单击右键全部更新，弹出窗选择后，更新此列所有数据 （只更新非只读字段） */
    onContextMenu = (e, record, showConfig, tbName) => {
      const contextMenuConfig = [];
      const showConfigNew = JSON.parse(JSON.stringify(showConfig)); /* 深拷贝配置 */
      contextMenuConfig.push(showConfigNew);
      this.props.onSaveState({
        contextMenuModalVisible: true, /* 右击全部更新弹窗 */
        contextMenuConfig, /* 右击字段配置 数组形式 */
        contextMenuRecord: record, /* 右击数据 */
        contextMenuName: showConfig.showName, /* 右击字段 */
        contextMenuTbName: tbName, /* 右击字段 */
      });
    }

    /**   获取应收账款   */
    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 [];
          }
        }
      }
    };
    handlePackDataAdd= (item, index, sControlId) => {
      const tableDataRow = {};
      tableDataRow.sId = commonUtils.createSid();
      tableDataRow.handleType = 'add';
      tableDataRow.sSlaveId = item.sId;
      tableDataRow.sParentId = item.sParentId;
      tableDataRow.sControlId = sControlId;
      tableDataRow.iOrder = item.iOrder;
      tableDataRow.sProductId = item.sProductId; /* 产品id */
      tableDataRow.sCustomerId = item.sCustomerId; /* 客户id */
      tableDataRow.sCustomerName = item.sCustomerName; /* 客户名称 */
      tableDataRow.sProductName = item.sProductName; /* 产品名称 */
      tableDataRow.sProductNo = item.sProductNo; /* 产品编号 */
      tableDataRow.dProductQty = commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0); /* 生产数量 */ /* 生产数量 */
      tableDataRow.sProductUnit = item.sProductUnit; /* 单位 */
      tableDataRow.sProductStyle = item.sProductStyle; /* 产品规格 */
      return tableDataRow;
    }
    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;
    };

    handleGetDataOld = async () => {
      const { currentId } = this.props; /* 当前页签数据 */
      this.props.onGetDataOld(currentId);
    }

    /**   获取主表、从表、审核表数据   */
    handleGetData = async (masterConfig, slaveConfig, checkConfig, bEditClick) => {
      const { currentId, masterData = {} } = this.props; /* 当前页签数据 */
      const sId = currentId || masterData.sId || '';
      this.props.handleGetDataOne({ name: 'master', configData: masterConfig, condition: { sId, pageSize: '', pageNum: '' }, bEditClick, slaveConfig });
      // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductId', []);
      // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductNo', []);
      // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductName', []);
      if (!commonUtils.isEmptyObject(slaveConfig)) {
        this.props.handleGetDataSet({
          name: 'slave', configData: slaveConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
        }).then((getData) => {
          if (commonUtils.isNotEmptyObject(getData) && commonUtils.isNotEmptyArr(getData.slaveData)) {
            getData.slaveData.forEach((item, iIndex) => {
              if (commonUtils.isNotEmptyObject(item.sReportParam)) {
                item = { ...item, ...commonUtils.convertStrToObj(item.sReportParam) };
                getData.slaveData[iIndex] = item;
              }
            });
            this.props.onSaveState({ ...getData });
          }
          if (commonUtils.isNotEmptyStr(getData.slaveData)) {
            const selectRowKey = getData.slaveData[0].sId;
            const selectRowKeyArr = [];
            selectRowKeyArr.push(selectRowKey);
            this.handleTableSelectRowChange('slave', selectRowKeyArr);
          }
        });
      }

      if (!commonUtils.isEmptyObject(checkConfig)) {
        this.props.handleGetDataSet({
          name: 'check', configData: checkConfig, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
    };
    /* 获取表数据 */
    handleGetMemoData = async (controlConfig, materialsConfig, processConfig, colorConfig, packConfig) => {
      const { currentId, sModelsType } = this.props; /* 当前页签数据 */
      const sId = currentId || this.props.masterData?.sId || ''; /* 数据Id */
      const addStateControl = await this.props.handleGetDataSet({
        name: 'control', configData: controlConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
      });
      const { controlData, controlSelectedRowKeys } = addStateControl; /* 同步树选中节点与部件选中节点 */
      const addStateMaterials = await this.props.handleGetDataSet({
        name: 'materials', configData: materialsConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
      });
      if(commonUtils.isNotEmptyObject(addStateMaterials)) {
        addStateMaterials.materials0Data = addStateMaterials.materialsData;
      }
      const addStateProcess = await this.props.handleGetDataSet({
        name: 'process', configData: processConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
      });
      if (addStateProcess) {
        if (Array.isArray(addStateProcess.processData)) {
          // eslint-disable-next-line array-callback-return
          addStateProcess.processData.map((itemProcess) => {
            if (commonUtils.isNotEmptyObject(sModelsType.includes('quotation/') ? itemProcess.sProcessParam : sModelsType.includes('manufacture/') ? itemProcess.sWorkOrderParam : itemProcess.sProcessParam)) {
              itemProcess.sProcessParamStr = '';
              // 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(itemProcess[`sParam${i.toString()}`])) {
                  itemProcess.sProcessParamStr += `${itemProcess[`sParam${i.toString()}`]}:${itemProcess[`sParamValue${i.toString()}`]},`;
                }
              }
              if (itemProcess.sProcessParamStr === '') {
                itemProcess.sProcessParamStr = '工艺参数';
              }
            }
          });

          if(commonUtils.isNotEmptyArr(addStateProcess.processData)){
            addStateProcess.processSelectedData = [addStateProcess.processData[0]];
            addStateProcess.processSelectedRowKeys = [addStateProcess.processData[0].sId];
            // addStateProcess.processData = this.sortData(addStateControl.controlData, addStateProcess.processData);
          }

        }
      }
      if (commonUtils.isNotEmptyObject(colorConfig)) {
        this.props.handleGetDataSet({
          name: 'color', configData: colorConfig, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
      if (commonUtils.isNotEmptyObject(packConfig)) {
        this.props.handleGetDataSet({
          name: 'pack', configData: packConfig, condition: { sSqlCondition: { sParentId: sId } },
        });
      }
      // this.handleBtnPreviewPdf(false);
      this.props.onSaveState({
        pageLoading: false, ...addStateControl, ...addStateProcess,  treeSelectedKeys: controlSelectedRowKeys, ...addStateMaterials,
      });
    };
    /* 获取单张表数据 */
    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 } },
        });
      }
    };
    handleGetTableConfig = async (name, sModelsId, oldConfig, configName) => {
      if(commonUtils.isNotEmptyObject(sModelsId)) {
        const newConfig = await this.props.onGetTableConfig(name, sModelsId, oldConfig);
        if(commonUtils.isNotEmptyObject(newConfig)) {
          const newColumn = commonFunc.getHeaderConfig(newConfig);
          this.props.onSaveState({[`${[configName || name]}Config`]: newConfig, [`${[configName || name]}Column`]: newColumn })
        }
      }
    }

    /**  根据key查找树节点并改变属性 */
    handleSearchNodes= (key, data, showNameNew) => {
      if (commonUtils.isNotEmptyObject(showNameNew)) {
        data.forEach((item) => {
          if (item.key === key) {
            item.showName = showNameNew;
          } else if (commonUtils.isNotEmptyArr(item.children)) {
            this.handleSearchNodes(key, item.children, showNameNew);
          }
        });
      }
    };

    /**  点击新增按钮   */
    handleAdd = async (config, copyTo, isWait) => {
      /*   外置处理业务   */
      const {
        sModelsId, sModelsType, app, 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过来的数据 */
      const addNewRecordStata = commonUtils.isNotEmptyObject(app.currentPane) && app.currentPane.newRecordRelation ?  app.currentPane.newRecordRelation : {};
      if(commonUtils.isNotEmptyObject(addNewRecordStata)) {
        masterData = {...masterData, ...addNewRecordStata};
      }

      let slaveData = [];
      const controlData = [];
      const materialsData = [];
      const processData = [];
      const orderDetailData = [];
      const dailyData = [];
      const packData = [];
      const colorData = [];
      const slaveChildData = []; /* 子从表数据 */
      // 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) };
        /* 识别系统模块同级CopyTo增加：sAllId=复制数据的父节点+本节点 */
        if (copyTo.name && copyTo.name.toLowerCase().includes('sameadd')) {
          const sId = masterData.sId; /* 当前 */
          if (copyTo.masterData) {
            const sParentIdOld = copyTo.masterData.sParentId;
            masterData.sParentId = sParentIdOld;
            const sAllOldId = copyTo.masterData.sAllId;
            // const sAllId = `${sParentIdOld},${sId}`;
            if (commonUtils.isNotEmptyObject(sAllOldId)) {
              const sAllId = sAllOldId.replace(copyTo.masterData.sId, sId);
              /* 找到同级父级sAllId */
              if (commonUtils.isEmptyObject(sAllId)) {
                message.warn('sAllId生成错误 请检查');
                return;
              } else {
                masterData.sAllId = sAllId;
              }
            }
          }
        }
        /* 识别系统模块子级CopyTo增加 sAllId=复制数据的完整节点sAllId +新生成sId */
        if (copyTo.name && copyTo.name.toLowerCase().includes('childrenadd')) {
          const sId = masterData.sId; /* 当前 */
          if (copyTo.masterData) {
            const sAllIdOld = copyTo.masterData.sAllId; /* 父级的sAllId */
            const sIdOld = copyTo.masterData.sId; /* 父级的sAllId */
            masterData.sParentId = sIdOld;
            /* 找到同级父级sAllId */
            if (commonUtils.isNotEmptyObject(sAllIdOld)) {
              const sAllId = `${sAllIdOld}-${sId}`;
              masterData.sAllId = sAllId;
              return;
            }
          } else {
            message.warn('缺失sId赋值 请检查');
          }
        }
        if (commonBusiness.getGeyPayDate(masterData) !== undefined) {
          masterData.tGetPayDate = commonBusiness.getGeyPayDate(masterData);
        }
        let sWareHouseNameDropDown;
        const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sWareHouseName');
        // 如果copyto主表数据带了sWareHouseId， 就不另外查询赋值了
        if (iIndex > -1 && commonUtils.isEmptyObject(masterData.sWareHouseId)) {
          const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
          let dataUrl;
          let condition;
          if (models === 'Product') {
            dataUrl = `${commonConfig.server_host}eleProductStock/getProductWareHouse?sModelsId=${sModelsId}`;
            condition = { sProductId: copyTo.slaveData[0].sProductId };
          } else {
            dataUrl = `${commonConfig.server_host}eleMaterialsStock/getMaterialsWareHouse?sModelsId=${sModelsId}`;
            condition = { sMaterialsId: copyTo.slaveData[0].sMaterialsId, sMaterialsStyle: copyTo.slaveData[0].sMaterialsStyle };
          }
          const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
          if (dataReturn.code === 1) {
            const sWareHouseId = dataReturn.dataset.rows.length > 0 ? dataReturn.dataset.rows[0].sWareHouseId : '';
            const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[iIndex]);
            sWareHouseNameDropDown = sqlDropDownData.dropDownData;
            if (commonUtils.isNotEmptyArr(sWareHouseNameDropDown) && !sModelsType.includes('materialsStock/productionmaterialsadjust')) {
              const { sAssignField } = masterConfig.gdsconfigformslave[iIndex];
              const iWareHouseNameIndex = sWareHouseNameDropDown.findIndex(item => item.sId === sWareHouseId);
              if (iWareHouseNameIndex > -1) {
                masterData = { ...masterData, ...commonFunc.getAssignFieldValue(sAssignField, sWareHouseNameDropDown[iWareHouseNameIndex]) };
              }
            }
          }
        }

        const copyToSlaveConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
        const slaveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
        if (slaveAssignField !== '') {
          let iCount = 0;
          let flagCopyTo = false;
          if (commonUtils.isEmptyArr(copyTo.controlData)) {
            flagCopyTo = true;
          }
          if (copyTo.name.includes('salsalesorderByQuo') || copyTo.name.includes('ByOrder')){ /* 未清报价单生产订单，订单生成工单未清 设置flagCopyTo=false代表走翻單 */
            flagCopyTo = false;
          }

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

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

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

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

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

                if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                  returnData.slave4.forEach((slave4Item) => {
                    newCopyTo.slave4 = slave4Item;
                    const newSid = commonUtils.createSid();
                    let slave4Row = commonFunc.getDefaultData(config.slave4Config, newCopyTo, { newSid }); // 取默认值
                    slave4Row = {...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo)}; // 取赋值字段
                    slave4Row.handleType = 'add';
                    slave4Row.sId = newSid;
                    slave4Row.sParentId = masterData.sId;
                    slave4Data.push(slave4Row);
                  });
                }
              } else {
                this.props.getServiceError(dataReturn);
              }
            } else {
              message.error('请正确配置参数！');
            }
          } else if (commonUtils.isNotEmptyArr(copyTo.slaveData)) {
            for (const slaveItem of copyTo.slaveData) {
              const newCopyTo = {};
              newCopyTo.master = copyTo.masterData;
              newCopyTo.slave = slaveItem;
              const newSid = commonUtils.createSid();
              let slaveRow = commonFunc.getDefaultData(config.slaveConfig, newCopyTo, { newSid }); // 取默认值
              slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(slaveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
              if ((!commonUtils.isEmpty(slaveRow.dProductQty) && slaveRow.dProductQty !== slaveRow.dSrcQty) ||
                (!commonUtils.isEmpty(slaveRow.dAuxiliaryQty) && slaveRow.dAuxiliaryQty !== slaveRow.dSrcAuxiliaryQty)) {
                let models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
                let sFieldName = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'dProductQty' : 'dAuxiliaryQty';

                /* 20210901标板问题 未清新增时,材料销售模块需要用换算数量进行业务计算 */
                if (sModelsType.includes('sales/materials') || sModelsType === 'sales/salesCheck') { /* 如果是材料销售模块/销售对账 如果是材料 则用换算数量*单价  算金额 */
                  slaveRow.dAuxiliaryQty = slaveRow.dProductQty;
                  /* 材料逻辑计算 */
                  if (commonUtils.isNotEmptyNumber('dMaterialsQty') && slaveRow.dMaterialsQty !== 0 && commonUtils.isNotEmptyObject(slaveRow.sMaterialsUnit)) {
                    let modelsNew = '';
                    if (models === 'Product') { /* 计算前将Product替换为Materials */
                      modelsNew = 'Materials';

                      const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
                      const { dNetPrice } = app.decimals;
                      const dForeignPrice = slaveRow[`d${models}ForeignPrice`];
                      if (commonUtils.isNotEmptyNumber(dForeignPrice)) {
                        /* 只有外币单价情況下 要算本位币单价 */
                        const dProductPrice = commonUtils.convertFixNum(dForeignPrice * dCurrencyRate, dNetPrice);
                        slaveRow[`d${models}Price`] = dProductPrice;
                      }

                      slaveRow[`dN${modelsNew}Price`] = slaveRow[`d${models}ForeignPrice`];
                      slaveRow[`d${modelsNew}ForeignPrice`] = slaveRow[`d${models}ForeignPrice`];
                      slaveRow[`d${modelsNew}Price`] = slaveRow[`d${models}Price`];
                      slaveRow[`dN${modelsNew}Money`] = slaveRow[`dN${models}Price`];
                      slaveRow[`dN${modelsNew}Money`] = slaveRow[`d${models}ForeignMoney`];
                      slaveRow[`d${modelsNew}ForeignMoney`] = slaveRow[`d${models}ForeignMoney`];
                      slaveRow[`d${modelsNew}Money`] = slaveRow[`d${models}Money`];
                      slaveRow.bSalesMaterials = true;/* 材料销售 销售对账 材料计算 */
                      models = 'Materials';
                      sFieldName = commonUtils.isNotEmptyObject(sFieldName) ? sFieldName.replace('Product', 'Materials') : sFieldName;
                    }
                  }
                }
                commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, slaveRow);
              }
              if (commonUtils.isNotEmptyObject(slaveRow.sReportParam)) {
                slaveRow = { ...slaveRow, ...commonUtils.convertStrToObj(slaveRow.sReportParam) };
              }
              slaveRow.handleType = 'add';
              slaveRow.sId = newSid;
              slaveRow.sParentId = masterData.sId;
              /* 没有sNodeId需要生成一个新的，有的直接带下来 */
              if(commonUtils.isEmptyObject(slaveItem.sNodeId)) {
                slaveRow.sNodeId =  commonUtils.createSid();
              } else {
                slaveRow.sNodeId = slaveItem.sNodeId;
              }
              if (commonUtils.isEmptyObject(slaveRow.sWareHouseId)) {
                slaveRow.sWareHouseId = masterData.sWareHouseId;
                slaveRow.sWareHouseNo = masterData.sWareHouseNo;
                slaveRow.sWareHouseName = masterData.sWareHouseName;
                slaveRow.sLocationId = masterData.sLocationId;
                slaveRow.sLocationNo = masterData.sLocationNo;
                slaveRow.sLocationName = masterData.sLocationName;
                slaveRow.sWareHouseLocationId = masterData.sWareHouseLocationId;
                slaveRow.sWareHouseLocationNo = masterData.sWareHouseLocationNo;
                slaveRow.sWareHouseLocationName = masterData.sWareHouseLocationName;
              }
              slaveRow.sOriginalId = commonUtils.isNotEmptyObject(slaveItem.sSlaveId) ? slaveItem.sSlaveId : slaveItem.sId;/* 翻单前的sId */
              slaveRow.sFatherSlaveId = commonUtils.isNotEmptyObject(slaveItem.sFatherSlaveId) ? slaveItem.sFatherSlaveId : '';/* 父级id */
              /* 若复制到没有序号，则序号从1自增 */
              if (commonUtils.isEmptyNumber(slaveRow.iOrder)) {
                iCount += 1;
                slaveRow.iOrder = iCount;
              }

              /* CopyTo时,若有树形,则sFartherParentId对应生成新的父级的sId */
              // if (commonUtils.isNotEmptyObject(slaveItem.sFatherSlaveId)) {
              //   const copyToSlaveChildConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slaveChild`.toLowerCase());
              //   const slaveChildAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveChildConfig[0].sAssignField : '';
              //   if(slaveChildAssignField) {
              //     slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(slaveChildAssignField, slaveItem, newCopyTo)}; // 取赋值字段
              //   }
              //   /* 代表该行是子级 */
              //   const sfIndex =  slaveData.findIndex(item => item.sOriginalId === slaveItem.sFatherSlaveId);
              //   if (sfIndex > -1) {
              //     slaveRow.sFatherSlaveId = slaveData[sfIndex].sId;
              //   }
              //   console.log('子级生成',slaveRow);
              // }

              if (sModelsType === 'purchase/purchaseInstore' || sModelsType === 'materialsStock/productionmaterialsreject') {
                let iIndex = app.systemData.findIndex(item => item.sName === 'CbxProductDefine');
                if(commonUtils.isNotEmptyObject(masterData.sMinusSrcId) || commonUtils.isNotEmptyObject(masterData.sMinusUsed) ){
                  console.log('红111冲', masterData);
                  iIndex = -1;
                }
                if (iIndex > -1) {
                  const sCbxMaterialsDefine = app.systemData[iIndex].sValue;
                  if (sCbxMaterialsDefine === 'datenum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYYMMDD');
                  } else if (sCbxMaterialsDefine === 'datetimenum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYYMMDDHHmm');
                  } else if (sCbxMaterialsDefine === 'yearnum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYY');
                  } else if (sCbxMaterialsDefine === 'yearmonthnum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYYMM');
                  } else if (sCbxMaterialsDefine === 'worknum') {
                    slaveRow.sDefineNo = slaveRow.sWorkOrderNo;
                  } else if (sCbxMaterialsDefine === 'manuualno') {
                    slaveRow.sDefineNo = slaveRow.sManualNo;
                  } else if (sCbxMaterialsDefine === 'createnownum') { /* 批号根据生产日期+当前日期 */
                    slaveRow.sDefineNo = moment(slaveRow.tProductionDate).format('YYYYMMDDHHmm') + moment(new Date()).format('YYYYMMDDHHmm');
                  }
                }
              } else if (sModelsType === 'productStock/productInStore' || sModelsType === 'outside/outsideinstoreAll') { /* 成品入库、整单发外入库 */
                let iIndex = app.systemData.findIndex(item => item.sName === 'CbxProductDefine');
                if(commonUtils.isNotEmptyObject(masterData.sMinusSrcId) || commonUtils.isNotEmptyObject(masterData.sMinusUsed) ){
                  console.log('红111冲', masterData);
                  iIndex = -1;
                }
                if (iIndex > -1) {
                  const sCbxProductDefine = app.systemData[iIndex].sValue;
                  if (sCbxProductDefine === 'datenum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYYMMDD');
                  } else if (sCbxProductDefine === 'datetimenum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYYMMDDHHmm');
                  } else if (sCbxProductDefine === 'yearnum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYY');
                  } else if (sCbxProductDefine === 'yearmonthnum') {
                    slaveRow.sDefineNo = moment(new Date()).format('YYYYMM');
                  } else if (sCbxProductDefine === 'worknum') {
                    slaveRow.sDefineNo = slaveRow.sWorkOrderNo;
                  } else if (sCbxProductDefine === 'manuualno') {
                    slaveRow.sDefineNo = slaveRow.sManualNo;
                  } else if (sCbxProductDefine === 'worktimenum') { /* 批号根据工单号码+日期时间批号 */
                    slaveRow.sDefineNo = slaveRow.sWorkOrderNo + moment(new Date()).format('YYYYMMDDHH');
                  } else if (sCbxProductDefine === 'yearToDate') { /* 2259 批号根据工单制单日期年月日，年取两位 */
                    slaveRow.sDefineNo = moment(copyTo.masterData.tCreateDate || new Date()).format('YYMMDD');
                  }
                }
              } else if (sModelsType === 'sales/salesCheck') {
                slaveRow.dSrcNoCheckMoney = slaveRow.dProductForeignMoney;
              } else if (sModelsType === 'purchase/purchasecheck') {
                slaveRow.dSrcNoCheckMoney = slaveRow.dMaterialsMoney;
              } else if (sModelsType === 'purchase/purchaseOrder') { // bug 2171 修正 吕杰 2021-03-26
                const dProcurementCycle = commonUtils.isNull(slaveRow.dProcurementCycle, 0);
                const tCreateDate = masterData && commonUtils.isNotEmptyObject(masterData.tCreateDate) ? masterData.tCreateDate : new Date();
                const tDeliverDate = moment(tCreateDate).add(dProcurementCycle, 'days').format(commonUtils.dateFormatA);
                slaveRow.tDeliverDate = tDeliverDate;
                slaveRow.dProcurementCycle = dProcurementCycle;
              }
              slaveData.push(slaveRow);
              console.log('是否翻单', flagCopyTo);
              if (sModelsType.includes('sales/salesOrder') && flagCopyTo && commonUtils.isNotEmptyArr(copyTo.slaveData)) {
                const { token } = this.props;
                const sSlaveId = commonUtils.isNotEmptyStr(slaveItem.sSlaveId) ? slaveItem.sSlaveId : slaveItem.sId;
                const sParentId = commonUtils.isNotEmptyStr(slaveItem.sParentId) ? slaveItem.sParentId : slaveItem.sId;
                let condition = {};
                if (sModelsType === 'sales/salesOrderPack') {
                  condition = { sParentId };
                } else {
                  condition = { sSlaveId };
                }
                /* 通用报价单:101251240115016244276286330 */
                const dataUrl = slaveItem.sFormId === '19211681019715780306452560' || slaveItem.sFormId === '101251240115016076506222050'
                || slaveItem.sFormId === '101251240115016036175782700' || slaveItem.sFormId === '101251240115016002356125200' || slaveItem.sFormId === '101251240115016244276286330' ||
                slaveItem.sFormId === '101251240115016197744514350' ?
                  `${commonConfig.server_host}salesorder/getQuotationPartsInfo?sModelsId=${sModelsId}` :
                  `${commonConfig.server_host}salesorder/getPartsInfo?sModelsId=${sModelsId}`;
                const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
                if (dataReturn.code === 1) {
                  const returnData = dataReturn.dataset.rows[0];
                  slaveItem.sId = sSlaveId;
                  copyTo.controlData = returnData.controlData;
                  copyTo.materialsData = returnData.materialsData;
                  copyTo.processData = returnData.processData;
                  copyTo.packData = returnData.packData;
                  copyTo.colorData = returnData.colorData;
                } else {
                  this.props.getServiceError(dataReturn);
                }
              }

              const copyToControlConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.control`.toLowerCase());
              const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
              if (controlAssignField !== '') {
                if (commonUtils.isNotEmptyObject(copyTo.controlData)) {
                  const treeCopyNodes = new Map();
                  let controlFilterData = [];
                  const srcFormRoute = copyTo.srcFormRoute;
                  if (srcFormRoute === '/indexPage/quotationPack' || (commonUtils.isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('quotationPack')) || slaveItem.sFormId === '101251240115016076506222050') {
                    controlFilterData = copyTo.controlData;
                  } else {
                    controlFilterData = copyTo.controlData.filter(controlItem => controlItem.sSlaveId === slaveItem.sId || controlItem.sSlaveId === slaveItem.sSlaveId);
                  }
                  await controlFilterData.forEach(async (controlItem) => {
                    const newCopyTo = {};
                    newCopyTo.master = copyTo.masterData;
                    newCopyTo.control = controlItem;
                    const newSid = commonUtils.createSid();
                    let controlRow = commonFunc.getDefaultData(config.controlConfig, newCopyTo, { newSid }); // 取默认值
                    controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
                    if ((!commonUtils.isEmpty(controlRow.dProductQty) && controlRow.dProductQty !== controlRow.dSrcQty) ||
                      (!commonUtils.isEmpty(controlRow.dAuxiliaryQty) && controlRow.dAuxiliaryQty !== controlRow.dSrcAuxiliaryQty)) {
                      const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
                      const sFieldName = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'dProductQty' : 'dAuxiliaryQty';
                      commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, controlRow);
                    }
                    controlRow.handleType = 'add';
                    controlRow.sId = newSid;
                    controlRow.sOriginalId = controlItem.sId; /* 复制前的部件表sId */
                    controlRow.sParentId = masterData.sId;
                    controlRow.sSlaveId = slaveRow.sId;
                    if (sModelsType === 'sales/salesOrderPack') {
                      /* 如果有树形结构 则sAllId,sControlParentId赋值 */
                      const sAllOldId = controlItem.sAllId;
                      let arr = [];
                      if (commonUtils.isNotEmptyObject(sAllOldId)) {
                        arr = sAllOldId.split(',');
                      }
                      const newId = controlRow.sId;
                      let sOldParentId = '';
                      let sNewParentAllId = '';
                      if (arr.length < 2) { /* 根节点复制 */
                        controlRow.sAllId = newId;
                        sOldParentId = newId;
                        sNewParentAllId = newId;
                      } else {
                        sOldParentId = arr[arr.length - 2];
                        if (treeCopyNodes.has(sOldParentId)) {
                          sNewParentAllId = treeCopyNodes.get(sOldParentId);
                        } else {
                          const obj = arr[arr.length - 1];
                          sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
                        }
                        const sNewArr = sNewParentAllId.split(',');
                        controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
                        sNewParentAllId = `${sNewParentAllId},${newId}`;
                        controlRow.sAllId = sNewParentAllId;
                      }
                      treeCopyNodes.set(controlItem.sId, sNewParentAllId);
                    }
                    controlData.push(controlRow);

                    const copyToMaterialsConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.materials`.toLowerCase());
                    const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
                    if (materialsAssignField !== '') {
                      if (commonUtils.isNotEmptyObject(copyTo.materialsData)) {
                        let materialsFilterData = [];
                        const srcFormRoute = copyTo.srcFormRoute;
                        if (srcFormRoute === '/indexPage/quotationPack' || (commonUtils.isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('quotationPack')) || slaveItem.sFormId === '101251240115016076506222050') {
                          materialsFilterData = copyTo.materialsData.filter(materialsItem => materialsItem.sControlId === controlItem.sId);
                        } else {
                          materialsFilterData = copyTo.materialsData.filter(materialsItem => (materialsItem.sSlaveId === slaveItem.sId ||
                            materialsItem.sSlaveId === slaveItem.sSlaveId ) && materialsItem.sControlId === controlItem.sId);
                        }
                        await materialsFilterData.forEach(async (materialsItem) => {
                          const newCopyTo = {};
                          newCopyTo.master = copyTo.masterData;
                          newCopyTo.materials = materialsItem;
                          const newSid = commonUtils.createSid();
                          let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo, { newSid }); // 取默认值
                          materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                          if ((!commonUtils.isEmpty(materialsRow.dProductQty) && materialsRow.dProductQty !== materialsRow.dSrcQty) ||
                            (!commonUtils.isEmpty(materialsRow.dAuxiliaryQty) && materialsRow.dAuxiliaryQty !== materialsRow.dSrcAuxiliaryQty)) {
                            const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
                            const sFieldName = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'dProductQty' : 'dAuxiliaryQty';
                            commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, materialsRow);
                          }
                          materialsRow.handleType = 'add';
                          materialsRow.sId = newSid;
                          materialsRow.sParentId = masterData.sId;
                          materialsRow.sControlId = controlRow.sId;
                          materialsRow.sPartsName = controlRow.sPartsName;
                          materialsRow.sSlaveId = slaveRow.sId;
                          // 材料对应工序的ID要变化
                          if (commonUtils.isNotEmptyArr(copyTo.processData)) {
                            const iProcessIndex = processData.findIndex(item => item.sControlId === controlRow.sId && item.sSrcProcessTbId === materialsItem.sProcessTbId);
                            if (iProcessIndex > -1) {
                              materialsRow.sProcessTbId = processData[iProcessIndex].sId;
                            }
                          }
                          if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
                            const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
                            const valueMaterialsStock = {
                              sProName: 'Sp_Inventory_MaterialsInventoryV56',
                              paramsMap: {
                                sMaterialsGuid: materialsRow.sMaterialsId,
                                sMaterialsStyle: materialsRow.sMaterialsStyle,
                                sWarehouseGuid: materialsRow.sWarehouseId,
                                sLocationalGuid: materialsRow.sLocationId,
                                sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
                                sDefine_no: materialsRow.sDefineNo,
                                sDefine_no2: materialsRow.sDefineNo2,
                                iGetQty: 1,
                                iHasZero: 1,
                              },
                            };
                            const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
                            if (returnDataMaterialsStock.code === 1) {
                              materialsRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
                            }
                          }
                          if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
                            const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
                            const valueMaterialsAvailableQty = {
                              sProName: 'Sp_Inventory_MaterialsInventoryV56',
                              paramsMap: {
                                sMaterialsGuid: materialsRow.sMaterialsId,
                                sMaterialsStyle: materialsRow.sMaterialsStyle,
                                sWarehouseGuid: materialsRow.sWarehouseId,
                                sLocationalGuid: materialsRow.sLocationId,
                                sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
                                sDefine_no: materialsRow.sDefineNo,
                                sDefine_no2: materialsRow.sDefineNo2,
                                iGetQty: 2,
                                iHasZero: 1,
                              },
                            };
                            const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
                            if (returnDataMaterialsAvailableQty.code === 1) {
                              materialsRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
                            }
                          }
                          materialsData.push(materialsRow);
                        });
                      }
                    }
                    /* 合版表复制到 */
                    if (sModelsType && sModelsType.includes('sales/salesOrderPack') ) {
                      const copyToPackConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.pack`.toLowerCase());
                      const packAssignField = commonUtils.isNotEmptyArr(copyToPackConfig) ? copyToPackConfig[0].sAssignField : '';
                      if (commonUtils.isNotEmptyObject(packAssignField)) {
                        /* 复制到时增加合版表 */
                        if (commonUtils.isNotEmptyArr(copyTo.packData)) {
                          await copyTo.packData.filter(item => item.sControlId === controlItem.sId).forEach(async (packItem) => {
                            newCopyTo.pack = packItem;
                            let packRow = commonFunc.getDefaultData(config.packConfig, newCopyTo); // 取默认值
                            packRow = { ...packRow, ...commonFunc.getAssignFieldValue(packAssignField, packItem, newCopyTo) }; // 取赋值字段
                            /* sSlaveId赋值 */
                            const packRowAdd = this.handlePackDataAdd(slaveRow, 0, controlRow.sId);
                            packRow = { ...packRow, ...packRowAdd };
                            packRow.sOrderSlaveId = slaveRow.sId;

                            /* 将控制表中的合版备注sId为新的sId */
                            let JsonData = [];
                            const jsonStr = controlRow.sCombinedMemo;
                            if (commonUtils.isNotEmptyObject(jsonStr) && commonUtils.isJSON(jsonStr)) {
                              JsonData = JSON.parse(jsonStr);
                              if (commonUtils.isNotEmptyArr(JsonData)) {
                                let sCombinedMemoNew = '';
                                JsonData.forEach((item, index) => {
                                  if (item.sId === packItem.sId) {
                                    JsonData[index].sId = packRow.sId;
                                  }
                                });
                                sCombinedMemoNew = JSON.stringify(JsonData);
                                controlRow.sCombinedMemo = sCombinedMemoNew;
                                const icontrolIndex = controlData.findIndex(item => item.sId === controlRow.sId);
                                if (icontrolIndex) {
                                  controlData[icontrolIndex] = { ...controlData[icontrolIndex], sCombinedMemo: sCombinedMemoNew };
                                }
                              }
                            }


                            packData.push(packRow);
                          });
                        }
                      }
                    }
                    const copyToProcessConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.process`.toLowerCase());
                    const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
                    if (processAssignField !== '') {
                      if (commonUtils.isNotEmptyObject(copyTo.processData)) {
                        let processFilterData = [];
                        const srcFormRoute = copyTo.srcFormRoute;
                        if (srcFormRoute === '/indexPage/quotationPack' || (commonUtils.isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('quotationPack')) || slaveItem.sFormId === '101251240115016076506222050') {
                          processFilterData = copyTo.processData.filter(processItem => processItem.sControlId === controlItem.sId);
                        } else {
                          processFilterData = copyTo.processData.filter(processItem => (processItem.sSlaveId === slaveItem.sId ||
                            processItem.sSlaveId === slaveItem.sSlaveId) && processItem.sControlId === controlItem.sId);
                        }
                        processFilterData.forEach((processItem) => {
                          const newCopyTo = {};
                          newCopyTo.master = copyTo.masterData;
                          newCopyTo.process = processItem;
                          const newSid = commonUtils.createSid();
                          let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo, { newSid }); // 取默认值
                          processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                          if ((!commonUtils.isEmpty(processRow.dProductQty) && processRow.dProductQty !== processRow.dSrcQty) ||
                            (!commonUtils.isEmpty(processRow.dAuxiliaryQty) && processRow.dAuxiliaryQty !== processRow.dSrcAuxiliaryQty)) {
                            const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'process';
                            const sFieldName = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'dProductQty' : 'dAuxiliaryQty';
                            commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, processRow);
                          }
                          processRow.handleType = 'add';
                          processRow.sId = newSid;
                          processRow.sParentId = masterData.sId;
                          processRow.sControlId = controlRow.sId;
                          processRow.sPartsName = controlRow.sPartsName;
                          processRow.sSlaveId = slaveRow.sId;
                          /* 根据合版表的源sOriginalId找到新sId */
                          let sNewIds = '';
                          let sNewNames = '';
                          const sOldIds = processRow.sCombinePartsName;
                          if (commonUtils.isNotEmptyObject(sOldIds)) {
                            const sOldArr = sOldIds.split(',');
                            for (const sId of sOldArr) {
                              const index = packData.findIndex(item => item.sOriginalId === sId);
                              if (index > -1) {
                                const tableDataRow = packData[index];
                                sNewIds += `${tableDataRow.sId},`;
                                sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName}-${tableDataRow.sCombinePartsName},`;
                              }
                            }
                            sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
                            sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
                          }
                          processRow.sCombinePartsName = sNewIds;
                          processRow.sCombinePartsNameNew = sNewNames;
                          processData.push(processRow);
                        });
                      }
                    }

                  });
                }

                const copyToMaterialsConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.materials`.toLowerCase());
                const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
                if (materialsAssignField !== '') {
                  if (commonUtils.isNotEmptyObject(copyTo.materialsData)) {
                    let materialsFilterData = [];
                    const srcFormRoute = copyTo.srcFormRoute;
                    if (srcFormRoute === '/indexPage/quotationPack' || (commonUtils.isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('quotationPack')) || slaveItem.sFormId === '101251240115016076506222050') {
                      materialsFilterData = copyTo.materialsData.filter(item => item.sType === '2');
                    } else {
                      materialsFilterData = copyTo.materialsData.filter(item => (item.sSlaveId === slaveItem.sId || item.sSlaveId === slaveItem.sSlaveId
                        || item.sCombinePartsName === slaveItem.sId || item.sCombinePartsName === slaveItem.sSlaveId) && item.sType === '2');
                    }
                    await materialsFilterData.forEach(async (materialsItem) => {
                      const newCopyTo = {};
                      newCopyTo.master = copyTo.masterData;
                      newCopyTo.materials = materialsItem;
                      const newSid = commonUtils.createSid();
                      let materialsRow = commonFunc.getDefaultData(config.materialsConfig, newCopyTo, { newSid }); // 取默认值
                      materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                      if ((!commonUtils.isEmpty(materialsRow.dProductQty) && materialsRow.dProductQty !== materialsRow.dSrcQty) ||
                        (!commonUtils.isEmpty(materialsRow.dAuxiliaryQty) && materialsRow.dAuxiliaryQty !== materialsRow.dSrcAuxiliaryQty)) {
                        const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
                        const sFieldName = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'dProductQty' : 'dAuxiliaryQty';
                        commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, materialsRow);
                      }
                      materialsRow.handleType = 'add';
                      materialsRow.sId = newSid;
                      materialsRow.sParentId = masterData.sId;
                      materialsRow.sSlaveId = slaveRow.sId;

                      /* 根据从表源sOriginalId找到新sId */
                      let sNewIds = '';
                      let sNewNames = '';
                      const sOldIds = materialsItem.sCombinePartsName;
                      if (commonUtils.isNotEmptyObject(sOldIds)) {
                        const sOldArr = sOldIds.split(',');
                        for (const sId of sOldArr) {
                          const index = slaveData.findIndex(item => item.sOriginalId === sId);
                          if (index > -1) {
                            const tableDataRow = slaveData[index];
                            sNewIds += `${tableDataRow.sId},`;
                            sNewNames += `${tableDataRow.sProductName},`;
                          }
                        }
                        sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
                        sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
                      }
                      materialsRow.sCombinePartsName = sNewIds;
                      materialsRow.sCombinePartsNameNew = sNewNames;

                      if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
                        const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
                        const valueMaterialsStock = {
                          sProName: 'Sp_Inventory_MaterialsInventoryV56',
                          paramsMap: {
                            sMaterialsGuid: materialsRow.sMaterialsId,
                            sMaterialsStyle: materialsRow.sMaterialsStyle,
                            sWarehouseGuid: materialsRow.sWarehouseId,
                            sLocationalGuid: materialsRow.sLocationId,
                            sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
                            sDefine_no: materialsRow.sDefineNo,
                            sDefine_no2: materialsRow.sDefineNo2,
                            iGetQty: 1,
                            iHasZero: 1,
                          },
                        };
                        const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
                        if (returnDataMaterialsStock.code === 1) {
                          materialsRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
                        }
                      }
                      if (Object.keys(materialsRow).length > 0 && Object.keys(materialsRow).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
                        const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
                        const valueMaterialsAvailableQty = {
                          sProName: 'Sp_Inventory_MaterialsInventoryV56',
                          paramsMap: {
                            sMaterialsGuid: materialsRow.sMaterialsId,
                            sMaterialsStyle: materialsRow.sMaterialsStyle,
                            sWarehouseGuid: materialsRow.sWarehouseId,
                            sLocationalGuid: materialsRow.sLocationId,
                            sWarehouseLocationGuid: materialsRow.sWarehouseLocationId,
                            sDefine_no: materialsRow.sDefineNo,
                            sDefine_no2: materialsRow.sDefineNo2,
                            iGetQty: 2,
                            iHasZero: 1,
                          },
                        };
                        const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
                        if (returnDataMaterialsAvailableQty.code === 1) {
                          materialsRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
                        }
                      }
                      materialsData.push(materialsRow);
                    });
                  }
                }
                const copyToProcessConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.process`.toLowerCase());
                const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
                if (processAssignField !== '') {
                  if (commonUtils.isNotEmptyObject(copyTo.processData)) {
                    let processFilterData = [];
                    const srcFormRoute = copyTo.srcFormRoute;
                    if (srcFormRoute === '/indexPage/quotationPack' || (commonUtils.isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('quotationPack')) || slaveItem.sFormId === '101251240115016076506222050') {
                      processFilterData = copyTo.processData.filter(item => item.sType === '3');
                    } else {
                      processFilterData = copyTo.processData.filter(item => (item.sSlaveId === slaveItem.sId || item.sSlaveId === slaveItem.sSlaveId ||
                        item.sCombinePartsName === slaveItem.sId || item.sCombinePartsName === slaveItem.sSlaveId) && item.sType === '3');
                    }
                    processFilterData.forEach((processItem) => {
                      const newCopyTo = {};
                      newCopyTo.master = copyTo.masterData;
                      newCopyTo.process = processItem;
                      const newSid = commonUtils.createSid();
                      let processRow = commonFunc.getDefaultData(config.processConfig, newCopyTo, { newSid }); // 取默认值
                      processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                      if ((!commonUtils.isEmpty(processRow.dProductQty) && processRow.dProductQty !== processRow.dSrcQty) ||
                        (!commonUtils.isEmpty(processRow.dAuxiliaryQty) && processRow.dAuxiliaryQty !== processRow.dSrcAuxiliaryQty)) {
                        const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'process';
                        const sFieldName = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'dProductQty' : 'dAuxiliaryQty';
                        commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, processRow);
                      }
                      processRow.handleType = 'add';
                      processRow.sId = newSid;
                      processRow.sParentId = masterData.sId;
                      processRow.sSlaveId = slaveRow.sId;
                      /* 根据合版表的源sOriginalId找到新sId */
                      let sNewIds = '';
                      let sNewNames = '';
                      const sOldIds = processItem.sCombinePartsName;
                      if (commonUtils.isNotEmptyObject(sOldIds)) {
                        const sOldArr = sOldIds.split(',');
                        for (const sId of sOldArr) {
                          const index = slaveData.findIndex(item => item.sOriginalId === sId);
                          if (index > -1) {
                            const tableDataRow = slaveData[index];
                            sNewIds += `${tableDataRow.sId},`;
                            sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName},`;
                          }
                        }
                      }
                      sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : '';
                      sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : '';
                      processRow.sCombinePartsName = sNewIds;
                      processRow.sCombinePartsNameNew = sNewNames;
                      processData.push(processRow);
                    });
                  }
                }
                /* 颜色表 */
                const copyToColorConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.param`.toLowerCase());
                const colorAssignField = commonUtils.isNotEmptyArr(copyToColorConfig) ? copyToColorConfig[0].sAssignField : '';
                if (colorAssignField !== '') {
                  if (commonUtils.isNotEmptyArr(copyTo.colorData)) {
                    if (commonUtils.isNotEmptyObject(config.colorConfig)) {
                      copyTo.colorData.forEach((colorItem) => {
                        newCopyTo.color = colorItem;
                        const newSid = commonUtils.createSid();
                        let colorRow = commonFunc.getDefaultData(config.colorConfig, newCopyTo, { newSid }); // 取默认值
                        colorRow = { ...colorRow, ...commonFunc.getAssignFieldValue(colorAssignField, colorItem, newCopyTo) }; // 取赋值字段
                        colorRow.handleType = 'add';
                        colorRow.sId = newSid;
                        colorRow.sParentId = masterData.sId;
                        colorData.push(colorRow);
                      });
                    }
                  }
                }
              }
            }
          }

          /*  若有层级 则拼装新的slaveData层级  */
          // if(commonUtils.isNotEmptyArr(slaveData)) {
          //   const slaveNewData = commonUtils.genTreeDataByArr(slaveData, 'sNodeId', 'sFatherSlaveId');
          //   if(commonUtils.isNotEmptyArr(slaveNewData)) {
          //     slaveData = slaveNewData;
          //   }
          // }
        }
        if (!commonUtils.isEmpty(masterData.sTestStandardId)) {
          const dataUrl = `${commonConfig.server_host}eleteamemployee/getObtainInspectionStandards?sModelsId=${sModelsId}&sParentId=${masterData.sTestStandardId}`;
          const dataReturn = (await commonServices.getService(this.props.app.token, dataUrl)).data;
          const slaveDelData = [];
          if (dataReturn.code === 1) {
            const returnSlaveData = dataReturn.dataset.rows;
            slaveData.forEach((item) => {
              item.handleType = 'del';
              slaveDelData.push(item);
            });
            slaveData = [];
            const newCopyTo = {};
            newCopyTo.master = masterData;
            const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'sTestStandardName');
            const slaveConfig = commonUtils.isEmptyObject(config) ? {} : config.slaveConfig;
            if (!isWait) {
              masterConfig = this.props.slaveConfig;
            }
            const iSqlIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sActValue');
            returnSlaveData.forEach((item, iIndex) => {
              const newSid = commonUtils.createSid();
              let tableDataRow = commonFunc.getDefaultData(config.slaveConfig, {}, { newSid });
              tableDataRow.handleType = 'add';
              tableDataRow.sId = newSid;
              tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
              tableDataRow.key = tableDataRow.sId;
              tableDataRow.iOrder = iIndex;
              if (iConfigIndex > -1) {
                tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(masterConfig.gdsconfigformslave[iConfigIndex].sAssignField, item, newCopyTo) }; // 取赋值字段
                const sTestReference = tableDataRow.sTestReference;
                const sParamObj = {};
                if (commonUtils.isNotEmptyObject(sTestReference)) {
                  if (sTestReference.indexOf('|') >= 0) {
                    sTestReference.split('|').forEach((itemField) => {
                      sParamObj[itemField] = itemField;
                    });
                    tableDataRow.sParamDropDownsActValue = sParamObj;
                    if (iSqlIndex > -1) {
                      slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = 'sql';
                    } else {
                      slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = '';
                    }
                  }
                }
              }
              if(location.pathname && location.pathname.includes('commonOeeBill')) {
                if(commonUtils.isNotEmptyObject(app) && app.currentPane && app.currentPane.copyTo){
                  const masterCopyToData =  app.currentPane.copyTo.masterData;
                  if(commonUtils.isNotEmptyObject(masterCopyToData)) {
                    tableDataRow.sReportPanel = masterCopyToData.sReportPanel;
                    tableDataRow.sReportParam = masterCopyToData.sReportParam;
                    tableDataRow.sProcessParam = masterCopyToData.sProcessParam;
                    tableDataRow.sProcessPanel = masterCopyToData.sProcessPanel;
                    tableDataRow.sSrcSlaveId = masterCopyToData.sSlaveId;
                  }
                }
              }

                slaveData.push(tableDataRow);
            });
          }
        }
      }
      if (!commonUtils.isEmpty(copyTo) && copyTo.bCopyToTree  && commonUtils.isNotEmptyArr(copyTo.copyOtherData)) {
        const copyToDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.detail`.toLowerCase());
        const detailAssignField = commonUtils.isNotEmptyArr(copyToDetailConfig) ? copyToDetailConfig[0].sAssignField : '';
        if (detailAssignField !== '') {
          const copyDetail = copyTo.copyOtherData.filter(item => item.name === 'detail')[0];
          const detail = copyDetail.data;
          if (commonUtils.isNotEmptyArr(detail)) {
            detail.forEach((detailItem) => {
              const newCopyTo = {};
              newCopyTo.master = copyTo.masterData;
              newCopyTo.detail = detailItem;
              const newSid = commonUtils.createSid();
              let tempDetail = commonFunc.getDefaultData(config.orderDetailConfig, newCopyTo, { newSid }); // 取默认值
              tempDetail = { ...tempDetail, ...commonFunc.getAssignFieldValue(detailAssignField, detailItem, newCopyTo) }; // 取赋值字段
              tempDetail.handleType = 'add';
              tempDetail.sId = newSid;
              tempDetail.sParentId = masterData.sId;
              /* commonListTree生成单据时候,要生成sId - sFatherParentId关系, 原关系是sSlaveId - sFatherParent */
              if(commonUtils.isNotEmptyArr(slaveData)) {
                const iIndex = slaveData.findIndex(item => item.sSrcSlaveId === tempDetail.sFatherSlaveId); /* 找到对应的父级行 */
                if(iIndex > -1) {
                  const sFartherId =  slaveData[iIndex].sId;
                  tempDetail.sFatherSlaveId = sFartherId;
                }
              }
              slaveChildData.push(tempDetail);
            });
          }
        }
      } else if (!commonUtils.isEmpty(copyTo) && commonUtils.isNotEmptyArr(copyTo.copyOtherData)) {
        const copyToDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.detail`.toLowerCase());
        const detailAssignField = commonUtils.isNotEmptyArr(copyToDetailConfig) ? copyToDetailConfig[0].sAssignField : '';
        if (detailAssignField !== '') {
          const copyDetail = copyTo.copyOtherData.filter(item => item.name === 'detail')[0];
          const detail = copyDetail.data;
          if(commonUtils.isNotEmptyArr(detail)) {
            detail.forEach((detailItem) => {
              const newCopyTo = {};
              newCopyTo.master = copyTo.masterData;
              newCopyTo.detail = detailItem;
              const newSid = commonUtils.createSid();
              let tempDetail = commonFunc.getDefaultData(config.orderDetailConfig, newCopyTo, { newSid }); // 取默认值
              tempDetail = { ...tempDetail, ...commonFunc.getAssignFieldValue(detailAssignField, detailItem, newCopyTo) }; // 取赋值字段
              const iIndex = slaveData.findIndex(slaveItem => slaveItem.sMaterialsId + slaveItem.sMaterialsStyle === detailItem.sMaterialsGS);
              if (iIndex !== -1) {
                slaveData[iIndex].sWorkOrderNo = commonUtils.isEmptyObject(slaveData[iIndex].sWorkOrderNo) ? detailItem.sWorkOrderNo : `${slaveData[iIndex].sWorkOrderNo},${detailItem.sWorkOrderNo}`;
              }
              tempDetail.handleType = 'add';
              tempDetail.sId = newSid;
              tempDetail.sParentId = masterData.sId;
              orderDetailData.push(tempDetail);
            });
          }
        }
      }
      /* 剔除订单到收款单,费用分摊单据新增空行 */
      if (slaveData.length === 0 && commonUtils.isNotEmptyObject(configNew.slaveConfig) && this.props.sModelsType !== 'cashier/receipt' && this.props.sModelsType !== 'cashier/payment' && this.props.sModelsType !== 'cost/cosexpenseshare'
        && sModelsType !== 'sales/salesInvoice' && sModelsType !== 'purchase/purchaseInvoice' && sModelsType !== 'purchase/outsideInvoice') {
        const allTableData = {};
        allTableData.master = masterData;
        allTableData.slave = slaveData;
        const newSid = commonUtils.createSid();
        const tableDataRowAdd = commonFunc.getDefaultData(configNew.slaveConfig, allTableData, { newSid });
        tableDataRowAdd.handleType = 'add';
        tableDataRowAdd.sId = newSid;
        tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
        tableDataRowAdd.sNodeId = commonUtils.createSid();
        tableDataRowAdd.key = tableDataRowAdd.sId;
        tableDataRowAdd.bDefault = false;
        tableDataRowAdd.iOrder = 1;
        /* 新增时生成采购批号 */
        if (sModelsType === 'purchase/purchaseInstore') {
          let iIndex = app.systemData.findIndex(item => item.sName === 'CbxMaterialsDefine');
          if(commonUtils.isNotEmptyObject(masterData.sMinusSrcId) || commonUtils.isNotEmptyObject(masterData.sMinusUsed) ){
            console.log('红冲', masterData);
            iIndex = -1;
          }
          if (iIndex > -1) {
            const sCbxMaterialsDefine = app.systemData[iIndex].sValue;
            if (sCbxMaterialsDefine === 'datenum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYYMMDD');
            } else if (sCbxMaterialsDefine === 'datetimenum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYYMMDDHHmm');
            } else if (sCbxMaterialsDefine === 'yearnum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYY');
            } else if (sCbxMaterialsDefine === 'yearmonthnum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYYMM');
            } else if (sCbxMaterialsDefine === 'worknum') {
              tableDataRowAdd.sDefineNo = tableDataRowAdd.sWorkOrderNo;
            } else if (sCbxMaterialsDefine === 'manuualno') {
              tableDataRowAdd.sDefineNo = tableDataRowAdd.sManualNo;
            } else if (sCbxMaterialsDefine === 'createnownum') { /* 批号根据生产日期+当前日期 */
              tableDataRowAdd.sDefineNo = moment(tableDataRowAdd.tProductionDate).format('YYYYMMDDHHmm') + moment(new Date()).format('YYYYMMDDHHmm');
            }
          }
        } else if (sModelsType === 'productStock/productInStore' || sModelsType === 'outside/outsideinstoreAll') { /* 成品入库、整单发外入库 */
          let iIndex = app.systemData.findIndex(item => item.sName === 'CbxProductDefine');
          if(commonUtils.isNotEmptyObject(masterData.sMinusSrcId) || commonUtils.isNotEmptyObject(masterData.sMinusUsed) ){
            console.log('红冲', masterData);
            iIndex = -1;
          }
          if (iIndex > -1) {
            const sCbxProductDefine = app.systemData[iIndex].sValue;
            if (sCbxProductDefine === 'datenum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYYMMDD');
            } else if (sCbxProductDefine === 'datetimenum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYYMMDDHHmm');
            } else if (sCbxProductDefine === 'yearnum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYY');
            } else if (sCbxProductDefine === 'yearmonthnum') {
              tableDataRowAdd.sDefineNo = moment(new Date()).format('YYYYMM');
            } else if (sCbxProductDefine === 'worknum') {
              tableDataRowAdd.sDefineNo = tableDataRowAdd.sWorkOrderNo;
            } else if (sCbxProductDefine === 'manuualno') {
              tableDataRowAdd.sDefineNo = tableDataRowAdd.sManualNo;
            } else if (sCbxProductDefine === 'worktimenum') { /* 批号根据工单号码+日期时间批号 */
              tableDataRowAdd.sDefineNo = tableDataRowAdd.sWorkOrderNo + moment(new Date()).format('YYYYMMDDHH');
            } else if (sCbxProductDefine === 'yearToDate') { /* 2259 批号根据工单制单日期年月日，年取两位 */
              tableDataRowAdd.sDefineNo = moment(copyTo.masterData.tCreateDate || new Date()).format('YYMMDD');
            }
          }
        }
        const bEmptyAddLine = configNew.slaveConfig.gdsconfigformslave.find(item => item.sControlName === 'bEmptyAddLine');
        if (!(commonUtils.isNotEmptyObject(bEmptyAddLine) && bEmptyAddLine.bVisible)) {
          slaveData.push(tableDataRowAdd);
        }
      }
      if (sModelsType === 'sales/salesSgoods') { /* 送货单中如果只有一个仓库，默认带这个仓库 */
        // const sWareHouseNameDropDown = commonUtils.getStoreDropDownData(sModelsId, 'master', 'sWareHouseName');
        let sWareHouseNameDropDown;
        const masterIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sWareHouseName');
        if (masterIndex > -1) {
          const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'master', masterConfig.gdsconfigformslave[masterIndex]);
          sWareHouseNameDropDown = sqlDropDownData.dropDownData;
        }
        if (commonUtils.isNotEmptyArr(sWareHouseNameDropDown) && sWareHouseNameDropDown.length === 1) {
          const addStata = {};
          addStata.sWareHouseId = sWareHouseNameDropDown[0].sId;
          addStata.sWareHouseNo = sWareHouseNameDropDown[0].sNo;
          addStata.sWareHouseName = sWareHouseNameDropDown[0].sName;
          addStata.sLocationId = sWareHouseNameDropDown[0].sLocationId;
          addStata.sLocationNo = sWareHouseNameDropDown[0].sLocationNo;
          addStata.sLocationName = sWareHouseNameDropDown[0].sLocationName;
          addStata.sWareHouseLocationId = sWareHouseNameDropDown[0].sWareHouseLocationId;
          addStata.sWareHouseLocationNo = sWareHouseNameDropDown[0].sWareHouseLocationNo;
          addStata.sWareHouseLocationName = sWareHouseNameDropDown[0].sWareHouseLocationName;
          const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sWareHouseName');
          if (iIndex > -1) {
            masterData = { ...masterData, ...addStata }; /* 主表赋默认仓库 */
            if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) { /* 从表赋默认仓库 */
              slaveData.forEach((item, index) => {
                slaveData[index] = { ...item, ...addStata };
              });
            }
          }
        }
      }
      const sTableType = commonUtils.isNotEmptyObject(configNew.slaveConfig) ? configNew.slaveConfig.sTableType : 'zero';
      const state = {
        masterData,
        slaveData,
        slaveTotal: [],
        slaveSelectedRowKeys: [],
        checkData: [],
        checkSelectedRowKeys: [],
        searchUpDownData: {},
        enabled: true,
        controlData,
        materialsData,
        processData,
        dailyData,
        packData,
        colorData,
        orderDetailData,
        slaveChildData,
        processSelectedRowKeys: [],
        controlSelectedRowKeys: [],
        materialsSelectedRowKeys: [],
        calculated: false,
        sTableType,
      };
      state.sUseInfo = '';

      /* 如果是红冲数据有值 则单据全部锁定 */
      if (commonUtils.isNotEmptyObject(masterData) && ((commonUtils.isNotEmptyObject(masterData.sMinusSrcId)) || commonUtils.isNotEmptyObject(masterData.sMinusUsed))) {
        state.sUseInfo = 'bUsed';
      }

      if (isWait) {
        return state;
      } else {
        this.props.onSaveState(state);
        return true;
      }
    };
    /**   点击修改按钮操作   */
    handleEdit = async (cb) => {
      const {
        masterConfig, slaveConfig, checkConfig, currentId, app, masterData, dispatch, billnosetting,
      } = this.props;
      const { userinfo, systemData } = app;
      const { sMakePerson } = masterData; /* 本单据制单人 */
      const { sUserName, sType } = userinfo;/* 登录用户 */
      // 判断是否全局都有配置
      const iIndex = systemData.findIndex(item => item.sName === 'CkxModifyBillNoMakePerson');
      let sValue = 0;
      if (iIndex > -1) {
        sValue = systemData[iIndex].sValue; // 全局配置的值; 1为开启：所有人都可以编辑，0是关闭;
      }
      const bModify = billnosetting.bModify; /* 勾选了可修改及代表普通用户非制单人可以修改单据 */
      if (!+sValue && !bModify && 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, checkConfig,'update');
          if (cb && typeof cb === 'function') {
            this.props.onSaveState({ enabled: false, calculated: false }, () => { cb(); });
          } else {
            this.props.onSaveState({ enabled: true, calculated: false, loading: false });
          }
        }
      };
      this.props.handleSendSocketMessage('update', 'showMsg', currentId, userinfo.sId, null, null);
    };
    /**   表单回带   */
    handleForm = (form) => {
      this.form = form;
    };
    /**   toolbar审核(消审)   */
    handleAudit = async (flag) => {
      /*   待用数据声明   */
      let bResult = true;
      const { masterData, gdsformconst } = this.props;
      if (!commonUtils.isEmpty(masterData)) {
        /*   作废订单不能审核   */
        if (masterData.bInvalid) {
          message.warning(commonFunc.showMessage(app.commonConst, 'sToVoid'));
          this.props.onSaveState({
            loading: false,
          });
          return '';
        }
        /**   数据审核   */
        bResult = await this.dataAudit(flag);
      } else {
        this.props.onSaveState({
          loading: false,
        });
      }
      return  bResult;
    };

    /**   数据审核   */
    dataAudit = async (flag, tmpCheck, isWait) => {
      message.destroy();
      /*   待用数据声明   */
      const {
        sModelsId, masterData, app, masterConfig, slaveConfig, checkConfig, token, sModelsType, controlConfig, materialsConfig, processConfig, colorConfig, packConfig, slaveData, orderDetailConfig,
      } = this.props;
      const FriendlyReminder = commonFunc.showLocalMessage(this.props, 'FriendlyReminder', '温馨提示');
      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.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder')) {
        if (commonUtils.isNotEmptyArr(slaveData)) {
          for (const item of slaveData) {
            if (commonUtils.isNotEmptyStr(item.sProductInfo)) {
              clearFlag = true;
              break;
            }
          }
        } else {
          this.props.onSaveState({
            loading: false,
          });
          return;
        }
      }
      /*   数据审核   */
      const url = `${commonConfig.server_host}business/doExamine?sModelsId=${sModelsId}`;
      const returnData = (await commonServices.postValueService(app.token, value, url)).data;
      if (isWait) {
        return returnData;
      } else {
        /*   接收返回值   */
        const check = commonFunc.showMessage(app.commonConst, 'BtnExamine');/* 审核 */
        const BtnCancelExamine = commonFunc.showMessage(app.commonConst, 'BtnCancelExamine');/* 销审 */
        if (returnData.code === 1) { /*   成功   */
          this.props.onSaveState({
            loading: false,
          });
          if (flag === 1) {
            /*   审核   */
            if (clearFlag && (sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder'))) {
              commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductId', []);
              commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductNo', []);
              commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductName', []);
            }
            let outData;
            if (commonUtils.isNotEmptyObject(returnData.dataset)) {
              outData = returnData.dataset.rows[0].dataSet.outData;
            }
            if (false && 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];
                const iIndex = checkConditions.findIndex(itemCondition => itemCondition.condition === checkCondition);
                if (iIndex <= -1) {
                  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,
                  });
                  return 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);
            }
          }
          await this.handleGetData(masterConfig, slaveConfig, checkConfig);
          if ((sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder')) && !commonUtils.isEmpty(controlConfig)) {
            await this.handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig);
          } else if (commonUtils.isNotEmptyObject(orderDetailConfig)) {
            await this.handleGetOneMemoData('orderDetail', orderDetailConfig);
          }
          if (this.props.app.currentPane.refresh !== undefined) {
            this.props.app.currentPane.refresh();
          }
        } else if(returnData.code === -8){
          Modal.info({
            title: FriendlyReminder,
            content: (
              <div>
                {this.handleGetMsg(returnData.msg)}
              </div>
            ),
            onOk() {},
          });
          this.props.onSaveState({
            loading: false,
          });
          return  false;
        } else { /*   失败   */
          this.props.getServiceError(returnData);
          this.props.onSaveState({
            loading: false,
          });
          return  false;
        }
        return true;
      }
    };

    /**   toolbar保存   */
    handleSaveData = async (params) => {
      const {
        token, sModelsId, currentId, masterData, masterConfig, slaveConfig, checkConfig, billnosetting, app, sModelsType, controlConfig,
        materialsConfig, processConfig, colorConfig, packConfig, orderDetailConfig, dispatch, slaveInfoList,
      } = 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 (returnData.code === -7) {
          // eslint-disable-next-line no-underscore-dangle
          const _this = this;
          confirm({
            title: '单据校验', /* 防呆校验 */
            content: returnData.msg,
            onOk() {
              params.iFlag = 1;
              _this.handleSaveData(params);
            },
            onCancel() {
            },
          });
          this.props.onSaveState({
            loading: false,
          });
          return true;
        }
        if (commonUtils.isNotEmptyObject(copyTo) && commonUtils.isNotEmptyArr(copyTo.slaveData)) {
          const { slaveData } = copyTo;
          const sIdArray = [];
          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，防止浏览器刷新时重新又变成新增。
        if (location.pathname !== '/indexOee/commonOeeBill') {
          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 } });
        }

        if (billnosetting.bAutoCheck) {
          await this.handleAudit(1);
        } else {
          await this.handleGetData(masterConfig, slaveConfig, checkConfig);
          if ((sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder')) && !commonUtils.isEmpty(controlConfig)) {
            await this.handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig);
          } else if (commonUtils.isNotEmptyObject(orderDetailConfig)) {
            await this.handleGetOneMemoData('orderDetail', orderDetailConfig);
          }
          if(commonUtils.isNotEmptyArr(slaveInfoList)) {
            slaveInfoList.forEach( async(name, index) =>  {
              const tbName = name.replace('Config', '');
              const {[`${tbName}Config`]: tableConfig } = this.props;
              if (tableConfig && tableConfig.sTbName && tableConfig.sSqlStr !== "noQuery") {
                await this.handleGetOneMemoData(tbName, tableConfig);
              }
            });
          }
          if (this.props.app.currentPane.refresh !== undefined) {
            this.props.app.currentPane.refresh();
          }
        }
        this.props.onSaveState({
          loading: false, slaveDelData: [], controlDelData: [], materialsDelData: [], processDelData: [], manyqtysDelData: [], colorDelData: [], packDelData: []
        });
        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, app, sModelsType, controlConfig, controlData, controlDelData, materialsConfig,
            materialsData, materialsDelData, processConfig, processData, processDelData, colorConfig, colorData, colorDelData,
            packConfig, packData, packDelData, orderDetailConfig, orderDetailData, orderDetailDelData, slaveInfoList,
          } = this.props;
          let { slaveDelData } = this.props;
          let { masterData } = this.props;
          if (sModelsType !== 'commonBill/onlyMaster' && commonUtils.isEmptyArr(slaveData) && !sModelsType.includes('sales/salesInvoice') && !sModelsType.includes('purchase/purchaseInvoice') && !sModelsType.includes('purchase/outsideInvoice') && sModelsType !== 'cashier/financialTransfer' && sModelsType !== 'cashier/financialAdjustment'
            && !sModelsType.includes('cashier/receipt') && !sModelsType.includes('cashier/payment') && !sModelsType.includes('purchase/purchaseEnquiry')) {
            /* 如果有审核按钮 则校验从表是否为空 */
            let bCheck = false;
            let iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnCheck' || item.sControlName === 'BtnExamine'  || item.sControlName === 'BtnSubmit');
            /* 配置了表格允许为空 则不进行校验 */
            if (slaveConfig && slaveConfig.bNotCanEmpty ) {
              message.error(`${slaveConfig.showName || ''}${commonFunc.showMessage(app.commonConst, 'slaveNotNull')}`); // 从表不能为空！
              this.props.onSaveState({
                loading: false,
              });
              return;
            }
            const isForceCanEmpty =  slaveConfig?.gdsconfigformslave?.find(item => item?.sControlName === 'sForceCanEmpty');
            if ((iIndex > -1) && !isForceCanEmpty) {
              bCheck = true;
            }
            if(bCheck) {
              message.error(`${slaveConfig.showName || ''}${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 && masterData.sWarehouseLocationId === item.sWarehouseLocationId && masterData.sLocationId === item.sLocationId) {
                    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)) {
                if (sModelsType.includes('sales/')) {
                  message.error(item.sProductName + commonFunc.showMessage(app.commonConst, 'NoStyle'));/* 请填写"${item.sProductName}"的规格 */
                } else {
                  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') {
          //   let flag = true;
          //   const iIndex = app.systemData.findIndex(item => item.sName === 'CkxMaterialsStockLimit');
          //   if (iIndex > -1) {
          //     const bCkxMaterialsStockLimit = app.systemData[iIndex].sValue;
          //     if (bCkxMaterialsStockLimit === '1') {
          //       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;
            let flagCheckSave = true;
            if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) {
              for (const item of slaveData) {
                if (item.handleType !== 'del') {
                  if (commonUtils.isNotEmptyNumber(item.dTotalMoney)) {
                    dslaveTotalMoney += item.dTotalMoney;
                  }
                  const dBalanceMoney = commonUtils.isNull(item.dBalanceMoney, 0);
                  const dTotalMoney = commonUtils.isNull(item.dTotalMoney, 0);
                  const dRoundingMoney = commonUtils.isNull(item.dRoundingMoney, 0);
                  const dCount = dRoundingMoney + dTotalMoney;
                  let bWarning = false;
                  if (dBalanceMoney > 0 || dBalanceMoney === 0) {
                    if (dCount > dBalanceMoney) {
                      bWarning = true;
                    }
                  } else if (dCount < dBalanceMoney) {
                    bWarning = true;
                  }
                  if (bWarning) {
                    if (sModelsType.includes('cashier/receipt')) {
                      message.error(commonFunc.showMessage(app.commonConst, 'NoOverBalanceMoneyReceipt'));/* 总金额不能超过未收/付款宽金额 */
                    } else if (sModelsType.includes('cashier/payment')) {
                      message.error(commonFunc.showMessage(app.commonConst, 'NoOverBalanceMoneyPay'));/* 总金额不能超过未收/付款宽金额 */
                    }
                    this.props.onSaveState({
                      loading: false,
                    });
                    return;
                  }
                }
                const flatDel = commonUtils.isNull(item.dTotalMoney, 0) !== 0 || commonUtils.isNull(item.dRoundingMoney, 0) !== 0;
                if (!flatDel) {
                  if (item.handleType === 'add') {
                    item.handleType = undefined; /*  付款单和收款单，去掉收款和付款金额为0的记录 */
                  } else if (item.handleType === 'update') {
                    item.handleType = 'del';
                    item.bRollBack = true; /* 删除失败后 该条数据回滚到修改状态 */
                    if (commonUtils.isEmptyArr(slaveDelData)) {
                      slaveDelData = [];
                    }
                    slaveDelData.push(item);
                  }
                } else {
                  flagCheckSave = false;
                }
              }
            }
            // if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0 && flagCheckSave) {
            //   message.warning('表格内容不能为空![dTotalMoney或dRoundingMoney必须大于0]');
            //   this.props.onSaveState({
            //     loading: false,
            //   });
            //   return;
            // }
            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;
            }
          }
          /*  销售发票、采购发票、发外发票 ，去掉总金额+舍入为0的数据 */
          if (sModelsType === 'sales/salesInvoice' || sModelsType === 'purchase/purchaseInvoice' || sModelsType === 'purchase/outsideInvoice') {
            let flagCheckSave = true;
            if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) {
              for (const item of slaveData) {
                const flatDel = commonUtils.isNull(item.dTotalMoney, 0) !== 0 || commonUtils.isNull(item.dRoundingMoney, 0) !== 0;
                if (!flatDel) {
                  if (item.handleType === 'add') {
                    item.handleType = undefined; /*  付款单和收款单，去掉收款和付款金额为0的记录 */
                  } else if (item.handleType === 'update') {
                    item.handleType = 'del';
                    item.bRollBack = true; /* 删除失败后 该条数据回滚到修改状态 */
                    if (commonUtils.isEmptyArr(slaveDelData)) {
                      slaveDelData = [];
                    }
                    slaveDelData.push(item);
                  }
                } else {
                  flagCheckSave = false;
                }
              }
            }
            /* 收付款保存前，看到从表没数据，预收勾上时，自动调用一下分摊 */
            if (commonUtils.isEmptyArr(slaveData)) {
              masterData = this.handleShare();
            }
            if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0 && flagCheckSave) {
              message.warning('表格内容不能为空![dTotalMoney或dRoundingMoney必须大于0]');
              this.props.onSaveState({
                loading: false,
              });
              return;
            }
          }
          const data = [];
          data.push(commonBusiness.mergeData('master', masterConfig.sTbName, [masterData]));
          if (sModelsType !== 'commonBill/onlyMaster' && sModelsType !== 'cashier/financialTransfer' && sModelsType !== 'cashier/financialAdjustment' && !sModelsType.includes('purchase/purchaseEnquiry')) {
            data.push(commonBusiness.mergeData('slave', slaveConfig.sTbName, slaveData, slaveDelData));
          }
          if (sModelsType.includes('sales/salesOrder') && !commonUtils.isEmpty(controlConfig)) {
            if (commonUtils.isNotEmptyArr(materialsData)) {
              const flag = true;
              // for (const item of materialsData) { /* 销售订单中的物料规格不是必填项，只有工单里才要判断必填 */
              //   if (commonUtils.isNotEmptyObject(item.sMaterialsType) && item.sMaterialsType === 'paper' && commonUtils.isEmptyObject(item.sMaterialsStyle)) {
              //     message.error(item.sMaterialsName + commonFunc.showMessage(app.commonConst, 'NoStyle'));/* 请填写规格 */
              //     flag = false;
              //     break;
              //   }
              // }
              if (!flag) {
                this.props.onSaveState({
                  loading: false,
                });
                return;
              }
            }
            data.push(commonBusiness.mergeData('control', controlConfig.sTbName, controlData, controlDelData));
            data.push(commonBusiness.mergeData('materials', materialsConfig.sTbName, materialsData, materialsDelData));
            data.push(commonBusiness.mergeData('process', processConfig.sTbName, processData, processDelData));
            if (commonUtils.isNotEmptyObject(colorConfig)) {
              data.push(commonBusiness.mergeData('color', colorConfig.sTbName, colorData, colorDelData));
            }
            if (commonUtils.isNotEmptyObject(packConfig)) {
              data.push(commonBusiness.mergeData('pack', packConfig.sTbName, packData, packDelData));
            }
          }
          if (!commonUtils.isEmpty(orderDetailConfig)) {
            data.push(commonBusiness.mergeData('detail', orderDetailConfig.sTbName, orderDetailData, orderDetailDelData));
          }
          if(commonUtils.isNotEmptyArr(slaveInfoList)){
            slaveInfoList.forEach(name => {
              const tbName = name.replace('Config', '');
              const {[`${tbName}Config`]: tableConfig, [`${tbName}Data`]: tableData, [`${tbName}DelData`]: tableDelData } = this.props;
              if (tableConfig && tableConfig.sTbName && tableConfig.sSqlStr !== "noQuery") {
                const tableDataNew = tbName === "master" ? [tableData] : tableData;
                data.push(commonBusiness.mergeData(tbName, tableConfig.sTbName, tableDataNew, tableDelData));
              }
            });
          }
          const sOldData = commonUtils.getOldDataFromProps(this.props);
          console.log('组装后的原始数据', sOldData);
          const sOperationType  = masterData?.handleType === 'add' ?  '1' : '2' ;

          this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId,
            sOldData, sOperationType, sBillNo: masterData.sBillNo  });
        }
      });
    };

    /* 切换作废状态 */
    handleOkChangeInvaild = async (props) => {
      const {
        sModelsId, masterData, masterConfig, handleType,
      } = props;
      const value = {
        sClientType: '1',
        sId: [masterData.sId],
        sTableName: masterConfig.sTbName,
        handleType,
      };
      const url = `${commonConfig.server_host}checkModel/updatebInvalid?sModelsId=${sModelsId}`;
      const { data } = await commonServices.postValueService(props.app.token, value, url);
      if (data.code === 1) {
        message.success(data.msg);
        masterData.bInvalid = handleType === 'toVoid'; /* 作废状态 */
        props.onSaveState({ masterData });
        /*  审核(消审)后刷新跳转路由数据（commonList）的数据 */
        if (props.app.currentPane.refresh !== undefined) {
          props.app.currentPane.refresh();
        }
      } else {
        props.getServiceError(data);
      }
    };

    /* 作废、取消作废的公用函数 */
    handleInvalid = (obj) => {
      const props = { ...this.props, ...this.state, ...obj };
      const onOkInvaild = this.handleOkChangeInvaild;
      confirm({
        title: obj.title,
        onOk() {
          onOkInvaild(props);
        },
        onCancel() {
        },
      });
    };

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

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

    /*   单据页复制到   */
    handleCopyTo = async (name, sActiveId) => {
      /*   待用数据声明   */
      const {
        masterConfig,
        masterData,
        slaveData,
        controlData,
        materialsData,
        processData,
        packData,
        app,
        token,
        sModelsId,
        formRoute,
        slaveSelectedRowKeys,
      } = 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.controlData = controlData;
      copyTo.materialsData = materialsData;
      copyTo.processData = processData;
      copyTo.packData = packData;
      copyTo.srcFormRoute = formRoute;

      // 部分红冲，需要将选中的从表数据带过去
      if (name.includes('Portion')) {
        if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
          message.warning('请选择至少一条从表数据');
          return;
        }
        const filterSlaveData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId));
        copyTo.slaveData = filterSlaveData;
      }
      if(sModelsId === '12710101116943091653680' && name === 'BtnCopyTo.alumite'){
        if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
          message.warning('请选择至少一条从表数据');
          return;
        }
      }


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

      const dataUrl = `${commonConfig.server_host}bill/billCopyToCheck/?sModelsId=${sModelsId}&sActiveId=${sActiveId}&tbSuffix=${tbSuffix}&sName=${formRoute}`;
      const values = { sSlaveId: sId };
      const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
      if (dataReturn.code === 1) {
        // eslint-disable-next-line no-underscore-dangle
        const _this = this; // 解决confirm中this指向问题；
        if (dataReturn.dataset.rows.length > 0) {
          confirm({
            title: commonFunc.showMessage(app.commonConst, 'beUsedToNew'), /* 单据已存在，是否填写新单据 */
            onOk() {
              _this.handleDispatch(copyTo, sActiveId);
            },
            onCancel() {
            },
          });
        } else {
          this.handleDispatch(copyTo, sActiveId);
        }
      }
    };
    handleDispatch = (copyTo, sActiveId) => {
      const { dispatch } = this.props;
      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.')
      && buttonConfig[0].sSqlCondition.includes('sCustomerId')) {
        if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isEmptyStr(slaveData[0].sCustomerId) && commonUtils.isEmptyStr(masterData.sCustomerId)) {
          message.error(commonFunc.showMessage(this.props.app.commonConst, 'pleaseInputCustomer'));/* 请填写客户 */
          return;
        }
      }
      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, masterData, masterConfig, slaveConfig, checkConfig,
       sSrcModelsId,
      } = this.props;
      let { sBillIdsArray = []} = this.props;
      let { currentId } = this.props;
      // 电化铝烫金资料 特殊处理
      if (sModelsId === '12710101116943091653680') {
        this.handleSearchData1(handleType);
        return;
      }
      const tipLast = commonFunc.showLocalMessage(this.props, 'tipLast', '当前已经是最后一条');
      const tipFirst = commonFunc.showLocalMessage(this.props, 'tipFirst', '当前已经是第一条');

      const { currentPane, token } = app;
      const {
        pages, sFilterOrderBy, bFilter, sListFormmasterId, currentIndex,
      } = currentPane;
      console.log('22page2222s2', pages);
      let currentPosition = currentIndexFlag ? currentPageNo : commonUtils.isEmptyObject(pages) ? 1 : (((pages.current - 1) * commonConfig.pageSize) + Number.parseInt(currentIndex, 10)) + 1;
      if (currentIndex === undefined) {
        currentPosition = 1;
      }
      if (!commonUtils.isNum(currentPosition)) { // 如果是列表直接点增加，就跳到第一条去
        currentPosition = 1;
      }
      let  bExist = false;
      /* 如果sBillIdsArray已存在 则不请求 */
      if(commonUtils.isNotEmptyArr(sBillIdsArray) && sBillIdsArray.length > 0) {
        const index =  sBillIdsArray.indexOf(currentId);
        if(index > -1) {
        if ("next".includes(handleType)) {
          currentPosition = index + 1;
          if(currentPosition > sBillIdsArray.length - 1 ){
            message.warn(tipLast);
            return ;
          }
        } else if ("up".includes(handleType)) {
          if(index === 0){
           message.warn(tipFirst);
            return ;
          }
          currentPosition = index - 1;
        } else if ("first".includes(handleType)) {
          currentPosition = 0;
        } else if ("end".includes(handleType)) {
          currentPosition = sBillIdsArray.length - 1;
        }
        currentId = sBillIdsArray[currentPosition];
        currentPosition = currentPosition + 1;
        bExist = true;
        } else {
          bExist = false;
        }
      }
      /* 如果是第一次请求 */
      if(!bExist) {
        const bFromList = commonUtils.isEmptyObject(pages) ? true: false;
        if(bFromList) {
          if(handleType ==='next' || handleType ==='end') {
            message.warn(tipLast);
            return ;
          }else {
            message.warn(tipFirst);
            return ;
          }
        }
        this.props.onSaveState({ loading: true });
        const value = {
          sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages?.total,
          sUpId: masterData?.sId,  sParentModelId :sSrcModelsId,
        };
        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];

          /* 拿到接口返回的sBillids */
          console.log('returnData', returnData);
          const sBillIds = returnData.sBillIds;
          if(commonUtils.isNotEmptyArr(sBillIds)) {
            sBillIdsArray =  sBillIds;
          }
          currentId = returnData.sId;
          currentPosition = returnData.currentPosition;
        } else { /*   失败   */
          this.props.getServiceError(data);
          return false;
        }

      }
      this.props.onSaveState({
        currentIndexFlag: true,
        currentPageNo: currentPosition,
        currentId,
        searchUpDownData: {},
        slaveSelectedRowKeys: [],
        sBillIdsArray,
        loading: true,
      }, () =>  this.handleGetData(masterConfig, slaveConfig, checkConfig));
      return true;
    };

    // 电化铝烫金资料 特殊处理 上一条、下一条、首条、末条
    handleSearchData1 = async (handleType) => {
      const { app, masterData } = this.props;
      const { currentPane = {} } = app;
      const { sListFormmasterId } = currentPane;
      const { sProductNo, sId } = masterData;

      if (commonUtils.isEmpty(sProductNo)) {
        message.error("sProductNo不能为空！");
        return;
      }

      const result = await this.props.handleGetDataSet({
        name: 'temp',
        configData: {
          sId: '12710101117126334972631' // 电化铝烫金资料明细
        },
        condition: {
          bFilter: [{
            bFilterCondition: "=",
            bFilterName: "sProductNo",
            bFilterValue: sProductNo,
          }]
        },
        isWait: true
      }) || {};

      const { tempData = [] } = result;
      const dataSize = tempData.length;
      const iIndex = tempData.findIndex(item => item.sId === sId);

      if (commonUtils.isEmptyArr(tempData)) {
        message.error('数据查询失败！');
        return;
      }

      let newId = '';

      if (handleType === 'first') {
        if (iIndex === 0) {
          message.info('当前已是第一条数据！');
          return;
        }
        newId = tempData[0].sId;
      } else if (handleType === 'end') {
        if (iIndex === dataSize - 1) {
          message.info('当前已是最后一条数据！');
          return;
        }
        newId = tempData[dataSize - 1].sId;
      } else if (handleType === 'next') {
        if (iIndex === dataSize - 1) {
          message.info('当前已是最后一条数据！');
          return;
        }
        newId = tempData[iIndex + 1].sId;
      } else if (handleType === 'up') {
        if (iIndex === 0) {
          message.info('当前已是第一条数据！');
          return;
        }
        newId = tempData[iIndex - 1].sId;
      }

      const { masterConfig, slaveConfig, checkConfig } = this.props;
      this.props.onSaveState({
        currentId: newId,
        searchUpDownData: {},
        slaveSelectedRowKeys: [],
      });
      this.handleGetData(masterConfig, slaveConfig, checkConfig);
    };

    /*   取消操作  */
    handleCancel = (obj) => {
      /*   待用数据声明   */
      const that = this;
      const {
        currentId, masterConfig, slaveConfig, checkConfig, app, masterData,
      } = this.props;
      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() {
          // 解决新建页签sid为空的bug
          if (!currentId) {
            const { panes, currentPane } = that.props.app;
            const currentPaneIndex = panes.findIndex(item => item.key === currentPane.key);
            const newPanes = [];
            if (currentPaneIndex > 0) {
              panes.forEach((item, index) => {
                if (index !== currentPaneIndex) {
                  newPanes.push(item);
                }
              });
              that.props.dispatch({ type: 'app/removePane', payload: { changePanes: newPanes, currentPane: panes[currentPaneIndex - 1] } });/* 关闭当前页签 */
            }
            /* 复制到新增页签取消时 关闭页签 并清除操作记录 */
            if (commonUtils.isNotEmptyObject(copyTo)) {
              const { slaveData, srcFormRoute, copyOtherData } = copyTo;
              if (commonUtils.isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('materialRequirementsPlanning')) { /* 物料需求计划用sWorkOrderMaterialId作为唯一键 */
                const sIdArray = [];
                if (commonUtils.isNotEmptyArr(copyOtherData) && copyOtherData[0].name === 'detail' && commonUtils.isNotEmptyArr(copyOtherData[0].data)) {
                  const slaveDetailData = copyOtherData[0].data;
                  slaveDetailData.forEach((item) => {
                    const redisKey = item.sWorkOrderMaterialId;
                    sIdArray.push(redisKey);
                  });
                } else { /* 变更单、采购申请单 */
                  slaveData.forEach((item) => {
                    const redisKey = item.sWorkOrderMaterialId;
                    sIdArray.push(redisKey);
                  });
                }

                const sId = sIdArray.toString();
                onSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
              } else if (commonUtils.isNotEmptyArr(slaveData)) {
                const sIdArray = [];
                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);
              } else  if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sSrcSlaveId)) {
                const sIdArray = [];
                /* 处理只有单主表解锁问题 */
                sIdArray.push(masterData.sSrcSlaveId);
                const sId = sIdArray.toString();
                onSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
              }
            }

            return;
          }
          //
         const bChanged =  commonBusiness.handleGetChanged(that.props) ;
          if(bChanged) {
            onGetDataOk(masterConfig, slaveConfig, checkConfig);
          }

          onSaveStateOk({ enabled: false });
          if (commonUtils.isNotEmptyObject(copyTo)) {
            const { slaveData } = copyTo;
            const sIdArray = [];
            slaveData.forEach((item) => {
              const redisKey = item.sSlaveId;
              sIdArray.push(redisKey);
            });
            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, checkConfig, orderDetailConfig, app,
      } = 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 sOldData = commonUtils.getOldDataFromProps(this.props);
      console.log('删除的原始数据', sOldData);
      const value = {
        sClientType: '1',
        data: {
          sMasterTable: masterConfig.sTbName,
          sId: [masterData.sId],
        },
        sOldData,
        sSysLogSrcId: masterData.sId,
      };
      const sSlaveTable = [];
      if (commonUtils.isNotEmptyObject(slaveConfig)) {
        sSlaveTable.push({
          tableName: slaveConfig.sTbName,
          relationName: 'sParentId',
        });
      }
      if (commonUtils.isNotEmptyObject(checkConfig)) {
        sSlaveTable.push({
          tableName: checkConfig.sTbName,
          relationName: 'sParentId',
        });
      }
      if (sModelsType === 'purchase/purchaseOrder') {
        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();
        }
        if (sModelsType !== 'commonOeeBill') {
          this.handleDelDataSuccess(props);
        } else {
          message.info('删除成功！');
        }
      } 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, [`${name}Pagination`]: tablePagination,
      } = this.props;
      let { [`${name}Data`]: tableData } = this.props;
      tableData = commonUtils.isEmptyObject(tableData) ? [] : tableData;
      const tableDataRow = this.props.onDataRowAdd(name, true);
      /*   添加行的业务处理拿出去   */
      if (sModelsType.includes('sales/') && name === 'slave') {
        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`]: { ...tablePagination, total: tableData.length, current: 9999 }, [`${name}SelectedRowKeys`]: [tableDataRow.sId] });
      }
    };

    handleTableAddChild = (name, flag, bchild) => {
      /*   从CommonBase获取默认参数   */
      const {
        masterData, masterConfig, sModelsType, app, [`${name}Pagination`]: tablePagination, slaveSelectedRowKeys,[`${name}SelectedRowKeys`]: tableSelectedRowKeys,
      } = this.props;
      let { [`${name}Data`]: tableData } = this.props;
      tableData = commonUtils.isEmptyObject(tableData) ? [] : tableData;
      if(name === 'slave' && bchild === 'childNode') {
        const tableDataRow = this.props.onDataRowAdd(name, true);
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          message.error('请选择数据!');
          return ;
        }
        const iSlaveIndex = tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]);
        if (iSlaveIndex > -1) {
          const slaveRow = tableData[iSlaveIndex];
          if(commonUtils.isNotEmptyObject(slaveRow)) {
            if(commonUtils.isEmptyObject(slaveRow.sNodeId)) {
              message.warn("数据生成错误，请删除父级后重新添加"); // 获取父节点的sAllId
              return;
            }
            tableDataRow.sFatherSlaveId = slaveRow.sNodeId;
            if (commonUtils.isNotEmptyObject(tableDataRow)) {
              tableData.push(tableDataRow);
              this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}Pagination`]: { ...tablePagination, total: tableData.length, current: 9999 }, [`${name}SelectedRowKeys`]: [tableDataRow.sId] });
            }
          }
        }

      }

    };

    /**   复制   */
    handleTableCopy = (name, isWait, isTree) => {
      const {
        [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys, [`${name}Pagination`]: tablePagination, sModelsType,
      } = this.props;
      if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(this.props.app.commonConst, 'pleaseChooseCopyData'));/* 请选择复制数据 */
      } else {
        if (sModelsType === 'sales/salesOrderPack' && isTree) { /* 树形 */
          const {
            [`${name}SelectedRowKeys`]: treeSelectedKeys,
          } = this.props;
          const controlChildData = tableData.filter(item => item.sAllId.indexOf(treeSelectedKeys[0]) > -1 && item.sId !== treeSelectedKeys[0]);
          if (commonUtils.isNotEmptyArr(tableData)) {
            controlChildData.forEach((itemNew) => {
              tableSelectedRowKeys.push(itemNew.sId);
            });
          }
        }
        const treeCopyNodes = new Map();
        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;
            tableDataRow.rowTag = null;
            tableDataRow.sOrderdetailUsed = '';
            tableDataRow.sProductionUsed = '';
            tableDataRow.sWorkOrderUsed = '';
            tableDataRow.dWorkOrderQty = 0;

            delete tableDataRow.sMakePerson;
            delete tableDataRow.tMakeDate;
            delete tableDataRow.sUpdatePerson;
            delete tableDataRow.tUpdate;

            const iOrderArr = [];
            tableData.forEach((item) => {
              const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
              iOrderArr.push(iOrder);
            });
            const iOrderMax = Math.max(...iOrderArr);
            tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 0;

            if (commonUtils.isNotEmptyObject(tableDataRow.sMaterialsMemo)) {
              tableDataRow.sMaterialsMemo = '';
            }
            if (commonUtils.isNotEmptyObject(tableDataRow.sProcessMemo)) {
              tableDataRow.sProcessMemo = '';
            }
            if (name === 'materials') {
              tableDataRow.bPurchaseApplyComplete = 0;
              tableDataRow.dPurchaseApplyAuxiliaryQty = 0;
              tableDataRow.dPurchaseApplyQty = 0;
              tableDataRow.bPurchaseComplete = 0;
              tableDataRow.dPurchaseAuxiliaryQty = 0;
              tableDataRow.dPurchaseQty = 0;
              tableDataRow.dProductionAuxiliaryQty = 0;
              tableDataRow.dProductionQty = 0;
              tableDataRow.bProductionComplete = 0;

              tableDataRow.dProductionApplyAuxiliaryQty = 0;
              tableDataRow.dProductionApplyQty = 0;
              tableDataRow.bProductionApplyComplete = 0;

              tableDataRow.bComComplete = 0;
              tableDataRow.dComAuxiliaryQty = 0;
              tableDataRow.dComQty = 0;
            }
            if (sModelsType === 'sales/salesOrderPack' && isTree) { /* 树形 */
              const sAllOldId = tableData[tableDataIndex].sAllId;
              const arr = sAllOldId.split(',');
              const newId = commonUtils.createSid();
              tableDataRow.sId = newId;
              let sOldParentId = '';
              let sNewParentAllId = '';
              if (arr.length < 2) { /* 根节点复制 */
                tableDataRow.sAllId = newId;
                sOldParentId = newId;
                sNewParentAllId = newId;
              } else {
                sOldParentId = arr[arr.length - 2];
                if (treeCopyNodes.has(sOldParentId)) {
                  sNewParentAllId = treeCopyNodes.get(sOldParentId);
                } else {
                  const obj = arr[arr.length - 1];
                  sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
                }
                const sNewArr = sNewParentAllId.split(',');
                tableDataRow.sControlParentId = sNewArr[sNewArr.length - 1];
                sNewParentAllId = `${sNewParentAllId},${newId}`;
                tableDataRow.sAllId = sNewParentAllId;
              }
              treeCopyNodes.set(sId, sNewParentAllId);
            }
            if (isWait) {
              return tableDataRow;
            } else if (commonUtils.isNotEmptyObject(tableDataRow)) {
              tableData.push(tableDataRow);
              this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}Pagination`]: { ...tablePagination, total: tableData.length, current: 9999 }});
            }
          }
        }
      }
    };

     // 递归函数，用于获取所有子数据
   getChildrenData = (parentId, data, visitedNodes = new Set()) => {
     const children = [];

  // 防止循环引用
  if (visitedNodes.has(parentId)) {
    console.warn(`检测到循环引用，父节点ID: ${parentId}`);
    return children;
  }
  visitedNodes.add(parentId);

  data.forEach(item => {
    if (item.sControlParentId === parentId) {
      children.push(item);
      const subChildren = this.getChildrenData(item.sNodeId, data, visitedNodes);
      children.push(...subChildren);
    }
  });

  visitedNodes.delete(parentId); // 回溯时移除标记
  return children;
   };


    buildAllIds = (data) => {
      const idMap = new Map(); // 存储节点ID到完整路径的映射
      const visitedNodes = new Set(); // 跟踪已访问的节点

      // 获取所有根节点（确保没有循环引用）
      const rootNodes = data.filter(item => {
        // 确保sControlParentId不存在或对应的父节点不存在
        return !item.sControlParentId || !data.some(parent => parent.sNodeId === item.sControlParentId);
      });

      // 递归构建每个节点的sAllId
      const buildPath = (node, path = '') => {
        if (visitedNodes.has(node.sNodeId)) {
          console.warn(`检测到循环引用，节点ID: ${node.sNodeId}`);
          return; // 避免无限递归
        }
        visitedNodes.add(node.sNodeId);

        // 根节点的sAllId直接等于sNodeId
        const currentPath = !node.sControlParentId ? node.sNodeId : (path ? `${path},${node.sNodeId}` : node.sNodeId);
        idMap.set(node.sNodeId, currentPath);
        node.sAllId = currentPath;

        // 处理子节点
        const children = data.filter(item => item.sControlParentId === node.sNodeId);
        children.forEach(child => {
          if (!visitedNodes.has(child.sNodeId)) { // 只处理未访问过的子节点
            buildPath(child, currentPath);
          }
        });

        visitedNodes.delete(node.sNodeId); // 回溯时移除标记
      };

      rootNodes.forEach(root => {
        if (!idMap.has(root.sNodeId)) { // 只处理未处理的根节点
          buildPath(root);
        }
      });

      // 处理孤立节点（没有父节点但sControlParentId不为空）
      data.forEach(item => {
        if (!idMap.has(item.sNodeId)) {
          item.sAllId = item.sNodeId; // 设为自身ID
          console.warn(`发现孤立节点: ${item.sNodeId}, 父节点: ${item.sControlParentId}`);
        }
      });

      return data;
    };

    /* 工单工艺卡复制全部 */
    handleTableWorkCopyAll = (name, isWait) => {
      const {
        [`${name}SelectedRowKeys`]: tableSelectedRowKeys, materials0Data: materialsData, app, packData = [], slaveData,
      } = this.props;
      let {  [`${name}Data`]: tableData, processData } = this.props;
      if (name === 'control') {
        const {
          [`${name}SelectedRowKeys`]: treeSelectedKeys,
        } = this.props;
        const tableSelectedNewRowKeys = [];
        if (commonUtils.isEmptyArr(treeSelectedKeys)) {
          message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseCopyData'));/* 请选择复制数据 */
        } else {
          /* 获取复制节点下的所有子节点 */
          if (commonUtils.isNotEmptyArr(tableData)) {
            // tableData = this.buildAllIds([...tableData]);    // 重新构建sAllId
            const tableRow = tableData.find(item => item.sId === treeSelectedKeys[0]);
            if(commonUtils.isNotEmptyObject(tableRow)) {
              const controlChildData = tableData.filter(item => commonUtils.isNotEmptyObject(item.sControlParentId) &&  item.sControlParentId === tableRow.sNodeId);

              controlChildData.forEach((itemNew) => {
                tableSelectedRowKeys.push(itemNew.sId);
              });
            }

          }
          const treeCopyNodes = new Map(); // 存储原节点ID到新节点ID的映射
          const newNodes = []; // 存储所有新节点

          for (const sId of tableSelectedRowKeys) {
            const tableDataIndex = tableData.findIndex(item => item.sId === sId);
            if (tableDataIndex > -1) {
              const originalNode = tableData[tableDataIndex];
              const tableDataRow = JSON.parse(JSON.stringify(originalNode));

              // 生成新ID
              const newId = commonUtils.createSid();
              tableDataRow.sId = newId;
              tableDataRow.sNodeId = commonUtils.createSid();
              tableDataRow.handleType = 'add';
              tableDataRow.key = tableDataRow.sId;
              tableDataRow.sPartsName = `${tableData[tableDataIndex].sPartsName}new`;
              tableDataRow.sCombinedMemo =  originalNode.sCombinedMemo;


              // 处理层级关系 - 修改这里
             if (originalNode.sControlParentId) {
              // 如果父节点已被复制，则从映射中获取新的父节点ID
              if (treeCopyNodes.has(originalNode.sControlParentId)) {
                tableDataRow.sControlParentId = treeCopyNodes.get(originalNode.sControlParentId);
              } else {
                // 否则保持原来的父节点ID
                tableDataRow.sControlParentId = originalNode.sControlParentId;
              }
             }
              // 存储映射关系和新节点
              treeCopyNodes.set(originalNode.sNodeId, tableDataRow.sNodeId);

              const iOrderArr = [];
              tableData.forEach((item) => {
                const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
                iOrderArr.push(iOrder);
              });
              const iOrderMax = Math.max(...iOrderArr);
              tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 0;
              if (commonUtils.isNotEmptyObject(tableDataRow.sCombinedMemo)) {
                const jsonStr = tableDataRow.sCombinedMemo;
                if (commonUtils.isNotEmptyObject(jsonStr) && commonUtils.isJSON(jsonStr)) {
                  const JsonData = JSON.parse(jsonStr);
                  if(JsonData.length > 1) { /* 超过1条不复制 合版信息 */
                    tableDataRow.sCombinedMemo = '';
                  }

                }

              }
              if (isWait) {
                return tableDataRow;
              } else if (commonUtils.isNotEmptyObject(tableDataRow)) {
                tableData.push(tableDataRow);
                packData.filter(item => item.sControlId === sId).forEach((item) => { /* 复制合版信息 */
                  const packRow = JSON.parse(JSON.stringify(item));
                  packRow.sId = commonUtils.createSid();
                  packRow.handleType = 'add';
                  packRow.sControlId = tableDataRow.sId;
                  packData.push(packRow);
                });
                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;
                  processRow.sSrcProcessTbId = item.sId;
                  processData.push(processRow);
                });
                processData = this.sortData(tableData, processData);
                materialsData.filter(item => item.sControlId === sId && item.sType !== '2').forEach((materialsItem) => {
                  const materialsRow = JSON.parse(JSON.stringify(materialsItem));
                  materialsRow.sId = commonUtils.createSid();
                  materialsRow.handleType = 'add';
                  materialsRow.sControlId = tableDataRow.sId;
                  materialsRow.sPartsName = tableDataRow.sPartsName;
                  materialsRow.bPurchaseApplyComplete = 0;
                  materialsRow.dPurchaseApplyAuxiliaryQty = 0;
                  materialsRow.dPurchaseApplyQty = 0;
                  materialsRow.bPurchaseComplete = 0;
                  materialsRow.dPurchaseAuxiliaryQty = 0;
                  materialsRow.dPurchaseQty = 0;
                  materialsRow.dProductionAuxiliaryQty = 0;
                  materialsRow.dProductionQty = 0;
                  materialsRow.bProductionComplete = 0;

                  materialsRow.dProductionApplyAuxiliaryQty = 0;
                  materialsRow.dProductionApplyQty = 0;
                  materialsRow.bProductionApplyComplete = 0;

                  materialsRow.bComComplete = 0;
                  materialsRow.dComAuxiliaryQty = 0;
                  materialsRow.dComQty = 0;
                  // 材料对应工序的ID要变化
                  if (commonUtils.isNotEmptyArr(processData)) {
                    const iProcessIndex = processData.findIndex(item => item.sControlId === tableDataRow.sId && item.sSrcProcessTbId === materialsItem.sProcessTbId);
                    if (iProcessIndex > -1) {
                      materialsRow.sProcessTbId = processData[iProcessIndex].sId;
                    }
                  }
                  materialsData.push(materialsRow);
                });

                if (commonUtils.isNotEmptyObject(newId)) {
                  tableSelectedNewRowKeys.push(newId);
                }
                // if (commonUtils.isNotEmptyArr(slaveData)) {
                //   slaveData.forEach((item, index) => {
                //     /* 合版信息表增加一条从表数据  */
                //     const packDataRow = this.handlePackDataAdd(item, index, tableDataRow.sId, 'add');
                //     if (commonUtils.isNotEmptyObject(packDataRow)) {
                //       // packDataRow.dCombineQty = 1;
                //       packData.push(packDataRow);
                //     }
                //   });
                // }

              }
            }
          }

        }
        this.props.onSaveState({
          [`${name}Data`]: tableData,
          [`${name}Pagination`]: { total: tableData.length, current: 9999 },
          [`${name}SelectedRowKeys`]: tableSelectedNewRowKeys,
          treeSelectedKeys: tableSelectedNewRowKeys,
          materialsSelectedRowKeys: [],
          materials0Data: materialsData,
          processData,
          packData,
        });

      }
    };

    /**   复制全部   */
    handleTableCopyAll = (name, isWait, isTree) => {
      const {
        slaveData, controlData, slaveSelectedRowKeys, materialsData, [`${name}Pagination`]: tablePagination, sModelsType,
      } = 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;
              const iOrderArr = [];
              slaveData.forEach((item) => {
                const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
                iOrderArr.push(iOrder);
              });
              const iOrderMax = Math.max(...iOrderArr);
              slaveDataRow.iOrder = commonUtils.isNotEmptyArr(slaveData) ? iOrderMax + 1 : 0;
              slaveData.push(slaveDataRow);
              if (sModelsType !== 'sales/salesOrderPack') {
                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);
                    /* 部件表复制其材料表、工序表 */
                    materialsData.filter(item => item.sControlId === itemControl.sId && item.sType !== '2').forEach((item) => {
                      const materialsRow = JSON.parse(JSON.stringify(item));
                      materialsRow.sId = commonUtils.createSid();
                      materialsRow.handleType = 'add';
                      materialsRow.sControlId = tableDataRow.sId;
                      materialsRow.sPartsName = tableDataRow.sPartsName;
                      materialsRow.sSlaveId = tableDataRow.sSlaveId;
                      materialsData.push(materialsRow);
                    });
                    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(materialsData)) { /* 订单从表复制全部 复制成品材料 */
                  materialsData.filter(item => item.sSlaveId === sId && item.sType === '2').forEach((materialsItem) => {
                    const materialsRow = JSON.parse(JSON.stringify(materialsItem));
                    materialsRow.handleType = 'add';
                    materialsRow.sId = commonUtils.createSid();
                    materialsRow.sSlaveId = slaveDataRow.sId;
                    materialsData.push(materialsRow);
                  });
                }

                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`]: { ...tablePagination, total: slaveData.length, current: 9999 },
              controlData,
              materialsData,
              processData,
            });
          }
        }
      } else if (name === 'control') {
        if(location.pathname.includes('TableTreeNew') || location.pathname.includes('ResearchTableTree')){
          this.handleTableWorkCopyAll(name, isWait, isTree);
          return;
        }
        const {
          [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
        } = this.props;
        if (commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          message.warn(commonFunc.showMessage(this.props.app.commonConst, 'pleaseChooseCopyData'));/* 请选择复制数据 */
        } else {
          /* 获取复制节点下的所有子节点 */
          if (sModelsType === 'sales/salesOrderPack' && isTree) { /* 树形 */
            const {
              [`${name}SelectedRowKeys`]: treeSelectedKeys,
            } = this.props;
            const controlChildData = tableData.filter(item => item.sAllId.indexOf(treeSelectedKeys[0]) > -1 && item.sId !== treeSelectedKeys[0]);
            if (commonUtils.isNotEmptyArr(tableData)) {
              controlChildData.forEach((itemNew) => {
                tableSelectedRowKeys.push(itemNew.sId);
              });
            }
          }
          const treeCopyNodes = new Map();
          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;
              const iOrderArr = [];
              tableData.forEach((item) => {
                const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
                iOrderArr.push(iOrder);
              });
              const iOrderMax = Math.max(...iOrderArr);
              tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 0;
              if (sModelsType === 'sales/salesOrderPack' && isTree) { /* 树形 */
                const sAllOldId = tableData[tableDataIndex].sAllId;
                const arr = sAllOldId.split(',');
                const newId = commonUtils.createSid();
                tableDataRow.sId = newId;
                let sOldParentId = '';
                let sNewParentAllId = '';
                if (arr.length < 2) { /* 根节点复制 */
                  tableDataRow.sAllId = newId;
                  sOldParentId = newId;
                  sNewParentAllId = newId;
                } else {
                  sOldParentId = arr[arr.length - 2];
                  if (treeCopyNodes.has(sOldParentId)) {
                    sNewParentAllId = treeCopyNodes.get(sOldParentId);
                  } else {
                    const obj = arr[arr.length - 1];
                    sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
                  }
                  const sNewArr = sNewParentAllId.split(',');
                  tableDataRow.sControlParentId = sNewArr[sNewArr.length - 1];
                  sNewParentAllId = `${sNewParentAllId},${newId}`;
                  tableDataRow.sAllId = sNewParentAllId;
                }
                treeCopyNodes.set(sId, sNewParentAllId);
              }
              if (isWait) {
                return tableDataRow;
              } else if (commonUtils.isNotEmptyObject(tableDataRow)) {
                tableData.push(tableDataRow);
                /* 部件表复制其材料表、工序表 */
                materialsData.filter(item => item.sControlId === sId && item.sType !== '2').forEach((item) => {
                  const materialsRow = JSON.parse(JSON.stringify(item));
                  materialsRow.sId = commonUtils.createSid();
                  materialsRow.handleType = 'add';
                  materialsRow.sControlId = tableDataRow.sId;
                  materialsRow.sPartsName = tableDataRow.sPartsName;
                  materialsData.push(materialsRow);
                });
                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`]: { ...tablePagination, total: tableData.length, current: 9999 },
                  materialsData,
                  processData
                });
              }
            }
          }
        }
      }
    };


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


    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,
      } = this.props;
      let { [`${name}InfoData`]: tableInfoData } = this.props;
      if (name === 'control' && sModelsType.includes('sales/salesOrder')) {
        const { [`${name}Data`]: tableData, materialsData: materialsDataOld, processData: processDataOld } = 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 materialsData = [];
        const processData = [];
        materialsDataOld.forEach((item) => {
          const itemNew = { ...item };
          if (itemNew.sControlId === sId) {
            itemNew.sPartsName = tableDataRow.sPartsName;
          }
          materialsData.push(itemNew);
        });
        processDataOld.forEach((item) => {
          const itemNew = { ...item };
          if (itemNew.sControlId === sId) {
            itemNew.sPartsName = tableDataRow.sPartsName;
          }
          processData.push(itemNew);
        });
        const materialsDataNew = this.sortData(tableData, materialsData);
        const processDataNew = this.sortData(tableData, processData);
        if (sModelsType === 'sales/salesOrderPack') {
          if (sFieldName === 'sPartsName') { /* 部件名称与子部件同步 */
            const { sPartsName } = tableDataRow;
            const { treeSelectedKeys, treeData } = this.props;
            if (commonUtils.isNotEmptyArr(treeSelectedKeys)) {
              this.handleSearchNodes(treeSelectedKeys[0], treeData, sPartsName);
            }
          } else if (sFieldName === 'dMachineQty') { /* 上机数量改变时,子级部件数量同步改变 */
            const { dMachineQty } = tableDataRow;
            /* 查找该节的所有子节点，将上机数量改为部件数量 */
            tableData.forEach((item, index) => {
              if (commonUtils.isNotEmptyObject(item.sAllId) && item.sAllId.indexOf(tableDataRow.sId) > -1 && item.sId !== tableDataRow.sId) {
                const addstate = {};
                addstate.dPartsQty = dMachineQty;
                tableData[index] = { ...tableData[index], ...addstate };
              }
            });
          }
        }
        const iIndex = tableData.findIndex(item => item.sId === sId);
        tableData[iIndex] = tableDataRow;
        this.props.onSaveState({
          [`${name}Data`]: tableData, materialsData: materialsDataNew, processData: processDataNew,
        });
      } else {
        let { masterData } = this.props;
        const sTableType = commonUtils.isNotEmptyObject(slaveConfig) && commonUtils.isNotEmptyObject(slaveConfig.sTableType) ? slaveConfig.sTableType : 'zero';
        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 === 'dProductQty' || sFieldName === 'dGiveQty') && name === 'slave' && (sModelsType.includes('sales/salesOrderPack') || sModelsType.includes('sales/salesOrder'))) {
          if (commonUtils.isNotEmptyObject(changeValue) && Object.keys(changeValue).length === 1 && Object.keys(changeValue)[0] === sFieldName) {
            const dProductQty = commonUtils.isEmptyNumber(tableDataRow.dProductQty) ? 0 : tableDataRow.dProductQty;
            const dGiveQty = commonUtils.isEmptyNumber(tableDataRow.dGiveQty) ? 0 : tableDataRow.dGiveQty;
            const dStockupRate = commonUtils.isEmptyNumber(masterData.dStockupRate) ? 0 : masterData.dStockupRate;
            if (dStockupRate !== 0) { /* 备货率不为0时,按照备货率计算，否则按照手填的算 */
              tableDataRow.dStockupQty = Math.round((dProductQty + dGiveQty) * dStockupRate);
            }
          }
        }
        if ((sFieldName === 'sProductId' || sFieldName === 'sProductName' || sFieldName === 'sProductStyle' || sFieldName === 'sProductUnit' || sFieldName === 'sProductNo'
          || sFieldName === 'sCustomerProductNo' || sFieldName === 'sProductClassifyId' || sFieldName === 'sProductClassifyName') && !commonUtils.isEmpty(tableDataRow.sProductId)) {
          let productIdDropDown = [];
          if (sFieldName === 'sProductStyle') {
            const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductName');
            if (iIndex > -1) {
              if (this.inputSearch) {
                clearTimeout(this.inputSearch);
              }
              this.inputSearch = setTimeout(async () => {
                const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[iIndex], tableDataRow, tableDataRow.sProductName, 1);
                productIdDropDown = sqlDropDownData.dropDownData;
              }, 500);
            }
          } else {
            productIdDropDown = dropDownData;
          }
          const iProductIdIndex = commonUtils.isEmptyArr(productIdDropDown) ? -1 : productIdDropDown.findIndex(item => (item.sId === tableDataRow.sProductId || item.sNId === tableDataRow.sProductId) && item.sProductStyle === tableDataRow.sProductStyle);
          const bProductInfo = location.pathname && location.pathname.includes('workOrderPackTableTree');
          if (iProductIdIndex === -1 && bProductInfo) {
            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 = '';
          }
          tableDataRow.sMaterialsStyle = tableDataRow.sProductStyle;
          if ((sFieldName === 'sProductId' || sFieldName === 'sProductName' || sFieldName === 'sProductNo') && !commonUtils.isEmpty(changeValue.sProductId) && tableDataRow.sProductId !== tableDataRow.sProductName && sModelsType && sModelsType.includes('sales/salesOrder')) {
            const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
            const { sCustomerId } = masterData; /* 增加客户id参数 */
            const value = {
              sProName: 'Sp_Cashier_GetProductPrice',
              paramsMap: {
                sProductGuid: changeValue.sProductId,
                sCustomerId,
              },
            };
            const returnData = (await commonServices.postValueService(app.token, value, url)).data;
            if (returnData.code === 1) {
              tableDataRow.dNProductPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice; /* 产品单价 */
              const dProofingMoney = commonUtils.convertToNum(tableDataRow.dProofingMoney); /* 打样金额 */
              const dPlateMoney = commonUtils.convertToNum(tableDataRow.dPlateMoney); /* 制版金额 */
              const dKnifeMouldMoney = commonUtils.convertToNum(tableDataRow.dKnifeMouldMoney); /* 刀模金额 */
              const dProductQty = commonUtils.convertToNum(tableDataRow.dProductQty); /* 数量 */
              const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
              const { dNetPrice } = app.decimals;
              if (dProductQty === 0 || (dProofingMoney === 0 && dPlateMoney === 0 && dKnifeMouldMoney === 0)) {
                const dProductForeignPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice;
                tableDataRow.dProductForeignPrice = dProductForeignPrice;
                tableDataRow.dProductPrice = commonUtils.convertFixNum(dProductForeignPrice * dCurrencyRate, dNetPrice);
              }
            }

            const models = name === 'materials' ? 'Materials' :
              sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
            if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/')) {
              tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, 'dProductQty', app, token, models);
            }
            tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dProductQty', masterData, tableDataRow);
            // else {
            //   this.props.getServiceError(returnData);
            // }
          }
        } else if (sModelsType.includes('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 materialsReturnData = this.otherTableDel('materials', tableSelectedRowKeys);
            const processReturnData = this.otherTableDel('process', tableSelectedRowKeys);
            const controlReturnData = this.props.onDataRowDel('control', true, tableSelectedRowKeys);
            this.props.onSaveState({
              ...materialsReturnData,
              ...processReturnData,
              ...controlReturnData,
            });
          }
        } else if ((sModelsType.includes('cashier/') || sModelsType.includes('sales/salesInvoice') || sModelsType.includes('purchase/purchaseInvoice') || sModelsType.includes('purchase/outsideInvoice')) && (sFieldName === 'dTotalMoney' || sFieldName === 'dRoundingMoney')) { /* 付款单、收款单，从表付款/收款金额改变，会自动汇总到主表付款金额中 */
          const addStata = {};
          let { handleType } = masterData;
          handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
          addStata.handleType = handleType;
          const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
          const { dNetMoney } = app.decimals;
          if (sFieldName === 'dTotalMoney') {
            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);
              tableDataRow.dTotalForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dMoney / dCurrencyRate : 0, dNetMoney);
            }
            // if (commonUtils.isNotEmptyNumber(tableDataRow.dBalanceMoney) && (tableDataRow.dTotalMoney > tableDataRow.dBalanceMoney)) { // 发外发票，采购发票，销售发票 付款单、收款单总金额不能大于余额
            //   const dTotalMoneyName = slaveConfig.gdsconfigformslave.filter(item => item.sName === sFieldName)[0].showName;
            //   const dBalanceMoneyName = slaveConfig.gdsconfigformslave.filter(item => item.sName === 'dBalanceMoney')[0].showName;
            //   message.error(`${dTotalMoneyName}不能大于${dBalanceMoneyName}!`);
            //   tableDataRow = { ...tableDataRow, dTotalMoney: tableDataRow.dBalanceMoney };
            //   // tableDataRow.dTotalMoney = commonUtils.convertStrToNumber(masterData.dTotalMoney);
            //   addStata.dTotalMoney = commonUtils.convertStrToNumber(masterData.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);
              }
            });
            /* 计算外币金额 */
            if (commonUtils.isNotEmptyNumber(addStata.dTotalMoney)) {
              addStata.dProductForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? addStata.dTotalMoney / dCurrencyRate : 0, dNetMoney);
            }
          } else if (sFieldName === 'dRoundingMoney') {
            addStata.dRoundingMoney = 0;
            if (iIndex > -1) { /* 选中行 */
              let dMoney = commonUtils.isNotEmptyNumber(tableDataRow.dRoundingMoney) ? tableDataRow.dRoundingMoney : 0;
              dMoney = commonUtils.convertStrToNumber(dMoney);
              addStata.dRoundingMoney = dMoney + commonUtils.convertStrToNumber(addStata.dRoundingMoney);
            }
            tableData.forEach((item, index) => { /* 非选中行 */
              if (index !== iIndex) {
                const dMoney = commonUtils.isNotEmptyNumber(item.dRoundingMoney) ? item.dRoundingMoney : 0;
                addStata.dRoundingMoney = commonUtils.convertFixNum(dMoney, 6) + commonUtils.convertFixNum(addStata.dRoundingMoney, 6);
              }
            });
          }
          masterData = { ...masterData, ...addStata };
          this.props.onSaveState({ masterData });
        } else if (sModelsType === 'purchase/purchaseOrder' && sFieldName === 'dProcurementCycle') {
          /* 交货周期改变时,交货时间等于制单时间 +交货周期 */
          const dProcurementCycle = commonUtils.isNull(tableDataRow.dProcurementCycle, 0);
          const tCreateDate = commonUtils.isNotEmptyObject(tableDataRow.tCreateDate) ? tableDataRow.tCreateDate : new Date();
          const tDeliverDate = moment(tCreateDate).add(dProcurementCycle, 'days').format(commonUtils.dateFormatA);
          tableDataRow.tDeliverDate = tDeliverDate;
        }
        // 取工艺卡数据
        if (sModelsType.includes('sales/salesOrder') && (sFieldName === 'sProductId' || sFieldName === 'sProductNo' || sFieldName === 'sProductName') && name === 'slave') {
          const {
            controlConfig, materialsConfig, processConfig, packConfig,
          } = this.props;
          let { controlData, materialsData, processData, packData } = this.props;
          let { slaveData } = this.props;
          let bCkxCopyFromTechnology = '0'; // app.systemData.filter(item => item.sName === 'CkxCopyFromTechnology')[0].sValue;
          /* 若从表配置bNoCopyFromTechnology 则代表产品切换不调用工艺卡 */
          if (commonUtils.isNotEmptyObject(slaveConfig) && commonUtils.isNotEmptyArr(slaveConfig.gdsconfigformslave)) {
            const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'bNoCopyFromTechnology');
            if (iIndex > -1) {
              bCkxCopyFromTechnology = 0;
            }
          }
          if(commonUtils.isEmptyArr(packData)) {
            packData = [];
          }
          // console.log('bCkxCopyFromTechnology', bCkxCopyFromTechnology);
          if (bCkxCopyFromTechnology === '1' && tableDataRow.sProductId !== tableDataRow.sProductName) {
            const controlSelectedData = commonUtils.isNotEmptyArr(controlData) ? controlData.filter(item => item.sSlaveId === sId) : [];
            if (commonUtils.isNotEmptyObject(controlSelectedData)) {
              const controlSelectedRowKeys = [];
              controlSelectedData.forEach((item) => {
                controlSelectedRowKeys.push(item.sId);
              });
              const materialsReturnData = this.otherTableDel('materials', controlSelectedRowKeys);
              const processReturnData = this.otherTableDel('process', controlSelectedRowKeys);
              const controlReturnData = this.props.onDataRowDel('control', true, controlSelectedRowKeys);
              controlData = controlReturnData.controlData;
              materialsData = materialsReturnData.materialsData;
              processData = processReturnData.processData;
              this.props.onSaveState({
                ...materialsReturnData,
                ...processReturnData,
                ...controlReturnData,
              });
            }
            const sCustomerId = masterData.sCustomerId;
            const sProductId = changeValue.sProductId;
            const sProductIdArray = [];
            sProductIdArray.push(sProductId);
            const sProductIds = sProductIdArray.toString();
            const condition = { sCustomerId, sProductIds, sType:'select' };
            let dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataByCustomIdProductId/?sModelsId=${sModelsId}`;
            /* 如果是单表树形或是多表树形 则走新的逻辑 */
            if(sTableType !=='') {
              dataUrl = `${commonConfig.server_host}salesorder/getProcessCardDataTree/?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 copyToSlaveConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Slave'.toLowerCase()); /* 从表赋值字段 */
              const copyToSlaveChildConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.SlaveChild'.toLowerCase()); /* 子表赋值字段 */
              const copyToControlConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Control'.toLowerCase());
              const copyToMaterialsConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Materials'.toLowerCase());
              const copyToProcessConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Process'.toLowerCase());
              const copyToPackConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Pack'.toLowerCase());
              const slaveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
              const slaveChildAssignField = commonUtils.isNotEmptyArr(copyToSlaveChildConfig) ? copyToSlaveChildConfig[0].sAssignField : '';
              const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
              const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : '';
              const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : '';
              const packAssignField = commonUtils.isNotEmptyArr(copyToPackConfig) ? copyToPackConfig[0].sAssignField : '';
              const newCopyTo = {};
              newCopyTo.master = masterData;
              newCopyTo.slave = commonUtils.isEmptyArr(tableData) ? {} : tableData;

              /* 订单选择产品 调用工艺卡数据 */
              if(commonUtils.isNotEmptyArr(returnData.slaveData)) {
                returnData.slaveData.forEach((slaveItem) => {
                  /* 从工艺卡数据集 找到从表相同产品ID,客户ID */
                  if(slaveItem.sProductId === tableDataRow.sProductId) { /* 选中当前行 */
                    tableDataRow = { ... tableDataRow, ...commonFunc.getAssignFieldValue(slaveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                    // tableDataRow.sFatherSlaveId = slaveItem.sFatherSlaveId;
                    tableDataRow.sOriginalId = commonUtils.isNotEmptyObject(slaveItem.sSlaveId) ? slaveItem.sSlaveId : slaveItem.sId;  /* 原始sId */
                    tableDataRow.sBatchNo = tableDataRow.sId; /* 添加批次行 */
                    tableData[iIndex] = { ...  tableData[iIndex], ...tableDataRow }; // 取赋值字段
                  } else{ /* 其他数据 新增 */
                    newCopyTo.slave = slaveItem;
                    let slaveRow ={};
                    slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(slaveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                    slaveRow.handleType = 'add';
                    slaveRow.sFatherSlaveId = slaveItem.sFatherSlaveId;
                    slaveRow.sId = commonUtils.createSid();
                    slaveRow.sParentId = masterData.sId;
                    slaveRow.sOriginalId = commonUtils.isNotEmptyObject(slaveItem.sSlaveId) ? slaveItem.sSlaveId : slaveItem.sId; /* 原始sId */
                    slaveRow.sBatchNo = tableDataRow.sId; /* 添加批次行 */
                    tableData.push(slaveRow);
                  }
                });
              }
              /*  若有层级 则拼装新的slaveData层级  */
              const tableFilterData = tableData.filter(item => item.sBatchNo ===tableDataRow.sId );
              if(commonUtils.isNotEmptyArr(tableFilterData)) {
                const slaveNewData = commonUtils.genTreeDataByArrSales(tableFilterData, 'sId', 'sFatherSlaveId');
                if(commonUtils.isNotEmptyArr(slaveNewData)) {
                  slaveNewData.forEach((item) => {
                    const iIndex = tableData.findIndex(row => row.sId === item.sId);
                    if(iIndex > -1) {
                      tableData[iIndex] =  {...tableData[iIndex], ...item };
                    }
                  })
                }
              }

              // if (commonUtils.isNotEmptyArr(returnData.controlData)) {
              //   const treeCopyNodes = new Map();
              //   // 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();
              //     const iSlaveIndex = slaveData.findIndex(item => item.sOriginalId === controlItem.sSlaveId);
              //     if(iSlaveIndex > -1) {
              //       controlRow.sSlaveId = slaveData[iSlaveIndex].sId;
              //     }
              //
              //     /* 通过部件的sSlaveId源单 去找现在部件对应的新的从表sSlaveId */
              //     controlRow.sParentId = masterData.sId;
              //     if (sModelsType === 'sales/salesOrderPack') { /* 树形 */
              //       /* CopyTo时sAllId,sControlParentId 设置 */
              //       const sAllOldId = controlItem.sAllId;
              //       let arr = [];
              //       if (commonUtils.isNotEmptyObject(sAllOldId)) {
              //         arr = sAllOldId.split(',');
              //       }
              //       const newId = controlRow.sId;
              //       let sOldParentId = '';
              //       let sNewParentAllId = '';
              //       if (arr.length < 2) { /* 根节点复制 */
              //         controlRow.sAllId = newId;
              //         sOldParentId = newId;
              //         sNewParentAllId = newId;
              //       } else {
              //         sOldParentId = arr[arr.length - 2];
              //         if (treeCopyNodes.has(sOldParentId)) {
              //           sNewParentAllId = treeCopyNodes.get(sOldParentId);
              //         } else {
              //           const obj = arr[arr.length - 1];
              //           sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
              //         }
              //         const sNewArr = sNewParentAllId.split(',');
              //         controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
              //         sNewParentAllId = `${sNewParentAllId},${newId}`;
              //         controlRow.sAllId = sNewParentAllId;
              //       }
              //       treeCopyNodes.set(controlItem.sId, sNewParentAllId);
              //     }
              //     controlData.push(controlRow);
              //
              //     if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
              //       returnData.materialsData.filter(item => item.sControlId === controlItem.sId).forEach((materialsItem) => {
              //         newCopyTo.materials = materialsItem;
              //         let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo); // 取默认值
              //         materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
              //         materialsRow.handleType = 'add';
              //         materialsRow.sId = commonUtils.createSid();
              //         const iSlaveIndex = slaveData.findIndex(item => item.sOriginalId === materialsItem.sSlaveId);
              //         if(iSlaveIndex > -1) {
              //           materialsRow.sSlaveId = slaveData[iSlaveIndex].sId;
              //         }
              //         materialsRow.sParentId = masterData.sId;
              //         materialsRow.sControlId = controlRow.sId;
              //         materialsRow.sPartsName = controlRow.sPartsName;
              //
              //         materialsData.push(materialsRow);
              //       });
              //     }
              //     if (commonUtils.isNotEmptyArr(returnData.packData)) {
              //       returnData.packData.filter(item => item.sControlId === controlItem.sId).forEach((packItem) => {
              //         newCopyTo.pack = packItem;
              //         let packRow = commonFunc.getDefaultData(packConfig, newCopyTo); // 取默认值
              //         packRow = { ...packRow, ...commonFunc.getAssignFieldValue(packAssignField, packItem, newCopyTo) }; // 取赋值字段
              //         /* sSlaveId赋值 */
              //         const packRowAdd = this.handlePackDataAdd(tableDataRow, 0, controlRow.sId);
              //         packRow = { ...packRow, ...packRowAdd };
              //         const iSlaveIndex = slaveData.findIndex(item => item.sOriginalId === packItem.sSlaveId);
              //         if(iSlaveIndex > -1) {
              //           packRow.sOrderSlaveId = slaveData[iSlaveIndex].sId;
              //         }
              //
              //         /* 添加控制表中的合版信息 */
              //         const sCombinedMemoJsonData = [];
              //         /* 将控制表中的合版备注sId为新的sId */
              //         const {
              //           sId, sProductNo, dCombineQty, dProductQty, dFactProductQty, sCombinePartsName,
              //         } = packRow;
              //         if (dCombineQty > 0) { /* 排版数大于0时,把数据带回到控制表 */
              //           const jsonObj = {};
              //           jsonObj.sId = sId;
              //           jsonObj.sProductNo = sProductNo; /* 产品编号 */
              //           jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
              //           jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
              //           jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
              //           jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
              //           sCombinedMemoJsonData.push(jsonObj);
              //         }
              //         const sCombinedMemoNew = commonUtils.isNotEmptyArr(sCombinedMemoJsonData) ? JSON.stringify(sCombinedMemoJsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
              //         const icontrolIndex = controlData.findIndex(item => item.sId === controlRow.sId);
              //         if (icontrolIndex > -1) {
              //           controlData[icontrolIndex] = { ...controlData[icontrolIndex], sCombinedMemo: sCombinedMemoNew };
              //         }
              //         packData.push(packRow);
              //       });
              //     }
              //
              //     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();
              //         const iSlaveIndex = slaveData.findIndex(item => item.sOriginalId === processItem.sSlaveId);
              //         if(iSlaveIndex > -1) {
              //           processRow.sSlaveId = slaveData[iSlaveIndex].sId;
              //         }
              //         processRow.sParentId = masterData.sId;
              //         processRow.sControlId = controlRow.sId;
              //         processRow.sPartsName = controlRow.sPartsName;
              //         processData.push(processRow);
              //       });
              //     }
              //   });
              // }
              // if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
              //   // eslint-disable-next-line no-loop-func
              //   returnData.materialsData.filter(item => item.sType === '2').forEach((materialsItem) => {
              //     newCopyTo.materials = materialsItem;
              //     let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo); // 取默认值
              //     materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
              //     materialsRow.handleType = 'add';
              //     materialsRow.sId = commonUtils.createSid();
              //     materialsRow.sSlaveId = tableDataRow.sId;
              //     materialsRow.sParentId = masterData.sId;
              //     materialsData.push(materialsRow);
              //   });
              // }
              // 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, materialsData, processData, packData,  slaveData,
              });
            }
          }
        } else if (sModelsType.includes('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.handleType = commonUtils.isEmpty(one.handleType) ? 'update' : one.handleType;
            one.dPartsQty = commonUtils.isNull(tableDataRow.dProductQty, 0) + commonUtils.isNull(tableDataRow.dGiveQty, 0) + commonUtils.isNull(tableDataRow.dStockupQty, 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;
          }
          const models = name === 'materials' ? 'Materials' :
            sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
          if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/')) {
            tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, 'dAuxiliaryQty', app, token, models);
          }
          tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dAuxiliaryQty', masterData, tableDataRow);

          if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === 'dMaterialsStockAuxiliaryQty') > -1) {
            const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
            const valueMaterialsStock = {
              sProName: 'Sp_Inventory_MaterialsInventoryV56',
              paramsMap: {
                sMaterialsGuid: tableDataRow.sMaterialsId,
                sMaterialsStyle: tableDataRow.sMaterialsStyle,
                sWarehouseGuid: tableDataRow.sWarehouseId,
                sLocationalGuid: tableDataRow.sLocationId,
                sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
                sDefine_no: tableDataRow.sDefineNo,
                sDefine_no2: tableDataRow.sDefineNo2,
                iGetQty: 1,
                iHasZero: 1,
              },
            };
            const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
            if (returnDataMaterialsStock.code === 1) {
              tableDataRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
            }
          }
          if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === 'dMaterialsStockAvailableQty') > -1) {
            const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
            const valueMaterialsAvailableQty = {
              sProName: 'Sp_Inventory_MaterialsInventoryV56',
              paramsMap: {
                sMaterialsGuid: tableDataRow.sMaterialsId,
                sMaterialsStyle: tableDataRow.sMaterialsStyle,
                sWarehouseGuid: tableDataRow.sWarehouseId,
                sLocationalGuid: tableDataRow.sLocationId,
                sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
                sDefine_no: tableDataRow.sDefineNo,
                sDefine_no2: tableDataRow.sDefineNo2,
                iGetQty: 2,
                iHasZero: 1,
              },
            };
            const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)).data;
            if (returnDataMaterialsAvailableQty.code === 1) {
              tableDataRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
            }
          }
          /* 选择材料后 交货周期改变 则交货时间等于制单时间+交货周期 */
          const dProcurementCycle = commonUtils.isNull(tableDataRow.dProcurementCycle, 0);
          const tCreateDate = commonUtils.isNotEmptyObject(tableDataRow.tCreateDate) ? tableDataRow.tCreateDate : new Date();
          const tDeliverDate = moment(tCreateDate).add(dProcurementCycle, 'days').format(commonUtils.dateFormatA);
          tableDataRow.tDeliverDate = tDeliverDate;
          // else {
          //   this.props.getServiceError(returnData);
          // }
        } else if (sModelsType === 'sales/salesCheck' && sFieldName === 'dLossMoney' && name === 'slave') {
          const dPmoney = this.props.getFloatNum('dProductMoney');
          const { dNetPrice } = app.decimals;
          const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
          const dTaxRate = commonUtils.convertToNum(tableDataRow.dTaxRate); /* 税率 */
          const dProductQty = commonUtils.convertToNum(tableDataRow.dProductQty); /* 数量 */
          if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcNoCheckMoney) && commonUtils.isNotEmptyNumber(tableDataRow.dLossMoney)) {
            const dProductForeignMoney = commonUtils.convertFixNum(tableDataRow.dSrcNoCheckMoney - tableDataRow.dLossMoney, dPmoney);
            const dProductMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dProductForeignMoney * dCurrencyRate : 0, dPmoney); /* 本位币金额 */
            tableDataRow.dProductForeignMoney = dProductForeignMoney;
            tableDataRow.dProductMoney = dProductMoney;
            const dProductNoTaxMoney = commonUtils.convertFixNum(dProductMoney / (1 + (dTaxRate / 100)), dPmoney); /* 不含税金额 */
            const dProductNoTaxPrice = commonUtils.convertFixNum(dProductQty !== 0 ? dProductNoTaxMoney / dProductQty : 0, dPmoney); /* 不含税价 */
            const dProductTaxMoney = commonUtils.convertFixNum(dProductMoney - dProductNoTaxMoney, dPmoney); /* 税额 */
            const dProductTaxForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dProductTaxMoney / dCurrencyRate : 0, dPmoney); /* 外币税额 */
            tableDataRow.dProductNoTaxMoney = dProductNoTaxMoney;  /* 不含税金额 */
            tableDataRow.dProductNoTaxPrice = dProductNoTaxPrice; /* 不含税价 */
            tableDataRow.dProductTaxMoney = dProductTaxMoney;  /* 税额 */
            tableDataRow.dProductTaxForeignMoney = dProductTaxForeignMoney; /* 外币税额 */
            /* 报损金额改变后 反算单价 */
            tableDataRow.dProductForeignPrice =  tableDataRow.dProductQty !==0 ? commonUtils.convertFixNum( dProductForeignMoney/tableDataRow.dProductQty, dNetPrice) : 0; /* 外币税额 */
            tableDataRow.dProductPrice =  tableDataRow.dProductQty !==0 ? commonUtils.convertFixNum( dProductMoney/tableDataRow.dProductQty, dNetPrice) : 0; /* 外币税额 */
          } else if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcNoCheckMoney) && commonUtils.isEmptyNumber(tableDataRow.dLossMoney)) {
            const dProductForeignMoney = commonUtils.isNull(tableDataRow.dSrcNoCheckMoney, 0);
            const dProductMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dProductForeignMoney * dCurrencyRate : 0, dPmoney); /* 本位币金额 */
            tableDataRow.dProductForeignMoney = dProductForeignMoney;
            tableDataRow.dProductMoney = dProductMoney;
            tableDataRow.dLossMoney = 0;
            const dProductNoTaxMoney = commonUtils.convertFixNum(dProductMoney / (1 + (dTaxRate / 100)), dPmoney); /* 不含税金额 */
            const dProductNoTaxPrice = commonUtils.convertFixNum(dProductQty !== 0 ? dProductNoTaxMoney / dProductQty : 0, dPmoney); /* 不含税价 */
            const dProductTaxMoney = commonUtils.convertFixNum(dProductMoney - dProductNoTaxMoney, dPmoney); /* 税额 */
            const dProductTaxForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dProductTaxMoney / dCurrencyRate : 0, dPmoney); /* 外币税额 */
            tableDataRow.dProductNoTaxMoney = dProductNoTaxMoney;  /* 不含税金额 */
            tableDataRow.dProductNoTaxPrice = dProductNoTaxPrice; /* 不含税价 */
            tableDataRow.dProductTaxMoney = dProductTaxMoney;  /* 税额 */
            tableDataRow.dProductTaxForeignMoney = dProductTaxForeignMoney; /* 外币税额 */
          }
        } else if (sModelsType && (sModelsType === 'purchase/purchasecheck' || sModelsType.includes('outside/outsideChecking') ) && sFieldName === 'dLossMoney' && name === 'slave') {
          const dPmoney = this.props.getFloatNum('dMaterialsMoney');
          const { dNetPrice } = app.decimals;
          const dTaxRate = commonUtils.convertToNum(tableDataRow.dTaxRate); /* 税率 */
          const type = 'Materials';
          const dProductQty = commonUtils.convertToNum(tableDataRow[`d${type}Qty`]); /* 数量 */
          if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcNoCheckMoney) && commonUtils.isNotEmptyNumber(tableDataRow.dLossMoney)) {
            const dMoney = commonUtils.convertFixNum(tableDataRow.dSrcNoCheckMoney - tableDataRow.dLossMoney, dPmoney);
            tableDataRow[`d${type}Money`] = dMoney;
            const dProductNoTaxMoney = commonUtils.convertFixNum(dMoney / (1 + (dTaxRate / 100)), dPmoney); /* 不含税金额 */
            const dProductNoTaxPrice = commonUtils.convertFixNum(dProductQty !== 0 ? dProductNoTaxMoney / dProductQty : 0, dPmoney); /* 不含税价 */
            const dProductTaxMoney = commonUtils.convertFixNum(dMoney - dProductNoTaxMoney, dPmoney); /* 税额 */
            tableDataRow[`d${type}NoTaxMoney`] = dProductNoTaxMoney;  /* 不含税金额 */
            tableDataRow[`d${type}NoTaxPrice`] = dProductNoTaxPrice; /* 不含税价 */
            tableDataRow[`d${type}TaxMoney`] = dProductTaxMoney;  /* 税额 */
            /* 报损金额改变后 反算单价 */
            tableDataRow[`d${type}Price`] =  dProductQty !==0 ? commonUtils.convertFixNum( dMoney/dProductQty, dNetPrice) : 0; /* 外币税额 */
          } else if (commonUtils.isNotEmptyNumber(tableDataRow.dSrcNoCheckMoney) && commonUtils.isEmptyNumber(tableDataRow.dLossMoney)) {
            tableDataRow.dMaterialsMoney = commonUtils.isNull(tableDataRow.dSrcNoCheckMoney, 0);
            tableDataRow.dLossMoney = 0;
          }
        } else if (sModelsType === 'cost/cosexpenseshare') { /* 改变费用分摊单据从表成本中心金额，总金额随之改变 */
          if (sFieldName.indexOf('dCostCenter') > -1) {
            const { slaveColumn, app } = this.props;
            const { dNetMoney } = app.decimals;
            let dAllMoney = 0;
            slaveColumn.forEach((item) => {
              const sName = item.dataIndex;
              if (sName.indexOf('dCostCenter') > -1) {
                dAllMoney += commonUtils.isNotEmptyNumber(tableDataRow[sName]) ? commonUtils.convertFixNum(tableDataRow[sName], dNetMoney) : 0;
              }
            });
            tableDataRow.dShareMoney = commonUtils.convertFixNum(dAllMoney, dNetMoney);
          }
        } else if (sModelsType === 'purchase/purchaseInstore' && name === 'slave') { /* 采购入库  材料批次=材料生产日期tSReserve1(此客户手输)+当前日期 */
          if (sFieldName === 'tProductionDate') {
            tableDataRow.sDefineNo = moment(tableDataRow.tProductionDate).format('YYYYMMDDHHmm') + moment(new Date()).format('YYYYMMDDHHmm');
          }
        }
        /* 各种金额，税额，价格计算 */
        let models = name === 'materials' ? 'Materials' :
          sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('cashier/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';

        if(sModelsType.includes('cashier/receipt') ) { /* 收款单 */
          models = 'Product';
        } else  if(sModelsType.includes('cashier/payment') ) {  /* 付款单 */
          models = 'Materials';
        }

        if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/')
          || sModelsType.includes('outside/') || sModelsType.includes('semigoodsStock/') || sModelsType.includes('sales/materials') || sModelsType === 'sales/salesCheck') {
          if (sModelsType.includes('sales/materials') || sModelsType === 'sales/salesCheck') {
            tableDataRow.dAuxiliaryQty = tableDataRow.dProductQty;
          }
          tableDataRow = await this.handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models);

          if (sModelsType.includes('sales/materials') || sModelsType === 'sales/salesCheck') { /* 如果是材料销售模块/销售对账 如果是材料 则用换算数量*单价  算金额 */
            /* 材料逻辑计算 */
            if (commonUtils.isNotEmptyNumber('dMaterialsQty') && tableDataRow.dMaterialsQty !== 0 && commonUtils.isNotEmptyObject(tableDataRow.sMaterialsUnit)) {
              let modelsNew = '';
              if (models === 'Product') { /* 计算前将Product替换为Materials */
                modelsNew = 'Materials';

                const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
                const { dNetPrice } = app.decimals;
                const dForeignPrice = tableDataRow[`d${models}ForeignPrice`];
                if (commonUtils.isNotEmptyNumber(dForeignPrice)) {
                  /* 只有外币单价情況下 要算本位币单价 */
                  const dProductPrice = commonUtils.convertFixNum(dForeignPrice * dCurrencyRate, dNetPrice);
                  tableDataRow[`d${models}Price`] = dProductPrice;
                }

                tableDataRow[`dN${modelsNew}Price`] = tableDataRow[`d${models}ForeignPrice`];
                tableDataRow[`d${modelsNew}ForeignPrice`] = tableDataRow[`d${models}ForeignPrice`];
                tableDataRow[`d${modelsNew}Price`] = tableDataRow[`d${models}Price`];
                tableDataRow[`dN${modelsNew}Money`] = tableDataRow[`dN${models}Price`];
                tableDataRow[`dN${modelsNew}Money`] = tableDataRow[`d${models}ForeignMoney`];
                tableDataRow[`d${modelsNew}ForeignMoney`] = tableDataRow[`d${models}ForeignMoney`];
                tableDataRow[`d${modelsNew}Money`] = tableDataRow[`d${models}Money`];
                tableDataRow.bSalesMaterials = true;/* 材料销售 销售对账 材料计算 */
                models = 'Materials';
                sFieldName = commonUtils.isNotEmptyObject(sFieldName) ? sFieldName.replace('Product', 'Materials') : sFieldName;
              }
            }
          }
        }
        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');
            }
          }
        }
        if (isWait) {
          return tableDataRow;
        } else {
          tableData[iIndex] = tableDataRow;
          if (name === 'report') { // 报表设计
            this.props.onSaveState({ reportPropsEnabled: true });
          } else {
            this.props.onSaveState({ enabled: true });
          }
          this.props.onSaveState({ [`${name}Data`]: tableData });
        }
      }
    };

    /**   删除表格数据   */
    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`]: [] };
    };

    handleMaterialsChangeBak = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => {
      if (this.inputChange) {
        clearTimeout(this.inputChange);
      }
      this.inputChange = setTimeout(async() => {
        // /*   调用父组件的回带函数 */
        tableDataRow = await this.handleMaterialsChangeWait(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models);
      }, 10);
      return  tableDataRow;
    }

    handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => {
      const { sComputeId, sConversionComputeId, sReConversionComputeId } = tableDataRow;
      const sFormulaIdType = tableDataRow.bInverse ? 'sReComputeId' : 'sComputeId'; /* 正算、反算类型 */
      if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || sFieldName === 'dAuxiliaryQty' || sFieldName === 'dReelAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle' || sFieldName === 'dProductQty') {
        if (sFieldName === 'dReelAuxiliaryQty') {
          if (tableDataRow.sMaterialsUnit === '吨' && tableDataRow.bReel && tableDataRow.dGramWeight > 0) {
            tableDataRow = commonBusiness.getMaterialsQty(app, { ...tableDataRow, sMaterialsStyle: tableDataRow.sReelMaterialsStyle }, 'dReelAuxiliaryQty', 'dMaterialsQty');
            tableDataRow.dAuxiliaryQty = tableDataRow.dMaterialsQty;
            tableDataRow.sMaterialsStyle = tableDataRow.sMaterialsStyle !== undefined && tableDataRow.sMaterialsStyle.split('*').length > 1 ? tableDataRow.sMaterialsStyle.split('*')[0] : tableDataRow.sMaterialsStyle;
            tableDataRow.sAuxiliaryUnit = tableDataRow.sMaterialsUnit;
          } else if (tableDataRow.sMaterialsUnit.toUpper() === 'M2' && tableDataRow.bReel) {
            tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dReelAuxiliaryQty', 'dMaterialsQty');
            tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty;
          } else {
            tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty;
          }
        }
        if (commonUtils.isEmpty(sComputeId) && sFieldName !== 'dConversionQty') {
          if (sFieldName === 'dProductQty') {
            tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dProductQty', 'dMaterialsQty');
          } else if (app.currentPane.sModelsType && app.currentPane.sModelsType.includes('outside/')) {
            tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dAuxiliaryQty', 'dMaterialsQty');
          } else {
            tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({
              token, sModelsId, masterData, tableDataRow, sComputeId, sFormulaIdType,
            });
          }
        } else if (!commonUtils.isEmpty(sComputeId)) {
          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) {
          if (app.currentPane.sModelsType && app.currentPane.sModelsType.includes('outside/')) {
            tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryQty');
          } else {
            tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({
              token, sModelsId, masterData, tableDataRow, sReComputeId, sFormulaIdType,
            });
          }
        } else if (tableDataRow.bInverse) {
          tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId: sReComputeId,
          });
          if (commonUtils.isNotEmptyArr(tableDataRow.dAuxiliaryQty) && tableDataRow.dAuxiliaryQty !== 0) {
            tableDataRow.dProductQty = tableDataRow.dAuxiliaryQty;
          }
        }
        if (!commonUtils.isEmpty(sReConversionComputeId)) {
          tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow, sComputeId: sReConversionComputeId,
          });
        }
      } else if (sFieldName === 'dAuxiliaryLossQty') {
        const tableDataRowNew ={ ...tableDataRow ,dAuxiliaryQty:tableDataRow.dAuxiliaryLossQty };
        if (commonUtils.isEmpty(sComputeId)) {
          // tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, sFieldName, 'dLossQty');
          tableDataRow.dLossQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow:tableDataRowNew, sComputeId, sFormulaIdType,
          });
        } else {
          tableDataRow.dLossQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow:tableDataRowNew, 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;
        const tableDataRowNew ={ ...tableDataRow ,dMaterialsQty:tableDataRow.dLossQty };
        if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) {
          // tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryLossQty');
          tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow:tableDataRowNew, sReComputeId, sFormulaIdType,
          });
        } else {
          tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({
            token, sModelsId, masterData, tableDataRow:tableDataRowNew, 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;
    }

    handleCustomerChange = (name, changeValue) => {
      if (commonUtils.isNotEmptyObject(changeValue)) {
        if (changeValue.sCustomerId !== this.state.changleCustomerId) {
          const sCustomerId = [];
          sCustomerId.push(changeValue.sCustomerId);
          this.handleTableSelectRowChange(name, sCustomerId, changeValue);
        }
      }
      this.setState({ changleCustomerId: changeValue.sCustomerId });
    }
    handleMasterChange = async (name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew) => {
      if(location.pathname === '/indexPage/printlabel') { /* printlabel 打印成品批次标识卡(EBC) 客户下拉页签需调用接口 */
        this.handleCustomerChange(name, changeValue); // 注掉原因：产品名称可输入时，会慢一拍，会清空。
      }
      const {
        sModelsId, sModelsType, masterData: masterDataOld,  app, masterConfig, slaveConfig, token,
        controlData, materialsData, processData, slaveData, slaveSelectedRowKeys,controlSelectedRowKeys,
        processSelectedRowKeys,materialsSelectedRowKeys,slaveInfoSelectedRowKeys, slaveInfoData, enabled,
      } = this.props;
      const addState = {};
      const masterData = masterDataNew === undefined ? masterDataOld === undefined ? {} : masterDataOld : masterDataNew;
      let bNewSlaveData = false;
      if (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' || sFieldName === 'sGetPayName') {
        changeValue.tGetPayDate = commonBusiness.getGeyPayDate({ ...masterData, ...changeValue });
      } else if (sFieldName === 'tInvoiceDate') {
        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 = '';
          }
        }
        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;
          }
        }
        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);
      if( commonUtils.isNotEmptyObject(returnData?.masterData.customConfig) && commonUtils.isJSON(returnData?.masterData.customConfig)) {
        const columnConfig = JSON.parse(returnData.masterData.customConfig);
        const newConfig =JSON.parse( JSON.stringify(slaveConfig));
        let buttonConfig = [];
        if(commonUtils.isNotEmptyArr(slaveConfig?.gdsconfigformslave)) {
          buttonConfig = slaveConfig?.gdsconfigformslave.filter(item => commonUtils.isEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sControlName) );
        }
        newConfig.gdsconfigformslave = columnConfig.concat(buttonConfig);
        addState.slaveConfig = newConfig;
      }
      // 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 === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName' ||
        sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName' || sFieldName === 'tDeliverDate' ||
        sFieldName === 'sCurrency' || sFieldName === 'dCurrencyRate' || sFieldName ==='sCurrencyName') {
        const slaveDataNew = [];
        const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
        for (const item of slaveData) {
          let tableDataRow = ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' ||
            sFieldName === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName' ||
            sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName') && (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;
            let dMaterialsMoney = '';
            if (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,
                });
                if (commonUtils.isNotEmptyObject(sComputeId)) {
                  dMaterialsMoney = await commonBusiness.getFormulaValue({
                    token, sModelsId, masterData: returnData.masterData, tableDataRow, sComputeId,
                  });
                  tableDataRow.dMaterialsMoney = dMaterialsMoney;
                  tableDataRow = commonBusiness.getCalculateMoney(app, returnData.masterData, tableDataRow, 'Materials');
                } else {
                  tableDataRow = commonBusiness.getCalculateMoney(app, returnData.masterData, tableDataRow, 'Materials'); /* 没有发外公式情况下 进行计算 */
                }
              } else {
                tableDataRow = commonBusiness.getCalculateMoney(app, returnData.masterData, tableDataRow, 'Materials')
              }
            } else {
              tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'sTaxId', returnData.masterData, tableDataRow);
            }
          } else if (sFieldName === 'sCurrency' || sFieldName === 'dCurrencyRate' || sFieldName ==='sCurrencyName') {
            let controlField =`d${models}ForeignPrice`;
             if(sModelsType?.includes('cashier/')) {
              tableDataRow.bSettleMoney = true;
              tableDataRow[`d${models}ForeignPrice`] = tableDataRow.dTotalForeignPrice;
              tableDataRow[`d${models}Money`] = tableDataRow.dTotalMoney;

            }
             if( sModelsType === 'sales/adjust') { /* 财务调整单 */
               // tableDataRow.dProductMoney = tableDataRow.dTotalMoney;
               controlField = 'dProductForeignMoney';
             }
            tableDataRow = commonBusiness.getCalculateAllMoney(app, models, controlField, returnData.masterData, tableDataRow);
            tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
          }
          if ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' ||
            sFieldName === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName' ||
            sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName') && (!sModelsType.includes('materialsStock/productionmaterialsadjust'))) {
            if (sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') {
              tableDataRow.sWareHouseId = changeValue.sWareHouseId;
              tableDataRow.sWareHouseNo = changeValue.sWareHouseNo;
              tableDataRow.sWareHouseName = changeValue.sWareHouseName;
            } else if (sFieldName === 'sLocationId' || sFieldName === 'sLocationNo' || sFieldName === 'sLocationName') {
              tableDataRow.sLocationId = changeValue.sLocationId;
              tableDataRow.sLocationNo = changeValue.sLocationNo;
              tableDataRow.sLocationName = changeValue.sLocationName;
            } else if (sFieldName === 'sWareHouseLocationId' || sFieldName === 'sWareHouseLocationNo' || sFieldName === 'sWareHouseLocationName') {
              tableDataRow.sWareHouseLocationId = changeValue.sWareHouseLocationId;
              tableDataRow.sWareHouseLocationNo = changeValue.sWareHouseLocationNo;
              tableDataRow.sWareHouseLocationName = changeValue.sWareHouseLocationName;
            }
            tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
          } else if (sFieldName === 'tDeliverDate') {
            tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
          }
          slaveDataNew.push(tableDataRow);
        }
        addState.slaveData = slaveDataNew;
        // this.props.onSaveState({ slaveData: slaveDataNew });
      } else if ((sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName')) {
        if (bNewSlaveData) {
          const slaveDataNew = [];
          const allTableData = {};
          allTableData.master = returnData.masterData;
          const newSid = commonUtils.createSid();
          const tableDataRowAdd = commonFunc.getDefaultData(slaveConfig, allTableData, { newSid });
          tableDataRowAdd.handleType = 'add';
          tableDataRowAdd.sId = newSid;
          tableDataRowAdd.sNodeId = commonUtils.createSid();
          tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
          tableDataRowAdd.key = tableDataRowAdd.sId;
          tableDataRowAdd.bDefault = false;
          tableDataRowAdd.iOrder = 1;
          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 === 'sTestStandardId' || sFieldName === 'sTestStandardName') {
        const { slaveDelData: slaveDelDataOld, slaveConfig, masterConfig } = this.props;
        const dataUrl = `${commonConfig.server_host}eleteamemployee/getObtainInspectionStandards?sModelsId=${sModelsId}&sParentId=${returnData.masterData.sTestStandardId}`;
        const dataReturn = (await commonServices.getService(this.props.app.token, dataUrl)).data;
        const slaveDelData = commonUtils.isEmptyArr(slaveDelDataOld) ? [] : slaveDelDataOld;
        if (dataReturn.code === 1) {
          const returnSlaveData = dataReturn.dataset.rows;
          if(commonUtils.isNotEmptyArr(slaveData)) {
            slaveData.forEach((item) => {
              item.handleType = 'del';
              slaveDelData.push(item);
            });
          }
          const slaveDataNew = [];
          const newCopyTo = {};
          newCopyTo.master = masterData;
          const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'sTestStandardName');
          const iSqlIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sActValue');
          returnSlaveData.forEach((item, iIndex) => {
            const newSid = commonUtils.createSid();
            let tableDataRow = commonFunc.getDefaultData(slaveConfig, {}, { newSid });
            tableDataRow.handleType = 'add';
            tableDataRow.sId = newSid;
            tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
            tableDataRow.key = tableDataRow.sId;
            tableDataRow.iOrder = iIndex;
            if (iConfigIndex > -1) {
              tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(masterConfig.gdsconfigformslave[iConfigIndex].sAssignField, item, newCopyTo) }; // 取赋值字段
              // tableDataRow.sTestReference = '15S|20S';
              const sTestReference = tableDataRow.sTestReference;
              const sParamObj = {};
              if (commonUtils.isNotEmptyObject(sTestReference)) {
                if (sTestReference.indexOf('|') >= 0) {
                  sTestReference.split('|').forEach((itemField) => {
                    sParamObj[itemField] = itemField;
                  });
                  tableDataRow.sParamDropDownsActValue = sParamObj;
                  if (iSqlIndex > -1) {
                    slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = 'sql';
                  } else {
                    slaveConfig.gdsconfigformslave[iSqlIndex].sDropDownType = '';
                  }
                }
              }
            }
            slaveDataNew.push(tableDataRow);
          });
          addState.slaveData = slaveDataNew;
          addState.slaveDelData = slaveDelData;
        } else {
          this.props.getServiceError(dataReturn);
        }
      } else if (sFieldName === 'sPeriodID') {
        const master = returnData.masterData;
        let { handleType } = master;
        handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
        if (handleType === 'add') { /* 费用分摊单据新增时，选择不同月份，自动获取从表的数据 */
          const { sModelsId } = this.props;
          let url = `${commonConfig.server_host}costCenter/getCostCenterData?sModelsId=${sModelsId}`;
          const body = {
            sPeriodId: changeValue.sPeriodID,
          };
          /**
           * 修改日期：2021-03-26
           * 修改人：吕杰
           * 区域：以下 4 行
           * BUG：2168
           * 说明：凭证导入表下主表月份切换从后台获取数据
           * 原代码：
           */
          if (sModelsType === 'cashier/voucher') {
            url = `${commonConfig.server_host}costCenter/getCosvoucherImportData?sModelsId=${sModelsId}`;
            body.sWeek = masterDataOld.sWeek;
          }
          const dataReturn = (await commonServices.postValueService(app.token, body, url)).data;
          if (dataReturn.code === 1) {
          /*   获取数据集   */
            const { rows } = dataReturn.dataset;
            const slaveDataNew = [];
            rows.forEach((row) => {
              /**
               * 修改日期：2021-03-26
               * 修改人：吕杰
               * 区域：以下 13 行
               * BUG：2168
               * 说明：凭证导入表下主表月份切换从后台获取数据
               * 原代码：
               */
              let tableDataRowAdd = row;
              if (sModelsType === 'cashier/voucher') {
                // 当主表中配置了转换信息时，对数据字段进行转换
                const index = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'Btnimport');
                if (index > -1) {
                  const newCopyTo = {};
                  newCopyTo.master = masterData;
                  newCopyTo.slave = row;
                  const config = masterConfig.gdsconfigformslave[index];
                  const slaveAssignField = config.sAssignField || '';
                  tableDataRowAdd = { ...row, ...commonFunc.getAssignFieldValue(slaveAssignField, row, newCopyTo) };
                }
              }
              tableDataRowAdd.handleType = handleType;
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
              tableDataRowAdd.key = tableDataRowAdd.sId;
              tableDataRowAdd.bDefault = false;
              slaveDataNew.push(tableDataRowAdd);
            });
            addState.slaveData = slaveDataNew;
          } else { /*   失败   */
            this.props.getServiceError(dataReturn);
            return [];
          }
        }
      } else if (sFieldName === 'sWeek' && sModelsType === 'cashier/voucher') {
        /**
         * 修改日期：2021-03-26
         * 修改人：吕杰
         * 区域：此if内
         * BUG：2168
         * 说明：凭证导入表下主表周期切换从后台获取数据
         * 原代码：
         */
        const master = returnData.masterData;
        let { handleType } = master;
        handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
        if (handleType === 'add') { /* 费用分摊单据新增时，选择不同月份，自动获取从表的数据 */
          const { sModelsId } = this.props;
          const url = `${commonConfig.server_host}costCenter/getCosvoucherImportData?sModelsId=${sModelsId}`;
          const body = {
            sWeek: changeValue.sWeek,
            sPeriodId: masterDataOld.sPeriodId,
          };
          const dataReturn = (await commonServices.postValueService(app.token, body, url)).data;
          if (dataReturn.code === 1) {
          /*   获取数据集   */
            const { rows } = dataReturn.dataset;
            const slaveDataNew = [];
            rows.forEach((row) => {
              let tableDataRowAdd = row;
              // 当主表中配置了转换信息时，对数据字段进行转换
              const index = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'Btnimport');
              if (index > -1) {
                const newCopyTo = {};
                newCopyTo.master = masterData;
                newCopyTo.slave = row;
                const config = masterConfig.gdsconfigformslave[index];
                const slaveAssignField = config.sAssignField || '';
                tableDataRowAdd = { ...row, ...commonFunc.getAssignFieldValue(slaveAssignField, row, newCopyTo) };
              }
              tableDataRowAdd.handleType = handleType;
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
              tableDataRowAdd.key = tableDataRowAdd.sId;
              tableDataRowAdd.bDefault = false;
              slaveDataNew.push(tableDataRowAdd);
            });
            addState.slaveData = slaveDataNew;
          } else { /*   失败   */
            this.props.getServiceError(dataReturn);
            return [];
          }
        }
      }
      const models = name === 'materials' ? 'Materials' :
        sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('print/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
      if (sModelsType.includes('purchase/') || sModelsType.includes('print/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/') || sModelsType.includes('quality/')) {
        let masterData = await this.handleMaterialsChange(returnData.masterData, sModelsId, masterData, changeValue, sFieldName, app, token, models);
        masterData = commonBusiness.getCalculateAllMoney(app, models, sFieldName, masterData, masterData);
        if (sFieldName !== 'dPackQty') {
          if (changeValue.dPackQty !== this.state.dPackQtyChange && changeValue.dPackQty !== undefined) {
            masterData = commonBusiness.getCalculateAllMoney(app, models, 'dPackQty', masterData, masterData);
            this.setState({ dPackQtyChange: changeValue.dPackQty });
          }
        }
        returnData = { ...returnData, masterData };
      }

      /* 将选中行塞到tableSelectedData数据集合中 */
      let slaveRow = {};
      let controlRow = {};
      let materialsRow  ={};
      let processRow = {};
      let slaveInfoRow = {};
      if(commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        const iSIndex =  slaveData.findIndex(item =>slaveSelectedRowKeys.includes(item.sId));
        if(iSIndex > -1) {
          slaveRow =  slaveData[iSIndex];
        }
      }
      if(commonUtils.isNotEmptyArr(slaveInfoData) && commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys)) {
        const iSIndex =  slaveData.findIndex(item =>slaveInfoSelectedRowKeys.includes(item.sId));
        if(iSIndex > -1) {
          slaveInfoRow =  slaveInfoData[iSIndex];
        }
      }
      if(commonUtils.isNotEmptyArr(controlData) && commonUtils.isNotEmptyArr(controlSelectedRowKeys)) {
        const iCIndex =   controlData.findIndex(item => controlSelectedRowKeys.includes(item.sId));
        if(iCIndex > -1) {
          controlRow =  controlData[iCIndex];
        }
      }
      if(commonUtils.isNotEmptyArr(materialsData) && commonUtils.isNotEmptyArr(materialsSelectedRowKeys)) {
        const iMIndex =  materialsData.findIndex(item => slaveSelectedRowKeys.includes(item.sId));
        if(iMIndex > -1) {
          materialsRow =  materialsData[iMIndex];
        }
      }
      if(commonUtils.isNotEmptyArr(processData) && commonUtils.isNotEmptyArr(processSelectedRowKeys)) {
        const iPIndex =  processData.findIndex(item => processSelectedRowKeys.includes(item.sId));
        if(iPIndex > -1) {
          processRow =  processData[iPIndex];
        }
      }
      const tableAllData = {};
      tableAllData.master = masterData;
      tableAllData.slave = slaveData;
      tableAllData.control = controlData;

      const tableSelectedData = {
        master: masterData,
        slaveRow: slaveRow,
        controlRow: controlRow,
        materialsRow: materialsRow,
        processRow: processRow,
      }
      const masterDataAfter = commonBusiness.getKeyUpEvent(name, sFieldName, masterConfig, returnData.masterData, tableAllData, true, tableAllData, tableSelectedData, app);
      if (commonUtils.isNotEmptyObject(masterDataAfter)) {
        if (masterDataAfter.bMultiTable) {
          returnData.masterData = masterDataAfter.master;
          if (commonUtils.isNotEmptyArr(masterDataAfter.slave)) {
            returnData.slaveData = masterDataAfter.slave;
          }
          if (commonUtils.isNotEmptyArr(masterDataAfter.control)) {
            returnData.controlData = masterDataAfter.control;
          }
          if (commonUtils.isNotEmptyArr(masterDataAfter.packing)) {
            returnData.packingData = masterDataAfter.packing;
          }
          if (commonUtils.isNotEmptyArr(masterDataAfter.other)) {
            returnData.otherData = masterDataAfter.other;
          }
          if (commonUtils.isNotEmptyArr(masterDataAfter.freight)) {
            returnData.freightData = masterDataAfter.freight;
          }
        } else {
          if(commonUtils.isNotEmptyObject(masterDataAfter.master)) {
            returnData.masterData = masterDataAfter.master;
          } else {
            returnData.masterData = masterDataAfter;
          }
        }
      }

      if (isWait) {
        return { ...returnData, ...addState, enabled: true };
      } else {
        this.props.onSaveState({ ...returnData, ...addState, enabled: true });
        return returnData;
      }
    }
    handleBtnPrint =async (sActiveId, checked, eKey) => {
      const {
        app, sModelsId, masterConfig, masterData, slaveConfig, sModelsType, reportData, menuChildData, formRoute, controlConfig,
      } = this.props;
      // if (sModelsType.includes('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中必填的三个字段
          // 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' && item.bNotEmpty);
          const dFractionQtyName = masterConfig.gdsconfigformslave.filter(item => item.sName === 'dFractionQty' && item.bNotEmpty);
          const dPackQtyName = masterConfig.gdsconfigformslave.filter(item => item.sName === 'dPackQty' && item.bNotEmpty);
          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 = (slavePagination) => {
      this.props.onSaveState({ slavePagination });
    };

    handleTitleChange1 = (name, slavePagination, filters, sorter) => {
      this.props.onSaveState({ [`${name}Pagination`]: slavePagination });
      const {
        slaveConfig, slaveFilterCondition, sGroupByList,[`${name}Config`] : tableConfig, [`${name}FilterCondition`]: tableFilterCondition,
      } = this.props;
      let bGetData = true;
      if (commonUtils.isNotEmptyObject(filters)) {
        for (const key of Object.keys(filters)) {
          if (commonUtils.isNotEmptyArr(filters[key])) {
            bGetData = false;
            break;
          }
        }
      }
      if (!bGetData) return;
      const { treeFilterCondition } = this.props;/* 树过滤条件 */
      const sort = sorter.order === 'ascend' ? 'asc' : 'desc';
      const slaveOrderBy = Object.keys(sorter).length > 0 ? { [sorter.columnKey]: sort } : ''; // 后端未支持空对象， 先用空表示
      if (commonUtils.isNotEmptyArr(treeFilterCondition)) { /* 判断是否有树过滤条件 */
        this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, '', sGroupByList, '', treeFilterCondition);
      } else {
        this.handleGetDataOne(name, tableConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy);
        // this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, '', sGroupByList, '', treeFilterCondition,
        //   slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, slave5Config, slave6Config, slave7Config, slave8Config, slave9Config, slave10Config,
        //   slave11Config, slave12Config,  slave13Config, slave14Config, slave15Config);
      }
    };

    /* 工单、工艺卡、报价单控制表回带图片地址 */
    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'));
      }
    }

    handleFilfileManageOk1 = async (params) => {
      const { controlFilfileData, controlFilfileDelData, sSrcSlaveId } = params;
      const {
        controlData: tableData, app, sModelsId, token, controlConfig,
      } = this.props;

      if (!commonUtils.isNotEmptyObject(sSrcSlaveId)) {
        message.warning(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));
        return;
      }

      // sMaterialsPicturePath:刀图 -> sType:2
      // sBeerMapPath:啤图 -> sType:1

      if (commonUtils.isNotEmptyArr(controlFilfileDelData)) {
        const addState = {};
        const iIndex = tableData.findIndex(item => item.sId === sSrcSlaveId);
        if (iIndex > -1) {
          const tableDataNewRow = tableData[iIndex];
          const { sMaterialsPicturePath, sBeerMapPath } = tableDataNewRow;
          const controlsMaterialsPictureDelData = controlFilfileDelData.filter(item => item.sType === '2');
          if (commonUtils.isNotEmptyArr(controlsMaterialsPictureDelData)) {
            controlsMaterialsPictureDelData.forEach((slaveItem) => {
              if (slaveItem.sPicturePath === sMaterialsPicturePath) {
                addState.sMaterialsPicturePath = '';
              }
            });
          }
          const sBeerMapPathDelPath = controlFilfileDelData.filter(item => item.sType === '1');
          if (commonUtils.isNotEmptyArr(sBeerMapPathDelPath)) {
            sBeerMapPathDelPath.forEach((slaveItem) => {
              if (slaveItem.sPicturePath === sBeerMapPath) {
                addState.sBeerMapPath = '';
              }
            });
          }
          if (commonUtils.isNotEmptyObject(addState) && (addState.sBeerMapPath === '' || addState.sMaterialsPicturePath === '')) {
            tableData[iIndex] = { ...tableDataNewRow, ...addState };
            const data = [];
            const updataData = {};
            const updateWhere = {};
            const column = {};
            if (addState.sMaterialsPicturePath === '') {
              column.sMaterialsPicturePath = addState.sMaterialsPicturePath;
            }
            if (addState.sBeerMapPath === '') {
              column.sBeerMapPath = addState.sBeerMapPath;
            }
            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, sBeerMapPath } = tableDataNewRow;
          const controlsMaterialsPictureData = controlFilfileData.filter(item => item.sType === '2');
          if (commonUtils.isNotEmptyArr(controlsMaterialsPictureData)) {
            let dataIndex = 0;
            const sDefaultLen = controlsMaterialsPictureData.filter(item => item.bDefault).length;
            if (sDefaultLen === 0) {
              notification.warning({ message: '提示', description: "【刀图】未设置默认启用项，取第一项数据", placement: 'topRight', duration: 2 });
            } else if (sDefaultLen > 1) {
              notification.warning({ message: '提示', description: "【刀图】设置了多个默认启用项，取第一项数据", placement: 'topRight', duration: 2 });
            } else {
              dataIndex = controlsMaterialsPictureData.findIndex(item => item.bDefault);
            }
            const sPicturePath = controlsMaterialsPictureData[dataIndex].sPicturePath;
            addState.sMaterialsPicturePath = commonUtils.isNotEmptyObject(sPicturePath) ? sPicturePath : ''; /* 上机默认取上传图片的第一条 */
          }
          const sBeerMapPathData = controlFilfileData.filter(item => item.sType === '1');
          if (commonUtils.isNotEmptyArr(sBeerMapPathData)) {
            let dataIndex = 0;
            const sDefaultLen = sBeerMapPathData.filter(item => item.bDefault).length;
            if (sDefaultLen === 0) {
              notification.warning({ message: '提示', description: "【啤图】未设置默认启用项，取第一项数据", placement: 'topRight', duration: 2 });
            } else if (sDefaultLen > 1) {
              notification.warning({ message: '提示', description: "【啤图】设置了多个默认启用项，取第一项数据", placement: 'topRight', duration: 2 });
            } else {
              dataIndex = sBeerMapPathData.findIndex(item => item.bDefault);
            }
            const sPicturePath = sBeerMapPathData[dataIndex].sPicturePath;
            addState.sBeerMapPath = commonUtils.isNotEmptyObject(sPicturePath) ? 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.sBeerMapPath) && addState.sBeerMapPath !== sBeerMapPath) {
              column.sBeerMapPath = addState.sBeerMapPath;
            }
            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);
              }
            }
          }
        }
      }
    }

    // 收付款分摊
    handleShare = () => {
      /* 分摊 */
      const {
        sModelsType, masterData: masterDataOld, slaveData: slaveDataOld, app,
      } = this.props;
      // if ((sModelsType.includes('cashier/receipt') && masterDataOld.sBillType !== 'customer') ||
      //   (sModelsType.includes('cashier/payment') && masterDataOld.sBillType !== 'supply')) {
      //   return masterDataOld;
      // }
      const { dNetMoney } = app.decimals;
      const masterData = { ...masterDataOld };
      const slaveData = [];
      if (commonUtils.isNotEmptyArr(slaveDataOld) && slaveDataOld.length > 0) {
        slaveDataOld.forEach((item) => {
          slaveData.push({ ...item });
        });
      }

      let dTotalMoney = masterData.dTotalMoney !== undefined ? masterData.dTotalMoney : 0;

      if (dTotalMoney === 0) {
        if (sModelsType === "cashier/payment") {
          /* 付款单1 */
          dTotalMoney = masterData.dMaterialsMoney;
        } else {
          dTotalMoney = masterData.dProductMoney;
        }
      }
      const models = sModelsType.includes("cashier/receipt") ? "Product" : "Materials";
      let minusSum = 0; /* 负数求和 */
      let minusRoundingSum = 0; /* 负数舍入求和 */
      const minusData = []; /* 负数集 */
      let positiveSum = 0; /* 正数求和 */
      let positiveRoundingSum = 0; /* 正数舍入求和 */
      const positiveData = []; /* 正数集 */
      if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) {
        slaveData.forEach((child) => {
          child.dTotalMoney = 0;
          child.dProductMoney = 0;
          child.dMaterialsMoney = 0;
          child.handleType = commonUtils.isEmpty(child.handleType) ? 'update' : child.handleType;
          child.dRoundingMoney = commonUtils.isNum(child.dRoundingMoney) ? child.dRoundingMoney : 0;
          child.dBalanceMoney =  commonUtils.convertFixNum(child.dBalanceMoney, dNetMoney);  /* 根据系统设定位数格式未付款金额*/
          if (child.dBalanceMoney < 0) {
            minusSum -= Math.abs(child.dBalanceMoney);
            minusRoundingSum -= Math.abs(child.dRoundingMoney);
            minusData.push(child);
          } else {
            const positiveSumTemp = commonUtils.convertFixNum(child.dBalanceMoney, dNetMoney) + commonUtils.convertFixNum(positiveSum, dNetMoney);
            positiveSum = commonUtils.convertFixNum(positiveSumTemp, dNetMoney);
            const positiveRoundingSumTemp = commonUtils.convertFixNum(child.dRoundingMoney, dNetMoney) + commonUtils.convertFixNum(positiveRoundingSum, dNetMoney);
            positiveRoundingSum = commonUtils.convertFixNum(positiveRoundingSumTemp, dNetMoney);
            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;
        }
        const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
        /* 分摊算外币金额 */
        if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) {
          slaveData.forEach((item, index) => {
            slaveData[index].dTotalForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? item.dTotalMoney / dCurrencyRate : 0, dNetMoney);
            slaveData[index].dProductForeignMoney = slaveData[index].dTotalForeignMoney;
            slaveData[index].dMaterialsForeignMoney = slaveData[index].dTotalForeignMoney;
            slaveData[index].dMaterialsMoney = slaveData[index].dTotalMoney;
            slaveData[index].dProductMoney = slaveData[index].dTotalMoney;
            console.log("111", slaveData[index]);
            console.log("222", models);
            if (models === "Materials" && commonUtils.isNotEmptyNumber(slaveData[index].dMaterialsQty)) {
              const dQty = slaveData[index].dMaterialsQty;
              const dMoney = slaveData[index].dMaterialsMoney;
              slaveData[index].dMaterialsPrice = commonUtils.convertFixNum(dMoney / dQty, 6);
              slaveData[index].dMaterialsForeignPrice = commonUtils.convertFixNum(slaveData[index].dMaterialsForeignMoney / dQty, 6);
            } else if (commonUtils.isNotEmptyNumber(slaveData[index].dProductQty)) {
              const dQty = slaveData[index].dProductQty;
              const dMoney = slaveData[index].dProductMoney;
              slaveData[index].dProductPrice = commonUtils.convertFixNum(dMoney / dQty, 6);
              slaveData[index].dProductForeignPrice = commonUtils.convertFixNum(slaveData[index].dProductForeignMoney / dQty, 6);
            }

            console.log("eeeee", slaveData[index]);
          });
        }
        masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
        if (commonUtils.isNotEmptyNumber(masterData.dTotalMoney)) {
          masterData.dProductForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? masterData.dTotalMoney / dCurrencyRate : 0, dNetMoney);
        }
        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;
          }
        }
        const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
        /* 分摊算外币金额 */
        if (commonUtils.isNotEmptyArr(slaveData) && slaveData.length > 0) {
          slaveData.forEach((item, index) => {
            slaveData[index].dTotalForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? item.dTotalMoney / dCurrencyRate : 0, dNetMoney);
            slaveData[index].dProductForeignMoney = slaveData[index].dTotalForeignMoney;
            slaveData[index].dMaterialsForeignMoney = slaveData[index].dTotalForeignMoney;
            slaveData[index].dMaterialsMoney = slaveData[index].dTotalMoney;
            slaveData[index].dProductMoney = slaveData[index].dTotalMoney;
            console.log("333", slaveData[index].dMaterialsQty);
            console.log("441", models);
            if (models === "Materials" && commonUtils.isNotEmptyNumber(slaveData[index].dMaterialsQty)) {
              const dQty = slaveData[index].dMaterialsQty;
              const dMoney = slaveData[index].dMaterialsMoney;
              slaveData[index].dMaterialsPrice = commonUtils.convertFixNum(dMoney / dQty, 6);
              slaveData[index].dMaterialsForeignPrice = commonUtils.convertFixNum(slaveData[index].dMaterialsForeignMoney / dQty, 6);
            } else if (commonUtils.isNotEmptyNumber(slaveData[index].dProductQty)) {
              const dQty = slaveData[index].dProductQty;
              const dMoney = slaveData[index].dProductMoney;
              slaveData[index].dProductPrice = commonUtils.convertFixNum(dMoney / dQty, 6);
              slaveData[index].dProductForeignPrice = commonUtils.convertFixNum(slaveData[index].dProductForeignMoney / dQty, 6);
            }
          });
        }
        masterData.dAdvanceMoney = 0;
        masterData.bAdvance = false;
        masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType; /* 主表分摊算外币金额 */
        if (commonUtils.isNotEmptyNumber(masterData.dTotalMoney)) {
          masterData.dProductForeignMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? masterData.dTotalMoney / dCurrencyRate : 0, dNetMoney);
        }
        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 (num) => {
      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}&num=${num}`;
      } else {
        url = `${commonConfig.server_host}eleMaterialsStock/getEleMaterialsStock?sModelsId=${sModelsId}&sWareHouseId=${masterData.sWareHouseId}&num=${num}`;
      }

      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, index) => {
          const tableDataRow = this.handleTableAdd('slave', true);
          item.handleType = 'add';
          item.sParentId = masterData.sId;
          item.iOrder = index + 1;
          returnData[index] = { ...tableDataRow, ...item };
        });
        this.props.onSaveState({ slaveData: returnData, slaveDelData });
      } else {
        this.props.getServiceError(dataReturn);
      }
      this.props.onSaveState({ isGetDataVisible: false });
    };

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

    /* 导出模版数据 */
    handleOutTemplateData = async () => {
      const {
        slaveConfig, formRoute, masterData, sortedInfo,
      } = this.props;
      const sort = commonUtils.isNotEmptyObject(sortedInfo) ? sortedInfo.order === 'ascend' ? 'asc' : 'desc' : '';
      const slaveOrderBy = commonUtils.isNotEmptyObject(sortedInfo) && Object.keys(sortedInfo).length > 0 ? { [sortedInfo.columnKey]: sort } : ''; //
      const sId = commonUtils.isNotEmptyObject(masterData) ? masterData.sId : '';
      if (commonUtils.isNotEmptyObject(sId)) {
        const sSqlCondition = { sParentId: sId };
        let url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.sParentId}&token=${this.props.app.token}&sName=${formRoute}`;
        if (commonUtils.isNotEmptyObject(sSqlCondition)) {
          url = `${url}&sSqlCondition=${encodeURIComponent(JSON.stringify(sSqlCondition))}`;
        }
        if (slaveOrderBy !== undefined && slaveOrderBy !== '' && Object.keys(slaveOrderBy).length > 0) {
          url = `${url}&sFilterOrderBy=${encodeURIComponent(JSON.stringify(slaveOrderBy))}`;
        }
        window.open(url);
      } else {
        message.warn('没有主表数据！');
      }
    };


    /* 导入未清数据 */
    handleImportFormData = () => {
      const { masterData, sModelsType } = this.props;
      if (commonUtils.isNotEmptyObject(masterData)) {
        let bFilterProValue = '';
        let bFilterProName = '';
        if (sModelsType === 'cashier/payment') { /* 付款单 */
          const { sSupplyName, sSupplyId } = masterData;
          if (commonUtils.isEmptyObject(sSupplyName)) {
            message.error('供应商名称不能为空!');
            return;
          } else {
            bFilterProName = 'sSupplyGuid_pro';
            bFilterProValue = sSupplyId;
          }
        } else if (sModelsType === 'cashier/receipt') { /* 收款单 */
          const { sCustomerName, sCustomerId } = masterData;
          if (commonUtils.isEmptyObject(sCustomerName)) {
            message.error('客户名称不能为空!');
            return;
          } else {
            bFilterProName = 'sCustomerGuid_pro';
            bFilterProValue = sCustomerId;
          }
        }
        this.props.onSaveState({ importFormDataVisible: true, bFilterProName, bFilterProValue });
      }
    }
    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 });
      }
    };

    /* 有外币时，配置BtnBatchNPriceUpdate， 会调用这个方法 */
    handleBatchNPriceUpdate = () => {
      const { slaveData, slaveSelectedRowKeys, app } = this.props;
      if (slaveSelectedRowKeys === undefined || slaveSelectedRowKeys.length !== 1) {
        return message.warning(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请选择一条数据进行操作 */
      } else {
        const batchNPriceUpdateData = slaveData.filter(item => item.sId === slaveSelectedRowKeys[0]);
        this.props.onSaveState({ batchNPriceUpdateData, visibleBatchNPriceUpdate: true });
      }
    };

    /* 解析消息 */
    handleGetMsg = (str) => {
      const msgArr = commonUtils.isNotEmptyObject(str) ? str.split('xpm'): '';
      const divStr = [];
      if(commonUtils.isNotEmptyArr(msgArr)) {
        for (let i = 0; i < msgArr.length; i ++) {
          divStr.push(<p>{msgArr[i]}</p>);
        }
      }
      return divStr;
    }

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

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

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

    /** 按钮操作事件 */
    handleButtonClick = async (name) => {

      const FriendlyReminder = commonFunc.showLocalMessage(this.props, 'FriendlyReminder', '温馨提示');

      if (name === 'BtnOut') {
        this.handleOut();
      } else if (name === 'BtnDesignFunction') {
        this.handleDesignFunction();
      } else if (name === 'BtnBatchPriceUpdate') {
        this.handleBatchPriceUpdate();
      } else if (name === 'BtnBatchNPriceUpdate') {
        this.handleBatchNPriceUpdate();
      } else if (name === 'BtnOutTemplate') {
        this.handleOutTemplate();
      } else if (name === 'BtnOutTemplateData') { /* 导出模版数据 */
        this.handleOutTemplateData();
      }else if (name === 'BtnShowAll') { /* 显示全部部件 */
        this.handleTableCancelSelect('slave');
      } else if (name === 'BtnShowControl') { /* 显示部件层级 */
        const {  controlData } = this.props;
        const expandedRowKeys =[];
        if(commonUtils.isNotEmptyArr(controlData)) { /* 当显示全部时 展开所有部件层级  */
          controlData.forEach((item) => {
            const { sId } = item;
            expandedRowKeys.push(sId);
          });
        }
        this.props.onSaveState({  showAllTreeVisible: true, controlShowExpandedRowKeys: { expandedRowKeys: expandedRowKeys } });
      } else if (name === 'BtnRefresh') {
        if (this.props.app.currentPane.refresh !== undefined) {
          this.props.app.currentPane.refresh();
        }
        const { masterConfig, slaveConfig, checkConfig } = this.props;
        this.handleGetData(masterConfig, slaveConfig, checkConfig);
      } else if(name && name.includes('BtnTempSql')) { /* 通过BtnTempSql按钮 自定义调用Sql 并将数据回填到界面上 */
        const { masterConfig, slaveConfig, sModelsId, token } = this.props;
        let {  masterData,slaveData } = this.props;
        const slave0Data = [];
        const slave1Data = [];
        const slave2Data = [];
        const slave3Data = [];
        const slave4Data = [];
        const copyTo ={};
        copyTo.name = name;
        copyTo.slaveData = slaveData;
        const buttonConfigArr = masterConfig &&  masterConfig.gdsconfigformslave.filter(item => item.sControlName && item.sControlName.includes('BtnTempSql'));
        const allConfig = {
          slaveConfig, masterConfig,
        };
        if(commonUtils.isNotEmptyArr(buttonConfigArr)) {
          copyTo.config = buttonConfigArr;
          const sTmpInfoConfig = buttonConfigArr.filter(item => item.sControlName && item.sControlName.includes('BtnTempSql'))[0];
          const sControlName = sTmpInfoConfig.sControlName;
          const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
          const sConfigformId = commonUtils.isEmpty(sTmpInfoConfig) ? '' : sTmpInfoConfig.sParentId;
          if (commonUtils.isNotEmptyObject(sTmpInfoConfig)) {
            const newCopyTo = {};
            newCopyTo.master = copyTo.masterData;
            newCopyTo.slave = commonUtils.isEmpty(copyTo.slaveData) ? [] : copyTo.slaveData[0];
            // const sRowData = copyTo.slaveData;
            const sRowData = [masterData];
            const condition = { sConfigformId, sControlName, sRowData };
            const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
            if (dataReturn.code === 1) {
              slaveData = [];
              const returnData = dataReturn.dataset.rows[0];
              const copyToMasterDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.masterdetail`.toLowerCase());
              const copyToSlaveConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave`.toLowerCase());
              const copyToSlaveDetailConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slavedetail`.toLowerCase());
              const copyToSlave1Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave1`.toLowerCase());
              const copyToSlave0Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave0`.toLowerCase());
              const copyToSlave2Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slave2`.toLowerCase());
              const copyToSlava3Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava3`.toLowerCase());
              const copyToSlava4Config = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.slava4`.toLowerCase());
              const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : '';
              const salveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : '';
              const salveAssignField = commonUtils.isNotEmptyArr(copyToSlaveConfig) ? copyToSlaveConfig[0].sAssignField : '';
              const slave1AssignField = commonUtils.isNotEmptyArr(copyToSlave1Config) ? copyToSlave1Config[0].sAssignField : '';
              const slave0AssignField = commonUtils.isNotEmptyArr(copyToSlave0Config) ? copyToSlave0Config[0].sAssignField : '';
              const slave2AssignField = commonUtils.isNotEmptyArr(copyToSlave2Config) ? copyToSlave2Config[0].sAssignField : '';
              const slave3AssignField = commonUtils.isNotEmptyArr(copyToSlava3Config) ? copyToSlava3Config[0].sAssignField : '';
              const slave4AssignField = commonUtils.isNotEmptyArr(copyToSlava4Config) ? copyToSlava4Config[0].sAssignField : '';
              if (commonUtils.isNotEmptyArr(returnData.master) && masterDetailAssignField) {
                masterData = { ...masterData, ...commonFunc.getAssignFieldValue(masterDetailAssignField, returnData.master[0], newCopyTo) };
              }
              if (commonUtils.isNotEmptyArr(returnData.slave)) {
                returnData.slave.forEach((slaveItem) => {
                  newCopyTo.slave = slaveItem;
                  const newSid = commonUtils.createSid();
                  let slaveRow = commonFunc.getDefaultData(allConfig.slaveConfig, newCopyTo, { newSid }); // 取默认值
                  if (salveDetailAssignField) {
                    slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo) };
                  } else if (salveAssignField) {
                    slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
                  }
                  slaveRow.handleType = 'add';
                  slaveRow.sId = newSid;
                  slaveRow.sParentId = masterData.sId;
                  slaveData.push(slaveRow);
                });
              }

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

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

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

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

              if (commonUtils.isNotEmptyArr(returnData.slave4)) {
                returnData.slave4.forEach((slave4Item) => {
                  newCopyTo.slave4 = slave4Item;
                  const newSid = commonUtils.createSid();
                  let slave4Row = commonFunc.getDefaultData(allConfig.slave4Config, newCopyTo, { newSid }); // 取默认值
                  slave4Row = { ...slave4Row, ...commonFunc.getAssignFieldValue(slave4AssignField, slave4Item, newCopyTo) }; // 取赋值字段
                  slave4Row.handleType = 'add';
                  slave4Row.sId = newSid;
                  slave4Row.sParentId = masterData.sId;
                  slave4Data.push(slave4Row);
                });
              }
              this.props.onSaveState({ slaveData, slave1Data, slave2Data, slave3Data, slave4Data});
            } else {
              this.props.getServiceError(dataReturn);
            }
          }
        } else {
          message.error('请正确配置自定义按钮！');
        }
      }else if (name && name.includes('BtnCalc')) { /* 实现通用计算功能 */
        const { masterConfig, masterData, sModelsId, } = this.props;
        this.props.onSaveState({
          pageLoading: true
        });
        const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))) ?
          masterConfig.gdsconfigformslave.filter(item => (item.sControlName === name))[0] : {};// sButtonEnabled  sButtonParam
        if(commonUtils.isNotEmptyObject(btnConfig)) {
          /* 组装allTableData */
          const allTableMap ={};
          const allReturnMap ={};
          const  slaveNameList = [];
          /* 从props找到 所有的Config */
          if(commonUtils.isNotEmptyArr(this.props)) {
            for (const key of Object.keys(this.props)) {
              if(key.includes('Config') && !key.includes('onGet') && !key.includes('report')) {
                const tablename =  key.replace('Config', '').trim();
                if (this.props.sModelsType === 'manufacture/workOrder3') {
                  if (tablename === 'materials') continue;
                }
                slaveNameList.push(tablename);
              }
            }
          }

          if (commonUtils.isNotEmptyArr(slaveNameList)) {
            slaveNameList.forEach((name, index) => {
              const tableConfig = this.props[name +'Config']; /* 动态配置 */
              if(commonUtils.isNotEmptyObject(tableConfig)) {
                const tableData = this.props[name +'Data']; /* 动态配置 */
                const tableSelectedRowKeys  = this.props[name + 'SelectedRowKeys']; /* 选中Key */
                allTableMap[name +'.'+ tableConfig.sTbName]  = tableData
              }
            })
            const masterTbName = masterConfig.sTbName;
            allTableMap['master.'+ masterTbName] = masterData;
          }
          const sButtonParam = btnConfig.sButtonParam;
          const btn = 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)) {
              if (this.props.sModelsType === 'manufacture/workOrder3') {
                slaveNameList.push('materials');
              }
              slaveNameList.forEach((name, index) => {
                const tableConfig = this.props[name +'Config']; /* 动态配置 */
                let tableDelData =  this.props[name +'DelData'];
                if(commonUtils.isEmptyArr(tableDelData)) {
                  tableDelData = [];
                }
                if (name === 'materials') {
                  if (this.props.sModelsType === 'manufacture/workOrder3') {
                    const tableData = this.props[name +'Data']; /* 动态配置 */
                    returnData[name +'.'+ tableConfig.sTbName]  = tableData;
                  }
                }
                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.master = returnData['master.'+ masterTbName];
              console.log('计算返回', allReturnMap);
            }
            this.props.onSaveState({ ...allReturnMap, pageLoading:false, });
          }else if (dataReturn.code === -8 || dataReturn.code === 2) {
            Modal.info({
              title: FriendlyReminder,
              content: (
                <div>
                  {this.handleGetMsg(dataReturn.msg)}
                </div>
              ),
              onOk() {},
            });
            this.props.onSaveState({ ...allReturnMap, pageLoading:false, });
          } else { /*   失败   */
            this.props.getServiceError(dataReturn);
            this.props.onSaveState({ pageLoading:false, });
          }

        }
      } else if (name && name.includes('BtnViewPartsInfo')) {
        const partsInfoType = name.split('_')[1];
        const { masterConfig } = this.props;
        const btnConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName === name);
        const sCusModelId = '12710101117151497988680';
        const slaveGuidConfig = await this.handleGetFormConfig(sCusModelId);
        this.props.onSaveState({
          partsInfoModalVisible: true,
          partsInfoModalTitle: btnConfig[0].showName,
          partsInfoType,
          partsInfoBtnConfig: btnConfig[0],
          slaveGuidConfig
        });
      } else if (name === 'BtnTmpInfoBySql') { /* 自定义数据源 */
        this.handleBtnTmpInfoBySql(name);
      }
      const { sModelsType } = this.props;
      // 收付款分摊
      if (sModelsType.includes('cashier/') || sModelsType.includes('sales/') || sModelsType.includes('purchase/')) {
        if (name === 'BtnShare') {
          this.handleShare();
        }
        if (sModelsType.includes('cashier/') && name === 'BtnImportFormData') { /* 导入未清数据 */
          this.handleImportFormData(name);
        }
      } else if (sModelsType.includes('materialsStock/') || sModelsType.includes('productStock/')) {
        if (name === 'BtnImport') {
          this.props.onSaveState({ isGetDataVisible: true });
        }
      }
    };

    handleBtnTmpInfoBySql = async (btnName) => {
      const { masterConfig, masterData, slaveConfig, slaveData, slaveSelectedRowKeys, token, sModelsId} = this.props;
      let slaveRow = {};
      if(commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId));
        if(iIndex > -1) {
          slaveRow = slaveData[iIndex];
        }
      } else {
        slaveRow = slaveData[0];
      }
      const tableConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === btnName)) ?
        masterConfig.gdsconfigformslave.filter(item => item.sControlName === btnName)[0] : {};
      const sTmpInfoConfig = tableConfig;
      const sButtonParam = tableConfig.sButtonParam;
      const btn = commonUtils.isNotEmptyObject(sButtonParam) ?  JSON.parse(sButtonParam) : '';
      if(commonUtils.isNotEmptyObject(btn)) {
        const sProName = commonUtils.isNotEmptyObject(btn) ? btn.sproName : '';
        const sTmpInfoBySqlBtnName = btn.sControlName;
        const newCopyTo = {};
        newCopyTo.master = masterData;
        /* 找到自定义TempInfo配置1111 */
        const sTmpInfoBySqlBtnConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes(sTmpInfoBySqlBtnName));
        const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
        const sConfigformId = commonUtils.isEmpty(sTmpInfoBySqlBtnConfig) ? '' : sTmpInfoBySqlBtnConfig[0].sParentId;
        const sControlName = commonUtils.isNotEmptyObject(sTmpInfoBySqlBtnName) ? sTmpInfoBySqlBtnName : 'TmpInfoBySql';
        const sAssignField = sTmpInfoBySqlBtnConfig[0].sAssignField;
        const sRowData = [slaveRow];
        /* 如果sqlCondition条件 不在rowData中 则添加 */
        const sSqlCondition =  sTmpInfoBySqlBtnConfig[0].sSqlCondition;
        if(commonUtils.isNotEmptyObject(sSqlCondition)) {
          let name = '';  /* 拿到条件表名 */
          let conditionValues = {};
          if(sSqlCondition.includes('.')) {
            let newRow = {};
            const name = sSqlCondition.split('.')[0];
            if(name === 'master') {
              newRow = masterData;
            }
            conditionValues = this.props.getSqlCondition(sTmpInfoBySqlBtnConfig[0], name, newRow);
            if(commonUtils.isNotEmptyObject(conditionValues)) {
              for (const key of Object.keys(conditionValues)) {
                if(commonUtils.isNotEmptyArr(sRowData)) {
                  if(commonUtils.isEmptyObject(sRowData[0][key])) {
                    sRowData[0][key] = conditionValues[key];
                  }
                }

              }
            }
          }
        }
        const values = { sConfigformId, sControlName, sRowData };
        if (true) {
          const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
          const allReturnMap = {};
          if (dataReturn.code === 1) {
            const returnData = dataReturn.dataset.rows[0];
            if (commonUtils.isNotEmptyObject(returnData)) {
              for (const key of Object.keys(returnData)) {
                const sName = `${key}Data`;
                const sDelName = `${key}DelData`;
                // allReturnMap[sName] = returnData[key];
                let { [`${key}Data`]: oldData, [`${key}Data`]: oldDelData } = this.props;

                if (commonUtils.isEmptyArr(oldDelData)) {
                  oldDelData = [];
                }
                if (commonUtils.isEmptyArr(oldData)) {
                  oldData = [];
                }
                if (sTmpInfoBySqlBtnName.includes('_edit')) { /* 替换 根据对应字段对比 相同的不管 不同的插入  */
                  /* 对应字段 */
                  const sActiveKey = sTmpInfoBySqlBtnConfig[0].sActiveKey;
                  const keyData = returnData[key];
                  let newData = [];
                  if (commonUtils.isNotEmptyArr(keyData)) {
                    keyData.forEach((child) => {
                      const filterData = oldData.filter(item => item[sActiveKey] !== child[sActiveKey]);
                      if (commonUtils.isNotEmptyArr(filterData) && filterData.length === oldData.length) {
                        let tableRow = {};
                        tableRow = { ...tableRow, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段
                        tableRow.sId = commonUtils.createSid();
                        tableRow.sParentId = masterData.sId;
                        tableRow.handleType = 'add';
                        newData.push(tableRow);
                      }
                    });
                    newData = oldData.concat(newData)
                  }
                  allReturnMap[sName] = newData;
                } else if (sTmpInfoBySqlBtnName.includes('_del')) { /* 替换 根据对应字段对比 相同的不管 不同的插入  */
                  /* 对应字段 */
                  oldData.forEach((child) => {
                    child.handleType ='del';
                    oldDelData.push(child);
                  });
                  allReturnMap[sDelName] = oldDelData;
                  oldData = [];
                  console.log('returnData', returnData[key]);
                  const keyData = returnData[key];
                  if (commonUtils.isNotEmptyArr(keyData)) {
                    keyData.forEach((child) => {
                      const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段
                      tableRow.sId = commonUtils.createSid();
                      tableRow.sParentId = masterData.sId;
                      tableRow.handleType = 'add';
                      oldData.push(tableRow);
                    });
                  }
                  allReturnMap[sName] = oldData;
                } else {
                  allReturnMap[sName] = returnData[key];
                }

              }
              if (commonUtils.isNotEmptyArr(allReturnMap.masterData) && Array.isArray(allReturnMap.masterData)) {
                allReturnMap.masterData = allReturnMap.masterData[0];
                if(commonUtils.isNotEmptyObject(allReturnMap.masterData.customConfig)) {
                  const columnConfig = JSON.parse(allReturnMap.masterData.customConfig);
                  console.log('columnConfig:', columnConfig);
                  const newConfig =JSON.parse(JSON.stringify(slaveConfig));
                  let buttonConfig = [];
                  if(commonUtils.isNotEmptyArr(slaveConfig?.gdsconfigformslave)) {
                    buttonConfig = slaveConfig?.gdsconfigformslave.filter(item => commonUtils.isEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sControlName) );
                  }
                  newConfig.gdsconfigformslave = columnConfig.concat(buttonConfig);
                  allReturnMap.slaveConfig = newConfig;
                }
              }
              console.log('allReturnMap:', allReturnMap);
              this.props.onSaveState({ ...allReturnMap });
            }
          } else {
            this.props.getServiceError(dataReturn);
          }
        }
      } else {
        message.error('配置错误，没有配置对应字段！');
      }

    }

    handleBtnChoose = async (name, sControlName, chooseConfig, recordIndex, tableName) => {
      const { token } = this.props;
      const { processSelectedRowKeys } = this.props;
      /* 如果是材料 则校验必须选择工序 */
      if(name === 'materials') {
        if (commonUtils.isEmptyArr(processSelectedRowKeys)) {
          message.warning('请选择对应工序');
          return;
        }
      }
      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, slaveSelectedIndex: recordIndex, tableName,
        });
      } else {
        this.props.getServiceError(dataReturn);
      }
    };

    handleSelect = (name, selectConfig, selectData) => {
      const {
        [`${name}Data`]: tableData, [`${name}Config`]: tableConfig, masterData, slaveSelectedIndex,
      } = this.props;
      if (commonUtils.isNotEmptyArr(selectData)) {
        selectData.forEach((item, index) => {
          const newCopyTo = {};
          newCopyTo.master = masterData;
          // newCopyTo.slave = item;
          const newSid = commonUtils.createSid();
          let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo, { newSid }); // 取默认值
          tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
          tableDataRow.handleType = 'add';
          tableDataRow.sId = newSid;
          tableDataRow.sParentId = masterData.sId;
          if (name === 'slave' && selectConfig.sControlName === 'BtnChooseMaterials' && index === 0 && (commonUtils.isEmpty(tableData[slaveSelectedIndex].sProductName) || tableData[slaveSelectedIndex].sProductName === '')) {
            tableData[slaveSelectedIndex] = { ...tableData[slaveSelectedIndex], ...tableDataRow };
          } else {
            tableData.push(tableDataRow);
          }
        });
      }
      this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}ChooseVisible`]: false });
    };

    handleSelectCancel = (name) => {
      if (name === 'process') this.isSColorSerialMemo.current = false;
      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) {
              const sMaterialsName = commonUtils.isEmpty(item.sMaterialsName) ? item.sMaterialsName1 : item.sMaterialsName;
              message.error(`[${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;
    }
    handleTableSelectRowChange = async (name, selectedRowKeys, changeValue, isWait) => {
      if (name === 'slave' || name === 'master') {
        const { token, sModelsId, [`${name}Data`]: tableData } = this.props;
        if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectedRowKeys)) {
          let url = '';
          let sCustomerId = '';
          if (sModelsId === '192116810113315228246447250' || sModelsId === '101251240115015952245193980' || sModelsId === '12710101117015005250780') {
            if (name === 'master') {
              sCustomerId = changeValue.sCustomerId;
            } else if (name === 'slave') {
              const sCustomerIdIndex = tableData.findIndex(item => item.sId === selectedRowKeys[0]);
              if (sCustomerIdIndex > -1) {
                sCustomerId = tableData[sCustomerIdIndex].sCustomerId;
              }
            }
            if (commonUtils.isNotEmptyObject(sCustomerId)) {
              url = `${commonConfig.file_host_ebc}printReport/getReportByCustomerId/${sCustomerId}?sModelsId=${sModelsId}`;
              const values = {};
              const masterReturn = (await commonServices.postValueService(token, values, url)).data;
              if (masterReturn.code === 1) {
                const menuChildData = masterReturn.dataset.rows;
                this.props.onSaveState({ menuChildData });
              }
            }
          } else {
            let sProcessId = '';
            if (name === 'master') {
              sProcessId = changeValue.sProcessClassifyId;
            } else if (name === 'slave') {
              const sProcessIdIndex = tableData.findIndex(item => item.sId === selectedRowKeys[0]);
              if (sProcessIdIndex > -1) {
                sProcessId = tableData[sProcessIdIndex].sProcessClassifyId;
              }
            }
            if (commonUtils.isNotEmptyObject(sProcessId)) {
              url = `${commonConfig.file_host_ebc}printReport/getReportByProcessId/${sProcessId}?sModelsId=${sModelsId}`;
              const values = {};
              const masterReturn = (await commonServices.postValueService(token, values, url)).data;
              if (masterReturn.code === 1) {
                const menuChildData = masterReturn.dataset.rows;
                this.props.onSaveState({ menuChildData });
              }
            }
          }
        }
      } else if (name === 'control') {
        const { treeData, sModelsType } = this.props; /* 赋值给树组件节点 */
        if (sModelsType === 'sales/salesOrderPack') {
          let { treeSelectedKeys } = this.props; /* 赋值给树组件节点 */
          if (treeData !== undefined) {
            treeSelectedKeys = selectedRowKeys; /* 把树形选中节点赋值给表格部件选中节点 */
            this.props.onSaveState({ treeSelectedKeys });
          }
        }
      } else if (name === 'sParam' && commonUtils.isNotEmptyArr(selectedRowKeys)) {
        /* 点击工艺参数列表 根据点击行动态加载配置 */
        const { sParamData, sParamConfig } = this.props;
        /* 找到最后一个选中 */
        const lastSelectedKeys = selectedRowKeys[selectedRowKeys.length - 1];
        const iIndex = sParamData.findIndex(item => lastSelectedKeys === item.sId);
        /* 选中数据时 塞入选中行的配置 */
        if (iIndex > -1) {
          const sParamObj = sParamData[iIndex];
          const index = sParamConfig.gdsconfigformslave.findIndex(item => item.sName === 'sParamValue');
          if (index > -1) {
            if (commonUtils.isNotEmptyObject(sParamObj.sDropDownData)) {
              sParamConfig.gdsconfigformslave[index].sDropDownType = 'const';
              sParamConfig.gdsconfigformslave[index].showDropDown = JSON.stringify(sParamObj.sDropDownData);
            } else {
              sParamConfig.gdsconfigformslave[index].sDropDownType = '';
              sParamConfig.gdsconfigformslave[index].showDropDown = undefined;
            }
          }
          /* 点击时 若没打钩 则选择框打钩 若已经打钩则取消打钩 */
          if (sParamData[iIndex].bSelfCbx) {
            // sParamData[iIndex] = { ...sParamData[iIndex], bSelfCbx: false };
          } else {
            sParamData[iIndex] = { ...sParamData[iIndex], bSelfCbx: true };
          }
          this.props.onSaveState({
            sParamData,
          });
        }
      }
      /* 点按钮删除时，会触发行点击事件 导致selectedRowKeys为删除行的sId */
      const { [`${name}Data`]: tableData } = this.props;
      if (Array.isArray(tableData) && tableData.length > 0 && selectedRowKeys.length) {
        const iIndex = tableData.findIndex(item => item.sId === selectedRowKeys[0]);
        if (iIndex === -1) {
          if (commonUtils.isNotEmptyArr(tableData) && tableData.length > 0) {
            selectedRowKeys = commonUtils.isNotEmptyArr(tableData) ? [tableData[0].sId] : [];
          }
        }
      }
      if (isWait) {
        return await this.props.onTableSelectRowChange(name, selectedRowKeys, isWait);
      } else {
        this.props.onTableSelectRowChange(name, selectedRowKeys);
      }
    }

    /* 取消表格行选中 */
    handleTableCancelSelect= (name) => {
      const { [`${name}SelectedRowKeys`]: tableSelectedRowKeys } = this.props;
      if (name === 'slave') {
        this.props.onSaveState({
          [`${name}SelectedRowKeys`]: [], controlSelectedRowKeys :[], processSelectedRowKeys :[], materials0SelectedRowKeys :[],
        });
      }
    }

    // 获取重量
    handleGetWeight = async () => {
      const { masterConfig, app } = this.props;
      const url = app.rxtx.sUrl;
      const returnData = (await commonServices.getService(app.token, url)).data;
      if (returnData.code === 1) {
        const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnGetWeight');
        const sAssignField = masterConfig.gdsconfigformslave[iConfigIndex].sAssignField;
        const sAssignFieldStr = sAssignField.split(':')[0];
        const sAssignFieldName = sAssignFieldStr.split('.')[0];
        const sAssignFieldKey = sAssignFieldStr.split('.')[1];
        const dWeight = returnData.dataset.rows[0].dWeight;
        if (commonUtils.isNotEmptyObject([`${sAssignFieldName}Data`])) {
          const { [`${sAssignFieldName}Data`]: tableData } = this.props;
          tableData[tableData.length - 1][sAssignFieldKey] = dWeight;
          this.props.onSaveState({ tableData: [`${sAssignFieldName}Data`] });
        }
      } else {
        this.props.getServiceError(returnData);
      }
    }
    handleViewClick = (name, sName, record, index, myConfig, configName) => {
      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 < 11; 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()}`];
              if (!commonUtils.isEmpty(record[`sParamDropDown${i.toString()}`])) {
                processConfig.gdsconfigformslave[iIndex].sDropDownType = 'sql';
              } else {
                processConfig.gdsconfigformslave[iIndex].sDropDownType = '';
              }
              // 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;
            }
          }
        } else {
          modalVisible = false;
          // eslint-disable-next-line no-plusplus
          for (let i = 1; i < 11; 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 === 'sQuoParams') { // 产品工艺卡报价参数
        const { processConfig, enabled, sModelsType } = this.props;
        const NoQuoParameters = commonFunc.showLocalMessage(this.props, 'NoQuoParameters', '无报价参数！');
        const slaveSelectOneData = record;
        let modalVisible = false;
        const sProcessParamsSelects = [];
        let sParamData = [];
        let paramType = '';
        if (commonUtils.isNotEmptyObject(slaveSelectOneData)) {
          paramType = slaveSelectOneData.sProcessParam;
        }
        if(commonUtils.isEmpty(paramType)) {
          message.warn(NoQuoParameters);
          return;
        }
        /* 工序参数以表格形式展示 列 */
        const sParamConfig = {
          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,
        }];
        sParamConfig.gdsconfigformslave = gdsconfigformslave;
        const sParamColumn = commonFunc.getHeaderConfig(sParamConfig);
        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') && !key.includes('FieldName')) {
              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]; /* 默认值 */
              }
              sParamData.push(obj);
            }
          }
          /* 将sParam1中的数据 还原到sParamData数据中 */
          if(commonUtils.isNotEmptyObject(record.sQuoParams)) {
            const selectedData = JSON.parse(record.sQuoParams);
            if(commonUtils.isNotEmptyArr(selectedData)) {
              selectedData.forEach((itemS) => {
                const iIndex = sParamData.findIndex(item => item.sParamName === itemS.sParamName);
                if(iIndex > -1) {
                  const addState ={};
                  addState.sParamValue = itemS.sParamValue;
                  addState.bSelfCbx = itemS.bSelfCbx;
                  sParamData[iIndex] ={...sParamData[iIndex], ...addState};
                }
              });
            }

            /* 如果数据集有一个是非选中的则非选中状态 否则全选 */
            if(commonUtils.isNotEmptyArr(sParamColumn)) {
              const iIndex = sParamColumn.findIndex(item => item.dataIndex ==='bSelfCbx');
              if(iIndex > -1) {
                const filterData = sParamData.filter(item => !item.bSelfCbx);
                if(commonUtils.isNotEmptyArr(filterData)) {
                  sParamColumn[iIndex] ={ ...sParamColumn[iIndex], bCheckAll:false};
                }else {
                  sParamColumn[iIndex] ={ ...sParamColumn[iIndex], bCheckAll:true};
                }
              }
            }
          }
        }
        this.props.onSaveState({
          processRecord: record,
          sProcessParamsSelects,
          sParamsModalVisible: true,
          sParamConfig,
          sParamColumn,
          sParamData,
          sParamModalType:'sQuo'
        });
      } else if (name === 'process' && sName === '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)) {
          paramType = slaveSelectOneData.sWorkOrderParam;
        }
        if(commonUtils.isEmpty(paramType)) {
          const NoProcessParameters = commonFunc.showLocalMessage(this.props, 'NoProcessParameters', '无工艺参数！');
          message.warn(NoProcessParameters);
          return;
        }
        /* 工序参数以表格形式展示 列 */
        const sParamConfig = {
          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,
        }];
        sParamConfig.gdsconfigformslave = gdsconfigformslave;
        const sParamColumn = commonFunc.getHeaderConfig(sParamConfig);
        if (commonUtils.isNotEmptyObject(paramType)) {
          /* 要把数据以表格的形式显示出来 */
          let sParamJsonObj = commonUtils.convertStrToObj(paramType, []);

          if(location.pathname ==='/indexPage/processCardPackTableTree') {
          /* 增加印面配置到工艺参数中 */
          let iFaceValue = '';
          if( commonUtils.isNotEmptyObject(record) && record.iFace !== undefined) {
            if(record.iFace === 0) {
              iFaceValue = '正面';
            }else if(record.iFace === 1) {
              iFaceValue = '反面';
            }else if(record.iFace === 2) {
              iFaceValue = '双面';
            }
          }
           /* 设置印面配置 */
          const sParam1000 = {
            sParam1000: '印面',
            sParamDefault1000: iFaceValue,
            sParamDropDown1000:{'':'','正面':'正面','反面':'反面','双面':'双面'},
          }
          /* 设置色序配置 */
          const sParam1001 = {
            sParam1001: '色序',
            sParamDefault1001: commonUtils.isNotEmptyObject(record && record.sColorSerialMemo) ? record.sColorSerialMemo : '选择色序',
          }
          sParamJsonObj ={...sParamJsonObj, ...sParam1000};

          sParamJsonObj ={...sParamJsonObj, ...sParam1001};
          }

          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]; /* 默认值 */
              }
              sParamData.push(obj);
            }
          }
          /* 将sParam1中的数据 还原到sParamData数据中 */
          if(commonUtils.isNotEmptyObject(record.sParams)) {
            let selectedData = [];
            try {
              selectedData = JSON.parse(record.sParams);
            } catch (error) {
              try {
                selectedData = JSON.parse(record.sParams.replace(/'/g, '"'));
              } catch (error) { }
            }
            if(commonUtils.isNotEmptyArr(selectedData)) {
              selectedData.forEach((itemS) => {
                const iIndex = sParamData.findIndex(item => item.sParamName === itemS.sParamName);
                if(iIndex > -1) {
                  const addState ={};
                  addState.sParamValue = itemS.sParamValue;
                  addState.bSelfCbx = itemS.bSelfCbx;
                  sParamData[iIndex] ={...sParamData[iIndex], ...addState};
                }
              });
            }

            /* 如果数据集有一个是非选中的则非选中状态 否则全选 */
            if(commonUtils.isNotEmptyArr(sParamColumn)) {
              const iIndex = sParamColumn.findIndex(item => item.dataIndex ==='bSelfCbx');
              if(iIndex > -1) {
                const filterData = sParamData.filter(item => !item.bSelfCbx);
                if(commonUtils.isNotEmptyArr(filterData)) {
                  sParamColumn[iIndex] ={ ...sParamColumn[iIndex], bCheckAll:false};
                }else {
                  sParamColumn[iIndex] ={ ...sParamColumn[iIndex], bCheckAll:true};
                }
              }
            }
          }
        }
        this.props.onSaveState({
          processRecord: record,
          sProcessParamsSelects,
          sParamsModalVisible: true,
          sParamConfig,
          sParamColumn,
          sParamData,
          sParamModalType:'sWork',
          enabled,
        });
      }else if ( name === 'control' && sName === 'dSinglePQty') { /* 控制表 查看开版图 */
        this.props.onSaveState({
          showSinglePQtyPictureVisible: true, /* 弹出查看开版图Modal*/
        });
      } else {
        if(sName === 'myTableConfig') {
          this.handleQuickViewClick(name, sName, record, index, myConfig, configName);
        } else {
          this.props.onViewClick(name, sName, record, index, myConfig );
        }
      }
    };

    handleQuickViewClick = async (name, sName, record, index , myConfigArr, configName) => {
      const {
        slaveConfig,
        slaveData,
        dispatch,
        slaveFilterCondition,
        slavePagination,
        slaveOrderBy,
        sModelsType,
        formRoute,
        treeFilterCondition,
        app,
        iPageSize,
        sModelsId,
        // slaveSelectedData,
        // masterData,
        // employeeConfig,
      } = this.props;

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

      if (picArr.length > 0) {
        const getConfig = this.handleGetTableConfig;
        const tableDataRow = record;
        const iIndex = index;
        const [{ sActiveId }] = picArr;
        let [{ sActiveKey }] = picArr;
        const sFormId = sActiveId === '1' ? commonUtils.isEmpty(tableDataRow.sFormId) ? tableDataRow.sSrcFormId : tableDataRow.sFormId : sActiveId;
        if (commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes('.')) { /* 接口按钮跳转 如果有slave.对应字段 则需要取出对应字段 */
          const index = sActiveKey.lastIndexOf('.');
          sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length);
        }
        const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sFormId}?sModelsId=${sFormId}&sName=${formRoute}`;
        const filterCondition = [];
        const conditionValues = this.props.getSqlCondition(picArr[0], name, tableDataRow);
        if (!commonUtils.isEmpty(conditionValues)) {
          Object.keys(conditionValues).forEach((item) => {
            if ((item === 'tStartDate_pro' || item.substring(0, 1) === 'p')) {
              if (!commonUtils.isEmpty(conditionValues[item]) && conditionValues[item].length >= 2) {
                const tStartDate = moment(conditionValues[item][0]).format(this.sDateFormat);
                const tEndDate = moment(conditionValues[item][1]).add(1, 'days').format(this.sDateFormat);
                filterCondition.push({
                  bFilterName: item,
                  bFilterCondition: '=',
                  bFilterValue: `${tStartDate},${tEndDate}`,
                });
              }
            } else if ((item === 'mStartDate_pro' || item.substring(0, 1) === 'm')) {
              if (!commonUtils.isEmpty(conditionValues[item])) {
                const tStartDate = moment(conditionValues[item]).startOf('month').format(this.sDateFormat);
                const tEndDate = moment(conditionValues[item]).endOf('month').add(1, 'days').format(this.sDateFormat);
                filterCondition.push({
                  bFilterName: `t${item.substring(1, item.length)}`,
                  bFilterCondition: '=',
                  bFilterValue: `${tStartDate},${tEndDate}`,
                });
              }
            } else if (item.substring(0, 1) === 't') {
              filterCondition.push({
                bFilterName: item,
                bFilterCondition: '=',
                bFilterValue: moment(conditionValues[item]).format(this.sDateFormat),
              });
            } else {
              filterCondition.push({
                bFilterName: item,
                bFilterCondition: '=',
                bFilterValue: conditionValues[item],
              });
            }
          });
        }
        this.props.dispatch({
          type: 'content/onRouter',
          payload: {
            url: sNameUrl,
            refresh: getConfig.bind(this, name, sModelsId, myConfigArr[0], configName), /*   刷新方法   */
            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: [tableDataRow],
            conditonValues: conditionValues,
            newKey: tableDataRow[sActiveKey],
            currentIndex: iIndex,
            filterCondition,
          },
        });
      }
    };

    /* 选择基础颜色 */
    handleSelectSisColor = async (name, selectConfig, selectData) => {
      const {
        enabled, processData, processSelectedRowId, controlSelectedRowId, controlData, sisColorField, masterData, slaveSelectedRowKeys, slaveData,packData, paramSelectedRowId,
        sParamData,
      } = this.props;
      if (enabled && commonUtils.isNotEmptyObject(processSelectedRowId)) {
        let sColorSerialMemoStr = '';
        const jsonData = [];
        if (commonUtils.isNotEmptyArr(selectData)) {
          selectData.forEach((item) => {
            const {
              sId, sName, dColor, CreateDate, sMakePerson,
            } = item;
            const jsonObj = {};
            jsonObj.sId = sId;
            jsonObj.sName = sName; /* 名称 */
            jsonObj.dColor = dColor; /* 色序 */
            jsonObj.CreateDate = CreateDate;
            jsonObj.sMakePerson = sMakePerson;
            sColorSerialMemoStr += `${sName}-${dColor},`;
            jsonData.push(jsonObj);
          });
          if (commonUtils.isNotEmptyObject(sColorSerialMemoStr)) {
            sColorSerialMemoStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
          }
        }
        const iIndex = processData.findIndex(item => item.sId === processSelectedRowId);
        if (iIndex > -1) {
          const addState = {};
          let { handleType } = processData[iIndex];
          handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
          addState.handleType = handleType;
          addState.sColorSerialMemo = sColorSerialMemoStr;
          processData[iIndex] = { ...processData[iIndex], ...addState };
        }

        if(commonUtils.isNotEmptyArr(sParamData) && commonUtils.isNotEmptyObject(paramSelectedRowId)) {
          const iParamIndex = sParamData.findIndex(item => item.sId === paramSelectedRowId);
          if (iParamIndex > -1) {
            const addState = {};
            // let { handleType } = sParamData[iIndex];
            // handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
            // addState.handleType = handleType;
            addState.sParamValue = sColorSerialMemoStr;
            sParamData[iParamIndex] = { ...sParamData[iParamIndex], ...addState };
          }
        }

      } else if (enabled && commonUtils.isNotEmptyObject(controlSelectedRowId)) { /* 控制表选择正面颜色、反面颜色 */
        let sColorSerialMemoStr = '';
        const jsonData = [];
        const sFieldName = commonUtils.isNotEmptyObject(sisColorField) ? sisColorField : 'sPositiveColor';
        let trueColor = 0; /* 正色 */
        let trueSpecialColor = 0; /* 正专 */
        let falseColor = 0; /* 反色 */
        let falseSpecialColor = 0; /* 反专 */
        if (commonUtils.isNotEmptyArr(selectData)) {
          selectData.forEach((item) => {
            const {
              sId, sName, dColor, CreateDate, sMakePerson,
            } = item;
            const jsonObj = {};
            jsonObj.sId = sId;
            jsonObj.sName = sName; /* 名称 */
            jsonObj.dColor = dColor; /* 色序 */
            jsonObj.CreateDate = CreateDate;
            jsonObj.sMakePerson = sMakePerson;
            sColorSerialMemoStr += `${sName}-${dColor},`;
            jsonData.push(jsonObj);
            if (sFieldName === 'sPositiveColor') {
              if (sName.toLowerCase().trim() === 'c' || sName.toLowerCase().trim() === 'm' || sName.toLowerCase().trim() === 'y' || sName.toLowerCase().trim() === 'k' || sName.toLowerCase().includes('c+m+y+k')) {
                trueColor += dColor;
              } else {
                trueSpecialColor += dColor;
              }
            } else if (sFieldName === 'sOppositeColor') {
              if (sName.toLowerCase().trim() === 'c' || sName.toLowerCase().trim() === 'm' || sName.toLowerCase().trim() === 'y' || sName.toLowerCase().trim() === 'k' || sName.toLowerCase().includes('c+m+y+k')) {
                falseColor += dColor;
              } else {
                falseSpecialColor += dColor;
              }
            }
          });
          if (commonUtils.isNotEmptyObject(sColorSerialMemoStr)) {
            sColorSerialMemoStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
          }
        }
        const iIndex = controlData.findIndex(item => item.sId === controlSelectedRowId);
        if (iIndex > -1) {
          const addState = {};
          let { handleType } = controlData[iIndex];
          handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
          addState.handleType = handleType;
          addState[sFieldName] = sColorSerialMemoStr;
          if (sFieldName === 'sPositiveColor') {
            addState.iPositiveColor = trueColor;
            addState.iPositiveSpecialColor = trueSpecialColor;
            addState.sOppositeColor= controlData[iIndex].sOppositeColor;
          } else if (sFieldName === 'sOppositeColor') {
            addState.iOppositeColor = falseColor;
            addState.iOppositeSpecialColor = falseSpecialColor;
            addState.sPositiveColor= controlData[iIndex].sPositiveColor;
          }
          controlData[iIndex] = { ...controlData[iIndex], ...addState };
        }
      }

      this.isSColorSerialMemo.current = false;
      this.props.onSaveState({
        sisColorChooseVisible: false,
      });
    }

    handleViewChoose= (name, sName, record) => {
      const { sId } = record; /* 控制表主键 */
      const { enabled, processSelectedRowKeys } = this.props;
      const NoProcessParameters = commonFunc.showLocalMessage(this.props, 'NoProcessParameters', '无工艺参数！');
      const sisColorSelectedRowKeys = [];
      let jsonData = [];
      if (name === 'process' && sName === 'sColorSerialMemo') {
        this.isSColorSerialMemo.current = true;
        const { [`${name}Data`]: tableData } = this.props;
        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          const sColorSerialMemo = tableData[iIndex].sColorSerialMemo;

          if (commonUtils.isNotEmptyObject(sColorSerialMemo)) {
            try {
              jsonData = JSON.parse(sColorSerialMemo);
              jsonData.forEach((item) => {
                sisColorSelectedRowKeys.push(item.sId);
              });
            } catch (ex) {
              // console.log('ex', ex);
            }
          }
        }
        this.props.onSaveState({
          sisColorChooseVisible: true,
          processSelectedRowId: sId, /* 工序表选中行sId */
          enabled,
          sisColorSelectedRowKeys,
          sisColorSelectedData: jsonData,
        });
      }else  if (name === 'sParam' && sName === 'sParamValue') {
        const { [`${name}Data`]: tableData } = this.props;
        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          const sColorSerialMemo = tableData[iIndex].sParamValue;

          if (commonUtils.isNotEmptyObject(sColorSerialMemo)) {
            try {
              jsonData = JSON.parse(sColorSerialMemo);
              jsonData.forEach((item) => {
                sisColorSelectedRowKeys.push(item.sId);
              });
            } catch (ex) {
              // console.log('ex', ex);
            }
          }
        }
        const sProcessKeyId =  commonUtils.isNotEmptyArr(processSelectedRowKeys) ? processSelectedRowKeys[0] : ''; /* 工序表选中行sId */

        this.props.onSaveState({
          sisColorChooseVisible: true,
          processSelectedRowId: sProcessKeyId, /* 工序表选中行sId */
          paramSelectedRowId: sId, /* 工艺参数表选中行sId */
          enabled,
          sisColorSelectedRowKeys,
          sisColorSelectedData: jsonData,
          sisColorTbType:'sParam' /* 弹出表格 */
        });
      }else if (sName === 'sParams' && location.pathname.includes('productionReport')) { // 产量上报 工艺参数
        const { enabled } = this.props;
        const slaveSelectOneData = record;
        const sProcessParamsSelects = [];
        const sParamData = [];
        let paramType = '';
        if (commonUtils.isNotEmptyObject(slaveSelectOneData)) {
          paramType = slaveSelectOneData.sReportParam; /* 上报参数 */
        }
        if (commonUtils.isEmpty(paramType)) {
          message.warn(NoProcessParameters);
          return;
        }
        /* 工序参数以表格形式展示 列 */
        const sParamConfig = {
          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,
          iFitWidth: 230,
        }];
        sParamConfig.gdsconfigformslave = gdsconfigformslave;
        const sParamColumn = commonFunc.getHeaderConfig(sParamConfig);
        if (commonUtils.isNotEmptyObject(paramType)) {
          /* 要把数据以表格的形式显示出来 */
          const sParamJsonObj = JSON.parse(paramType);
          console.log('aaa111', sParamJsonObj, sParamConfig);
          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]; /* 默认值 */
                /* 如果sParamValue有值 则替换默认值 */
                const oldKey = `sParamValue${number}`;
                const oldParamValue = slaveSelectOneData[oldKey]; /* 界面打开时，数据集中原始的sParamValue1,sParamValue2数据填充到数据上 */
                if (commonUtils.isNotEmptyObject(oldParamValue)) {
                  obj.sParamValue = oldParamValue; /* 默认值 */
                }
              }
              sParamData.push(obj);
            }
          }
          /* 将sParam1中的数据 还原到sParamData数据中 */
          if (commonUtils.isNotEmptyObject(record.sParams)) {
            const selectedData = JSON.parse(record.sParams);
            if (commonUtils.isNotEmptyArr(selectedData)) {
              selectedData.forEach((itemS) => {
                const iIndex = sParamData.findIndex(item => item.sParamName === itemS.sParamName);
                if (iIndex > -1) {
                  const addState = {};
                  addState.sParamValue = itemS.sParamValue;
                  addState.bSelfCbx = itemS.bSelfCbx;
                  sParamData[iIndex] = { ...sParamData[iIndex], ...addState };
                }
              });
            }

            /* 如果数据集有一个是非选中的则非选中状态 否则全选 */
            if (commonUtils.isNotEmptyArr(sParamColumn)) {
              const iIndex = sParamColumn.findIndex(item => item.dataIndex === 'bSelfCbx');
              if (iIndex > -1) {
                const filterData = sParamData.filter(item => !item.bSelfCbx);
                if (commonUtils.isNotEmptyArr(filterData)) {
                  sParamColumn[iIndex] = { ...sParamColumn[iIndex], bCheckAll: false };
                } else {
                  sParamColumn[iIndex] = { ...sParamColumn[iIndex], bCheckAll: true };
                }
              }
            }
          }
        }
        console.log('sParamData111', sParamData);
        this.props.onSaveState({
          slaveRecord: record,
          sProcessParamsSelects,
          sParamsModalVisible: true,
          sParamConfig,
          sParamColumn,
          sParamData,
          sParamModalType: 'sReport',
          enabled,
        });
      }else if (enabled && name === 'control' && (sName === 'sPositiveColor' || sName === 'sOppositeColor')) { /* 控制表 选择正面颜色、反面颜色 */
        const { [`${name}Data`]: tableData } = this.props;
        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          const sColorSerialMemo = tableData[iIndex][sName];

          if (commonUtils.isNotEmptyObject(sColorSerialMemo)) {
            try {
              jsonData = JSON.parse(sColorSerialMemo);
              jsonData.forEach((item) => {
                sisColorSelectedRowKeys.push(item.sId);
              });
            } catch (ex) {
              // console.log('ex', ex);
            }
          }
        }
        this.props.onSaveState({
          sisColorChooseVisible: true,
          controlSelectedRowId: sId, /* 控制表选中行sId */
          processSelectedRowId: '', /* 工序表选中行sId */
          enabled,
          sisColorSelectedRowKeys,
          sisColorSelectedData: jsonData,
          sisColorField: sName, /* 弹出字段 */
        });
      } else if (enabled && name === 'control' && sName === 'dSinglePQty') { /* 控制表 查看开版图 */
        const { [`${name}Data`]: tableData } = this.props;
        const iIndex = tableData.findIndex(item => item.sId === sId);
        if (iIndex > -1) {
          const tableDataRow = tableData[iIndex];
          const dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsWidth, 0)); /* 产品长 */
          const dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsLength, 0)); /* 产品宽 */
          // const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */
          // const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */

          /* 算拼版数 */
          if (dProductLength !== 0 && dProductWidth !== 0) {
            this.props.onSaveState({
              showSinglePQtyPictureVisible: true, /* 弹出查看开版图Modal111 */
              showSinglePQtyRow: tableDataRow, /* 弹出查看开版图行 */
              controlSelectedRowId: sId, /* 控制表选中行sId */
              processSelectedRowId: '', /* 工序表选中行sId */
              enabled,
              sisColorSelectedRowKeys,
              sisColorSelectedData: jsonData,
              sisColorField: sName, /* 弹出字段 */
            });
          }
        }
      }
    }
    handleCancelModal = (modelVisible) => {
      this.props.onSaveState({
        [modelVisible]: false,
      });
    }
    /* 根据不同条件 计算排版数 */
    //竖排（上机高、上机宽、部件高、部件宽、出血咬口） dPartsLength --》dMachineLength，dPartsWidth--》dMachineWidth
    getSp = (dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth)=>{
      var dMachineWidth = dMachineWidth;
      var dMachineLength = dMachineLength;
      //计算合版数量
      var iTemp = Math.floor(dMachineWidth / dPartsWidth) * Math.floor(dMachineLength /dPartsLength );
      return iTemp;
    }
    //横排（上机高、上机宽、部件高、部件宽、出血咬口） dPartsLength --》dMachineWidth，dPartsWidth--》dMachineLength
    getHp = (dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth) =>{
      var dMachineWidth = dMachineWidth;
      var dMachineLength = dMachineLength;
      //计算合版数量
      var iTemp = Math.floor(dMachineWidth / dPartsLength) * Math.floor(dMachineLength / dPartsWidth);
      return iTemp;
    }
    //横竖取大
    getHSQD = (dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth) =>{
      var iTemp =this.getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
      var iTemp2 =this.getSp(dMachineLength,dMachineWidth,dPartsLength,dPartsWidth);
      if(iTemp2>iTemp){
        iTemp = iTemp2;
        // tag= 2;//竖排
      }
      return iTemp;
    }

    /* 计算排版数 */
    handleResolveSinglePQty = (tableDataRow) => {
      let dSingleQty = 0; /* 排版数 */
      const tag = 1;//1横排还是2竖排
      let dPartsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsWidth, 0)); /* 产品长 */
      let dPartsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsLength, 0)); /* 产品宽 */
      let dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */
      let dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */

      const dBoold = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dBlood, 0)); /* 出血位 */
      const dBite = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dBite, 0)); /* 咬口 */
      // console.log('dPartsWidth', dPartsWidth, dPartsLength);
      var dMachineTmp = 0;
      var dPartsTmp = 0;
      var tagval = "";
      var xxfx = 3;//虚线方向 1：横虚线 2：树虚线;3:无需虚线
      var wlfx = 1;//竖纹
      //机器长宽转换
      if(dMachineWidth > dMachineLength){
        dMachineTmp = dMachineWidth;//上级高
        dMachineWidth = dMachineLength;//上级宽
        dMachineLength = dMachineTmp;
        wlfx = 2;
      }
      //长宽转换（dLength 高度、dWidth 表示宽度,高度永远大于宽度）
      if(dPartsWidth > dPartsLength){
        dPartsTmp = dPartsWidth;//上级高
        dPartsWidth = dPartsLength;//上级宽
        dPartsLength = dPartsTmp;
      }
      dMachineWidth = dMachineWidth-dBite;

      const sCutMethod = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.sCutMethod, 0));  /* 裁切方式 */
      const sSpineDirection = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.sSpineDirection, 0)); /* 书脊方向 */
      const sPrintingPlate =  commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.sPrintingPlate, 0)); /* 排版方式 */
      // console.log('sPrintingPlate', sPrintingPlate);
      // console.log('sCutMethod', sCutMethod);
      // console.log('sSpineDirection', sSpineDirection);
      let tmpBl = 1;//排版数乘的数字，如果书类为2 默认是1
      let tmp = 0;
      //三边裁切
      if( sCutMethod === 1){
        //长书(1,3,4)
        if(sSpineDirection=== 1){
          dPartsLength = dPartsLength;
          dPartsWidth = dPartsWidth*2;
        }else{
          dPartsWidth = dPartsWidth
          dPartsLength = dPartsLength*2;
        }
        tmpBl = 2;
        dPartsWidth = dPartsWidth + 2*dBoold;
        dPartsLength = dPartsLength + 2*dBoold;
        if(sPrintingPlate === 1){ /* 横竖取大 */
          tmp = this.getHSQD(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
          dSingleQty = tmp*2;
          console.log('横竖取大排版数：', dSingleQty);
        }else if(sPrintingPlate ===3){  /* 横排 */
          if(wlfx===1 && sSpineDirection===1){
            //长书脊
            tmp = this.getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            dSingleQty = tmp*2;
          }else if(wlfx===2 && sSpineDirection===1){
            //长书脊
            tmp = this.getSp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,4,1);
            dSingleQty = tmp*2;
          }else if(wlfx===1 && sSpineDirection===2){
            //长书脊
            tmp = this.getSp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,4,1);
            dSingleQty = tmp*2;
          }else if(wlfx==2 && sSpineDirection==2){
            //长书脊
            tmp = this.getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,3,2);
            dSingleQty = tmp*2;
          }
        }else if(sPrintingPlate===4) {  /* 竖排 */
          //竖排
          if(wlfx===1 && sSpineDirection===1){
            //长书脊
            tmp = this.getSp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,4,1);
            dSingleQty = tmp*2;
          }else if(wlfx===2 && sSpineDirection===1){
            //长书脊
            tmp = this.getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,3,2);
            dSingleQty = tmp*2;
          }else if(wlfx===1 && sSpineDirection===2){
            //长书脊
            tmp = this.getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,3,2);
            dSingleQty = tmp*2;
          }else if(wlfx===2 && sSpineDirection===2){
            //长书脊
            tmp = this.getSp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,4,1);
            dSingleQty = tmp*2;
          }
        }else if(sPrintingPlate===2){ /* 混排 */
          //混排 横排 多余部分 看看是否能够竖着排 如果竖排 看看能否再横着排（折页没有混排）
        }
      }else{ /* 四边裁 */
        dPartsWidth = dPartsWidth+2*dBoold;
        dPartsLength = dPartsLength+2*dBoold;
        if(sPrintingPlate===1){
          tmp = this.getHSQD(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
          //1：横虚线 2：树虚线;3:无需虚线
          // if(tag==2){
          //   //alert("横竖取大==版数："+tmp);
          //   addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,4,3);
          // }else{
          //   //alert("横竖取大==版数："+tmp);
          //   addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,3,3);
          // }
          console.log("四边裁-横竖取大："+tmp);
          dSingleQty = tmp;
        }else if(sPrintingPlate===3){
          if(wlfx===1){
            //长书级
            tmp = this.getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            dSingleQty = tmp;
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,3,3);
          }else{
            //长书级
            tmp = this.getSp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            dSingleQty = tmp;
            // $("#dPlateQty").val(tmp);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,4,3);
          }
          // var tmp = getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
          // alert("横排版数："+tmp);
          // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,3,2);
        }else if(sPrintingPlate===4) {
          //竖排
          if(wlfx===1){
            //长书级
            tmp = this.getSp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            console.log("竖排版数："+tmp);
            dSingleQty = tmp;
            // $("#dPlateQty").val(tmp);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,4,3);
          }else{
            //长书级
            tmp = this.getHp(dMachineLength,dMachineWidth ,dPartsLength ,dPartsWidth);
            console.log("竖排版数："+tmp);
            dSingleQty = tmp;
            // $("#dPlateQty").val(tmp);
            // addHtml(dMachineLength,dMachineWidth ,dPartsLength,dPartsWidth,dBoold ,dBite,3,3);
          }
        }else if(sPrintingPlate===2){
          //混排 横排 多余部分 看看是否能够竖着排 如果竖排 看看能否再横着排（折页没有混排）
          if( sCutMethod===1){
            message.warning("书没有混排");
            return;
          }
          //竖排+横排
          let htTmpTag = 0;
          let tmp3 = 0;
          tmp = this.getHHP(dMachineWidth,dMachineLength ,dPartsLength ,dPartsWidth);
          tmp3 = this.getHHP(dMachineWidth,dMachineLength ,dPartsWidth,dPartsLength);
          if(tmp<tmp3){
            tmp = tmp3;
            htTmpTag = 1;
          }
          // alert("混拼排版数："+tmp);
          // $("#dPlateQty").val(tmp);
          console.log("混拼排版数："+tmp);
          dSingleQty = tmp;
        }
      }

      const lrl= ((tmp*dPartsLength*dPartsWidth)/(dMachineWidth*(dMachineLength+dBite)))*100 ;

      console.log("利润率："+ lrl);
      // $("#dLylQty").val(((tmp*dPartsLength*dPartsWidth)/(dMachineWidth*(dMachineLength+dBite)))*100);
      // $("#dPlateQty").css("background-color","#0000ff80");
      // $("#dLylQty").css("background-color","#0000ff80");
      return dSingleQty;
    }

     /* 查询单表数据 */
     handleGetDataOne = async (name, slaveInfoConfig, slaveFilterCondition, page, pageSize, slaveOrderBy, props, isWait) => {
      const { slaveData, slaveSelectedRowKeys } = props || this.props;
      if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(slaveInfoConfig)) {
        let record =  slaveData[0]; /* 从表选中行 没有选中行时 取第一行 */
        if(commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
          const iIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
          if (iIndex > -1) {
            record = slaveData[iIndex];
          }
        }
        let conditonValues = {};
        const sSqlCondition0 = slaveInfoConfig.sSqlCondition;
        if (commonUtils.isNotEmptyObject(sSqlCondition0)) {
          conditonValues = this.props.getSqlCondition(slaveInfoConfig, 'slave', record);
        }
        conditonValues = { sParentId: record.sId, ...conditonValues};
        const pageNum = commonUtils.isEmpty(page) ? 1 : page;
        const pageTableSize = commonUtils.isNotEmptyNumber(pageSize) ? pageSize : commonConfig.pageSize;
        let addState = await this.props.handleGetDataSet({
          name,
          configData: slaveInfoConfig,
          condition: {
            pageNum, pageSize: pageTableSize, bFilter: [], sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues,
          },
          flag: true,
          clearSelectData: true,
          isWait:true,
        });
        if(isWait) {
          if(commonUtils.isEmptyObject(addState)) {
            addState = {};
          }
          addState.pageLoading = false;
          return addState;
        } else {
          this.props.onSaveState({ pageLoading: false, ...addState });
        }
      }
    };

    /* 根据上机长、上机宽，材料长，材料宽 计算自动排版数 */
    handleResolveMachineComposing = (productLength, productWidth, maxMachineLength, maxMachineWidth) => {
      let result1 = {};
      const productLengthTemp = commonUtils.convertStrToNumber(commonUtils.isNull(productLength, 0)); /* 产品长 */
      const productWidthTemp = commonUtils.convertStrToNumber(commonUtils.isNull(productWidth, 0)); /* 产品宽 */
      const maxMachineLengthTemp = commonUtils.convertStrToNumber(commonUtils.isNull(maxMachineLength, 0)); /* 材料长 */
      const maxMachineWidthTemp = commonUtils.convertStrToNumber(commonUtils.isNull(maxMachineWidth, 0)); /* 材料宽 */
      if (isNaN(productLengthTemp) || productLengthTemp === 0 || isNaN(productWidthTemp) || productWidthTemp === 0 || isNaN(maxMachineLengthTemp) || maxMachineLengthTemp === 0 || isNaN(maxMachineWidthTemp) || maxMachineWidthTemp === 0) {
        return result1;
      }
      const vh = this.handleDescVerticalComposing(productLength, productWidth, maxMachineLength, maxMachineWidth);
      const hv = this.handleDescHorizonalComposing(productLength, productWidth, maxMachineLength, maxMachineWidth);
      const totalNumVH = vh.totalNum;
      const totalNumHV = hv.totalNum;
      if (totalNumVH === totalNumHV) {
        if (vh.remaining === 0) {
          result1 = vh;
        } else {
          result1 = hv;
        }
      } else if (totalNumVH > totalNumHV) {
        result1 = vh;
      } else {
        result1 = hv;
      }
      return result1;
    };

    handleDescHorizonalComposing = (productLength, productWidth, maxMachineLength, maxMachineWidth) => {
      let horizonalWWNum = 0;
      let horizonalLWNum = 0;
      let verticalLLNum = 0;
      let verticalLWNum = 0;
      let totalNum = 0;// 总的排列数目
      let totalLength = 0;// 上机长，即最大排列占据的长度
      let totalWidth = 0;// 上机宽，即最大排列占据的宽度

      let mLength = 0;
      let mWidth = 0;
      let horizonalRemaining = 0;
      // let fTempmarginW = 0;
      // let fTempmarginL = 0;
      // const mTemp = 0;
      const dmargin = 0;

      const result1 = {};

      if (maxMachineLength > maxMachineWidth || maxMachineLength === maxMachineWidth) {
        mLength = maxMachineLength;
      } else {
        mLength = maxMachineWidth;
      }

      if (maxMachineLength < maxMachineWidth || maxMachineLength === maxMachineWidth) {
        mWidth = maxMachineLength;
      } else {
        mWidth = maxMachineWidth;
      }
      maxMachineLength = mLength;
      maxMachineWidth = mWidth;

      // 按机器优先横排--竖向横排数量，即上述竖向横排一共排几行
      verticalLLNum = Math.floor(maxMachineLength / this.handleZeroToOne(productWidth + commonUtils.convertFixNum(dmargin, 2)));
      // 按机器优先横排--横向横排数量，即横向排列的时候，一行最多能排几个
      verticalLWNum = Math.floor(maxMachineWidth / this.handleZeroToOne(productLength + commonUtils.convertFixNum(dmargin, 2)));

      totalNum += verticalLLNum * verticalLWNum;

      // 画册类，不能混排，而且只能是偶数，如果是奇数，则首选在长方向去掉一列，
      horizonalRemaining = 0;
      // fTempmarginW = 0;// 宽方向 需减少的出血
      // fTempmarginL = 0;// 长方向 需减少的出血
      horizonalWWNum = 0;
      horizonalLWNum = 0;

      if (totalNum > 0) {
        // 上述横排完成之后，剩余的右边宽度，用于竖向排列
        horizonalRemaining = maxMachineWidth - (verticalLWNum * (productLength + commonUtils.convertFixNum(dmargin, 2)));
        // 按机器优先长排--竖向横排一行能排的数量，即排完竖向之后，剩余的排横向的，看一行能排多少个

        // / 剩余空间  横向 排数量
        horizonalWWNum = Math.floor(horizonalRemaining / (productWidth + commonUtils.convertFixNum(dmargin, 2)));
        // 剩余空间  竖向 排数量
        horizonalLWNum = Math.floor(maxMachineLength / (productLength + commonUtils.convertFixNum(dmargin, 2)));
      }

      if (horizonalWWNum * horizonalLWNum === 0) {
        // 不是混排的情况
        totalLength = verticalLLNum * (productWidth + commonUtils.convertFixNum(dmargin, 2));
        totalWidth = verticalLWNum * (productLength + commonUtils.convertFixNum(dmargin, 2));
      } else {
        totalNum += horizonalWWNum * horizonalLWNum;
        // 有可能是左边横向排列占用的长度更长，也有可能是剩余右侧的竖向排列方式占用的长度更长，最终更长的那个作为上机尺寸
        if (verticalLLNum * (productWidth + dmargin) > horizonalLWNum * (productLength + commonUtils.convertFixNum(dmargin, 2))) {
          totalLength = verticalLLNum * (productWidth + dmargin);
        } else {
          totalLength = horizonalLWNum * (productLength + dmargin);
        }
        // 最终宽度是所有左侧横向排列占据的宽度以及右侧剩余空间竖向排列占据的宽度之和
        totalWidth = (verticalLWNum * (productLength + dmargin)) + (horizonalWWNum * (productWidth + commonUtils.convertFixNum(dmargin, 2)));
      }

      result1.remaining = horizonalLWNum * horizonalWWNum;
      result1.iLengthComposing = verticalLLNum;
      result1.iWidthComposing = verticalLWNum;


      result1.sMethod = `W#${commonUtils.convertNumberToStr(verticalLLNum)}*${commonUtils.convertNumberToStr(verticalLWNum)}+L#${commonUtils.convertNumberToStr(horizonalWWNum)}*${commonUtils.convertNumberToStr(horizonalLWNum)}`;
      result1.sMaterialMethod = `W#${commonUtils.convertNumberToStr(verticalLLNum)}*${commonUtils.convertNumberToStr(verticalLWNum)}+L#${commonUtils.convertNumberToStr(horizonalWWNum)}*${commonUtils.convertNumberToStr(horizonalLWNum)}`;
      // 最终要保存排列之后的长和宽，按机器排的时候获取的是上机尺寸;按材料排的时候，就是最优材料排版
      if (totalLength > totalWidth) {
        result1.totalLength = totalLength;
        result1.totalWidth = totalWidth;
      } else {
        result1.totalLength = totalWidth;
        result1.totalWidth = totalLength;
      }
      // 最终保存最大数目，以便比较最优排版数
      result1.totalNum = totalNum;
      return result1;
    };
    handleDescVerticalComposing = (productLength, productWidth, maxMachineLength, maxMachineWidth) => {
      let horizonalWWNum = 0;
      let horizonalLWNum = 0;
      let verticalLLNum = 0;
      let verticalLWNum = 0;
      let mLength = 0;
      let mWidth = 0;
      let verticalRemaining = 0;
      // eslint-disable-next-line no-unused-vars
      let fTempmarginW = 0;
      // eslint-disable-next-line no-unused-vars
      let fTempmarginL = 0;
      const result1 = {};
      // eslint-disable-next-line no-unused-vars
      const TYHLLookupList = 0;
      const dmargin = 0;
      let totalNum = 0;// 总的排列数目
      let totalLength = 0;// 上机长，即最大排列占据的长度
      let totalWidth = 0; // 上机宽，即最大排列占据的宽度
      if (maxMachineLength >= maxMachineWidth) {
        mLength = maxMachineLength;
      } else {
        mLength = maxMachineWidth;
      }

      if (maxMachineLength <= maxMachineWidth) {
        mWidth = maxMachineLength;
      } else {
        mWidth = maxMachineWidth;
      }
      maxMachineLength = mLength;
      maxMachineWidth = mWidth;
      // 画册类，不能混排，而且只能是偶数，如果是奇数，则首选在长方向去掉一列，
      verticalRemaining = 0;

      fTempmarginW = 0;// 宽方向 需减少的出血
      fTempmarginL = 0;// 长方向 需减少的出血

      horizonalWWNum = 0;
      horizonalLWNum = 0;

      // 按机器优先长排--竖排竖方向排多少个
      verticalLLNum = Math.floor(maxMachineLength / this.handleZeroToOne(commonUtils.convertFixNum(productLength, 2) + commonUtils.convertFixNum(dmargin, 2)));
      // 竖排横方向排多少个
      verticalLWNum = Math.floor(maxMachineWidth / this.handleZeroToOne(commonUtils.convertFixNum(productWidth, 2) + commonUtils.convertFixNum(dmargin, 2)));
      totalNum += verticalLLNum * verticalLWNum;

      if (totalNum > 0) {
        // 上述竖排完成之后，剩余的长度
        verticalRemaining = maxMachineLength - (verticalLLNum * (commonUtils.convertFixNum(productLength, 2) + commonUtils.convertFixNum(dmargin, 2)));
        // 剩余下面 竖向 排数量
        horizonalLWNum = Math.floor(verticalRemaining / this.handleZeroToOne(productWidth + commonUtils.convertFixNum(dmargin, 2)));
        // 剩余下面 横向 排数量
        horizonalWWNum = Math.floor(maxMachineWidth / this.handleZeroToOne(productLength + commonUtils.convertFixNum(dmargin, 2)));
      }

      if (horizonalWWNum * horizonalLWNum === 0) {
        totalLength = verticalLLNum * (productLength + commonUtils.convertFixNum(dmargin, 2));
        totalWidth = verticalLWNum * (productWidth + commonUtils.convertFixNum(dmargin, 2));
      } else {
        totalNum += horizonalLWNum * horizonalWWNum;
        totalLength = (verticalLLNum * (productLength + commonUtils.convertFixNum(dmargin, 2))) + ((productWidth + commonUtils.convertFixNum(dmargin, 2)) * horizonalLWNum);
        // 最终宽度是所有左侧横向排列占据的宽度以及右侧剩余空间竖向排列占据的宽度之和
        if (verticalLWNum * (productWidth + dmargin) > horizonalWWNum * (productLength + commonUtils.convertFixNum(dmargin, 2))) {
          totalWidth = verticalLWNum * (productWidth + commonUtils.convertFixNum(dmargin, 2));
        } else {
          totalWidth = horizonalWWNum * (productLength + commonUtils.convertFixNum(dmargin, 2));
        }
      }
      result1.remaining = horizonalLWNum * horizonalWWNum;
      result1.iLengthComposing = verticalLLNum;
      result1.iWidthComposing = verticalLWNum;
      result1.sMethod = `L#${commonUtils.convertNumberToStr(verticalLLNum)}*${commonUtils.convertNumberToStr(verticalLWNum)}+W#${commonUtils.convertNumberToStr(horizonalLWNum)}*${commonUtils.convertNumberToStr(horizonalWWNum)}`;
      result1.sMaterialMethod = `L#${commonUtils.convertNumberToStr(verticalLLNum)}*${commonUtils.convertNumberToStr(verticalLWNum)}+W#${commonUtils.convertNumberToStr(horizonalWWNum)}*${commonUtils.convertNumberToStr(horizonalLWNum)}`;
      // 最终要保存排列之后的长和宽，按机器排的时候获取的是上机尺寸;按材料排的时候，就是最优材料排版
      if (totalLength > totalWidth) {
        result1.totalLength = totalLength;
        result1.totalWidth = totalWidth;
      } else {
        result1.totalLength = totalWidth;
        result1.totalWidth = totalLength;
      }
      // 最终保存最大数目，以便比较最优排版数
      result1.totalNum = Math.floor(totalNum);
      return result1;
    };
    handleZeroToOne = (num) => {
      if (commonUtils.isEmptyNumber(num) && num === 0) {
        num = 1;
      }
      return num;
    };

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

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


    /* 选择工艺参数点击确定 */
    handleParamsOk = () => { // 工艺参数弹窗确定按钮
      const {
        processData,
        processRecord,
        processConfig,
        // sParamData,
        enabled,
        sParamModalType
      } = this.props;
      let { sParamData } = this.props;
      if(enabled) {
        if (commonUtils.isNotEmptyArr(processData) && commonUtils.isNotEmptyObject(processRecord)) {
          const processSelectDataIndex = processData.findIndex(item => item.sId === processRecord.sId);
          if (processSelectDataIndex > -1) {
            if (commonUtils.isNotEmptyArr(sParamData)) {
              let sParamJsonData = '';
              // const sParamSeletedData = sParamData.filter(item => item.bSelfCbx);
              const iFaceIndex = sParamData.findIndex(item => item.sParamKey === 'sParam1000');
              const iColorIndex = sParamData.findIndex(item => item.sParamKey === 'sParam1001');
              if(iFaceIndex > -1) {
                let iFaceValue = '';
                const iFaceObj =  sParamData[iFaceIndex];
                if(commonUtils.isNotEmptyObject(iFaceObj)) {
                  if(iFaceObj.sParamValue === '正面') {
                    iFaceValue = 0;
                  }else if(iFaceObj.sParamValue === '反面') {
                    iFaceValue = 1;
                  }else if(iFaceObj.sParamValue === '双面') {
                    iFaceValue = 2;
                  }
                }
                processData[processSelectDataIndex].iFace = iFaceValue;
                sParamData.splice(iFaceIndex, 1);
              }
              /* 移除 印面、色序配置 */
              if(iColorIndex > -1) {
                const iColorObj =  sParamData[iColorIndex];
                sParamData.splice(iFaceIndex, 1);
              }
              /* 移除色序，单双面 */
              const sParamSeletedData = sParamData;
              if(commonUtils.isNotEmptyObject(sParamSeletedData)) {
                sParamJsonData = JSON.stringify(sParamSeletedData);
              }
              let { handleType } = processData[processSelectDataIndex];
              handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
              if(sParamModalType === 'sQuo') { /* 报价参数点击确定 */
                processData[processSelectDataIndex].sQuoParams = sParamJsonData;
              } else { /* 工单参数点击确定 */
                processData[processSelectDataIndex].sParams = sParamJsonData;
              }
              processData[processSelectDataIndex].handleType = handleType;
            }
          }
        }
        this.props.onSaveState({
          processData,
          sParamsModalVisible: false,
        });
      } else {
        this.props.onSaveState({
          sParamsModalVisible: false,
        });
      }
    }

    /* 选择上报参数点击确定 */
    handleReportParamsOk = () => { // 工艺参数弹窗确定按钮
      const {
        slaveData,
        slaveRecord,
        sParamData,
        // enabled,
        sParamModalType,
      } = this.props;
      if (true) {
        if (commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(slaveRecord)) {
          const processSelectDataIndex = slaveData.findIndex(item => item.sId === slaveRecord.sId);
          if (processSelectDataIndex > -1) {
            if (commonUtils.isNotEmptyArr(sParamData)) {
              let sParamJsonData = '';
              const sParamSeletedData = sParamData.filter(item => item.bSelfCbx);
              if (commonUtils.isNotEmptyObject(sParamSeletedData)) {
                sParamJsonData = JSON.stringify(sParamSeletedData);
              }
              let { handleType } = slaveData[processSelectDataIndex];
              handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
              if (sParamModalType === 'sReport') { /* 报价参数点击确定 */
                slaveData[processSelectDataIndex].sParams = sParamJsonData;
              }
              slaveData[processSelectDataIndex].handleType = handleType;
            }
          }
        }
        console.log('gggg', slaveData);
        this.props.onSaveState({
          slaveData,
          sParamsModalVisible: false,
        });
      } else {
        this.props.onSaveState({
          sParamsModalVisible: false,
        });
      }
    }

   /* 动态参数标题选择框 全选/取消全选 */
    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
        })
      }
    }

    /* 工单、工艺卡、报价单上移下移排序 */
    orderNum = (tableData, controlSelectedRowKeys) => {
      /* 部件工序排序 */
      const tableFilterData = tableData.filter(item => controlSelectedRowKeys.includes(item.sControlId));
      if (commonUtils.isNotEmptyArr(tableFilterData)) {
        tableFilterData.forEach((item, index) => {
          item.iOrder = index + 1;
          item.handleType = commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType;
          const index1 = tableData.findIndex(item1 => item1.sId === item.sId);
          if (index1 > -1) {
            tableData[index1] = { ...tableData[index1], ...item };
          }
        });
      }
      /* 成品工序 */
      const tableFilterCPData = tableData.filter(item => item.sType === '3');
      if (commonUtils.isNotEmptyArr(tableFilterCPData)) {
        let num = 1001;
        tableFilterCPData.forEach((item) => {
          item.iOrder = num;
          item.handleType = commonUtils.isEmpty(item.handleType) ? 'update' : item.handleType;
          const index1 = tableData.findIndex(item1 => item1.sId === item.sId);
          num += 1;
          if (index1 > -1) {
            tableData[index1] = { ...tableData[index1], ...item };
          }
        });
      }
      return tableData;
    };

    /* 单据预览PDF */
    handleBtnPreviewPdf = async (isWait) => {
      const {
        app, sModelsId, masterConfig, masterData, slaveConfig, reportData, formRoute, enabled,
      } = this.props;
      if (formRoute === '/indexPage/commonCheckBill' && commonUtils.isNotEmptyObject(masterData) && !enabled) {
        const { token } = app;
        const queryFilter = {};
        queryFilter[masterConfig.sId] = { sId: masterData.sId };
        if (commonUtils.isNotEmptyObject(slaveConfig)) {
          queryFilter[slaveConfig.sId] = { sSqlCondition: { sParentId: masterData.sId } };
        }
        let sActiveId = '';
        const queryFilterJson = JSON.stringify(queryFilter);
        /* 拿到打印报表名称 */
        let printReportName = 'report';
        if (commonUtils.isNotEmptyArr(reportData)) {
          const iIndex = 0;
          if (iIndex > -1) {
            printReportName = reportData[iIndex].sReportName;
            sActiveId = reportData[iIndex].sId;
          }
        } else {
          message.error('没有报表模块！');
          return;
        }

        /* 调用POST接口拿到PDF地址 */
        const dataUrl = `${commonConfig.file_host_ebc}printReport/printPreviewPdf/${sActiveId}/${printReportName}.pdf?${false ? 'fileType=.xlsx&' : ''}sModelsId=${sModelsId}&sMaintableId=${masterConfig.sId}`;
        const value = {
          queryFilter: queryFilterJson,
        };
        const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data;
        if (dataReturn.code === 1) {
          const url = dataReturn.dataset.rows[0];
          if (commonUtils.isNotEmptyObject(url)) {
            const previewUrl = `${commonConfig.file_host}file/downloadPreviewPdf?savePathStr=${url}`;
            if (isWait) {
              console.log('previewUrl', previewUrl);
              return previewUrl;
            } else {
              this.props.onSaveState({ previewUrl });
            }
          }
        } else {
          this.props.getServiceError(dataReturn);
        }
      }
    };

    /* 未审核单据 只能预览 */
    handleBtnPreview = async (sActiveId, checked, eKey) => {
      const {
        app, sModelsId, masterConfig, masterData, slaveConfig, reportData, menuChildData, formRoute, controlConfig,
      } = this.props;
      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') {
        /* 调用POST接口拿到PDF地址 */
        const dataUrl = `${commonConfig.file_host_ebc}printReport/printPreviewPdf/${sActiveId}/${printReportName}.pdf?${false ? 'fileType=.xlsx&' : ''}sModelsId=${sModelsId}&sMaintableId=${masterConfig.sId}`;
        const value = {
          queryFilter: queryFilterJson,
        };
        const dataReturn = (await commonServices.postValueService(token, value, dataUrl)).data;
        if (dataReturn.code === 1) {
          const url = dataReturn.dataset.rows[0];
          if (commonUtils.isNotEmptyObject(url)) {
            const previewUrl = `${commonConfig.file_host}file/downloadPreviewPdf?savePathStr=${url}`;
            console.log('previewUrl:', previewUrl);
            if (true) {
              this.handleOpenPrintTab(previewUrl);
            }
          }
        } else {
          this.props.getServiceError(dataReturn);
        }
      }
    };

    handleOpenPrintTab = (url) => {
      const { dispatch } = this.props;
      const newsId = '01251240115015952245193980'; /* 表格行的sId */
      const newKey = new Date().getTime().toString();
      const route = '/indexPage/printPdf';
      const title = '预览PDF';
      const sModelsType = 'print/printPdf';
      const previewUrl = url;
      const pane = {
        title, route, formId: newsId, key: newKey, sModelsType, previewUrl,
      };
      dispatch({ type: 'app/addPane', payload: { pane } });
    };
    /* 选择产品 调用工艺卡 选择数据带回窗体  */
    handleSelectCommonPopupProduct = (currentPaneName, selectConfig, selectData, tbName) => {
      const {
        [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData,
        controlData, controlSelectedRowKeys, sModelsId, sModelsType, token,
      } = this.props;
      const addState = {};

      let { [`${tbName}Data`]: tableData } = this.props;
      if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData)) {
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1; /* 控制表 */
        selectData.forEach(async (item, index) => {
          const newCopyTo = {};
          newCopyTo.master = masterData;
          const sName = selectConfig.sKeyUpFilter; /* 将后台配置筛选字段作为 列字段 */
          let sValue = '';
          if (iIndex > -1) {
            newCopyTo.slave = tableData[iIndex];
            sValue = tableData[iIndex][sName];
          }
          if (iControlIndex > -1) {
            newCopyTo.control = controlData[iControlIndex];
          }
          /* 第一条数据若字段值为空或者只有一条数据时 则添加到该行 否则新增一行s */
          if (selectData.length === 1 || (index === 0 && commonUtils.isEmptyObject(sValue))) {
            let tableDataRow = {}; // 取默认值
            if (tbName === 'master') {
              tableDataRow = { ...tableData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
              tableData = tableDataRow;
              tableData.handleType = commonUtils.isEmpty(tableData.handleType) ? 'update' : tableData.handleType;
            } else {
              tableDataRow = { ...tableData[iIndex], ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
              tableData[iIndex] = tableDataRow;
              tableData[iIndex].handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;

              // 取工艺卡数据
              if (tbName === 'slave') {
                const {
                  controlConfig, materialsConfig, processConfig,
                } = this.props;
                let { controlData, materialsData, processData } = this.props;
                const sId = tableData[iIndex].sId;
                const bCkxCopyFromTechnology = '1'; // 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 controlSelectedRowKeys = [];
                    controlSelectedData.forEach((item) => {
                      controlSelectedRowKeys.push(item.sId);
                    });
                    const materialsReturnData = this.otherTableDel('materials', controlSelectedRowKeys);
                    const processReturnData = this.otherTableDel('process', controlSelectedRowKeys);
                    const controlReturnData = this.props.onDataRowDel('control', true, controlSelectedRowKeys);
                    controlData = controlReturnData.controlData;
                    materialsData = materialsReturnData.materialsData;
                    processData = processReturnData.processData;
                    this.props.onSaveState({
                      ...materialsReturnData,
                      ...processReturnData,
                      ...controlReturnData,
                    });
                  }
                  const sCustomerId = masterData.sCustomerId;
                  const sProductId = tableDataRow.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 copyToMaterialsConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Materials'.toLowerCase());
                    const copyToProcessConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Process'.toLowerCase());
                    const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
                    const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[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)) {
                      const treeCopyNodes = new Map();
                      // eslint-disable-next-line no-loop-func
                      returnData.controlData.forEach((controlItem) => {
                        newCopyTo.control = controlItem;
                        const newSid = commonUtils.createSid();
                        let controlRow = commonFunc.getDefaultData(controlConfig, newCopyTo, { newSid }); // 取默认值
                        controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
                        controlRow.handleType = 'add';
                        controlRow.sId = newSid;
                        controlRow.sSlaveId = tableDataRow.sId;
                        controlRow.sParentId = masterData.sId;
                        if (sModelsType === 'sales/salesOrderPack') { /* 树形 */
                          /* CopyTo时sAllId,sControlParentId 设置 */
                          const sAllOldId = controlItem.sAllId;
                          let arr = [];
                          if (commonUtils.isNotEmptyObject(sAllOldId)) {
                            arr = sAllOldId.split(',');
                          }
                          const newId = controlRow.sId;
                          let sOldParentId = '';
                          let sNewParentAllId = '';
                          if (arr.length < 2) { /* 根节点复制 */
                            controlRow.sAllId = newId;
                            sOldParentId = newId;
                            sNewParentAllId = newId;
                          } else {
                            sOldParentId = arr[arr.length - 2];
                            if (treeCopyNodes.has(sOldParentId)) {
                              sNewParentAllId = treeCopyNodes.get(sOldParentId);
                            } else {
                              const obj = arr[arr.length - 1];
                              sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
                            }
                            const sNewArr = sNewParentAllId.split(',');
                            controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
                            sNewParentAllId = `${sNewParentAllId},${newId}`;
                            controlRow.sAllId = sNewParentAllId;
                          }
                          treeCopyNodes.set(controlItem.sId, sNewParentAllId);
                        }
                        controlData.push(controlRow);

                        if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
                          returnData.materialsData.filter(item => item.sControlId === controlItem.sId).forEach((materialsItem) => {
                            newCopyTo.materials = materialsItem;
                            const newSid = commonUtils.createSid();
                            let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo, { newSid }); // 取默认值
                            materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                            materialsRow.handleType = 'add';
                            materialsRow.sId = newSid;
                            materialsRow.sSlaveId = tableDataRow.sId;
                            materialsRow.sParentId = masterData.sId;
                            materialsRow.sControlId = controlRow.sId;
                            materialsRow.sPartsName = controlRow.sPartsName;

                            materialsData.push(materialsRow);
                          });
                        }

                        if (commonUtils.isNotEmptyArr(returnData.processData)) {
                          returnData.processData.filter(item => item.sControlId === controlItem.sId).forEach((processItem) => {
                            newCopyTo.process = processItem;
                            const newSid = commonUtils.createSid();
                            let processRow = commonFunc.getDefaultData(processConfig, newCopyTo, { newSid }); // 取默认值
                            processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                            processRow.handleType = 'add';
                            processRow.sId = newSid;
                            processRow.sSlaveId = tableDataRow.sId;
                            processRow.sParentId = masterData.sId;
                            processRow.sControlId = controlRow.sId;
                            processRow.sPartsName = controlRow.sPartsName;
                            processData.push(processRow);
                          });
                        }
                      });
                    }
                    if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
                      // eslint-disable-next-line no-loop-func
                      returnData.materialsData.filter(item => item.sType === '2').forEach((materialsItem) => {
                        newCopyTo.materials = materialsItem;
                        const newSid = commonUtils.createSid();
                        let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo, { newSid }); // 取默认值
                        materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                        materialsRow.handleType = 'add';
                        materialsRow.sId = newSid;
                        materialsRow.sSlaveId = tableDataRow.sId;
                        materialsRow.sParentId = masterData.sId;
                        materialsData.push(materialsRow);
                      });
                    }
                    if (commonUtils.isNotEmptyArr(returnData.processData)) {
                      // eslint-disable-next-line no-loop-func
                      returnData.processData.filter(item => item.sType === '3').forEach((processItem) => {
                        newCopyTo.process = processItem;
                        const newSid = commonUtils.createSid();
                        let processRow = commonFunc.getDefaultData(processConfig, newCopyTo, { newSid }); // 取默认值
                        processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                        processRow.handleType = 'add';
                        processRow.sId = newSid;
                        processRow.sSlaveId = tableDataRow.sId;
                        processRow.sParentId = masterData.sId;
                        processData.push(processRow);
                      });
                    }
                    addState.controlData = controlData;
                    addState.materialsData = materialsData;
                    addState.processData = processData;
                    addState.controlData = controlData;
                  }
                }
              }
            }
          } else {
            let tableDataRowAdd = this.handleTableAdd(tbName, true);
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
            // 取工艺卡数据
            if (tbName === 'slave') {
              const {
                controlConfig, materialsConfig, processConfig,
              } = this.props;
              let { controlData, materialsData, processData } = this.props;
              const sId = tableData[iIndex].sId;
              const bCkxCopyFromTechnology = '1'; // app.systemData.filter(item => item.sName === 'CkxCopyFromTechnology')[0].sValue;
              if (bCkxCopyFromTechnology === '1' && tableDataRowAdd.sProductId !== tableDataRowAdd.sProductName) {
                const controlSelectedData = controlData.filter(item => item.sSlaveId === sId);
                if (commonUtils.isNotEmptyObject(controlSelectedData)) {
                  const controlSelectedRowKeys = [];
                  controlSelectedData.forEach((item) => {
                    controlSelectedRowKeys.push(item.sId);
                  });
                  const materialsReturnData = this.otherTableDel('materials', controlSelectedRowKeys);
                  const processReturnData = this.otherTableDel('process', controlSelectedRowKeys);
                  const controlReturnData = this.props.onDataRowDel('control', true, controlSelectedRowKeys);
                  controlData = controlReturnData.controlData;
                  materialsData = materialsReturnData.materialsData;
                  processData = processReturnData.processData;
                  this.props.onSaveState({
                    ...materialsReturnData,
                    ...processReturnData,
                    ...controlReturnData,
                  });
                }
                const sCustomerId = masterData.sCustomerId;
                const sProductId = tableDataRowAdd.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 copyToMaterialsConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Materials'.toLowerCase());
                  const copyToProcessConfig = config.filter(item => item.sControlName.toLowerCase() === 'BtnCopyFrom.ActProcessCard.Process'.toLowerCase());
                  const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : '';
                  const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[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)) {
                    const treeCopyNodes = new Map();
                    // eslint-disable-next-line no-loop-func
                    returnData.controlData.forEach((controlItem) => {
                      newCopyTo.control = controlItem;
                      const newSid = commonUtils.createSid();
                      let controlRow = commonFunc.getDefaultData(controlConfig, newCopyTo, { newSid }); // 取默认值
                      controlRow = { ...controlRow, ...commonFunc.getAssignFieldValue(controlAssignField, controlItem, newCopyTo) }; // 取赋值字段
                      controlRow.handleType = 'add';
                      controlRow.sId = newSid;
                      controlRow.sSlaveId = tableDataRowAdd.sId;
                      controlRow.sParentId = masterData.sId;
                      if (sModelsType === 'sales/salesOrderPack') { /* 树形 */
                        /* CopyTo时sAllId,sControlParentId 设置 */
                        const sAllOldId = controlItem.sAllId;
                        let arr = [];
                        if (commonUtils.isNotEmptyObject(sAllOldId)) {
                          arr = sAllOldId.split(',');
                        }
                        const newId = controlRow.sId;
                        let sOldParentId = '';
                        let sNewParentAllId = '';
                        if (arr.length < 2) { /* 根节点复制 */
                          controlRow.sAllId = newId;
                          sOldParentId = newId;
                          sNewParentAllId = newId;
                        } else {
                          sOldParentId = arr[arr.length - 2];
                          if (treeCopyNodes.has(sOldParentId)) {
                            sNewParentAllId = treeCopyNodes.get(sOldParentId);
                          } else {
                            const obj = arr[arr.length - 1];
                            sNewParentAllId = sAllOldId.replace((`,${obj}`), '');
                          }
                          const sNewArr = sNewParentAllId.split(',');
                          controlRow.sControlParentId = sNewArr[sNewArr.length - 1];
                          sNewParentAllId = `${sNewParentAllId},${newId}`;
                          controlRow.sAllId = sNewParentAllId;
                        }
                        treeCopyNodes.set(controlItem.sId, sNewParentAllId);
                      }
                      controlData.push(controlRow);

                      if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
                        returnData.materialsData.filter(item => item.sControlId === controlItem.sId).forEach((materialsItem) => {
                          newCopyTo.materials = materialsItem;
                          const newSid = commonUtils.createSid();
                          let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo, { newSid }); // 取默认值
                          materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                          materialsRow.handleType = 'add';
                          materialsRow.sId = newSid;
                          materialsRow.sSlaveId = tableDataRowAdd.sId;
                          materialsRow.sParentId = masterData.sId;
                          materialsRow.sControlId = controlRow.sId;
                          materialsRow.sPartsName = controlRow.sPartsName;

                          materialsData.push(materialsRow);
                        });
                      }

                      if (commonUtils.isNotEmptyArr(returnData.processData)) {
                        returnData.processData.filter(item => item.sControlId === controlItem.sId).forEach((processItem) => {
                          newCopyTo.process = processItem;
                          const newSid = commonUtils.createSid();
                          let processRow = commonFunc.getDefaultData(processConfig, newCopyTo, { newSid }); // 取默认值
                          processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                          processRow.handleType = 'add';
                          processRow.sId = newSid;
                          processRow.sSlaveId = tableDataRowAdd.sId;
                          processRow.sParentId = masterData.sId;
                          processRow.sControlId = controlRow.sId;
                          processRow.sPartsName = controlRow.sPartsName;
                          processData.push(processRow);
                        });
                      }
                    });
                  }
                  if (commonUtils.isNotEmptyArr(returnData.materialsData)) {
                    // eslint-disable-next-line no-loop-func
                    returnData.materialsData.filter(item => item.sType === '2').forEach((materialsItem) => {
                      newCopyTo.materials = materialsItem;
                      const newSid = commonUtils.createSid();
                      let materialsRow = commonFunc.getDefaultData(materialsConfig, newCopyTo, { newSid }); // 取默认值
                      materialsRow = { ...materialsRow, ...commonFunc.getAssignFieldValue(materialsAssignField, materialsItem, newCopyTo) }; // 取赋值字段
                      materialsRow.handleType = 'add';
                      materialsRow.sId = newSid;
                      materialsRow.sSlaveId = tableDataRowAdd.sId;
                      materialsRow.sParentId = masterData.sId;
                      materialsData.push(materialsRow);
                    });
                  }
                  if (commonUtils.isNotEmptyArr(returnData.processData)) {
                    // eslint-disable-next-line no-loop-func
                    returnData.processData.filter(item => item.sType === '3').forEach((processItem) => {
                      newCopyTo.process = processItem;
                      const newSid = commonUtils.createSid();
                      let processRow = commonFunc.getDefaultData(processConfig, newCopyTo, { newSid }); // 取默认值
                      processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignField, processItem, newCopyTo) }; // 取赋值字段
                      processRow.handleType = 'add';
                      processRow.sId = newSid;
                      processRow.sSlaveId = tableDataRowAdd.sId;
                      processRow.sParentId = masterData.sId;
                      processData.push(processRow);
                    });
                  }
                  addState.controlData = controlData;
                  addState.materialsData = materialsData;
                  addState.processData = processData;
                  addState.controlData = controlData;
                }
              }
            }
            tableData.push(tableDataRowAdd);
          }
          this.props.onSaveState({ [`${tbName}Data`]: tableData, ...addState });
        });
      }
    };

    handleTableBlur = async (name, sFieldName, record, tableConfig) => {
      const { sModelsId, app, token, sModelsType, [`${name}Data`]: tableData, [`${name}Data`]: tableSelectedRowKeys, masterData , [`${name}Config`]: tempConfig } = this.props;
      const models = name === 'materials' ? 'Materials' :
        sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('print/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
      let tableDataRow = {};
      if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || (sModelsType && sModelsType !== 'outside/outsideprocessAll' && sFieldName === 'dAuxiliaryQty') || sFieldName === 'dReelAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle') {
        let iIndex = -1;
        if(commonUtils.isEmptyArr(tableSelectedRowKeys)) {
          iIndex = 0;
        } else {
          tableData.findIndex(item => item.sId === tableSelectedRowKeys.toString())
        }
        tableDataRow = await this.handleMaterialsChange(record, sModelsId, masterData, {}, sFieldName, app, token, models);
        if(iIndex > -1) {
          tableData[iIndex] = tableDataRow;
        }
        this.props.onSaveState({ [`${name}Data`]: tableData})
      } else if(commonUtils.isNotEmptyObject(tableConfig) && commonUtils.isNotEmptyObject(tableConfig.sButtonParam) && sFieldName === 'sInkBOM') {
        let { materials0Data, materials0DelData } = this.props;
        if(commonUtils.isEmptyArr(materials0Data)) {
          materials0Data = [];
        }
        if(commonUtils.isEmptyArr(materials0DelData)) {
          materials0DelData = [];
        }
        const sTmpInfoConfig = tableConfig;
        const sButtonParam = tableConfig.sButtonParam;
        const btn = commonUtils.isNotEmptyObject(sButtonParam) && commonUtils.isJSON(sButtonParam)?  JSON.parse(sButtonParam) : {};;
        const sProName = commonUtils.isNotEmptyObject(btn) ?  btn.sproName : '';
        const sTmpInfoBySqlBtnName = commonUtils.isNotEmptyObject(btn) ? btn.sControlName : '';
        const sActiveKey = sTmpInfoConfig.sActiveKey;
        if (commonUtils.isNotEmptyObject(sTmpInfoConfig) && sTmpInfoBySqlBtnName.includes('sTmpInfoBySql')) {
          const newCopyTo = {};
          newCopyTo.master = masterData;
          /* 找到自定义TempInfo配置 */

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

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

                    /* 找到老数据的oldRowMap sInkBOMId 信息 */
                    // const recordOldRow = record.oldRowMap;
                    let oldMFilterData = materials0Data.filter(old => old.sInkFatherMaterialsTbId === record.sId);
                    // if(commonUtils.isEmptyArr(oldMFilterData) && commonUtils.isNotEmptyObject(recordOldRow)) {
                    //    oldMFilterData = materials0Data.filter(old => commonUtils.isNotEmptyObject(old.sInkBOMId) && commonUtils.isNotEmptyObject(old.sInkBOMsSlaveId) && old.sInkBOMId === recordOldRow.sInkBOMId && old.sInkBOMsSlaveId === recordOldRow.sInkBOMsSlaveId && commonUtils.isEmpty(old.sInkBOMsMaterialsId) );
                    // }
                    oldMFilterData.forEach((child) => {
                      child.handleType ='del';
                      const iIndex = materials0Data.findIndex(item => item.sId === child.sId);
                      if(iIndex > -1 ) {
                        materials0Data.splice(iIndex, 1);
                      }
                      materials0DelData.push(child);
                    });

                    allReturnMap[sDelName] = oldDelData;
                    oldData = [];
                    if(commonUtils.isNotEmptyArr(keyData)) {
                      keyData.forEach((child) => {
                        const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111
                        tableRow.sId = commonUtils.createSid();
                        tableRow.sParentId = masterData.sId;
                        tableRow.sInkFatherMaterialsTbId = record.sId;
                        tableRow.handleType = 'add';
                        // tableRow.sBclassifyName ='油墨';
                        oldData.push(tableRow);
                        materials0Data.push(tableRow);
                      });
                    }
                    allReturnMap[sName] = oldData;
                    allReturnMap.materials0Data = materials0Data;
                    allReturnMap.materials0DelData = materials0DelData;
                  } else {
                    allReturnMap[sName] = returnData[key];
                  }

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

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

    handleShowParam = (name,  record, tableSelectedRowKeys) => {
      let processSelectedData = [];
      if(commonUtils.isNotEmptyObject(record)) {
        processSelectedData = [record];
      }
      this.props.onSaveState({
        commonParamVisible: true,
        processSelectedData,
        processSelectedRowKeys:tableSelectedRowKeys,
      });
    }

    handleSelectCommonPopup = (currentPaneName, selectConfig, selectData, tbName, commonPopupShowConfig, other) => {
      const {
        [`${tbName}Data`]: tableData, [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData, processConfig,
      } = this.props;

      /* 工单，工艺卡 放大镜选择材料 直接插入全部材料中 */
      if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopupMaterialsWorkOrder') {

        let { materials0Data, materials1Data, materials1Config,  materials2Data, materials2Config, } = this.props;

        if(commonUtils.isEmptyArr(materials0Data)){
          materials0Data = [];
        }
        if(commonUtils.isEmptyArr(materials1Data)){
          materials1Data = [];
        }
        if(commonUtils.isEmptyArr(materials2Data)){
          materials2Data = [];
        }
        /* 找到放大镜复制到配置 */

        /* 材料大类 */
        const copyToConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials0`.toLowerCase());
        const copyToAssignField = commonUtils.isNotEmptyArr(copyToConfig) ? copyToConfig[0].sAssignField : ''; /* 材料大类 */

        const addState ={};
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        if (commonUtils.isNotEmptyArr(selectData)) {
          const selectFilterDataAll =  selectData; /* 除了油墨,专色墨,电化铝之外的物料大类 */

          /* 全部材料 */
          if(commonUtils.isNotEmptyArr(selectFilterDataAll)) {
            selectFilterDataAll.forEach((item, index) => {
              const newCopyTo = {};
              newCopyTo.master = masterData;
              if (iIndex > -1) {
                newCopyTo.materials0 = item;
              }
              let tableDataRowAdd = this.handleTableAdd('materials0', true);
              item.handleType = 'add';
              // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
              tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField, item) }; // 取赋值字段
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = masterData.sId;
              tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
              materials0Data.push(tableDataRowAdd);
            });
          }
          console.log('222', materials0Data, copyToAssignField);

          if(commonUtils.isNotEmptyArr(materials0Data) && location.pathname.includes('processCardPackTableTree')) {
            /* 根据配置过滤数据 */
            const sSqlCondition1 = materials1Config ? materials1Config.sSqlCondition : 'materials0.sBclassifyName.油墨';
            if (commonUtils.isNotEmptyObject(sSqlCondition1)) {
              let targetTbName = sSqlCondition1.split('.')[0]; /* 1.表名 control  */
              let filteredValue = sSqlCondition1.split('.')[1]; /* 2.解析filterValue: controlSelectedRowKeys */
              let sParentKey = sSqlCondition1.split('.')[2]; /* 2.解析本身表对应的值,如控制表筛选材料表 则材料表的sControlId = 控制表的controlSelectedRowKeys[0] */
              if (targetTbName === 'materials0') {
                const filterData = materials0Data.filter(item => sParentKey && sParentKey.includes(item[filteredValue]));
                if (commonUtils.isNotEmptyArr(filterData))
                  filterData.forEach((item, index) => {
                    materials1Data.push(item);
                  })
              }
            }


            const sSqlCondition2 = materials2Config ? materials2Config.sSqlCondition : 'materials0.sBclassifyName.电化铝';
            if (commonUtils.isNotEmptyObject(sSqlCondition2)) {
              let targetTbName = sSqlCondition2.split('.')[0]; /* 1.表名 control  */
              let filteredValue = sSqlCondition2.split('.')[1]; /* 2.解析filterValue: controlSelectedRowKeys */
              let sParentKey = sSqlCondition2.split('.')[2]; /* 2.解析本身表对应的值,如控制表筛选材料表 则材料表的sControlId = 控制表的controlSelectedRowKeys[0] */
              if (targetTbName === 'materials0') {
                const filterData = materials0Data.filter(item => item[filteredValue] === sParentKey);
                if (commonUtils.isNotEmptyArr(filterData))
                  filterData.forEach((item, index) => {
                    materials2Data.push(item);
                  })
              }
            }

            addState.materials1Data = materials1Data;
            addState.materials2Data = materials2Data;
          } else  if(commonUtils.isNotEmptyArr(materials0Data) && location.pathname.includes('workOrderResearchTableTree')) {
            /* 根据配置过滤数据 */
            const sSqlCondition1 = materials1Config ? materials1Config.sSqlCondition : 'materials0.sBclassifyName.纸张';
            if (commonUtils.isNotEmptyObject(sSqlCondition1)) {
              let targetTbName = sSqlCondition1.split('.')[0]; /* 1.表名 control  */
              let filteredValue = sSqlCondition1.split('.')[1]; /* 2.解析filterValue: controlSelectedRowKeys */
              let sParentKey = sSqlCondition1.split('.')[2]; /* 2.解析本身表对应的值,如控制表筛选材料表 则材料表的sControlId = 控制表的controlSelectedRowKeys[0] */
              if (targetTbName === 'materials0') {
                const filterData = materials0Data.filter(item => sParentKey && sParentKey.includes(item[filteredValue]));
                if (commonUtils.isNotEmptyArr(filterData))
                  filterData.forEach((item, index) => {
                    materials1Data.push(item);
                  })
              }
            }


            const sSqlCondition2 = materials2Config ? materials2Config.sSqlCondition : 'materials0.sBclassifyName.油墨';
            if (commonUtils.isNotEmptyObject(sSqlCondition2)) {
              let targetTbName = sSqlCondition2.split('.')[0]; /* 1.表名 control  */
              let filteredValue = sSqlCondition2.split('.')[1]; /* 2.解析filterValue: controlSelectedRowKeys */
              let sParentKey = sSqlCondition2.split('.')[2]; /* 2.解析本身表对应的值,如控制表筛选材料表 则材料表的sControlId = 控制表的controlSelectedRowKeys[0] */
              if (targetTbName === 'materials0') {
                const filterData = materials0Data.filter(item => item[filteredValue] === sParentKey);
                if (commonUtils.isNotEmptyArr(filterData))
                  filterData.forEach((item, index) => {
                    materials2Data.push(item);
                  })
              }
            }

            addState.materials1Data = materials1Data;
            addState.materials2Data = materials2Data;
          }
          this.props.onSaveState({ materials0Data, ...addState });
        }
      } else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopupMaterialsQuo') {

        let { materialsData, materials0Data, materials1Data,  materials0Config, materials1Config,  materials2Data, materials2Config, } = this.props;

        if(commonUtils.isEmptyArr(materialsData)){
          materialsData = [];
        }
        if(commonUtils.isEmptyArr(materials0Data)){
          materials0Data = [];
        }

        if(commonUtils.isEmptyArr(materials1Data)){
          materials1Data = [];
        }
        if(commonUtils.isEmptyArr(materials2Data)){
          materials2Data = [];
        }
        /* 找到放大镜复制到配置 */

        /* 材料大类 */
        const copyToConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials0`.toLowerCase());
        const copyToAssignField = commonUtils.isNotEmptyArr(copyToConfig) ? copyToConfig[0].sAssignField : ''; /* 材料大类 */

        const addState ={};
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        if (commonUtils.isNotEmptyArr(selectData)) {
          const selectFilterDataAll =  selectData; /* 除了油墨,专色墨,电化铝之外的物料大类 */
          /* 全部材料 */
          if(commonUtils.isNotEmptyArr(selectFilterDataAll)) {
            selectFilterDataAll.forEach((item, index) => {
              const newCopyTo = {};
              newCopyTo.master = masterData;
              if (iIndex > -1) {
                newCopyTo.materials0 = item;
              }
              let tableDataRowAdd = this.handleTableAdd('materials0', true);
              item.handleType = 'add';
              // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
              tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField, item) }; // 取赋值字段
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = masterData.sId;
              tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
              materialsData.push(tableDataRowAdd);
            });
          }
          if(false && commonUtils.isNotEmptyArr(materialsData)) {
            /* 根据配置过滤数据 */
            const sSqlCondition1 = materials0Config ? materials0Config.sSqlCondition : 'materials0.sBclassifyName.油墨';
            if (commonUtils.isNotEmptyObject(sSqlCondition1)) {
              let targetTbName = sSqlCondition1.split('.')[0]; /* 1.表名 control  */
              let filteredValue = sSqlCondition1.split('.')[1]; /* 2.解析filterValue: controlSelectedRowKeys */
              let sParentKey = sSqlCondition1.split('.')[2]; /* 2.解析本身表对应的值,如控制表筛选材料表 则材料表的sControlId = 控制表的controlSelectedRowKeys[0] */
              if (targetTbName === 'materials0') {
                const filterData = materials0Data.filter(item => sParentKey && sParentKey.includes(item[filteredValue]));
                if (commonUtils.isNotEmptyArr(filterData))
                  filterData.forEach((item, index) => {
                    materials0Data.push(item);
                  })
              }
            }


            const sSqlCondition2 = materials1Config ? materials1Config.sSqlCondition : 'materials0.sBclassifyName.电化铝';
            if (commonUtils.isNotEmptyObject(sSqlCondition2)) {
              let targetTbName = sSqlCondition2.split('.')[0]; /* 1.表名 control  */
              let filteredValue = sSqlCondition2.split('.')[1]; /* 2.解析filterValue: controlSelectedRowKeys */
              let sParentKey = sSqlCondition2.split('.')[2]; /* 2.解析本身表对应的值,如控制表筛选材料表 则材料表的sControlId = 控制表的controlSelectedRowKeys[0] */
              if (targetTbName === 'materials0') {
                const filterData = materials0Data.filter(item => item[filteredValue] === sParentKey);
                if (commonUtils.isNotEmptyArr(filterData))
                  filterData.forEach((item, index) => {
                    materials1Data.push(item);
                  })
              }
            }
            addState.materialsData = materialsData;
            addState.materials0Data = materials0Data;
            addState.materials1Data = materials1Data;
            addState.materials2Data = materials2Data;
          }
          this.props.onSaveState({  ...addState });
        }
      }else if(selectConfig.sControlName && (selectConfig.sControlName === 'BtnPopupMaterials1Child' || selectConfig.sControlName.includes('BtnHeadPopup') )) {
        const {materials0SelectedRowKeys, materials1SelectedRowKeys, materials2SelectedRowKeys} = this.props; /* 油墨数据选中行 */
        let { materials0Data } = this.props;
        let fatherRow = {};
        if(tbName === 'materials1Child') {
          const iIndex = commonUtils.isNotEmptyArr(materials1SelectedRowKeys) ? materials0Data.findIndex(item => item.sId === materials1SelectedRowKeys[0]) : -1;
          if(iIndex  === -1) {
            message.error('请选择左侧选择行！');
            return;
          }
          fatherRow =  materials1Data[iIndex];
        }else if(tbName === 'materials2Child') {
          const iIndex = commonUtils.isNotEmptyArr(materials2SelectedRowKeys) ? materials0Data.findIndex(item => item.sId === materials2SelectedRowKeys[0]) : -1;
          if(iIndex  === -1) {
            message.error('请选择左侧选择行！');
            return;
          }
          fatherRow =  materials2Data[iIndex];
        } else if(tbName === 'materials0Child') {
          const iIndex = commonUtils.isNotEmptyArr(materials0SelectedRowKeys) ? materials0Data.findIndex(item => item.sId === materials0SelectedRowKeys[0]) : -1;
          if(iIndex  === -1) {
            message.error('请选择左侧选择行！');
            return;
          }
          fatherRow =  materials0Data[iIndex];
        }

        let { [`${tbName}Data`]: tableData } = this.props;
        if(commonUtils.isEmptyArr(tableData)) {
          tableData = [];
        }
        if(commonUtils.isEmptyArr(materials0Data)) {
          materials0Data = [];
        }

        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            const newCopyTo = {};
            newCopyTo.master = masterData;
            let tableDataRowAdd = this.handleTableAdd(tbName, true);
            item.handleType = 'add';
            tableDataRowAdd = {...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item)}; // 取赋值字段
            tableDataRowAdd.handleType = 'add';
            tableDataRowAdd.sId = commonUtils.createSid();
            tableDataRowAdd.sParentId = masterData.sId;
            tableDataRowAdd.sParentMaterialsId = fatherRow.sId; /* 选中从表的sId */
            tableDataRowAdd.sProcessId = fatherRow.sProcessId; /* 工序ID */
            tableDataRowAdd.sProcessTbId = fatherRow.sProcessTbId; /* 工序表格ID */
            if(tbName === 'materials0Child') { /* 替代料 */
              tableDataRowAdd.sMaterialsNo1 = fatherRow.sMaterialsNo; /* 原材料编号 */
              tableDataRowAdd.sMaterialsName1 = fatherRow.sMaterialsName;  /* 原材料名称 */
              tableDataRowAdd.bAlternative = true;
            }

            // const newTableDataRowAdd =  JSON.parse(JSON.stringify(tableDataRowAdd));
              // newTableDataRowAdd.sId = commonUtils.createSid();
              materials0Data.push(tableDataRowAdd);


          });
          console.log('放大镜确认数据：',tbName,  tableData, materials0Data)
          this.props.onSaveState({ materials0Data });
        }
      } else if(selectConfig.sControlName && selectConfig.sControlName.includes('BtnPopupMaterials')) { /* 报价单工序表放大镜 选择材料 */
        /* materials1ChildData:油墨, materials2ChildData：电化铝 */
        let { materials1Data, materials1ChildData, materials2Data,  materials2ChildData, materials0Data, processData, processSelectedRowKeys } = this.props;
        let materialsOtherData = [];

        if(commonUtils.isEmptyArr(materials0Data)){
          materials0Data = [];
        }

        if(commonUtils.isEmptyArr(materials1Data)){
          materials1Data = [];
        }

        if(commonUtils.isEmptyArr(materials1ChildData)){
          materials1ChildData = [];
        }

        if(commonUtils.isEmptyArr(materials2ChildData)){
          materials2ChildData = [];
        }

        if(commonUtils.isEmptyArr(materials2Data)) {
          materials2Data = [];
        }

        /* 找到放大镜复制到配置 */
        /* 材料大类 */
        const copyToConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials0`.toLowerCase());
        const copyToAssignField = commonUtils.isNotEmptyArr(copyToConfig) ? copyToConfig[0].sAssignField : ''; /* 材料大类 */

        /* 自调专色墨 */
        const copyToConfig1Left = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials1`.toLowerCase());
        const copyToAssignField1Left = commonUtils.isNotEmptyArr(copyToConfig1Left) ? copyToConfig1Left[0].sAssignField : ''; /* 专色墨 */

        /* 油墨 */
        const copyToConfig1 = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials1Child`.toLowerCase());
        const copyToAssignField1 = commonUtils.isNotEmptyArr(copyToConfig1) ? copyToConfig1[0].sAssignField : ''; /* 油墨 */

        /* 油墨 */
        const copyToConfig2 = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${selectConfig.sControlName}.materials2Child`.toLowerCase());
        const copyToAssignField2 = commonUtils.isNotEmptyArr(copyToConfig2) ? copyToConfig2[0].sAssignField : ''; /* 电化铝 */

        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        if (commonUtils.isNotEmptyArr(selectData)) {
          if (commonUtils.isEmpty(materials1ChildData)) {
            materials1ChildData = [];
          }
          if (commonUtils.isEmpty(materials2ChildData)) {
            materials2ChildData = [];
          }
          // const selectFilterData1 =  selectData.filter(item => item.sZmldlName === sMaterialsClassfiy.youmo);
          // const selectFilterData1Left =  selectData.filter(item => item.sZmldlName === sMaterialsClassfiy.zsm);
          // // const selectFilterData1 =  selectData.filter(item => item.sZmldlName === '纸张');
          // const selectFilterData2 =  selectData.filter(item => item.sZmldlName === sMaterialsClassfiy.dhl );
          //
          // const selectFilterDataOther =  selectData.filter(item => item.sZmldlName !== sMaterialsClassfiy.youmo &&
          //   item.sZmldlName !== sMaterialsClassfiy.zsm && item.sZmldlName !== sMaterialsClassfiy.dhl  ); /* 除了油墨,专色墨,电化铝之外的物料大类 */
          //
          // /* 自动专色墨 */
          // if(commonUtils.isNotEmptyArr(selectFilterData1Left)) {
          //   selectFilterData1Left.forEach((item, index) => {
          //     const newCopyTo = {};
          //     newCopyTo.master = masterData;
          //     if (iIndex > -1) {
          //       newCopyTo.materials1Child = item;
          //     }
          //     let tableDataRowAdd = this.handleTableAdd('materials1', true);
          //     item.handleType = 'add';
          //     // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
          //     tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField1Left, item) }; // 取赋值字段
          //     tableDataRowAdd.sId = commonUtils.createSid();
          //     tableDataRowAdd.sParentId = masterData.sId;
          //     tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
          //     materials1Data.push(tableDataRowAdd);
          //   });
          // }
          //
          // /* 油墨 */
          // if(commonUtils.isNotEmptyArr(selectFilterData1)) {
          //   selectFilterData1.forEach((item, index) => {
          //     const newCopyTo = {};
          //     newCopyTo.master = masterData;
          //     if (iIndex > -1) {
          //       newCopyTo.materials1Child = item;
          //     }
          //     let tableDataRowAdd = this.handleTableAdd('materials1Child', true);
          //     item.handleType = 'add';
          //     // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
          //     tableDataRowAdd = {...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField1, item)}; // 取赋值字段
          //     tableDataRowAdd.sId = commonUtils.createSid();
          //     tableDataRowAdd.sParentId = masterData.sId;
          //     tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
          //     materials1ChildData.push(tableDataRowAdd);
          //   });
          // }
          //
          // /* 电化铝 */
          // if(commonUtils.isNotEmptyArr(selectFilterData2)) {
          //   selectFilterData2.forEach((item, index) => {
          //     const newCopyTo = {};
          //     newCopyTo.master = masterData;
          //     if (iIndex > -1) {
          //       newCopyTo.materials2Child = item;
          //     }
          //     let tableDataRowAdd = this.handleTableAdd('materials2Child', true);
          //     item.handleType = 'add';
          //     // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
          //     tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField2, item) }; // 取赋值字段
          //     tableDataRowAdd.sId = commonUtils.createSid();
          //     tableDataRowAdd.sParentId = masterData.sId;
          //     tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
          //     materials2ChildData.push(tableDataRowAdd);
          //   });
          // }
          //
          // if(commonUtils.isNotEmptyArr(materials2ChildData)) {
          //   materials2ChildData.forEach((val) => {
          //     const iIndex = materials2Data.findIndex(item => item.sMaterialsId === val.sMaterialsId  && item.sControlId  === val.sControlId && item.sMaterialsStyle === val.sMaterialsStyle);
          //     if(iIndex === -1){
          //       materials2Data.push(val);
          //     }
          //   });
          // }
          //

          // /* 其他材料 */
          // if(commonUtils.isNotEmptyArr(selectFilterDataOther)) {
          //   selectFilterDataOther.forEach((item, index) => {
          //     const newCopyTo = {};
          //     newCopyTo.master = masterData;
          //     if (iIndex > -1) {
          //       newCopyTo.materials0 = item;
          //     }
          //     let tableDataRowAdd = this.handleTableAdd('materials0', true);
          //     item.handleType = 'add';
          //     // tableDataRowAdd = { ...tableDataRowAdd, ...item }; // 取赋值字段
          //     tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField, item) }; // 取赋值字段
          //     tableDataRowAdd.sId = commonUtils.createSid();
          //     tableDataRowAdd.sParentId = masterData.sId;
          //     tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
          //     if(commonUtils.isNotEmptyObject(processRow)) {
          //       if(commonUtils.isEmptyObject(tableDataRowAdd.sProcessId) ) {
          //         tableDataRowAdd.sProcessId = processRow.sProcessId; /* 选中从表的sId */
          //       }
          //       if(commonUtils.isEmptyObject(tableDataRowAdd.sProcessTbId) ) {
          //         tableDataRowAdd.sProcessTbId = processRow.sId; /* 选中从表的sId */
          //       }
          //       if(commonUtils.isEmptyObject(tableDataRowAdd.sControlId) ) {
          //         tableDataRowAdd.sControlId = processRow.sControlId; /* 选中从表的sId */
          //       }
          //     }
          //
          //     materialsOtherData.push(tableDataRowAdd);
          //   });
          // }
          // const temp1Data = materials1Data.concat(materials1ChildData);
          // const temp2Data = temp1Data.concat(materials2Data);
          //
          // materials0Data = temp2Data.concat(materialsOtherData);
          let processRow = {};
          if(commonUtils.isNotEmptyArr(processData) && commonUtils.isNotEmptyArr(processSelectedRowKeys)) {
            const iPIndex =  processData.findIndex(item => processSelectedRowKeys.includes(item.sId));
            if(iPIndex > -1) {
              processRow =  processData[iPIndex];
            }
          }
          const selectFilterDataAll =  selectData; /* 除了油墨,专色墨,电化铝之外的物料大类 */
          /* 全部材料 */
          if(commonUtils.isNotEmptyArr(selectFilterDataAll)) {
            selectFilterDataAll.forEach((item, index) => {
              const newCopyTo = {};
              newCopyTo.master = masterData;
              if (iIndex > -1) {
                newCopyTo.materials0 = item;
              }
              let tableDataRowAdd = this.handleTableAdd('materials0', true);
              item.handleType = 'add';
              tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(copyToAssignField, item) }; // 取赋值字段
              tableDataRowAdd.sId = commonUtils.createSid();
              tableDataRowAdd.sParentId = masterData.sId;
              tableDataRowAdd.sParentSlaveId = tableData[iIndex].sId; /* 选中从表的sId */
              if(commonUtils.isNotEmptyObject(processRow)) {
                if(commonUtils.isEmptyObject(tableDataRowAdd.sProcessId) ) {
                  tableDataRowAdd.sProcessId = processRow.sProcessId; /* 选中从表的sId */
                }
                if(commonUtils.isEmptyObject(tableDataRowAdd.sProcessTbId) ) {
                  tableDataRowAdd.sProcessTbId = processRow.sId; /* 选中从表的sId */
                }
                if(commonUtils.isEmptyObject(tableDataRowAdd.sControlId) ) {
                  tableDataRowAdd.sControlId = processRow.sControlId; /* 选中从表的sId */
                }
              }
              materials0Data.push(tableDataRowAdd);
            });
          }

          console.log('materials1Data1:', materials0Data,  materials1Data, materials1ChildData, materials2ChildData, materialsOtherData);

          this.props.onSaveState({ materials1Data,  materials1ChildData, materials2ChildData, materialsOtherData, materials0Data });
        }
      }else if( location.pathname && location.pathname.includes('quotationPackTableTree') && selectConfig.sName && selectConfig.sName === 'sAlumiteBomBillNo') { /* 报价单电化铝Bom选择数据后，数据带入到电化铝 */
        let { materialsData,materials1Data, materials2Data, materials2ChildData, materials0Data } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(materials0Data)){
          materials0Data = [];
        }
        if(commonUtils.isEmptyArr(materials0Data)){
          materials0Data = [];
        }
        if(commonUtils.isEmptyArr(materials1Data)){
          materials1Data = [];
        }
        if(commonUtils.isEmptyArr(materials2Data)){
          materials2Data = [];
        }
        if(commonUtils.isEmptyArr(materials2ChildData)){
          materials2ChildData = [];
        }
        const sControlName = 'sPopupsAlumiteBomBillNo';
        /* 电化铝父级赋值配置 */
        const copyToConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${sControlName}.materials2Data`.toLowerCase());
        const copyToAssignField = commonUtils.isNotEmptyArr(copyToConfig) ? copyToConfig[0].sAssignField : ''; /* 电化铝 */

        /* 电化铝子级赋值配置 */
        const copyToChildConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${sControlName}.materials2ChildData`.toLowerCase());
        const copyToChildAssignField = commonUtils.isNotEmptyArr(copyToChildConfig) ? copyToChildConfig[0].sAssignField : ''; /* 电化铝子级 */

        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            const newCopyTo = {};
            newCopyTo.master = masterData;
            let tableDataRowAdd = this.handleTableAdd('materials1Data', true);
            item.handleType = 'add';
            tableDataRowAdd = {...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item)}; // 取赋值字段
            tableDataRowAdd.sId = commonUtils.createSid();
            tableDataRowAdd.sParentId = masterData.sId;
            // tableDataRowAdd.sParentMaterialsId = fatherRow.sId; /* 选中从表的sId */
            materials1Data.push(tableDataRowAdd);
            const newTableDataRowAdd =  JSON.parse(JSON.stringify(tableDataRowAdd));
            // newTableDataRowAdd.sId = commonUtils.createSid();
            materialsData.push(newTableDataRowAdd);
          });
          addState.materials1Data = materials1Data;
          addState.materialsData = materialsData;
          this.props.onSaveState({ materials1Data, materials2Data, materials0Data });
        }
      } else if( (selectConfig.sName && selectConfig.sName === 'sAlumiteBomBillNo') || selectConfig?.sControlName === 'BtnPopupsAlumiteBomBillNo') { /* 电化铝Bom选择数据后，数据带入到电化铝 */
        let { materials2Data, materials2ChildData, materialsData, materials0Data, processData, processSelectedRowKeys, materialsDelData,  materials0DelData } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(materialsData)){
          materialsData = [];
        }
        if(commonUtils.isEmptyArr(materials0Data)){
          materials0Data = [];
        }
        if(commonUtils.isEmptyArr(materials2Data)){
          materials2Data = [];
        }
        if(commonUtils.isEmptyArr(materials2ChildData)){
          materials2ChildData = [];
        }
        if(commonUtils.isEmptyArr(materials0DelData)){
          materials0DelData = [];
        }
        if(commonUtils.isEmptyArr(materialsDelData)){
          materialsDelData = [];
        }
        const sControlName = 'sPopupsAlumiteBomBillNo';
        /* 电化铝父级赋值配置 */
        const copyToConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${sControlName}.materials2Data`.toLowerCase());
        const copyToAssignField = commonUtils.isNotEmptyArr(copyToConfig) ? copyToConfig[0].sAssignField : ''; /* 电化铝 */

        /* 电化铝子级赋值配置 */
        const copyToChildConfig = processConfig.gdsconfigformslave.filter(item => item.sControlName.toLowerCase() === `${sControlName}.materials2ChildData`.toLowerCase());
        const copyToChildAssignField = commonUtils.isNotEmptyArr(copyToChildConfig) ? copyToChildConfig[0].sAssignField : ''; /* 电化铝子级 */

        if (commonUtils.isNotEmptyArr(selectData)) {
          if (commonUtils.isNotEmptyArr(processSelectedRowKeys) && commonUtils.isNotEmptyArr(processData)) {
            const iProcessIndex = processData.findIndex(item => item.sId === processSelectedRowKeys[0]);
            processData[iProcessIndex].handleType = commonUtils.isEmpty(processData[iProcessIndex].handleType) ? 'update' : processData[iProcessIndex].handleType;
            processData[iProcessIndex].sAlumiteBomBillNo = selectData[0].sVersionNum;
            addState.processData = processData;
            /* 移除该工序下的所有电化铝 */
            const filterDelData  =  materials0Data.filter(row => row.sProcessId === processData[iProcessIndex].sProcessId &&
              row.sProcessTbId === processData[iProcessIndex].sId && row.sBclassifyName === '电化铝' && commonUtils.isEmptyObject(row.sParentMaterialsId));
            console.log('移除该工序下的所有电化铝', filterDelData);
            if(commonUtils.isNotEmptyArr(filterDelData)) {
              filterDelData.forEach((item, index) => {
                const iIndex = materials0Data.findIndex(row => row.sId === item.sId);
                if(iIndex > -1) {
                  const delRow = materials0Data[iIndex];
                  delRow.handleType = 'del';
                  if(selectConfig?.sControlName === 'BtnPopupsAlumiteBomBillNo') {
                    materialsData.splice(iIndex, 1);
                    materialsDelData.push(delRow);
                  } else {
                    materials0Data.splice(iIndex, 1);
                    materials0DelData.push(delRow);
                  }
                }
              })
            }
          }
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            // const iIndex = materials0Data.findIndex(row => row.sAluminumBomId === item.sId && row.sAluminumBomSlaveId === item.sSlaveId);
            // console.log('iIndex', iIndex);
            // if(iIndex > -1) {
            //   const delRow = materials0Data[iIndex];
            //   delRow.handleType = 'del';
            //   if(selectConfig?.sControlName === 'BtnPopupsAlumiteBomBillNo') {
            //     materialsData.splice(iIndex, 1);
            //     materialsDelData.push(delRow);
            //   } else {
            //     materials0Data.splice(iIndex, 1);
            //     materials0DelData.push(delRow);
            //   }
            // }
            const newCopyTo = {};
            newCopyTo.master = masterData;
            let tableDataRowAdd = this.handleTableAdd('materials2Data', true);
            item.handleType = 'add';
            tableDataRowAdd = {...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item)}; // 取赋值字段
            tableDataRowAdd.sId = commonUtils.createSid();
            tableDataRowAdd.sParentId = masterData.sId;
            // tableDataRowAdd.sParentMaterialsId = fatherRow.sId; /* 选中从表的sId */
            materials2Data.push(tableDataRowAdd);

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

            const newTableDataRowAdd =  JSON.parse(JSON.stringify(tableDataRowAdd));
            // newTableDataRowAdd.sId = commonUtils.createSid();
            materials0Data.push(newTableDataRowAdd);
            if(selectConfig?.sControlName === 'BtnPopupsAlumiteBomBillNo') {
              materialsData.push(newTableDataRowAdd);
            }
          });
          if(selectConfig?.sControlName === 'BtnPopupsAlumiteBomBillNo') {
            addState.materialsData = materialsData;
            addState.materialsDelData = materialsDelData;
          } else {
            addState.materials0Data = materials0Data;
            addState.materials0DelData = materials0DelData;
          }


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

          this.props.onSaveState({ ...addState });
        }
      } else if (selectConfig.sControlName?.startsWith('BtnPopupEdit')) {
       if (!Array.isArray(selectData)) return;
       if (other?.index >= 0 && tableData[other.index]) {
        tableData[other.index][selectConfig.sActiveKey] = JSON.stringify(selectData || []);
        if (!tableData[other.index].handleType) {
          tableData[other.index].handleType = 'update';
        }
       }
        this.props.onSaveState({ [`${tbName}Data`]: [...tableData] });
      }else if(selectConfig.sControlName && selectConfig.sControlName === 'BtnPopup.dPreMatProductQty') { /* 消耗备料 */
        let { slaveData, slaveSelectedRowKeys } = this.props;
        const addState ={};
        if(commonUtils.isEmptyArr(slaveData)){
          slaveData = [];
        }
        const iIndex = this.handleGetSelectedIndex(this.props, 'slave');
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        if (commonUtils.isNotEmptyArr(selectData)) {
          // eslint-disable-next-line no-unused-vars
          selectData.forEach((item, index) => {
            dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0);
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.sId = item.sId;
            obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0;
            jsonData.push(obj);
          });
          addState.dPreMatProductQty = dModifyProductQty;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sPreMatProduct = jsonStr;
          }
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        } else {
          addState.dPreMatProductQty = 0;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          addState.sPreMatProduct = '';
          if(iIndex > -1) {
            slaveData[iIndex] = { ...slaveData[iIndex], ...addState };
          }
          addState.slaveData = slaveData;
          this.props.onSaveState({ ...addState });
        }
      } else if(selectConfig.sName === 'sOrderNo' ) { /* 选择试制订单号 */
        const { controlData : controlDataNew, packData} = this.props;
        const addReturn = this.props.onSelectCommonPopup(currentPaneName, selectConfig, selectData, tbName, true);
        const addState = {};
        const tableData = commonUtils.isNotEmptyObject(addReturn) && commonUtils.isNotEmptyArr(addReturn[tbName +'Data']) ? addReturn[tbName +'Data'] : [];
        if(commonUtils.isNotEmptyArr(tableData)) {
          const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0])  ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
          const tableDataRow =  iIndex > -1 ? tableData[iIndex] : {};
          /* 如果packData只有一条数据 则同步合版数据 及增加控制表合版备注 */
          if (commonUtils.isNotEmptyArr(packData) && packData.length === 1 && packData[0].sSlaveId === tableDataRow.sId) {
            let packDataRow = packData[0];
            const sControlId = packDataRow.sControlId;
            packDataRow = this.handlePackDataAdd(tableDataRow, 0, sControlId);
            packDataRow.dCombineQty = 1;
            packData[0] = { ...packData[0], ...packDataRow }

            if (commonUtils.isNotEmptyObject(packData[0])) {
              const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[0];
              const tableCombineSelectedData = [];
              const jsonObj = {};
              jsonObj.sId = sId;
              jsonObj.sProductNo = sProductNo; /* 产品编号 */
              jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
              jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
              jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
              jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
              tableCombineSelectedData.push(jsonObj);
              const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) ? JSON.stringify(tableCombineSelectedData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
              // const controlDataNew =commonUtils.isNotEmptyArr(addState.controlData)? addState.controlData: controlDataOld;
              if (commonUtils.isNotEmptyArr(controlDataNew)) {
                const iControlIndex = controlDataNew.findIndex(item => item.sId === sControlId);
                if (iControlIndex > -1) {
                  controlDataNew[iControlIndex].sCombinedMemo = sCombinedMemo;
                  controlDataNew[iControlIndex].sPartsName = tableDataRow.sProductName;
                }
                addState.controlData = controlDataNew;
              }
            }
          } else if (packData.length > 1) {
            const packFilterData = packData.filter(item => item.sSlaveId === tableDataRow.sId);
            if (commonUtils.isNotEmptyArr(packFilterData)) {
              packFilterData.forEach((itemPack, index) => {
                let packDataRow = itemPack;
                const sControlId = packDataRow.sControlId;
                packDataRow = this.handlePackDataAdd(tableDataRow, 0, sControlId);
                // packDataRow.dCombineQty = 1;
                const pIndex = packData.findIndex(item => item.sId === itemPack.sId);
                if (pIndex > -1){
                  packData[pIndex] = { ...packData[pIndex], ...packDataRow}; /* 根据选中的从表 找到所有的合版数据，将合版数据中的产品换成切换后的产品 */
                  let sCombinedMemoStr = ''; /* 将控制表合版信息中的产品换成新选择的产品 */
                  if(commonUtils.isNotEmptyArr(controlDataNew)) {
                    const iControlIndex = controlDataNew.findIndex(item => item.sId === sControlId);
                    if (iControlIndex > -1) {
                      sCombinedMemoStr = controlDataNew[iControlIndex].sCombinedMemo;
                      if(sCombinedMemoStr) {
                        const sCombinedMemoArr = commonUtils.isNotEmptyObject(sCombinedMemoStr) ? JSON.parse(sCombinedMemoStr): {};
                        if(commonUtils.isNotEmptyArr(sCombinedMemoArr)) {
                          const iIndex = sCombinedMemoArr.findIndex(item => item.sId === itemPack.sId);
                          if(iIndex > -1){
                            const addState ={};
                            addState.sProductId = tableDataRow.sProductId; /* 产品id */
                            addState.sCustomerId = tableDataRow.sCustomerId; /* 客户id */
                            addState.sCustomerName = tableDataRow.sCustomerName; /* 客户名称 */
                            addState.sProductName = tableDataRow.sProductName; /* 产品名称 */
                            addState.sProductNo = tableDataRow.sProductNo; /* 产品编号 */
                            sCombinedMemoArr[iIndex] ={...sCombinedMemoArr[iIndex], ...addState};
                            const sCombinedMemo = commonUtils.isNotEmptyArr(sCombinedMemoArr) ? JSON.stringify(sCombinedMemoArr) : ''; /* JSON对象转换为字符串存放到合版信息中 */
                            controlDataNew[iControlIndex].sCombinedMemo =sCombinedMemo;
                            controlDataNew[iControlIndex].sPartsName = tableDataRow.sProductName;
                          }
                        }
                      }
                    }
                  }
                }
              });
              addState.controlData = controlDataNew;
            }

          }
          addState.packData = packData;
          this.props.onSaveState({ [`${tbName}Data`]: tableData, ...addState });
        }

      }
      else {
        this.props.onSelectCommonPopup(currentPaneName, selectConfig, selectData, tbName);
      }
    };
    handleGetSplitData = (allData, config, type) => {
      const addState = {};
      let newData = [];
      const sSqlCondition = config ? config.sSqlCondition : 'materials0.sBclassifyName.油墨';
      if (commonUtils.isNotEmptyArr(allData) && commonUtils.isNotEmptyObject(sSqlCondition)) {
        let targetTbName = sSqlCondition.split('.')[0]; /* 1.表名 control  */
        if (commonUtils.isEmptyObject(targetTbName)) {
          targetTbName = 'materials0';
        }
        let filteredValue = sSqlCondition.split('.')[1]; /* 2.解析filterValue: controlSelectedRowKeys */
        let sParentKey = sSqlCondition.split('.')[2]; /* 2.解析本身表对应的值,如控制表筛选材料表 则材料表的sControlId = 控制表的controlSelectedRowKeys[0] */
        if (commonUtils.isEmptyObject(targetTbName)) {
          if (type === 'materials1') { /* materials0.sBclassifyName.油墨 */
            filteredValue = 'sBclassifyName';
            sParentKey = '油墨';
          } else if (type === 'materials2') { /* materials0.sBclassifyName.电化铝 */
            filteredValue = 'sBclassifyName';
            sParentKey = '电化铝';
          }
        }
        if (targetTbName === 'materials0') {
          // const filterData = allData.filter(item => item[filteredValue] === sParentKey);
          const filterData = allData.filter(item => sParentKey && sParentKey.includes(item[filteredValue]));
          if (commonUtils.isNotEmptyArr(filterData)) {
            newData = filterData;
          }
        }

      }
      addState[`${type}Data`] = newData;
      return addState;
    }

    /* 选择成品工序 点确定 */
    handleSelectFinalProcessNew = async (name, selectConfig, selectData, slaveFinalSelectedData) => {
      const targetname = 'process';
      const {
        [`${targetname}Data`]: tableData, [`${targetname}Config`]: tableConfig, controlSelectedRowKeys, sModelsId, token,
        materialsConfig, processConfig,masterConfig,
      } = this.props;
      const { masterData } = this.props;
      if (name === 'chooseProductProcess') {
        const { controlData } = this.props;
        const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1;
        /* 取选择工序从表配置 */
        const slavesControlName = commonUtils.isNotEmptyObject(selectConfig.sControlName) ? `${selectConfig.sControlName}.slave` : '';
        let slaveSelectConfig = {};
        let slaveIndex = -1;
        if (commonUtils.isNotEmptyObject(masterConfig)) {
          slaveIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === slavesControlName);
          if (slaveIndex > -1) {
            slaveSelectConfig = masterConfig.gdsconfigformslave[slaveIndex];
          }
        }
        /* 通过slaveFinalSelectedRowKeys找到slaveData数据 */
        if (commonUtils.isNotEmptyArr(slaveFinalSelectedData)) {
          for (const slaveObj of slaveFinalSelectedData) {
            if (commonUtils.isNotEmptyArr(selectData)) {
              for (const item of selectData) {
                const newCopyTo = {};
                newCopyTo.master = masterData;
                if (iControlIndex > -1) {
                  newCopyTo.control = controlData[iControlIndex];
                }
                let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo); // 取默认值
                tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
                if (commonUtils.isNotEmptyObject(slaveSelectConfig)) {
                  tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(slaveSelectConfig.sAssignField, slaveObj, newCopyTo) }; // 取从表赋值字段
                }
                tableDataRow.handleType = 'add';
                tableDataRow.sId = commonUtils.createSid();
                tableDataRow.sParentId = masterData.sId;

                tableDataRow.sCombinePartsName = slaveObj.sId; /* 成品工序sCombinePartsName 为从表id */
                tableDataRow.sCombinePartsNameNew = slaveObj.sProductName; /* 成品工序sCombinePartsName 为从表产品名称 */
                // tableDataRow.sSlaveProductId = slaveObj.sId;

                tableDataRow.sType = '3';
                if (commonUtils.isNotEmptyObject(tableDataRow.sWorkOrderParam)) {
                  tableDataRow = { ...tableDataRow, ...commonUtils.convertStrToObj(tableDataRow.sWorkOrderParam) };
                }
                if (targetname === 'process') {
                  const value = { sSqlCondition: { sParentId: item.sId } };
                  const configDataId = '11811781131121915166093023980';
                  const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
                  const returnData = (await commonServices.postValueService(token, value, dataUrl)).data;
                  if (returnData.code === 1) {
                    const eleprocessmachineData = returnData.dataset.rows[0].dataSet;
                    const newData = eleprocessmachineData.filter(item => item.bDefault);
                    if (commonUtils.isNotEmptyArr(newData)) {
                      tableDataRow.sMachineId = newData[0].sMachineId;
                    }
                  }
                  const bProcessAssort = false;
                  let returnProcessAssort = [];
                  let processAssignAssort = '';
                  let dropDownDataProcessName;
                  if (bProcessAssort) {
                    const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
                    const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
                    if (dataProcessAssort.code === 1) {
                      returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
                      const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProcessName');
                      if (iIndex > -1) {
                        const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', processConfig.gdsconfigformslave[iIndex]);
                        dropDownDataProcessName = sqlDropDownData.dropDownData;
                        processAssignAssort = processConfig.gdsconfigformslave[iIndex].sAssignField;
                      }
                    }
                  }
                  // 配套工序
                  if (bProcessAssort) {
                    returnProcessAssort.filter(item => item.sParentId === tableDataRow.sProcessId).forEach(((itemProcessAssort) => {
                      const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
                      if (iIndex > -1) {
                        const iProcessIndex = selectData.findIndex(item => item.sId === itemProcessAssort.sProcessId);
                        const iNewProcessIndex = tableDataRow.sType === '3' ?
                          tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
                          tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId);
                        if (iProcessIndex < 0 && iNewProcessIndex < 0) {
                          let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
                          processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
                          processRow.handleType = 'add';
                          processRow.sId = commonUtils.createSid();
                          processRow.sParentId = masterData.sId;
                          processRow.sType = dropDownDataProcessName[iIndex].sType;

                          // 成品工序的配套工序带入产品名称-开始
                          processRow.sCombinePartsName = slaveObj.sId; /* 成品工序sCombinePartsName 为从表id */
                          processRow.sCombinePartsNameNew = slaveObj.sProductName; /* 成品工序sCombinePartsName 为从表产品名称 */
                          processRow.sCombineProductNameNew = slaveObj.sProductName; /* 成品工序sCombinePartsName 为从表产品名称 */
                          // processRow.sParentProcessId = item.sId;
                          // 成品工序的配套工序带入产品名称-结束

                          if (iControlIndex > -1 && processRow.sType !== '3') {
                            processRow.sControlId = controlData[iControlIndex].sId;
                            processRow.sPartsName = controlData[iControlIndex].sPartsName;
                          }
                          tableData.push(processRow);

                          if (itemProcessAssort.sType === 'all') {
                            controlData.filter(item => item.sId !== controlData[iControlIndex].sId).forEach((controlTableRow) => {
                              const iNewProcessIndex = dropDownDataProcessName[iIndex].sType === '3' ?
                                tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) :
                                tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId);
                              if (iNewProcessIndex < 0) {
                                let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
                                processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
                                processRow.handleType = 'add';
                                processRow.sId = commonUtils.createSid();
                                processRow.sParentId = masterData.sId;
                                processRow.sType = dropDownDataProcessName[iIndex].sType;

                                // 成品工序的配套工序带入产品名称-开始
                                processRow.sCombinePartsName = slaveObj.sId; /* 成品工序sCombinePartsName 为从表id */
                                processRow.sCombinePartsNameNew = slaveObj.sProductName; /* 成品工序sCombinePartsName 为从表产品名称 */
                                processRow.sCombineProductNameNew = slaveObj.sProductName; /* 成品工序sCombinePartsName 为从表产品名称 */
                                // processRow.sParentProcessId = item.sId;
                                // 成品工序的配套工序带入产品名称-结束

                                if (iControlIndex > -1 && processRow.sType !== '3') {
                                  processRow.sControlId = controlTableRow.sId;
                                  processRow.sPartsName = controlTableRow.sPartsName;
                                }
                                tableData.push(processRow);
                              }
                            });
                          }
                        }
                      }
                    }));
                  }
                }
                // const processLen = commonBusiness.getTableTypes('process', this.props).data.filter(item => this.state.currentTab.process.split('-').indexOf(item.sType) !== -1).length;
                // tableDataRow.iOrder = processLen;
                if (iControlIndex > -1 && tableDataRow.sType !== '3') {
                  tableDataRow.sControlId = controlData[iControlIndex].sId;
                  tableDataRow.sPartsName = controlData[iControlIndex].sPartsName;
                  const processLen = tableData.filter(item => item.sType !== '3').length + 1; /* 工序序号自增 */
                  tableDataRow.iOrder = processLen;
                  tableData.push(tableDataRow);
                } else if (tableDataRow.sType === '3') {
                  const processLen = tableData.filter(item => item.sType === '3').length + 1; /* 工序序号自增 */
                  tableDataRow.iOrder = processLen;
                  tableData.push(tableDataRow);
                }
              }
            }
          }
        } else {
          message.error('请选择产品！');
          return;
        }
        const tableDataNew = this.sortData(controlData, tableData);
        this.props.onSaveState({
          [`${targetname}Data`]: tableDataNew, [`${name}ChooseVisible`]: false, materialsConfig, materialsSelectedRowKeys: [],
        });
      }
    }

    /* 选择成品材料 点确定 */
    handleSelectFinalMaterialsNew = async (name, selectConfig, selectData, slaveFinalSelectedData) => {
      // 选择成品材料，将sType改为2
      if (name === 'productMaterials') {
        selectData = selectData.map(val => ({ ...val, sType: '2' }));
        name = 'materials0';
      }
      const {
        [`${name}Data`]: tableData = [], [`${name}Config`]: tableConfig, controlSelectedRowKeys, materialsConfig,masterConfig,
      } = this.props;
      const { masterData } = this.props;
      const { controlData } = this.props;
      const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1;
      /* 取选择工序从表配置 */
      const slavesControlName = commonUtils.isNotEmptyObject(selectConfig.sControlName) ? `${selectConfig.sControlName}.slave` : '';
      let slaveSelectConfig = {};
      let slaveIndex = -1;
      if (commonUtils.isNotEmptyObject(masterConfig)) {
        slaveIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === slavesControlName);
        if (slaveIndex > -1) {
          slaveSelectConfig = masterConfig.gdsconfigformslave[slaveIndex];
        }
      }
      if (commonUtils.isNotEmptyArr(slaveFinalSelectedData)) {
        for (const slaveObj of slaveFinalSelectedData) {
          if (commonUtils.isNotEmptyArr(selectData)) {
            for (const item of selectData) {
              const newCopyTo = {};
              newCopyTo.master = masterData;
              if (iControlIndex > -1) {
                newCopyTo.control = controlData[iControlIndex];
              }
              let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo); // 取默认值
              tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
              if (commonUtils.isNotEmptyObject(slaveSelectConfig)) {
                tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(slaveSelectConfig.sAssignField, slaveObj, newCopyTo) }; // 取从表赋值字段
              }
              tableDataRow.handleType = 'add';
              tableDataRow.sId = commonUtils.createSid();

              tableDataRow.sParentId = masterData.sId;
              tableDataRow.sCombinePartsName = slaveObj.sId; /* 成品材料sCombinePartsName 为从表id */
              tableDataRow.sCombinePartsNameNew = slaveObj.sProductName;
              // tableDataRow.sSlaveProductId = slaveObj.sId;

              if (iControlIndex > -1 && tableDataRow.sType !== '2') {
                tableDataRow.sControlId = controlData[iControlIndex].sId;
                tableDataRow.sPartsName = controlData[iControlIndex].sPartsName;
                tableData.push(tableDataRow);
              } else if (tableDataRow.sType === '2') {
                tableData.push(tableDataRow);
              }
            }
          }
        }
      } else {
        message.error('请选择产品！');
        return;
      }
      this.props.onSaveState({
        [`${name}Data`]: tableData, [`${name}ChooseVisible`]: false, materialsConfig, materialsSelectedRowKeys: [],
      });
    }
    handleOnExpand = async (expanded, record) => {
      const { expKeys } = this.props;
      /* 添加移除展开的sId */
      const { formRoute } = this.props;
      let newExp = commonUtils.isNotEmptyArr(expKeys) ? expKeys : [];
      let rowKeyId = '';
      if (formRoute === '/indexPage/materialRequirementsPlanning') {
        rowKeyId = record.sMaterialsGS;
      }
      if (expanded) {
        if (commonUtils.isNotEmptyObject(rowKeyId)) {
          newExp.push(rowKeyId);
        }
      } else {
        newExp = newExp.filter(item => item !== rowKeyId);
      }
      this.props.onSaveState({ expKeys: newExp });
    }
    /* 点击展开图标时，调用接口获取嵌套字表数据 */
    handleOnExpandMultiTree = async (expanded, record) => {
      const {
        expKeys, slaveInfoConfig, slaveFilterCondition,
      } = this.props;
      let { slaveInfoData } = this.props;
      const { sId: sSlaveId, sSqlConditionId } = record;
      const sProductionPlanId = sSlaveId;
      /* 添加移除展开的sId */
      const rowKey = 'sId';
      let newExp = commonUtils.isNotEmptyArr(expKeys) ? expKeys : [];
      if (expanded) {
        newExp.push(record[rowKey]);
      } else {
        newExp = newExp.filter(item => item !== record[rowKey]);
      }
      let childrenData = [];
      /* 查看是否已经获取到明细表数据 */
      if (commonUtils.isNotEmptyArr(slaveInfoData)) {
        childrenData = slaveInfoData.filter(item => item.sSqlConditionId === sSqlConditionId);
      }
      if (expanded && commonUtils.isEmptyArr(childrenData)) {
        if (commonUtils.isNotEmptyObject(sProductionPlanId)) {
          const planLoadingSate = {};
          planLoadingSate.sId = sProductionPlanId;
          planLoadingSate.planLoading = true;
          const addStateSlaveInfo = await this.handleGetMultiDataInfo(slaveInfoConfig, slaveFilterCondition, 1, undefined, record, true);
          if (commonUtils.isNotEmptyObject(addStateSlaveInfo)) {
            const returnData = addStateSlaveInfo.slaveInfoData;
            if (commonUtils.isNotEmptyArr(returnData)) {
              childrenData = returnData;
              if (commonUtils.isEmptyArr(slaveInfoData)) {
                slaveInfoData = [];
              }
              childrenData.forEach((child) => {
                const iIndex = slaveInfoData.findIndex(item => item.sSlaveId === child[rowKey]);
                if (iIndex === -1) {
                  // child.sFatherSlaveId = record.sSlaveId; /* 增加父行的主键作为从表行的sFatherSlaveId */
                  slaveInfoData.push(child);
                }
              });
              const childrendFilterData = childrenData.filter(item => item.sSqlConditionId === record.sSqlConditionId);
              if(commonUtils.isNotEmptyArr(childrendFilterData)){
                childrendFilterData.forEach((child) => {
                  const iIndex = slaveInfoData.findIndex(item => item[rowKey] === child[rowKey]);
                  if (iIndex > -1) {
                    slaveInfoData[iIndex].sFatherSlaveId = record[rowKey];
                  }
                });
              }
            }
            planLoadingSate.planLoading = false;
            planLoadingSate.expKeys = newExp;
            this.props.onSaveState({
              planLoadingSate, slaveInfoData,
            });
          } else {
            planLoadingSate.planLoading = false;
            this.props.onSaveState({ planLoadingSate });
          }
        }
      } else if (expanded && commonUtils.isNotEmptyArr(slaveInfoData)) {  /* 已获得明细表数据时 */
        childrenData.forEach((child) => {
          const iIndex = slaveInfoData.findIndex(item => item[rowKey] === child[rowKey]);
          if (iIndex > -1) {
            slaveInfoData[iIndex].sFatherSlaveId = record[rowKey];
          }
        });
      }
    }

    handleGetNewSelectData = (data) => {
      const {
        processData, controlSelectedRowKeys,
      } = this.props;
      const newData = [];
      let startIndex = 0; /* 最开始下标 */
      const iOrderArr = [];
      /* 当前控制表选中行下的工序 接着编号 */
      const filterData = commonUtils.isNotEmptyArr(processData) && commonUtils.isNotEmptyArr(controlSelectedRowKeys) ?
        processData.filter(item => controlSelectedRowKeys.includes(item.sControlId)) : [];
      if (commonUtils.isNotEmptyArr(filterData)) {
        /* 找到最大序号值 接着拍 */
        filterData.forEach((item) => {
          const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
          iOrderArr.push(iOrder);
        });
      }
      /* 对所有移动的数据 进行一次重新排序 */
      if (commonUtils.isNotEmptyArr(iOrderArr)) {
        startIndex = Math.max(...iOrderArr);
      }
      if (commonUtils.isNotEmptyArr(data)) {
        data.forEach((item, index) => {
          const iOrderNew = startIndex + index + 1;
          const newRow = { ...item, iOrder: iOrderNew };
          newData.push(newRow);
        });
      }
      return newData;
    }
    /* 根据配置拉窗体配置 */
    handleGetFormConfig = async (sModelsId) => {
      let formConfig = {};
      const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}&sName=/commonAuto`;
      const configReturn = (await commonServices.getService('', configUrl)).data;
      if (configReturn.code === 1) {
        const dataReturn = configReturn.dataset.rows;
        if (commonUtils.isNotEmptyArr(dataReturn)) {
          const { formData } = dataReturn[0];
          if (commonUtils.isNotEmptyArr(formData)) {
            formConfig = formData[0];
          }
        }
      } else {
        message.error(configReturn.msg);
      }
      return formConfig;
    }

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

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

    handleBtnParamPage = (props, comparedTableId, type) =>{
      /* 找到所选择控制表, 根据当前行找 上条，下条，首条，末条 */
      const { processData} = props;
      const processRow = this.handleGetSelectedData(props, 'process'); /* 工序当前选中行 */
      const controlRow = this.handleGetSelectedData(props, 'control'); /* 控制表当前选中行 */
      let filterData = [];
      if(commonUtils.isNotEmptyObject(controlRow) && commonUtils.isNotEmptyArr(processData)){
        filterData = processData.filter(item => item.sType === '3'
          || (item.sType !== '3'  && item.sControlId === controlRow.sId )  );
      }
      let tableDataRow = {};
      if( commonUtils.isNotEmptyArr(filterData)) {
        const iIndex = filterData.findIndex(item => item.sId === processRow.sId);
        if(iIndex > -1) {
          const len = filterData.length;
          if (type === 'first') {
            tableDataRow = filterData[0];

          }else if (type === 'last') {
            tableDataRow = filterData[len -1];

          }else if (type === 'before') {
            if(iIndex === 0 || iIndex > len -1) {
              const currentFirst = commonFunc.showMessage(props.app.commonConst, 'currentFirst') || '当前是首条';
              message.error(currentFirst);
              return;
            }
            tableDataRow = filterData[iIndex - 1];

          }else if (type === 'next') {
            if(iIndex === len-1 || iIndex > len -1) {
              const currentLast = commonFunc.showMessage(props.app.commonConst, 'currentLast') || '当前是末条';
              message.error(currentLast);
              return;
            }
            tableDataRow = filterData[iIndex + 1];
          }
          if(commonUtils.isNotEmptyObject(tableDataRow)) {
            props.onSaveState({ processSelectedRowKeys: [tableDataRow.sId]})
          }
        }else{
          message.error('数据错误！');
        }
      } else{
        message.error('数据错误！');
      }

    }
    /** 控制选择控制表时，显示部件工序与成品工序 */
    handleFilterData = (name, dataIndex, value, record) => {
      if (value === undefined) {
        return true;
      }
      if (name === 'process') {
        return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '3') ||
          (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()));
      } else {
        return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '2') ||
          (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()));
      }
    };
    render() {
      const { masterData, sModelsType, app } = this.props;
      const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app);
      return (
        <ChildComponent
          {...this.props}
          {...this.state}
          onKeyDown={this.onKeyDown}
          onContextMenu={this.onContextMenu}
          onAdd={this.handleAdd}
          onEdit={this.handleEdit}
          onSubmit={this.handleValidateSave}
          onSaveData={this.handleSaveData}
          onSelectRowChange={this.handleSelectRowChange}
          onTableSelectRowChange={this.handleTableSelectRowChange}
          onReturnForm={this.handleForm}
          onChangeInvalid={this.handleInvalid}
          onBtnExamine={this.handleAudit.bind(this, 1)}
          onBtnCancelExamine={this.handleAudit.bind(this, 0)}
          onCopyTo={this.handleCopyTo}
          onCopyFrom={this.handleCopyFrom}
          onSearchData={this.handleSearchData}
          onNext={this.handleSearchData.bind(this, 'next')}
          onBtnPrior={this.handleSearchData.bind(this, 'up')}
          onBtnFirst={this.handleSearchData.bind(this, 'first')}
          onBtnLast={this.handleSearchData.bind(this, 'end')}
          onSearchUpDown={this.handleSearchUpDown}
          onGetData={this.handleGetData}
          onCancel={this.handleCancel}
          onDel={this.handleDel}
          onSearchUpDownThird={this.handleSearchUpDownThird}
          onDataRowAdd={this.handleTableAdd}
          onDataRowAddChild={this.handleTableAddChild}
          onDataRowCopy={this.handleTableCopy}
          onDataRowCopyAll={this.handleTableCopyAll}
          onDataChange={this.handleTableChange}
          onBtnPrint={this.handleBtnPrint}
          onChange={this.handleMasterChange}
          onTitleChange={this.handleTitleChange}
          onTitleChange1={this.handleTitleChange1}
          onButtonClick={this.handleButtonClick}
          onBtnChoose={this.handleBtnChoose}
          onSelect={this.handleSelect}
          onSelectCancel={this.handleSelectCancel}
          // onGetMemo={this.handleGetMemo}
          // onGetMemoCancel={this.handleGetMemoCancel}
          onDelDataSuccess={this.handleDelDataSuccess}
          onMaterialsChange={this.handleMaterialsChange}
          onDataAudit={this.dataAudit}
          imgSrc={imgSrc}
          onFilfileManageOk={this.handleFilfileManageOk}
          onFilfileManageOk1={this.handleFilfileManageOk1}
          onGetWeight={this.handleGetWeight}
          onDataImport={this.handleImport}
          onViewClick={this.handleViewClick}
          onViewChoose={this.handleViewChoose}
          onSelectSisColor={this.handleSelectSisColor}
          onCancelModal={this.handleCancelModal}
          onResolveMachineComposing={this.handleResolveMachineComposing}
          onContextMenuOk={this.handleContextMenuOk}
          orderNum={this.orderNum}
          onBtnPreview={this.handleBtnPreview}
          onSelectCommonPopupProduct={this.handleSelectCommonPopupProduct}
          onResolveSinglePQty={this.handleResolveSinglePQty}
          onGetDataOne ={this.handleGetDataOne}
          onParamsOk={this.handleParamsOk}
          onReportParamsOk={this.handleReportParamsOk}
          onCheckParamChange ={this.handleCheckParamChange}
          onDropDownBlur={this.handleTableBlur}
          onDataRowShowParam={this.handleShowParam}
          onSelectCommonPopup={this.handleSelectCommonPopup} /* 送货单个性化放大镜弹窗 */
          onChildTableDel={this.handleChildTableDel}
          onExpand={this.props.sTableType === 'multiple' ? this.handleOnExpandMultiTree :  this.handleOnExpand}
          onSplitData ={this.handleGetSplitData}
          onGetNewSelectData ={this.handleGetNewSelectData}
          isSColorSerialMemo={this.isSColorSerialMemo}
          onBtnParamPage ={this.handleBtnParamPage}
          onFilterData ={this.handleFilterData}
          onSelectProductProcessNew={this.handleSelectFinalProcessNew}
          onSelectProductMaterialsNew={this.handleSelectFinalMaterialsNew}
        />
      );
    }
  };
};
