/* eslint-disable */
/* eslint-disable prefer-destructuring */
/**
 * Created by mar105 on 2019-02-15.
 */

import React, { Component, useEffect } from 'react';
import { message } from '@/utils/common/message';
import moment from 'moment';
import lodash from 'lodash';
import commonConfig from '../../utils/config';
import * as commonUtils from '../../utils/utils';
import * as commonServices from '../../services/services';
import * as commonFunc from './commonFunc';
import * as commonKeyUp from './commonKeyUp';
import * as commonBusiness from './commonBusiness'; /* 通用单据方法 */
import instructSet from "@/components/Common/CommonInstructSet";

export default (ChildComponent) => {
  return class extends Component {
    constructor(props) {
      super(props);
      this.state = {
        pageLoading: true,
        token: props.routing ? (props.formRoute === '/indexOee' || props.formRoute === '/indexMobile') ? props.app.token : '' : props.app.token, // /indexOee为oee报产页面
        sTabId: this.handleConfigValue('key', props.formRoute), // type无论是indexoee和一般的都使用eles
        sSrcModelsId: props.app.currentPane.sSrcModelsId, /* 获取配置数据用的modelId */
        sModelsId: props.routing ? props.sModelsId : (commonUtils.isNotEmptyStr(props.formRoute) && (props.formRoute.indexOf('/indexOee') > -1 || props.formRoute.indexOf('/indexMobile') > -1)) ? props.sModelsId : this.handleConfigValue('formId'), /* 获取配置数据用的modelId */
        formRoute: props.routing ? props.formRoute : (commonUtils.isNotEmptyStr(props.formRoute) && (props.formRoute.indexOf('/indexOee') > -1 || props.formRoute.indexOf('/indexMobile') > -1)) ? props.formRoute : this.handleConfigValue('route'), /* 组件名： 路由名称 */
        formSrcRoute: props.routing ? props.routing.pathname.replace('/', '') : commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase() === '/loginoee' ? '/commonAuto' : '',
        sModelsType: this.handleConfigValue('sModelsType', props.formRoute), /* 组件名： 路由名称 */
        bFastOrderView: this.handleConfigValue('bFastOrderView'), /* 是否显示快速下单 */
        formData: [], /* 所有配置 */
        gdsformconst: [], /* 获取配置常量 */
        gdsjurisdiction: [], /* 获取配置权限 */
        currentId: (commonUtils.isNotEmptyStr(props.formRoute) && (props.formRoute.indexOf('/indexOee') > -1 || props.formRoute.indexOf('/indexMobile') > -1)) ? props.checkedId : props.app.currentPane.checkedId, /* 当前数据的Id  */
        selectedRowKeys: [], /*   已选择的数据行(数据格式:数组)   */
        clearArray: [], /*   table清除数组   */
        calculated: false, // 工单是否经过计算
        iPageSize: commonConfig.pageSize, /* 默认config配置的pageSize */
        showTableName: false, // 展示控件名称
        noChangeDiffMap: props.noChangeDiffMap
      };
      this.sDateFormat = 'YYYY-MM-DD';
      window.addEventListener('beforeunload', this.beforeunload);
      window.addEventListener('unload', this.unload);
      window.addEventListener('keydown', this.handleF9KeyPress);
    }

    async componentWillMount() {
      if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase() !== '/loginoee') {
        if (this.props.app.webSocket === null || this.props.app.webSocket.readyState !== WebSocket.OPEN) {
          this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch: this.props.dispatch } });
        }
      }
      /* 获取配置 */
      this.mounted = true;
      const { token, sModelsId, formSrcRoute } = this.state;
      let { iPageSize } = this.state;
      const config = await commonUtils.getStoreDropDownData(sModelsId, '', '');
      if (commonUtils.isEmpty(config)) {
        const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
        const configReturn = (await commonServices.getService(token, configUrl)).data;
        if (configReturn.code === 1) {
          const [configData] = configReturn.dataset.rows;
          const { formData } = configData;
          if (commonUtils.isNotEmptyArr(formData)) {
            if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) {
              iPageSize = formData[0].iPageSize;/* 后台设定页数 */
            }
          }
          if (this.mounted) {
            commonUtils.setStoreDropDownData(sModelsId, '', '', configData);
            this.handleSaveState({ ...configData, iPageSize });
          }
        } else {
          this.getServiceError(configReturn);
        }
      } else {
        this.handleSaveState({ ...config });
      }
    }

    componentDidMount() {
      if (this.state.sTabId && !this.state.noChangeDiffMap) {
        this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: this.state.sTabId, changed: false } });
      }
      if (this.state.formRoute && (this.state.formRoute.indexOf('/indexOee') > -1 || this.state.formRoute.indexOf('/indexMobile') > -1) && this.state.sModelsId && this.state.formRoute) {
        const sModelData = {
          sModelsId: this.state.sModelsId,
          formRoute: this.state.formRoute,
        };
        localStorage.setItem('oeeModelData', JSON.stringify(sModelData));
      }

      try {
        const { key } = this.props.app.currentPane;
        window[`getPropsByPanelKey${key}`] = () => ({ ...this.props, ...this.state });
      } catch (e) {}

      /* 关闭浏览器前进行提示 */
    }

    shouldComponentUpdate(nextProps, nextState) {
      // // 修改或新增后的保存功能
      // if (nextState.enabled && !nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) {
      //   this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: true } });
      // }
      // if (!nextState.enabled && nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) {
      //   this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: false } });
      // }
      const currentKey = nextProps.app.currentPane.key; /* 当前页签key */
      const { formData } = nextState;
      if (commonUtils.isNotEmptyObject(nextProps.formRoute) && (nextProps.formRoute.indexOf('/indexOee') > -1 || nextProps.formRoute.indexOf('/indexMobile') > -1)) {
        return (formData.length > 0);
      }
      /* 处理loginOee下拉框切换 重新渲染 */
      if (commonUtils.isNotEmptyObject(location.pathname) && location.pathname.toLowerCase() === '/loginoee') {
        return true;
      }
      if (nextProps.app.unReadSid !== this.props.app.unReadSid) {
        return false;
      }
      return (currentKey === nextState.sTabId && formData.length > 0)
        || (nextState.fastOrderModalVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.fastOrderModalVisible)
        || (nextState.visibleStatement !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleStatement)
        || (nextState.visibleBatchPriceUpdate !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleBatchPriceUpdate)
        || (nextState.modalVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.modalVisible)
        || (nextState.visibleModal !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleModal)
        || (nextState.materialsChooseVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.materialsChooseVisible)
        || (nextState.processChooseVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.processChooseVisible)
        || (nextState.visibleFilfile !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.visibleFilfile)
        || (nextState.contextMenuModalVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.contextMenuModalVisible)
        || (nextState.bTabModal !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.bTabModal)
    || (nextState.workScheduleVisible !== undefined && nextProps.app.currentPane.notCurrentPane === !nextState.workScheduleVisible);
    }

    componentDidUpdate(nextProps, nextState) {
      // 修改或新增后的保存功能
      if (nextProps.onRemovePane && nextState.enabled && !nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) {
        this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: true } });
      }
      if (nextProps.onRemovePane && !nextState.enabled && nextProps.app.diffMap.get(nextState.sTabId) && nextProps.app.diffMap.get(nextState.sTabId) !== undefined) {
        this.props.dispatch({ type: 'app/changeDiffMap', payload: { sTabId: nextState.sTabId, changed: false } });
      }

      // 页面加载完成后执行一次指令集
      this.initInstruct();
      // 修改tab显示状态
      this.handleChangeTabStatus();
    }

    componentWillUnmount() {
      const {
        currentId,
      } = this.state;
      const { userinfo } = this.props.app;
      window.removeEventListener('beforeunload', this.beforeunload);
      window.removeEventListener('unload', this.unload);
      window.removeEventListener('keydown', this.handleF9KeyPress);
      try {
        const { key } = this.props.app.currentPane;
        delete window[`getPropsByPanelKey${key}`];
      } catch (e) {}
    }

    // 页面加载完成后执行一次指令集
    initInstruct = () => {
      if (!this.bInit) {
        clearTimeout(this.initTimer);
        this.initTimer = setTimeout(() => {
          this.bInit = true;
          const { masterConfig = {} } = this.state;
          const { sOnShowInstruct } = masterConfig;
          if (sOnShowInstruct) {
            instructSet({
              ...this.props,
              ...this.state,
              btnConfig: { sInstruct: sOnShowInstruct, showName: "页面初始化" },
              onSaveState: this.handleSaveState
            })
          }
        }, 500);
      }
    }

    // 修改tab显示状态
    handleChangeTabStatus = () => {
      clearTimeout(this.tabTimer);
        this.tabTimer = setTimeout(() => {
          this.handleChangeTabStatusFunc();
        }, 300);
    }

    // 修改tab显示状态方法
    handleChangeTabStatusFunc = () => {
      if (!this.baseRef) return;

      const { masterConfig = {} } = this.state;
      const { sInstruct: sInstructStr } = masterConfig;
      if (!sInstructStr) {
        this.baseRef.classList.remove('xlyCommonBase');
        return;
      };

      const sInstruct = commonUtils.convertStrToObj(sInstructStr, {});
      const { tabs = [] } = sInstruct;
      if (!tabs.length) {
        this.baseRef.classList.remove('xlyCommonBase');
        return;
      };

      // 根据配置获取要隐藏的tab
      const hideTabNameList = [];

      tabs.forEach(item => {
        const { name, show } = item;
        if (show === undefined) return;

        let result = false;
        if (typeof show === "boolean") {
          result = show;
        } else {
          result = commonFunc.getEvalResult({
            props: {...this.props, ...this.state},
            str: show,
            defaultValue: true
          })
        }
        if (result === false) {
          hideTabNameList.push(name);
        }
      });

      // 遍历所有tab页签，隐藏掉在hideTabNameList中的tab页签
      const oTabBtns = this.baseRef.querySelectorAll('.ant-tabs-tab-btn');
      oTabBtns.forEach(oDom => {
        const tabName = oDom.innerHTML;
        const oTab = oDom.parentNode;
        const bHide = hideTabNameList.includes(tabName);
        if (bHide) {
          oTab.style.display = 'none';
        } else {
          oTab.style.display = '';
        }
      });

      // 遍历所有tabsList页签，如果下面的tab没有一个处于激活且显示状态的，默认点击第一个tab
      const oNavList = this.baseRef.querySelectorAll('.ant-tabs-nav-list');
      oNavList.forEach(oList => {
        const { childNodes } = oList;
        const bHasActive = Array.from(childNodes).some(oTab =>
          oTab.classList.contains("ant-tabs-tab-active") &&
          oTab.style.display !== "none"
        );
        if (!bHasActive) {
          const oTemp = Array.from(childNodes).find(oTab =>
            oTab.style.display !== "none"
          );
          if (oTemp) {
            oTemp.click();
          }
        }
      });

      this.baseRef.classList.remove('xlyCommonBase');
    }

    handleSearchNodes= (key, data, showNameNew) => {
      let tableRow = {};
      if (commonUtils.isNotEmptyObject(key)) {
        for (let i = 0, len = data.length; i < len; i ++) {
          const item = data[i];
          if (data[i].key === key) {
            tableRow = item;
            return tableRow;
          } else if (commonUtils.isNotEmptyArr(item.children)) {
            const res = this.handleSearchNodes(key, item.children, showNameNew);
            if(commonUtils.isNotEmptyObject(res)) {
              return res;
            }
          }
        }
      }
      return tableRow;

    };

    /*
    componentWillUnmount() {
      this.mounted = false;
      const { sModelsId } = this.state;
      const { app, currentId } = this.props;
      const { webSocket, userinfo, currentPane } = app;
      const { key } = currentPane;
      commonUtils.clearFormStoreDropDownData(sModelsId);
      const { copyTo } = app.currentPane;
      if (commonUtils.isNotEmptyObject(copyTo)) {
        const { slaveData } = copyTo;
        const sIdArray = [];
        slaveData.forEach((item) => {
          const redisKey = item.sSlaveId;
          sIdArray.push(redisKey);
        });
        const sId = sIdArray.toString();
        commonFunc.sendWebSocketMessage(webSocket, key, 'copyfinish', 'noAction', userinfo.sId, null, sId, userinfo.sId, null);
      }
      if (!commonUtils.isEmpty(currentId)) {
        commonFunc.sendWebSocketMessage(webSocket, key, 'release', 'noAction', userinfo.sId, null, currentId, userinfo.sId, null);
      }
    } */

    /**   sql条件   */
    getSqlCondition = (showConfig, name, record) => {
      const conditonValues = {};
      if (commonUtils.isNotEmptyStr(showConfig.sSqlCondition)) {
        // 电化铝bom单独处理，不作标版使用。
        if (showConfig.sName === 'sAlumiteBomBillNo' || showConfig.sControlName === 'BtnPopupsAlumiteBomBillNo') {
          const { materialsData, processData: processDataOld, processSelectedRowKeys: processSelectedRowKeysOld  } = this.state;
          const { slave0Data, slave0SelectedRowKeys } = this.state;
          const processData = commonUtils.isEmptyArr(processDataOld)  && commonUtils.isEmptyArr(processSelectedRowKeysOld) ? slave0Data : processDataOld;
          const processSelectedRowKeys = commonUtils.isEmptyArr(processDataOld)  && commonUtils.isEmptyArr(processSelectedRowKeysOld) ? slave0SelectedRowKeys : processSelectedRowKeysOld;
          if (commonUtils.isNotEmptyArr(materialsData)  && commonUtils.isNotEmptyArr(processSelectedRowKeys)) {
            const iMaterialsIndex = materialsData.findIndex(item => item.sProcessTbId === processSelectedRowKeys[0]);
            if (iMaterialsIndex > -1) {
              conditonValues.iNumberOfTime = materialsData[iMaterialsIndex].iNumberOfTime;
              conditonValues.sVersionNum = materialsData[iMaterialsIndex].sVersionNum;
            } else {
              conditonValues.iNumberOfTime = 0;
              conditonValues.sVersionNum = '';
            }
          }
        }
        const conditon = showConfig.sSqlCondition.split(',');
        conditon.forEach((item) => {
          if (item.indexOf('.') > -1) {
            const tableName = item.split('.')[0];
            let fieldName = item.split('.')[1];
            let fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
            const warnArr = fieldName.split('|');
            let warnStr = '';
            if(commonUtils.isNotEmptyArr(warnArr)) {
              fieldName = warnArr[0];
              warnStr = warnArr[1];
            }
            // master.sId 作为参数   master.sId.sId 作为filterDropdown过滤参数
            if (showConfig.sDropDownType === 'picArr' || showConfig.sDropDownType === 'picArrModal' ) {
              fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
              if (fieldName.indexOf('&Search') > -1) {
                // 参数为&Search时认为是查找数据集中取数据
                const data = this.state[`${tableName}Data`];
                if (typeof data === 'object' && data.constructor === Object) {
                  Object.keys(data).forEach((dataItem) => {
                    if (`&Search${data[dataItem]}` === fieldName) {
                      let sTmpName = dataItem;
                      sTmpName = sTmpName.replace('First', 'Third');
                      if (data[dataItem].substring(0, 1) === 't') {
                        fieldName = `p${sTmpName.substring(1, dataItem.length)}`;
                      } else if (data[dataItem].substring(0, 1) === 'm') {
                        fieldName = data[dataItem].substring(0, 1) + sTmpName.substring(1, sTmpName.length);
                      } else {
                        fieldName = data[dataItem].substring(0, 1) + sTmpName.substring(1, sTmpName.length);
                      }
                    }
                  });
                }
              } else if (fieldName.indexOf('&') > -1) {
                fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
                conditonValues[fieldNameFilter] = fieldName.replace('&', '');
                return;
              }
            }
            if (fieldName !== '') {
              if (name === tableName && !commonUtils.isEmptyObject(record)) {
                const data = record;
                conditonValues[fieldNameFilter] = data[fieldName];
              } else {
                let data = this.state[`${tableName}Data`];
                if(commonUtils.isEmptyArr(data)) {
                  const dataRelationJson = this.state.relateRelationJson;
                  if(commonUtils.isNotEmptyObject(dataRelationJson)){
                    const relateName = dataRelationJson[tableName];
                    if(relateName) {
                      data = this.state[`${relateName}Data`];
                    }
                  }
                }

                let selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
                if(tableName === 'tree') {
                  selectedRowKeys = this.state[`${tableName}SelectedKeys`];
                }
                if (typeof data === 'object' && data.constructor === Object) {
                  conditonValues[fieldNameFilter] = data[fieldName];
                  if(commonUtils.isNotEmptyObject(warnStr)) {
                    if(commonUtils.isEmpty(data[fieldName])) {
                      conditonValues['warning'] = commonUtils.isNotEmptyObject(conditonValues['warning']) ?
                        conditonValues['warning']+ warnStr : warnStr;
                    }
                  }
                }
                else if (fieldName.indexOf('_all') > -1) {
                  let sAllConditionValue = '';
                  const fieldNameNew = fieldName.replace('_all', '');
                  if (commonUtils.isNotEmptyArr(data)) {
                    // 电化铝bom单独处理，不作标版使用。
                    let dataNew = data;
                    if (showConfig.sName === 'sAlumiteBomBillNo' || showConfig.sControlName === 'BtnPopupsAlumiteBomBillNo') {
                      const { controlData, controlSelectedRowKeys: controlSelectedRowKeysOld, slave0Child1SelectedRowKeys } = this.state;
                      const controlSelectedRowKeys = commonUtils.isEmptyArr(controlData) ? slave0Child1SelectedRowKeys : controlSelectedRowKeysOld;
                      if (commonUtils.isNotEmptyArr(controlSelectedRowKeys)) {
                        dataNew = data.filter(item => item.sControlId === controlSelectedRowKeys[0]);
                      }
                    }
                    for(const item of dataNew) {
                      if (item[fieldNameNew]) {
                        sAllConditionValue = sAllConditionValue + ',' + item[fieldNameNew];
                      }
                    }
                  }
                  conditonValues[fieldNameFilter] = sAllConditionValue;
                }else if(tableName ==='tree' && commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(data)) {
                  const selectedKey = selectedRowKeys?.toString();
                  /* 如果是树形 递归查找选中行  */
                 const tableRow =  this.handleSearchNodes(selectedKey, data);
                 if(commonUtils.isNotEmptyObject(tableRow)) {
                   conditonValues[fieldNameFilter] = tableRow[fieldName];
                 }
                }
                else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(data)) {
                  let iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
                  iIndex = iIndex > -1 ? iIndex : data.findIndex(itemData => itemData.sSlaveId === selectedRowKeys[0]);
                  if (iIndex > -1) {
                    conditonValues[fieldNameFilter] = data[iIndex][fieldName];
                  }
                } else if (commonUtils.isNotEmptyArr(data)) {
                  conditonValues[fieldNameFilter] = data[0][fieldName];
                  if(commonUtils.isEmpty(data[0][fieldName])) {
                    conditonValues['warning'] = commonUtils.isNotEmptyObject(conditonValues['warning']) ?
                      conditonValues['warning']+ warnStr : warnStr;
                  }

                }
              }
            }
          }
        });
      }
      return conditonValues;
    };

    /**   获取sql下拉数据   */
    getSqlDropDownData = async (formId, name, showConfig, record, sKeyUpFilterName, pageNum) => {
      /*   地址   */
      const { formSrcRoute } = this.state;
      if (commonUtils.isEmpty(showConfig.sFieldToContent)) {
        if (commonUtils.isEmpty(showConfig.showDropDown)) {
          return {
            dropDownData: [], totalPageCount: 0, currentPageNo: 0, conditonValues: {},
          };
        }
        const url = `${commonConfig.server_host}business/getSelectLimit/${showConfig.sId}?sModelsId=${this.state.sModelsId}&sName=${formSrcRoute}`;
        /*   参数   */
        const nameNew = (name.includes('slaveUp') || name.includes('slaveDown')) ? 'slave' : name;
        const conditonValues = this.getSqlCondition(showConfig, nameNew, record);

        const body = {
          sSqlCondition: commonUtils.isEmptyObject(conditonValues) ? '' : conditonValues, /*   查询条件   */
        };
        if (commonUtils.isEmpty(showConfig.sId)) {
          body.showDropDown = showConfig.showDropDown;
          body.sKeyUpFilter = showConfig.sKeyUpFilter;
        }
        if (!commonUtils.isEmpty(pageNum)) {
          body.sKeyUpFilterName = sKeyUpFilterName; /*   边输入边过滤,暂时没用1   */
          body.pageNum = pageNum;
          // 下拉数据改为无限
          body.pageSize = commonConfig.pageSize;
          // body.pageSize = 9999;
        }
        /*   获取数据   */
        const json = await commonServices.postValueService(this.props.app.token, body, url);
        /*   code为1代表获取数据成功   */
        if (json.data.code === 1) {
          /*   获取数据集   */
          const { rows, totalPageCount, currentPageNo, totalCount } = json.data.dataset;
          return {
            dropDownData: rows, totalPageCount, currentPageNo, conditonValues, totalCount,
          };
        } else {
          return {
            dropDownData: [], totalPageCount: 0, currentPageNo: 0, conditonValues,
          };
        }
      } else {
        const returnData = [];
        if (showConfig.sFieldToContent === '1') {
          if (name === 'master') {
            const { [`${name}Data`]: data } = this.state;
            const sName = `sParamDropDown${showConfig.sName.replace('sParamValue', '')}`;
            returnData.push(...commonUtils.objectToArr(data[sName]));
          } else {
            const { [`${name}Data`]: data, [`${name}SelectedRowKeys`]: selectedRowKeys } = this.state;
            const sName = `sParamDropDown${showConfig.sName.replace('sParamValue', '')}`;
            if (commonUtils.isNotEmptyObject(record)) {
              returnData.push(...commonUtils.objectToArr(record[sName]));
            } else if (commonUtils.isNotEmptyArr(data) && commonUtils.isNotEmptyArr(selectedRowKeys)) {
              const iIndex = data.findIndex(item => item.sId === selectedRowKeys.toString());
              if (iIndex > -1) {
                returnData.push(...commonUtils.objectToArr(data[iIndex][sName]));
              }
            }
          }
        } else {
          const unionCondition = showConfig.sFieldToContent.split('&&');
          unionCondition.forEach((unionItem) => {
            const conditon = unionItem.split(',');
            const tableNameContent = conditon[0].split('.')[0];
            let data = this.state[`${tableNameContent}Data`];
            if (commonUtils.isNotEmptyArr(data)) {
              if (showConfig.sSqlCondition !== '') {
                const sSqlCondition = showConfig.sSqlCondition;
                const sqlConditon = sSqlCondition.split(',');
                sqlConditon.forEach((item) => {
                  const tableName = item.split('.')[0];
                  const fieldName = item.split('.')[1];
                  const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
                  const dataCondition = this.state[`${tableName}Data`];
                  const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
                  if (typeof dataCondition === 'object' && dataCondition.constructor === Object) {
                    // 对象不用filter
                    // data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[fieldName], ''));
                  } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
                    let iIndex = dataCondition.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
                    iIndex = iIndex > -1 ? iIndex : dataCondition.findIndex(itemData => itemData.sSlaveId === selectedRowKeys[0]);
                    if (iIndex > -1) {
                      data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[iIndex][fieldName], ''));
                    }
                  } else if (commonUtils.isNotEmptyArr(data)) {
                    data = data.filter(item => commonUtils.isNull(item[fieldNameFilter], '') === commonUtils.isNull(dataCondition[0][fieldName], ''));
                  }
                });
              }
              if (typeof data === 'object' && data.constructor === Object) {
                const dataRow = {};
                conditon.forEach((item) => {
                  const fieldName = item.split('.')[1];
                  const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
                  if (fieldName.indexOf('-') >= 0) {
                    fieldName.split('-').forEach((itemField) => {
                      const sFieldValue = commonUtils.isEmpty(data[itemField]) ? '' : data[itemField].toString();
                      dataRow[fieldNameFilter] = commonUtils.isEmpty(dataRow[fieldNameFilter]) ? sFieldValue : `${dataRow[fieldNameFilter]}-${sFieldValue}`;
                    });
                  } else {
                    dataRow[fieldNameFilter] = commonUtils.isEmpty(data[fieldName]) ? '' : data[fieldName].toString();
                  }
                });
                returnData.push(dataRow);
              } else {
                data.forEach((itemDataRow) => {
                  const dataRow = {};
                  conditon.forEach((item) => {
                    const fieldName = item.split('.')[1];
                    const fieldNameFilter = item.split('.').length > 2 ? item.split('.')[2] : fieldName;
                    if (fieldName.indexOf('-') >= 0) {
                      fieldName.split('-').forEach((itemField) => {
                        const sFieldValue = commonUtils.isEmpty(itemDataRow[itemField]) ? '' : itemDataRow[itemField].toString();
                        dataRow[fieldNameFilter] = commonUtils.isEmpty(dataRow[fieldNameFilter]) ? sFieldValue : `${dataRow[fieldNameFilter]}-${sFieldValue}`;
                      });
                    } else {
                      dataRow[fieldNameFilter] = commonUtils.isEmpty(itemDataRow[fieldName]) ? '' : itemDataRow[fieldName].toString();
                    }
                  });
                  returnData.push(dataRow);
                });
              }
            }
          });
        }
        return { dropDownData: returnData, totalPageCount: 0, currentPageNo: 0 };
      }
    };
    /*   获取数字格式化规范   */
    getFloatNum = (sName) => {
      if (sName.toLowerCase().endsWith('price')) { /*   价格   */
        return this.props.app.decimals.dNetPrice;
      } else if (sName.toLowerCase().endsWith('money')) { /*   金额   */
        return this.props.app.decimals.dNetMoney;
      } else { /*   其它   */
        return 6;
      }
    };

    /**   获取sql下拉数据   */
    getServiceError = async (returnData) => {
      if (this.state.loading) {
        this.handleSaveState({ loading: false });
      }
      if (location.pathname.indexOf('/indexOee/') > -1) {
        this.props.dispatch({ type: 'app/throwErrorOee', payload: returnData });
      } else {
        this.props.dispatch({ type: 'app/throwError', payload: returnData });
      }
    };

    /*   获取数字格式化规范   */
    getDateFormat = () => {
      return this.props.app.dateFormat;
    };

    beforeunload = (e) => {
      const confirmationMessage = '您确定要离开么？';
      if (e) {
        e.returnValue = confirmationMessage;
      }
      return confirmationMessage;
    }

    unload = () => {
      // sessionStorage.clear();
      // const {
      //   currentId, sModelsId,
      // } = this.state;
      // const url = `${commonConfig.server_host}logout`;
      // this.handleSendSocketMessage('release', 'noAction', currentId, this.props.app.userinfo.sId, null, null);
      // this.handleSendSocketMessage('release', 'noAction', sModelsId, this.props.app.userinfo.sId, null, null);
      // this.props.dispatch({ type: 'app/loginOut', payload: { url, sId: this.props.app.userinfo.sId, loginOutType: 'loginOut' } });
    }

    handleF9KeyPress = (event) => {
      // 判断是否按下的是F9键
      if (event.key === 'F9') {
        event.preventDefault();
        this.setState({
          showTableName: !this.state.showTableName,
        });
      }
    }

    handleSendSocketMessage = (flag, showType, sId, sendTo, msgInfo, param) => {
      const { token } = this.props.app;
      const sendws = this.handleSendWebSocketMsg;
      const { dispatch } = this.props;
      if (commonUtils.isNotEmptyObject(token)) {
        if (this.props.app.webSocket !== null && this.props.app.webSocket.readyState === WebSocket.OPEN) {
          sendws(flag, showType, msgInfo, sId, sendTo, param);
        } else {
          this.props.dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } });
          setTimeout(() => {
            sendws(flag, showType, msgInfo, sId, sendTo, param);
          }, 30000);
        }
      }
    };
    handleSendWebSocketMsg = (flag, showType, msgInfo, sId, sendTo, param) => {
      const { app } = this.props;
      const { webSocket, userinfo, currentPane } = app;
      const { key } = currentPane;
      commonFunc.sendWebSocketMessage(webSocket, key, flag, showType, userinfo.sId, msgInfo, sId, sendTo, param);
    }
    /**   sql下拉新增处理   */
    handleSqlDropDownNewRecord = async (showConfig, name) => {
      const {
        [`${name}SelectedRowKeys`]: tableSelectedRowKeys, [`${name}Data`]: tableNewData, masterData, formSrcRoute,  [`${name}Config`]: tableConfig, slaveData,
      } = this.state;
      /*   待用数据声明   */
      const sTabId = this.props.app.currentPane.key; /*   当前标签页TabId   */
      /*   接口地址   */
      const sNameUrl = `${commonConfig.server_host}gdsmodule/getGdsmoduleById/${showConfig.sActiveId}?sModelsId=${showConfig.sActiveId}&sName=${formSrcRoute}`;
      const CallBackRecord = this.handleCallBackRecord;/* 字段名，主从表，字段名 */
      /*  newRecord时，如果是新增产品，则要带客户过去 */
      let addStata = {};
      for (const each of this.props.app.panes) {
        each.notCurrentPane = true;
      }
      const iIndex = name !== 'master' ? tableNewData.findIndex(item => item.sId === tableSelectedRowKeys.toString()) : -1;
      if (commonUtils.isNotEmptyObject(showConfig) && showConfig.sName === 'sProductName') {
        if (name !== 'master' && commonUtils.isNotEmptyObject(tableSelectedRowKeys)) {
          const newData = tableNewData[iIndex];
          addStata.sCustomerId = newData.sCustomerId;
          addStata.sCustomerNo = newData.sCustomerNo;
          addStata.sCustomerName = newData.sCustomerName;
          if (commonUtils.isEmptyObject(addStata.sCustomerId)) { /* 新增产品时，看客户在从表还是主表。如果不在从表，那看是否在主表 */
            addStata.sCustomerId = masterData.sCustomerId;
            addStata.sCustomerNo = masterData.sCustomerNo;
            addStata.sCustomerName = masterData.sCustomerName;
          }
        }
      }
      /* newRecord 根据配置赋值 带数据 */
      const sCopyToConfigField = commonUtils.isNotEmptyObject(showConfig) &&  showConfig.sControlName &&  showConfig.sControlName.includes('BtnNewRecord') ?  showConfig.sControlName : {};
      let sCopyToConfigMaster = {};
      if(commonUtils.isNotEmptyArr(sCopyToConfigField) && commonUtils.isNotEmptyArr(tableConfig)) {
        sCopyToConfigMaster = tableConfig.gdsconfigformslave.filter(item => item.sControlName === sCopyToConfigField);
        if(commonUtils.isNotEmptyArr(sCopyToConfigMaster)) {
          const sCopyToConfigMasterAssignField= sCopyToConfigMaster[0].sAssignField;
          const newCopyTo = {};
          if(iIndex > -1) {
            const newData = tableNewData[iIndex];
            newCopyTo.master = masterData;
            newCopyTo.slave = commonUtils.isEmptyArr(slaveData) ? {} : slaveData[0];
            newCopyTo.process = newData;
            addStata = { ...addStata, ...commonFunc.getAssignFieldValue(sCopyToConfigMasterAssignField, newData, newCopyTo)};
          }
        }
      }
      /*   接口参数   */
      const payload = {
        url: sNameUrl,
        sParentId: sTabId,
        classifyOption: 'add',
        newRecordFlag: `NewRecord_${sTabId}`, /* newRecord当前字段 */
        newRecordRelation: addStata, /* newRecord 关联字段，如新增产品，带客户信息 */
        newRecordMethod: CallBackRecord.bind(this, showConfig.sName, name), /* newRecord当前字段 */
        sSrcModelsId: this.state.sModelsId
      };
      /*   调用接口   */
      this.props.dispatch({ type: 'content/onRouter', payload });
    };

    /* 获取配置数据用的sTabId,formId,formRoute */
    handleConfigValue = (value, type) => {
      if (commonUtils.isNotEmptyObject(type) && (type.indexOf('/indexOee') > -1 || type.indexOf('/indexMobile') > -1)) {
        return this.props[value];
      } else {
        const { secondppopupPane, ppopupPane, currentPane } = this.props.app;
        return commonUtils.isNotEmptyObject(secondppopupPane)
          ? secondppopupPane[value]
          : commonUtils.isNotEmptyObject(ppopupPane)
            ? ppopupPane[value] : currentPane[value];
      }
    };

    /* 获取后台数据（单条） */
    handleGetDataOne = async (params) => {
      const { token, sModelsId } = this.state;
      const {
        name, configData, condition, isWait, formSrcRoute, bEditClick, slaveConfig
      } = params;

      const lockUrl = `${commonConfig.server_host}business/addSysLocking?sModelsId=${sModelsId}&sName=${formSrcRoute}`;

      const configDataId = configData.sId;
      const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
      const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
      if (dataReturn.code === 1) {
        const [returnData] = dataReturn.dataset.rows[0].dataSet;
        if (commonUtils.isNotEmptyArr(returnData)) {
          let addState = {};
          const value = {
            tableName: configData.sTbName,
            sId: [returnData.sId],
          };
          if(bEditClick === 'update') { /* 只有点击修改时 调用addSysLocking */
            const { data } = await commonServices.postValueService(token, value, lockUrl);
            if (data.code === 1) { /*   失败   */
              addState.sUseInfo = '';
            } else { /*   失败   */
              addState.sUseInfo = data.msg;
              if (commonUtils.isNotEmptyObject(data.erroMsg)) {
                message.error(data.erroMsg);
              }
            }
          }
          addState[`${name}Data`] = returnData;
          addState[`${name}DataOld`] = returnData;
          if(commonUtils.isNotEmptyObject(returnData.customConfig) && commonUtils.isJSON(returnData.customConfig) && commonUtils.isNotEmptyObject(slaveConfig)) {
            const columnConfig = JSON.parse(returnData.customConfig);
            const newConfig =JSON.parse(JSON.stringify(slaveConfig));
            let buttonConfig = [];
            if(commonUtils.isNotEmptyArr(slaveConfig?.gdsconfigformslave)) {
              buttonConfig = slaveConfig?.gdsconfigformslave.filter(item => commonUtils.isEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sControlName) );
            }
            newConfig.gdsconfigformslave = columnConfig.concat(buttonConfig);
            addState.slaveConfig = newConfig;
          }
          addState.currentId = returnData.sId;
           if(bEditClick === 'update') {
             addState[`${name}Data`].enabled = true;
           }

          /* 获取主表数据时表字段数据根据条件控制 本表或其他表格字段的显示与隐藏功能 */
          if (name === 'master' && commonUtils.isNotEmptyObject(configData)) {
            const addStateChange = this.handelControlFieldVisible(name, configData, returnData);
            if (commonUtils.isNotEmptyObject(addStateChange)) {
              addState = { ...addState, ...addStateChange };
            }
          }

          if (isWait) {
            return addState;
          } else if (this.mounted) {
            this.handleSaveState({ ...addState });
          }
        }
      } else {
        this.getServiceError(dataReturn);
      }
    };
    handleGetDataOld = async (sId) => {
      const {
        token, sModelsId, formSrcRoute
      } = this.state;
      const dataUrl = `${commonConfig.server_host}log/getLogDetail/${sId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
      const condition = {};
      const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
      if(dataReturn.sCode === 1) {
        let returnData = dataReturn.dataset.rows[0].dataSet;
        console.log('ssreturnDatas', returnData);

      }

    }

    /* 获取后台数据（数据集） */
    handleGetDataSet = async (params) => {
      const {
        name, condition, flag, isWait, configData, clearSelectData,
      } = params;
      const {
        token, sModelsId, formRoute, [`${name}SelectedData`]: tableSelectedData, formSrcRoute, formData,  [`${name}DelData`]: tableDelData, sModelsType, [`${name}PageSize`]: pageSize, [`${name}Config`]: tableConfig,
      } = this.state;
      let {
        menuChildData,
        [`${name}SelectedRowKeys`]: tableSelectedRowKeys, iPageSize,
      } = this.state;
      const masterConditionData = commonUtils.isNotEmptyObject(condition) ? condition.sSqlCondition :  {};
      /* 根据后台主表配置bPagination判断 是否分页  */
      if (commonUtils.isNotEmptyObject(configData) && commonUtils.isNotEmptyObject(condition)) {
        const { bPagination } = configData;
        if (!bPagination || bPagination === undefined) {
          condition.pageSize = 10000; /* 不分页 */
          iPageSize = 10000;
        } else { /* 分页 */
          // eslint-disable-next-line no-lonely-if
          if (commonUtils.isNotEmptyArr(formData)) {
            if (commonUtils.isNotEmptyNumber(formData[0].iPageSize) && formData[0].iPageSize !== 0) {
              iPageSize = formData[0].iPageSize;/* 后台设定页数 */
            }
          }
        }
      }

      const configDataId = configData.sId;
      const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
      const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
      if (dataReturn.code === 1) {
        if( commonUtils.isNotEmptyObject(dataReturn.dataset) && commonUtils.isNotEmptyArr(dataReturn.dataset.rows) ) {
          let returnData = dataReturn.dataset.rows[0].dataSet;
          if (this.props && this.props.app && this.props.app.currentPane && this.props.app.currentPane.route && dataReturn.dataset.rows[0].columnConfig) {
            const columnConfig = dataReturn.dataset.rows[0].columnConfig;
            const newConfig = commonUtils.isNotEmptyObject(tableConfig) ?  JSON.parse( JSON.stringify(tableConfig)) : JSON.parse(JSON.stringify(configData)) ;
            let buttonConfig = [];
            if(commonUtils.isNotEmptyArr(tableConfig?.gdsconfigformslave)) {
               buttonConfig = tableConfig?.gdsconfigformslave.filter(item => commonUtils.isEmptyObject(item.sName) && commonUtils.isNotEmptyObject(item.sControlName) );
            }
            newConfig.gdsconfigformslave = columnConfig.concat(buttonConfig);
            let addConfig = {};
            if(name === 'slave' && commonUtils.isNotEmptyObject(newConfig)) {
               addConfig = {
                [`${name}Config`]:newConfig
              };
            }
            this.handleSaveState({
              customConfig: columnConfig,
              ...addConfig,
            })
          }
          // const returnData = dataReturn.dataset.rows[0].dataSet;
          if (commonUtils.isNotEmptyObject(returnData)) {
            if (formRoute === '/indexPage/materialRequirementsPlanning') {
              returnData.forEach((tableDataRow) => {
                tableDataRow.sSlaveId = tableDataRow.sMaterialsId + tableDataRow.sMaterialsStyle;
                tableDataRow.dAuxiliaryQtyAll = tableDataRow.dAuxiliaryQty;
                tableDataRow.dMaterialsQtyAll = tableDataRow.dMaterialsQty;
              });
            }
            if ((sModelsType && sModelsType.includes('linkTree'))) {
              returnData.forEach((tableDataRow) => {
                tableDataRow.dAuxiliaryQtyAll = tableDataRow.dAuxiliaryQty;
                tableDataRow.dMaterialsQtyAll = tableDataRow.dMaterialsQty;
              });
            }
            /* 若有sDivRow则数据行上面插入一行 */
            const returnFilterData = returnData.filter(item => commonUtils.isNotEmptyObject(item.sDivRow) && item.sDivRow !== '');
            if (commonUtils.isNotEmptyArr(returnFilterData)) {
              returnFilterData.forEach((tableDataRow, index) => {
                /* 找到白班与晚班区间的汇总条数与工时 */
                let startIndex = 0; /* 找到开始下标 */
                let endindex = 0; /* 找到结束下标 */
                let sliceData = [];
                startIndex = returnData.findIndex(item => item.sId === returnFilterData[index].sId);
                if (index + 1 < returnFilterData.length) {
                  endindex = returnData.findIndex(item => item.sId === returnFilterData[index + 1].sId);
                }
                if (index === returnFilterData.length - 1) {
                  endindex = returnData.length;
                }
                if (startIndex < endindex) {
                  sliceData = returnData.slice(startIndex, endindex);
                }
                let num = 0;
                let dTime = 0;
                let dPlateQty = 0; /* 付版 */
                let dProcessQty = 0;
                let endTime;
                const scheduleShow = ['16508090850002295893127095467000'].includes(sModelsId);
                let timeSName = 'dHour1';
                if (scheduleShow) timeSName = 'dSumHour';
                const newRow = {};
                newRow.sId = 'sDivRow' + index;
                newRow.sSlaveId = 'sDivRow' + commonUtils.createSid();
                if (commonUtils.isNotEmptyArr(sliceData)) {
                  num = sliceData.length;
                  sliceData.forEach((item) => {
                    if (commonUtils.isNotEmptyNumber(item[timeSName])) {
                      dTime += item[timeSName];
                      dPlateQty += commonUtils.isNotEmptyNumber(item.dPlateQty) ? item.dPlateQty : 0;
                      dProcessQty += commonUtils.isNotEmptyNumber(item.dProcessQty) ? item.dProcessQty : 0;
                      if (item?.tEndDate) {
                        let value = item.tEndDate;
                        if (endTime) {
                          value = moment.max(moment(endTime), moment(item.tEndDate));
                        }
                        endTime = value;
                      }
                      const iSrcIndex = returnData.findIndex(itemReturn => itemReturn.sSlaveId === item.sSlaveId); /* 汇总的每行上都加newRow的sSlaveId作为父级Id */
                      if (iSrcIndex > -1) {
                        returnData[iSrcIndex] = {...returnData[iSrcIndex], sDivRowParentId: newRow.sSlaveId}
                      }
                    }
                  });
                }
                newRow.sDivRowNew = tableDataRow.sDivRow;
                newRow.bInsert = true; /* 新插入 */
                newRow.sState = null;
                newRow.sProcessId = tableDataRow.sProcessId;
                /* 取第一个配置 */
                const configArr = configData.gdsconfigformslave.filter(item => item.bVisible && item.sName !== '');
                if (commonUtils.isNotEmptyArr(configArr)) {
                  let firstName = '';
                  if (configArr[0].sName === 'iOrder') {
                    firstName = configArr[1].sName;
                  } else {
                    firstName = configArr[1].sName;
                  }
                  if (commonUtils.isNotEmptyObject(firstName)) {
                    const firstDataIndex = firstName.substring(0, 1);
                    if (firstDataIndex !== 't' && firstDataIndex !== 'p') {
                      newRow[firstName] = tableDataRow.sDivRow;
                      if (num > 0) {
                        newRow[firstName] += 'F' + num + '单';
                      }
                      if (dProcessQty > 0) {
                        newRow[firstName] += ' - ' + dProcessQty;
                      }
                      if (tableDataRow.sType === "1" && !scheduleShow ) {
                        newRow[firstName] += ' - ' + dPlateQty + '付版';
                      }
                      if (dTime > 0) {
                        if (scheduleShow) {
                          newRow[firstName]  +=  ' - ' + Math.floor(dTime / 24) + "d" + (dTime % 24).toFixed(2) + 'h';
                        } else {
                          newRow[firstName] += ' - ' + (dTime / 60).toFixed(2) + 'h';
                        }
                      }
                      if (endTime) {
                        newRow[firstName] += ' - ' + moment(endTime).format('MM月DD日');
                      }
                    }
                  }
                }
                const iInsertIndex = returnData.findIndex(item => item.sSlaveId === tableDataRow.sSlaveId);
                if (iInsertIndex > -1) {
                  returnData[iInsertIndex].sDivRow = '';
                  returnData.splice(iInsertIndex, 0, newRow); /* 在目标位置前面增加一行 */
                }
              });
            }
            if (commonUtils.isEmptyArr(tableSelectedData)) {
              if (formRoute !== '/indexPage/materialRequirementsPlanning' && formRoute !== '/indexPage/commonClassify' &&
              sModelsId !=='12710101117238854446770') {
                if (commonUtils.isNotEmptyStr(returnData[0].sSlaveId)) {
                  const keys = [];
                  keys.push(returnData[0].sSlaveId);
                  tableSelectedRowKeys = keys;
                } else {
                  const keys = [];
                  keys.push(returnData[0].sId);
                  tableSelectedRowKeys = keys;
                }
              }
              if (flag) {
                tableSelectedRowKeys = [];
                menuChildData = []; // 打印下拉置空
              }
            }
          }
          if (clearSelectData) {
            tableSelectedRowKeys = [];
            menuChildData = []; // 打印下拉置空
          }
          /**
           * 修改日期：2021-03-30
           * 修改人：吕杰
           * 区域：以下 4 行
           * BUG：2185
           * 说明：右下角 增加单据个数显示
           * 原代码：
           */
          let billNum = '';
          let footTotalStr = '';
          const footTotal =commonFunc.showMessage(this.props.app.commonConst, 'footTotal') ||
            '当前显示 共${billNum}个单据 共${total}条记录';
          if (dataReturn.dataset.billNum) {
            billNum = `共${dataReturn.dataset.billNum}个单据 `;
          }
          const iOeeBillPageSize = iPageSize < 100 ? 100 : iPageSize;
          const pageSize = formRoute === '/indexPage/commonBill' || (formRoute === '/indexPage/productionMainPlan')
          ||  formRoute === '/indexPage/commonSubBill' ||  formRoute === '/indexPage/commonGroupBill' || formRoute === '/eleintefaceDialog' ?
            iPageSize : location.pathname.includes('commonOeeBill') ? iOeeBillPageSize : dataReturn.dataset.pageSize;
          const returnPagination = {
            total: dataReturn.dataset.totalCount,
            current: dataReturn.dataset.currentPageNo,
            pageSize: pageSize,
            showTotal: (total) => {
              footTotalStr =  footTotal.replace('${billNum}', dataReturn.dataset.billNum).replace('${total}', total);
              return (
                <span style={{fontWeight: 'bold'}}>{footTotalStr}</span>
              );
            },
          };
          // 如果是commonNewBill，不取接口返回的分页数
          if (formRoute === '/indexPage/commonNewBill' && pageSize) {
            const { bPagination } = configData;
            let iNewPageSize = pageSize;
            if (!bPagination || bPagination === undefined) {
              iNewPageSize = 10000;
            } else { /* 分页 */
              if (commonUtils.isNotEmptyNumber(configData.iPageSize) && configData.iPageSize !== 0) {
                iNewPageSize = configData.iPageSize;/* 后台设定页数 */
              }
            }
            returnPagination.pageSize = iNewPageSize;
          }
          // const sumSet1Default = [{
          //   "dProfit": '辊底重量:0.00',
          //   "dTotalProfitMoney": '转入重量:0.00',
          //   "dNetMargin": '分切重量:0.00',
          //   "dTotalNetProfit": '边料重量:0.00',
          //   "dMainBusinessMoney": '转出重量:0.00',
          //   "dOperaMoney": '总重量:0.00',
          //   "dFreight": '转入数量:0.00',
          //   "dOtherbusinessCostMoney": '转出数量:0.00',
          //   "dSellingExpenses": '总件数:0',
          // }];
          const { sumSet, sumSet1 } = dataReturn.dataset.rows[0];
          const totalData = sumSet !== undefined ? sumSet : [];
          const totalData1 = sumSet1 !== undefined ? sumSet1 : [];
          const filterCondition = commonUtils.isNotEmptyObject(condition) ? condition.bFilter : '';
          const orderBy = commonUtils.isNotEmptyObject(condition) ? condition.sFilterOrderBy : '';
          /* 去除树搜索filterCondition */
          const filterConditionNew = commonUtils.isNotEmptyObject(filterCondition) ? filterCondition.filter(item => item.bFilterType !== 'tree') : '';
          let addState = {
            [`${name}Data`]: returnData,
            [`${name}DataOld`]: returnData,
            [`${name}Pagination`]: returnPagination,
            [`${name}FilterCondition`]: filterConditionNew,
            [`${name}OrderBy`]: orderBy,
            [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
            menuChildData,
            /*
              修改日期：2021-03-17
              修改人：吕杰
              区域：以下一行
              需求变更：fix 2135 搜索时添加loading动画
            */
            pageLoading: false,
            iPageSize,
            masterConditionData
          };
          if (commonUtils.isNotEmptyArr(totalData1)) {
            addState = { ...addState, [`${name}Total1`]: totalData1, [`${name}AllTotal`]: totalData1 };
          }
          if (dataReturn.dataset.currentPageNo === 1) {
            addState = { ...addState, [`${name}Total`]: totalData, [`${name}AllTotal`]: totalData };
          }
          if(commonUtils.isNotEmptyNumber(dataReturn?.dataset.totalCount)) {
            const iCount = dataReturn.dataset.totalCount;
            addState = { ...addState, [`${name}TotalCount`]: iCount };
          }
          const slaveSelectedData = [];
          if ((formRoute === '/indexPage/commonList' || formRoute === '/indexPage/materialRequirementsPlanning') && name === 'slave' && commonUtils.isNotEmptyArr(tableSelectedRowKeys) && !clearSelectData) {
            tableSelectedRowKeys.forEach((item) => {
              const iPageIndex = returnData.findIndex(pageItem => pageItem.sSlaveId === item);
              if (iPageIndex > -1) {
                slaveSelectedData.push(returnData[iPageIndex]);
              } else if (commonUtils.isNotEmptyArr(tableSelectedData)) {
                const iIndex = tableSelectedData.findIndex(pageItem => pageItem.sSlaveId === item);
                if (iIndex > -1) {
                  slaveSelectedData.push(tableSelectedData[iIndex]);
                }
              }
            });
          } else if (formRoute === '/indexPage/materialRequirementsPlanning' && clearSelectData) { /* 处理物料需求计划生成采购申请单，刷新时，数据重复问题 */
            addState.slaveInfoSelectedRowKeys = [];
            addState.slaveInfoSelectedData = [];
          }
          addState[`${name}SelectedData`] = slaveSelectedData;
          /* 如果获取数据集时候 删除数据集有数据 则清空 */
          if (commonUtils.isNotEmptyArr(tableDelData)) {
            addState[`${name}DelData`] = [];
          }
          if (isWait) {
            return addState;
          } else if (this.mounted) {
            this.handleSaveState(addState);
          }
        } else {
          console.error(name +'表数据获取错误！');
        }
      } else {
        /*
          修改日期：2021-03-17
          修改人：吕杰
          区域：以下三行
          需求变更：fix 2135 搜索时添加loading动画
        */
        if (!isWait && this.mounted) {
          this.handleSaveState({ pageLoading: false });
        }
        this.getServiceError(dataReturn);
      }
    };

    /* 获取过滤树数据（数据集） */
    handleGetTreeDataSet = async (params, name) => {
      const {
        configData, condition, isWait,
      } = params;
      const { token, sModelsId, formSrcRoute } = this.state;
      let treeData = [];
      const expandedKeys = [];
      const configDataId = configData.sParentId;
      const dataUrl = `${commonConfig.server_host}filterTree/getFilterTree/${configDataId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
      const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
      if (dataReturn.code === 1) {
        const returnData = dataReturn.dataset.rows;
        if (commonUtils.isNotEmptyArr(returnData)) {
          /* 拼装树结构 */
          treeData = returnData;
          /* 默认展开第一个父节点 */
          if (treeData.length > 0) {
            if (commonUtils.isNotEmptyObject(treeData[0]) && commonUtils.isNotEmptyObject(treeData[0].key)) {
              expandedKeys.push(treeData[0].key);
            } else {
              treeData =[];
            }
          }
        }
        let addState = {
          expandedKeys,
        };
        if (name) {
          addState[`${name}TreeData`] = treeData;
        } else {
          addState.treeData = treeData;
        }
        addState = { ...addState };
        if (isWait) {
          return addState;
        } else if (this.mounted) {
          this.handleSaveState(addState);
        }
      } else {
        this.getServiceError(dataReturn);
      }
    };

    /* 重新获取界面配置 */
    handleGetTableConfig = async (name, sModelsId, oldConfig) => {
      const { token, formSrcRoute, formRoute } = this.state;
      let tableConfig = {};
      const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`;
      const configReturn = (await commonServices.getService(token, configUrl)).data;
      if (configReturn.code === 1) {
        const [configData] = configReturn.dataset.rows;
        const { formData } = configData;
        if (commonUtils.isNotEmptyArr(formData)) {
          if (oldConfig) {
            tableConfig = formData.find(item => item.sId === oldConfig.sId);
          } else if(formRoute === '/indexPage/commonList') {
            tableConfig = formData[0];
          } else if(formRoute === '/indexPage/commonNewBill') {
            if (name === 'master') {
              tableConfig = formData[0];
            } else if (name === 'slave') {
              tableConfig = formData.length > 1 ?  formData[1] : {};
            } else if (name === 'slave0') {
              tableConfig = formData.length > 2 ?  formData[2] : {};
            } else if (name === 'slave1') {
              tableConfig = formData.length > 3 ?  formData[3] : {};
            } else if (name === 'slave2') {
              tableConfig = formData.length > 4 ?  formData[4] : {};
            }
          } else {
            if (name === 'master') {
              tableConfig = formData[0];
            } else if (name === 'slave') {
              tableConfig = formData.length > 1 ?  formData[1] : {};
            } else if (name === 'control') {
              tableConfig = formData.length > 2 ?  formData[2] : {};
            } else if (name === 'materials') {
              tableConfig = formData.length > 3 ?  formData[3] : {};
            } else if (name === 'process') {
              tableConfig = formData.length > 4 ?  formData[4] : {};
            } else if (name === 'slave0') {
              tableConfig = formData.length > 2 ?  formData[2] : {};
            } else if (name === 'slave1') {
              tableConfig = formData.length > 3 ?  formData[3] : {};
            } else if (name === 'slave2') {
              tableConfig = formData.length > 4 ?  formData[4] : {};
            } else if (name === 'slave3') {
              tableConfig = formData.length > 5 ?  formData[5] : {};
            } else if (name === 'slave4') {
              tableConfig = formData.length > 6 ?  formData[6] : {};
            }
          }
        }
      } else {
        this.getServiceError(configReturn);
      }
      return tableConfig;
    }
    /*
      修改日期：2021-03-18
      修改人：吕杰
      区域：以下handleSaveState函数
      需求变更：添加回调
      原代码：
        handleSaveState = (values) => {
          if (this.mounted) {
            this.handleSaveState(values);
          }
        };
    */
    /* 数据保存到state */
    handleSaveState = (values = {}, callback) => {
      if (this.mounted) {
        // 如果将要保存的masterConfig是合并过的，则删除掉
        if (commonUtils.isNotEmptyObject(values.masterConfig) && values.masterConfig.bMerged) {
          delete values.masterConfig;
        }
        Object.keys(values).forEach(key => {
          // 如果将要保存的slaveConfig是合并过的，则删除掉
          if (key.startsWith('slave') && key.endsWith('Config') && commonUtils.isNotEmptyObject(values[key]) && values[key].bMerged) {
            delete values[key];
          }
        });
        // 如果改变了主表数据，遍历下所有配置sButtonEnabled的字段，生成配置
        const addState = {};
        const sRulesJsonTotal = this.handleGetRulesJsonTotal(values);
        if (sRulesJsonTotal) {
          addState.sRulesJsonTotal = sRulesJsonTotal;
        }
        // if (commonUtils.isNotEmptyObject(addState.sRulesJsonTotal)) {
        //   console.log('=====sRulesJsonTotal', addState.sRulesJsonTotal);
        // }
        this.setState({ ...values, ...addState }, typeof callback === 'function' ? callback : undefined);
      }
    };

    // 遍历下所有配置sButtonEnabled的字段，生成配置
    handleGetRulesJsonTotal = (values) => {
      const { masterConfig: masterConfig1, masterData: masterData1 } = values;
      const { masterConfig: masterConfig2, masterData: masterData2, sRulesJsonTotal } = this.state;

      const masterConfig = masterConfig1 || masterConfig2;
      const masterData = masterData1 || masterData2;

      const condition0 = commonUtils.isEmptyObject(masterConfig1) && commonUtils.isEmptyObject(masterData1);
      const condition1 = commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyObject(masterData1);
      const condition2 = commonUtils.isNotEmptyObject(masterConfig) && sRulesJsonTotal === undefined && commonUtils.isNotEmptyObject(masterData);
      const condition3 = commonUtils.convertObjToStr(masterData1) === commonUtils.convertObjToStr(masterData2) && sRulesJsonTotal !== undefined;

      const { sRulesTableList = [] } = this.state;
      let condition4 = false;
      if (sRulesTableList.length) {
        sRulesTableList.forEach(tableName => {
          const { [`${tableName}Data`]: tableData1 } = values;
          const { [`${tableName}Data`]: tableData2 = [] } = this.state;
          if (tableData1 !== undefined && commonUtils.convertObjToStr(tableData1) !== commonUtils.convertObjToStr(tableData2)) {
            condition4 = true;
          }
        })
      }

      if (condition0 || !(condition1 || condition2) || condition3) {
        if (!condition4) {
          return '';
        }
      }

      const { gdsconfigformslave = [] } = masterConfig;
      return gdsconfigformslave.reduce((result, config) => {
        const { sButtonEnabled } = config;
        const sRulesJson = commonUtils.convertStrToObj(sButtonEnabled, []);
        if (commonUtils.isNotEmptyArr(sRulesJson)) {
          for (let i = 0; i < sRulesJson.length; i += 1) {
            const rule = sRulesJson[i] || {};
            const { condition = [] } = rule;
            let flag = false; // 是否满足条件
            for (let j = 0; j < condition.length; j += 1) {
              const item = condition[j];
              const { bFilterName, bFilterCondition, bFilterValue, jsCondition } = item;
              if (jsCondition) {
                flag = commonFunc.getEvalResult({
                  props: {...this.props, ...this.state, ...values},
                  str: jsCondition,
                  defaultValue: false,
                  reocrdRules: true,
                  onSaveState: this.handleSaveState,
                })
              } else if (bFilterName !== undefined && bFilterCondition !== undefined && bFilterValue !== undefined) {
                const currentValue = masterData[bFilterName];
                flag = this.handleCompareValues(currentValue, bFilterValue, bFilterCondition);
              }
              if (!flag) {
                break;
              }
            }
            if (flag) {
              // console.log('=====匹配的规则', config, rule);
              const columnList = Object.keys(rule).filter(columnName => columnName && columnName.indexOf('Column') !== -1);
              columnList.forEach((columnName) => {
                if (commonUtils.isEmptyArr(result[columnName])) {
                  result[columnName] = [];
                }
                result[columnName] = Array.from(new Set([...result[columnName], ...rule[columnName]]));
              });
              // return result;
            }
          }
        }
        return result;
      }, {});
    }

    // 根据两个值是否满足比较条件
    handleCompareValues = (value1, value2, compare) => {
      if (value1 === undefined || value2 === undefined) {
        return false;
      }
      switch (compare) {
        case '=':
          return value1 == value2; // eslint-disable-line
        case '==':
          return value1 === value2;
        case '!=':
          return value1 !== value2;
        case '>':
          return value1 > value2;
        case '>=':
          return value1 >= value2;
        case '<':
          return value1 < value2;
        case '<=':
          return value1 <= value2;
        case 'like':
          return value1.includes(value2);
        default:
          return false;
      }
    }

    // 合并主表配置和所有sButtonEnabled配置
    handleMergeMasterConfig = (config) => {
      const { masterConfig: masterConfigOld, sRulesJsonTotal } = this.state;
      const masterConfig = commonUtils.isNotEmptyObject(config) ? config : masterConfigOld;
      if (commonUtils.isEmptyObject(masterConfig)) {
        return {};
      }
      if (commonUtils.isEmptyObject(sRulesJsonTotal)) {
        return masterConfig;
      }
      const masterConfigNew = lodash.cloneDeep(masterConfig);
      const { gdsconfigformslave } = masterConfigNew;
      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.showColumn)) {
        sRulesJsonTotal.showColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === child.sName);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bVisible = true;
          }
        });
      }

      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.hideColumn)) {
        sRulesJsonTotal.hideColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === child.sName);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bVisible = false;
          }
        });
      }

      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.mustColumn)) {
        sRulesJsonTotal.mustColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === child.sName);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bNotEmpty = true;
          }
        });
      }

      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.readOnlyColumn)) {
        sRulesJsonTotal.readOnlyColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === child.sName);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bReadonly = true;
          }
        });
      }
      return { ...masterConfigNew, bMerged: true };
    }

    // 合并从表配置和所有sButtonEnabled配置
    handleMergeSlaveConfig = (tableConfig) => {
      const { sRulesJsonTotal } = this.state;
      if (commonUtils.isEmptyObject(tableConfig)) {
        return {};
      }
      if (commonUtils.isEmptyObject(sRulesJsonTotal)) {
        return tableConfig;
      }
      const { sTbName } = tableConfig;
      const tableConfigNew = lodash.cloneDeep(tableConfig);
      const { gdsconfigformslave } = tableConfigNew;
      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.showColumn)) {
        sRulesJsonTotal.showColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bVisible = true;
          }
          const iIndex1 = gdsconfigformslave.findIndex(child => `${sTbName}.${child.sControlName}`.includes(item));
          if (iIndex1 !== -1) {
            if (gdsconfigformslave[iIndex1].sControlName.includes('DividerArea')) {
              gdsconfigformslave[iIndex1].sControlName = gdsconfigformslave[iIndex1].sControlName.split('.hide')[0];
            } else {
              gdsconfigformslave[iIndex1].bControl = true;
            }
          }
        });
      }

      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.hideColumn)) {
        sRulesJsonTotal.hideColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bVisible = false;
          }
          const iIndex1 = gdsconfigformslave.findIndex(child => `${sTbName}.${child.sControlName}`.includes(item));
          if (iIndex1 !== -1) {
            if (gdsconfigformslave[iIndex1].sControlName.includes('DividerArea')) {
              gdsconfigformslave[iIndex1].sControlName = `${gdsconfigformslave[iIndex1].sControlName}.hide`;
            } else {
              gdsconfigformslave[iIndex1].bControl = false;
            }
          }
        });
      }

      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.mustColumn)) {
        sRulesJsonTotal.mustColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bNotEmpty = true;
          }
        });
      }

      if (commonUtils.isNotEmptyArr(sRulesJsonTotal.readOnlyColumn)) {
        sRulesJsonTotal.readOnlyColumn.filter(item => item).forEach((item) => {
          const iIndex = gdsconfigformslave.findIndex(child => item === `${sTbName}.${child.sName}`);
          if (iIndex !== -1) {
            gdsconfigformslave[iIndex].bReadonly = true;
          }
        });
      }
      return { ...tableConfigNew, bMerged: true };
    }

    /** 修改主表数据 */
    handleMasterChange = (name, sFieldName, changeValue, sId, dropDownData, isWait, masterDataNew) => {
      const { masterData: masterDataOld } = this.state;
      const {
        sModelsId, masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config, slave5Config,
      } = this.state;
      const addState = {};
      let masterData = masterDataNew === undefined ? masterDataOld === undefined ? {} : masterDataOld : masterDataNew;
      let { handleType } = masterData;
      handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
      if (sFieldName.substring(0, 1).toLowerCase() === 'c') {
        const sAllField = sFieldName.substring(1, sFieldName.length);
        const allField = sAllField.split('_');
        const value = changeValue[sFieldName];
        allField.forEach((item, iArr) => {
          if (value.length > iArr) {
            changeValue[item] = value[iArr];
          }
        });
      }
      const bClearSelectedRowKeys = location.pathname.includes('commonList') ? false : true; /* 是否清除从表选择行 */
      if (!commonUtils.isEmpty(masterConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName)) {
        masterConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
          (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
          (item.sSqlCondition.includes(sFieldName) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
          commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []);
        });
        if (commonUtils.isNotEmptyObject(slaveConfig)) {
          slaveConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
            (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
            (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
            commonUtils.setStoreDropDownData(sModelsId, 'slave', item.sName, []);
            if (bClearSelectedRowKeys) {
              addState.slaveSelectedRowKeys = [];
            }
          });
        }
        if (commonUtils.isNotEmptyObject(slave0Config)) {
          slave0Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
            (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
            (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
            commonUtils.setStoreDropDownData(sModelsId, 'slave0', item.sName, []);
            if (bClearSelectedRowKeys) {
              addState.slave0SelectedRowKeys = [];
            }
          });
        }
        if (commonUtils.isNotEmptyObject(slave1Config)) {
          slave1Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
            (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
            (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
            commonUtils.setStoreDropDownData(sModelsId, 'slave1', item.sName, []);
            if (bClearSelectedRowKeys) {
              addState.slave1SelectedRowKeys = [];
            }
          });
        }
        if (commonUtils.isNotEmptyObject(slave2Config)) {
          slave2Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
            (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
            (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
            commonUtils.setStoreDropDownData(sModelsId, 'slave2', item.sName, []);
            if (bClearSelectedRowKeys) {
              addState.slave2SelectedRowKeys = [];
            }
          });
        }
        if (commonUtils.isNotEmptyObject(slave3Config)) {
          slave3Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
            (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
            (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
            commonUtils.setStoreDropDownData(sModelsId, 'slave3', item.sName, []);
            if (bClearSelectedRowKeys) {
              addState.slave3SelectedRowKeys = [];
            }
          });
        }
        if (commonUtils.isNotEmptyObject(slave4Config)) {
          slave4Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
            (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
            (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
            commonUtils.setStoreDropDownData(sModelsId, 'slave4', item.sName, []);
            if (bClearSelectedRowKeys) {
              addState.slave4SelectedRowKeys = [];
            }
          });
        }
        if (commonUtils.isNotEmptyObject(slave5Config)) {
          slave5Config.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
            (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
            (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
            commonUtils.setStoreDropDownData(sModelsId, 'slave5', item.sName, []);
            if (bClearSelectedRowKeys) {
              addState.slave5SelectedRowKeys = [];
            }
          });
        }
        /* 字段输入时 根据规则 控制其他字段的显示与隐藏 */
        // const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === sFieldName);
        // if (iConfigIndex > -1) {
        //   if (commonUtils.isEmptyObject(masterConfig.bak)) {
        //     masterConfig.bak = JSON.parse(JSON.stringify(masterConfig));
        //   }
        //   const sFiledConfig = masterConfig.gdsconfigformslave[iConfigIndex];
        //   if (commonUtils.isNotEmptyObject(sFiledConfig)) {
        //     const tableDataRow = { ...masterData, ...changeValue, handleType };
        //     const sRulesJson = sFiledConfig.sButtonEnabled;
        //     if (commonUtils.isNotEmptyObject(sRulesJson) && commonUtils.isJSON(sRulesJson)) {
        //       const sRulesObjArr = JSON.parse(sRulesJson);
        //       if (commonUtils.isNotEmptyArr(sRulesObjArr)) {
        //         console.log('sRulesObjArr:', sRulesObjArr);
        //         sRulesObjArr.forEach((sRulesObj) => {
        //           const {
        //             showColumn, hideColumn, condition, tbName, sConfigName,
        //           } = sRulesObj;
        //           console.log('tbName:', tbName);
        //           /* 主表单表字段根据条件控制 其他字段的显示与隐藏 */
        //           if (commonUtils.isEmptyObject(tbName)) {
        //             if (commonUtils.isNotEmptyArr(condition)) {
        //               let flag = false;
        //               for (const item of condition) {
        //                 const {
        //                   bFilterName, bFilterCondition, bFilterValue,
        //                 } = item;
        //                 if (bFilterCondition === '>') {
        //                   if (tableDataRow[bFilterName] > bFilterValue) {
        //                     flag = true;
        //                   }
        //                 } else if (bFilterCondition === '=') {
        //                   if (tableDataRow[bFilterName] === bFilterValue) {
        //                     flag = true;
        //                   }
        //                 } else if (bFilterCondition === '<') {
        //                   if (tableDataRow[bFilterName] < bFilterValue) {
        //                     flag = true;
        //                   }
        //                 }
        //               }
        //               if (flag) {
        //                 if (commonUtils.isNotEmptyArr(showColumn)) {
        //                   for (const column of showColumn) {
        //                     const iShowIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column);
        //                     if (iShowIndex > -1) {
        //                       const sFiledObj = masterConfig.gdsconfigformslave[iShowIndex];
        //                       if (commonUtils.isNotEmptyObject(sFiledObj)) {
        //                         if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') {
        //                           masterConfig.gdsconfigformslave[iShowIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */
        //                         } else {
        //                           masterConfig.gdsconfigformslave[iShowIndex].bVisible = true;
        //                         }
        //                       }
        //                     }
        //                   }
        //                 }
        //                 if (commonUtils.isNotEmptyArr(hideColumn)) {
        //                   for (const column of hideColumn) {
        //                     const iHideIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column);
        //                     if (iHideIndex > -1) {
        //                       if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') {
        //                         masterConfig.gdsconfigformslave[iHideIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */
        //                       } else {
        //                         masterConfig.gdsconfigformslave[iHideIndex].bVisible = false;
        //                       }
        //                     }
        //                   }
        //                 }
        //                 addState.masterConfig = masterConfig;
        //               }
        //             }
        //           } else { /* 主表字段根据条件控制 其他表格字段的显示与隐藏 */
        //             const { [`${tbName}Config`]: tableConfig } = this.state;
        //             // const { controlConfig: tableConfig } = this.state;
        //             if (commonUtils.isNotEmptyObject(tableConfig)) {
        //               if (commonUtils.isNotEmptyArr(condition)) {
        //                 let flag = false;
        //                 for (const item of condition) {
        //                   const {
        //                     bFilterName, bFilterCondition, bFilterValue,
        //                   } = item;
        //                   if (bFilterCondition === '>') {
        //                     if (tableDataRow[bFilterName] > bFilterValue) {
        //                       flag = true;
        //                     }
        //                   } else if (bFilterCondition === '=') {
        //                     if (tableDataRow[bFilterName] === bFilterValue) {
        //                       flag = true;
        //                     }
        //                   } else if (bFilterCondition === '<') {
        //                     if (tableDataRow[bFilterName] < bFilterValue) {
        //                       flag = true;
        //                     }
        //                   }
        //                 }
        //                 if (flag) {
        //                   if (commonUtils.isNotEmptyArr(showColumn)) {
        //                     for (const column of showColumn) {
        //                       const iShowIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column);
        //                       if (iShowIndex > -1) {
        //                         const sFiledObj = tableConfig.gdsconfigformslave[iShowIndex];
        //                         if (commonUtils.isNotEmptyObject(sFiledObj)) {
        //                           tableConfig.gdsconfigformslave[iShowIndex].bVisible = true;
        //                         }
        //                       }
        //                     }
        //                   }
        //                   if (commonUtils.isNotEmptyArr(hideColumn)) {
        //                     for (const column of hideColumn) {
        //                       const iHideIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column);
        //                       if (iHideIndex > -1) {
        //                         const sFiledObj = tableConfig.gdsconfigformslave[iHideIndex];
        //                         if (commonUtils.isNotEmptyObject(sFiledObj)) {
        //                           tableConfig.gdsconfigformslave[iHideIndex].bVisible = false;
        //                         }
        //                       }
        //                     }
        //                   }
        //                   if (commonUtils.isNotEmptyObject(tableConfig)) {
        //                     const tableColumn = commonFunc.getHeaderConfig(tableConfig);
        //                     // addState.masterConfig = masterConfig;
        //                     // addState.controlConfig = tableConfig; /* 表格配置塞到addState中 */
        //                     // addState.controlColumn = tbColumn;
        //                     addState[`${tbName}Config`] = tableConfig;
        //                     addState[`${tbName}Column`] = tableColumn;
        //                   }
        //                 }
        //               }
        //             }
        //           }
        //         });
        //       }
        //     }
        //   }

        //   // if (commonUtils.isEmptyObject(addState.masterConfig) && commonUtils.isNotEmptyObject(masterConfig.bak)) {
        //   //   addState.masterConfig = masterConfig.bak;
        //   // }
        // }
      }

      masterData = { ...masterData, ...changeValue, handleType };

      const { dGramWeight, dWlcd, dWlkd, iNumerator } = masterData;
      if (
        (
          ['dGramWeight', 'dWlcd', 'dWlkd', 'iNumerator'].includes(sFieldName) ||
          commonUtils.isEmptyObject(changeValue)
        ) &&
        !commonUtils.isEmpty(dGramWeight) &&
        !commonUtils.isEmpty(dWlcd) &&
        !commonUtils.isEmpty(dWlkd) &&
        !commonUtils.isEmpty(iNumerator)
      ) {
        masterData = commonBusiness.getMaterialsQty(this.props.app, { ...masterData, sMaterialsStyle: `${dWlcd}*${dWlkd}` }, 'iNumerator', 'iDenominatr');
        if (masterData.iDenominatr) {
          masterData.iDenominatr = Number(masterData.iDenominatr).toFixed(0);
        }
      }

      if (isWait) {
        return { masterData, ...addState }; // , sUseInfo: ''
      } else if (this.mounted) {
        this.handleSaveState({ masterData, ...addState }); // , sUseInfo: ''
        return { masterData, ...addState };
      }
    };

    /** 表格数据更改 */
    // name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
    handleTableChange = (name, sFieldName, changeValue, sId, dropDownData, isWait) => {
      const {
       [`${name}Config`]: tableConfig, sModelsId, masterData, slaveData, controlData, materialsData, processData, slaveInfoData, slaveChildData,
        slaveSelectedRowKeys, slaveInfoSelectedRowKeys, controlSelectedRowKeys, materialsSelectedRowKeys, processSelectedRowKeys, slaveChildSelectedRowKeys,
      } = this.state;
      const { app } = this.props;
      let { [`${name}Data`]: tableData } = this.state;
      if (name === 'slave' && window.tmpSlaveData) {
        tableData = window.tmpSlaveData;
      }
      const iIndex = tableData.findIndex(item => item.sId === sId);
      let { handleType } = tableData[iIndex];
      handleType = commonUtils.isEmpty(handleType) ? 'update' : handleType;
      if (sFieldName.substring(0, 1).toLowerCase() === 'c') {
        const sAllField = sFieldName.substring(1, sFieldName.length);
        const allField = sAllField.split('_');
        const value = changeValue[sFieldName];
        allField.forEach((item, iArr) => {
          if (value.length > iArr) {
            changeValue[item] = value[iArr];
          }
        });
      }

      if (!commonUtils.isEmpty(tableConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(tableConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName)) {
        tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
          (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
          (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
          commonUtils.setStoreDropDownData(sModelsId, 'slave', item.sName, []);
        });
        // tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && item.sSqlCondition.includes(sFieldName)).forEach((item) => {
        //   commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []);
        // });

        /* 字段输入时 根据规则 控制其他字段的显示与隐藏 */
        const iConfigIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === sFieldName);
        if (iConfigIndex > -1) {
          const sFiledConfig = tableConfig.gdsconfigformslave[iConfigIndex];
          if (commonUtils.isNotEmptyObject(sFiledConfig)) {
            const tableDataRow = { ...tableData[iIndex], ...changeValue, handleType };
            const sRulesJson = sFiledConfig.sButtonEnabled;
            if (commonUtils.isNotEmptyObject(sRulesJson) && commonUtils.isJSON(sRulesJson)) {
              const sRulesObj = JSON.parse(sRulesJson);
              if (commonUtils.isNotEmptyObject(sRulesObj)) {
                const { showColumn, hideColumn, condition } = sRulesObj;
                if (commonUtils.isNotEmptyArr(condition)) {
                  let flag = false;
                  for (const item of condition) {
                    const {
                      bFilterName, bFilterCondition, bFilterValue,
                    } = item;
                    if (bFilterCondition === '>') {
                      if (tableDataRow[bFilterName] > bFilterValue) {
                        flag = true;
                      }
                    } else if (bFilterCondition === '=') {
                      if (tableDataRow[bFilterName] === bFilterValue) {
                        flag = true;
                      }
                    } else if (bFilterCondition === '<') {
                      if (tableDataRow[bFilterName] < bFilterValue) {
                        flag = true;
                      }
                    }
                  }
                  if (flag) {
                    if (commonUtils.isNotEmptyArr(showColumn)) {
                      for (const column of showColumn) {
                        const iShowIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column);
                        if (iShowIndex > -1) {
                          const sFiledObj = tableConfig.gdsconfigformslave[iShowIndex];
                          if (commonUtils.isNotEmptyObject(sFiledObj)) {
                            tableConfig.gdsconfigformslave[iShowIndex].bVisible = true;
                          }
                        }
                      }
                    }
                    if (commonUtils.isNotEmptyArr(hideColumn)) {
                      for (const column of hideColumn) {
                        const iHideIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column);
                        if (iHideIndex > -1) {
                          tableConfig.gdsconfigformslave[iHideIndex].bVisible = false;
                        }
                      }
                    }

                    const tableColumn = commonFunc.getHeaderConfig(tableConfig);
                    this.handleSaveState({ [`${name}Config`]: tableConfig, [`${name}Column`]: tableColumn });
                  }
                }
              }
            }
          }
        }
        /* 将选中行塞到tableSelectedData数据集合中 */
        let slaveRow = {};
        let controlRow = {};
        let materialsRow  ={};
        let processRow = {};
        let slaveInfoRow = {};
        let slaveChildRow = {};
        if(commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
          const iSIndex =  slaveData.findIndex(item =>slaveSelectedRowKeys.includes(item.sId));
          if(iSIndex > -1) {
            slaveRow =  slaveData[iSIndex];
          }
        }
        if(commonUtils.isNotEmptyArr(slaveInfoData) && commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys)) {
          const iSIndex =  slaveInfoData.findIndex(item =>slaveInfoSelectedRowKeys.includes(item.sId));
          if(iSIndex > -1) {
            slaveInfoRow =  slaveInfoData[iSIndex];
          }
        }
        if(commonUtils.isNotEmptyArr(slaveChildData) && commonUtils.isNotEmptyArr(slaveChildSelectedRowKeys)) {
          const iSIndex =  slaveChildData.findIndex(item => slaveChildSelectedRowKeys.includes(item.sId));
          if(iSIndex > -1) {
            slaveChildRow =  slaveChildData[iSIndex];
          }
        }
        if(commonUtils.isNotEmptyArr(controlData) && commonUtils.isNotEmptyArr(controlSelectedRowKeys)) {
          const iCIndex =   controlData.findIndex(item => controlSelectedRowKeys.includes(item.sId));
          if(iCIndex > -1) {
            controlRow =  controlData[iCIndex];
          }
        }
        if(commonUtils.isNotEmptyArr(materialsData) && commonUtils.isNotEmptyArr(materialsSelectedRowKeys)) {
          const iMIndex =  materialsData.findIndex(item => materialsSelectedRowKeys.includes(item.sId));
          if(iMIndex > -1) {
            materialsRow =  materialsData[iMIndex];
          }
        }
        if(commonUtils.isNotEmptyArr(processData) && commonUtils.isNotEmptyArr(processSelectedRowKeys)) {
          const iPIndex =  processData.findIndex(item => processSelectedRowKeys.includes(item.sId));
          if(iIndex > -1) {
            processRow =  processData[iPIndex];
          }
        }

        const tableAllData = {
          master: masterData,
          slave: slaveData,
          control: controlData,
          materials: materialsData,
          process: processData,
          slaveInfo: slaveInfoData,
          slaveChild: slaveChildData,

        };
        const tableSelectedData = {
          master: masterData,
          slaveRow: slaveRow,
          controlRow: controlRow,
          materialsRow: materialsRow,
          processRow: processRow,
          slaveInfoRow: slaveInfoRow,
          slaveChildRow: slaveChildRow,
        }

        const tableDataRowNew = { ...tableData[iIndex], ...changeValue, handleType };
        const tableDataAfter = commonKeyUp.getKeyUpEvent(name, sFieldName, tableConfig, masterData, tableDataRowNew, true, tableAllData, tableSelectedData, app);
        if (commonUtils.isNotEmptyObject(tableDataAfter)) {
          changeValue = { ...tableDataAfter };
        }
      }
      if (isWait) {
        return { ...tableData[iIndex], ...changeValue, handleType };
      } else {
        tableData[iIndex] = { ...tableData[iIndex], ...changeValue, handleType };
        if (this.mounted) {
          this.handleSaveState({ [`${name}Data`]: tableData, sUseInfo: '' });
        }
      }
    };
    /**   添加表格空行   */
    handleTableAdd = (name, isWait) => {
      /*   外置处理业务   */
      const {
        [`${name}Config`]: tableConfig, masterData, slaveData, slaveSelectedRowKeys, controlData, controlSelectedRowKeys,
        processData, processSelectedRowKeys, materialsData, materialsSelectedRowKeys, sModelsType
      } = this.state;
      let { [`${name}Data`]: tableData } = this.state;
      const { app } = this.props;
      tableData = commonUtils.isEmptyObject(tableData) ? [] : tableData;
      const allTableData = {};
      allTableData.master = masterData;
      if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys.toString());
        allTableData.slave = slaveData[iSlaveIndex];
      }
      if (commonUtils.isNotEmptyArr(controlSelectedRowKeys) && commonUtils.isNotEmptyArr(controlData)) {
        const iSlaveIndex = controlData.findIndex(item => item.sId === controlSelectedRowKeys.toString());
        allTableData.control = controlData[iSlaveIndex];
      }
      if (commonUtils.isNotEmptyArr(processSelectedRowKeys)) {
        const iSlaveIndex = processData.findIndex(item => item.sId === processSelectedRowKeys.toString());
        allTableData.process = processData[iSlaveIndex];
      }
      if (commonUtils.isNotEmptyArr(materialsSelectedRowKeys)) {
        const iSlaveIndex = materialsData.findIndex(item => item.sId === materialsSelectedRowKeys.toString());
        allTableData.materials = materialsData[iSlaveIndex];
      }

      const iOrderArr = [];
      tableData.forEach((item) => {
        const iOrder = commonUtils.isNotEmptyNumber(item.iOrder) ? item.iOrder : 0; /* 获取tableData中iOrder最大值 */
        iOrderArr.push(iOrder);
      });
      const iOrderMax = Math.max(...iOrderArr);
      let tableDataRow = {};
      tableDataRow.handleType = 'add';
      tableDataRow.sId = commonUtils.createSid();
      tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
      tableDataRow.key = tableDataRow.sId;
      tableDataRow.bDefault = false;
      tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 1;
      tableDataRow.defaultAdded = tableData.length === 0;
      allTableData.self = tableDataRow;
      if(tableConfig.sTableType === 'single' || name === 'control') {
        tableDataRow.sNodeId = commonUtils.createSid(); /* 用于建立关联关系 */
      }
      tableDataRow = { ...tableDataRow, ...commonFunc.getDefaultData(tableConfig, allTableData)};
      tableDataRow = commonUtils.getDefineNo(app, sModelsType, name,  masterData, tableDataRow);
      if (isWait) {
        return tableDataRow;
      } else {
        // tableData.splice(index, 1, tableDataRow);  /* 该处会导致新增时删除首行 */
        tableData.push(tableDataRow);
        if (this.mounted) {
          this.handleSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] });
        }
      }
    };

    // name 不写完整的state名称作用为了要用到total
    /**   删除表格数据   */
    handleTableDel = (name, isWait, tableSelectedRowKeys, callback) => {
      const { app } = this.props;
      const { [`${name}Data`]: tableDataOld = [] } = this.state;
      let { [`${name}DelData`]: tableDelDataOld = [], [`${name}Pagination`]: pagination = {} } = this.state;
      const tableData = [...tableDataOld];
      const tableDelData = [...tableDelDataOld];
      if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
        for (const sId of tableSelectedRowKeys) {
          /*   看看删除集合和从表中是否都存在该条数据   */
          let tableDataIndex = tableData.findIndex(item => item.sId === sId);
          while (tableDataIndex > -1) {
            /*   删除从表中的数据并存入删除集合中   */
            const slaveDataFilter = tableData[tableDataIndex];
            tableData.splice(tableDataIndex, 1);
            slaveDataFilter.handleType = 'del';
            tableDelData.push(slaveDataFilter);
            tableDataIndex = tableData.findIndex(item => item.sId === sId);
          }
        }

        const addState = {};
        if (commonUtils.isNotEmptyObject(pagination)) {
          addState[`${name}Pagination`] = {
            ...pagination,
            total: tableData.length,
          }
        }
        let newSelectedRowKeys = [];
        if(name === 'slave') { /* 删除后定位最后一条 */
          if(commonUtils.isNotEmptyArr(tableData)) {
            const len = tableData.length -1;
            newSelectedRowKeys = [tableData[len].sId];
          }
        }

        if (isWait) {
          return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: newSelectedRowKeys, ...addState };
        } else {
          if (this.mounted) {
            this.handleSaveState({
              [`${name}Data`]: tableData,
              [`${name}DelData`]: tableDelData,
              [`${name}SelectedRowKeys`]: [],
              ...addState,
            }, () => {
              callback && callback();
            });
          }
          return true;
        }
      } else {
        if (!isWait) {
          message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseDelData')); // 请选择删除数据
        }
        return false;
      }
    };

    /**   处理选择行发生改变   */
    handleTableSelectRowChange = (name, selectedRowKeys, isWait) => {
      /*   外置处理业务   */
      const {
        formRoute, slaveData, sModelsId, [`${name}Config`]: tableConfig,
      } = this.state;
      let { slaveSelectedData } = this.state;
      const addState = {};
      addState[`${name}SelectedRowKeys`] = selectedRowKeys;
      addState.searchUpDownData = {};
      const formRouteArr = [
        '/indexPage/commonList',
        '/indexPage/commonListEdit',
        '/indexPage/commonListTree',
        '/indexPage/commonListLeft'
      ];
      if (name === 'slave' && (formRouteArr.includes(formRoute) || formRoute.indexOf('/indexOee') > -1)) {
        const slavePageData = slaveData.filter(item => selectedRowKeys.includes(item.sSlaveId));
        slaveSelectedData = commonUtils.isEmpty(slaveSelectedData) ? [] : slaveSelectedData.filter(item => selectedRowKeys.toString().includes(item.sSlaveId));
        selectedRowKeys.forEach((item) => {
          const iIndex = slaveSelectedData.findIndex(selectItem => selectItem.sSlaveId === item);
          if (iIndex === -1) {
            const iPageIndex = slavePageData.findIndex(pageItem => pageItem.sSlaveId === item);
            if (iPageIndex > -1) {
              slaveSelectedData.push(slavePageData[iPageIndex]);
            }
          }
        });
        addState.slaveSelectedData = slaveSelectedData;
      }
      if (commonUtils.isNotEmptyObject(tableConfig)) {
        tableConfig.gdsconfigformslave.forEach((configItem) => {
          const sFieldName = configItem.sName;
          if (!commonUtils.isEmpty(tableConfig.gdsconfigformslave) && commonUtils.isNotEmptyArr(tableConfig.gdsconfigformslave) && !commonUtils.isEmpty(sFieldName) &&
            (commonUtils.isEmptyArr(this.state[`${name}SelectedRowKeys`]) || selectedRowKeys.toString() !== this.state[`${name}SelectedRowKeys`].toString())) {
            tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && !commonUtils.isEmpty(item.sChineseDropDown) &&
              (item.sChineseDropDown.includes(`#${sFieldName}`) || item.sChineseDropDown.includes(`*${sFieldName}`)) &&
              (item.sSqlCondition.includes(`master.${sFieldName}`) || item.sSqlCondition.includes(sFieldName.replace('Name', 'Id')))).forEach((item) => {
              commonUtils.setStoreDropDownData(sModelsId, 'slave', item.sName, []);
            });
            // tableConfig.gdsconfigformslave.filter(item => !commonUtils.isEmpty(item.sSqlCondition) && item.sSqlCondition.includes(sFieldName)).forEach((item) => {
            //   commonUtils.setStoreDropDownData(sModelsId, name, item.sName, []);
            // });
          }
        });
      }
      if (this.mounted) {
        if (isWait) {
          return addState;
        } else {
          this.handleSaveState(addState);
        }
      }
    };

    handleViewClick = (name, sName, record, index) => {
      const {
        [`${name}Config`]: slaveConfig, customConfig, [`${name}Data`]: slaveData, [`${name}Pagination`]: slavePagination, formSrcRoute, masterConfig,
      } = this.state;
      let {
        [`${name}FilterCondition`]: slaveFilterCondition,
      } = this.state;
      let picArr = slaveConfig?.gdsconfigformslave.filter(item => (item.sName === sName));
      if (commonUtils.isNotEmptyArr(customConfig)) {
        picArr = customConfig.filter(item => item.sName === sName);
      }
      if (commonUtils.isNotEmptyObject(sName) && sName.includes('BtnEject')) {
        picArr = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sControlName === sName);
      }
      if (picArr.length > 0) {
        const tableDataRow = record;
        const iIndex = index;
        // let tableDataRow = {};
        // let iIndex = 0;
        /* 判断slaveData是数组还是对象 */
        // if (commonUtils.isNotEmptyObject(slaveData) && slaveData.length > 0) {
        //   iIndex = slaveData.findIndex(item => item.sId === sId);
        //   tableDataRow = iIndex > -1 ? slaveData[iIndex] : {};
        // } else if (commonUtils.isNotEmptyObject(slaveData)) {
        //   tableDataRow = slaveData;
        // }
        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=${formSrcRoute}`;
        const filterCondition = [];
        const conditionValues = this.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],
              });
            }
          });
        }
        let copyTo ={};
        let bLinkPlanTree = commonUtils.isNotEmptyObject(tableDataRow) && tableDataRow.bLinkPlanTree;
        if(bLinkPlanTree) {
          copyTo = {
            treeKey : tableDataRow.sMachineId + tableDataRow.sWorkCenterId,
            sWorkCenterName: tableDataRow.sWorkCenterName,
          }
        }

        let payload = {
          url: sNameUrl,
          sTabId: commonUtils.createSid(),
          sParentId: this.state.sTabId,
          urlDataType: 'newPane',
          checkedId: tableDataRow[sActiveKey],
          bFilter: slaveFilterCondition,
          pageSize: this.state.iPageSize,
          pages: slavePagination,
          currentData: [tableDataRow],
          conditonValues: bLinkPlanTree ? undefined : conditionValues,
          sListFormmasterId: slaveConfig?.sId,
          newKey: tableDataRow[sActiveKey],
          currentIndex: iIndex,
          filterCondition: bLinkPlanTree ? undefined : filterCondition,
          copyTo: copyTo,
          sSrcModelsId: this.state.sModelsId,
        }
        this.props.dispatch({
          type: 'content/onRouter',
          payload
        });
      }
    };
    /* 快捷键跳转 */
    handleQuickViewClick = (name, sName, record, index, myConfigArr) => {
      const {
        [`${name}Config`]: slaveConfig, customConfig, [`${name}FilterCondition`]: slaveFilterCondition, [`${name}Pagination`]: slavePagination, formSrcRoute, masterConfig,
      } = this.state;

      let picArr = slaveConfig.gdsconfigformslave.filter(item => (item.sName === sName));

      if (commonUtils.isNotEmptyArr(customConfig)) {
        picArr = customConfig.filter(item => item.sName === sName);
      }
      if (commonUtils.isNotEmptyObject(sName) && sName.includes('BtnEject')) {
        picArr = masterConfig.gdsconfigformslave.filter(item => item.bVisible && item.sControlName === sName);
      }
      if (commonUtils.isNotEmptyArr(myConfigArr)) {
        picArr = myConfigArr;
      }
      if (picArr.length > 0) {
        const tableDataRow = record;
        const iIndex = index;
        // let tableDataRow = {};
        // let iIndex = 0;
        /* 判断slaveData是数组还是对象 */
        // if (commonUtils.isNotEmptyObject(slaveData) && slaveData.length > 0) {
        //   iIndex = slaveData.findIndex(item => item.sId === sId);
        //   tableDataRow = iIndex > -1 ? slaveData[iIndex] : {};
        // } else if (commonUtils.isNotEmptyObject(slaveData)) {
        //   tableDataRow = slaveData;
        // }
        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=${formSrcRoute}`;
        const filterCondition = [];
        const conditionValues = this.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],
              });
            }
          });
        }
        let copyTo = {};
        if (commonUtils.isNotEmptyObject(tableDataRow) && tableDataRow.bLinkPlanTree) {
          copyTo = {
            treeKey: tableDataRow.sMachineId + tableDataRow.sWorkCenterId,
            sWorkCenterName: tableDataRow.sWorkCenterName,
          };
        }
        this.props.dispatch({
          type: 'content/onRouter',
          payload: {
            url: sNameUrl,
            sTabId: commonUtils.createSid(),
            sParentId: this.state.sTabId,
            urlDataType: 'newPane',
            checkedId: (commonUtils.isNotEmptyObject(tableDataRow[sActiveKey])) ? tableDataRow[sActiveKey] : myConfigArr[0].sId,
            sName: myConfigArr[0].sName,
            bFilter: slaveFilterCondition,
            pageSize: this.state.iPageSize,
            pages: slavePagination,
            currentData: [tableDataRow],
            conditonValues: conditionValues,
            sListFormmasterId: slaveConfig.sId,
            newKey: tableDataRow[sActiveKey],
            currentIndex: iIndex,
            filterCondition,
            copyTo,
            sSrcModelsId: this.state.sModelsId,
          },
        });
      }
    };

    handleTabModalClick = (name, sName, record, index, showConfig) => {
      this.setState({
        bTabModal: true,
        tabModalConfig: showConfig,
        tabModalRecord: record,
      });
    }
    handleRowMove = (addState) => {
      this.handleSaveState(addState);
    };
    handleFilterDropDownData = (dropDownData, showConfig, name, record) => {
      if (!commonUtils.isEmptyArr(dropDownData)) {
        const conditon = showConfig.sSqlCondition.split(',');
        let orTableName;
        let orFieldName;
        let orFieldNameFilter;
        let orValue;
        conditon.forEach((item) => {
          if (item.indexOf('.') > -1) {
            const tableName = item.split('.')[0];
            const fieldName = item.split('.')[1];
            const fieldNameFilter = item.split('.')[2];
            if (tableName.indexOf('|') > -1) {
              orTableName = tableName.replace('|', '');
              orFieldName = fieldName;
              orFieldNameFilter = fieldNameFilter;
              if (orFieldName.indexOf('&') > -1) {
                orValue = orFieldName.replace('&', '');
              } else if (!commonUtils.isEmpty(orFieldNameFilter)) {
                if (name === orTableName && !commonUtils.isEmpty(record)) {
                  const data = record;
                  orValue = data[orFieldName];
                } else {
                  const data = this.state[`${orTableName}Data`];
                  const selectedRowKeys = this.state[`${orTableName}SelectedRowKeys`];
                  if (typeof data === 'object' && data.constructor === Object) {
                    orValue = data[orFieldName];
                  } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
                    const iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
                    if (iIndex > -1) {
                      orValue = data[iIndex][orFieldName];
                    }
                  } else if (commonUtils.isNotEmptyArr(data)) {
                    orValue = data[0][orFieldName];
                  }
                }
              }
              orValue = orValue.toString();
            } else if (!commonUtils.isEmpty(orFieldName)) {
              // master.sId 作为参数   control.sId.sControlId 作为filterDropdown过滤参数
              if (!commonUtils.isEmpty(fieldNameFilter)) {
                if (name === tableName && !commonUtils.isEmpty(record)) {
                  const data = record;
                  dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName] || itemDrop[orFieldNameFilter] === orValue);
                } else {
                  const data = this.state[`${tableName}Data`];
                  const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
                  if (typeof data === 'object' && data.constructor === Object) {
                    dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName] || itemDrop[orFieldNameFilter] === orValue);
                  } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
                    const iIndex = data.findIndex(itemData => itemData.sId === selectedRowKeys[0]);
                    if (iIndex > -1) {
                      dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[iIndex][fieldName] || itemDrop[orFieldNameFilter] === orValue);
                    }
                  } else if (commonUtils.isNotEmptyArr(data)) {
                    dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[0][fieldName] || itemDrop[orFieldNameFilter] === orValue);
                  }
                }
              }
            } else if (!commonUtils.isEmpty(fieldNameFilter)) {
              if (name === tableName && !commonUtils.isEmpty(record)) {
                const data = record;
                dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName]);
              } else {
                const data = this.state[`${tableName}Data`];
                const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
                if (typeof data === 'object' && data.constructor === Object) {
                  dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[fieldName]);
                } else if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
                  const iIndex = data.findIndex(itemData => (commonUtils.isEmpty(itemData.sSlaveId) ? itemData.sId : itemData.sSlaveId) === selectedRowKeys[0]);
                  if (iIndex > -1) {
                    dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[iIndex][fieldName]);
                  }
                } else if (commonUtils.isNotEmptyArr(data)) {
                  dropDownData = dropDownData.filter(itemDrop => itemDrop[fieldNameFilter] === data[0][fieldName]);
                }
              }
            }
          }
        });
      }

      // let dropDownData = dropDownDataOld;
      // const data = this.state[`${tableName}Data`];
      // const selectedRowKeys = this.state[`${tableName}SelectedRowKeys`];
      // if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
      //   const SelectedData = data.filter(item => item.sId === selectedRowKeys[0]);
      //   if (SelectedData.length > 0 && commonUtils.isNotEmptyStr(SelectedData[0][fieldName])) {
      //     if (commonUtils.isNotEmptyArr(dropDownData)) {
      //       dropDownData = dropDownData.filter(item => item[fieldName] === SelectedData[0][fieldName]);
      //     }
      //   }
      // }
      return dropDownData;
    };
    /* newRecord新纪录保存后，将数据回到到下拉框中 字段名，主从表名，赋值字段 */
    handleCallBackRecord = async (sName, name, sId) => {
      const {
        [`${name}SelectedRowKeys`]: tableSelectedRowKeys, sModelsId, [`${name}Data`]: tableNewData, slaveData, masterData, sModelsType, token, formRoute,
      } = this.state;
      const { app } = this.props;
      /* 获取下拉的字段showConfig */
      const { [`${[name]}Config`]: nameConfig } = this.state;
      const filedShowConfig = nameConfig.gdsconfigformslave.filter(item => (item.sName === sName));
      const AssignField = commonUtils.isNotEmptyArr(filedShowConfig) ? filedShowConfig[0].sAssignField : '';
      const sqlDropDownData = await this.getSqlDropDownData(sModelsId, name, filedShowConfig[0]);
      /* 根据sName得到过滤数据 */
      const dropdownData = sqlDropDownData.dropDownData;
      const filterDataIndex = dropdownData.findIndex(item => (item.sId === sId) || (commonUtils.isNotEmptyObject(item.sNId) && item.sNId === sId));
      if (filterDataIndex > -1) {
        if (name !== 'master' && commonUtils.isNotEmptyObject(tableSelectedRowKeys)) {
          const newCopyTo = {};
          const iIndex = tableNewData.findIndex(item => item.sId === tableSelectedRowKeys.toString());
          newCopyTo.master = masterData;
          newCopyTo.slave = tableNewData[iIndex];
          let slaveRow = {};
          slaveRow = { ...tableNewData[iIndex], ...commonFunc.getAssignFieldValue(AssignField, dropdownData[filterDataIndex], newCopyTo) }; // 取赋值字段
          slaveRow.handleType = commonUtils.isEmpty(slaveRow.handleType) ? 'update' : slaveRow.handleType;
          if (sName === 'sProductId' || sName === 'sProductName') {
            slaveRow.sProductInfo = '';
          }
          tableNewData[iIndex] = slaveRow;

          /* 套装工单、报价单、工艺卡的从表, 点击newRecord后 回带控制表合版数据 */
          const addState = {};
          if(formRoute && formRoute.includes('PackTableTree') && name === 'slave') {
            const { controlData } = this.state;;
            let { packData } = this.state;
            if(commonUtils.isEmptyArr(packData)){
              packData =[];
            }
            if(controlData.length ===1) {
              const controlRow = controlData[0];
              const iIndex = packData.findIndex(item=> item.sControlId === controlRow.sId);
              if(iIndex > -1){
                const packFilterData = packData.filter(item => item.sControlId === controlRow.sId);
                if (commonUtils.isNotEmptyArr(packFilterData)) {
                  packFilterData.forEach((itemPack, index) => {
                    let packDataRow = itemPack;
                    const sControlId = controlRow.sControlId;
                    packDataRow.sControlId = controlRow.sId;
                    packDataRow.sSlaveId = slaveRow.sId;
                    packDataRow.sProductId = slaveRow.sProductId; /* 产品id */
                    packDataRow.sCustomerId = slaveRow.sCustomerId; /* 客户id */
                    packDataRow.sCustomerName = slaveRow.sCustomerName; /* 客户名称 */
                    packDataRow.sProductName = slaveRow.sProductName; /* 产品名称 */
                    packDataRow.sProductNo = slaveRow.sProductNo; /* 产品编号 */
                    packDataRow.dCombineQty = 1;
                    packData[index] = { ...packData[index], ...packDataRow };
                    if (commonUtils.isNotEmptyObject(packData[index])) {
                      const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[0];
                      const tableCombineSelectedData = [];
                      const jsonObj = {};
                      jsonObj.sId = sId;
                      jsonObj.sProductNo = sProductNo; /* 产品编号 */
                      jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
                      jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
                      jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
                      jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
                      tableCombineSelectedData.push(jsonObj);
                      const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) ? JSON.stringify(tableCombineSelectedData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
                      controlRow.sCombinedMemo =commonUtils.isNotEmptyObject(sCombinedMemo)? sCombinedMemo: '合版信息';
                      controlRow.handleType = commonUtils.isEmpty(controlRow.handleType) ? 'update' : controlRow.handleType;
                      controlData[0]={...controlData,...controlRow};
                    }
                  });
                  addState.packData = packData;
                  addState.controlData = controlData;
                }
              }
            }
          }

          this.handleSaveState({ [`${name}Data`]: tableNewData, ...addState });
        } else { /* 主表赋值 */
          const changeValue = commonFunc.getAssignFieldValue(AssignField, dropdownData[filterDataIndex]);
          const masterNewData = { ...masterData, ...changeValue }; // 取赋值字段
          const sFieldName = sName;
          const addState = {};
          if (sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName' || sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName' || sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName' || sFieldName === 'tDeliverDate') {
            const slaveDataNew = [];
            for (const item of slaveData) {
              let tableDataRow = ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') && (sModelsType.includes('materialsStock/productionmaterialsadjust'))) ?
                { ...item } : { ...item, [sFieldName]: changeValue[sFieldName] };
              if (sFieldName === 'sCustomerId' || sFieldName === 'sCustomerNo' || sFieldName === 'sCustomerName' || sFieldName === 'sSupplyId' || sFieldName === 'sSupplyNo' || sFieldName === 'sSupplyName') {
                tableDataRow.sTaxId = changeValue.sTaxId;
                tableDataRow.sTaxNo = changeValue.sTaxNo;
                tableDataRow.sTaxName = changeValue.sTaxName;
                tableDataRow.dTaxRate = changeValue.dTaxRate;
                tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
                const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';

                tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'sTaxId', masterData, tableDataRow);
                let dMaterialsMoney = '';
                if (sModelsType.includes('outside/')) { /* 工序发外 */
                  let sComputeId = '';
                  const sSupplyId = changeValue.sSupplyId;
                  const sProcessId = tableDataRow.sProcessId;
                  /* 根据客户id,工序id获取公式ID */
                  if (commonUtils.isNotEmptyObject(sSupplyId) && commonUtils.isNotEmptyObject(sProcessId)) {
                    sComputeId = await commonBusiness.getOutSideProcessFormula({
                      token, sModelsId, sSupplyId, sProcessId,
                    });
                    if (commonUtils.isNotEmptyObject(sComputeId)) {
                      dMaterialsMoney = await commonBusiness.getFormulaValue({
                        token, sModelsId, masterData, tableDataRow, sComputeId,
                      });
                      tableDataRow.dMaterialsMoney = dMaterialsMoney;
                      tableDataRow = commonBusiness.getCalculateMoney(app, masterData, tableDataRow, 'Materials');
                    }
                  }
                }
              }
              if ((sFieldName === 'sWareHouseId' || sFieldName === 'sWareHouseNo' || sFieldName === 'sWareHouseName') && (!sModelsType.includes('materialsStock/productionmaterialsadjust'))) {
                tableDataRow.sWareHouseId = changeValue.sWareHouseId;
                tableDataRow.sWareHouseNo = changeValue.sWareHouseNo;
                tableDataRow.sWareHouseName = changeValue.sWareHouseName;
                tableDataRow.sLocationId = changeValue.sLocationId;
                tableDataRow.sLocationNo = changeValue.sLocationNo;
                tableDataRow.sLocationName = changeValue.sLocationName;
                tableDataRow.sWareHouseLocationId = changeValue.sWareHouseLocationId;
                tableDataRow.sWareHouseLocationNo = changeValue.sWareHouseLocationNo;
                tableDataRow.sWareHouseLocationName = changeValue.sWareHouseLocationName;
                tableDataRow.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? 'update' : tableDataRow.handleType;
              }
              slaveDataNew.push(tableDataRow);
            }
            addState.slaveData = slaveDataNew;
            // this.props.onSaveState({ slaveData: slaveDataNew });
          }
          this.handleSaveState({ [`${name}Data`]: masterNewData, ...addState });
        }
      }
    }

    /**   树选择   */
    handleTreeSelect = (name, selectedKeys, e) => {
      const { treeNode } = e.node.props;
      this.handleSaveState({ [`${name}SelectedKeys`]: selectedKeys, [`${name}TreeNode`]: treeNode });
    };
    /* 通用弹窗 选择数据带回窗体 */
    handleSelectCommonPopup = (currentPaneName, selectConfig, selectData, tbName, isWait) => {
      // 如果配置了sAfterClickInstruct，先走指令集再走原逻辑，否值直接走原逻辑
      const { sAfterClickInstruct, showName } = selectConfig;
      if (sAfterClickInstruct) {
        instructSet({
          ...this.props,
          ...this.state,
          slavepupData: selectData,
          btnConfig: { sInstruct: sAfterClickInstruct, showName },
          onSaveState: this.handleSaveState,
          callback: () => {
            this.handleSelectCommonPopupNew(currentPaneName, selectConfig, selectData, tbName, isWait);
          }
        })
      } else {
        if(typeof isWait === 'boolean' && isWait) {
          return  this.handleSelectCommonPopupNew(currentPaneName, selectConfig, selectData, tbName, isWait);
        } else {
          this.handleSelectCommonPopupNew(currentPaneName, selectConfig, selectData, tbName);
        }
      }
    };

    handleSelectCommonPopupNew = (currentPaneName, selectConfig, selectData, tbName, isWait) => {
      const {
        [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData,
        controlData, controlSelectedRowKeys, sModelsId,
      } = this.state;
      const { sOnChangeInstruct, showName } = selectConfig;
      const type = 'change';
      const onChangeNew = commonUtils.convertStrToObj(sOnChangeInstruct, {});
      const instructType = onChangeNew[type];
      // 回弹字段直接设置单价
      async function setProductPrice(tableDataRowAdd, item, props) {
        if (selectConfig.sName === 'sProductId' || selectConfig.sName === 'sProductName' || selectConfig.sName === 'sProductNo') {
          const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
          const { sCustomerId } = masterData; /* 增加客户id参数 */
          const value = {
            sProName: 'Sp_Cashier_GetProductPrice',
            paramsMap: {
              sProductGuid: item.sId,
              sCustomerId,
            },
          };
          const returnData = (await commonServices.postValueService(props.app.token, value, url)).data;
          if (returnData.code === 1) {
            tableDataRowAdd.dNProductPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice; /* 产品单价 */
            const dProofingMoney = commonUtils.convertToNum(tableDataRowAdd.dProofingMoney); /* 打样金额 */
            const dPlateMoney = commonUtils.convertToNum(tableDataRowAdd.dPlateMoney); /* 制版金额 */
            const dKnifeMouldMoney = commonUtils.convertToNum(tableDataRowAdd.dKnifeMouldMoney); /* 刀模金额 */
            const dProductQty = commonUtils.convertToNum(tableDataRowAdd.dProductQty); /* 数量 */
            const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
            const { dNetPrice } = props.app.decimals;
            if (dProductQty === 0 || (dProofingMoney === 0 && dPlateMoney === 0 && dKnifeMouldMoney === 0)) {
              const dProductForeignPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice;
              tableDataRowAdd.dProductForeignPrice = dProductForeignPrice;
              tableDataRowAdd.dProductPrice = commonUtils.convertFixNum(dProductForeignPrice * dCurrencyRate, dNetPrice);
            }
          }
          return tableDataRowAdd;
        } else {
          return tableDataRowAdd;
        }
      }
      let { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination = {} } = this.state;
      let addReturn  = {};
      if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData)) {
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0])  ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1; /* 控制表 */
        selectData.forEach(async (item, index) => {
          const newCopyTo = {};
          newCopyTo.master = masterData;
          const sName = selectConfig.sKeyUpFilter; /* 将后台配置筛选字段作为 列字段 */
          let sValue = '';
          if (iIndex > -1) {
            newCopyTo.slave = tableData[iIndex];
            sValue = tableData[iIndex][sName];
          }
          if (iControlIndex > -1) {
            newCopyTo.control = controlData[iControlIndex];
          }
          /* 第一条数据若字段值为空或者只有一条数据时 则添加到该行 否则新增一行 */
          if (selectData.length === 1 || (index === 0 && commonUtils.isEmptyObject(sValue))) {
            let tableDataRow = {}; // 取默认值
            if (tbName === 'master') {
              tableDataRow = { ...tableData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
              tableData = tableDataRow;
              tableData.handleType = commonUtils.isEmpty(tableData.handleType) ? 'update' : tableData.handleType;
              if (instructType) {
                this.handleExecInstructSet({
                  type,
                  sInstruct: instructType,
                  showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`,
                });
              }

            } else {
              tableDataRow = { ...tableData[iIndex] };
              if (tbName === 'slave') {
                tableDataRow.sSqlConditionId = tableDataRow.sId;
              }
              tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段

              tableData[iIndex] = tableDataRow;
              tableData[iIndex].handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
              tableData[iIndex] = await setProductPrice(tableData[iIndex], item, this.props);
              if (instructType) {
                this.handleExecInstructSet({
                  type,
                  sInstruct: instructType,
                  showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`,
                });
              }
            }
          } else {
            let tableDataRowAdd = this.handleTableAdd(tbName, true);
            if (tbName === 'slave') {
              tableDataRowAdd.sSqlConditionId = tableDataRowAdd.sId;
            }
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
            tableDataRowAdd = await setProductPrice(tableDataRowAdd, item, this.props);
            if (instructType) {
              this.handleExecInstructSet({
                type,
                sInstruct: instructType,
                showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`,
              });
            }
            tableData.push(tableDataRowAdd);
          }

          pagination = {
            ...pagination,
            total: tableData.length,
          }

          if (tbName === 'master') {
            const result = this.handleMasterChange(tbName, selectConfig.sName, {}, null, null, true, tableData);
            tableData = result.masterData;
          }

          const addState = { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination };
          if(typeof isWait !== 'boolean') {
            this.handleSaveState(addState);
          }

        });
        if(typeof isWait === 'boolean' && isWait) {
          addReturn = { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination };
          return addReturn;
        }
      }
    };


    /* 通用弹窗 将选择数据汇总求和带回窗体 */
    handleSelectCommonPopupSum = (currentPaneName, selectConfig, selectData, tbName) => {
      const {
        [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData,
        controlData, controlSelectedRowKeys, sModelsId,
      } = this.state;
      // 回弹字段直接设置单价
      async function setProductPrice(tableDataRowAdd, item, props) {
        if (selectConfig.sName === 'sProductId' || selectConfig.sName === 'sProductName' || selectConfig.sName === 'sProductNo') {
          const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
          const { sCustomerId } = masterData; /* 增加客户id参数 */
          const value = {
            sProName: 'Sp_Cashier_GetProductPrice',
            paramsMap: {
              sProductGuid: item.sId,
              sCustomerId,
            },
          };
          const returnData = (await commonServices.postValueService(props.app.token, value, url)).data;
          if (returnData.code === 1) {
            tableDataRowAdd.dNProductPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice; /* 产品单价 */
            const dProofingMoney = commonUtils.convertToNum(tableDataRowAdd.dProofingMoney); /* 打样金额 */
            const dPlateMoney = commonUtils.convertToNum(tableDataRowAdd.dPlateMoney); /* 制版金额 */
            const dKnifeMouldMoney = commonUtils.convertToNum(tableDataRowAdd.dKnifeMouldMoney); /* 刀模金额 */
            const dProductQty = commonUtils.convertToNum(tableDataRowAdd.dProductQty); /* 数量 */
            const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(masterData.dCurrencyRate); /* 汇率 */
            const { dNetPrice } = props.app.decimals;
            if (dProductQty === 0 || (dProofingMoney === 0 && dPlateMoney === 0 && dKnifeMouldMoney === 0)) {
              const dProductForeignPrice = returnData.dataset.rows[0].dataSet.outData[0].dPrice;
              tableDataRowAdd.dProductForeignPrice = dProductForeignPrice;
              tableDataRowAdd.dProductPrice = commonUtils.convertFixNum(dProductForeignPrice * dCurrencyRate, dNetPrice);
            }
          }
          return tableDataRowAdd;
        } else {
          return tableDataRowAdd;
        }
      }
      let { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination = {} } = this.state;
      if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData)) {
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0])  ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        const iControlIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1; /* 控制表 */
        let dModifyProductQty = 0;
        const jsonData = [];
        let jsonStr = '';
        selectData.forEach((item, index) => {
          const newCopyTo = {};
          newCopyTo.master = masterData;
          const sName = selectConfig.sKeyUpFilter; /* 将后台配置筛选字段作为 列字段 */
          let sValue = '';
          if (iIndex > -1) {
            newCopyTo.slave = tableData[iIndex];
            sValue = tableData[iIndex][sName];
          }
          if (iControlIndex > -1) {
            newCopyTo.control = controlData[iControlIndex];
          }
          /* 第一条数据若字段值为空或者只有一条数据时 则添加到该行 否则新增一行 */
          if (false) {
            let tableDataRow = {}; // 取默认值
            if (tbName === 'master') {
              tableDataRow = { ...tableData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
              tableData = tableDataRow;
              tableData.handleType = commonUtils.isEmpty(tableData.handleType) ? 'update' : tableData.handleType;
            } else {
              dProductQty += commonUtils.isNull(item.dProductQty, 0); /* 赠送数量叠加 */
              tableDataRow = { ...tableData[iIndex], ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
              tableData[iIndex] = tableDataRow;
              tableData[iIndex].handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
              // tableData[iIndex] = await setProductPrice(tableData[iIndex], item, this.props);
            }
          } else {
            let tableDataRowAdd = this.handleTableAdd(tbName, true);
            /* 叠加求和 */
            dModifyProductQty += commonUtils.isNull(item.dModifyProductQty, 0); /* 赠送数量叠加 */
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
            // tableDataRowAdd = await setProductPrice(tableDataRowAdd, item, this.props);
            // tableData.push(tableDataRowAdd);
          }

          if(selectConfig.sControlName && selectConfig.sControlName.includes('dStockUpConsumeQty')) { /* 备货消耗数 特殊处理 */
            const obj ={};
            obj.sSlaveId = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
            obj.dModifyProductQty = commonUtils.isNotEmptyNumber(item.dModifyProductQty) ? item.dModifyProductQty : 0;
            jsonData.push(obj);
          }

          pagination = {
            ...pagination,
            total: tableData.length,
          }

          if (tbName === 'master') {
            const result = this.handleMasterChange(tbName, selectConfig.sName, {}, null, null, true, tableData);
            tableData = result.masterData;
          }
        });
        const addState = {};
        if (selectConfig.sControlName && selectConfig.sControlName.includes('sumeQty')) {
          /* 找到汇总字段 */
          const sFileSumName = selectConfig.sAssignField && selectConfig.sAssignField.split(':')[0];
          addState[sFileSumName] = dModifyProductQty;
          addState.dRavailableQty = dModifyProductQty + tableData[iIndex].dConsumeQty;
          addState.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? 'update' : tableData[iIndex].handleType;
          if(commonUtils.isNotEmptyArr(jsonData)) {
            jsonStr = commonUtils.isNotEmptyArr(jsonData) ? JSON.stringify(jsonData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
            addState.sStockUpConsume = jsonStr;
          }
          tableData[iIndex] = { ...tableData[iIndex], ...addState };
        }
        this.handleSaveState({ [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination });
      }
    };

    /* 接口数据带入数据 */
    handleSelectDialog = (name, selectConfig, selectData, tbName) =>{
      const {
        [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, sModelsId, slaveNameList, allDataList, masterConfig,
      } = this.state;
      let { masterData } = this.state;
      const addState = {};
      let { [`${tbName}Data`]: tableData } = this.state;
      if (commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectData)) {
        const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) && commonUtils.isNotEmptyObject(tableSelectedRowKeys[0])  ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1;
        let sControlNameMatchList = [];
        if (tbName === 'master') {
          sControlNameMatchList = ['BtnSendDialog', 'BtnSendDialog.master'];
        } else {
          sControlNameMatchList = [`BtnSendDialog.${tbName}`];
        }

        const btnConfig = masterConfig.gdsconfigformslave.find(item =>
          item.sControlName &&
          sControlNameMatchList.includes(item.sControlName)) || {}

        selectData.forEach(async (item, index) => {
          let dataMap = {};
          /* 通过主键 找到对应的数据集 对应铺数据 */
          if(commonUtils.isNotEmptyArr(allDataList)) {
            for (const key of Object.keys(allDataList)) {
              let targetKey = commonUtils.isNotEmptyObject(item.sSlaveId) ? item.sSlaveId : item.sId;
              targetKey = 'master-'+targetKey;
              if(key && key === targetKey) {
                dataMap = allDataList[key];
                if (commonUtils.isNotEmptyArr(slaveNameList) && commonUtils.isNotEmptyArr(dataMap)) {
                  slaveNameList.forEach((name) => {
                    const tableConfig = this.state[name +'Config']; /* 动态配置 */
                    let tableData = [];
                    if(commonUtils.isNotEmptyObject(tableConfig)) {
                      tableData = dataMap[name +'-'+ tableConfig.sTbName]; /* 动态配置 */
                      if(commonUtils.isNotEmptyObject(tableData)) {
                        const newCopyTo = {};
                        newCopyTo.master = masterData;
                        const tableNewData = JSON.parse(JSON.stringify(tableData));
                        if(name === 'master') {
                          masterData = { ...masterData, ...commonFunc.getAssignFieldValue(btnConfig.sAssignField, tableNewData, newCopyTo) }; // 取赋值字段
                          addState.masterData = masterData;
                        } else {
                          const btnTableName = btnConfig.sControlName +'.'+ name;
                          const btnTableConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => (item.sControlName === btnTableName))) ?
                            masterConfig.gdsconfigformslave.filter(item => (item.sControlName === btnTableName))[0] : {};// sButtonEnabled  sButtonParam

                          const newData = [];
                          tableNewData.forEach((child) => {
                            let  newRow ={};
                            if(commonUtils.isNotEmptyObject(btnTableConfig) && btnTableConfig.sAssignField){
                              newRow = { ...child, ...commonFunc.getAssignFieldValue(btnTableConfig.sAssignField, child, newCopyTo) }; // 取赋值字段
                            }else {
                              newRow = child;
                            }
                            newRow = {
                              ...newRow,
                              handleType: 'add',
                              sId: commonUtils.createSid(),
                              sParentId: masterData.sId
                            };
                            newData.push(newRow);
                          });
                          addState[name +'Data'] = newData;
                        }

                      }
                    }

                  });
                }

              }

            }
          }
        });
        console.log('确定后数据:', addState);
        this.handleSaveState({ ...addState });
      }

    }

    /* 自定义复制从窗体 选择数据带回窗体 */
    handleCopyFromSelect = (name, selectConfig, selectData) => {
      const { sModelsType } = this.state;
      let { masterData, slaveData } = this.state;
      const addState = {};
      if (commonUtils.isNotEmptyArr(selectData)) {
        const newCopyTo = {};
        newCopyTo.master = masterData;
        selectData.forEach((item) => {
          if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes('onlyMaster')) { /* 单主表调用复制从数据 */
            masterData = { ...masterData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
            masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? 'update' : masterData.handleType;
            addState.masterData = masterData;
          } else { /* 从表调用复制从数据 */
            if (commonUtils.isEmptyArr(slaveData)) {
              slaveData = [];
            }
            let tableDataRowAdd = this.handleTableAdd('slave', true);
            tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
            slaveData.push(tableDataRowAdd);
            addState.slaveData = slaveData;
          }
        });
      }
      addState.copyFromChooseVisible = false;
      this.handleSaveState({ ...addState });
    };


    handelControlFieldVisible = (name, configData, tableData) => {
      const addState = {};
      /* 获取主表数据时表字段数据根据条件控制 本表或其他表格字段的显示与隐藏功能 */
      if (name === 'master' && commonUtils.isNotEmptyObject(configData) && commonUtils.isNotEmptyObject(tableData)) {
        const masterConfig = configData;
        const iConfigIndex = masterConfig.gdsconfigformslave.findIndex(item => commonUtils.isNotEmptyObject(item.sButtonEnabled));
        if (iConfigIndex > -1) {
          const sFiledConfig = masterConfig.gdsconfigformslave[iConfigIndex];
          if (commonUtils.isNotEmptyObject(sFiledConfig)) {
            const tableDataRow = tableData;
            const sRulesJson = sFiledConfig.sButtonEnabled;
            if (commonUtils.isNotEmptyObject(sRulesJson) && commonUtils.isJSON(sRulesJson)) {
              const sRulesObjArr = JSON.parse(sRulesJson);
              if (Array.isArray(sRulesObjArr) && commonUtils.isNotEmptyArr(sRulesObjArr)) {
                sRulesObjArr.forEach((sRulesObj) => {
                  const {
                    showColumn, hideColumn, condition, tbName, sConfigName,
                  } = sRulesObj;
                  /* 主表单表字段根据条件控制 其他字段的显示与隐藏 */
                  if (commonUtils.isEmptyObject(tbName)) {
                    if (commonUtils.isNotEmptyArr(condition)) {
                      let flag = false;
                      for (const item of condition) {
                        const {
                          bFilterName, bFilterCondition, bFilterValue,
                        } = item;
                        if (bFilterCondition === '>') {
                          if (tableDataRow[bFilterName] > bFilterValue) {
                            flag = true;
                          }
                        } else if (bFilterCondition === '=') {
                          if (tableDataRow[bFilterName] === bFilterValue) {
                            flag = true;
                          }
                        } else if (bFilterCondition === '<') {
                          if (tableDataRow[bFilterName] < bFilterValue) {
                            flag = true;
                          }
                        }
                      }
                      if (flag) {
                        if (commonUtils.isNotEmptyArr(showColumn)) {
                          for (const column of showColumn) {
                            const iShowIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column);
                            if (iShowIndex > -1) {
                              const sFiledObj = masterConfig.gdsconfigformslave[iShowIndex];
                              if (commonUtils.isNotEmptyObject(sFiledObj)) {
                                if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') {
                                  masterConfig.gdsconfigformslave[iShowIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */
                                } else {
                                  masterConfig.gdsconfigformslave[iShowIndex].bVisible = true;
                                }
                              }
                            }
                          }
                        }
                        if (commonUtils.isNotEmptyArr(hideColumn)) {
                          for (const column of hideColumn) {
                            const iHideIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === column);
                            if (iHideIndex > -1) {
                              if (commonUtils.isNotEmptyObject(sConfigName) && sConfigName === 'bControl') {
                                masterConfig.gdsconfigformslave[iHideIndex].bControl = true; /* 控制字段bControl的显示与隐藏 */
                              } else {
                                masterConfig.gdsconfigformslave[iHideIndex].bVisible = false;
                              }
                            }
                          }
                        }
                        addState.masterConfig = masterConfig;
                      }
                    }
                  } else { /* 主表字段根据条件控制 其他表格字段的显示与隐藏 */
                    const { [`${tbName}Config`]: tableConfig } = this.state;
                    // const { controlConfig: tableConfig } = this.state;
                    if (commonUtils.isNotEmptyObject(tableConfig)) {
                      if (commonUtils.isNotEmptyArr(condition)) {
                        let flag = false;
                        for (const item of condition) {
                          const {
                            bFilterName, bFilterCondition, bFilterValue,
                          } = item;
                          if (bFilterCondition === '>') {
                            if (tableDataRow[bFilterName] > bFilterValue) {
                              flag = true;
                            }
                          } else if (bFilterCondition === '=') {
                            if (tableDataRow[bFilterName] === bFilterValue) {
                              flag = true;
                            }
                          } else if (bFilterCondition === '<') {
                            if (tableDataRow[bFilterName] < bFilterValue) {
                              flag = true;
                            }
                          }
                        }
                        if (flag) {
                          if (commonUtils.isNotEmptyArr(showColumn)) {
                            for (const column of showColumn) {
                              const iShowIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column);
                              if (iShowIndex > -1) {
                                const sFiledObj = tableConfig.gdsconfigformslave[iShowIndex];
                                if (commonUtils.isNotEmptyObject(sFiledObj)) {
                                  tableConfig.gdsconfigformslave[iShowIndex].bVisible = true;
                                }
                              }
                            }
                          }
                          if (commonUtils.isNotEmptyArr(hideColumn)) {
                            for (const column of hideColumn) {
                              const iHideIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === column);
                              if (iHideIndex > -1) {
                                const sFiledObj = tableConfig.gdsconfigformslave[iHideIndex];
                                if (commonUtils.isNotEmptyObject(sFiledObj)) {
                                  tableConfig.gdsconfigformslave[iHideIndex].bVisible = false;
                                }
                              }
                            }
                          }
                          if (commonUtils.isNotEmptyObject(tableConfig)) {
                            const tableColumn = commonFunc.getHeaderConfig(tableConfig);
                            // addState.masterConfig = masterConfig;
                            // addState.controlConfig = tableConfig; /* 表格配置塞到addState中 */
                            // addState.controlColumn = tbColumn;
                            addState[`${tbName}Config`] = tableConfig;
                            addState[`${tbName}Column`] = tableColumn;
                          }
                        }
                      }
                    }
                  }
                });
              }
            }
          }
        }
      }
      return addState;
    }

    /* 下拉多选离开事件 */
    handleTableBlur = async (name, sFileName, record, tableConfig, other) => {
      const { sModelsId, app } = this.props;
      const {  controlData, slaveConfig,[`${name}Data`]: tableData , [`${name}Config`]: tempConfig } = this.state;
      let { slaveData: slaveDataOld, masterData, slaveDelData, } = this.state;
      const addState = {};
      if(commonUtils.isEmptyArr(slaveDelData)) {
        slaveDelData = [];
      }
      if (sFileName === 'sPartsNameNew') {
        if(commonUtils.isNotEmptyArr(controlData)) {
          /* 离开时 把sPartsNameNewId数据挂载到sControlParentId */
          let iIndex = controlData.findIndex(item => item.sId === record.sId);
          if(iIndex === -1) {
            if(record.sId && record.sId.split('-').length > 1) {
              iIndex = controlData.findIndex(item => item.sId === record.sId.split('-')[0]);
            }
          }
          if (iIndex > -1) {
            addState.sControlParentId = controlData[iIndex].sPartsNameNewId;
            if(commonUtils.isNotEmptyObject(controlData[iIndex].sPartsNameNewId)) {
              controlData[iIndex] = {...controlData[iIndex], ...addState};
              this.props.onSaveState({ controlData: controlData });
            }
          }
        }
      } else if (tableConfig.sDropDownType === 'movesql') { /* 通用字段离开调下拉事件 */
        let slaveRow = record;
        const sqlDropDownData = await this.getSqlDropDownData(sModelsId, name, tableConfig, slaveRow);
        const dDropDownData = sqlDropDownData.dropDownData;
        const iIndex = tableData.findIndex(item => item.sId === record.sId);
        if (commonUtils.isNotEmptyArr(dDropDownData) && iIndex > -1) {
          slaveRow = { ...slaveRow, ...commonFunc.getAssignFieldValue(tableConfig.sAssignField, dDropDownData[0]) }; // 取赋值字段
          slaveRow.handleType = commonUtils.isEmpty(slaveRow.handleType) ? 'update' : slaveRow.handleType;
          const sButtonParam = tableConfig.sButtonParam; /* 设置多级联动 */
          if(commonUtils.isNotEmptyObject(sButtonParam)) {
            let sLinkFieldName = 'dMaterialsPrice';
            if (commonUtils.isJSON(sButtonParam)) { /* 按钮条件 */
              const linkObj = JSON.parse(sButtonParam); /* 联动配置 */
              let models = 'Materials';
              if (linkObj.linkMaterials) {
                sLinkFieldName = linkObj.linkMaterials;
                models = 'Materials';
              } else if (linkObj.linkProduct) {
                sLinkFieldName = linkObj.linkProduct;
                models = 'Product';
              }
              slaveRow =  commonBusiness.getCalculateAllMoney(app, models, sLinkFieldName, masterData, slaveRow);
            }
          }

          tableData[iIndex] = { ...tableData[iIndex] , ...slaveRow };
          this.setState({ ...addState });
        }
      } else if(commonUtils.isNotEmptyObject(tableConfig) && commonUtils.isNotEmptyObject(tableConfig.sButtonParam)) {
        let slaveNewData = [];
        const allConfig = { slaveConfig };
        // console.log('sTmpInfoConfigArr', sTmpInfoConfigArr);
        const sTmpInfoConfig = tableConfig;
        const sButtonParam = tableConfig.sButtonParam;
        const btn = commonUtils.isNotEmptyObject(sButtonParam) && commonUtils.isJSON(sButtonParam)?  JSON.parse(sButtonParam) : {};;
        const sProName = commonUtils.isNotEmptyObject(btn) ?  btn.sproName : '';
        const sTmpInfoBySqlBtnName = commonUtils.isNotEmptyObject(btn) ? btn.sControlName : '';
        const sActiveKey = sTmpInfoConfig.sActiveKey;
        if (commonUtils.isNotEmptyObject(sTmpInfoConfig)) {
          if (commonUtils.isEmptyObject(sTmpInfoBySqlBtnName)) {
            const newCopyTo = {};
            newCopyTo.master = masterData;
            // newCopyTo.slave = commonUtils.isEmpty(slaveData) ? [] : slaveData[0];
            // const sRowData = copyTo.slaveData;
            const sRowData = masterData;
            const value = { sProName, sProInParam: JSON.stringify({ params: sRowData }) };
            if (other?.iFlag === 1) {
              value.iFlag = 1;
            }
            const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
            const dataReturn = (await commonServices.postValueService(app.token, value, url)).data;
            if (dataReturn.code === 1) {
              if (commonUtils.isNotEmptyArr(slaveDataOld)) {
                slaveDataOld.forEach((item) => {
                  item.handleType = 'del';
                  slaveDelData.push(item);
                });
                addState.slaveDelData = slaveDelData;
              }
              const returnData = dataReturn.dataset.rows[0];
              const slaveReturn = returnData.dataSet.proData;
              if (commonUtils.isNotEmptyArr(slaveReturn)) {
                slaveReturn.forEach((slaveItem) => {
                  newCopyTo.slave = slaveItem;
                  let slaveRow = commonFunc.getDefaultData(allConfig.slaveConfig, newCopyTo); // 取默认值
                  // if (salveDetailAssignField) {
                  //   slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveDetailAssignField, copyTo.masterData, newCopyTo)};
                  // } else if (salveAssignField) {
                  //   slaveRow = {...slaveRow, ...commonFunc.getAssignFieldValue(salveAssignField, slaveItem, newCopyTo)}; // 取赋值字段
                  // }
                  slaveRow = { ...slaveRow, ...slaveItem };
                  slaveRow.handleType = 'add';
                  slaveRow.sId = commonUtils.createSid();
                  slaveRow.sParentId = masterData.sId;
                  slaveNewData.push(slaveRow);
                });
              }
              addState.slaveData = slaveNewData;
              this.setState({ ...addState });
            } else {
              this.getServiceError({ ...dataReturn, fn: () => this.handleTableBlur(name, sFileName, record, tableConfig, { iFlag: 1 }) });
            }
          } else if(sTmpInfoBySqlBtnName.includes('sTmpInfoBySql')) { /* 走TmpInfo逻辑 */
            const newCopyTo = {};
            newCopyTo.master = masterData;
            /* 找到自定义TempInfo配置 */

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

                    }else if(sTmpInfoBySqlBtnName.includes('_del')) { /* 替换 根据对应字段对比 相同的不管 不同的插入  */
                      /* 对应字段 */
                      oldData.forEach((child) => {
                        child.handleType ='del';
                        oldDelData.push(child);
                      });
                      allReturnMap[sDelName] = oldDelData;
                      oldData = [];
                      const keyData = returnData[key];
                      if(commonUtils.isNotEmptyArr(keyData)) {
                        keyData.forEach((child) => {
                          const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111
                          tableRow.sId = commonUtils.createSid();
                          if (sName === 'slaveData' && !tableRow.sSqlConditionId) {
                            tableRow.sSqlConditionId = tableRow.sId;
                          }
                          tableRow.sParentId = masterData.sId;
                          tableRow.handleType = 'add';
                          oldData.push(tableRow);
                        });
                      }
                      allReturnMap[sName] = oldData;
                    } else if(sTmpInfoBySqlBtnName.includes('_update')) { /* 更新字段  */
                      const keyData = returnData[key];
                      if(commonUtils.isNotEmptyArr(keyData) && sActiveKeyNew) {
                        const [linkField, onchangeField] = sActiveKeyNew.split(',');
                        const tableName = key.split('_update')[0];
                        const { [`${tableName}Data`]: tableData = [] } = this.state;

                        for (let i = 0; i < keyData.length; i++) {
                          const child = keyData[i];
                          const tableDataFilter = tableData.filter(item => item[linkField] === child[linkField]);
                          for (let j = 0; j < tableDataFilter.length; j++) {
                            const item = tableDataFilter[j];
                            const iIndex = tableData.findIndex(row => row.sId === item.sId);
                            tableData[iIndex] = { ...item, ...child };
                            if (onchangeField && this.state.onEventDataChange) {
                              const { sId, [onchangeField]: fieldsValue } = tableData[iIndex];
                              window.tmpSlaveData = tableData;
                              tableData[iIndex] = await this.state.onEventDataChange('slave', onchangeField, { [onchangeField]: fieldsValue }, sId, [], true);
                              window.tmpSlaveData = null;
                            }
                          }
                        }
                        allReturnMap[`${tableName}Data`] = tableData;
                      }
                    } else {
                      allReturnMap[sName] = returnData[key];
                    }

                  }
                  if (commonUtils.isNotEmptyArr(allReturnMap.masterData) && Array.isArray(allReturnMap.masterData)) {
                    allReturnMap.masterData = allReturnMap.masterData[0];
                  }
                  this.setState({ ...allReturnMap });
                }
              } else {
                this.getServiceError(dataReturn);
              }
            }
          }
        } else {
          message.error('请正确配置自定义按钮！');
        }
      }
    };

    /**   通用下载    */
    handleDownload = (name, flag, tableSelectedRowKeys) => {
      const { sModelsId, app } = this.props;
      const {
        [`${name}Data`]: tableData } = this.state;
      if (tableSelectedRowKeys === undefined || tableSelectedRowKeys.length !== 1) {
        message.warn(commonFunc.showMessage(app.commonConst, 'selectedRowKeysNo'));/* 请先选择一条数据 */
        return;
      }
      const dataSelect = tableData.filter(item => item.sId === tableSelectedRowKeys[0]);
      const { token } = this.props.app;
      const { sPicturePath } = dataSelect[0];
      const urlPrint = `${commonConfig.file_host}file/download?sModelsId=${sModelsId}&token=${token}&savePathStr=${sPicturePath}`;
      window.open(urlPrint);
    };

    // 调用指令集
    handleExecInstructSet = (params) => {
      const { type, sInstruct, showName, callback } = params;
      instructSet({
        ...this.props,
        ...this.state,
        btnConfig: { sInstruct: JSON.stringify(sInstruct), showName },
        onSaveState: this.handleSaveState,
        callback
      })
    }

    /**
     * 色序反显
     * @returns
     */
    showCacheData = (isSColorSerialMemo, data, processSelectedRowId) => {
      if (isSColorSerialMemo && Array.isArray(data)) {
        const value = data.find(
          item => item && item.sId === processSelectedRowId
        );
        try {
          return {
            sMemoData: JSON.parse(value?.sColorSerialMemo || '[]'),
            isSColorSerialMemo,
          }
        } catch (error) {
          return {}
        }
      }
    }

    /**
     * 取消当前页面websocket 状态
     * @returns
     */
    handleSendSocketMessageProxy = (flag, showType, sId, sendTo, msgInfo, param) => {
      if (!['noAction'].includes(showType) || !['release'].includes(flag)) {
        return this.handleSendSocketMessage(flag, showType, sId, sendTo, msgInfo, param);
      }
      const { currentPane, userinfo } = this.props.app;
      const { copyTo } = currentPane;
      const { isNotEmptyObject, isNotEmptyArr } = commonUtils;
      if (isNotEmptyObject(copyTo)) {
        const {
          slaveData, srcFormRoute, copyOtherData, masterData, copyToDataSid,
        } = copyTo;
        const sIdArray = [...copyToDataSid || []];

        if (!currentPane?.checkedId) {
          if (isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('materialRequirementsPlanning')) { /* 物料需求计划用sWorkOrderMaterialId作为唯一键 */
            if (isNotEmptyArr(copyOtherData) && copyOtherData[0]?.name === 'detail' && isNotEmptyArr(copyOtherData[0]?.data)) {
              const slaveDetailData = copyOtherData[0].data;
              slaveDetailData.forEach((item) => {
                const redisKey = item.sWorkOrderMaterialId;
                sIdArray.push(redisKey);
              });
            } else { /* 变更单、采购申请单 */
              slaveData.forEach((item) => {
                const redisKey = item.sWorkOrderMaterialId;
                sIdArray.push(redisKey);
              });
            }
          }
        }

        if (isNotEmptyObject(masterData) &&
         isNotEmptyObject(masterData.sSrcSlaveId)) {
          sIdArray.push(masterData.sSrcSlaveId);
        }

        if (Array.isArray(slaveData)) {
          slaveData.forEach((item) => {
            const redisKey = item.sSlaveId;
            sIdArray.push(redisKey);
          });
        }

        const sId = [...new Set(sIdArray)].filter(Boolean).toString();
       this.handleSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
      }
      this.handleSendSocketMessage('release', 'noAction', currentPane?.checkedId || '', userinfo.sId, null, null);
      this.handleSendSocketMessage('release', 'noAction', currentPane?.formId || '', userinfo.sId, null, null);
    };

    render() {
      return (
        <div
          className='xlyCommonBase'
          style={{ height: '100%' }}
          ref={(ref) => { this.baseRef = ref; }}
        >
          <ChildComponent
            style={{ height: '100%' }}
            {...this.props}
            {...this.state}
            getSqlDropDownData={this.getSqlDropDownData}
            getSqlCondition={this.getSqlCondition}
            getServiceError={this.getServiceError}
            handleSqlDropDownNewRecord={this.handleSqlDropDownNewRecord}
            getFloatNum={this.getFloatNum}
            getDateFormat={this.getDateFormat}
            handleGetDataOne={this.handleGetDataOne}
            handleGetDataSet={this.handleGetDataSet}
            onGetDataOld={this.handleGetDataOld}
            handleGetTreeDataSet={this.handleGetTreeDataSet}
            onSaveState={this.handleSaveState}
            onChange={this.handleMasterChange}
            onDataChange={this.handleTableChange}
            onDataRowAdd={this.handleTableAdd}
            onDataRowDel={this.handleTableDel}
            onTableSelectRowChange={this.handleTableSelectRowChange}
            onViewClick={this.handleViewClick}
            onTabModalClick={this.handleTabModalClick}
            onQuickViewClick={this.handleQuickViewClick}
            handleSendSocketMessage={this.handleSendSocketMessageProxy}
            onRowMove={this.handleRowMove}
            onFilterDropDownData={this.handleFilterDropDownData}
            onTreeSelect={this.handleTreeSelect}
            onSelectCommonPopup={this.handleSelectCommonPopup}
            onSelectCommonPopupSum={this.handleSelectCommonPopupSum}
            onSelectDialog={this.handleSelectDialog}
            onCopyFromSelect={this.handleCopyFromSelect}
            onGetTableConfig={this.handleGetTableConfig}
            onDropDownBlur={this.handleTableBlur}
            onMergeMasterConfig={this.handleMergeMasterConfig}
            onMergeSlaveConfig={this.handleMergeSlaveConfig}
            onDataRowDownload={this.handleDownload}
            onExecInstructSet={this.handleExecInstructSet} // 调用指令集
            showCacheData={this.showCacheData}
          />
          <div style={{ display: 'none' }} >
            <CommonChangePageEvent  {...this.props} {...this.state} onSaveState={this.handleSaveState}/>
          </div>
        </div>
      );
    }
  };
};

const CommonChangePageEvent = (props) => {

  const { currentPageNo, currentId, masterData = {}, loading } = props;
  const { sId } = masterData;

  // 上一页下一页loading加载完成后，取消loading
  useEffect(() => {
    if (loading && currentPageNo && currentId && sId) {
      if (currentId === sId) {
        props.onSaveState({ loading: false });
      }
    }
  }, [currentPageNo, sId]);

  return null;
}
