/* eslint-disable */
/* eslint-disable prefer-destructuring */
/**
 * Created by mar105 on 2019-03-27.
 */
import React, { Component } from 'react';
import { Modal, message } from 'antd-v4';
import * as commonUtils from '../../utils/utils'; /* 通用方法 */
import * as commonFunc from './commonFunc'; /* 通用单据方法 */
import commonConfig from '../../utils/config';
import * as commonServices from '../../services/services';
import * as commonBusiness from './commonBusiness';

const { confirm } = Modal;

export default (ChildComponent) => {
  return class extends Component {
    constructor(props) {
      super(props);
      this.state = {};
      this.loadingCount = 0;
    }

    componentWillMount() {
      /* 获取配置 */
      this.mounted = true;
      const {
        slaveData, slaveSelectedRowKeys, formRoute, app, sModelsType,
      } = this.props;
      const { currentPane } = app;
      /* 选择合版部件 slaveConfig,slaveColumn,slaveData有值 会将值存储到state中 */
      if (currentPane.name === 'combineParts' || currentPane.name === 'logView' || currentPane.name === 'sisColor' || currentPane.name === 'commonPopup') {
        const bFilterProName = currentPane.bFilterProName;
        const bFilterProValue = currentPane.bFilterProValue;
        this.props.onSaveState({
          slaveData, formRoute, pageLoading: false, slaveSelectedRowKeys, selectedRowKeys: slaveSelectedRowKeys, sModelsType, bFilterProName, bFilterProValue,
        });
      } else if (currentPane.name === 'chooseProductProcess') { /* 选择成品工序 */
        const { slaveFinalConfig, slaveFinalColumn, slaveFinalData } = this.props;
        this.props.onSaveState({
          slaveData,
          formRoute,
          pageLoading: false,
          slaveSelectedRowKeys,
          sModelsType,
          slaveFinalConfig, /* 成品工序 对应的工单从表配置 */
          slaveFinalColumn, /* 成品工序 对应的工单从表表头 */
          slaveFinalData, /* 成品工序 对应的工单从表数据源 */
        });
      }
    }

    async componentWillReceiveProps(nextProps) {
      const {
        app, formData, currentId, searchSolution, masterData, sGroupByList, formRoute, sModelsType,
      } = nextProps;
      let { slaveConfig: slaveConfigOld } = nextProps;
      // nextProps.onSaveState({ realizeHeight: nextProps.realizeHeight });
      let { iPageSize } = nextProps;
      // formRoute === '/indexOee'为oee报产页面;
      if (nextProps.customConfig) {
        let slaveColumn = commonFunc.getHeaderConfig({gdsconfigformslave: nextProps.customConfig});
        if (JSON.stringify(slaveColumn) !== JSON.stringify(nextProps.slaveColumn)) {
          this.props.onSaveState({slaveColumn});
        }
      }
      if (commonUtils.isEmptyObject(slaveConfigOld) && formData.length > 0 && (formRoute.indexOf('/indexOee') > -1 || searchSolution !== undefined)) {
        const sId = currentId || nextProps.masterData?.sId || '';
        /* 数据Id */
        const slaveConfig = formData[0];
        let addState = {};
        if (sModelsType === 'cost/cotordercostanalysis') { /* 工单实际成本 */
          const { sModelsId } = this.props;
          const { gdsconfigformslave } = slaveConfig;
          if (commonUtils.isNotEmptyArr(gdsconfigformslave)) {
            const gdsconfigformslaveNew = gdsconfigformslave.filter(item => item.sName !== undefined && item.sName.indexOf('dExpense') < 0);
            const iIndex = gdsconfigformslave.findIndex(item => item.sName !== undefined && item.sName.indexOf('dExpense'));
            if (iIndex > -1) {
              let iOrder = 0;
              /* 取可见配置中最大iOrder */
              const costVisibleConfig = gdsconfigformslave.filter(item => item.bVisible);
              if (commonUtils.isNotEmptyArr(costVisibleConfig)) {
                const len = costVisibleConfig.length;
                iOrder = costVisibleConfig[len - 1].iOrder;
                iOrder = commonUtils.isNotEmptyNumber(iOrder) ? iOrder : 0;
              }
              const { sId, sParentId } = slaveConfig;
              const url = `${commonConfig.server_host}costCenter/getCostCenterConfigByOrder/${iOrder}?sModelsId=${sModelsId}`;
              const body = { sId, sParentId };
              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) {
                  const costdExpenseConfigNew = rows[0].gdsconfigformslave;/* 获取新的费用配置 */
                  costdExpenseConfigNew.forEach((item) => {
                    /* 去后台配置中通过sName匹配配置 */
                    let itemNew;
                    const dtIndex = gdsconfigformslave.findIndex(child => child.sName === item.sName);
                    if (dtIndex > -1) {
                      itemNew = { ...gdsconfigformslave[dtIndex], showName: item.showName, bVisible: item.bVisible };
                    } else {
                      itemNew = item;
                    }
                    const iIndex = gdsconfigformslaveNew.findIndex(child => child.sId === item.sId);
                    if (iIndex === -1) {
                      gdsconfigformslaveNew.push(itemNew);
                    }
                  });
                  slaveConfig.gdsconfigformslave = gdsconfigformslaveNew;
                }
              } else { /*   失败   */
                this.props.getServiceError(dataReturn);
                return [];
              }
            }
          }
        }
        let slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
        /* 选择工序选中表-拷贝slave配置 */
        const slaveFilterConfig = formData[0];
        const slaveFilterColumn = commonFunc.getHeaderConfig(slaveFilterConfig);
        let filterCondition = [];
        if (commonUtils.isNotEmptyObject(masterData) && !commonUtils.isEmpty(masterData.sSearchSolutionId) && commonUtils.isNotEmptyArr(searchSolution)) {
          const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId);
          if (iIndex > -1 && !commonUtils.isEmpty(searchSolution[iIndex].sCondition)) {
            filterCondition = JSON.parse(searchSolution[iIndex].sCondition);
          }
        }
        let slaveInfoColumn = {};
        let slaveInfoConfig;
        let iOeePageSize = iPageSize;/* OEE没有分页组件 只需要根据后台设定页数分页 */
        if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) {
          iOeePageSize = formData[0].iPageSize;
        }
        // oee页面从表
        if (sModelsType === '/indexOee/processReportList') { // 机台任务
          const bFilter = [];
          bFilter.push({
            bFilterName: 'sMachineId_s_pro',
            bFilterCondition: '=',
            bFilterValue: app.sMachineNameSId,
          });
          const pageNum = 1;
          addState = (await this.props.handleGetDataSet({
            name: 'slave',
            configData: slaveConfig,
            // condition: { pageNum, pageSize: commonConfig.pageSize, bFilter },
            condition: { bFilter, pageSize: iOeePageSize, pageNum },
            isWait: true,
          }));
          if (commonUtils.isNotEmptyObject(addState)) {
            addState.slaveSelectedRowKeys = commonUtils.isNotEmptyArr(this.props.slaveSelectedRowKeys) ? this.props.slaveSelectedRowKeys : [];
          }
        } if (sModelsType === '/indexOee/process') { // 所有任务
          const bFilter = [];
          bFilter.push({
            bFilterName: 'sMachineId_s_pro',
            bFilterCondition: '=',
            bFilterValue: app.sMachineNameSId,
          }, {
            bFilterName: 'sProceeAllMachine_pro',
            bFilterCondition: '=',
            bFilterValue: 'process',
          });
          const pageNum = 1;
          addState = (await this.props.handleGetDataSet({
            name: 'slave',
            configData: slaveConfig,
            // condition: { pageNum, pageSize: commonConfig.pageSize, bFilter },
            condition: { bFilter, pageSize: iOeePageSize, pageNum },
            isWait: true,
          }));
          if (commonUtils.isNotEmptyObject(addState)) {
            addState.slaveSelectedRowKeys = commonUtils.isNotEmptyArr(this.props.slaveSelectedRowKeys) ? this.props.slaveSelectedRowKeys : [];
          }
        } else if (sModelsType === '/indexOee/oeeCurrentState') { // 历史记录
          let masterData = [];
          let masterDataIndex = -1;
          const bFilter = [];
          bFilter.push({
            bFilterName: 'sMachineId',
            bFilterCondition: '=',
            bFilterValue: app.sMachineNameSId,
          });
          const pageNum = 1;
          addState = (await this.props.handleGetDataSet({
            name: 'slave',
            configData: slaveConfig,
            condition: { bFilter, pageSize: iOeePageSize, pageNum },
            isWait: true,
          }));
          addState.slaveData.forEach((item, iIndex) => {
            if (commonUtils.isNotEmptyObject(item.sReportParam)) {
              item = { ...item, ...commonUtils.convertStrToObj(item.sReportParam) };
              addState.slaveData[iIndex] = item;
            }
          });

          // 获取正在开工的数据
          // masterDataIndex = commonUtils.isNotEmptyObject(addState) ? addState.slaveData.findIndex(item => item.sStatus === commonFunc.showMessage(app.commonConst, 'startWorking') || item.sStatus === 'startWorking') : -1;
          masterDataIndex = commonUtils.isNotEmptyObject(addState) ? 0 : -1; /* 当前设备永远获取第一条数据 */
          if (commonUtils.isNotEmptyObject(addState)) {
            if (commonUtils.isNotEmptyArr(this.props.slaveSelectedRowKeys) && commonUtils.isNotEmptyArr(addState.slaveData)) {
              addState.slaveSelectedRowKeys = this.props.slaveSelectedRowKeys;
              const currentKeyArrIndex = addState.slaveData.findIndex(item => item.sId === this.props.slaveSelectedRowKeys[0]);
              if (currentKeyArrIndex > -1) {
                addState.slaveSelectedData.push(addState.slaveData[currentKeyArrIndex]);
              }
            } else {
              addState.slaveSelectedRowKeys = [];
            }
          }
          if (masterDataIndex > -1) {
            if (commonUtils.isNotEmptyObject(addState) && commonUtils.isNotEmptyArr(addState.slaveData)) {
              masterData = commonFunc.getDefaultData(slaveConfig); // 取当前设备状态配置的默认值
              masterData = { ...masterData, ...addState.slaveData[masterDataIndex] };
              masterData.handleType = 'update';
              masterData.sTeamId = app.sTeamNameSId;
              masterData.sTeamName = app.sTeamNameSName;

              if (commonUtils.isNotEmptyObject(masterData.sReportParam)) {
                // eslint-disable-next-line no-plusplus
                for (let i = 1; i < 11; i++) {
                  const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
                  if (iIndex > -1 && !commonUtils.isEmpty(masterData[`sParam${i.toString()}`])) {
                    slaveConfig.gdsconfigformslave[iIndex].showName = masterData[`sParam${i.toString()}`];
                    slaveConfig.gdsconfigformslave[iIndex].bVisible = !masterData[`sParam${i.toString()}`].includes('参数值');
                  } else if (iIndex > -1) {
                    slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
                  }
                }
              } else {
                // eslint-disable-next-line no-plusplus
                for (let i = 1; i < 11; i++) {
                  const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === `sParamValue${i.toString()}`);
                  if (iIndex > -1) {
                    slaveConfig.gdsconfigformslave[iIndex].bVisible = false;
                  }
                }
              }
            }
            if (commonUtils.isNotEmptyObject(masterData)) {
              const employeeConfig = formData.filter(item => item.bGrd && item.sTbName === 'mftmachineworkemployee')[0];
              const employeeColumn = commonFunc.getHeaderConfig(employeeConfig);
              const bFilter = [];
              bFilter.push({
                bFilterName: 'sParentId',
                bFilterCondition: '=',
                bFilterValue: masterData.sTeamId,
              });
              const getData = await this.props.handleGetDataSet({
                name: 'employee', configData: employeeConfig, condition: { bFilter }, isWait: true,
              });
              if (commonUtils.isNotEmptyObject(getData) && getData.employeeDelData === undefined) {
                getData.employeeDelData = [];
              }
              // const employeeData = commonUtils.isNotEmptyObject(app.employeeAndProcessData) && commonUtils.isNotEmptyArr(app.employeeAndProcessData.employeeData) ? app.employeeAndProcessData.employeeData : [];
              // 为oee历史记录员工数据进行数据缓存
              if (commonUtils.isJSON(localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData_${app.sTeamNameSId}`)) && JSON.parse(localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData_${app.sTeamNameSId}`)).length > 0 && !this.props.employeeDataSetted) {
                getData.employeeData = JSON.parse(localStorage.getItem(`${commonConfig.prefix}oeeEmployeeData_${app.sTeamNameSId}`));
              }
              addState = {
                ...addState, masterData, employeeConfig, employeeColumn, ...getData,
              };
            }
          }
        } else if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('dynamicList')) { /* 改分支用于动态列处理 */
          if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) {
            iPageSize = formData[0].iPageSize;
          }
          const bFilter = [];
          if (!commonUtils.isEmptyArr(filterCondition)) {
            bFilter.push(...filterCondition);
          }
          addState = await this.props.handleGetDataSet({
            name: 'slave',
            configData: slaveConfig,
            condition: {
              pageNum: 1, pageSize: iPageSize, bFilter,
            },
            flag: true,
            isWait: true,
          });
          if (commonUtils.isNotEmptyObject(addState)) {
            const { slaveData } = addState;
            if (commonUtils.isNotEmptyArr(slaveData)) {
              const gdsconfigformslave = slaveConfig.gdsconfigformslave;
              const columnConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.showName !== '' && !(item.sControlName !== '' && item.sControlName.indexOf('Btn') > -1)) : [];
              const slaveRow = slaveData[0];
              if (commonUtils.isNotEmptyObject(slaveRow)) {
                const iOrderArr = [];
                for (const key of Object.keys(slaveRow)) {
                  let splitData = [];
                  splitData = commonUtils.isNotEmptyObject(key) ? key.split('_') : [];
                  /* 标题需要按照s_名称_序号 规则设定 */
                  if (splitData.length > 1) {
                    let title = splitData[1];/* 标题名称 */
                    /* 如果有### ,替换为 . */
                    if (commonUtils.isNotEmptyObject(title) && title.includes('###')) {
                      title = title.replace('###', '.');
                    }
                    const iOrder = splitData[2];/* 排序号 */
                    iOrderArr.push(iOrder);
                    /* 根据接口返回列的序号 匹配后台配置列下标 */
                    if (commonUtils.isNotEmptyObject(columnConfig[iOrder])) {
                      columnConfig[iOrder].showName = title;
                      columnConfig[iOrder].sChinese = title;
                      columnConfig[iOrder].sName = key;
                      const iIndex = gdsconfigformslave.findIndex(item => item.sId === columnConfig[iOrder].sId);
                      if (iIndex > -1) {
                        gdsconfigformslave[iIndex] = columnConfig[iOrder];
                      }
                    }
                  }
                }

                /* 把多余字段隐藏掉 找到最大下标 把其他多余显示行隐藏掉 */
                if (commonUtils.isNotEmptyArr(iOrderArr)) {
                  const iOrderMax = Math.max(...iOrderArr);
                  if (commonUtils.isNotEmptyArr(columnConfig)) {
                    columnConfig.forEach((itemConfig, iIndex) => {
                      if (iIndex > iOrderMax) {
                        const iIndexConfig = gdsconfigformslave.findIndex(item => item.sId === itemConfig.sId);
                        if (iIndexConfig > -1) {
                          gdsconfigformslave[iIndexConfig].bVisible = false;
                        }
                      }
                    });
                  }
                }

                slaveConfig.gdsconfigformslave = gdsconfigformslave;
                slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
              }
            }
          }
        } else if (sModelsType === 'commonGantte') { /* 获取甘特图列表数据集 */
          /* 找到配置的存储过程名称 */
          const ganntObj = {
            sProcedureName: slaveConfig.sTbName,
          };
          this.handleGanttChar(ganntObj, filterCondition);
        } else if (sModelsType !== '/indexOee/wagesSearch' && sModelsType !== '/indexOee/processReportList') { /* 该分支用于除OEE外的列表再次获取时执行 */
          /* 首先以下拉页数为准 否则以后台页数为准 如果以上都没有设置 则依照config配置的页码设置 */
          if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) {
            iPageSize = formData[0].iPageSize;
          }
          await this.handleGetData(slaveConfig, filterCondition, 1, commonUtils.isNotEmptyNumber(iPageSize) && iPageSize !== 0 ? iPageSize : commonConfig.pageSize, '', false, sGroupByList);
          slaveInfoConfig = formData[1];
          slaveInfoColumn = {};
          if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
            slaveInfoColumn = commonFunc.getHeaderConfig(slaveInfoConfig);
            await this.handleGetDataInfo(slaveInfoConfig, filterCondition, 1);
          }
          /* 判断是否要加载过滤树数据 */
          const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
          if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
            const filterTreeConfig = filterTreeConfigArr[0];
            // if (this.props.productProcess) {
            //   filterCondition.push({
            //     bFilterCondition: '=',
            //     bFilterName: 'sType',
            //     bFilterValue: '3',
            //   });
            // }
            await this.handleGetFilterTreeData(filterTreeConfig, filterCondition, 1);
          }
          const iIndexBtnFirst = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnFirst');
          if (iIndexBtnFirst < 0) {
            slaveConfig.gdsconfigformslave.push({
              sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnFirst', sControlName: 'BtnFirst',
            });
          }
          const iIndexBtnPrior = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnPrior');
          if (iIndexBtnPrior < 0) {
            slaveConfig.gdsconfigformslave.push({
              sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnPrior', sControlName: 'BtnPrior',
            });
          }
          const iIndexBtnNext = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnNext');
          if (iIndexBtnNext < 0) {
            slaveConfig.gdsconfigformslave.push({
              sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnNext', sControlName: 'BtnNext',
            });
          }
          const iIndexBtnLast = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnLast');
          if (iIndexBtnLast < 0) {
            slaveConfig.gdsconfigformslave.push({
              sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnLast', sControlName: 'BtnLast',
            });
          }
          const iIndexBtnSave = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnSave');
          if (iIndexBtnSave < 0) {
            slaveConfig.gdsconfigformslave.push({
              sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnSave', sControlName: 'BtnSave',
            });
          }
          const iIndexBtnCancel = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnCancel');
          if (iIndexBtnCancel < 0) {
            slaveConfig.gdsconfigformslave.push({
              sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCancel', sControlName: 'BtnCancel',
            });
          }
          const iIndexBtnCopyFrom = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnCopyFrom');
          if (iIndexBtnCopyFrom < 0) {
            slaveConfig.gdsconfigformslave.push({
              sId: commonUtils.createSid(), bVisible: false, sName: '', showName: 'BtnCopyFrom', sControlName: 'BtnCopyFrom',
            });
          }
        }
        this.props.onSaveState({
          masterConfig: slaveConfig,
          slaveConfig,
          slaveColumn,
          slaveInfoConfig,
          slaveInfoColumn,
          sId,
          pageLoading: false,
          slaveFilterColumn,
          slaveFilterConfig,
          ...addState,
        });
      } else if (JSON.stringify(app.currentPane.conditonValues) !== JSON.stringify(this.props.app.currentPane.conditonValues)) {
        const { slaveConfig, slaveFilterCondition } = nextProps;
        this.handleGetData(slaveConfig, slaveFilterCondition, 1, commonUtils.isNotEmptyNumber(iPageSize) && iPageSize !== 0 ? iPageSize : commonConfig.pageSize, undefined, undefined, undefined, nextProps);
      } else if (JSON.stringify(nextProps.id) !== JSON.stringify(this.props.id)) {
        this.props.onSaveState({ slaveSelectedRowKeys: [] });
      } else if (commonUtils.isEmptyObject(slaveConfigOld) && formData.length > 0 && formRoute === '/indexPage/unifiedPlanning') {
        // const masterConfig = formData.filter(item => !item.bGrd && item.sTbName === 'elemachine')[0];
        // const masterColumn = commonFunc.getHeaderConfig(masterConfig); masterColumn,
        const importConfigTypes = [];
        const CalculateTime= commonFunc.showMessage(this.props.app.commonConst, 'CalculateTime') || '计算时间' ;
        const BtnCalculate= commonFunc.showMessage(this.props.app.commonConst, 'Calculate') || '计算' ;
        importConfigTypes.push({ ...commonFunc.getImitateGdsconfigTypes(CalculateTime, 'tCurrTime', 'tCurrTime', false, '', '', false), sDateFormat: 'YYYY-MM-DD' });
        importConfigTypes.push(commonFunc.getImitateGdsconfigTypes(BtnCalculate, 'BtnCalculation', '', false, '', '', true));

        const currConfig = {};
        currConfig.rowGdsconfig = [{ gdsconfigformslave: importConfigTypes }];

        const masterData = {};
        masterData.handleType = '';
        masterData.sId = commonUtils.createSid();

        const slaveConfig = formData.filter(item => item.bGrd && item.sTbName === 'elemachine')[0];
        const slaveColumn = commonFunc.getHeaderConfig(slaveConfig);
        this.handleGetData(slaveConfig, undefined, undefined, undefined, undefined, undefined, undefined, nextProps);
        this.props.onSaveState({
          masterConfig: currConfig, masterData, slaveConfig, slaveColumn, enabled: true, pageLoading: false,
        });
      } else if (!commonUtils.isEmpty(this.props.pageNum) && this.props.pageNum !== nextProps.pageNum) {
        const {
          slaveConfig, slaveFilterCondition, sGroupByList, treeFilterCondition, slavePagination, slaveOrderBy,
        } = this.props;
        if (this.props.pageNum >= Math.ceil(slavePagination.total / slavePagination.pageSize)) {
          this.props.onToFirst();
        } else if (commonUtils.isNotEmptyArr(treeFilterCondition)) { /* 判断是否有树过滤条件 */
          this.handleGetData(slaveConfig, slaveFilterCondition, nextProps.pageNum, slavePagination.pageSize, slaveOrderBy, '', sGroupByList, '', treeFilterCondition);
        } else {
          this.handleGetData(slaveConfig, slaveFilterCondition, nextProps.pageNum, slavePagination.pageSize, slaveOrderBy, '', sGroupByList);
        }
      }
      if (sModelsType === 'search/workSchedule') {
        if (!nextProps.pageLoading && !this.props.pageLoading) {
          this.loadingCount = this.loadingCount + 1;
          if (this.loadingCount === 2) {
            this.loadingCount = 0;
            this.props.onSaveState({
              realizeHeight: this.props.realizeHeight,
            });
          }
        }
      }
    }

    shouldComponentUpdate(nextProps) {
      const { slaveColumn } = nextProps;
      return commonUtils.isNotEmptyArr(slaveColumn);
    }

    /**   获取表数据   */
    handleGetData = async (slaveConfig, slaveFilterCondition, page, pageSize, slaveOrderBy, clearSelectData, sGroupByListNew, nextProps, treeFilterCondition) => {
      const {
        app,
        name,
        formRoute,
        slavePagination,
        selectedRowKeys,
        fatherModelsType,
        iPageSize,
      } = commonUtils.isEmpty(nextProps) ? this.props : nextProps;
      let { sModelsType } = app.currentPane; /* 特殊处理 选择工序不分页s */
      const sGroupByList = sGroupByListNew !== undefined ? commonUtils.isEmptyArr(sGroupByListNew) ? null : sGroupByListNew : this.props.sGroupByList;
      const conditonValues = app.currentPane.conditonValues;
      const filterCondition = app.currentPane.filterCondition;
      const bFilter = [];
      const pageNum = commonUtils.isEmpty(page) ? 1 : page;
      if (formRoute === '/indexOee/processReportList' || formRoute === '/indexOee/process') {
        bFilter.push({
          bFilterName: 'sMachineId_s_pro',
          bFilterCondition: '=',
          bFilterValue: app.sMachineNameSId,
        });
        if (formRoute === '/indexOee/process') {
          bFilter.push({
            bFilterName: 'sProceeAllMachine_pro',
            bFilterCondition: '=',
            bFilterValue: 'process',
          });
        }
        pageSize = 100;
      } else if (formRoute === '/indexOee/wagesSearch') {
        bFilter.push({
          bFilterName: 'sMachineGuid_pro',
          bFilterCondition: '=',
          bFilterValue: app.sMachineNameSId,
        });
        pageSize = 20;
      } else if (sModelsType === 'search/importFormData') {
        /* 导入未清数据 根据客户ID 获取数据集 */
        const { currentPane } = app;
        const bFilterProName = currentPane.bFilterProName;
        const bFilterProValue = currentPane.bFilterProValue;
        if (commonUtils.isNotEmptyObject(bFilterProValue)) {
          bFilter.push({
            bFilterName: bFilterProName,
            bFilterCondition: '=',
            bFilterValue: bFilterProValue,
          });
        }
      } else if (sModelsType === 'search/workSchedule') { /* 生产排程 工艺流程 查看生产进度详情 */
        const { currentPane } = app;
        const bFilterProName = currentPane.bFilterProName;
        const bFilterProValue = currentPane.bFilterProValue;
        if (commonUtils.isNotEmptyObject(bFilterProValue)) {
          bFilter.push({
            bFilterName: bFilterProName,
            bFilterCondition: '=',
            bFilterValue: bFilterProValue,
          });
        }
      }
      if (!commonUtils.isEmptyArr(slaveFilterCondition)) {
        bFilter.push(...slaveFilterCondition);
      }
      if (!commonUtils.isEmptyArr(filterCondition)) {
        bFilter.push(...filterCondition);
      }
      if (!commonUtils.isEmptyArr(treeFilterCondition)) {
        bFilter.push(...treeFilterCondition);
      }
      pageSize = commonUtils.isEmpty(pageSize) ? commonUtils.isEmpty(slavePagination) || commonUtils.isEmpty(slavePagination.pageSize) ? iPageSize : slavePagination.pageSize : pageSize;
      if (formRoute === '/indexOee/oeeCurrentState') {
        bFilter.push({
          bFilterName: 'sMachineId',
          bFilterCondition: '=',
          bFilterValue: app.sMachineNameSId,
        });
        sModelsType = this.props.sModelsType;
      }
      if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType === 'modal/searchProcess') { // 选择工序中的取数并获取工艺参数配置
        const addState = await this.props.handleGetDataSet({
          name: 'slave',
          configData: slaveConfig,
          condition: {
            pageNum: 1, pageSize: 10000, bFilter, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues, sGroupList: sGroupByList,
          },
          flag: true,
          isWait: true,
          clearSelectData,
        });
        if (commonUtils.isNotEmptyObject(fatherModelsType)) {
          addState.slaveData.forEach((item, iIndex) => {
            if (commonUtils.isNotEmptyObject(fatherModelsType.includes('quotation/') ? item.sProcessParam : fatherModelsType.includes('manufacture/') ? item.sWorkOrderParam : item.sProcessParam)) {
              item = { ...item, ...commonUtils.convertStrToObj(fatherModelsType.includes('quotation/') ? item.sProcessParam : fatherModelsType.includes('manufacture/') ? item.sWorkOrderParam : item.sProcessParam) };
              addState.slaveData[iIndex] = item;
            }
          });
          addState.slaveConfig = slaveConfig;
        }
        this.props.onSaveState({
          ...addState,
        });
      } else if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('dynamicList')) { /* 动态列回刷 */
        const { formData } = commonUtils.isEmpty(nextProps) ? this.props : nextProps;
        let { slaveColumn } = commonUtils.isEmpty(nextProps) ? this.props : nextProps;
        const slaveConfigNew = commonUtils.isNotEmptyObject(formData[0]) ? formData[0] : slaveConfig;
        const addState = await this.props.handleGetDataSet({
          name: 'slave',
          configData: slaveConfigNew,
          condition: {
            pageNum: commonUtils.isNotEmptyObject(sModelsType) && sModelsType === 'modal/searchProcess' ? '' : pageNum, pageSize: commonUtils.isNotEmptyObject(sModelsType) && (sModelsType === 'modal/searchProcess' || sModelsType === '/productionPlan/unifiedPlanning' || sModelsType === 'modal/logView') ? '' : pageSize, bFilter, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues, sGroupList: sGroupByList,
          },
          flag: true,
          isWait: true,
          clearSelectData,
        });
        if (commonUtils.isNotEmptyObject(addState)) { /* 动态列 */
          const { slaveData } = addState;
          if (commonUtils.isNotEmptyArr(slaveData)) {
            const gdsconfigformslave = slaveConfigNew.gdsconfigformslave;
            const columnConfig = commonUtils.isNotEmptyObject(slaveConfigNew) ? slaveConfigNew.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.showName !== '' && !(item.sControlName !== '' && item.sControlName.indexOf('Btn') > -1)) : [];
            const columnConfigOld = commonUtils.isNotEmptyObject(slaveConfigNew) ? slaveConfigNew.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '' && item.showName !== '' && !(item.sControlName !== '' && item.sControlName.indexOf('Btn') > -1)) : [];
            const slaveRow = slaveData[0];
            if (commonUtils.isNotEmptyObject(slaveRow)) {
              const iOrderArr = [];
              for (const key of Object.keys(slaveRow)) {
                let splitData = [];
                splitData = commonUtils.isNotEmptyObject(key) ? key.split('_') : [];
                /* 标题需要按照s_名称_序号 规则设定 */
                if (splitData.length > 1) {
                  let title = splitData[1];/* 标题名称 */
                  /* 如果有### ,替换为 . */
                  if (commonUtils.isNotEmptyObject(title) && title.includes('###')) {
                    title = title.replace('###', '.');
                  }
                  const iOrder = splitData[2];/* 排序号 */
                  iOrderArr.push(iOrder);
                  /* 根据接口返回列的序号 匹配后台配置列下标 */
                  if (commonUtils.isNotEmptyObject(columnConfig[iOrder])) {
                    columnConfig[iOrder].showName = title;
                    columnConfig[iOrder].sChinese = title;
                    columnConfig[iOrder].sName = key;
                    const iIndex = gdsconfigformslave.findIndex(item => item.sId === columnConfig[iOrder].sId);
                    if (iIndex > -1) {
                      gdsconfigformslave[iIndex] = columnConfig[iOrder];
                    }
                  }
                }
              }
              /* 把多余字段隐藏掉 找到最大下标 把其他多余显示行隐藏掉 */
              if (commonUtils.isNotEmptyArr(iOrderArr)) {
                const iOrderMax = Math.max(...iOrderArr);
                if (commonUtils.isNotEmptyArr(columnConfigOld)) {
                  columnConfigOld.forEach((itemConfig, iIndex) => {
                    if (iIndex > iOrderMax) {
                      const iIndexConfig = gdsconfigformslave.findIndex(item => item.sId === itemConfig.sId);
                      if (iIndexConfig > -1) {
                        gdsconfigformslave[iIndexConfig].bVisible = false;
                      }
                    }
                  });
                }
              }
              slaveConfigNew.gdsconfigformslave = gdsconfigformslave;
              slaveColumn = commonFunc.getHeaderConfig(slaveConfigNew);
            }
          }
          this.props.onSaveState({ ...addState, slaveConfig: slaveConfigNew, slaveColumn });
        }
      } else {
        this.props.handleGetDataSet({
          name: 'slave',
          configData: slaveConfig,
          condition: {
            pageNum: commonUtils.isNotEmptyObject(sModelsType) && sModelsType === 'modal/searchProcess' ? '' : pageNum, pageSize: commonUtils.isNotEmptyObject(sModelsType) && (sModelsType === 'modal/searchProcess' || sModelsType === '/productionPlan/unifiedPlanning' || sModelsType === 'modal/logView') ? '' : pageSize, bFilter, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues, sGroupList: sGroupByList,
          },
          flag: true,
          clearSelectData,
        });
      }
      if (formRoute === '/indexPage/materialRequirementsPlanning' && clearSelectData) {
        const { slaveFilterCondition, slaveInfoConfig } = this.props;
        if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
          this.handleGetDataInfo(slaveInfoConfig, slaveFilterCondition, 1);
        }
      }
      // 复制到过后，没有选中的情况下打印菜单置空
      if (commonUtils.isNotEmptyObject(name) && name.indexOf('BtnCopyTo') > -1 && commonUtils.isEmptyArr(selectedRowKeys)) {
        this.props.onSaveState({ menuChildData: [] });
      }
    };

    /**   获取过滤树数据数据   */
    handleGetFilterTreeData= (slaveConfig, slaveFilterCondition, page, slaveOrderBy, props) => {
      const { app } = props === undefined ? this.props : props;
      const conditonValues = app.currentPane.conditonValues;
      const pageNum = commonUtils.isEmpty(page) ? 1 : page;
      this.props.handleGetTreeDataSet({
        name: 'slave',
        configData: slaveConfig,
        condition: {
          pageNum, pageSize: commonConfig.pageSize, bFilter: slaveFilterCondition, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues,
        },
        flag: true,
        clearSelectData: true,
      });
    };

    /**   获取表详情数据   */
    handleGetDataInfo = (slaveInfoConfig, slaveFilterCondition, page, slaveOrderBy, props) => {
      const { app } = props === undefined ? this.props : props;
      const conditonValues = app.currentPane.conditonValues;
      const pageNum = commonUtils.isEmpty(page) ? 1 : page;
      this.props.handleGetDataSet({
        name: 'slaveInfo',
        configData: slaveInfoConfig,
        condition: {
          pageNum, pageSize: commonConfig.pageSize, bFilter: slaveFilterCondition, sFilterOrderBy: slaveOrderBy, sSqlCondition: conditonValues,
        },
        flag: true,
        clearSelectData: true,
      });
    };
    /* 获取commonGantte列表数据集 */
    handleGanttChar = async (ganttChart, slaveFilterCondition) => {
      const {
        token, sModelsId, formRoute,
      } = this.props;
      const char = {};
      if (commonUtils.isNotEmptyObject(ganttChart)) {
        char.sProcedureName = ganttChart.sProcedureName;
        char.paramsMap = {};
      }
      let charGanttData = {};
      const value = {
        sProName: char.sProcedureName,
        paramsMap: char.prodParamsMap,
        bFilter: slaveFilterCondition,
      };
      const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}&sName=${formRoute}`;
      const { data: returnData } = await commonServices.postValueService(token, value, url);
      if (returnData.code === 1) {
        const { dataset } = returnData;
        if (commonUtils.isNotEmptyObject(dataset)) {
          const outData = returnData.dataset.rows[0].dataSet.outData[0];
          if (outData.sCode === -1) {
            message.error(outData.sReturn);
          } else {
            charGanttData = commonUtils.isEmpty(outData.sReturn) ? [] : JSON.parse(outData.sReturn);
            this.props.onSaveState({ charGanttData });
          }
        }
      } else {
        message.error(returnData.msg);
      }
    };


    handleTitleChange = (slavePagination, filters, sorter) => {
      const {
        slaveConfig, slaveFilterCondition, sGroupByList, //  slaveOrderBy: slaveOrderByOld,
      } = 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.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, '', sGroupByList);
      }
    };

    handleDoubleClick = async (record) => {
      const {
        slaveConfig,
        slaveData,
        dispatch,
        slaveFilterCondition,
        slavePagination,
        slaveOrderBy,
        sModelsType,
        formRoute,
        treeFilterCondition,
        app,
        iPageSize,
        // slaveSelectedData,
        // masterData,
        // employeeConfig,
      } = this.props;
      // oee双击查看开工任务
      // if (formRoute.indexOf('indexOee') > -1) {
      //   if (slaveSelectedData[0].sCompleteCheck !== 'bCompleteCheck' && commonUtils.isNotEmptyArr(slaveSelectedData)) {
      //     this.props.changePage(false, 'startWork', '2', false);
      //     this.props.onSaveState({
      //       masterData: slaveSelectedData[0],
      //     });
      //     if (commonUtils.isNotEmptyObject(record)) {
      //       const bFilter1 = [];
      //       bFilter1.push({
      //         bFilterName: 'sParentId',
      //         bFilterCondition: '=',
      //         bFilterValue: record.sId,
      //       });
      //       const employeeData = (await this.props.handleGetDataSet({
      //         name: 'employee',
      //         configData: employeeConfig,
      //         condition: { bFilter: bFilter1 },
      //         isWait: true,
      //       }));
      //       this.props.onSaveState({
      //         ...employeeData,
      //       });
      //     }
      //   }
      // } else {}
      const picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === 'picArr'));
      const getData = this.handleGetData;
      if (picArr.length > 0) {
        let sActiveId = '';
        if (picArr[0].sName === 'picArr' && picArr[0].sDropDownType === 'picArr' && sModelsType !== 'commonList/msg') {
          [{ sActiveId }] = picArr;
          if (sActiveId === '1') {
            sActiveId = sActiveId === '1' ? commonUtils.isEmpty(record.sFormId) ? record.sSrcFormId : record.sFormId : sActiveId;
          }
        } else if (picArr[0].sName === 'picArr' && picArr[0].sDropDownType === 'picArr' && sModelsType === 'commonList/msg' && (record.sType === '消息' || record.sType === '1')) {
          [{ sActiveId }] = picArr;
        } else if (sModelsType === 'commonList/msg' && (record.sType !== '消息' || record.sType !== '1')) {
          sActiveId = '19211681019715633459786050';
        }
        /* 消息列表双击打开时 调用获取websocket消息 */
        if (sModelsType === 'commonList/msg') {
          const { webSocket, userinfo } = app;
          webSocket.onmessageTmp = async (msg) => {
            const rtmsg = JSON.parse(msg.data);
            if (rtmsg.action === 'showImg') {
              const msgData = JSON.parse(msg.data);
              dispatch({ type: 'app/saveMsgCount', payload: { msgCount: msgData.msg } });
            }
          };
          this.props.handleSendSocketMessage('reflush', 'showImg', record.sId, userinfo.sId, '您有消息待审核', null);
          if (this.props.app.currentPane.refresh !== undefined) {
            this.props.app.currentPane.refresh();
          }
        }
        const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`;
        dispatch({
          type: 'content/onRouter',
          payload: {
            refresh: getData.bind(this, slaveConfig, slaveFilterCondition, commonUtils.isEmpty(slavePagination) ? 0 : slavePagination.current, slavePagination.pageSize, slaveOrderBy, undefined, undefined, undefined, treeFilterCondition), /*   刷新方法   */
            url: sNameUrl,
            sTabId: commonUtils.createSid(),
            sParentId: this.state.sTabId,
            urlDataType: 'newPane',
            checkedId: record.sId,
            bFilter: slaveFilterCondition,
            pageSize: commonUtils.isNotEmptyNumber(iPageSize) && iPageSize !== 0 ? iPageSize : commonConfig.pageSize,
            pages: slavePagination,
            currentData: slaveData,
            sListFormmasterId: slaveConfig.sId,
            newKey: record.sId,
            currentIndex: slaveData.findIndex(item => item.sId === record.sId),
            sSrcModelsId: this.props.sModelsId,
          },
        });
      }
    };

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

    /**  点击新增按钮   */
    handleAdd = (extendsParams) => {
      const {
        slaveConfig, slaveData, dispatch, slaveFilterCondition, slavePagination, slaveOrderBy, formRoute, treeFilterCondition, iPageSize,
      } = this.props;
      const picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === 'picArr'));
      const getData = this.handleGetData;
      if (picArr.length > 0) {
        let sActiveId = '';
        if (picArr[0].sName === 'picArr' && picArr[0].sDropDownType === 'picArr') {
          [{ sActiveId }] = picArr;
        }
        const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`;
        dispatch({
          type: 'content/onRouter',
          payload: {
            refresh: getData.bind(this, slaveConfig, slaveFilterCondition, commonUtils.isEmpty(slavePagination) ? 0 : slavePagination.current, commonUtils.isEmpty(slavePagination) ? iPageSize : slavePagination.pageSize, slaveOrderBy, undefined, undefined, undefined, treeFilterCondition), /*   刷新方法   */
            url: sNameUrl,
            sTabId: commonUtils.createSid(),
            sParentId: this.state.sTabId,
            urlDataType: 'newPane',
            bFilter: slaveFilterCondition,
            pageSize: iPageSize,
            pages: slavePagination,
            currentData: slaveData,
            sListFormmasterId: slaveConfig.sId,
            ...extendsParams,
            sSrcModelsId: this.props.sModelsId,
          },
        });
      }
    };

    /* 确定要删除 */
    handleOkDel = async (props) => {
      /*   数据参数   */
      const {
        token, sModelsId, slaveConfig, slaveData, slaveSelectedRowKeys, slaveFilterCondition, slavePagination, slaveOrderBy, formRoute, app, iPageSize,
      } = props;
      const allId = [];
      slaveSelectedRowKeys.forEach((key) => {
        const iIndex = slaveData.findIndex(item => item.sSlaveId === key);
        if (iIndex > -1) {
          if (allId.indexOf(slaveData[iIndex].sId) === -1) {
            allId.push(slaveData[iIndex].sId);
          }
        }
      });
      if (commonUtils.isNotEmptyArr(allId)) {
        const value = {
          sClientType: '1',
          data: {
            sMasterTable: slaveConfig.sTbName,
            sId: allId,
            sSlaveTable: 'commonList',
          },
        };
        const { sBillNo, sId } = props.masterData || {};
        const url = `${commonConfig.server_host}business/delMasSlaBusinessData?sModelsId=${sModelsId}&sName=${formRoute}&sBillNo=${sBillNo}&sSysLogSrcId=${sId}`;
        /*   接收返回值   */
        const { data } = await commonServices.postValueService(token, value, url);
        if (data.code === 1) {
          /*   数据删除成功   */
          const oeeCurrentStateFilter = [];
          if (formRoute === '/indexOee/oeeCurrentState') {
            oeeCurrentStateFilter.push({
              bFilterName: 'sMachineId',
              bFilterCondition: '=',
              bFilterValue: app.sMachineNameSId,
            });
          }
          message.success(data.msg);
          this.props.handleGetDataSet({
            name: 'slave',
            configData: slaveConfig,
            condition: {
              pageNum: formRoute === '/indexOee/oeeCurrentState' ? '' : slavePagination.current,
              pageSize: formRoute === '/indexOee/oeeCurrentState' ? '' : commonUtils.isNotEmptyNumber(iPageSize) && iPageSize !== 0 ? iPageSize : commonConfig.pageSize,
              bFilter: formRoute === '/indexOee/oeeCurrentState' ? oeeCurrentStateFilter : slaveFilterCondition,
              slaveOrderBy: formRoute === '/indexOee/oeeCurrentState' ? '' : slaveOrderBy,
            },
            clearSelectData: true,
          });
        } else { /*   失败   */
          this.props.getServiceError(data);
        }
      }
    };

    handleDel = () => {
      const onOkDel = this.handleOkDel;
      const props = this.props;
      confirm({
        title: commonFunc.showMessage(props.app.commonConst, 'SureDel'),
        onOk() {
          onOkDel(props);
        },
        onCancel() {},
      });
    };
    // 销售订单明细获取订单号
    handleGetGoods = () => {
      this.props.onSaveState({ visibleGetGoods: true });
    };

    handleGetGoodsValue = async (value) => {
      const { sModelsId, token, formRoute } = this.props;
      const url = `${commonConfig.server_host}erpOrderProcurement/getPlatOrderOne?sModelsId=${sModelsId}&sName=${formRoute}`;
      const values = { orderHeaderId: value };

      const masterReturn = (await commonServices.postValueService(token, values, url)).data;
      if (masterReturn.code === 1) {
        message.success(masterReturn.msg);
        this.handleButtonClick('BtnRefresh');
      } else {
        this.props.getServiceError(masterReturn);
      }

      this.props.onSaveState({
        visibleGetGoods: false,
      });
    }
    handleGetGoodsCancle = () => {
      this.props.onSaveState({
        visibleGetGoods: false,
      });
    }

    /* 导出Excel */
    handleOut = async () => {
      const {
        slaveConfig, slaveFilterCondition, slaveOrderBy, formRoute, slaveSelectedRowKeys, sGroupByList, formData, app,
      } = this.props;
      const { currentPane } = app;
      const slaveFilterConditionNew = slaveFilterCondition === undefined ? [] : [...slaveFilterCondition];
      let sids = '';
      let bMutiSelect = false; /* 默认单选或不选  true ：多选 */
      if (commonUtils.isNotEmptyArr(formData)) {
        bMutiSelect = formData[0].bMutiSelect;
      }
      if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && bMutiSelect) { /* 导出Excel 只有多选情况下 导出时是根据勾选行 否则导出全部 */
        slaveSelectedRowKeys.forEach((item, i) => {
          if (i === slaveSelectedRowKeys.length - 1) {
            sids = `${sids}${item}`;
          } else {
            sids = `${sids}${item},`;
          }
        });
        const addFilter = {};
        addFilter.bFilterName = 'sSlaveId';
        addFilter.bFilterCondition = 'in';
        addFilter.bFilterValue = sids;
        slaveFilterConditionNew.push(addFilter);
      }
      /* 如果列表是别的界面弹窗进来，则需要加当前界面的条件 */
      let conditionValues ={};
      if(commonUtils.isNotEmptyObject(currentPane) && !commonUtils.isEmpty(currentPane.conditonValues)) {
        conditionValues = currentPane.conditonValues;
      }
      // let url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.sParentId}&token=${this.props.app.token}&sName=${formRoute}`;
      // if (commonUtils.isNotEmptyArr(slaveFilterConditionNew)) {
      //   url = `${url}&bFilter=${encodeURIComponent(JSON.stringify(slaveFilterConditionNew))}`;
      // }
      // if (slaveOrderBy !== undefined && slaveOrderBy !== '' && Object.keys(slaveOrderBy).length > 0) {
      //   url = `${url}&sFilterOrderBy=${encodeURIComponent(JSON.stringify(slaveOrderBy))}`;
      // }
      // if (commonUtils.isNotEmptyArr(sGroupByList)) {
      //   url = `${url}&sGroupList=${encodeURIComponent(JSON.stringify(sGroupByList))}`;
      // }
      // window.open(url);

      /* 导出使用Post提交 */
      const url = `${commonConfig.server_host}excel/export/${slaveConfig.sId}?sModelsId=${slaveConfig.sParentId}&sName=${formRoute}&token=${encodeURIComponent(this.props.app.token)}`;
      const bFilter = JSON.stringify(slaveFilterConditionNew);
      const sFilterOrderBy = JSON.stringify(slaveOrderBy);
      const sGroupList = JSON.stringify(sGroupByList);
      const conditionValuesStr = JSON.stringify(conditionValues);
      this.handleOpenOut(url, bFilter, sFilterOrderBy, sGroupList, 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(slaveOrderBy)) {
        formStr += `<input type="hidden" name="sFilterOrderBy" value='${slaveOrderBy}' />`;
      }
      if (commonUtils.isNotEmptyObject(sGroupByList)) {
        formStr += `<input type="hidden" name="sGroupList" value='${sGroupByList}' />`;
      }
      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;
    }

    /* 批量审核 */
    handleBatchExamine = () => {
      this.handleAudit(1);
    };

    /* 批量消审 */
    handleBatchCancelExamine = () => {
      this.handleAudit(0);
    };

    deteleObject = (obj) => {
      // eslint-disable-next-line camelcase
      const replace_data = obj;
      const result = []; // 去重后的数组对象集合
      const hash = {};
      // eslint-disable-next-line no-plusplus
      for (let i = 0; i < replace_data.length; i++) {
        const elem = replace_data[i].sId;
        if (!hash[elem]) {
          result.push(replace_data[i]);
          hash[elem] = true;
        }
      }
      return result;
    }
    /**   toolbar批量审核(消审)   */
    handleAudit = async (flag) => {
      /*   待用数据声明   */
      const {
        slaveSelectedData, app, slaveConfig, slavePagination, slaveFilterCondition, slaveOrderBy,
      } = this.props;
      /*   作废订单不能审核   */
      if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
        const slaveSelectedDataNew = this.deteleObject(slaveSelectedData); // 删除sid重复的数据
        let allMsg = '';
        let allErrorMsg = '';
        let dataAuditProcessValue = 0;
        const dataAuditProcessMaxValue = slaveSelectedDataNew.length;
        for (const child of slaveSelectedDataNew) {
          if (child.bInvalid) {
            message.warning(`已作废的单据${child.sBillNo}不能审核！`);
            return '';
          }
          /**   数据审核   */
          const strMsgs = await this.dataAudit(flag, `${child.sId}_${child.sFormId}`, child.sBillNo);
          if (commonUtils.isNotEmptyStr(strMsgs.strMsg)) {
            allMsg += `${strMsgs.strMsg} \n `;
          } else {
            allMsg += '';
          }
          if (commonUtils.isNotEmptyStr(strMsgs.strErrorMsg)) {
            allErrorMsg += `${strMsgs.strErrorMsg} \n `;
          } else {
            allErrorMsg += '';
          }
          dataAuditProcessValue += 1;
          this.props.onSaveState({ bDataAuditProgress: true, dataAuditProcessValue, dataAuditProcessMaxValue });
        }
        if (commonUtils.isNotEmptyStr(allMsg)) {
          message.info(allMsg);
        }
        if (allErrorMsg !== undefined && commonUtils.isNotEmptyStr(allErrorMsg)) {
          message.error(allErrorMsg);
        }
        this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, true); /*   刷新方法   */
        this.props.onSaveState({ bDataAuditProgress: false });
      } else {
        message.error(commonFunc.showMessage(app.commonConst, 'pleaseChooseData'));/* 请选择一条数据 */
      }
    };

    /**   数据审核   */
    dataAudit = async (flag, sId_sFormId, sBillNo, tmpCheck, isWait) => {
      const [sId, sFormId] = sId_sFormId.split('_');
      /*   待用数据声明   */
      const {
        sModelsId, app, slaveConfig, formRoute,
      } = this.props;
      /*   数据参数   */
      const picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === 'picArr'));
      const value = {
        sClientType: '1',
        paramsMap: {
          iFlag: flag,
          iTmpCheck: commonUtils.isEmptyNumber(tmpCheck) ? 0 : tmpCheck,
          sFormGuid: commonUtils.isEmptyArr(picArr) ? sFormId : picArr[0].sActiveId,
          sGuid: sId,
        },
      };
      /*   数据审核   */
      const url = `${commonConfig.server_host}business/doExamine?sModelsId=${sModelsId}&sName=${formRoute}`;
      const returnData = (await commonServices.postValueService(app.token, value, url)).data;
      const msgs = {};
      if (isWait) {
        return returnData;
      } else {
        /*   接收返回值   */
        if (returnData.code === 1) { /*   成功   */
          if (flag === 1) {
            /*   审核   */
            const { outData } = returnData.dataset.rows[0].dataSet;
            if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
              msgs.strMsg = commonUtils.isNotEmptyObject(sBillNo) ? `${sBillNo}${outData[0].sReturn}` : `${outData[0].sReturn}`;
              // if (outData[0].sReturn.split('-').length < 2) {
              //   // 正常业务提示，非审核模板
              //   if (this.props.app.currentPane.refresh !== undefined) {
              //     this.props.app.currentPane.refresh();
              //   }
              //   msgs.strMsg = `${sBillNo}审核${outData[0].sReturn}`;
              //   return msgs;
              // }
              // const sReturnArray = outData[0].sReturn.split('|');
              // const sCheckModelId = sReturnArray[0].split('-')[1];
              // if (commonUtils.isNotEmptyStr(sCheckModelId)) {
              //   msgs.strMsg = `${sBillNo}审核失败`;
              // }
            } else {
              // this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, true); /*   刷新方法   */
              // message.destroy();
              msgs.strMsg = commonUtils.isNotEmptyObject(sBillNo) ? `${sBillNo}${returnData.msg}` : `${returnData.msg}`;
            }
          } else {
            /*   消审   */
            const { outData } = returnData.dataset.rows[0].dataSet;
            if (commonUtils.isNotEmptyStr(outData[0].sReturn)) {
              msgs.strMsg = commonUtils.isNotEmptyObject(sBillNo) ? `${sBillNo}${outData[0].sReturn}` : `$${outData[0].sReturn}`;
            } else {
              // this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, true); /*   刷新方法   */
              msgs.strMsg = commonUtils.isNotEmptyObject(sBillNo) ? `${sBillNo}${returnData.msg}` : `${returnData.msg}`;
            }
          }
        } else { /*   失败   */
          msgs.strErrorMsg = returnData.msg;
          // this.props.getServiceError(returnData);
        }
        return msgs;
      }
    };

    /** 按钮操作事件 */
    handleButtonClick = (name, isFresh) => {
      if (name === 'BtnOut') {
        this.handleOut();
      } else if (name === 'BtnDesignFunction') {
        this.handleDesignFunction();
      } else if (name === 'BtnRefresh') {
        const {
          slaveConfig, slavePagination, slaveFilterCondition, slaveOrderBy,
        } = this.props;
        this.props.onSaveState({
          clearArray: [], searchText: '', slaveSelectedRowKeys: [], slaveSelectedData: [], slaveInfoSelectedRowKeys: [], slaveInfoSelectedData: [], treeSelectedKeys: [], treeFilterCondition: [], loading: false, pageLoading: true, isFresh,
        });
        if (slavePagination === undefined) return;
        this.handleGetData(slaveConfig, slaveFilterCondition, slavePagination.current, slavePagination.pageSize, slaveOrderBy, true); /*   刷新方法   */
        // if (formRoute === '/indexPage/materialRequirementsPlanning') {
        //   if (commonUtils.isNotEmptyObject(slaveInfoConfig)) {
        //     this.handleGetDataInfo(slaveInfoConfig, slaveFilterCondition, 1);
        //   }
        // }
        /* 判断是否要加载过滤树数据 */
        const filterTreeConfigArr = slaveConfig.gdsconfigformslave.filter(item => item.bTree);
        if (commonUtils.isNotEmptyArr(filterTreeConfigArr)) {
          const filterTreeConfig = filterTreeConfigArr[0];
          this.handleGetFilterTreeData(filterTreeConfig, slaveFilterCondition, 1);
        }
        const { clearArray } = this.props;
        if (!commonUtils.isEmpty(clearArray)) {
          for (const item of clearArray) {
            const { confirm, clearFilters } = item;
            confirm();
            clearFilters();
          }
        }
      } else if (name === 'BtnSelect') {
        const { slaveSelectedData, app } = this.props;
        if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
          this.props.app.currentPane.select(this.props.app.currentPane.name, this.props.app.currentPane.config, slaveSelectedData);
        } else {
          message.error(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); /* 请选择一条数据 */
        }
      } else if (name === 'BtnSelectCancel') {
        this.props.app.currentPane.selectCancel(this.props.app.currentPane.name);
      } else if (name === 'BtnBatchExamine') {
        this.handleBatchExamine();
      } else if (name === 'BtnBatchCancelExamine') {
        this.handleBatchCancelExamine();
      } else if (name === 'BtnNoForceComplete') {
        this.handleNoForceComplete();
      } else if (name === 'BtnSettleAccounts') {
        this.handleToSettlement(1);
      } else if (name === 'BtnReverseCheckout') {
        this.handleToSettlement(2);
      } else if (name === 'BtnBatchWorkListPriceUpdate') { /* 工单列表价格批量更新 */
        this.handleBatchWorkListsPriceUpdate();
      }
    };
    /* OEE机台任务 点击开工执行的逻辑 */
    handleOeeCopyTo = async (name) => {
      const {
        token, app, sModelsId, slaveSelectedData, slaveConfig, slaveDelData,
      } = this.props;
      const newCopyTo = {};
      const slaveData = [];
      if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
        // 验证是否单据是否使用
        const sMachineId = app.sMachineNameSId;
        const creatId = commonUtils.createSid();
        const dataUrl = `${commonConfig.server_host}bill/billCopyToCheckWork?sModelsId=${sModelsId}`;
        const values = { sMachineId };
        const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
        if (dataReturn.code === 1) {
          const copyToConfig = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.gdsconfigformslave.filter(item => item.sControlName === name) : '';
          const slaveAssignField = commonUtils.isNotEmptyObject(copyToConfig) ? copyToConfig[0].sAssignField : '';
          slaveSelectedData.forEach((slaveItem) => {
            newCopyTo.slave = slaveItem;
            let colorRow = commonFunc.getDefaultData(slaveConfig, newCopyTo); // 取默认值
            colorRow = { ...colorRow, ...commonFunc.getAssignFieldValue(slaveAssignField, slaveItem, newCopyTo) }; // 取赋值字段
            colorRow.handleType = 'add';
            colorRow.sStatus = 'adjustment'; /* 点击开工进来是调机中，原来是生产中 */
            colorRow.sId = creatId;
            colorRow.sTeamId = app.sTeamNameSId;
            colorRow.sMachineId = app.sMachineNameSId;
            colorRow.sParentId = colorRow.sId;
            colorRow.tCreateDate = new Date();
            slaveData.push(colorRow);
          });
          const params = {};
          params.data = [];
          params.data.push(commonBusiness.mergeData('slave', 'plc_machinedata', slaveData, slaveDelData));
          // params.data = slaveData;
          const BtnSave = commonFunc.showMessage(app.commonConst, 'BtnSave');/* 保存 */
          params.optName = BtnSave;
          params.sClientType = '1';
          const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
          if (commonUtils.isNotEmptyObject(returnData)) {
            if (returnData.code === 1) {
              // const copyTo = {};
              // copyTo.name = name;
              // copyTo.config = commonUtils.isNotEmptyArr(copyToConfig) ? copyToConfig[0] : {};
              // copyTo.slaveData = slaveData;
              // copyTo.copyOtherData = [];
              // dispatch({
              //   type: 'content/onRouter',
              //   payload: {
              //     url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`, /*   接口地址   */
              //     copyTo,
              //   },
              // });
              // 改变indexOee中的activeKey,
              this.props.onSaveCurrentState(slaveData, true, undefined, undefined, 1);
            }
          }
        } else {
          this.props.getServiceError(dataReturn);
        }
      }
    }
    handleOeeLabelCopyTo = async (name, sActiveId) => {
      const {
        slaveSelectedData, dispatch,
      } = this.props;
      if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
        const formRouteNew = '/indexOee/labelPrint';
        dispatch({
          type: 'content/onRouter',
          payload: {
            url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRouteNew}`, /*   接口地址   */
            sSrcModelsId: this.props.sModelsId,
          },
        });
      }
    }

    /*   单据页复制到   */
    handleCopyTo = async (name, sActiveId) => {
      /*   待用数据声明   */
      const {
        slaveConfig, slaveSelectedData, token, app, sModelsId, formRoute, slaveInfoConfig, slaveInfoSelectedData, slaveFilterCondition,
        slavePagination, slaveOrderBy, treeFilterCondition, dispatch,
      } = this.props;

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

      let isRefresh = true;

      if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
        const copyToConfig = slaveConfig.gdsconfigformslave.filter(item => item.sControlName.includes(name));
        let copyToData = slaveSelectedData;
        const addcopyOther = [];
        let tbSuffix = '';
        if (formRoute === '/indexPage/materialRequirementsPlanning') {
          if (name === 'BtnCopyTo.ActPurchaseOrder') {
            const detailCopy = {};
            detailCopy.name = 'detail';
            detailCopy.config = slaveInfoConfig;
            detailCopy.data = slaveInfoSelectedData;
            addcopyOther.push(detailCopy);
            tbSuffix = 'detail';
            isRefresh = true;
          } else {
            copyToData = slaveInfoSelectedData;
            isRefresh = true;
          }
          /* 物料需求计划生成采购申请、采购订单去重处理 */
          if (commonUtils.isNotEmptyArr(copyToData)) {
            const copyToDataNew = [];
            copyToData.forEach((item) => {
              const iIndex = copyToDataNew.findIndex(child => child.sWorkOrderMaterialId === item.sWorkOrderMaterialId);
              if (iIndex < 0) {
                copyToDataNew.push(item);
              }
            });
            copyToData = copyToDataNew;
          }
        } else if (name === 'BtnCopyTo.ActProduceReport') { /* 若机台中点击暂停 则待产量上报中点击上报提示”工序已暂停，无法上报 */
          if (commonUtils.isNotEmptyArr(copyToData) && copyToData[0].sState === '3') {
            message.warn('工序已暂停，无法开工！');
            return;
          }
        }
        // 不重复字段处理 例如 复制到时只能同一客户复制到
        const iIndex = copyToConfig.findIndex(item => item.sControlName === name);
        if (iIndex > -1 && !commonUtils.isEmpty(copyToConfig[iIndex].sNotRepeatColumn)) {
          const sNotRepeatColumn = copyToConfig[iIndex].sNotRepeatColumn.trim();
          const sNotRepeatValue = copyToData[0][sNotRepeatColumn];
          const iCount = copyToData.filter(item => item[sNotRepeatColumn] === sNotRepeatValue).length;
          if (iCount !== copyToData.length) {
            const iConfigIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sNotRepeatColumn);
            const sNotRepeatShowName = iConfigIndex > -1 ? slaveConfig.gdsconfigformslave[iConfigIndex].showName : '';
            message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseSame') + sNotRepeatShowName); // 请选择相同
            return;
          }
        }
        const { userinfo } = app;
        const sIdArray = [];
        copyToData.forEach((item) => {
          if (formRoute === '/indexPage/materialRequirementsPlanning') {
            sIdArray.push(item.sWorkOrderMaterialId); /* 物料需求计划生成用sWorkOrderMaterialId作为唯一键 */
          } else {
            sIdArray.push(item.sSlaveId);
          }
        });
        this.props.app.webSocket.onmessageTmp = (msg) => {
          const rtmsg = JSON.parse(msg.data);
          if (rtmsg.action === 'execute') {
            if (rtmsg.msg === 'continue') {
              const { formRoute } = this.state;
              if (commonUtils.isNotEmptyArr(copyToData)) {
                const copyTo = {};
                copyTo.name = name;
                copyTo.config = copyToConfig;
                copyTo.masterData = copyToData[0];
                copyTo.slaveData = copyToData;
                copyTo.copyOtherData = addcopyOther;
                copyTo.srcFormRoute = this.props.formRoute; /* 未清来源路由 */
                dispatch({
                  type: 'content/onRouter',
                  payload: {
                    url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`, /*   接口地址   */
                    copyTo,
                    refresh: getData.bind(this, slaveConfig, slaveFilterCondition, commonUtils.isEmpty(slavePagination) ? 0 : slavePagination.current, slavePagination.pageSize, slaveOrderBy, isRefresh, undefined, undefined, treeFilterCondition),
                    sSrcModelsId: this.props.sModelsId,
                  },
                });
              } else {
                message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据
              }
            } else {
              message.warning(rtmsg.handlers + commonFunc.showMessage(app.commonConst, 'InOperation'));/* 在操作,请稍后再操作! */
            }
          }
        };
        const sId = sIdArray.toString();
        const getData = this.handleGetData;
        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) {
          const sendSocketMessage = this.props.handleSendSocketMessage;
          if (dataReturn.dataset.rows.length > 0) {
            confirm({
              title: commonFunc.showMessage(app.commonConst, 'beUsedToNew'), /* 单据已存在，是否填写新单据 */
              onOk() {
                sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);
              },
              onCancel() {
              },
            });
          } else {
            sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);
          }
        } else {
          this.props.getServiceError(dataReturn);
        }
      } else {
        message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据
      }
    };


    handleBillCopyTo = async (name, sActiveId, copyToBillConfig, callBack) => {
      /*   待用数据声明   */
      const {
        slaveConfig, slaveSelectedData, token, app, sModelsId, slaveInfoConfig, slaveInfoSelectedData, slaveFilterCondition,
        slavePagination, slaveOrderBy, treeFilterCondition, dispatch,
      } = this.props;
      let isRefresh = true;
      const formRoute = '/indexOee/commonOeeBill';

      if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
        const copyToConfig = slaveConfig.gdsconfigformslave.filter(item => item.sControlName.includes(name));
        let copyToData = slaveSelectedData;
        const addcopyOther = [];
        let tbSuffix = '';
        if (formRoute === '/indexPage/materialRequirementsPlanning') {
          if (name === 'BtnCopyTo.ActPurchaseOrder') {
            const detailCopy = {};
            detailCopy.name = 'detail';
            detailCopy.config = slaveInfoConfig;
            detailCopy.data = slaveInfoSelectedData;
            addcopyOther.push(detailCopy);
            tbSuffix = 'detail';
            isRefresh = true;
          } else {
            copyToData = slaveInfoSelectedData;
            isRefresh = true;
          }
          /* 物料需求计划生成采购申请、采购订单去重处理 */
          if (commonUtils.isNotEmptyArr(copyToData)) {
            const copyToDataNew = [];
            copyToData.forEach((item) => {
              const iIndex = copyToDataNew.findIndex(child => child.sWorkOrderMaterialId === item.sWorkOrderMaterialId);
              if (iIndex < 0) {
                copyToDataNew.push(item);
              }
            });
            copyToData = copyToDataNew;
          }
        } else if (name === 'BtnCopyTo.ActProduceReport') { /* 若机台中点击暂停 则待产量上报中点击上报提示”工序已暂停，无法上报 */
          if (commonUtils.isNotEmptyArr(copyToData) && copyToData[0].sState === '3') {
            message.warn('工序已暂停，无法开工！');
            return;
          }
        }
        // 不重复字段处理 例如 复制到时只能同一客户复制到
        const iIndex = copyToConfig.findIndex(item => item.sControlName === name);
        if (iIndex > -1 && !commonUtils.isEmpty(copyToConfig[iIndex].sNotRepeatColumn)) {
          const sNotRepeatColumn = copyToConfig[iIndex].sNotRepeatColumn.trim();
          const sNotRepeatValue = copyToData[0][sNotRepeatColumn];
          const iCount = copyToData.filter(item => item[sNotRepeatColumn] === sNotRepeatValue).length;
          if (iCount !== copyToData.length) {
            const iConfigIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === sNotRepeatColumn);
            const sNotRepeatShowName = iConfigIndex > -1 ? slaveConfig.gdsconfigformslave[iConfigIndex].showName : '';
            message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseSame') + sNotRepeatShowName); // 请选择相同
            return;
          }
        }
        const { userinfo } = app;
        const sIdArray = [];
        copyToData.forEach((item) => {
          if (formRoute === '/indexPage/materialRequirementsPlanning') {
            sIdArray.push(item.sWorkOrderMaterialId); /* 物料需求计划生成用sWorkOrderMaterialId作为唯一键 */
          } else if (formRoute === '/indexOee/commonOeeBill') {
            const activeKey = commonUtils.isNotEmptyObject(copyToBillConfig) ? copyToBillConfig.sActiveKey : 'sWorkOrderSlaveId';
            sIdArray.push(item[activeKey]); /* 物料需求计划生成用sWorkOrderMaterialId作为唯一键 */
          } else {
            sIdArray.push(item.sSlaveId);
          }
        });
        this.props.app.webSocket.onmessageTmp = (msg) => {
          const rtmsg = JSON.parse(msg.data);
          if (rtmsg.action === 'execute') {
            if (rtmsg.msg === 'continue') {
              const { formRoute } = this.state;
              if (commonUtils.isNotEmptyArr(copyToData)) {
                const copyTo = {};
                copyTo.name = name;
                copyTo.config = copyToConfig;
                copyTo.masterData = copyToData[0];
                copyTo.slaveData = copyToData;
                copyTo.copyOtherData = addcopyOther;
                copyTo.srcFormRoute = this.props.formRoute; /* 未清来源路由 */
                dispatch({
                  type: 'content/onRouter',
                  payload: {
                    url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`, /*   接口地址   */
                    copyTo,
                    refresh: getData.bind(this, slaveConfig, slaveFilterCondition, commonUtils.isEmpty(slavePagination) ? 0 : slavePagination.current, slavePagination.pageSize, slaveOrderBy, isRefresh, undefined, undefined, treeFilterCondition),
                    sSrcModelsId: this.props.sModelsId,
                  },
                });
              } else {
                message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据
              }
            } else {
              message.warning(rtmsg.handlers + commonFunc.showMessage(app.commonConst, 'InOperation'));/* 在操作,请稍后再操作! */
            }
          }
        };
        const sId = sIdArray.toString();
        const getData = this.handleGetData;

        const dataUrl = `${commonConfig.server_host}bill/billCopyToCheck/?sModelsId=${sModelsId}&sActiveId=${sActiveId}&tbSuffix=${tbSuffix}&sName='/indexOee/commonOeeBill'`;
        const values = { sSlaveId: sId };
        const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
        if (dataReturn.code === 1) {
          const sendSocketMessage = this.props.handleSendSocketMessage;
          if (dataReturn.dataset.rows.length > 0) {
            const { sId } = dataReturn.dataset.rows[0];
            if (commonUtils.isNotEmptyObject(sId)) { /* 查看 */
              sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);
              this.props.onSaveOeeState({ checkedId: sId });
            }
            // confirm({
            //   title: commonFunc.showMessage(app.commonConst, 'beUsedToNew'), /* 单据已存在，是否填写新单据 */
            //   onOk() {
            //     sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);
            //   },
            //   onCancel() {
            //   },
            // });
          } else {
            sendSocketMessage('copy', 'execute', sId, userinfo.sId, null, null);
          }
        } else {
          this.props.getServiceError(dataReturn);
        }
        if (callBack) {
          callBack();
        }
      } else {
        message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据
      }
    };

    // CopyTo = (refresh, copyToData, name, copyToConfig, sActiveId, dispatch, app, copyOther) => {
    //   const { formRoute } = this.state;
    //   if (commonUtils.isNotEmptyArr(copyToData)) {
    //     const copyTo = {};
    //     copyTo.name = name;
    //     copyTo.config = copyToConfig;
    //     copyTo.masterData = copyToData[0];
    //     copyTo.slaveData = copyToData;
    //     copyTo.copyOtherData = copyOther;
    //     dispatch({
    //       type: 'content/onRouter',
    //       payload: {
    //         url: `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${sActiveId}?sModelsId=${sActiveId}&sName=${formRoute}`, /*   接口地址   */
    //         copyTo,
    //         refresh,
    //       },
    //     });
    //   } else {
    //     message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择数据
    //   }
    // };
    // handleForceComplete = (name) => {
    //   const { slaveSelectedRowKeys, app, masterConfig } = this.props;
    //   if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
    //     message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择记录
    //   } else {
    //     const slaveMemoConfigOld = [];
    //     let btnConfigNameArr = [];
    //     if (name.indexOf('BtnRepair') > -1) {
    //       const btnConfig = masterConfig.gdsconfigformslave.filter(item => item.sControlName === name)[0];// sButtonEnabled  sButtonParam
    //       if (!commonUtils.isEmpty(btnConfig.sActiveKey)) {
    //         btnConfigNameArr = btnConfig.sActiveKey.split(',');
    //       }
    //       if (commonUtils.isNotEmptyArr(btnConfigNameArr)) {
    //         // eslint-disable-next-line array-callback-return
    //         btnConfigNameArr.map((i) => {
    //           const singleConfig = this.props.slaveConfig.gdsconfigformslave.filter(item => (item.sName === i))[0];
    //           slaveMemoConfigOld.push(singleConfig);
    //         });
    //       }
    //     }
    //     const sysLogData = { sId: slaveSelectedRowKeys.toString() };
    //     this.props.onSaveState({
    //       slaveMemoConfig: slaveMemoConfigOld,
    //       sCurrMemoProps: {
    //         bVisibleMemo: true,
    //         sMemoField: 'sReason',
    //         sRecord: sysLogData,
    //         dataSource: sysLogData,
    //         btnName: name,
    //       },
    //     });
    //   }
    // }

    handleNoForceComplete = async () => {
      const {
        sModelsId, slaveSelectedRowKeys, slaveConfig, app, formRoute,
      } = this.props;
      const { token } = this.props.app;
      if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseData')); // 请选择记录
      } else {
        const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnNoForceComplete');
        const btnConfig = slaveConfig.gdsconfigformslave[iIndex];
        const sRelation = btnConfig.sRelation;
        const url = `${commonConfig.server_host}bill/billForceComplete?sModelsId=${sModelsId}&sName=${formRoute}`;
        const values = { sqlParam: sRelation, sId: slaveSelectedRowKeys.toString(), sType: 'noforce' };

        const dataReturn = (await commonServices.postValueService(token, values, url)).data;
        if (dataReturn.code === 1) {
          message.success(dataReturn.msg);
          this.handleButtonClick('BtnRefresh');
        } else {
          this.props.getServiceError(dataReturn);
        }
      }
    }

    // /* 双击弹出Memo */
    // handleGetMemo = (name, sValue, sMemoFiled, sRecord) => {
    //   const { sCurrMemoProps } = this.props;
    //   sCurrMemoProps.bVisibleMemo = false;
    //   sRecord[sMemoFiled] = sValue;
    //   this.props.onSaveState({ sCurrMemoProps });
    //   this.handleToForceComplete(sValue);
    // };

    /* 设计报表功能 */
    handleDesignFunction = () => {
      this.props.onSaveState({ visibleStatement: true });
    };
    handleBtnPrint = (sActiveId, checked, key) => {
      const {
        app,
        sModelsId,
        masterConfig,
        menuChildData,
        reportData,
        slaveFilterCondition,
        slaveSelectedRowKeys,
        slaveSelectedData,
        formRoute,
        treeFilterCondition,
        slaveData,
      } = this.props;
      const { token } = app;
      const slaveFilterConditionNew = slaveFilterCondition === undefined ? [] : [...slaveFilterCondition];
      // const queryFilter = {};
      // queryFilter[masterConfig.sId] = { sId: masterData.sId };
      // queryFilter[slaveConfig.sId] = { sSqlCondition: { sParentId: masterData.sId } };

      let sids = '';
      slaveSelectedRowKeys.forEach((item, i) => {
        if (commonUtils.isNotEmptyArr(slaveData)) {
          const iIndex = slaveData.findIndex(child => child.sSlaveId === item);
          if (iIndex > -1) {
            if (i === slaveSelectedRowKeys.length - 1) {
              sids = `${sids}${item}`;
            } else {
              sids = `${sids}${item},`;
            }
          }
        }
      });
      if (sids !== '') {
        const addFilter = {};
        addFilter.bFilterName = 'sSlaveId';
        addFilter.bFilterCondition = 'in';
        addFilter.bFilterValue = sids;
        slaveFilterConditionNew.push(addFilter);
      }
      // 将过滤数的赛选条件塞入打印中
      if (key.indexOf('BtnPrint.') > -1 && commonUtils.isNotEmptyArr(treeFilterCondition)) {
        // eslint-disable-next-line array-callback-return
        treeFilterCondition.map((item) => {
          slaveFilterConditionNew.push(item);
        });
      }
      const queryFilter = {};

      queryFilter[masterConfig.sId] = { bFilter: slaveFilterConditionNew };
      const queryFilterJson = encodeURIComponent(JSON.stringify(queryFilter));
      /* 拿到打印报表名称 */
      let printReportName = 'report';
      let slaveOneData = commonUtils.isNotEmptyArr(slaveSelectedData) ? JSON.stringify(slaveSelectedData) : '[]';
      slaveOneData = slaveOneData.replace("'", '');
      if (key.indexOf('BtnPrint.') > -1) {
        if (commonUtils.isNotEmptyArr(reportData)) {
          const iIndex = reportData.findIndex(item => item.sId === sActiveId);
          if (iIndex > -1) {
            printReportName = reportData[iIndex].sReportName;
          }
        }
        const urlPrint = `${commonConfig.file_host}printReport/printPdf/${sActiveId}/${printReportName}.pdf?${checked ? 'fileType=.xlsx&' : ''}queryFilter=${queryFilterJson}&sModelsId=${sModelsId}&sMaintableId=${masterConfig.sId}&token=${encodeURIComponent(token)}&sName=${formRoute}`;
        window.open(urlPrint);
      } else if (key.indexOf('BtnPrintCus.') > -1) {
        if (commonUtils.isNotEmptyArr(menuChildData)) {
          const iIndex = menuChildData.findIndex(item => item.sId === sActiveId);
          if (iIndex > -1) {
            printReportName = menuChildData[iIndex].sReportName;
          }
        }
        // const urlPrint = `${commonConfig.file_host}printReport/printPdf/${printReportName}?${checked ? 'fileType=.xlsx&' : ''}sModelsId=${sModelsId}&printType=noquery&slaveOneData=${slaveOneData}`;
        // window.open(`${encodeURI(`${urlPrint}&queryFilter=${queryFilterJson}`)}&token=${encodeURIComponent(token)}`);

        /* Get提交地址栏参数过多,更改Get提交为Post提交 */
        const url = `${commonConfig.file_host}printReport/printPdf/${printReportName}?${checked ? 'fileType=.xlsx&' : ''}sModelsId=${sModelsId}&printType=noquery&token=${encodeURIComponent(token)}`;
        const param = slaveOneData;
        this.handleOpenPost(url, param);
      }
    };
    /* 工单列表价格批量更新 */
    handleBatchWorkListsPriceUpdate = () => {
      const { slaveData, slaveSelectedRowKeys, app } = this.props;
      if (commonUtils.isEmptyStr(slaveSelectedRowKeys)) {
        return message.warning(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请选择一条数据进行操作 */
      } else {
        const batchPriceWorkListUpdateData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId));
        this.props.onSaveState({ batchPriceWorkListUpdateData, visibleBatchWorkListPriceUpdate: true });
      }
    };

    handleOpenPost= (url, params) => {
      const newWin = window.open();
      let formStr = '';
      // 设置样式为隐藏，打开新标签再跳转页面前，如果有可现实的表单选项，用户会看到表单内容数据
      formStr = `<form style="visibility:hidden;" method="POST" action="${url}">` +
        `<input type="hidden" name="slaveOneData" value='${params}' />` +
        '</form>';
      newWin.document.body.innerHTML = formStr;
      newWin.document.forms[0].submit();
      return newWin;
    }

    // handleGetMemoCancel = () => {
    //   const sCurrMemoProps = { bVisibleMemo: false };
    //   this.props.onSaveState({ sCurrMemoProps });
    // };

    // handleToForceComplete = async (sValue) => {
    //   const {
    //     app, slaveSelectedRowKeys, slaveConfig, sModelsId, slaveInfoSelectedRowKeys, formRoute,
    //   } = this.props;
    //
    //   const { token } = app;
    //   const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === 'BtnForceComplete' || item.sControlName === 'BtnNoPurchase');
    //   const btnConfig = slaveConfig.gdsconfigformslave[iIndex];
    //   const sRelation = btnConfig.sRelation;
    //
    //   let selectedRowKeys = '';
    //   if (formRoute === '/materialRequirementsPlanning') {
    //     selectedRowKeys = slaveInfoSelectedRowKeys.toString();
    //   } else {
    //     selectedRowKeys = slaveSelectedRowKeys.toString();
    //   }
    //
    //   const url = `${commonConfig.server_host}bill/billForceComplete?sModelsId=${sModelsId}&sName=${formRoute}`;
    //   const values = { sqlParam: sRelation, sId: selectedRowKeys, sReason: sValue };
    //
    //   const masterReturn = (await commonServices.postValueService(token, values, url)).data;
    //   if (masterReturn.code === 1) {
    //     message.success(masterReturn.msg);
    //     this.handleButtonClick('BtnRefresh');
    //   } else {
    //     this.props.getServiceError(masterReturn);
    //   }
    // }

    handleToSettlement = async (sType) => {
      const {
        app, sModelsId, slaveSelectedRowKeys, slaveData, formRoute,
      } = this.props;
      let continueFlag = true;
      let msg = '';

      const selectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId));
      const point = commonUtils.convertStrToNumber(selectedData[0].sPeriodId);
      if (sType === 1) {
        for (const item of slaveData) {
          const curr = commonUtils.convertStrToNumber(item.sPeriodId);
          if (curr > point && item.bFrozen) {
            continueFlag = false;
            msg = `${item.sPeriodId}已结账`;
            break;
          } else if (curr < point && !item.bFrozen) {
            continueFlag = false;
            msg = `${item.sPeriodId}未结账`;
            break;
          }
        }
      } else if (sType === 2) {
        for (const item of slaveData) {
          const curr = commonUtils.convertStrToNumber(item.sPeriodId);
          if (curr < point && item.bFrozen) {
            continueFlag = false;
            msg = `${item.sPeriodId}已结账`;
            break;
          } else if (curr > point && !item.bFrozen) {
            continueFlag = false;
            msg = `${item.sPeriodId}未结账`;
            break;
          }
        }
      }
      // tStartDate: "2017-01-02 16:00:00"  tEndDate: "2017-02-01 16:00:00"  tStartDate, tEndDate,
      if (continueFlag) {
        const value = {
          sProName: 'Sp_System_AutoMaterialsPriceSingle',
          paramsMap: { tStartDate: selectedData[0].tStartDate, tEndDate: selectedData[0].tEndDate },
        };
        const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}&sName=${formRoute}`;
        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);
          }
        } else {
          this.props.getServiceError(returnData);
        }
      } else {
        message.warn(msg);
      }
    }
    handleTreeSelect = (name, selectedKeys, e) => {
      const { slaveFilterCondition, slaveConfig, slavePagination } = this.props;
      const slaveFilterConditionNew = {};
      let ids = '';
      const treeFilterCondition = [];
      this.props.onTreeSelect(name, selectedKeys, e);
      /* 加过滤条件 */
      for (const sId of selectedKeys) {
        const searchId = sId.split('_')[1];
        const searchName = sId.split('_')[0];
        ids = slaveFilterConditionNew[`${searchName}`];
        if (commonUtils.isNotEmptyObject(ids)) {
          ids += `,${searchId}`;
        } else {
          ids = searchId;
        }
        slaveFilterConditionNew[`${searchName}`] = ids;
      }
      if (commonUtils.isNotEmptyObject(slaveFilterConditionNew)) {
        Object.keys(slaveFilterConditionNew).forEach((item) => {
          if (commonUtils.isNotEmptyObject(slaveFilterConditionNew[item])) {
            treeFilterCondition.push({
              bFilterName: item,
              bFilterCondition: 'in',
              bFilterValue: slaveFilterConditionNew[item],
              bFilterType: 'tree',
            });
          }
        });
        if (commonUtils.isNotEmptyArr(treeFilterCondition)) {
          this.props.onSaveState({
            treeFilterCondition,
          });
        }
      }
      this.handleGetData(slaveConfig, slaveFilterCondition, 1, slavePagination.pageSize, '', false, '', '', treeFilterCondition);
      /* 如果有选中树节点，则展开选中节点的父节点，否则默认展开第一个父节点 */
      if (commonUtils.isNotEmptyArr(selectedKeys) && selectedKeys.length > 0) {
        const { treeData } = this.props;
        const expandedKeys = [];
        const len = selectedKeys.length;
        const iIndex = treeData.findIndex(item => item.key === selectedKeys[len - 1] || item.sName === selectedKeys[len - 1].split('_')[0]);
        if (iIndex > -1) { /* 选中的是父节点 */
          expandedKeys.push(treeData[iIndex].key);
        }
        this.props.onSaveState({
          expandedKeys,
        });
      }
    };
    handleTableSelectRowChange = async (name, selectedRowKeys, changeValue) => {
      if (name === 'slave' || name === 'master') {
        const {
          token, sModelsId, [`${name}Total`]: totalData, [`${name}AllTotal`]: totalAllData, [`${name}Config`]: tableConfig, [`${name}Data`]: tableData, formData, app,
        } = this.props;
        const { dNetMoney, dNetPrice } = app.decimals;
        const selectedTotalData = [];
        let bMutiSelect = false; /* 默认单选或不选  true ：多选 */
        if (commonUtils.isNotEmptyArr(formData)) {
          bMutiSelect = formData[0].bMutiSelect;
        }
        if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectedRowKeys)) {
          let url = '';
          if (sModelsId === '19211681019715326709731800') {
            let sProcessId = '';
            if (name === 'master') {
              sProcessId = changeValue.sProcessClassifyId;
            } else if (name === 'slave') {
              const sProcessIdIndex = tableData.findIndex(item => item.sSlaveId === 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 });
              }
            }
          }
          /* 只有多选情况下 汇总勾选行字段 */
          if (commonUtils.isNotEmptyArr(totalData)) {
            if (commonUtils.isNotEmptyObject(tableConfig) && tableConfig.gdsconfigformslave && bMutiSelect) {
              const tableConfigSum = tableConfig.gdsconfigformslave.filter(item => commonUtils.isNotEmptyObject(item.sName) && item.bSum && item.bVisible);
              const tableFilterData = tableData.filter(item => selectedRowKeys.includes(item.sSlaveId));
              if (commonUtils.isNotEmptyArr(tableConfigSum) && commonUtils.isNotEmptyArr(tableFilterData)) {
                const selectedTotal = {};
                selectedTotal.bSum = true;
                selectedTotal.key = '0000';
                tableConfigSum.forEach((itemConfig) => {
                  const sName = itemConfig.sName;
                  if (commonUtils.isNotEmptyObject(sName)) {
                    tableFilterData.forEach((child) => {
                      if (commonUtils.isNotEmptyNumber(child[sName])) {
                        /* 金额、单价 保留系统设置小数位 */
                        if (sName.toLowerCase().endsWith('price')) { /*   价格   */
                          selectedTotal[sName] = commonUtils.convertFixNum(commonUtils.convertFixNum(commonUtils.isNull(child[sName], 0),dNetPrice) + commonUtils.convertFixNum(commonUtils.isNull(selectedTotal[sName], 0),dNetPrice),dNetPrice);
                        } else if (sName.toLowerCase().endsWith('money')) { /*   金额   */
                          selectedTotal[sName] = commonUtils.convertFixNum(commonUtils.convertFixNum(commonUtils.isNull(child[sName], 0),dNetMoney) + commonUtils.convertFixNum(commonUtils.isNull(selectedTotal[sName], 0),dNetMoney),dNetMoney);
                        } else{
                          selectedTotal[sName] = commonUtils.convertFixNum(commonUtils.convertFixNum(commonUtils.isNull(child[sName], 0),dNetMoney) + commonUtils.convertFixNum(commonUtils.isNull(selectedTotal[sName], 0),dNetMoney),dNetMoney);
                        }

                      }
                    });
                  }
                });
                if (commonUtils.isNotEmptyObject(selectedTotal)) {
                  selectedTotalData.push(selectedTotal);
                }
              }
            }
          }
        } else if (commonUtils.isEmptyArr(selectedRowKeys)) {
          const menuChildData = [];
          this.props.onSaveState({ menuChildData });
        }
        this.props.onSaveState({ [`${name}Total`]: commonUtils.isNotEmptyArr(selectedRowKeys) && bMutiSelect ? selectedTotalData : totalAllData });
      }
      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,
          });
        }
      }
      this.props.onTableSelectRowChange(name, selectedRowKeys);
    }


    // OEE自定义按钮调用存储过程
    handleOEEProcedureCall = async (btnConfig, proName, proInParam) => {
      const { app, sModelsId } = this.props;
      const value = {
        sProName: proName,
        paramsMap: {
          sMachineId: app.sMachineNameSId,
          sProInParam: proInParam,
        },
      };
      const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
      const returnData = (await commonServices.postValueService(app.token, value, url)).data;
      if (returnData.code === 1) {
        message.success(returnData.msg);
        this.handleButtonClick('BtnRefresh');
        this.props.onSaveState({ oeeBtnStatus: true }); /* oeeBtnStatus 按钮点击时置灰 执行数据完成后按钮回置 */
      } else {
        this.props.onSaveState({ loading: false, oeeBtnStatus: true });
        this.props.getServiceError(returnData);
      }
    }
    // 根据配置解析拼接具体参数
    handleProParams = (sKey, arr) => {
      const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props;
      const keyData = commonUtils.isNotEmptyArr(tableData) ? tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId)) : [];
      if (commonUtils.isNotEmptyArr(keyData)) {
        const addState = {};
        addState.key = sKey;
        const val = [];
        keyData.forEach((currData) => {
          const currVal = {};
          arr.forEach((filed) => {
            currVal[`${filed}`] = currData[`${filed}`];
          });
          val.push(currVal);
        });
        addState.value = val;
        return addState;
      } else {
        return undefined;
      }
    };
    // 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析，配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"}
    handleOeeBtnEent = (btnConfig) => {
      const { masterData } = this.props;
      const { sButtonParam } = btnConfig;
      const btn = JSON.parse(sButtonParam);
      const sProName = btn.sproName;
      const inParams = [];
      const { inMap } = btn;
      const inlist = inMap.split(',');
      const masterArr = [];
      const slaveArr = [];

      if (inlist.length > 0) {
        inlist.forEach((item) => {
          const itemArr = item.split('.');
          if (itemArr.length > 0) {
            const sname = itemArr[0];
            const stype = itemArr[1];
            if (commonUtils.isNotEmptyStr(sname) && sname === 'master') {
              masterArr.push(stype);
            }
            if (commonUtils.isNotEmptyStr(sname) && sname === 'slave') {
              slaveArr.push(stype);
            }
          }
        });

        if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
          const addState = {};
          addState.key = 'master';
          const val = [];
          const currVal = {};
          masterArr.forEach((filed) => {
            currVal[`${filed}`] = masterData[`${filed}`];
          });
          val.push(currVal);
          addState.value = val;
          inParams.push({ ...addState });
        }
        if (commonUtils.isNotEmptyArr(slaveArr)) {
          const addState = this.handleProParams('slave', slaveArr);
          if (commonUtils.isNotEmptyObject(addState)) {
            inParams.push({ ...addState });
          }
        }
      }
      /* OEE模块调用OEE自定义按钮存储过程 */
      if (location.pathname.toLowerCase().indexOf('oee') > -1) {
        this.handleOEEProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParams }));
      }
    };


    // 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析，配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"}
    // handleBtnEent = (btnConfig, name, sValue) => {
    //   const { masterData, sCurrMemoProps } = this.props;
    //   if (commonUtils.isNotEmptyObject(sCurrMemoProps) && name.indexOf('BtnRepair') > -1) {
    //     sCurrMemoProps.bVisibleMemo = false;
    //     this.props.onSaveState({ sCurrMemoProps });
    //   }
    //   const sButtonParam = btnConfig.sButtonParam;
    //   const btn = JSON.parse(sButtonParam);
    //   const sProName = btn.sproName;
    //   const inParams = [];
    //   const inMap = btn.inMap;
    //   const inlist = inMap.split(',');
    //
    //   const masterArr = [];
    //   const slaveArr = [];
    //   const slaveInfoArr = [];
    //   const controlArr = [];
    //   const materialsArr = [];
    //   const processArr = [];
    //
    //   if (inlist.length > 0) {
    //     inlist.forEach((item) => {
    //       const itemArr = item.split('.');
    //       if (itemArr.length > 0) {
    //         const sname = itemArr[0];
    //         const stype = itemArr[1];
    //         if (commonUtils.isNotEmptyStr(sname) && sname === 'master') {
    //           masterArr.push(stype);
    //         }
    //         if (commonUtils.isNotEmptyStr(sname) && sname === 'slave') {
    //           slaveArr.push(stype);
    //         }
    //         if (commonUtils.isNotEmptyStr(sname) && sname === 'slaveInfo') {
    //           slaveInfoArr.push(stype);
    //         }
    //         if (commonUtils.isNotEmptyStr(sname) && sname === 'control') {
    //           controlArr.push(stype);
    //         }
    //         if (commonUtils.isNotEmptyStr(sname) && sname === 'materials') {
    //           materialsArr.push(stype);
    //         }
    //         if (commonUtils.isNotEmptyStr(sname) && sname === 'process') {
    //           processArr.push(stype);
    //         }
    //       }
    //     });
    //
    //     if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
    //       const addState = {};
    //       addState.key = 'master';
    //       const val = [];
    //       const currVal = {};
    //       masterArr.forEach((filed) => {
    //         currVal[`${filed}`] = masterData[`${filed}`];
    //       });
    //       val.push(currVal);
    //       addState.value = val;
    //       inParams.push({ ...addState });
    //     }
    //     if (commonUtils.isNotEmptyArr(slaveArr)) {
    //       const addState = this.handleProParams('slave', slaveArr);
    //       if (commonUtils.isNotEmptyObject(addState)) {
    //         inParams.push({ ...addState });
    //       }
    //     }
    //     if (commonUtils.isNotEmptyArr(slaveInfoArr)) {
    //       const addState = this.handleProParams('slaveInfo', slaveInfoArr);
    //       if (commonUtils.isNotEmptyObject(addState)) {
    //         inParams.push({ ...addState });
    //       }
    //     }
    //     if (commonUtils.isNotEmptyArr(controlArr)) {
    //       const addState = this.handleProParams('control', controlArr);
    //       if (commonUtils.isNotEmptyObject(addState)) {
    //         inParams.push({ ...addState });
    //       }
    //     }
    //     if (commonUtils.isNotEmptyArr(materialsArr)) {
    //       const addState = this.handleProParams('materials', materialsArr);
    //       if (commonUtils.isNotEmptyObject(addState)) {
    //         inParams.push({ ...addState });
    //       }
    //     }
    //     if (commonUtils.isNotEmptyArr(processArr)) {
    //       const addState = this.handleProParams('process', processArr);
    //       if (commonUtils.isNotEmptyObject(addState)) {
    //         inParams.push({ ...addState });
    //       }
    //     }
    //   }
    //
    //   this.handleProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParams, changeValue: sValue }));
    // };
    // 根据配置解析拼接具体参数
    // handleProParams = (sKey, arr) => {
    //   const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props;
    //   const keyData = tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId));
    //   if (commonUtils.isNotEmptyArr(keyData)) {
    //     const addState = {};
    //     addState.key = sKey;
    //     const val = [];
    //     keyData.forEach((currData) => {
    //       const currVal = {};
    //       arr.forEach((filed) => {
    //         currVal[`${filed}`] = currData[`${filed}`];
    //       });
    //       val.push(currVal);
    //     });
    //     addState.value = val;
    //     return addState;
    //   } else {
    //     return undefined;
    //   }
    // };
    // 存储过程按钮调用存储过程
    // handleProcedureCall = async (btnConfig, proName, proInParam) => {
    //   const { app, sModelsId } = this.props;
    //   const value = { sProName: proName, sProInParam: proInParam };
    //   const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
    //   const returnData = (await commonServices.postValueService(app.token, value, url)).data;
    //   if (returnData.code === 1) {
    //     message.success(returnData.msg);
    //     this.handleButtonClick('BtnRefresh');
    //   } else {
    //     this.props.onSaveState({ loading: false });
    //     this.props.getServiceError(returnData);
    //   }
    // }
    /* 点击展开图标时，调用接口获取嵌套字表数据 */
    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 });
    }
    handleTableAdd = (name, isWait) => {
      const { formRoute } = this.props;
      if (commonUtils.isNotEmptyObject(formRoute) && formRoute.indexOf('/indexOee') > -1 && name === 'employee') { // oee开工页面人员表点击增加弹窗人员选择框
        this.props.onSaveState({ employeeVisble: true });
      } else if (isWait) { /*  报表设计新增 */
        const tableDataRow = this.props.onDataRowAdd(name, isWait);
        return tableDataRow;
      }
    }

    /* 操作日志点击链接弹出Modal呈现日志明细 */
    handleGetLogDetail=(record) => {
      const { sModelsType } = this.props;
      let { logColumn } = this.props;
      /* 操作日志明细弹窗功能 */
      if (sModelsType === 'commonList/logdetail') {
        const { sDetailMemo } = record;
        let JsonData = [];
        const logData = [];
        const logConfig = {};
        if (commonUtils.isNotEmptyObject(sDetailMemo)) {
          const addState = {};
          addState.logVisible = true;
          if (commonUtils.isEmptyArr(logColumn)) {
            logConfig.sId = commonUtils.createSid();
            logConfig.gdsconfigformslave = [{
              bVisible: false,
              sName: 'sId',
              bNotEmpty: true,
              showName: '表sId',
              bFind: false,
            }, {
              bVisible: false,
              sName: 'sSlaveId',
              bNotEmpty: true,
              showName: '表主键',
              bFind: false,
            }, {
              bVisible: true,
              sName: 'sTableName',
              bNotEmpty: true,
              showName: '表名称',
              bFind: false,
            }, {
              bVisible: true,
              sName: 'sTableType',
              bReadOnly: true,
              showName: '表类型',
              iTag: 1,
              bFind: false,
            }, {
              bVisible: true,
              sName: 'handleType',
              bReadOnly: true,
              showName: '状态',
              iTag: 1,
              bFind: false,
            }, {
              bVisible: true,
              sName: 'sFieldName',
              bReadOnly: true,
              showName: '字段名',
              iTag: 1,
              bFind: false,
            }, {
              bVisible: true,
              sName: 'sFieldValue',
              bReadOnly: true,
              showName: '字段值',
              iTag: 1,
              bFind: false,
            }];
            logColumn = [{
              title: '表名称',
              dataIndex: 'sTableName',
              width: 200,
              bFind: true,
            }, {
              title: '表类型',
              dataIndex: 'sTableType',
              width: 100,
              bFind: true,
            }, {
              title: '状态',
              dataIndex: 'handleType',
              width: 100,
              bFind: true,
            }, {
              title: '字段名',
              dataIndex: 'sFieldName',
              width: 200,
              bFind: true,
            }, {
              title: '字段值',
              dataIndex: 'sFieldValue',
              width: 200,
              bFind: true,
            }];
            addState.logColumn = logColumn;
            addState.logConfig = logConfig;
          }
          try {
            JsonData = JSON.parse(sDetailMemo);
            /* 弹窗字段取值 */
            JsonData.forEach((item) => {
              const columnArr = item.column;
              if (commonUtils.isNotEmptyArr(columnArr)) {
                columnArr.forEach((column) => {
                  // eslint-disable-next-line guard-for-in
                  for (const property in column) {
                    const logObj = {};
                    logObj.sTableName = item.sTable;
                    logObj.sTableType = item.name;
                    logObj.sFieldName = property;
                    logObj.sFieldValue = column[property];
                    const newId = commonUtils.createSid();
                    logObj.sId = newId;
                    logObj.sSlaveId = newId;
                    const handleType = column.handleType;
                    switch (handleType) {
                      case 'add':
                        logObj.handleType = '新增';
                        break;
                      case 'update':
                        logObj.handleType = '修改';
                        break;
                      case 'del':
                        logObj.handleType = '删除';
                        break;
                      default:
                        break;
                    }
                    logData.push(logObj);
                  }
                });
              }
            });
            addState.logData = logData;
          } catch (e) {
            JsonData = [];
          }
          this.props.onSaveState({
            ...addState,
          });
        }
      }
    }

    handleViewClick = (name, sName, record, index, myConfig) => {
      /* 操作日志明细链接弹出Modal */
      if (sName === 'sDetailMemoview') {
        this.handleGetLogDetail(record);
      } else {
        if (sName === 'myTableConfig') {
          this.handleQuickViewClick(name, sName, record, index, myConfig);
        } else {
          this.props.onViewClick(name, sName, record, index, myConfig);
        }
      }
    }

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

      let picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === sName));
      if (commonUtils.isNotEmptyArr(myConfigArr)) {
        picArr = myConfigArr;
      }

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

        this.props.dispatch({
          type: 'content/onRouter',
          payload: {
            url: sNameUrl,
            refresh: getConfig.bind(this, name, sModelsId), /*   刷新方法   */
            sTabId: commonUtils.createSid(),
            sParentId: this.state.sTabId,
            urlDataType: 'newPane',
            checkedId: myConfigArr[0].sId,
            sName: myConfigArr[0].sName,
            bFilter: slaveFilterCondition,
            pageSize: commonConfig.pageSize,
            pages: slavePagination,
            currentData: slaveData,
            conditonValues: conditionValues,
            newKey: tableDataRow[sActiveKey],
            currentIndex: iIndex,
            filterCondition,
            sSrcModelsId: this.props.sModelsId,
          },
        });
      }
    };

    handleGetTableConfig = async (name, sModelsId) => {
      if (commonUtils.isNotEmptyObject(sModelsId)) {
        const newConfig = await this.props.onGetTableConfig(name, sModelsId);
        if (commonUtils.isNotEmptyObject(newConfig)) {
          let slaveColumn = commonFunc.getHeaderConfig(newConfig);
          this.props.onSaveState({[`${[name]}Config`]: newConfig, slaveColumn })
        }
      }
    }

    handlePartNameClick =(sName, showConfig, record) => {
      if (commonUtils.isNotEmptyObject(sName) && commonUtils.isNotEmptyObject(showConfig) && commonUtils.isNotEmptyObject(record)) {
        this.props.onSaveState({ workScheduleConfig: showConfig, workScheduleRecord: record, workScheduleVisible: true });
      }
    }
    handleCloseModel = (modelVisible) => {
      this.props.onSaveState({ [modelVisible]: false });
    };

    /* 获取树形slaveTreeData数据 */
    handleGetSlaveTreeData = (slaveData) => {
      const slaveTreeData = []; /* 用于界面树形展示的slaveData */
      const expKeys = [];
      const addState = {};
      if (commonUtils.isNotEmptyArr(slaveData)) {
        slaveData.forEach((tableDataRow) => {
          const tableDataRowNew = JSON.parse(JSON.stringify(tableDataRow));
          if (commonUtils.isEmpty(tableDataRow.sParentId)) { /* 一级分类 */
            const childrenData = this.handleGetChildData(slaveData, tableDataRowNew.sId); /* 获取子数据 */
            if (commonUtils.isNotEmptyArr(childrenData)) {
              expKeys.push(tableDataRow.sSlaveId);
              tableDataRowNew.children = childrenData;
            }
            slaveTreeData.push(tableDataRowNew);
          } else { /* 搜索后的数据集 若没有完整的树形结构 没有父级时 挂载当层 */
            const sParentId = tableDataRow.sParentId;
            /* 层级里去查sParentId的层级 */
            const slaveFilterData = slaveData.filter(item => item.sId === sParentId); /* 查找该节点的父级 */
            if (slaveFilterData.length === 0) { /* 没有父级 代表搜索后零散数据 */
              const childrenData = this.handleGetChildData(slaveData, tableDataRowNew.sId); /* 获取子数据 */
              if (commonUtils.isNotEmptyArr(childrenData)) {
                expKeys.push(tableDataRow.sSlaveId);
                tableDataRowNew.children = childrenData;
              }
              slaveTreeData.push(tableDataRowNew);
            }
          }
        });
      }
      addState.slaveTreeData = slaveTreeData;
      addState.expKeys = expKeys;
      return addState;
    }
    /* 获取子节点数据 */
    handleGetChildData = (data, sId) => {
      if (commonUtils.isNotEmptyArr(data)) {
        const filterData = data.filter(item => item.sParentId === sId);
        if (commonUtils.isNotEmptyArr(filterData)) {
          filterData.forEach((child, index) => {
            const filterChildData = this.handleGetChildData(data, child.sId);
            if (commonUtils.isNotEmptyArr(filterChildData)) {
              filterData[index].children = filterChildData;
            }
          });
        }
        return filterData;
      }
    }

    /* 选择上报参数点击确定 */
    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,
        });
      }
    }

    handleViewChoose= (name, sName, record) => {
      const { sId } = record; /* 控制表主键 */
      const { enabled } = this.props;
      let jsonData = [];
     if (sName === 'sParams') { // 产量上报 工艺参数
        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('无工艺参数！');
          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);
          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 };
                }
              }
            }
          }
        }
        this.props.onSaveState({
          slaveRecord: record,
          sProcessParamsSelects,
          sParamsModalVisible: true,
          sParamConfig,
          sParamColumn,
          sParamData,
          sParamModalType: 'sReport',
          enabled,
        });
      }
    }


    /* 动态参数标题选择框 全选/取消全选 */
    handleCheckParamChange = () => {
      const {
        sParamData,
        sParamColumn,
      } = 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 };
          });
        }
        this.props.onSaveState({
          sParamData,
          sParamColumn,
        });
      }
    }


    render() {
      return (
        <ChildComponent
          {...this.props}
          {...this.state}
          onReturnForm={this.handleForm}
          onGetData={this.handleGetData}
          onGetDataInfo={this.handleGetDataInfo}
          onTableSelectRowChange={this.handleTableSelectRowChange}
          onGetFilterTreeData={this.handleGetFilterTreeData}
          onTitleChange={this.handleTitleChange}
          onDoubleClick={this.handleDoubleClick}
          onAdd={this.handleAdd}
          onDel={this.handleDel}
          onButtonClick={this.handleButtonClick}
          onCopyTo={this.handleCopyTo}
          // onGetMemo={this.handleGetMemo}
          // onGetMemoCancel={this.handleGetMemoCancel}
          onGetGoods={this.handleGetGoods}
          onGetGoodsValue={this.handleGetGoodsValue}
          onGetGoodsCancle={this.handleGetGoodsCancle}
          onBtnPrint={this.handleBtnPrint}
          onCheck={this.handleTreeCheck}
          onSelect={this.handleTreeSelect}
          onExpand={this.handleOnExpand}
          onOeeCopyTo={this.handleOeeCopyTo}
          onOeeLabelCopyTo={this.handleOeeLabelCopyTo}
          onOeeBillCopyTo={this.handleBillCopyTo}
          onDataRowAdd={this.handleTableAdd}
          onViewClick={this.handleViewClick}
          onDataChange={this.props.onDataChange}
          onPartNameClick={this.handlePartNameClick}
          onCloseModel={this.handleCloseModel}
          // onBtnEent={this.handleBtnEent}
          onOeeBtnEent={this.handleOeeBtnEent} // onBtnEent={this.handleBtnEent}
          onGetSlaveTreeData={this.handleGetSlaveTreeData}
          onReportParamsOk={this.handleReportParamsOk}
          onViewChoose={this.handleViewChoose}
          onCheckParamChange={this.handleCheckParamChange}
        />
      );
    }
  };
};
