/* eslint-disable */
/* eslint-disable spaced-comment,no-lonely-if */
/* eslint-disable prefer-destructuring */
import React, { Component } from "react";
import moment from "moment";
import lodash from "lodash";
import { Icon as LegacyIcon } from "@ant-design/compatible";
import { DownloadOutlined, DownOutlined, UploadOutlined } from "@ant-design/icons";
import { Menu, Spin, Input, Checkbox, Upload, Modal, Progress } from "antd-v4";
import { message } from "@/utils/common/message";
import commonConfig from "@/utils/config";
import * as commonUtils from "@/utils/utils";
import StatementInfo from "@/components/CommonElementEvent/StatementInfo";
import FilfileManageInfo from "@/components/CommonElementEvent/FilfileManageInfo";
import BatchPriceUpdate from "@/components/CommonElementEvent/BatchPriceUpdate";
import BatchNPriceUpdate from "@/components/CommonElementEvent/BatchNPriceUpdate"; /* 产品单价价格批量更新 */
import AffixMenu from "@/routes/common/AffixMenu";
import * as commonBusiness from "@/components/Common/commonBusiness";
import * as commonFunc from "@/components/Common/commonFunc";
import AntdDraggableModal from "@/components/Common/AntdDraggableModal";
import SlaveMemo from "@/components/Common/SlaveMemo";
import SlaveMemo1 from "@/components/Common/SlaveMemo1";
import * as commonServices from "@/services/services";
import BatchWorkListPriceUpdate from "@/components/CommonElementEvent/BatchWorkListPriceUpdate";
import CommonListSelect from "@/components/Common/CommonListSelect";
import EditorModal from "@/components/Common/EditorModal";
import styles from "./index.less";
import SvgIcon from "../../SvgIcon";
import CommonList from "@/components/Common/CommonList";
import instructSet from "@/components/Common/CommonInstructSet";
import PersonCenterAddFace from "@/components/Common/PersonCenter/PersonCenterAddFace";
import FileImposition from "@/components/Common/FileImposition";
import MakeUpPDF from "@/components/Common/MakeUpPDF";
import BoxDesignCompontent from "@/components/Common/BoxDesignCompontent";
const { SubMenu } = Menu;
const MenuItemGroup = Menu.ItemGroup;

let time;
const throttle = (fn, wtime) => {
  return (...arg) => {
    if (!time || Date.now() - time > wtime) {
      time = Date.now();
      fn(...arg);
    }
  };
};

class ToolBarComponent extends Component {
  /**   构造函数   */
  constructor(props) {
    super(props);
    this.state = {
      menuData: [] /* 导航工具栏 */,
      enabled: false,
      bCheck: false,
      bInvalid: false,
      reportData: [] /* 报表数据 */,
      reportSelectedRowKeys: [],
      inputChange: "",
      checked: false,
      checkedId: "",
      printData: [] /* 打印数据集 */,
    };
  }

  componentWillMount() {
    this.componentWillReceiveProps(this.props);
  }

  componentWillReceiveProps(nextProps) {
    const { masterConfig, gdsjurisdiction, report, masterData, app, menuChildData } = nextProps;
    let {
      searchUpDownData,
      enabled,
      bCheck,
      bInvalid,
      visibleStatement,
      visibleBatchPriceUpdate,
      visibleBatchNPriceUpdate,
      reportData,
      reportSelectedRowKeys,
    } = this.state;
    const btnShowData = [];
    commonConfig.btnData.forEach(item => {
      btnShowData.push({ ...item });
    });
    let menuData = [];

    if (commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isEmptyArr(menuData)) {
      const buttonConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === "" && item.showName !== "" && item.sControlName !== "");
      /** 筛选出显示的按钮 */
      buttonConfig.forEach(child => {
        const index = btnShowData.findIndex(item => item.sControlName === child.sControlName);
        if (
          child.bVisible &&
          child.sControlName.substring(0, 3) === "Btn" &&
          btnShowData.findIndex(item => item.sControlName === child.sControlName) === -1
        ) {
          child.iconName = "menu-unfold";
          if (child.sControlName === "BtnBatchExamine") {
            child.iconName = "check";
          }
          if (child.sControlName === "BtnBatchCancelExamine") {
            child.iconName = "rollback";
          }
          if (child.sControlName === "BtnUpload") {
            child.iconName = "upload";
          }
          if (child.sControlName === "BtnUploadicon") {
            child.iconName = "upload";
          }
          if (child.sControlName === "BtnUploadPic") {
            child.iconName = "upload";
          }
          if (child.sControlName === "BtnCalculation") {
            child.iconName = "calculator";
          }
          if (child.sControlName === "BtnAddBug") {
            child.iconName = "plus";
          }
          if (child.sControlName === "BtnAddTo") {
            child.iconName = "plus";
          }
          if (child.sControlName === "BtnSubmit") {
            child.iconName = "submit";
          }
          if (child.sControlName === "BtnSubmitCancel") {
            child.iconName = "submitCancel";
          }
          if (child.sControlName === "BtnBatchSubmit") {
            child.iconName = "batchSubmit";
          }
          if (child.sControlName === "BtnEventAdjust") {
            child.iconName = "batchSubmitCancel";
          }

          btnShowData.push(child);
        } else if (!child.bVisible && index > -1) {
          btnShowData.splice(index, 1);
        } else if (index > -1) {
          btnShowData[index].sColor = child.sColor;
          btnShowData[index].showName = child.showName;
          btnShowData[index].interface = commonUtils.isNotEmptyArr(child.interface) ? child.interface : []; /* 按钮接口参数 */
          btnShowData[index] = { ...child, ...btnShowData[index] };
        }
      });
      /** 根据权限，筛选出显示的按钮  */
      gdsjurisdiction.forEach(child => {
        const index = btnShowData.findIndex(item => item.sControlName === child.sAction);
        if (index > -1) {
          btnShowData.splice(index, 1);
        }
      });
      /* 管理员有重置按钮,非管理员无重置按钮 */
      const { sType } = app.userinfo;
      if (sType !== "sysadmin") {
        const index = btnShowData.findIndex(item => item.sControlName === "BtnResetpwd");
        if (index > -1) {
          btnShowData.splice(index, 1);
        }
      }
      /*  筛选出一级菜单    */
      menuData = btnShowData.filter(item => !item.sControlName.includes("."));
      /*  初始值的二级菜单    */
      // const secondMenu = btnShowData.filter(item => item.sControlName.includes('.'));
      /** 配置后匹配二级菜单 */
      menuData.forEach(menu => {
        menu.child = [];
        /** 匹配相应的子菜单 */
        const childData = btnShowData.filter(
          item => item.sControlName.startsWith(`${menu.sControlName}.`) && item.sControlName.split(".").length <= 2
        );
        if (menu.sControlName === "BtnPrint") {
          /*   打印的二级菜单集合   */
          const reportChild = [];
          if (commonUtils.isNotEmptyArr(report)) {
            for (const each of report) {
              reportChild.push({
                sControlName: `BtnPrint.${each.sId}`,
                showName: each.sReportName,
                disabled: false,
                sActiveId: each.sId,
                sId: each.sId,
              });
            }
          }
          menu.child.push(...reportChild);
        } else if (menu.sControlName === "BtnPrintCustomer" && commonUtils.isNotEmptyObject(menuChildData)) {
          const reportChild = [];
          if (commonUtils.isNotEmptyArr(menuChildData)) {
            for (const each of menuChildData) {
              reportChild.push({
                sControlName: `BtnPrintCus.${each.sId}`,
                showName: each.sReportName,
                disabled: false,
                sActiveId: each.sId,
                sId: each.sId,
              });
            }
          }
          menu.child.push(...reportChild);
        } else if (commonUtils.isNotEmptyArr(childData)) {
          childData.forEach(childTwo => {
            if (childTwo.sControlName === "BtnBsOperation.BtnUpCheck" || childTwo.sControlName === "BtnBsOperation.BtnDownCheck") {
              const childDataThree = btnShowData.filter(
                item => item.sControlName.startsWith(`${childTwo.sControlName}.`) && item.sControlName.split(".").length === 3
              );
              childTwo.child = childDataThree;
            }
          });
          menu.child.push(...childData);
        }
      });
    }

    /* 按照后台配置加载按钮顺序 */
    if (commonUtils.isNotEmptyArr(menuData)) {
      menuData = menuData.sort((item, item2) => item.iOrder - item2.iOrder);
    }

    if (enabled !== nextProps.enabled) {
      enabled = nextProps.enabled;
    }
    if (visibleStatement !== nextProps.visibleStatement) {
      visibleStatement = nextProps.visibleStatement;
    }
    if (visibleBatchPriceUpdate !== nextProps.visibleBatchPriceUpdate) {
      visibleBatchPriceUpdate = nextProps.visibleBatchPriceUpdate;
    }
    if (visibleBatchNPriceUpdate !== nextProps.visibleBatchNPriceUpdate) {
      visibleBatchNPriceUpdate = nextProps.visibleBatchNPriceUpdate;
    }
    if (reportData !== nextProps.reportData) {
      reportData = nextProps.reportData;
    }
    if (reportSelectedRowKeys !== nextProps.reportSelectedRowKeys) {
      reportSelectedRowKeys = nextProps.reportSelectedRowKeys;
    }
    if (commonUtils.isNotEmptyObject(masterData) && bCheck !== masterData.bCheck) {
      bCheck = masterData.bCheck;
    }
    if (commonUtils.isNotEmptyObject(masterData) && bInvalid !== masterData.bInvalid) {
      bInvalid = masterData.bInvalid;
    }
    if (JSON.stringify(searchUpDownData) !== JSON.stringify(nextProps.searchUpDownData)) {
      searchUpDownData = nextProps.searchUpDownData;
    }

    // 当前页面全部数据
    const allTableData = commonFunc.getAllTableData(nextProps);
    // 当前页面所有选中数据
    const allTableSelectedData = Object.keys(allTableData).reduce((result, tableName) => {
      const tableData = allTableData[tableName];
      if (!Array.isArray(tableData)) {
        result = {
          ...result,
          [tableName]: tableData,
        };
      } else {
        const { [`${tableName}SelectedRowKeys`]: selectedRowKeys = [] } = nextProps;
        result = {
          ...result,
          [tableName]: tableData.filter(item => selectedRowKeys.includes(item.sSlaveId) || selectedRowKeys.includes(item.sId)),
        };
      }
      return result;
    }, {});
    this.setState({
      menuData,
      searchUpDownData,
      enabled,
      bCheck,
      bInvalid,
      visibleStatement,
      visibleBatchPriceUpdate,
      visibleBatchNPriceUpdate,
      reportData,
      reportSelectedRowKeys,
      allTableSelectedData,
    });

    if (this.props.makeUpPDFRecord === undefined && nextProps.makeUpPDFRecord !== undefined) {
      this.setState({
        makeUpPDFRecord: nextProps.makeUpPDFRecord,
      }, () => {
        this.handleClick({ key: "BtnSendCombined" });
      });
    }
  }

  shouldComponentUpdate(nextProps, nextState) {
    const { masterConfig } = nextProps;
    const {
      menuData,
      searchUpDownData,
      enabled,
      bCheck,
      bInvalid,
      visibleStatement,
      visibleBatchPriceUpdate,
      visibleBatchNPriceUpdate,
      visibleBatchWorkListPriceUpdate,
      reportData,
      reportSelectedRowKeys,
    } = this.state;
    const { adDisabled } = this.props;
    return (
      masterConfig !== undefined &&
      Object.keys(masterConfig).length > 0 &&
      (JSON.stringify(menuData) !== JSON.stringify(nextState.menuData) ||
        JSON.stringify(masterConfig) !== JSON.stringify(nextState.masterConfig) ||
        JSON.stringify(searchUpDownData) !== JSON.stringify(nextState.searchUpDownData) ||
        JSON.stringify(reportData) !== JSON.stringify(nextState.initialReportData) ||
        JSON.stringify(reportSelectedRowKeys) !== JSON.stringify(nextState.reportSelectedRowKeys) ||
        enabled !== nextState.enabled ||
        bCheck !== nextState.bCheck ||
        visibleStatement !== nextState.visibleStatement ||
        visibleBatchPriceUpdate !== nextState.visibleBatchPriceUpdate ||
        visibleBatchNPriceUpdate !== nextState.visibleBatchNPriceUpdate ||
        visibleBatchWorkListPriceUpdate !== nextState.visibleBatchWorkListPriceUpdate ||
        bInvalid !== nextState.bInvalid ||
        adDisabled !== nextProps.adDisabled)
    );
  }
  componentDidUpdate(prevProps) {
    const { slaveSelectedRowKeys, slaveInfoSelectedRowKeys, slaveData, slaveInfoData, masterData } = prevProps;
    if (
      JSON.stringify(slaveData) !== JSON.stringify(this.props.slaveData) ||
      JSON.stringify(slaveInfoData) !== JSON.stringify(this.props.slaveInfoData) ||
      JSON.stringify(slaveSelectedRowKeys) !== JSON.stringify(this.props.slaveSelectedRowKeys) ||
      JSON.stringify(masterData) !== JSON.stringify(this.props.masterData) ||
      JSON.stringify(slaveInfoSelectedRowKeys) !== JSON.stringify(this.props.slaveInfoSelectedRowKeys)
    ) {
      this.handleBtnEnabled(this.props, false);
    }

    if (!this.btnSendDialogLoaded) {
      const { masterConfig = {} } = this.props;
      const { gdsconfigformslave = [] } = masterConfig;
      const sBtnSendDialogConfigList = gdsconfigformslave.filter(item => item.sControlName && item.sControlName.includes("BtnSendDialog"));
      if (location.pathname === "/indexPage/quotationPackTableTree" || (commonUtils.isNotEmptyArr(sBtnSendDialogConfigList) && !this.props.onToolBarBtnClick)) {
        this.btnSendDialogLoaded = true;
        this.props.onSaveState({
          onToolBarBtnClick: this.handleClick,
          sBtnSendDialogConfigList,
        });
      }
    }
  }
  /**   获取有三级菜单的父级菜单属性   */
  getMenuProps = (menu, type) => {
    const { iconName, showName: showNameOld, sIcon } = menu;
    const { menuStatus, bShown, showName: showNameNew } = this.getMenuStatus(menu);
    const showName = showNameNew || showNameOld;
    const obj = {};
    obj.key = menu.sControlName;
    obj.name = showName;
    obj.disabled = menuStatus;
    obj.style = bShown ? {} : { display: "none" };
    obj.className = this.getMenuStatus(menu) && this.props.billList === "billList" ? styles.toolBarSubDisabled : styles.toolBarSub;
    if (
      menu.sControlName !== undefined &&
      (menu.sControlName === "BtnBsOperation.BtnUpCheck" || menu.sControlName === "BtnBsOperation.BtnDownCheck")
    ) {
      obj.onMouseEnter = this.handleMouseEnter; /*   根据二级菜单获取三级数据   */
    }
    // if (menu.sControlName !== undefined && (menu.sControlName.indexOf('BtnBsOperation.BtnUpCheck') > -1 || menu.sControlName.indexOf('BtnBsOperation.BtnDownCheck') > -1) && menu.sControlName.split('.').length === 3) {
    //   obj.onMouseEnter = this.handleMouseEnter; /*   根据二级菜单获取三级数据   */
    // }
    obj["data-sactiveid"] = menu.sActiveId;
    if (type === "icon") {
      const imageDom = this.getImageDom(sIcon) || <SvgIcon className="toolbarIcon" iconClass={iconName} />;
      obj.title = (
        <span>
          {imageDom}
          {showName}
          <DownOutlined />
        </span>
      );
    } else if (type === "title") {
      obj.title = showName;
    } else if (type === "key" && commonUtils.isEmpty(menu.sControlName)) {
      obj.key = menu.sId;
    }
    return obj;
  };

  /**   获取父级菜单属性   */
  getMenuStatus = menu => {
    let bShown = true;

    // 如果配置了按钮自定义状态，走自定义逻辑
    const statusObj = this.getMenuStatusCostom(menu);
    const { bContinue, bContinueMenuStatus } = statusObj;
    if (!bContinue && !bContinueMenuStatus) {
      // 如果不在配置中，走默认逻辑
      return statusObj;
    } else if (bContinueMenuStatus) {
      // 如果只配置了show没有配置enabled，show取自定义结果，enabled走默认逻辑
      bShown = statusObj.bShown;
    }

    let { masterData, formRoute, enabled } = this.props;

    // 主表数据是当前表格已选中数据
    if (formRoute === "/indexPage/commonListLeft") {
      const { slaveSelectedData } = this.props;
      if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
        masterData = slaveSelectedData[0];
      }
    }

    const { sortEnabled } = this.props;
    const {  sUseInfo, adDisabled, sModelsType, masterConfig, activeKey, sModelsId } = this.props;

    if (commonUtils.isEmptyObject(masterData)) {
      masterData = {};
    }
    const { bInvalid, bSubmit } = masterData;
    let { bCheck, bNextCheck } = masterData;
    /* 是否有审核按钮 基础模块转换的commonNewBill复制到只需通过有无审核按钮判断 */
    const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName && item.sControlName.includes("BtnCheck"));
    let bBtnCheck = true;
    if (iIndex > -1) {
      bBtnCheck = true;
    } else {
      bBtnCheck = false;
    }
    if(commonUtils.isNotEmptyObject(sUseInfo)) {
      enabled = false;
    }
    if (location.pathname === "/indexPage/commonClassify") {
      /* 通用分类 若配置没有审核按钮 则默认bCheck不为空 */
      if (iIndex === -1) {
        bCheck = false;
      }
    }

    let disabledData = []; /* 置灰按钮集合 */
    if (adDisabled) {
      disabledData = ["BtnAdd", "BtnAddChild", "BtnUpd", "BtnDel", "BtnSave", "BtnCancel", "BtnSetPeriod"];
    } else if (!adDisabled) {
      if (!enabled) {
        if (bInvalid) {
          // 已作废
          disabledData = [
            "BtnUpd",
            "BtnDel",
            "BtnSave",
            "BtnCancel",
            "BtnExamine",
            "BtnCancelExamine",
            "BtnCopyTo",
            "BtnCopyFrom",
            "BtnBsOperation.BtnInvalid",
            "BtnInvalid",
          ];
        } else if (bCheck) {
          // 已审核
          if (!commonUtils.isEmpty(sModelsType) && sModelsType.includes("element/")) {
            if (sModelsType === "element/customerInfo") {
              const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnCheck");
              if (iIndex > -1) {
                disabledData = ["BtnDel", "BtnSave", "BtnCancel", "BtnExamine", "BtnCopyFrom", "BtnCancelInvalid", "BtnImport"]; //'BtnUpd',
              } else {
                disabledData = ["BtnSave", "BtnCancel", "BtnCancelExamine", "BtnCopyFrom", "BtnCancelInvalid"];
              }
            } else {
              disabledData = ["BtnSave", "BtnCancel", "BtnCancelExamine", "BtnCopyFrom", "BtnCancelInvalid"];
            }
          } else {
            /* 已审核查看状态 修改 删除 保存 取消 审核 复制从 取消作废置灰 */
            disabledData = ["BtnUpd", "BtnDel", "BtnSave", "BtnCancel", "BtnExamine", "BtnCopyFrom", "BtnCancelInvalid", "BtnImport"];
          }
        } else {
          /** 查看状态 修改 删除 保存 取消 审核 复制从置灰 */
          disabledData = ["BtnSave", "BtnCancel", "BtnCopy2Custom", "BtnCancelExamine", "BtnCopyTo", "BtnCopyFrom", "BtnCancelInvalid"];
          if (!commonUtils.isEmpty(sModelsType) && sModelsType.includes("element/")) {
            /* 除了客户信息，其他基础信息在查看状态状态下 复制到常亮 */
            disabledData = ["BtnSave", "BtnCancel", "BtnCancelExamine", "BtnCopyFrom", "BtnCancelInvalid"];
            if (sModelsType === "element/customerInfo") {
              const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnCheck");
              if (iIndex > -1) {
                disabledData = ["BtnSave", "BtnCancel", "BtnCancelExamine", "BtnCopyTo", "BtnCopyFrom", "BtnCancelInvalid"];
              }
            }
          }
        }
      } else {
        /* 修改状态 */
        if (sModelsType === "production/productionPlanInfo" || sModelsType === "productionMainPlan/productionMainPlan") {
          disabledData = [
            "BtnAdd",
            "BtnAddChild",
            "BtnUpd",
            "BtnDel",
            "BtnFirst",
            "BtnPrior",
            "BtnNext",
            "BtnLast",
            "BtnUpCheck",
            "BtnDownCheck",
            "BtnExamine",
            "BtnCancelExamine",
            "BtnCopyTo",
            "BtnBsOperation.BtnInvalid",
            "BtnBsOperation.BtnCancelInvalid",
            "BtnCancelInvalid",
            "BtnInvalid",
          ];
        } else {
          disabledData = [
            "BtnRefresh",
            "BtnAdd",
            "BtnInit",
            "BtnExportSql",
            "Btn",
            "BtnAddChild",
            "BtnUpd",
            "BtnDel",
            "BtnFirst",
            "BtnPrior",
            "BtnNext",
            "BtnLast",
            "BtnUpCheck",
            "BtnDownCheck",
            "BtnExamine",
            "BtnCancelExamine",
            "BtnCopyTo",
            "BtnBsOperation.BtnInvalid",
            "BtnBsOperation.BtnCancelInvalid",
            "BtnPrint",
            "BtnCancelInvalid",
            "BtnInvalid",
          ];
        }
      }
    }

    if (bSubmit) {
      // 提交后不能修改
      if (!disabledData.includes("BtnUpd")) {
        disabledData.push("BtnUpd");
      }
      if (!disabledData.includes("BtnDel")) {
        disabledData.push("BtnDel");
      }
      if (!disabledData.includes("BtnSave")) {
        disabledData.push("BtnSave");
      }
      if (!disabledData.includes("BtnEventCancel")) {
        disabledData.push("BtnEventCancel");
      }
      // 提交后提交按钮变灰
      if (!disabledData.includes("BtnSubmit")) {
        disabledData.push("BtnSubmit");
      }
      // 提交后取消提交按钮变亮
      if (disabledData.indexOf("BtnSubmitCancel") !== -1) {
        disabledData.splice(disabledData.indexOf("BtnSubmitCancel"), 1);
      }
    } else {
      // 未提交时取消提交按钮变灰
      if (!disabledData.includes("BtnSubmitCancel")) {
        disabledData.push("BtnSubmitCancel");
        disabledData.push("BtnEventOrder");
      }
    }

    // 修改或者审核后提交、取消提交按钮都变灰
    if (enabled || bCheck) {
      if (!disabledData.includes("BtnSubmit")) {
        disabledData.push("BtnSubmit");
      }
      if (!disabledData.includes("BtnSubmitCancel")) {
        disabledData.push("BtnSubmitCancel");
      }
    }
    if (bCheck) {
      /* 已审核状态下 审核按钮灰色 */
      if (!disabledData.includes("BtnEventOrder")) {
        disabledData.push("BtnEventOrder");
      }

      // if (!disabledData.includes('BtnEventSubmit')) {
      //   disabledData.push('BtnEventSubmit');
      // }
      // /* 已审核状态下 消审亮 */
      // if (disabledData.indexOf('BtnEventSubmitCancel') !== -1) {
      //   disabledData.splice(disabledData.indexOf('BtnEventSubmitCancel'), 1);
      // }

      /* 已审核状态下 驳回灰色 */
      // if (!disabledData.includes('BtnEventCancel')) {
      //   disabledData.push('BtnEventCancel');
      // }

      // if (!disabledData.includes('BtnBatchExamine')) {
      //   disabledData.push('BtnBatchExamine');
      // }
    }
    /* 未审核状态 ，审核按钮亮，销审按钮灰色 */
    if (!bCheck) {
      if (!disabledData.includes("BtnEventSubmitCancel")) {
        disabledData.push("BtnEventSubmitCancel");
      }
      if (!disabledData.includes("BtnBatchCancelExamine")) {
        disabledData.push("BtnBatchCancelExamine");
      }
    }

    /* 若下游已审核，则上游的消审按钮置灰  */
    if (bNextCheck) {
      if (!disabledData.includes("BtnEventSubmitCancel")) {
        disabledData.push("BtnEventSubmitCancel");
      }

      if (!disabledData.includes("BtnBatchCancelExamine")) {
        disabledData.push("BtnBatchCancelExamine");
      }
    }

    /*
      将按钮的sButtonParam中的b开头字段的值 与 主表中相同字段的值做对比
      值相同 代表审核通过 对应按钮置灰
    **/
    const sButtonParamBtn = masterConfig.gdsconfigformslave.filter(
      item => commonUtils.isNotEmptyStr(item.showName) && commonUtils.isNotEmptyStr(item.sControlName) && commonUtils.isNotEmptyStr(item.sButtonParam)
    );

    sButtonParamBtn.forEach(btn => {
      const { sButtonParam = {} } = commonUtils.convertStrToObj(btn.sButtonParam);
      const key = Object.keys(sButtonParam).find(item => item && item.substring(0, 1) === "b");
      if (key) {
        const bCheckCostom = masterData[key] === sButtonParam[key];
        if (bCheckCostom) {
          disabledData.push(btn.sControlName);
        }
      }
    });

    // 生产排程搜索时不可以上下移动
    if (sortEnabled === false) {
      if (sModelsType === "production/productionPlanInfo") {
        // disabledData.push('BtnSave');
      }
      disabledData.push("BtnRepairstartdate");
    }

    /* 通用上传按钮 除了新增,其他状态下都是亮的*/
    if (menu.sControlName === "BtnUpload") {
      const { handleType } = masterData;
      if (handleType === "add") {
        disabledData.push("BtnUpload");
      }
    }
    // 其它自定义按钮不在以上 不能操作数据里
    if (menu.disabled) {
      disabledData.push(menu.sControlName);
    }
    // 订单已审核 价格批量更新亮 */
    if (commonUtils.isNotEmptyObject(menu.sControlName) && menu.sControlName.includes("PriceUpdate")) {
      const { bCheck } = masterData;
      if (!bCheck) {
        disabledData.push(menu.sControlName);
      }
    }
    /* 导入未清按钮 只有编辑亮的*/
    if (menu.sControlName === "BtnImportFormData") {
      if (!enabled) {
        disabledData.push("BtnImportFormData");
      }
    }

    /* 盘点导出模板数据 只有非编辑 按钮亮*/
    if (menu.sControlName === "BtnOutTemplateData") {
      if (enabled) {
        disabledData.push("BtnOutTemplateData");
      }
    }

    if (sModelsType === "productionMainPlan/productionMainPlan") {
      // 主计划中保存,取消保存按钮默认不可点击
      if (disabledData.indexOf("BtnSave") === -1) {
        disabledData.push("BtnSave");
      }
      if (disabledData.indexOf("BtnRefresh") === -1) {
        disabledData.push("BtnRefresh");
      }
      // 生产主计划数据集有改动的时候才会高亮保存按钮
      // 生产主计划保存按钮和确认计划的按钮互斥，存一
      if (this.props.dataChanged === true) {
        // 列表有所改动
        // 显示保存，禁用确认计划
        if (disabledData.indexOf("BtnSave") !== -1) {
          disabledData.splice(disabledData.indexOf("BtnSave"), 1);
        }
        if (disabledData.indexOf("BtnRefresh") !== -1) {
          disabledData.splice(disabledData.indexOf("BtnRefresh"), 1);
        }
        if (disabledData.indexOf("BtnUnifiedPlanning") === -1) {
          disabledData.push("BtnUnifiedPlanning");
        }
      }
      // if (this.props.dataChanged === false) {
      //   if (disabledData.indexOf('BtnUnifiedPlanning') !== -1) {
      //     disabledData.splice(disabledData.indexOf('BtnUnifiedPlanning'), 1);
      //   }
      //   if (disabledData.indexOf('BtnSave') === -1) {
      //     disabledData.push('BtnSave');
      //     disabledData.push('BtnRefresh'); /* 生产主计划刷新按钮的亮与灰与保存按钮同步 */
      //   }
      // }
    }

    if (sModelsType === "system/sisformulaInfo") {
      // 方案保存开放复制方案
      disabledData.splice(disabledData.indexOf("BtnCopyTo"), 1);
    }

    /* 审核中的按钮 所有按钮都置灰 */
    if (commonUtils.isNotEmptyObject(masterData) && masterData.sStatus === "2") {
      const disabledDataNew = [
        "BtnUpd",
        "BtnDel",
        "BtnRevert",
        "BtnSave",
        "BtnCopyTo",
        "BtnCancel",
        "BtnExamine",
        "BtnCancelExamine",
        "BtnCopyFrom",
        "BtnCancelInvalid",
        "BtnImport",
        "BtnBsOperation.BtnInvalid",
        "BtnBsOperation.BtnCancelInvalid",
        "BtnUpload",
        "BtnSend",
        "BtnEject",
        "BtnBsOperation.BtnUpCheck",
        "BtnBsOperation",
      ];
      if (commonUtils.isNotEmptyArr(disabledDataNew)) {
        for (const item of disabledDataNew) {
          const iIndex = disabledData.findIndex(each => each === item);
          if (iIndex === -1) {
            disabledData.push(item);
          }
        }
      }
    }

    /* 红冲中的单据 根据条件进行所有按钮置灰 */
    if (
      commonUtils.isNotEmptyObject(masterData) &&
      ((masterData.bCheck && commonUtils.isNotEmptyObject(masterData.sMinusSrcId)) || commonUtils.isNotEmptyObject(masterData.sMinusUsed))
    ) {
      disabledData = [
        "BtnUpd",
        "BtnDel",
        "BtnRevert",
        "BtnSave",
        "BtnCopyTo",
        "BtnCancel",
        "BtnExamine",
        "BtnCancelExamine",
        "BtnCopyFrom",
        "BtnCancelInvalid",
        "BtnImport",
        "BtnBsOperation.BtnInvalid",
        "BtnBsOperation.BtnCancelInvalid",
        "BtnUpload",
        "BtnSend",
        "BtnEject",
        "BtnBsOperation.BtnUpCheck",
        "BtnBsOperation",
      ];
    }

    /* 红冲中的单据 红冲按钮置灰色 */
    if (
      commonUtils.isNotEmptyObject(masterData) &&
      (commonUtils.isNotEmptyObject(masterData.sMinusSrcId) || commonUtils.isNotEmptyObject(masterData.sMinusUsed))
    ) {
      disabledData.push("BtnCopyTo.ActProductionMaterials"); /* 红冲单据按钮若已红冲 则置灰色 */
    }

    /* 工艺卡启用按钮 只有审核是亮的 */
    if (location.pathname.includes("processCardPackTableTree")) {
      if (!masterData.bCheck) {
        disabledData.push("BtnEventEnable");
      }
    }
    /* 单据的自定义按钮，控制它在保存后才高亮 */

    if (location.pathname.includes("Bill")) {
      if (
        commonUtils.isNotEmptyObject(menu.sControlName) &&
        (menu.sControlName.indexOf("BtnEvent") > -1 ||
          menu.sControlName.indexOf("BtnRepair") > -1 ||
          menu.sControlName.indexOf("BtnSubmit") > -1 ||
          menu.sControlName.indexOf("BtnBatchSubmit") > -1)
      ) {
        if (enabled) {
          /* 只有非编辑编辑状态 按钮会亮 */
          disabledData.push(menu.sControlName);
        }
      }
      if (commonUtils.isNotEmptyObject(menu.sControlName) && menu.sControlName.indexOf("BtnCalc") > -1) {
        if (!enabled) {
          /* 只有编辑状态 按钮会亮 */
          disabledData.push(menu.sControlName);
        }
      }
    }

    if (location.pathname.includes("systemPermission")) {
      if (activeKey === "3") {
        /* 用户权限 */
        if (commonUtils.isNotEmptyObject(menu.sControlName) && menu.sControlName.indexOf("BtnRepairGroup") > -1) {
          disabledData.push(menu.sControlName);
        }
      } else {
        /* 组权限 */
        if (commonUtils.isNotEmptyObject(menu.sControlName) && menu.sControlName.indexOf("BtnRepairUser") > -1) {
          disabledData.push(menu.sControlName);
        }
      }
    }

    if (menu.sColor === "alwaysAbled") {
      const iIndex = disabledData.findIndex(item => item === menu.sControlName);
      if (iIndex !== -1) {
        disabledData.splice(iIndex, 1);
      }
      if (sModelsId === "12710101117055564119120" || sModelsId === "12710101117170330526240") {
        /* 物资评审 采购申请常亮 */
        const iCIndex = disabledData.findIndex(item => item === "BtnCopyTo");
        if (iCIndex !== -1) {
          disabledData.splice(iCIndex, 1);
        }
      }
    }

    let bReturn = true;
    if (menu.sControlName !== undefined && menu.sControlName.indexOf(".") > -1) {
      bReturn = disabledData.findIndex(item => item === menu.sControlName.substring(0, menu.sControlName.indexOf("."))) > -1;
      if (!bReturn) {
        bReturn = disabledData.findIndex(item => item === menu.sControlName) > -1;
      }
    } else {
      bReturn = disabledData.findIndex(item => item === menu.sControlName) > -1;
    }
    bReturn = bReturn || (this.props.getMenuStatus !== undefined && this.props.getMenuStatus(menu));
    return { menuStatus: bReturn, bShown };
  };

  // 获取父级菜单属性(自定义逻辑)
  getMenuStatusCostom = menu => {
    const { sInstruct: sInstructStr } = this.props.masterConfig || {};
    const sInstruct = commonUtils.convertStrToObj(sInstructStr, {});
    const { data = [], conditionGroup = {} } = sInstruct;
    let menuStatus = false;
    let bShown = true;

    const { showName: showNameDefault } = menu;
    let { sControlName } = menu;
    if (sControlName && sControlName.includes("BtnPrint")) {
      sControlName = "BtnPrint";
    }
    let showName = showNameDefault;
    const btnConfig = data.find(
      item => item.name && item.name.split(",").includes(sControlName) && (item.enabled !== undefined || item.show !== undefined)
    );
    if (btnConfig === undefined) return { bContinue: true };

    const getStatus = (type, defaultValue) => {
      const { [type]: condition = "" } = btnConfig;
      if (condition === "") return defaultValue;
      if (typeof condition === "boolean") {
        return condition;
      } else if (condition.includes("conditionGroup")) {
        const [, conditionName] = condition.split(".");
        const conditionNew = conditionGroup[conditionName];
        const result = this.getStatusResult(conditionNew, defaultValue);
        return condition.includes("!") ? !result : result;
      } else if (typeof condition === "string") {
        return this.getStatusResult(condition, defaultValue);
      }

      return defaultValue;
    };

    menuStatus = !getStatus("enabled", menuStatus);
    bShown = getStatus("show", bShown);

    const { showText } = btnConfig;
    if (typeof showText === "string") {
      showName = showText;
    } else if (commonUtils.isNotEmptyArr(showText)) {
      for (let i = 0; i < showText.length; i++) {
        let tempResult = false;
        const item = showText[i];
        const { condition, text } = item;
        if (condition.includes("conditionGroup")) {
          const [, conditionName] = condition.split(".");
          const conditionNew = conditionGroup[conditionName];
          tempResult = this.getStatusResult(conditionNew, tempResult);
          tempResult = condition.includes("!") ? !tempResult : tempResult;
        } else {
          tempResult = this.getStatusResult(condition, tempResult);
        }
        if (tempResult) {
          showName = text;
          break;
        }
      }
    }

    // 是否继续走原先的逻辑（当没有配置enabled时）
    const bContinueMenuStatus = btnConfig.enabled === undefined;

    return { menuStatus, bShown, showName, bContinueMenuStatus };
  };

  matchResult = (rowData, sFileName, conditionStr, conditionValue) => {
    let rowDataValue = rowData[sFileName];
    try {
      if (rowDataValue === undefined || rowDataValue === null || rowData === "null") {
        rowDataValue = "";
      } else {
        rowDataValue = rowDataValue.toString();
      }
    } catch (error) {}
    switch (conditionStr) {
      case "===":
        return rowDataValue === conditionValue;
      case "==":
        return rowDataValue === conditionValue;
      case ">=":
        return rowDataValue >= conditionValue;
      case "<=":
        return rowDataValue <= conditionValue;
      case ">":
        return rowDataValue > conditionValue;
      case "<":
        return rowDataValue < conditionValue;
      case "!=":
        return rowDataValue != conditionValue;
      case "!==":
        return rowDataValue !== conditionValue;
      default:
        throw new Error("conditionStr is not valid");
    }
  };

  getStatusResult = (str, defaultValue) => {
    let strNew = str.replace(/\s+/g, "");
    let result = defaultValue;
    const { allTableSelectedData: tempData } = this.state;
    tempData.props = {
      sSrcModelsId: this.props.sSrcModelsId,
      enabled: !!this.props.enabled,
    };
    Object.keys(tempData).forEach(key => {
      const reg = new RegExp(`${key}\\.`, "g");
      strNew = strNew.replace(reg, `tempData["${key}"].`);
    });

    try {
      // 截取字符串中 ${tableName@all.fieldName.判断符号.判断内容} 格式的内容
      const reg1 = /\$\{[^{}@]+@[^{}\.]+\.[^{}\.]+\.[^{}\.]+\.[^{}\.]*\}/g;
      strNew = strNew.replace(reg1, matchStr => {
        const matchStrNew = matchStr.substring(2, matchStr.length - 1);
        const [tableName, restStr] = matchStrNew.split("@");
        const [filterType, sFileName, conditionStr, conditionValue] = restStr.split(".");
        let matchResult = matchStr;

        const tableData = tempData[tableName] || [];
        const selectedRowKeys = this.props[`${tableName}SelectedRowKeys`] || [];
        const selectedData = tableData.filter(rowData => selectedRowKeys.includes(rowData.sSlaveId) || selectedRowKeys.includes(rowData.sId));
        if (commonUtils.isEmptyObject(selectedData)) return false;
        if (filterType === "all") {
          matchResult = !selectedData.some(rowData => !this.matchResult(rowData, sFileName, conditionStr, conditionValue));
        } else if (filterType === "one") {
          matchResult = selectedData.some(rowData => this.matchResult(rowData, sFileName, conditionStr, conditionValue));
        }
        return matchResult;
      });

      const evalStr = eval("`" + strNew + "`");
      // console.log("=====数据处理结果", { tempData, str, strNew, evalStr });
      result = eval(evalStr);
    } catch (error) {
      // console.log("=====error", error);
      // clearInterval(this.modaltimer);
      // this.modaltimer = setTimeout(() => {
      //   Modal.error({
      //     width: 1000,
      //     title: "按钮状态指令集错误信息",
      //     content: <div>
      //       <div>按钮状态运算错误！</div>
      //       <div>请检查按钮状态运算语法！</div>
      //       <div>按钮状态运算内容：</div>
      //       <div>{str}</div>
      //       <div>按钮状态运算被替代后的结果：</div>
      //       <div>{strNew}</div>
      //     </div>,
      //     okText: "知道了"
      //   });
      // }, 1000);
      return defaultValue;
    }

    if (typeof result !== "boolean") {
      clearInterval(this.modaltimer);
      this.modaltimer = setTimeout(() => {
        clearInterval(this.modaltimer);
        Modal.error({
          width: 1000,
          title: "按钮状态指令集错误信息",
          content: (
            <div>
              <div>按钮状态运算返回值不是布尔值！</div>
              <div>请检查按钮状态运算语法！</div>
              <div>按钮状态运算内容：</div>
              <div>{str}</div>
              <div>按钮状态运算被替代后的结果：</div>
              <div>{strNew}</div>
              <div>按钮状态运算返回值：</div>
              <div>{result}</div>
            </div>
          ),
          okText: "知道了",
        });
      }, 1000);
      return defaultValue;
    }

    // console.log("=====result", result);
    return result;
  };

  getDisabledProps = name => {
    if (commonUtils.isNotEmptyObject(name)) {
      const { enabled } = this.props;
      const obj = {};
      obj.disabled = enabled;
      return obj;
    }
  };

  /* */
  handleBtnEnabled = (props, isReturn) => {
    const { masterConfig: masterConfigOld } = props;
    if (commonUtils.isNotEmptyObject(masterConfigOld)) {
      const masterConfig = JSON.parse(JSON.stringify(masterConfigOld));
      const buttonConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === "" && item.showName !== "" && item.sControlName !== "");
      if (commonUtils.isNotEmptyArr(buttonConfig)) {
        for (const btnItem of buttonConfig) {
          const iIndex = masterConfig.gdsconfigformslave.findIndex(item => btnItem.sId === item.sId);
          let btndisabled = false;
          if (commonUtils.isNotEmptyStr(btnItem.sButtonEnabled)) {
            btndisabled = this.handleAnalysisBtnEnabled(props, btnItem, masterConfig.gdsconfigformslave);
          }
          if (!!masterConfig.gdsconfigformslave[iIndex].disabled !== btndisabled) {
            masterConfig.gdsconfigformslave[iIndex].disabled = btndisabled; // = { ...masterConfig.gdsconfigformslave[iIndex], disabled: btndisabled };
          }
        }
      }
      if (isReturn) {
        return { ...masterConfig };
      } else if (JSON.stringify(masterConfig) === JSON.stringify(masterConfigOld)) {
        return;
      } else {
        const addState = {};
        addState.masterConfig = { ...masterConfig };
        this.props.onSaveState({ ...addState });
      }
    }
  };

  handleAnalysisBtnEnabled = (props, currConfig, gdsconfigformslave) => {
    const { sButtonEnabled } = currConfig;
    let btndisabled = false;
    if (commonUtils.isNotEmptyObject(sButtonEnabled)) {
      const btnObj = JSON.parse(sButtonEnabled);
      const solution = btnObj.solution;
      const rowSelected = btnObj.rowSelected;
      const buttonFilter = btnObj.button; /* 需要控制的按钮集 */
      const dataArr = btnObj.data; /* 根据数据控制按钮亮与灰色 */

      // 解析配置中  solution:["新工单"]
      if (!(commonUtils.isNotEmptyArr(solution) && solution.includes(props.masterData.sSolutionName))) {
        btndisabled = true;
        // return btndisabled;
      }

      let disabledRowSelected;
      // 解析配置中  rowSelected: [{name:'master',rule:'&&'},{name:'slave',rule:'&&'}],
      if (commonUtils.isNotEmptyArr(rowSelected)) {
        let rule;
        let selectRt;
        let i = 0;
        for (const item of rowSelected) {
          const name = item.name;
          i += 1;
          if (commonUtils.isNotEmptyArr(props[`${name}SelectedRowKeys`])) {
            selectRt = true; // 表示 满足当前条件，
          } else {
            selectRt = false;
          }
          /* 只有1个配置：
             selectRt = true 当满足当前条件，按钮应该为亮，即当前btndisabled =false，不返回继续往下进行判断
             selectRt = false 不当满足当前条件，按钮应该为灰色，即当前btndisabled =true，已经有条件不满足，按钮可直接定为灰色的，即直接返回true
          */
          if (i === 1) {
            disabledRowSelected = selectRt;
          } else if (i > 1 && rule === "&&") {
            disabledRowSelected = selectRt && disabledRowSelected;
          } else if (i > 1 && rule === "||") {
            disabledRowSelected = selectRt || disabledRowSelected;
          }
          rule = item.rule;
        }
        if (!disabledRowSelected) {
          btndisabled = true;
          // return btndisabled;
        }
      }
      // gdsconfigformslave[iIndex].disabled 为true 表示按钮至灰， false 表示按钮亮，可使用
      let disabledButtonFilter;
      if (commonUtils.isNotEmptyArr(buttonFilter)) {
        let rule;
        let buttonRt;
        let i = 0;
        for (const item of buttonFilter) {
          i += 1;
          const name = item.name;
          const currDisabled = !item.enabled;
          const iIndex = gdsconfigformslave.findIndex(config => config.sControlName === name);
          if (iIndex === -1) {
            continue;
          }
          const tempDisabled = gdsconfigformslave[iIndex].disabled;
          if (tempDisabled === currDisabled) {
            buttonRt = true;
          } else {
            buttonRt = false;
          }
          if (i === 1) {
            disabledButtonFilter = buttonRt;
          } else if (i > 1 && rule === "&&") {
            disabledButtonFilter = buttonRt && disabledRowSelected;
          } else if (i > 1 && rule === "||") {
            disabledButtonFilter = buttonRt || disabledRowSelected;
          }
          rule = item.rule;
        }
        if (!disabledButtonFilter) {
          btndisabled = true;
          // return btndisabled;
        }
      }
      /* 按钮根据需要能按字段值来控制 */
      if (commonUtils.isNotEmptyArr(dataArr)) {
        const currButtonName = currConfig.sControlName; /* 当前按钮 */
        let flag = btndisabled;
        for (const item of dataArr) {
          const { name, fieldName, condition, value, showBtn, hideBtn } = item;
          const { [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: selectedRowKeys, masterData } = this.props;
          let tableDataRow = {};
          if (name === "master") {
            tableDataRow = masterData;
          } else {
            const filterData =
              commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectedRowKeys)
                ? tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId))
                : [];
            if (commonUtils.isNotEmptyArr(filterData)) {
              tableDataRow = filterData[0];
            }
          }
          if (commonUtils.isNotEmptyObject(tableDataRow)) {
            if (condition === ">") {
              if (tableDataRow[fieldName] > value) {
                if (commonUtils.isNotEmptyArr(showBtn)) {
                  const iIndex = showBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = false; /* 按钮亮 */
                  }
                }
                if (commonUtils.isNotEmptyArr(hideBtn)) {
                  const iIndex = hideBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = true; /* 按钮灰 */
                  }
                }
              }
            } else if (condition === "===") {
              if (tableDataRow[fieldName] === value) {
                if (commonUtils.isNotEmptyArr(showBtn)) {
                  const iIndex = showBtn.findIndex(item => item.indexOf(currButtonName) > -1);
                  if (iIndex > -1) {
                    flag = false; /* 按钮亮 */
                  }
                }
                if (commonUtils.isNotEmptyArr(hideBtn)) {
                  const iIndex = hideBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = true; /* 按钮灰 */
                  }
                }
              }
            } else if (condition === "!==") {
              if (tableDataRow[fieldName] !== value) {
                if (commonUtils.isNotEmptyArr(showBtn)) {
                  const iIndex = showBtn.findIndex(item => item.indexOf(currButtonName) > -1);
                  if (iIndex > -1) {
                    flag = false; /* 按钮亮 */
                  }
                }
                if (commonUtils.isNotEmptyArr(hideBtn)) {
                  const iIndex = hideBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = true; /* 按钮灰 */
                  }
                }
              }
            } else if (condition === "<") {
              if (tableDataRow[fieldName] < value) {
                if (commonUtils.isNotEmptyArr(showBtn)) {
                  const iIndex = showBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = false; /* 按钮亮 */
                  }
                }
                if (commonUtils.isNotEmptyArr(hideBtn)) {
                  const iIndex = hideBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = true; /* 按钮灰 */
                  }
                }
              }
            } else if (condition === "like") {
              if (fieldName.substring(0, 1) === "s") {
                if (commonUtils.isNotEmptyArr(showBtn)) {
                  const iIndex = showBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = false; /* 按钮亮 */
                  }
                }
                if (commonUtils.isNotEmptyArr(hideBtn)) {
                  const iIndex = hideBtn.findIndex(item => item.indexOf(currButtonName));
                  if (iIndex > -1) {
                    flag = true; /* 按钮灰 */
                  }
                }
              }
            }
          }
        }
        btndisabled = flag;
      }
      /* End */
    }
    return btndisabled;
  };

  /**  根据二级菜单获取三级数据   */
  handleMouseEnter = e => {
    if (commonUtils.isNotEmptyStr(e.key) && this.props.onSearchUpDownThird !== undefined) {
      this.props.onSearchUpDownThird(e.key);
    }
  };

  handleMouseEnterTooBar = () => {
    const focusedElement = document.activeElement;
    if (focusedElement.tagName.toLowerCase() === "input") {
      focusedElement.blur();
    }
  };

  handleImport = async (proName, proInParam, other) => {
    this.props.onSaveState({
      loading: true,
    });
    const { sModelsId, masterData, slaveData, slaveDelData: slaveDelDataOld, app } = this.props;
    const confirmSetting = commonFunc.showLocalMessage(this.props, 'confirmSetting', '请配置按钮的存储过程');
    const btnConfig = this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName === "BtnCommonImport")[0]; // sButtonEnabled  sButtonParam
    if (!commonUtils.isNotEmptyObject(btnConfig) || !commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
      message.error(confirmSetting);
      this.props.onSaveState({
        loading: false,
      });
    }

    const sButtonParam = btnConfig.sButtonParam;
    const btn = JSON.parse(sButtonParam);
    const sProName = btn.sproName;
    const inParams = [];
    const inMap = btn.inMap;
    const inlist = inMap ? inMap.split(",") : [];
    const masterArr = [];
    const slaveArr = [];
    const slaveInfoArr = [];
    const controlArr = [];
    const materialsArr = [];
    const processArr = [];

    if (!sTableName && !inMap) {
      // 都为undefined时直接退出
      return;
    }

    if (inlist.length > 0) {
      inlist.forEach(item => {
        const itemArr = item.split(".");
        if (itemArr.length > 0) {
          const sname = itemArr[0];
          const stype = itemArr[1];
          if (commonUtils.isNotEmptyStr(sname) && sname === "master") {
            masterArr.push(stype);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "slave") {
            slaveArr.push(stype);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "slaveInfo") {
            slaveInfoArr.push(stype);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "control") {
            controlArr.push(stype);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "materials") {
            materialsArr.push(stype);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "process") {
            processArr.push(stype);
          }
        }
      });

      if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
        const addState = {};
        addState.key = "master";
        const val = [];
        const currVal = {};
        masterArr.forEach(filed => {
          currVal[`${filed}`] = masterData[`${filed}`];
        });
        val.push(currVal);
        addState.value = val;
        inParams.push({ ...addState });
      }
      if (commonUtils.isNotEmptyArr(slaveArr)) {
        const addState = this.handleProParams("slave", slaveArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(slaveInfoArr)) {
        const addState = this.handleProParams("slaveInfo", slaveInfoArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(controlArr)) {
        const addState = this.handleProParams("control", controlArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(materialsArr)) {
        const addState = this.handleProParams("materials", materialsArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(processArr)) {
        const addState = this.handleProParams("process", processArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
    }

    const value = { sProName, sProInParam: JSON.stringify({ params: inParams }) };
    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;
    // const url = `${commonConfig.server_host}eleMaterialsStock/getEleMaterialsStock?sModelsId=${sModelsId}&sWareHouseId=${masterData.sWareHouseId}&num=${num}`;
    // const dataReturn = (await commonServices.getService(this.props.app.token, url)).data;
    if (dataReturn.code === 1) {
      const returnData = dataReturn.dataset.rows;
      const slaveDelData = commonUtils.isEmptyArr(slaveDelDataOld) ? [] : slaveDelDataOld;
      slaveData.forEach(item => {
        item.handleType = "del";
        slaveDelData.push({ ...item });
      });
      returnData.forEach((item, index) => {
        item.handleType = "add";
        item.sParentId = masterData.sId;
        item.iOrder = index + 1;
        returnData[index] = { ...item };
      });
      this.props.onSaveState({ slaveData: returnData, slaveDelData });
    } else {
      this.props.getServiceError({ ...dataReturn, fn: () => this.handleImport(proName, proInParam, { iFlag: 1 }) });
    }
    this.props.onSaveState({
      loading: false,
    });
  };

  handleSBusinessType = (key, sBusinessType) => {
    const result = {
      "BtnCopyTo.saldelivergoods": v => ({ isTrue: ["ZS05"].includes(v), message: "送货单只能选择非免费订单" }),
      "BtnCopyTo.saldeliverfree": v => ({ isTrue: !["ZS05"].includes(v), message: "免费送货只能选择免费订单" }),
    }[key];
    return result?.(sBusinessType);
  };
  /**
   * 区分是否免费送货
   * @param {*} key
   * @returns
   */
  handleFreeDeliver = key => {
    if (
      ["BtnCopyTo.saldelivergoods", "BtnCopyTo.saldeliverfree"].includes(key) &&
      Array.isArray(this.props.slaveSelectedData) &&
      this.props.slaveSelectedData.length
    ) {
      const selectSBusinessType = this.props.slaveSelectedData.map(i => i?.sBusinessType);
      if (selectSBusinessType.includes("ZS05") && selectSBusinessType.find(i => i !== "ZS05")) {
        message.error("送货单只能选择非免费订单, 免费送货只能选择免费订单");
        return true;
      } else {
        const result = this.handleSBusinessType(key, selectSBusinessType[0]);
        if (result?.isTrue) {
          message.error(result?.message || "送货类型需保持一致");
          return true;
        }
      }
    }
  };

  // 按钮指令集
  handleClick = e => {
    // 如果没找到调用指令集方法，执行原始方法
    if (!this.props.onExecInstructSet) {
      this.handleClick1(e);
      return;
    }
    let { key } = e;
    const { menuData } = this.state;
    if (key.includes("BtnCopyTo")) {
      key = "BtnCopyTo";
    }
    const iIndex = menuData.findIndex(item => item.sName === key || item.sControlName === key);
    const { sInstruct: sInstructStr, sChangeType } = iIndex > -1 ? menuData[iIndex] : {};
    const sInstruct = commonUtils.convertStrToObj(sInstructStr, {});
    // const { data = [] } = sInstruct;
    // console.log('btnConfig', iIndex, sInstruct, data);
    // const btnConfig = data.find(item => item.name && item.name.split(',').includes(key) && item.click);
    if (commonUtils.isEmptyObject(sInstruct)) {
      this.handleClick1(e);
      return;
    }

    if (sChangeType === "clickOnly") {
      // 只执行指令集
      this.props.onExecInstructSet({
        sInstruct: sInstruct,
        showName: "按钮only",
      });
    } else if (sChangeType === "afterClick") {
      // 先按钮再指令集
      this.handleClick1(e);
      setTimeout(() => {
        this.props.onExecInstructSet({
          sInstruct: sInstruct,
          showName: "按钮-指令集",
        });
      }, 1000);
    } else {
      // 先指令集再按钮
      this.props.onExecInstructSet({
        sInstruct: sInstruct,
        showName: "指令集-按钮",
        callback: ex => {
          console.log("=====xxx", "指令集-按钮", ex);
          this.handleClick1(e);
        },
      });
    }
  };

  /**   菜单的点击事件   */
  handleClick1 = async e => {
    if (this.props.onToolBarClick && this.props.onToolBarClick(e)) {
      return;
    }

    let checkedBoolean = false;
    let obj = { enabled: false };
    const { checked, checkedId, menuData, printData } = this.state;
    const { key, keyPath = "" } = e;
    // if (checked && checkedId === key) {
    //   checkedBoolean = true;
    // }
    const checkIndex = printData.findIndex(item => item.checkedId === key);
    if (checkIndex > -1) {
      checkedBoolean = printData[checkIndex].checked;
    }
    // console.log('toolbar-checked', checked, checkedId, key);

    const iIndex = menuData.findIndex(item => item.sName === key || item.sControlName === key);
    let interfaceArr = [];
    if (iIndex > -1) {
      interfaceArr = menuData[iIndex].interface;
    }

    const sErrorInfo = this.handleCheckButton(key); /* 验证按钮是否可以点击 */
    if (commonUtils.isNotEmptyObject(sErrorInfo)) {
      message.error(sErrorInfo);
      return;
    }
    const bCancel = commonFunc.showLocalMessage(this.props, 'bCancel', '确定要取消');

    const bInvalid = commonFunc.showLocalMessage(this.props, 'bInvalid', '确定要作废');

    const bInvalidCancel = commonFunc.showLocalMessage(this.props, 'bInvalidCancel', '确定要作废');

    const confirmSetting = commonFunc.showLocalMessage(this.props, 'confirmSetting', '请配置按钮的存储过程');
    /*   新增   */
    if (key === "BtnAdd") {
      /*   增加   */
      this.handleAdd(obj);
    } else if (key === "BtnAddChild") {
      /*   分类增加子级   */
      this.handleAddChild(obj);
    } else if (key.indexOf("BtnAddTo") > -1) {
      /*   新增下拉   */
      this.props.onAddTo(e.key);
    } else if (key === "BtnUpd") {
      /*   修改   */
      this.props.onSaveState({
        loading: true,
      });
      this.props.onEdit(obj);
    } else if (key === "BtnSave") {
      /*   保存   */
      this.props.onSaveState({
        loading: true,
      });
      /*  生产主计划重置数据变化状态  */
      this.props.onSaveState({
        dataChanged: false,
      });
      setTimeout(async () => {
        /* 根据接口返回是之前调用还是之后调用 */
        if (commonUtils.isNotEmptyArr(interfaceArr)) {
          const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
          const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
          let flag = 0;
          if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
            /* 之前调用 */
            const asyncFunc = async () => {
              for (let i = 0; i < beforeInterfaceArr.length; i++) {
                const data = await this.handleInterfaceCall(beforeInterfaceArr[i]);
                if (!data) {
                  flag += 1;
                  return;
                }
              }
            };
            await asyncFunc();
            // beforeInterfaceArr.forEach((item) => {
            //   this.handleInterfaceCall(item);
            // });
            if (flag == 0) {
              this.handleSubmit();
            } else {
              this.props.onSaveState({
                loading: false,
              });
            }
          }
          if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
            /* 之后调用 */
            this.handleSubmit();
            const asyncFunc = async () => {
              for (let i = 0; i < afterInterfaceArr.length; i++) {
                await this.handleInterfaceCall(afterInterfaceArr[i]);
              }
            };
            await asyncFunc();
            // afterInterfaceArr.forEach((item) => {
            //   this.handleInterfaceCall(item);
            // });
          }
        } else {
          this.handleSubmit();
        }
      }, 500);
    } else if (key === "BtnExamine") {
      /*   审核   */
      this.props.onSaveState({
        loading: true,
      });
      /* 根据接口返回是之前调用还是之后调用 */
      let flag = 0;
      if (commonUtils.isNotEmptyArr(interfaceArr)) {
        const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
        const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
        if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
          /* 之前调用 */
          // beforeInterfaceArr.forEach((item) => {
          //   this.handleInterfaceCall(item);
          // });
          const asyncFunc = async () => {
            for (let i = 0; i < beforeInterfaceArr.length; i++) {
              const data = await this.handleInterfaceCall(beforeInterfaceArr[i]);
              if (!data) {
                flag += 1;
                return;
              }
            }
          };
          await asyncFunc();
        }
        let result;
        if (flag == 0) {
          result = await this.props.onBtnExamine();
        } else {
          this.props.onSaveState({
            loading: false,
          });
        }

        if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
          /* 之后调用 */
          // const result = await this.props.onBtnExamine();
          if (result) {
            /* 只有审核成功 才能调用接口 -5代表审核失败 */
            const asyncFunc = async () => {
              for (let i = 0; i < afterInterfaceArr.length; i++) {
                await this.handleInterfaceCall(afterInterfaceArr[i], true);
              }
            };
            await asyncFunc();
            // afterInterfaceArr.forEach((item) => {
            //   this.handleInterfaceCall(item);
            // });
          }
        }
      } else {
        this.props.onBtnExamine();
      }
    } else if (key === "BtnBatchExamine") {
      /*  批量审核 接口循环调用 选中行1 调用接口+审核  选中行2 调用接口+审核  选中行3 调用接口+审核, 1错了，2、3继续   */
      this.props.onSaveState({
        loading: true,
      });
      /* 根据接口返回是之前调用还是之后调用 */
      if (commonUtils.isNotEmptyArr(interfaceArr)) {
        this.props.onBtnBatchExamine(interfaceArr);
      } else {
        this.props.onBtnBatchExamine();
      }
      this.props.onSaveState({
        loading: false,
      });
    } else if (key === "BtnBatchCancelExamine") {
      /*  批量审核 接口循环调用 选中行1 调用接口+审核  选中行2 调用接口+审核  选中行3 调用接口+审核, 1错了，2、3继续   */
      this.props.onSaveState({
        loading: true,
      });
      /* 根据接口返回是之前调用还是之后调用 */
      if (commonUtils.isNotEmptyArr(interfaceArr)) {
        this.props.onBtnBatchCancelExamine(interfaceArr);
      } else {
        this.props.onBtnBatchCancelExamine(interfaceArr);
      }
      this.props.onSaveState({
        loading: false,
      });
    } else if (key === "BtnBatchExamine" && false) {
      /*   批量审核 统一接口调用, 三条勾选行 合并为sIdArr   */
      this.props.onSaveState({
        loading: true,
      });
      /* 根据接口返回是之前调用还是之后调用 */
      if (commonUtils.isNotEmptyArr(interfaceArr)) {
        const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
        const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
        if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
          /* 之前调用 */
          // beforeInterfaceArr.forEach((item) => {
          //   this.handleInterfaceCall(item);
          // });
          let flag = 0;
          const asyncFunc = async () => {
            for (let i = 0; i < beforeInterfaceArr.length; i++) {
              const data = await this.handleInterfaceCall(beforeInterfaceArr[i]);
              if (!data) {
                flag += 1;
                return;
              }
            }
          };
          await asyncFunc();
          if (flag == 0) {
            this.props.onBtnBatchExamine();
          } else {
            this.props.onSaveState({
              loading: false,
            });
          }
        }
        if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
          /* 之后调用 */
          const result = await this.props.onBtnBatchExamine();
          if (result !== -5) {
            /* 只有审核成功 才能调用接口 -5代表审核失败 */
            const asyncFunc = async () => {
              for (let i = 0; i < afterInterfaceArr.length; i++) {
                await this.handleInterfaceCall(afterInterfaceArr[i], true);
              }
            };
            await asyncFunc();
            this.props.onSaveState({
              loading: false,
            });
            // afterInterfaceArr.forEach((item) => {
            //   this.handleInterfaceCall(item);
            // });
          }
        }
      } else {
        this.props.onBtnBatchExamine();
        this.props.onSaveState({
          loading: false,
        });
      }
    } else if ( key.includes("BtnSendDialog")) {
      /*   推送接口   */
      /* 将当前界面所有数据集作为入参传到接口中 */
      const { masterConfig, sModelsId } = this.props;
      let { masterData } = this.props;
      const addState = {};
      let allTableMap = {};
      const allReturnMap = {};
      let masterDataList = []; /* 弹窗数据集合 */
      let allDataList = {}; /* 接口返回所有数据对象集合 */
      const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === key))
        ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]
        : {}; // sButtonEnabled  sButtonParam
      const slaveNameList = [];
      if (commonUtils.isNotEmptyObject(btnConfig)) {
        /* 组装allTableData */
        /* 从props找到 所有的Config */
        if (commonUtils.isNotEmptyArr(this.props)) {
          for (const key of Object.keys(this.props)) {
            if (key.includes("Config") && !key.includes("onGet") && !key.includes("report")) {
              const tablename = key.replace("Config", "").trim();
              slaveNameList.push(tablename);
            }
          }
        }
        addState.slaveNameList = slaveNameList;

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

        const { sActiveKey } = btnConfig;
        if (commonUtils.isNotEmptyStr(sActiveKey)) {
          sActiveKey.split(",").forEach(item => {
            const [tableName, fieldName] = item.split(".");
            if (commonUtils.isNotEmptyStr(tableName) && commonUtils.isNotEmptyStr(fieldName)) {
              let tableData = this.props[`${tableName}Data`];
              if (commonUtils.isNotEmptyObject(tableData)) {
                tableData = tableName === "master" ? tableData : tableData[0];
                if (commonUtils.isNotEmptyObject(tableData)) {
                  allTableMap[fieldName] = tableData[fieldName];
                }
              }
            }
          });

          if (commonUtils.isNotEmptyObject(this.tempCondition)) {
            allTableMap = {
              ...allTableMap,
              ...this.tempCondition,
            };
          }
        }
      }
      /* 根据接口返回是之前调用还是之后调用 */
      this.props.onSaveState({
        loading: true,
      });
      let addStateReturn = {};
      if (commonUtils.isNotEmptyArr(interfaceArr)) {
        const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
        const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
        if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
          /* 之前调用 */
          const asyncFunc = async () => {
            for (let i = 0; i < beforeInterfaceArr.length; i++) {
              addStateReturn = await this.handleInterfaceCallDialog(beforeInterfaceArr[i], true, key, allTableMap);
            }
          };
          await asyncFunc();
        }
        if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
          /* 之后调用 */
          const asyncFunc = async () => {
            for (let i = 0; i < afterInterfaceArr.length; i++) {
              addStateReturn = await this.handleInterfaceCallDialog(afterInterfaceArr[i], true, key, allTableMap);
            }
          };
          await asyncFunc();
        }
      }
      if (addStateReturn && addStateReturn.bResult) {
        addState.interfaceDialogData = addStateReturn.returnData;
        addState.interfaceDialogAllData = addStateReturn.returnData;
      } else {
        addState.interfaceDialogData = [];
      }
      addState.masterData = { ...masterData, bIsSAP: 1 };

      if (commonUtils.isNotEmptyArr(addState.interfaceDialogAllData)) {
        /* 循环interfaceDialogData */
        addState.interfaceDialogAllData.forEach((item, index) => {
          /* 先把master数据 放到interfaceDialogData中 */
          let sMasterId = "";
          const dataMap = {};
          for (const key of Object.keys(item)) {
            /* 把主表数据塞到masterDataList中 */
            if (key && key.includes("master")) {
              const data = commonUtils.isNotEmptyObject(item[key]) && commonUtils.isJSON(item[key]) ? JSON.parse(item[key]) : [];
              if (commonUtils.isNotEmptyObject(data)) {
                sMasterId = commonUtils.isNotEmptyObject(data.sSlaveId) ? data.sSlaveId : data.sId;
                masterDataList.push(data);
              }
            }
            const data = commonUtils.isNotEmptyObject(item[key]) && commonUtils.isJSON(item[key]) ? JSON.parse(item[key]) : [];
            dataMap[key] = data;
          }
          /* 将全部返回数据都铺到allDataList中 */
          const allKey = "master-" + sMasterId;
          allDataList[allKey] = dataMap; /* 根据返回的下标 封装key-value */
        });
        addState.allDataList = allDataList;
      }
      /* 弹窗的条件是 数据集数量>1 或者有this.tempCondition 切配置弹窗，否则直接将返回数据集铺到界面上 */
      if (
        (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyObject(btnConfig.sActiveId) && masterDataList.length > 0) ||
        commonUtils.isNotEmptyObject(this.tempCondition)
      ) {
        addState.interfaceDialogData = masterDataList;
        addState.visibleInterfaceDialog = true;
        addState.masterData = { ...masterData, bIsSAP: 1 };
      } else {
        addState.visibleInterfaceDialog = false; /* 没有弹窗 且主表只有1条 则不弹窗 直接带值 */
        const dataMap = commonUtils.isNotEmptyArr(addState.interfaceDialogData) ? addState.interfaceDialogData[0] : {};
        console.log("接口返回值：", dataMap);
        if (commonUtils.isNotEmptyArr(slaveNameList) && commonUtils.isNotEmptyArr(dataMap)) {
          slaveNameList.forEach(name => {
            const tableConfig = this.props[name + "Config"]; /* 动态配置 */
            let tableData = [];
            if (commonUtils.isNotEmptyObject(tableConfig)) {
              tableData = dataMap[name + "-" + tableConfig.sTbName]; /* 动态配置 */
              if (commonUtils.isNotEmptyObject(tableData) && commonUtils.isJSON(tableData)) {
                const newCopyTo = {};
                newCopyTo.master = masterData;
                let tableNewData = JSON.parse(tableData);
                if (name === "master") {
                  tableNewData = Array.isArray(tableNewData) ? tableNewData[0] : tableNewData;
                  masterData = { ...masterData, ...commonFunc.getAssignFieldValue(btnConfig.sAssignField, tableNewData, newCopyTo, true), bIsSAP: 1 }; // 取赋值字段
                  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;
                }
              }
            }
          });
        } else {
          addState.masterData = { ...masterData, bIsSAP: 1 };
        }
      }
      this.tempCondition = null;
      addState.loading = false;
      console.log("弹窗接口数据：", addState);
      this.props.onSaveState({
        ...addState,
      });
    } else if (key.indexOf('BtnSend') > -1) { /*   推送接口   */
      /* 根据接口返回是之前调用还是之后调用 */
      this.props.onSaveState({
        loading: true,
      });
      if(commonUtils.isNotEmptyArr(interfaceArr)) {
        const sendInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "0" );
        if(commonUtils.isNotEmptyArr(sendInterfaceArr)) {  /* 之前调用 */
          const asyncFunc = async () => {
            for (let i = 0; i < sendInterfaceArr.length; i ++) {
              await this.handleInterfaceCall(sendInterfaceArr[i], true, key);
            }
          }
          await asyncFunc();
        }

      }
      this.props.onSaveState({
        loading: false,
      });
    } else if (key.includes("BtnAddFace")) {
      // 显示人脸采集弹窗
      this.props.onSaveState({
        addFaceVisible: true,
      });
    } else if (key.includes("BtnGetApiDialog")) {
      /*   从第三方拿数据   */
      /* 将当前界面所有数据集作为入参传到接口中 */
      const { masterConfig, sModelsId } = this.props;
      let { masterData } = this.props;
      const addState = {};
      let allTableMap = {};
      const allReturnMap = {};
      let masterDataList = []; /* 弹窗数据集合 */
      let allDataList = {}; /* 接口返回所有数据对象集合 */
      const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === key))
        ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]
        : {}; // sButtonEnabled  sButtonParam
      /* 根据接口返回是之前调用还是之后调用 */
      this.props.onSaveState({
        loading: true,
      });
      let addStateReturn = {};
      if (commonUtils.isNotEmptyArr(interfaceArr)) {
        const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
        const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
        if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
          /* 之前调用 */
          const asyncFunc = async () => {
            for (let i = 0; i < beforeInterfaceArr.length; i++) {
              addStateReturn = await this.handleInterfaceCallDialog(beforeInterfaceArr[i], true, key, allTableMap);
            }
          };
          await asyncFunc();
        }
        if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
          /* 之后调用 */
          const asyncFunc = async () => {
            for (let i = 0; i < afterInterfaceArr.length; i++) {
              addStateReturn = await this.handleInterfaceCallDialog(afterInterfaceArr[i], true, key, allTableMap);
            }
          };
          await asyncFunc();
        }
      }
      if (addStateReturn) {
        addState.getApiDialogData = addStateReturn.returnData;
      } else {
        addState.getApiDialogData = [];
      }
      /* 弹窗的条件是 数据集数量>1 或者有this.tempCondition 切配置弹窗，否则直接将返回数据集铺到界面上 */
      if (
        (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyObject(btnConfig.sActiveId)) ||
        commonUtils.isNotEmptyObject(this.tempCondition)
      ) {
        addState.visibleApiDialog = true;
      }
      this.tempCondition = null;
      addState.loading = false;
      console.log("发票获取第三方接口：", addState);
      this.props.onSaveState({
        ...addState,
      });
    } else if (key === "BtnCancelExamine") {
      /*   消审   */
      this.props.onSaveState({
        loading: true,
      });
      /* 根据接口返回是之前调用还是之后调用 */
      if (commonUtils.isNotEmptyArr(interfaceArr)) {
        const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
        const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
        if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
          /* 之前调用 */
          let flag = 0;
          const asyncFunc = async () => {
            for (let i = 0; i < beforeInterfaceArr.length; i++) {
              const data = await this.handleInterfaceCall(beforeInterfaceArr[i]);
              if (!data) {
                flag += 1;
                return;
              }
            }
          };
          await asyncFunc();
          if (flag == 0) {
            this.props.onBtnCancelExamine();
          } else {
            this.props.onSaveState({
              loading: false,
            });
          }
        }
        if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
          /* 之后调用 */
          const result = await this.props.onBtnCancelExamine();
          if (result) {
            /* 只有审核成功 才能调用接口 -5代表审核失败 */
            const asyncFunc = async () => {
              for (let i = 0; i < afterInterfaceArr.length; i++) {
                await this.handleInterfaceCall(afterInterfaceArr[i], true);
              }
            };
            await asyncFunc();
          }
        }
      } else {
        this.props.onBtnCancelExamine();
      }
    } else if (key.indexOf("BtnBsOperation") > -1) {
      /*   作废、取消作废   */
      if (key === "BtnBsOperation.BtnInvalid") {
        obj = {
          title: bInvalid,
          handleType: "toVoid",
        };
        this.props.onChangeInvalid(obj);
      } else if (key === "BtnBsOperation.BtnCancelInvalid") {
        obj = {
          title: bInvalidCancel,
          handleType: "cancel",
        };
        this.props.onChangeInvalid(obj);
      } else {
        const name = key.split(".");
        this.props.onButtonClick(name[1]);
      }
    } else if (key === "BtnInvalid") {
      obj = {
        title: bInvalid,
        handleType: "toVoid",
      };
      this.props.onChangeInvalid(obj);
    } else if (key === "BtnCancelInvalid") {
      obj = {
        title: bInvalidCancel,
        handleType: "cancel",
      };
      this.props.onChangeInvalid(obj);
    } else if (key === "BtnGetWeight") {
      // 获取重量
      this.props.onGetWeight();
    } else if (key.indexOf("BtnCopyTo") > -1) {
      /* 复制到 */ // && commonUtils.isNotEmptyStr(e.item.props.sActiveId)

      // if (this.handleFreeDeliver(key)) return;
      this.props.onCopyTo(e.key, e.item.props["data-sactiveid"]);
    } else if (key.indexOf("BtnCopyFrom") > -1 && commonUtils.isNotEmptyStr(e.item.props["data-sactiveid"])) {
      /* 复制从 */
      obj = {
        name: e.key,
        copyFromKey: key,
        copyFromSActiveId: e.item.props["data-sactiveid"],
      };
      this.props.onCopyFrom(obj);
    } else if (key.indexOf("BtnEject") > -1) {
      /* 自定义接口弹出 */
      const { masterConfig, masterData } = this.props;
      const buttonConfig = masterConfig.gdsconfigformslave.filter(item => item.sName === "" && item.showName !== "" && item.sControlName === key);
      if (commonUtils.isNotEmptyStr(buttonConfig)) {
        const sActiveKey = buttonConfig[0].sActiveKey;
        /* 拿到表名 */
        if (commonUtils.isNotEmptyObject(sActiveKey)) {
          let tbName = "slave"; /* 表名 */
          const btnName = key; /* 按钮名 */
          let record = {}; /* 选中行 */
          let iIndex = -1;
          const splitData = sActiveKey.split(".");
          if (commonUtils.isNotEmptyStr(splitData) && splitData.length > 1) {
            tbName = splitData[0]; /* 表名 */
            if (tbName === "master") {
              record = masterData;
            } else {
              const { [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, [`${tbName}Data`]: tableData } = this.props;
              if (commonUtils.isNotEmptyStr(tableData)) {
                iIndex = tableData.findIndex(item => tableSelectedRowKeys.includes(item.sSlaveId));
                if (iIndex > -1) {
                  record = tableData[iIndex];
                }
              }
            }
          }
          this.props.onViewClick(tbName, btnName, record, iIndex);
        }
      }
    } else if (
      keyPath.indexOf("BtnBsOperation.BtnUpCheck") > -1 &&
      commonUtils.isNotEmptyStr(e.item.props["data-sactiveid"]) &&
      key.indexOf("BtnBsOperation.BtnUpCheck") < 0
    ) {
      /* 上查 */ /* key.indexOf('BtnUpCheck') < 0 用于防止用户点击二级菜单时的跳转 */
      this.props.onSearchUpDown(key, e.item.props["data-sactiveid"]);
    } else if (
      keyPath.indexOf("BtnBsOperation.BtnDownCheck") > -1 &&
      commonUtils.isNotEmptyStr(e.item.props["data-sactiveid"]) &&
      key.indexOf("BtnBsOperation.BtnDownCheck") < 0
    ) {
      /* 下查 */ /* key.indexOf('BtnDownCheck') < 0 用于防止用户点击二级菜单时的跳转 */
      this.props.onSearchUpDown(key, e.item.props["data-sactiveid"]);
    } else if (key === "BtnNext") {
      /*  下一条  */
      this.props.onNext();
    } else if (key === "BtnPrior") {
      /*  上一条  */
      this.props.onBtnPrior();
    } else if (key === "BtnFirst") {
      /*  首条  */
      this.props.onBtnFirst();
    } else if (key === "BtnLast") {
      /*  末条  */
      this.props.onBtnLast();
    } else if (key === "BtnCancel") {
      /*   取消   */
      obj = {
        title: bCancel,
      };
      this.props.onCancel(obj);
    } else if (key.indexOf("BtnPrint") > -1 && commonUtils.isNotEmptyStr(e.item.props["data-sactiveid"])) {
      /*   打印   */
      const { billnosetting, masterData } = this.props;
      let sActiveId = e.item.props["data-sActiveId"];
      if (commonUtils.isEmptyObject(sActiveId)) {
        sActiveId = e.item.props["data-sactiveid"];
      }
      if (billnosetting.sStatusType === "1") {
        /* 1:审核后打印 0:制单后打印 */
        if (!masterData.bCheck) {
          /* 未审核只能预览pdf */
          this.props.onBtnPreview(sActiveId, checkedBoolean, e.key);
        } else {
          /* 已审核:打印 */
          this.props.onBtnPrint(sActiveId, checkedBoolean, e.key);
        }
      } else {
        /* 制单后可以直接打印 */
        this.props.onBtnPrint(sActiveId, checkedBoolean, e.key);
      }
    } else if (key === "BtnDel") {
      /*   删除   */
      const sureDelTitle = commonUtils.isNotEmptyObject(this.props?.app) ? commonFunc.showMessage(this.props.app.commonConst, "SureDel") : "SureDel";
      obj = {
        title: sureDelTitle,
      };
      this.props.onDel(obj);
    } else if (key === "BtnGetGoods") {
      this.props.onGetGoods();
    } else if (key.indexOf("BtnUploadOther") > -1) {
      /*   上传   */
      const { slaveSelectedRowKeys } = this.props;
      if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
        message.warning("请先选择一条数据");
        return;
      }
      this.props.onSaveState({
        visibleOtherFilfile: true,
      });
    } else if (key.indexOf("BtnUpload_") > -1) {
      const targetField = key.replace("BtnUpload_", "");
      const fileInput = document.createElement('input');
      fileInput.type = 'file';
      fileInput.accept = 'image/*';
      fileInput.style.position = 'fixed';
      fileInput.style.left = '-9999px';
      document.body.appendChild(fileInput);

      fileInput.addEventListener('change', (e) => {
        const file = e.target.files[0];
        const formData = new FormData();
        formData.append('file', file);

        const { formId } = this.props;
        const { token } = this.props.app;
        const url = `${commonConfig.file_host}file/upload?sModelsId=${formId}&token=${token}`;
        fetch(url, {
          method: 'POST',
          body: formData,
        }).then(res => res.json()).then(response => {
          if (response.code === 1) {
            const imgUrl = response.dataset.rows[0].savePathStr;
            const { masterData = {} } = this.props;
            this.props.onSaveState({
              masterData: {
                ...masterData,
                [targetField]: imgUrl,
                handleType: masterData.handleType || 'update'
              }
            });
          } else {
            this.props.getServiceError(response);
          }
        })

        document.body.removeChild(fileInput);
      });

      fileInput.click();
    } else if (key.indexOf("BtnUpload") > -1) {
      /*   上传   */
      const { slaveSelectedRowKeys } = this.props;
      if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
        message.warning("请先选择一条数据");
        return;
      }
      this.props.onSaveState({
        visibleFilfile: true,
      });
    }else if (key.indexOf("BtnDownloadBacth") > -1) {
      /* 一键下载功能 */
      const { slaveSelectedRowKeys, slaveData, app } = this.props;

      // 检查是否选中数据
      if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
        message.warning("请先选择数据");
        return;
      }

      // 获取选中数据的文件路径
      const savePathArr = [];
      const dataSelect = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sSlaveId) || slaveSelectedRowKeys.includes(item.sId));

      if (commonUtils.isNotEmptyArr(dataSelect)) {
        dataSelect.forEach(item => {
          // 假设文件路径字段为sFilePath，根据实际数据结构调整
          if (item.sPicturePath) {
            savePathArr.push(item.sPicturePath);
          }
        });
      }

      // 如果没有找到文件路径，提示用户
      if (commonUtils.isEmptyArr(savePathArr)) {
        message.warning("选中的数据没有文件路径");
        return;
      }

      // 获取菜单名称作为压缩包文件名
      const menuName = commonUtils.isNotEmptyArr(dataSelect) ?  dataSelect[0].sZipFileName : '下载文件';
      const savePathStr = savePathArr.join(",");
      // savePathStr = 'D:/xlyweberp/printPreviewPdf/192116811110017394976081060_采购订单_标准A4_CGDD25020036.xlsx,D:/xlyweberp/printPreviewPdf/19211681211917497873921861_估价单.pdf';
      const zipFileName = `${menuName}`;

      // 调用下载接口
      const downloadUrl = `${commonConfig.file_host}file/downloadBacth`;
      this.handleOpenPostBatch(downloadUrl, savePathStr, zipFileName);

    } else if (key.indexOf("BtnEvent") > -1 || key.indexOf("BtnBatchSubmit") > -1 || key.indexOf("BtnSubmit") > -1) {
      const {
        slaveSelectedRowKeys,
        slaveData,
        formRoute,
        slave0Child1Data: controlData,
        materialsData: materialsData,
        slave0Data: processData,
      } = this.props;
      let { slaveSelectedData } = this.props;

      if (key == "BtnEventSAP" && ["/indexPage/processCardPackTableTree"].includes(this.props.formRoute)) {
        if (!commonBusiness.validatePramsNotEmpty(this.props)) return;
      }
      // if (formRoute === '/indexPage/commonList' && commonUtils.isEmptyArr(slaveSelectedData)) {
      //   message.warning('请先选择一条数据');
      //   return;
      // }
      /* 如果主体数据为空 则提示 */
      // if(location.pathname ==='/indexPage/commonCostomTabBill') {
      //   if(commonUtils.isEmptyArr(controlData) && commonUtils.isEmptyArr(processData) && commonUtils.isEmptyArr(materialsData)){
      //     message.error('主体数据不能为空！');
      //     return;
      //   }
      // }

      if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) {
        slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
      }
      this.props.onSaveState({
        loading: true,
      });
      // const slaveSelectedDataNew = this.deteleObject(slaveSelectedData); // 删除sid重复的数据
      const btnConfig = this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]; // sButtonEnabled  sButtonParam
      if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
        /* 根据接口返回是之前调用还是之后调用 */
        if (commonUtils.isNotEmptyArr(interfaceArr)) {
          const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
          const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
          const bProgressBar = btnConfig.sRelation === "progressBar";

          let bContinue = true;
          if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
            /* 之前调用 */
            let flag = 0;
            const asyncFunc = async () => {
              for (let i = 0; i < beforeInterfaceArr.length; i++) {
                if (bProgressBar) {
                  this.xlyProcessPercent = 0;
                  clearInterval(this.xlyProcessTimer);
                  message.loading({
                    content: <Progress percent={this.xlyProcessPercent} />,
                    key: "xlyProcess",
                    duration: 0,
                    className: styles.xlyProcess,
                  });
                  for (let j = 0; j < slaveSelectedRowKeys.length; j++) {
                    const slaveSelectedRowOneKey = slaveSelectedRowKeys[j];
                    const data = await this.handleInterfaceCall(beforeInterfaceArr[i], false, key, slaveSelectedRowOneKey, slaveSelectedRowOneKey);
                    if (!data) {
                      message.destroy("xlyProcess");
                      flag += 1;
                      break;
                    }
                    this.xlyProcessPercent = ((((i + 1) * (j + 1)) / (beforeInterfaceArr.length * slaveSelectedRowKeys.length)) * 100).toFixed(2);
                    message.loading({
                      content: <Progress percent={this.xlyProcessPercent} />,
                      key: "xlyProcess",
                      duration: this.xlyProcessPercent >= 100 ? 3 : 0,
                      className: styles.xlyProcess,
                    });
                  }
                } else {
                  const data = await this.handleInterfaceCall(beforeInterfaceArr[i], false, key, slaveSelectedRowKeys);
                  if (!data) {
                    flag += 1;
                    return;
                  }
                }
              }
            };
            await asyncFunc();
            if (flag == 0) {
              await this.handleBtnEent(btnConfig);
            } else {
              bContinue = false;
            }
          }
          if (commonUtils.isNotEmptyArr(afterInterfaceArr) && bContinue) {
            /* 之后调用 */
            const result = await this.handleBtnEent(btnConfig);
            if (result === 1) {
              /* 只有按钮成功 才能调用接口 -5代表审核失败 */
              const asyncFunc = async () => {
                for (let i = 0; i < afterInterfaceArr.length; i++) {
                  if (bProgressBar) {
                    this.xlyProcessPercent = 0;
                    clearInterval(this.xlyProcessTimer);
                    message.loading({
                      content: <Progress percent={this.xlyProcessPercent} />,
                      key: "xlyProcess",
                      duration: 0,
                      className: styles.xlyProcess,
                    });
                    for (let j = 0; j < slaveSelectedRowKeys.length; j++) {
                      const slaveSelectedRowOneKey = slaveSelectedRowKeys[j];
                      const data = await this.handleInterfaceCall(afterInterfaceArr[i], false, key, slaveSelectedRowOneKey, slaveSelectedRowOneKey);
                      if (!data) {
                        message.destroy("xlyProcess");
                        break;
                      }
                      this.xlyProcessPercent = ((((i + 1) * (j + 1)) / (afterInterfaceArr.length * slaveSelectedRowKeys.length)) * 100).toFixed(2);
                      message.loading({
                        content: <Progress percent={this.xlyProcessPercent} />,
                        key: "xlyProcess",
                        duration: this.xlyProcessPercent >= 100 ? 3 : 0,
                        className: styles.xlyProcess,
                      });
                    }
                  } else {
                    await this.handleInterfaceCall(afterInterfaceArr[i], false, key, slaveSelectedRowKeys);
                  }
                }
              };
              await asyncFunc();
            }
          }

          // for (const child of slaveSelectedDataNew) {
          //
          // }
        } else if (btnConfig.sButtonParam?.includes("Sp_BtnEven_CalcJsHs") && btnConfig.showName?.includes("工资核算")) {
          // 工资核算特殊处理
          const { slave3Data = [], slave3SelectedRowKeys = [] } = this.props;
          const slave3SelectedData = slave3Data.filter(item => slave3SelectedRowKeys.includes(item.sId));
          if (slave3SelectedData.length) {
            for (let i = 0; i < slave3SelectedData.length; i++) {
              const slave3DataOne = slave3SelectedData[i];
              const { sCalcProName: sCalcProDetail, sId, sCalcDepart } = slave3DataOne;
              const inParams = [
                {
                  key: "slave3",
                  value: [{ sId, sCalcProDetail }],
                },
              ];
              const percent = ((i / slave3SelectedData.length) * 100).toFixed(2);
              message.loading({ content: <Progress percent={percent} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
              await this.handleBtnEent(btnConfig, undefined, undefined, inParams);
              // message.success(`【${sCalcDepart}】核算完成。`);
            }
            message.loading({ content: <Progress percent={99} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
            message.success(`全部方案计算成功。`);
            setTimeout(() => {
              message.loading({ content: <Progress percent={100} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
            }, 1000);
            setTimeout(() => {
              message.destroy("xlyProcess");
            }, 2000);
          } else {
            message.warning("请先选择计算方案!");
          }
        } else {
          this.handleBtnEent(btnConfig);
        }
        this.props.onSaveState({
          loading: false,
        });
      } else {
        message.error(confirmSetting);
        this.props.onSaveState({
          loading: false,
        });
      }
    } else if (key.indexOf("BtnRepair") > -1) {
      if (key.toLowerCase().endsWith("choosedate")) {
        this.handleForceComplete(key, "chooseDate");
      } else if (key.includes("BtnRepairGroup") || key.includes("BtnRepairUser")) {
        /* 复制组权限单独处理 */
        this.props.onButtonClick(key);
      } else {
        /* 根据接口返回是之前调用还是之后调用 */
        if (false) {
          const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
          const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
          if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
            /* 之前调用 */

            let flag = 0;
            const asyncFunc = async () => {
              for (let i = 0; i < beforeInterfaceArr.length; i++) {
                const data = await this.handleInterfaceCall(beforeInterfaceArr[i]);
                if (!data) {
                  flag += 1;
                  return;
                }
              }
            };
            await asyncFunc();
            if (flag == 0) {
              this.handleForceComplete(key);
            }
          }
          if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
            /* 之后调用 */
            const result = await this.handleForceComplete(key);
            if (result !== -5) {
              /* 只有审核成功 才能调用接口 -5代表审核失败 */
              const asyncFunc = async () => {
                for (let i = 0; i < afterInterfaceArr.length; i++) {
                  await this.handleInterfaceCall(afterInterfaceArr[i], true);
                }
              };
              await asyncFunc();
            }
          }
        } else {
          this.handleForceComplete(key);
        }
      }
    } else if (key.indexOf("BtnApiLog") > -1) {
      /* 操作日志 */
      const { slaveSelectedRowKeys, slaveData, formRoute } = this.props;
      let { slaveSelectedData } = this.props;
      /* 根据接口返回是之前调用还是之后调用 */
      const btnConfig = commonUtils.isNotEmptyArr(this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName === key))
        ? this.props.masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]
        : {}; // sButtonEnabled  sButtonParam
      const msgInfo = commonUtils.isNotEmptyObject(btnConfig) ? btnConfig.sAssignField : "";
      if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) {
        slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
      }
      let slaveSelectedDataNew = [];
      if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
        slaveSelectedDataNew = this.deteleObject(slaveSelectedData); // 删除sid重复的数据
        if (slaveSelectedData[0].iStatus !== 0) {
          message.error(msgInfo);
          return;
        }
      }
      let ids = "";
      if (commonUtils.isNotEmptyArr(slaveSelectedDataNew)) {
        slaveSelectedDataNew.forEach(item => {
          if (commonUtils.isNotEmptyObject(item)) {
            ids += `${item.sId},`;
          }
        });
        ids = commonUtils.isNotEmptyObject(ids) ? ids.substr(0, ids.length - 1) : "";
      }
      this.handleInterfaceCallLog(ids);
    } else if (key === "BtnForceComplete" || key === "BtnNoPurchase" || key === "BtnForceComplete2" || key === "BtnForceComplete3") {
      this.handleForceComplete(key);
    } else if (key === "BtnUpPbOrder") {
      this.props.onSaveState({
        upPbOrderVisible: true,
      });
    } else if (key === "BtnDlPbOrder") {
      this.props.onSaveState({
        dlPbOrderVisible: true,
      });
    } else if (key === "BtnCommonImport") {
      this.handleImport();
    } else if (key === "BtnInit") {
      this.props.handleSlaveInit("slave");
    } else if (key === "BtnExportSql.salve") {
      this.props.handleMenuClick({ key: "formSlave" });
    } else if (key === "BtnExportSql.master") {
      this.props.handleMenuClick({ key: "formMaster" });
    } else if (key === "BtnExportSql.full") {
      this.props.handleMenuClick({ key: "fromMasterSlave" });
    } else if (key === "BtnExportSql.full") {
      this.props.handleMenuClick({ key: "fromMasterSlave" });
    } else if (key === "BtnCopy2Custom") {
      this.props.handleCopy2Custom();
    } else if (key === "BtnModuleSql.sModuleSql") {
      this.props.handleSqlDownload("single");
    } else if (key === "BtnModuleSql.sModule2Sql") {
      this.props.handleSqlDownload("all");
    } else if (key === "BtnFileImposition") {
      this.setState({
        fileImpositionData: {
          visible: true,
          onCancel: () => {
            this.setState({ fileImpositionData: null });
          },
          onOk: () => {
            this.setState({ fileImpositionData: null });
          },
          onSaveState: obj => {
            this.setState({
              fileImpositionData: { ...this.state.fileImpositionData, ...obj },
            });
          },
          onSaveState1: this.props.onSaveState,
        },
      });
    } else if (key === "BtnSendCombined") {
      const { masterConfig, sModelsId } = this.props;
      const { makeUpPDFRecord } = this.state;
      const config = masterConfig.gdsconfigformslave.find(x => x.sControlName === key) || makeUpPDFRecord.picArrConfig;
      if (!config?.sActiveId) {
        message.error("请先配置弹出界面");
        return;
      }
      this.setState({
        makeUpPDFData: {
          pdfMakeUpVisible: true,
          makeUpPDFRecord,
          title: config.showName,
          onCancel: (bRefreshTable) => {
            if (bRefreshTable && this.props.onBtnSearch) {
              this.props.onBtnSearch();
            }
            this.setState({ makeUpPDFData: null, makeUpPDFRecord: undefined });
            this.props.onSaveState({
              makeUpPDFRecord: undefined,
            });
          },
          onOk: () => {
            this.setState({ makeUpPDFData: null, makeUpPDFRecord: undefined });
            this.props.onSaveState({
              makeUpPDFRecord: undefined,
            });
          },
          selectData: this.props.slaveData.filter(x => this.props.slaveSelectedRowKeys.includes(x.sSlaveId || x.sId)),
          app: {
            ...this.props.app,
            currentPane: {
              name: "pdfMakeUp",
              config,
              title: "文件拼板",
              route: "element/pdfMakeUp",
              formId: config.sActiveId,
              key: `${sModelsId}${config.sActiveId}`,
              sModelsType: "element/pdfMakeUp",
            },
          },
          sModelsId: config.sActiveId,
          formSrcRoute: "element/pdfMakeUp",
          dispatch: this.props.dispatch,
          content: this.props.content,
          config,
          enabled: true,
        },
      });
    } else if (key === "BtnBoxData") {
      // 盒型设计弹窗
      // 获取页面上的盒型数据
      const { masterConfig, sModelsId } = this.props;
      const { makeUpPDFRecord } = this.state;
      const config = masterConfig.gdsconfigformslave.find(x => x.sControlName === key) || makeUpPDFRecord.picArrConfig;
      const makeConfig = masterConfig.gdsconfigformslave.find(x => x.sControlName === "sMakeUpFile")
      if (!config?.sActiveId) {
        message.error("请先配置弹出界面");
        return;
      }
      this.setState({
        BtnBoxData: {
          state:{...this.props},
          boxVisible: true,
          makeUpPDFRecord,
          title: config.showName,

          onCancel: () => {
            this.setState({ BtnBoxData: null, makeUpPDFRecord: undefined });
            this.props.onSaveState({
              makeUpPDFRecord: undefined,
            });
          },
          onOk: (obj) => {
            this.setState({ BtnBoxData: null, makeUpPDFRecord: undefined ,slaveData:obj.slaveData,masterData:obj.masterData});
            this.props.onSaveState({
              slaveData:obj.slaveData,
              masterData:obj.masterData
            });
          },
          selectData: this.props.slaveData.filter(x => this.props.slaveSelectedRowKeys.includes(x.sSlaveId || x.sId)),
          app: {
            ...this.props.app,
            currentPane: {
              name: "boxDesign",
              config,
              title: "盒型设计",
              route: "element/boxDesign",
              formId: config.sActiveId,
              key: `${sModelsId}${config.sActiveId}`,
              sModelsType: "element/boxDesign",
              sActiveName:config.sActiveName
            },
          },
          sModelsId: config.sActiveId,
          formSrcRoute: "element/boxDesign",
          dispatch: this.props.dispatch,
          content: this.props.content,
          config,
          makeConfig,
          enabled: true,
        },
      });
    } else if (this.props.onButtonClick !== undefined) {
      this.props.onButtonClick(key);
    }
  };

  // 删除当前pane
  handleClosePane = (btnConfig, callback) => {
    const { showName, sButtonParam } = btnConfig;
    /* 若sButtonParam含有 bClose": true 则关闭当前页签*/
    let bClose = false; /* 是否关闭当前页签 */
    let bRefreshBefore = false; /* 是否刷新之前列表 */
    if (sButtonParam && commonUtils.isJSON(sButtonParam)) {
      const jsonObj = JSON.parse(sButtonParam);
      if (jsonObj.bClose) {
        bClose = true;
      }
      if (jsonObj.bRefreshBefore) {
        bRefreshBefore = true;
      }
    }
    if (bClose) {
      const { panes, currentPane } = this.props.app;
      const currentPaneIndex = panes.findIndex(item => item.key === currentPane.key);
      if (currentPaneIndex > 0) {
        const newPanes = panes.filter(item => item.key !== currentPane.key);
        this.props.dispatch({
          type: "app/removePane",
          payload: { changePanes: newPanes, currentPane: panes[currentPaneIndex - 1] },
        }); /* 关闭当前页签 */
      }
      if (bRefreshBefore) {
        if (currentPane.refresh !== undefined) {
          currentPane.refresh();
        }
      }
    } else {
      callback();
    }
  };
// 在handleOpenPost方法后添加批量下载方法
  handleOpenPostBatch = (url, savePathStr, zipFileName) => {
    console.log('222', {url, savePathStr, zipFileName})
    const newWin = window.open();
    let formStr = "";
    formStr =
      `<form style="visibility:hidden;" method="POST" action="${url}">` +
      `<input type="hidden" name="savePathStr" value='${savePathStr}' />` +
      `<input type="hidden" name="zipFileName" value='${zipFileName}' />` +
      "</form>";
    newWin.document.body.innerHTML = formStr;
    newWin.document.forms[0].submit();
    return newWin;
  };
  handleSubmit = () => {
    // 保存前手机号、邮箱校验
    let checkResult = true;
    const { masterData = {}, masterConfig = {} } = this.props;
    const { gdsconfigformslave = [] } = masterConfig;

    const sDateFormatTypeList = ["phone", "mobile", "mail", "postcode"];
    const fieldsList = gdsconfigformslave.filter(item => item.bVisible && item.sDateFormat && sDateFormatTypeList.includes(item.sDateFormat));

    for (let i = 0; i < fieldsList.length; i++) {
      const config = fieldsList[i];
      const { sName, showName, sDateFormat } = config;
      const value = masterData[sName];

      if (value === undefined || value === "") {
        continue;
      }

      if (sDateFormat === "phone") {
        const reg = /^0\d{2,3}-\d{7,8}$/;
        const reg1 = /^1[0-9]{10}$/;
        const reg2 = /^0\d{2,3}-\d{7,8}-\d{1,8}$/;
        if (!reg.test(value) && !reg1.test(value) && !reg2.test(value)) {
          message.warning(`【${showName}】【${sName}】格式不正确！`);
          checkResult = false;
          break;
        }
      } else if (sDateFormat === "mobile") {
        const reg = /^0\d{2,3}-\d{7,8}$/;
        const reg1 = /^1[0-9]{10}$/;
        const reg2 = /^0\d{2,3}-\d{7,8}-\d{1,8}$/;
        if (!reg.test(value) && !reg1.test(value) && !reg2.test(value)) {
          message.warning(`【${showName}】【${sName}】格式不正确！`);
          checkResult = false;
          break;
        }
      } else if (sDateFormat === "mail") {
        const reg = /^[a-zA-Z0-9]{1,20}@[a-zA-Z0-9]{1,5}\.[a-zA-Z0-9]{1,5}$/;
        if (!reg.test(value)) {
          message.warning(`【${showName}】【${sName}】格式不正确！`);
          checkResult = false;
          break;
        }
      } else if (sDateFormat === "postcode") {
        const reg = /^[1-9][0-9]{5}$/;
        if (!reg.test(value)) {
          message.warning(`【${showName}】【${sName}】格式不正确！`);
          checkResult = false;
          break;
        }
      }
    }

    // 客户简码校验
    // if (masterData.sBuSort2) {
    //   const reg = /^(?:[A-Z]{4}|[A-Z]{2}\d{2}|[A-Z]{3}\d)$/;
    //   if (!reg.test(masterData.sBuSort2)) {
    //     message.warning(`【客户简码】格式不正确【正确格式：大写字母+数字（共四位）】！`);
    //     checkResult = false;
    //   }
    // }

    if (checkResult) {
      // 验证各种工序参数的必填项
      if (!commonBusiness.validatePramsNotEmpty(this.props)) return;
      this.props.onSubmit();
    } else {
      this.props.onSaveState({
        loading: false,
      });
    }
  };

  deteleObject = (obj = []) => {
    // eslint-disable-next-line camelcase
    const replace_data = obj;
    const result = []; // 去重后的数组对象集合
    const hash = {};
    // eslint-disable-next-line no-plusplus
    for (let i = 0; i < replace_data.length; i++) {
      const elem = replace_data[i].sId;
      if (!hash[elem]) {
        result.push(replace_data[i]);
        hash[elem] = true;
      }
    }
    return result;
  };

  handleCheckButton = key => {
    let sErrorInfo = "";
    const sCheckName = "s" + key + "ErroMsg";
    /* sControlName + ErrorMsg 看数据集是否包含，包含则提示出来 */
    let tableName = "";
    if (location.pathname && location.pathname.includes("List")) {
      tableName = "slave";
    } else {
      tableName = "master";
    }
    if (commonUtils.isNotEmptyObject(tableName)) {
      const { [`${tableName}Data`]: tableData, [`${tableName}SelectedRowKeys`]: tableSelectedRowKeys } = this.props;
      if (tableName === "master" && commonUtils.isNotEmptyObject(tableData)) {
        sErrorInfo = tableData[sCheckName];
      } else if (commonUtils.isNotEmptyArr(tableData)) {
        const iIndex = tableData.findIndex(item => tableSelectedRowKeys.includes(item.sSlaveId));
        if (iIndex > -1) {
          const tableRow = tableData[iIndex];
          if (commonUtils.isNotEmptyObject(tableRow[sCheckName])) {
            sErrorInfo = tableRow[sCheckName];
          }
        }
      }
    }
    return sErrorInfo;
  };

  handleToolBarKeyDown = e => {
    /* 前端CTRL+ALT+G后，如果没有数据默认跳转第一个配置的数据 */
    if (e.ctrlKey && (e.altKey || e.metaKey) && e.keyCode === 71) {
      /* CTRL+ALT+G F7 设置界面 */
      const { sType } = this.props?.app?.userinfo || {};
      if (!["sysadmin"].includes(sType)) {
        return;
      }
      if (commonUtils.isNotEmptyObject(this.props)) {
        let name = "master";
        if (location.pathname.includes("commonList")) {
          name = "slave";
        }
        console.log("name", name);
        const { [`${name}Config`]: tableConfig } = this.props;
        if (commonUtils.isNotEmptyArr(tableConfig)) {
          const myTableConfig = JSON.parse(JSON.stringify(tableConfig));
          myTableConfig.sActiveId = "16411004790004762980820285096000";
          /* 找到配置的第一个字段 */
          const columnArr = tableConfig.gdsconfigformslave.filter(child => child.sName !== "" && child.bVisible && child.showName !== "");
          const sName = commonUtils.isNotEmptyArr(columnArr) ? columnArr[0].sName : "";
          myTableConfig.sName = sName;
          const myTableConfigArr = [];
          myTableConfigArr.push(myTableConfig);
          if (name === "master") {
            /* 主表 */
            this.props.onViewClick(name, "myTableConfig", {}, 0, myTableConfigArr, "");
          } else {
            /* 从表 */
            this.props.onViewClick(name, "myTableConfig", {}, 0, myTableConfigArr, "");
          }
        }
      }
    }
  };

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

  /* 调用后台配置的接口 */
  handleInterfaceCall = async (obj, showTip, key, ids, slaveSelectedRowKeysOld) => {
    let bResult = false;
    const { app, sModelsId, masterData, slaveData, masterConfig, slaveFilterCondition } = this.props;
    const slaveSelectedRowKeys = slaveSelectedRowKeysOld || this.props.slaveSelectedRowKeys;
    const sInterfaceName = obj.sInterfaceName;
    /* 如果key是BtnSendList 传从表的主键集合 */
    let idArr = "";
    /* 如果有对应字段 则取对应字段 ,否则 取默认值 */
    const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === key))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]
      : {};

    let sActiveKey = "";
    if (commonUtils.isNotEmptyObject(btnConfig)) {
      sActiveKey = btnConfig.sActiveKey;
    }
    if (sActiveKey) {
      if (sActiveKey.includes("master.sId")) {
        idArr = masterData.sId;
      }
    } else if (key && (key.includes("BtnSendList") || key.includes("BtnBatchExamine"))) {
      if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        slaveSelectedRowKeys.forEach(item => {
          if (commonUtils.isNotEmptyObject(item)) {
            idArr += `${item},`;
          }
        });
        idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : "";
      }
    } else if (location.pathname.includes("commonList")) {
      const { slaveSelectedRowKeys, slaveData } = this.props;
      let { slaveSelectedData } = this.props;
      if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) {
        slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
      }
      const slaveSelectedDataNew = this.deteleObject(slaveSelectedData); // 删除sid重复的数据

      if (commonUtils.isNotEmptyArr(slaveSelectedDataNew)) {
        slaveSelectedDataNew.forEach(item => {
          if (commonUtils.isNotEmptyObject(item)) {
            idArr += `${item.sId},`;
          }
        });
        idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : "";
      }
      if (commonUtils.isNotEmptyObject(ids)) {
        /* 如果是勾选多行 则sId为循环的每一条 */
        idArr = ids;
      }
    } else {
      idArr = masterData.sId;
    }
    const value = {
      sId: commonUtils.isNotEmptyObject(idArr) ? idArr : commonUtils.isNotEmptyObject(ids) ? ids : masterData.sId,
      sSlaveId: slaveSelectedRowKeys?.toString(),
      masterData,
      userInfo: app.userinfo,
    };
    if (location.pathname.includes("commonList") && commonUtils.isNotEmptyArr(slaveFilterCondition)) {
      value.bFilter = JSON.stringify(slaveFilterCondition);
    }
    const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`;
    const returnData = (await commonServices.postValueService(app.token, value, url, app)).data;
    if (showTip) {
      if (!returnData || returnData.code < 0) {
        if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -8) {
          Modal.info({
            title: "温馨提示:",
            content: <div>{this.handleGetMsg(returnData.msg)}</div>,
            okText: "确认",
            onOk() {},
          });
        } else {
          Modal.info({
            title: "温馨提示:",
            content: <div>{this.handleGetMsg(returnData.msg)}</div>,
            okText: "确认",
            onOk() {},
          });
          return;
        }
        // message.error('同步INFOR失败！');
        return;
      } else {
        // message.success('同步INFOR成功！');
      }
    }
    if (!returnData) {
      message.error("接口调用失败！");
      return false;
    }
    if (returnData.code === 1) {
      bResult = true;
      // message.success(returnData.msg);
    } else if (returnData.code === 2) {
      // Modal.info({
      //   title: '温馨提示:',
      //   content: (
      //     <div>
      //       {this.handleGetMsg(returnData.msg)}
      //     </div>
      //   ),
      //   okText: '确认',
      //   onOk() {},
      // });
      bResult = true;
    } else if (returnData.code === -8) {
      Modal.info({
        title: "温馨提示:",
        content: <div>{this.handleGetMsg(returnData.msg)}</div>,
        okText: "确认",
        onOk() {},
      });
      bResult = false;
    } else {
      bResult = false;
      this.props.getServiceError(returnData);
    }
    /* 若配置的是按钮后调用第三方, 则调用成功后 需要重新回刷一次数据 */
    if (commonUtils.isNotEmptyObject(obj) && obj.sInterfaceCallMethod === "2") {
      if (bResult) {
        this.props.onButtonClick("BtnRefresh");
      }
    }
    return bResult;
  };

  /* 调用后台配置的接口 */
  handleInterfaceCallDialog = async (obj, showTip, key, map) => {
    const addState = {};
    let bResult = false;
    const { app, sModelsId, masterData, slaveSelectedRowKeys } = this.props;
    const sInterfaceName = obj.sInterfaceName;
    /* 如果key是BtnSendList 传从表的主键集合 */
    let idArr = "";
    if (key && key.includes("BtnSendList")) {
      if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        slaveSelectedRowKeys.forEach(item => {
          if (commonUtils.isNotEmptyObject(item)) {
            idArr += `${item},`;
          }
        });
        idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : "";
      }
    }
    const value = { sId: key === "BtnSendList" ? idArr : masterData.sId, masterData, userInfo: app.userinfo, data: map };
    const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`;
    const returnData = (await commonServices.postValueService(app.token, value, url, app)).data;

    /*
      -1: 提示returnData.msg的信息（message.error）
      -8: 提示提示returnData.msg的信息(Modal温馨提示)
      1: 提示returnData.msg的信息（message.sucess）
      2: 提示提示returnData.msg的信息(Modal温馨提示)
    **/

    if (showTip) {
      if (!returnData || returnData.code < 1) {
        if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -8) {
          Modal.info({
            title: "温馨提示:",
            content: <div>{this.handleGetMsg(returnData.msg)}</div>,
            okText: "确认",
            onOk() {},
          });
        } else if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -1) {
          message.error(returnData.msg);
        }
        return;
      } else if (returnData.code === 2) {
        Modal.info({
          title: "温馨提示:",
          content: <div>{this.handleGetMsg(returnData.msg)}</div>,
          okText: "确认",
          onOk() {},
        });
      } else {
        // message.success('同步INFOR成功！');
      }
    }
    let inforEvent = ["itemiss", "jobmatliss", "jobmatliss-bz", "jobmatliss-tl", "jobmatliss-cx"];
    if (obj && inforEvent.indexOf(obj.sInterfaceName) !== -1) {
      if (!returnData || returnData.code < 1) {
        if (returnData) {
          if (returnData.code === -8) {
            Modal.info({
              title: "温馨提示:",
              content: <div>{this.handleGetMsg(returnData.msg)}</div>,
              okText: "确认",
              onOk() {},
            });
          } else {
            message.error(returnData.erroMsg || returnData.msg);
          }
        } else {
          message.error("审核失败！");
        }
        return false;
      }
    }
    if (commonUtils.isNotEmptyObject(returnData)) {
      if (returnData.code > 0) {
        bResult = true;
        if (commonUtils.isNotEmptyObject(returnData.data) && commonUtils.isNotEmptyObject(returnData.data.dataList)) {
          addState.returnData = returnData.data.dataList;
        }
      } else if (returnData.code === -8) {
        Modal.info({
          title: "温馨提示:",
          content: <div>{this.handleGetMsg(returnData.msg)}</div>,
          okText: "确认",
          onOk() {},
        });
      } else {
        message.error(returnData.erroMsg || returnData.msg);
      }
    } else {
      bResult = false;
      this.props.getServiceError(returnData);
    }
    addState.bResult = bResult;
    // addState.returnData = datalist;
    return addState;
  };

  /* 调用后台配置的日志接口 */
  handleInterfaceCallLog = async ids => {
    let bResult = false;
    const { app, sModelsId } = this.props;
    const value = { userInfo: app.userinfo };
    const url = `${commonConfig.interface_host}interfaceDefine/callthirdpartyByLogId/${ids}?sModelsId=${sModelsId}`;
    const returnData = (await commonServices.postValueService(app.token, value, url, app)).data;
    if (!returnData) {
      message.error("接口调用失败！");
      return false;
    }
    if (returnData.code === 1) {
      bResult = true;
      // message.success(returnData.msg);
    } else if (returnData.code === 2) {
      Modal.info({
        title: "温馨提示:",
        content: <div>{this.handleGetMsg(returnData.msg)}</div>,
        okText: "确认",
        onOk() {},
      });
      bResult = true;
    } else if (returnData.code === -8) {
      Modal.info({
        title: "温馨提示:",
        content: <div>{this.handleGetMsg(returnData.msg)}</div>,
        okText: "确认",
        onOk() {},
      });
      bResult = false;
    } else {
      bResult = false;
      this.props.getServiceError(returnData);
    }
    return bResult;
  };

  /* 新增 */
  handleAdd = () => {
    this.props.onAdd();
  };

  /* 新增子级 */
  handleAddChild = obj => {
    this.props.onAddChild(obj);
  };

  handleRefresh = () => {
    this.props.onButtonClick("BtnRefresh");
  };
  handleFilfileManageCancel = modelVisible => {
    const { slaveConfig, sModelsId } = this.props;
    if (["12710101117013204247130"].includes(sModelsId)) {
      this.props.onGetData(slaveConfig);
    }
    this.props.onSaveState({ [modelVisible]: false });
  };

    onSaveFaceSuccess = () => {
    // 人脸采集成功后关闭弹窗
    this.props.onSaveState({ addFaceVisible: false });
    message.success("人脸采集成功");
  };
  handleFilfileManageOk = (modelVisible, selectConfig, filfileSelectedData, sSrcSlaveId, filfileDelData) => {
    if (commonUtils.isNotEmptyObject(sSrcSlaveId) && !location.pathname.includes("commonList")) {
      /* 工单、工艺卡、报价单控制表数据带回 */
      let controlFilfileData = [];
      let controlFilfileDelData = [];
      if (commonUtils.isNotEmptyArr(filfileSelectedData)) {
        controlFilfileData = filfileSelectedData.filter(item => item.sSrcSlaveId === sSrcSlaveId); /* 控制表选中行上传的图片数组 */
      }
      if (commonUtils.isNotEmptyArr(filfileDelData)) {
        controlFilfileDelData = filfileDelData.filter(item => item.sSrcSlaveId === sSrcSlaveId);
      }
      const { sActiveId } = selectConfig;
      if (sActiveId && location.pathname.includes("processCardPackTableTree")) {
        // 印品PBOM专用附件回调
        this.props.onFilfileManageOk1 &&
          this.props.onFilfileManageOk1({
            controlFilfileData,
            controlFilfileDelData,
            sSrcSlaveId,
          });
      } else {
        // 通用附件回调
        this.props.onFilfileManageOk(controlFilfileData, controlFilfileDelData, sSrcSlaveId);
      }
    }
    this.props.onSaveState({ [modelVisible]: false, visibleOtherFilfile: false }, () => {
      const { sAfterClickInstruct, showName } = selectConfig;
      if (sAfterClickInstruct) {
        instructSet({
          ...this.props,
          slavepupData: filfileSelectedData,
          btnConfig: { sInstruct: sAfterClickInstruct, showName },
        });
      }
    });
  };

  handleSelectDialog = (name, selectConfig, selectData) => {
    this.props.onSelectDialog(name, selectConfig, selectData, "master");
  };
  handleDialogCancel = () => {
    this.props.onSaveState({ visibleInterfaceDialog: false });
  };
  // 获取订单中的取消
  handleCancel = () => {
    this.setState({
      inputChange: "",
    });
    this.props.onGetGoodsCancle();
  };
  // 获取订单中的确定
  handleOk = () => {
    this.props.onGetGoodsValue(this.state.inputChange);
  };
  // 获取订单中的值变化
  handleInputChange = e => {
    this.setState({
      inputChange: e.target.value,
    });
  };
  radioClick = (Child, e) => {
    e.stopPropagation();
    const { printData } = this.state;
    const iIndex = printData.findIndex(item => item.checkedId === Child.sControlName);
    if (iIndex === -1) {
      const printObj = {};
      printObj.checked = e.target.checked;
      printObj.checkedId = Child.sControlName;
      printData.push(printObj);
    } else {
      printData[iIndex] = { ...printData[iIndex], checked: e.target.checked };
    }

    this.setState({
      // eslint-disable-next-line react/no-unused-state
      // checked: e.target.checked, checkedId: Child.sControlName,
      printData,
    });
  };
  // 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析，配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"}
  handleBtnEent = async (btnConfig, name, sValue, nextInParams) => {
    this.xlyProcessPercent = 0;
    clearInterval(this.xlyProcessTimer);
    if (this.props.app?.currentPane?.title === "工单损耗及无形损跟踪" && btnConfig?.sControlName === "BtnEventAllWork") {
      message.loading({ content: <Progress percent={0} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
      this.xlyProcessTimer = setInterval(() => {
        if (this.xlyProcessPercent >= 50) {
          this.xlyProcessPercent += 0.2;
        } else if (this.xlyProcessPercent >= 90) {
          return;
        } else {
          this.xlyProcessPercent += 0.5;
        }
        message.loading({ content: <Progress percent={this.xlyProcessPercent} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
      }, 500);
    }
    this.props.onSaveState({
      pageLoading: true,
    });
    const { menuData } = this.state;
    let iResult = 0;
    let bFirst = false;
    if (
      commonUtils.isNotEmptyObject(btnConfig) &&
      (btnConfig.sControlName === "BtnEventReceiveReturn" || btnConfig.sControlName === "BtnEventReceive")
    ) {
      // 刀模归还, 刀模领用判断是否选择数据
      const { slaveSelectedRowKeys, app } = this.props;
      if (slaveSelectedRowKeys && commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
        this.props.onSaveState({
          pageLoading: false,
        });
        return;
      }
    }

    if (commonUtils.isNotEmptyObject(btnConfig) && btnConfig.sControlName.includes("BtnEventAutoOrder")) {
      // 刀模归还, 刀模领用判断是否选择数据
      bFirst = true; /* 沒有选中行时 默认第一条 */
    }
    const { masterData, sCurrMemoProps, masterConditionData } = this.props;
    if (commonUtils.isNotEmptyObject(name) && name.indexOf("BtnRepair") > -1 && commonUtils.isNotEmptyObject(sCurrMemoProps)) {
      sCurrMemoProps.bVisibleMemo = false;
      this.props.onSaveState({ sCurrMemoProps });
    }
    const sButtonParam = btnConfig.sButtonParam;
    console.log("11", btnConfig);
    const btn = commonUtils.convertStrToObj(sButtonParam);
    const sProName = btn.sproName;
    const inParams = [];
    const inMap = btn.inMap;
    const inlist = inMap ? inMap.split(",") : [];
    const masterArr = [];
    const masterConditionArr = [];
    const slaveArr = [];
    const slaveInfoArr = [];
    const controlArr = [];
    const materialsArr = [];
    const processArr = [];
    const sTableName = btn.sTableName;

    if (!sTableName && !inMap) {
      // 都为undefined时直接退出
      this.props.onSaveState({
        pageLoading: false,
      });
      return;
    }

    if (inlist.length > 0) {
      inlist.forEach(item => {
        const itemArr = item.split(".");
        if (itemArr.length > 0) {
          const sname = itemArr[0];
          const stype = itemArr[1];
          const stypeNew = itemArr.length > 2 ? itemArr[2] : stype;
          if (commonUtils.isNotEmptyStr(sname) && sname === "master") {
            masterArr.push([stype, stypeNew]);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "masterCondition") {
            /* 参数数据集 */
            masterConditionArr.push([stype, stypeNew]);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "slave") {
            slaveArr.push([stype, stypeNew]);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "slaveInfo") {
            slaveInfoArr.push([stype, stypeNew]);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "control") {
            controlArr.push([stype, stypeNew]);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "materials") {
            materialsArr.push([stype, stypeNew]);
          }
          if (commonUtils.isNotEmptyStr(sname) && sname === "process") {
            processArr.push([stype, stypeNew]);
          }
          if (
            commonUtils.isNotEmptyStr(sname) &&
            !["master", "masterCondition", "slave", "slaveInfo", "control", "materials", "process"].includes(sname)
          ) {
            const addState = this.handleProParams(sname, [[stype, stypeNew]]);
            if (commonUtils.isNotEmptyObject(addState)) {
              inParams.push({ ...addState });
            }
          }
        }
      });

      if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
        const addState = {};
        addState.key = "master";
        const val = [];
        const currVal = {};
        masterArr.forEach(([stype, stypeNew]) => {
          currVal[`${stypeNew}`] = masterData[`${stype}`];
        });
        val.push(currVal);
        addState.value = val;
        inParams.push({ ...addState });
      }
      if (commonUtils.isNotEmptyArr(masterConditionArr) && commonUtils.isNotEmptyObject(masterConditionData)) {
        const addState = {};
        addState.key = "masterCondition";
        const val = [];
        const currVal = {};
        masterConditionArr.forEach(filed => {
          currVal[`${filed}`] = masterConditionData[`${filed}`];
        });
        val.push(currVal);
        addState.value = val;
        inParams.push({ ...addState });
      }
      if (commonUtils.isNotEmptyArr(slaveArr)) {
        const addState = this.handleProParams("slave", slaveArr, bFirst);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(slaveInfoArr)) {
        const addState = this.handleProParams("slaveInfo", slaveInfoArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(controlArr)) {
        const addState = this.handleProParams("control", controlArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(materialsArr)) {
        const addState = this.handleProParams("materials", materialsArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
      if (commonUtils.isNotEmptyArr(processArr)) {
        const addState = this.handleProParams("process", processArr);
        if (commonUtils.isNotEmptyObject(addState)) {
          inParams.push({ ...addState });
        }
      }
    }

    if (commonUtils.isNotEmptyStr(sTableName) && commonUtils.isNotEmptyArr(inParams)) {
      inParams.forEach(item => {
        if (commonUtils.isNotEmptyArr(item.value)) {
          item.value.forEach(item1 => {
            item1.sTableName = sTableName;
          });
        }
      });
    }

    /* 列表增加查询条件的传参 */
    if (
      location.pathname?.includes("indexPage/commonList") &&
      (btnConfig?.sControlName === "BtnEventOneWork" || btnConfig?.sControlName === "BtnEventAllWork")
    ) {
      const { slaveFilterCondition = [] } = this.props;
      if (commonUtils.isNotEmptyArr(slaveFilterCondition) && commonUtils.isNotEmptyArr(inParams)) {
        inParams.forEach(item => {
          item.bFilter = slaveFilterCondition;
        });
      }
      console.log("inParams", inParams);
    }

    const iIndex = commonUtils.isNotEmptyObject(btnConfig) ? menuData.findIndex(item => item.sControlName === btnConfig.sControlName) : -1;
    let interfaceArr = [];
    if (iIndex > -1) {
      interfaceArr = menuData[iIndex].interface;
    }
    if (commonUtils.isNotEmptyArr(interfaceArr) && commonUtils.isNotEmptyObject(btnConfig) && btnConfig.sControlName.includes("BtnRepair")) {
      if (true) {
        const { slaveSelectedRowKeys, app, slaveData } = this.props;
        if (inMap && inMap.includes("slave.") && slaveSelectedRowKeys && commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
          message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
          this.props.onSaveState({
            pageLoading: false,
          });
          return;
        }
        let slaveRow = {};
        const iSlaveDataIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
        if (iSlaveDataIndex > -1) {
          slaveRow = slaveData[iSlaveDataIndex];
        }
        let ids = "";
        if (location.pathname.includes("commonList")) {
          let { slaveSelectedData } = this.props;
          if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) {
            slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
          }
          const slaveSelectedDataNew = this.deteleObject(slaveSelectedData); // 删除sid重复的数据
          if (commonUtils.isNotEmptyArr(slaveSelectedDataNew)) {
            slaveSelectedDataNew.forEach(item => {
              if (commonUtils.isNotEmptyObject(item)) {
                ids += `${item.sId},`;
              }
            });
            ids = commonUtils.isNotEmptyObject(ids) ? ids.substr(0, ids.length - 1) : "";
          }
        } else {
          ids = slaveRow.sId;
        }
        const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
        const afterInterfaceArr = commonUtils.isNotEmptyArr(interfaceArr) ? interfaceArr.filter(item => item.sInterfaceCallMethod === "2") : [];
        if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
          /* 之前调用 */
          let flag = 0;
          const asyncFunc = async () => {
            for (let i = 0; i < beforeInterfaceArr.length; i++) {
              const data = await this.handleInterfaceCall(beforeInterfaceArr[i], true, btnConfig.sControlName, ids);
              if (!data) {
                flag += 1;
                this.props.onSaveState({
                  pageLoading: false,
                });
                return;
              }
            }
          };
          await asyncFunc();
          if (flag == 0) {
            await this.handleProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParams, changeValue: sValue, sButtonParam: btn }));
          }
        }
        if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
          /* 之后调用 */
          const result = await this.handleProcedureCall(
            btnConfig,
            sProName,
            JSON.stringify({ params: inParams, changeValue: sValue, sButtonParam: btn })
          );
          console.log("result", result);
          if (result > 0) {
            /* 只有成功 才能调用接口 -5代表失败 */
            const asyncFunc = async () => {
              for (let i = 0; i < afterInterfaceArr.length; i++) {
                await this.handleInterfaceCall(afterInterfaceArr[i], true, btnConfig.sControlName, ids);
              }
            };
            await asyncFunc();
          }
        }
      }
    } else {
      const inParamsNew = nextInParams || inParams;
      iResult = await this.handleProcedureCall(btnConfig, sProName, JSON.stringify({ params: inParamsNew, changeValue: sValue, sButtonParam: btn }));
    }

    if (this.props.app?.currentPane?.title === "工单损耗及无形损跟踪" && btnConfig?.sControlName === "BtnEventAllWork") {
      clearInterval(this.xlyProcessTimer);
      this.xlyProcessPercent = 91;
      message.loading({ content: <Progress percent={91} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
      this.xlyProcessTimer = setInterval(() => {
        this.xlyProcessPercent += 1;
        message.loading({ content: <Progress percent={this.xlyProcessPercent} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
        if (this.xlyProcessPercent === 100) {
          clearInterval(this.xlyProcessTimer);
          setTimeout(() => {
            message.destroy();
          }, 1000);
        }
      }, 100);
    }

    this.props.onSaveState({
      pageLoading: false,
    });
    return iResult;
  };
  // 存储过程按钮调用存储过程
  handleProcedureCall = async (btnConfig, proName, proInParam, other) => {
    const { app, sModelsId } = this.props;
    let iResult = 0;
    const sBtnName = btnConfig.sControlName;
    const value = { sProName: proName, sProInParam: proInParam, sBtnName };
    if (other?.iFlag === 1) {
      value.iFlag = 1;
    }
    const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
    // const url  = '';
    const returnData = (await commonServices.postValueService(app.token, value, url)).data;
    if (proName === "Sp_BtnEven_CalcJsHs") {
      if (returnData.code === 1) {
        message.success(returnData.msg);
      } else {
        message.warning(returnData.msg);
      }
      const proInParamJson = commonUtils.convertStrToObj(proInParam);
      const sId = proInParamJson.params?.[0]?.value?.[0]?.sId;
      const { slave3Data = [] } = this.props;
      const iIndex = slave3Data.findIndex(item => item.sId === sId);
      if (iIndex !== -1) {
        slave3Data[iIndex].sCalcProDetail = returnData.msg;
        this.props.onSaveState({ slave3Data });
      }
    } else if (returnData.code === 1) {
      message.success(returnData.msg);
      this.handleClosePane(btnConfig, () => {
        this.props.onButtonClick("BtnRefresh");
      });
    } else if (returnData.code === -8) {
      Modal.info({
        title: "温馨提示:",
        content: <div>{this.handleGetMsg(returnData.msg)}</div>,
        okText: "确认",
        onOk() {},
      });
    } else {
      this.props.getServiceError({ ...returnData, fn: () => this.handleProcedureCall(btnConfig, proName, proInParam, { iFlag: 1 }) });
    }
    iResult = returnData.code;
    this.props.onSaveState({ loading: false });
    // 点击返回重排的时候刷新树
    if (btnConfig.sControlName === "BtnEventReturn") {
      if (this.props.refreshTreeData) {
        this.props.refreshTreeData();
      }
    }
    return iResult;
  };
  // 根据配置解析拼接具体参数
  handleProParams = (sKey, arr, bFirst) => {
    const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props;
    let keyData =
      commonUtils.isNotEmptyArr(tableData) && commonUtils.isNotEmptyArr(selectedRowKeys)
        ? tableData.filter(
            item => commonUtils.isEmptyObject(item.sDivRowNew) && (selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId))
          )
        : [];
    if (bFirst) {
      /* 没有选中行时默认第一条 */
      if (commonUtils.isNotEmptyArr(tableData)) {
        keyData = [tableData[0]];
      }
    }
    if (commonUtils.isNotEmptyArr(keyData)) {
      const addState = {};
      addState.key = sKey;
      const val = [];
      keyData.forEach(currData => {
        const currVal = {};
        arr.forEach(([stype, stypeNew]) => {
          currVal[`${stypeNew}`] = currData[`${stype}`];
        });
        val.push(currVal);
      });
      addState.value = val;
      return addState;
    } else {
      return undefined;
    }
  };
  /* 双击弹出Memo */
  handleGetMemo = (name, sValue, sMemoFiled, sRecord, bVisibleMemo, btnConfig, sCurrMemoPropsType) => {
    const sCurrMemoProps = sCurrMemoPropsType === "1" ? this.props.sCurrMemoProps1 : this.props.sCurrMemoProps;
    sCurrMemoProps.bVisibleMemo = false;
    if (btnConfig.length > 0) {
      sRecord[sMemoFiled] = sValue;
      if (sCurrMemoPropsType === "1") {
        this.props.onSaveState({ sCurrMemoProps1: sCurrMemoProps });
      } else {
        this.props.onSaveState({ sCurrMemoProps });
      }
      this.handleToForceComplete(sValue);
    } else {
      let { [`${name}Data`]: tableData } = this.props;
      let addStata = { [`${sMemoFiled}`]: sValue };
      if (name !== "master") {
        const iIndex = tableData.findIndex(item => item.sId === sRecord.sId);
        let handleType = tableData[iIndex].handleType; /* 获取操作类型 */
        handleType = commonUtils.isEmpty(handleType) ? "update" : handleType;
        addStata.handleType = handleType;
        tableData[iIndex] = { ...tableData[iIndex], ...addStata };
      } else {
        if (sMemoFiled === "sFormulaMemo") {
          addStata.sFormula = sValue;
        }
        let handleType = tableData.handleType; /* 获取操作类型 */
        handleType = commonUtils.isEmpty(handleType) ? "update" : handleType;
        addStata.handleType = handleType;
        tableData = { ...tableData, ...addStata };
      }
      this.props.onSaveState({ ...sCurrMemoProps, [`${name}Data`]: tableData });
    }
  };
  handleGetMemo1 = (name, sValue, sMemoFiled, sRecord, bVisibleMemo, btnConfig) => {
    this.handleGetMemo(name, sValue, sMemoFiled, sRecord, bVisibleMemo, btnConfig, "1");
  };
  /* 点击隐藏Memo 弹窗 */
  handleGetMemoCancel = () => {
    const { sCurrMemoProps } = this.props;
    sCurrMemoProps.bVisibleMemo = false;
    this.props.onSaveState({ sCurrMemoProps });
  };
  handleGetMemoCancel1 = () => {
    const { sCurrMemoProps1 } = this.props;
    sCurrMemoProps1.bVisibleMemo = false;
    this.props.onSaveState({ sCurrMemoProps1 });
  };
  handleForceComplete = (name, createDate) => {
    let sysLogData = {};
    const slaveMemoConfigOld = [];
    const { slaveSelectedRowKeys, slaveInfoSelectedRowKeys, app, masterConfig, slaveInfoData, masterData, slaveData, gdsformconst } = this.props;
    const btnConfig =
      commonUtils.isNotEmptyObject(masterConfig) &&
      commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === name))
        ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === name)[0]
        : {}; // sButtonEnabled  sButtonParam
    const bNoMemo = btnConfig.sDefault === "noMemo";
    if (createDate !== "chooseDate") {
      let target = "";
      if (btnConfig.sActiveKey) {
        target = btnConfig.sActiveKey.split(",")[0].split(".")[0];
      }
      if (target === "slave" && commonUtils.isEmptyArrNew(slaveSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
      } else if (target === "slaveInfo" && commonUtils.isEmptyArrNew(slaveInfoSelectedRowKeys)) {
        message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
      } else if (target === "slaveInfo" && !Array.isArray(slaveInfoData)) {
        message.warn("请展开详情并选择数据。"); // 请选择记录
      } else {
        let btnConfigNameArr = [];
        let singleConfig = {};
        let singleRow = {}; /* 选中行的数据 */
        if (name.indexOf("BtnRepair") > -1) {
          if (!commonUtils.isEmpty(btnConfig.sActiveKey)) {
            btnConfigNameArr = btnConfig.sActiveKey.split(",");
          }
          if (commonUtils.isNotEmptyArr(btnConfigNameArr)) {
            // eslint-disable-next-line array-callback-return
            btnConfigNameArr.map(i => {
              let sIndex = -1;
              if (target === "slaveInfo") {
                sIndex = this.props.slaveInfoConfig.gdsconfigformslave.findIndex(item => item.sName === i.split(".")[1]);
                const iSlaveIndex = slaveInfoData.findIndex(item => slaveInfoSelectedRowKeys.includes(item.sSlaveId));
                if (iSlaveIndex > -1) {
                  singleRow = slaveInfoData[iSlaveIndex];
                }
              } else if (target === "master") {
                sIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sName === i.split(".")[1]);
                singleRow = masterData;
              } else {
                if (commonUtils.isNotEmptyObject(this.props) && commonUtils.isNotEmptyObject(this.props.slaveConfig)) {
                  sIndex = this.props.slaveConfig.gdsconfigformslave.findIndex(item => item.sName === i);
                  const iSlaveIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
                  if (iSlaveIndex > -1) {
                    singleRow = slaveData[iSlaveIndex];
                  }
                }
              }
              console.log("singleRow:", singleRow);
              if (sIndex > -1) {
                if (target === "slaveInfo") {
                  singleConfig = this.props.slaveInfoConfig.gdsconfigformslave[sIndex];
                } else if (target === "master") {
                  singleConfig = this.props.masterConfig.gdsconfigformslave[sIndex];
                } else {
                  singleConfig = this.props.slaveConfig.gdsconfigformslave[sIndex];
                }
                if (masterData && commonUtils.isNotEmptyObject(singleRow)) {
                  masterData[singleConfig.sName] = singleRow[singleConfig.sName];
                }
                // if (masterData && commonUtils.isNotEmptyObject(singleConfig)) {
                //   masterData[singleConfig.sName] = undefined;
                // }
                slaveMemoConfigOld.push(singleConfig);
              }
            });
          }
        }
        /* 时间格式的字段 若默认值为空 则取当前时间 */
        const activeKeyData = commonUtils.isNotEmptyObject(btnConfig.sActiveKey) ? btnConfig.sActiveKey.split(",") : [];
        if (activeKeyData.length > 1) {
          /* 当多字段时候  若时间格式的字段 若默认值为空 则取当前时间 */
          const filterData = activeKeyData.filter(item => item.substring(0, 1) === "t");
          if (commonUtils.isNotEmptyArr(filterData)) {
            filterData.forEach(item => {
              let currentDate = moment().format("YYYY-MM-DD HH:mm:ss");

              // 如果默认值为0 则不设置默认时间
              const itemConfigIndex = masterConfig.gdsconfigformslave.findIndex(config => config.sName === item);
              if (itemConfigIndex !== -1 && masterConfig.gdsconfigformslave[itemConfigIndex].sDefault === "0") {
                currentDate = null;
              }
              if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmpty(masterData[item])) {
                masterData[item] = currentDate;
              }
            });
          }
        } else {
          if (commonUtils.isNotEmptyObject(btnConfig.sActiveKey) && btnConfig.sActiveKey.substring(0, 1) === "t") {
            if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmpty(masterData[btnConfig.sActiveKey])) {
              masterData[btnConfig.sActiveKey] = moment().format("YYYY-MM-DD HH:mm:ss");
            }
          }
        }
        // if (slaveSelectedRowKeys === undefined || slaveSelectedRowKeys === null) {
        //   message.warn('请选择数据！');
        //   return;
        // }
        sysLogData = commonUtils.isNotEmptyArr(slaveSelectedRowKeys) ? { sId: slaveSelectedRowKeys.toString() } : {};
        this.props.onSaveState({
          slaveMemoConfig: slaveMemoConfigOld,
          masterData: commonUtils.isNotEmptyObject(masterData)
            ? lodash.cloneDeep(masterData)
            : {} /* 将选中行数据深拷贝 变成两个互不相扰的独立数据源 */,
          sCurrMemoProps: {
            bVisibleMemo: true,
            sMemoField: "sReason",
            sRecord: sysLogData,
            dataSource: sysLogData,
            btnName: name,
            bNoMemo,
          },
        });
      }
    } else {
      /* 从系统常量中找到pChooseDate的sName */
      let pChooseDateName = "生成凭证";
      if (commonUtils.isNotEmptyArr(gdsformconst)) {
        const iIndex = gdsformconst.findIndex(item => item.sName === "pChooseDate");
        if (iIndex > -1) {
          pChooseDateName = gdsformconst[iIndex].showName;
        }
      }
      const chooseDateConfig = {
        sId: commonUtils.createSid(),
        sName: "pChooseDate",
        sDropDownType: "sql",
        bNotEmpty: false,
        iVisCount: 1,
        dropDownData: [],
        showName: pChooseDateName,
        sDateFormat: btnConfig && btnConfig.sDateFormat ? btnConfig.sDateFormat : "YYYY-MM-DD",
      };
      slaveMemoConfigOld.push(chooseDateConfig);
      this.props.onSaveState({
        slaveMemoConfig: slaveMemoConfigOld,
        sCurrMemoProps: {
          bVisibleMemo: true,
          sMemoField: "sReason",
          sRecord: sysLogData,
          dataSource: sysLogData,
          btnName: name,
          bNoMemo,
        },
      });
    }
  };
  handleToForceComplete = async sValue => {
    const { app, slaveSelectedRowKeys, slaveConfig, sModelsId, slaveInfoSelectedRowKeys, formRoute, masterConfig } = this.props;

    const { token } = app;
    let iIndex = -1;
    if (masterConfig && Array.isArray(masterConfig.gdsconfigformslave)) {
      iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnForceComplete" || item.sControlName === "BtnNoPurchase");
    }
    if (iIndex < 0 && slaveConfig && Array.isArray(slaveConfig.gdsconfigformslave)) {
      iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnForceComplete" || item.sControlName === "BtnNoPurchase");
    }
    if (iIndex < 0) return;
    const btnConfig = slaveConfig.gdsconfigformslave[iIndex];
    // debugger
    const sRelation = btnConfig.sRelation;

    let selectedRowKeys = "";
    if (formRoute === "/indexPage/materialRequirementsPlanning") {
      selectedRowKeys = slaveInfoSelectedRowKeys.toString();
    } else {
      selectedRowKeys = slaveSelectedRowKeys.toString();
    }

    const url = `${commonConfig.server_host}bill/billForceComplete?sModelsId=${sModelsId}&sName=${formRoute}`;
    const values = { sqlParam: sRelation, sId: selectedRowKeys, sReason: sValue };

    const masterReturn = (await commonServices.postValueService(token, values, url)).data;
    if (masterReturn.code === 1) {
      message.success(masterReturn.msg);
      this.props.onButtonClick("BtnRefresh");
    } else {
      this.props.getServiceError(masterReturn);
    }
  };
  /** 上传文件改变时的状态 */
  handleUploadChange = async info => {
    const { slaveSelectedRowKeys, app, slaveSelectedData, sModelsId, token } = this.props;
    if (slaveSelectedRowKeys === undefined || slaveSelectedRowKeys.length !== 1) {
      message.warn(commonFunc.showMessage(app.commonConst, "selectedRowKeysNo")); /* 请先选择一条数据！ */
      return;
    }
    const { file } = info;
    if (file.response) {
      if (file.response.code === 1) {
        /*   成功   */
        message.success(file.response.msg);
        const savePathStr = file.response.dataset.rows[0].savePathStr;
        const sId = commonUtils.isNotEmptyArr(slaveSelectedData) ? slaveSelectedData[0].sId : "";
        const bFile = commonUtils.isNotEmptyArr(slaveSelectedData) ? slaveSelectedData[0].bCorrespondFile : "";
        if (commonUtils.isNotEmptyObject(sId) && !bFile) {
          const url = `${commonConfig.server_host}salesorder/updateOrderCorrespondFile?sModelsId=${sModelsId}`;
          const values = { sOrderId: sId, savePathStr };
          const sReturn = (await commonServices.postValueService(token, values, url)).data;
          if (sReturn.code === 1) {
            this.props.onButtonClick("BtnRefresh");
          } else {
            this.props.getServiceError(sReturn);
          }
        }
      } else {
        /*   失败   */
        this.props.getServiceError({ msg: commonFunc.showMessage(app.commonConst, "reportDesign") + file.response }); /* 报表设计 */
      }
    }
  };

  /** 上传发票文件改变时的状态 */
  handleUploadInvoiceChange = async info => {
    const { slaveSelectedRowKeys, app, slaveSelectedData, sModelsId, token } = this.props;
    if (slaveSelectedRowKeys === undefined || slaveSelectedRowKeys.length !== 1) {
      message.warn(commonFunc.showMessage(app.commonConst, "selectedRowKeysNo")); /* 请先选择一条数据！ */
      return;
    }
    const { file } = info;
    if (file.response) {
      if (file.response.code === 1) {
        /*   成功   */
        message.success(file.response.msg);
      } else {
        /*   失败   */
        this.props.getServiceError({ msg: "发票上传失败！" }); /* 报表设计 */
      }
    }
  };

  /* 订单文件下载 */
  handleBtnDownload = () => {
    const { slaveSelectedRowKeys, slaveData, app } = this.props;
    if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
      message.warn(commonFunc.showMessage(app.commonConst, "selectedRowKeysNo")); /* 请先选择一条数据 */
      return;
    }
    const dataSelect = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sSlaveId));
    const sBillNoArr = [];
    let sBillNoStr = "";
    if (commonUtils.isNotEmptyArr(dataSelect)) {
      dataSelect.forEach(item => {
        sBillNoArr.push(item.sBillNo);
      });
      sBillNoStr = JSON.stringify(sBillNoArr);
    }
    if (commonUtils.isNotEmptyArr(sBillNoArr)) {
      const urlPrint = `${commonConfig.file_host}file/downloadPbOrder`;
      this.handleOpenPost(urlPrint, sBillNoStr);
    }
  };
  handleOpenPost = (url, params) => {
    const newWin = window.open();
    let formStr = "";
    formStr =
      `<form style="visibility:hidden;" method="POST" action="${url}">` + `<input type="hidden" name="sOrderNo" value='${params}' />` + "</form>";
    newWin.document.body.innerHTML = formStr;
    newWin.document.forms[0].submit();
    return newWin;
  };
  handleUploadImgChange = info => {
    const { file } = info;
    if (file.response && file.response.code === 1) {
      const { treeSelectedKeys } = this.props;
      const sPicturePath = file.response.dataset.rows[0].savePathStr;
      const uploadInfo = {
        sPicturePath,
        sFileName: file.name,
      };
      let { masterData } = this.props;
      const addState = {};
      if (file.response && file.response.code === 1) {
        addState.sTitleLogoPath = uploadInfo.sPicturePath;
        /* 当前设备状态上传多张图 */
        if (commonUtils.isNotEmptyArr(treeSelectedKeys) && treeSelectedKeys[0].indexOf("101251240115016043081412740") > -1) {
          addState.sTitleLogoPath = masterData.sTitleLogoPath;
          if (commonUtils.isNotEmptyObject(addState.sTitleLogoPath)) {
            addState.sTitleLogoPath += `,${uploadInfo.sPicturePath}`;
          } else {
            addState.sTitleLogoPath = uploadInfo.sPicturePath;
          }
        }
        addState.handleType = "update";
      }
      masterData = { ...masterData, ...addState };
      this.props.onSaveState({ masterData });
    } else if (file.response && file.response.code === -1) {
      message.error(file.response.msg);
    }
  };

  /* 通用上传员工图片 */
  handleUploadPicChange = info => {
    const { file } = info;
    if (file.response && file.response.code === 1) {
      const sPicturePath = file.response.dataset.rows[0].savePathStr;
      const spicture = sPicturePath;
      const uploadInfo = {
        sPicturePath,
        sFileName: file.name,
      };
      let { masterData } = this.props;
      const addState = {};
      if (file.response && file.response.code === 1) {
        addState.sPicturePath = uploadInfo.sPicturePath;
        addState.spicture = spicture;
        addState.handleType = "update";
      }
      masterData = { ...masterData, ...addState };
      this.props.onSaveState({ masterData });
    } else if (file.response && file.response.code === -1) {
      message.error(file.response.msg);
    }
  };


  /* 通用上传各种文件 */
  handleUploadFilesChange = info => {
    const { file,} = info;
    if (file.response && file.response.code === 1) {
     /* 刷新列表 */
      message.open({
        type:  'success',
        content: '文件上传成功',
        duration: 1
      });
      this.handleRefresh();
    }else if (file.response && file.response.code === -8) {
      Modal.info({
        title: '温馨提示:',
        content: (
          <div>
            {this.handleGetMsg(file.response.msg)}
          </div>
        ),
        okText: '确认',
        onOk() {},
      });
    } else if (file.response && file.response.code === -1) {
      message.error(file.response.msg);
    }
  };

  customRequest = option => {
    const { onSuccess, onError, file, action, data = {} } = option;
    // 添加额外的参数
    const formData = new FormData();
    formData.append("file", file);
    Object.keys(data).forEach(key => {
      formData.append(key, data[key]);
    });

    fetch(action, {
      method: "POST",
      body: formData,
    })
      .then(response => response.json())
      .then(data => {
        onSuccess(data, file);
      })
      .catch(error => {
        onError(error);
      });
  };

  // 获取img元素
  getImageDom = sIcon => {
    if (!sIcon) {
      return false;
    }
    const imageUrl = `${commonConfig.file_host}file/download?savePathStr=${sIcon}&sModelsId=100&token=${this.props.token}`;
    return (
      <img
        src={imageUrl}
        style={{
          width: 13,
          height: 13,
          marginRight: 3,
          marginTop: -2,
        }}
      />
    );
  };

  /**   渲染   */
  render() {
    const { menuData, searchUpDownData, fileImpositionData = {}, makeUpPDFData = {},BtnBoxData={} } = this.state;
    const {
      loading,
      sModelsId,
      masterConfig,
      masterData,
      visibleGetGoods,
      visibleFilfile,
      visibleOtherFilfile,
      copyFromChooseVisible,
      app,
      sTabId,
      controlSelectedRowKeys,
      sModelsType,
      slaveSelectedData,
      slaveSelectedRowKeys,
      formRoute,
      slaveData,
      visibleInterfaceDialog,
      interfaceDialogData,
      visibleApiDialog,
      getApiDialogData,
      bTabModal,
      addFaceVisible,
    } = this.props;
    const { userinfo } = app;
    const pane = app.panes.filter(paneTmp => paneTmp.key === sTabId)[0];
    const filfileManageTitle = commonFunc.showMessage(app.commonConst, "filfileManageTitle"); /* 通用文件上传 */
    const getGoodsTitle = commonFunc.showMessage(app.commonConst, "getGoodsTitle"); /* 获取订单表头 */
    const getGoodsPlaceholder = commonFunc.showMessage(app.commonConst, "handleNoWebOrderIds"); /* 获取订单输入框字样 */
    let btnUploadConfig = {};
    if (commonUtils.isNotEmptyObject(masterConfig)) {
      const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnUpload");
      if (iIndex > -1) {
        btnUploadConfig = this.props.masterConfig.gdsconfigformslave[iIndex];
      }
    }

    /* 第二个上传按钮 */
    let btnUploadOtherConfig = {};
    if (commonUtils.isNotEmptyObject(masterConfig)) {
      const iOtherIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName && item.sControlName.includes("BtnUploadOther"));
      if (iOtherIndex > -1) {
        btnUploadOtherConfig = this.props.masterConfig.gdsconfigformslave[iOtherIndex];
      }
    }

    let btnUploadIconConfig = {};
    if (commonUtils.isNotEmptyObject(masterConfig)) {
      const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnUploadicon");
      if (iIndex > -1) {
        btnUploadIconConfig = this.props.masterConfig.gdsconfigformslave[iIndex];
      }
    }
    let sSlaveId = "";
    let selectedsId = ""; /*  列表选中行或窗体sFormId */
    let selectedRow = {};
    const bList = ["/indexPage/commonList", "/indexPage/commonClassify"].includes(formRoute);
    if (
      (sModelsType === "manufacture/workOrder" || sModelsType === "manufacture/workOrder3" || sModelsType === "quotation/quotation") &&
      commonUtils.isNotEmptyArr(controlSelectedRowKeys)
    ) {
      sSlaveId = controlSelectedRowKeys[0]; /* 控制表选中行ID */
    } else if (bList) {
      /* HM订单准印资质列表 sSrcId为列表选中行sId */
      if (sModelsType === "HMOrderList") {
        if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
          selectedsId = slaveSelectedRowKeys[0];
        }
      } else if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
        if (iIndex > -1) {
          selectedRow = slaveData[iIndex];
          selectedsId =
            commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(selectedRow)
              ? commonUtils.isNotEmptyObject(selectedRow.sFormId)
                ? selectedRow.sFormId
                : ""
              : ""; /* 列表从表的sFormId */
          sSlaveId =
            commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(selectedRow)
              ? commonUtils.isNotEmptyObject(selectedRow.sSlaveId)
                ? selectedRow.sSlaveId
                : ""
              : ""; /* 列表从表的sSlaveId */
        }
      }
    }

    /* 如果配置按钮有sqlConditon条件 则根据SQLCondition条件 否则走正常 */
    let conditonValues = { sSrcId: bList ? selectedsId : commonUtils.isNotEmptyObject(masterData) ? masterData.sId : "" };
    if (commonUtils.isNotEmptyObject(btnUploadConfig) && btnUploadConfig.sSqlCondition) {
      /* 选中行 */
      if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
        if (iIndex > -1) {
          if (commonUtils.isNotEmptyObject(selectedRow)) {
            conditonValues = this.props.getSqlCondition(btnUploadConfig, "slave", selectedRow);
          }
        }
      }
    }

    let conditonOtherValues = { sSrcId: bList ? selectedsId : commonUtils.isNotEmptyObject(masterData) ? masterData.sId : "" };
    if (commonUtils.isNotEmptyObject(btnUploadOtherConfig) && btnUploadOtherConfig.sSqlCondition) {
      /* 选中行 */
      if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
        if (iIndex > -1) {
          if (commonUtils.isNotEmptyObject(selectedRow)) {
            conditonOtherValues = this.props.getSqlCondition(btnUploadOtherConfig, "slave", selectedRow);
          }
        }
      }
    }

    const filfilemanageType = {
      app: {
        ...this.props.app,
        currentPane: {
          name: "elefilfilemanage",
          config: btnUploadConfig,
          conditonValues,
          title: filfileManageTitle,
          route: "/elefilfilemanage",
          formId: btnUploadConfig && btnUploadConfig.sActiveId ? btnUploadConfig.sActiveId : "15864832090002447752315825731600",
          key: `${sModelsId}15864832090002447752315825731600`,
          sModelsType: "element/filfilemanage",
          sSrcNo: bList
            ? commonUtils.isNotEmptyArr(selectedRow)
              ? selectedRow.sBillNo
              : ""
            : commonUtils.isNotEmptyObject(masterData)
              ? masterData.sBillNo
              : "" /* 源单号 */,
          sSrcFormId: bList
            ? commonUtils.isNotEmptyArr(selectedRow)
              ? sModelsId
              : ""
            : commonUtils.isNotEmptyObject(masterData)
              ? masterData.sFormId
              : "" /* 源单窗体Id */,
          sSrcId: bList
            ? commonUtils.isNotEmptyObject(selectedRow)
              ? selectedRow.sId
              : ""
            : commonUtils.isNotEmptyObject(masterData)
              ? masterData.sId
              : "" /* 源单Id */,
          sSrcSlaveId: commonUtils.isNotEmptyObject(sSlaveId) ? sSlaveId : "" /* 工单控制表选中行或列表的是sSlaveId */,
          onFilfileOk: this.handleFilfileManageOk,
          onFilfileCancel: this.handleFilfileManageCancel,
          refresh: this.handleRefresh,
        },
      },
      config: btnUploadConfig,
      enabled: true /*this.props.enabled */,
      dispatch: this.props.dispatch,
      content: this.props.content,
      id: new Date().getTime().toString(),
    };

    /* 第二个上传按钮配置 */
    const filfilemanageOtherType = {
      app: {
        ...this.props.app,
        currentPane: {
          name: "elefilfilemanage",
          config: btnUploadOtherConfig,
          conditonValues: conditonOtherValues,
          title: filfileManageTitle,
          route: "/elefilfilemanage",
          formId: btnUploadOtherConfig && btnUploadOtherConfig.sActiveId ? btnUploadOtherConfig.sActiveId : "15864832090002447752315825731600",
          key: `${sModelsId}15864832090002447752315825731600`,
          sModelsType: "element/filfilemanage",
          sSrcNo: bList
            ? commonUtils.isNotEmptyArr(selectedRow)
              ? selectedRow.sBillNo
              : ""
            : commonUtils.isNotEmptyObject(masterData)
              ? masterData.sBillNo
              : "" /* 源单号 */,
          sSrcFormId: bList
            ? commonUtils.isNotEmptyArr(selectedRow)
              ? sModelsId
              : ""
            : commonUtils.isNotEmptyObject(masterData)
              ? masterData.sFormId
              : "" /* 源单窗体Id */,
          sSrcId: bList
            ? commonUtils.isNotEmptyObject(selectedRow)
              ? selectedRow.sId
              : ""
            : commonUtils.isNotEmptyObject(masterData)
              ? masterData.sId
              : "" /* 源单Id */,
          sSrcSlaveId: commonUtils.isNotEmptyObject(sSlaveId) ? sSlaveId : "" /* 工单控制表选中行或列表的是sSlaveId */,
          onFilfileOk: this.handleFilfileManageOk,
          onFilfileCancel: this.handleFilfileManageCancel.bind(this, "visibleOtherFilfile"),
        },
      },
      config: btnUploadOtherConfig,
      enabled: true /*this.props.enabled */,
      dispatch: this.props.dispatch,
      content: this.props.content,
      id: new Date().getTime().toString(),
    };

    /* 通用复制从调用  */
    let copyFromType = {};
    let copyFromConfig = {};
    let copyFromTitle = "自定义复制从窗体"; /* 复制从工艺卡查询结果 */
    if (commonUtils.isNotEmptyObject(this.props.copyFromChooseData)) {
      const copyFromKey = this.props.copyFromKey;
      const iIndex = this.props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === copyFromKey);
      if (iIndex > -1) {
        copyFromConfig = this.props.masterConfig.gdsconfigformslave[iIndex];
        copyFromTitle = commonUtils.isNotEmptyObject(copyFromConfig) ? copyFromConfig.sActiveName : copyFromTitle;
      }
      copyFromType = {
        app: {
          ...this.props.app,
          currentPane: {
            name: "commonCopyFrom",
            config: copyFromConfig,
            conditonValues: this.props.getSqlCondition(copyFromConfig),
            title: this.props.copyFromChooseData.sMenuName,
            route: this.props.copyFromChooseData.sName,
            formId: this.props.copyFromChooseData.sId,
            key: sModelsId + this.props.copyFromChooseData.sId,
            sModelsType: this.props.copyFromChooseData.sModelType,
            select: this.props.onCopyFromSelect /* 自定义复制从窗体时间 */,
            selectCancel: this.handleFilfileManageCancel.bind(this, "copyFromChooseVisible"),
          },
        },
        dispatch: this.props.dispatch,
        content: this.props.content,
        id: new Date().getTime().toString(),
      };
    }

    /* 接口对话框弹出推送接口返回数据功能 */
    let btnDialogConfig = {};
    if (commonUtils.isNotEmptyObject(masterConfig)) {
      const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnSendDialog");
      if (iIndex > -1) {
        btnDialogConfig = this.props.masterConfig.gdsconfigformslave[iIndex];
      }
    }

    const intefaceDialogType = {
      app: {
        ...this.props.app,
        currentPane: {
          name: "interfaceDialog",
          config: btnDialogConfig,
          conditonValues,
          title: filfileManageTitle,
          route: "/eleintefaceDialog",
          formId: btnDialogConfig && btnDialogConfig.sActiveId ? btnDialogConfig.sActiveId : "15864832090002447752315825731600",
          key: `${sModelsId}15864832090002447752315825731600`,
          sModelsType: "element/intefaceDialog",
          select: this.handleSelectDialog,
          selectCancel: this.handleDialogCancel,
        },
      },
      config: btnDialogConfig,
      slaveData: interfaceDialogData,
      enabled: true /*this.props.enabled */,
      dispatch: this.props.dispatch,
      content: this.props.content,
      id: new Date().getTime().toString(),
      onGetIntefaceDialogData: (slaveFilterCondition = [], callback) => {
        const tempCondition = {};
        slaveFilterCondition.forEach(item => {
          const { bFilterName, bFilterValue } = item;
          tempCondition[bFilterName] = bFilterValue;
        });
        this.tempCondition = tempCondition;
        this.handleClick({ key: "BtnSendDialog" });
        setTimeout(() => {
          callback && callback();
        }, 1000);
      },
    };

    let upPbOrderProps = {};
    let sBillNo = "";
    if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
      sBillNo = slaveSelectedData[0].sBillNo;
    }
    const uploadIconProps = {
      action: `${commonConfig.file_host}file/upload?sModelsId=${sModelsId}&token=${app.token}&sUploadType=model`,
      onChange: this.handleUploadImgChange,
      accept: "image/*",
      showUploadList: false,
      listType: "text",
      disabled: !this.props.enabled,
      // beforeUpload: this.handleBeforeUpload,
    };
    upPbOrderProps = {
      action: `${commonConfig.file_host_ebc}file/uploadPbOrder?sModelsId=${sModelsId}&&sOrderNo=${sBillNo}`,
      onChange: this.handleUploadChange,
      accept: ".pdf",
      showUploadList: false,
      beforeUpload: () => {
        if (commonUtils.isEmptyObject(sBillNo)) {
          const noUpload = commonFunc.showMessage(app.commonConst, "NoUpload"); /* 禁止上传 */
          message.error(noUpload);
          return false;
        }
      },
    };
    /* 职工信息上传员工图片 */
    const uploadPicProps = {
      action: `${commonConfig.file_host}file/upload?sModelsId=${sModelsId}&token=${app.token}`,
      onChange: this.handleUploadPicChange,
      accept: "image/*",
      showUploadList: false,
      disabled: !this.props.enabled,
      // beforeUpload: this.handleBeforeUpload,
    };
    const sBrandsId = userinfo?.sBrandsId;
    const sSubsidiaryId = userinfo?.sSubsidiaryId;
    /* 上传文件 */
    const uploadFilesProps = {
      action: `${commonConfig.file_host}file/uploadMachinePlc?sModelsId=${sModelsId}&&sBrandsId=${sBrandsId}&sSubsidiaryId=${sSubsidiaryId}&token=${app.token}`,
      onChange: this.handleUploadFilesChange,
      accept: '*/*',
      showUploadList: false,
      disabled: false,
      multiple:true,
      // beforeUpload: this.handleBeforeUpload,
    };

    /* 发票上传  */
    let invoiceBody = {};
    if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
      const slaveRow = slaveSelectedData[0];
      invoiceBody = {
        invTaxNum: slaveRow.sBillNo /* 发票号码 */,
        invType: "8000" /* 增值税发票类型代码 */,
        invSellerName: slaveRow.sSupplyName /* 发票销方名称 */,
        statusQuery: 0 /* 查询条件 */,
        relaBizNos: {
          /* 业务单号集合 */
          // "relaBizNo1": "",
          // "relaBizNo2": "",
          // "relaOaNo": "",
          // "relaVoucherNo": ""
        },
        operatorId: userinfo.sUserNo /* 操作人账号 */,
        operatorName: userinfo.sUserName /* 操作人名字 */,
        InfoSysSource: "EBC" /* 信息系统来源 */,
        beginDate: slaveRow.tCreateDate /* 查询起始时间  */,
        endDate: slaveRow.tEndDate /* 查询结束时间 */,
        // size:3,  /* 查询行 */
        // page:1, /* 查询页 */
        // invOrder: "desc",  /* 排序方式 */
        companyCode: userinfo.sSubsidiaryId /* 公司代码 */,
      };
    }
    const upInvoiceProps = {
      action: `${commonConfig.server_host}open/api/tax/input/invlock`,
      onChange: this.handleUploadInvoiceChange,
      accept: "*/*",
      customRequest: this.customRequest,
      // 添加额外的参数
      data: invoiceBody,
      showUploadList: false,
      beforeUpload: () => {},
    };

    /* 第三方接口拉取数据源 */
    let btnGetApiDialogConfig = {};
    if (commonUtils.isNotEmptyObject(masterConfig)) {
      const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnGetApiDialog");
      if (iIndex > -1) {
        btnGetApiDialogConfig = this.props.masterConfig.gdsconfigformslave[iIndex];
        /* 根据配置条件 */
        if (bList && commonUtils.isNotEmptyObject(btnGetApiDialogConfig) && btnGetApiDialogConfig.sSqlCondition) {
          /* 选中行 */
          if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
            const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
            if (iIndex > -1) {
              if (commonUtils.isNotEmptyObject(selectedRow)) {
                conditonValues = this.props.getSqlCondition(btnGetApiDialogConfig, "slave", selectedRow);
              }
            }
          }
        }
      }
    }

    const getApiDialogType = {
      app: {
        ...this.props.app,
        currentPane: {
          name: "getApiDialog",
          config: btnGetApiDialogConfig,
          conditonValues,
          title: filfileManageTitle,
          route: "/eleintefaceDialog",
          formId: btnGetApiDialogConfig && btnGetApiDialogConfig.sActiveId ? btnGetApiDialogConfig.sActiveId : "15864832090002447752315825731600",
          key: `${sModelsId}15864832090002447752315825731600`,
          sModelsType: "element/getApiDialog",
          select: this.props.onSelect,
          selectCancel: this.handleFilfileManageCancel.bind(this, "visibleApiDialog"),
        },
      },
      config: btnGetApiDialogConfig,
      // slaveData: getApiDialogData,
      enabled: true /*this.props.enabled */,
      dispatch: this.props.dispatch,
      content: this.props.content,
      id: new Date().getTime().toString(),
      // onGetApiDialogData: (slaveFilterCondition = [], callback) => {
      //   const tempCondition = {};
      //   slaveFilterCondition.forEach(item => {
      //     const { bFilterName, bFilterValue } = item;
      //     tempCondition[bFilterName] = bFilterValue;
      //   });
      //   this.tempCondition = tempCondition;
      //   this.handleClick({ key: 'BtnGetApiDialog' });
      //   setTimeout(() => {
      //     callback && callback();
      //   }, 1000);
      // }
    };

    let menuDataCopy = JSON.parse(JSON.stringify(menuData));
    // let btnOutData = menuDataCopy.find(item => item.sName === 'BtnOut');
    // if (commonUtils.isNotEmptyObject(btnOutData)) {
    //   btnOutData.child = [];
    //   for (let i = -1; i < 100; i++) {
    //     const slaveConfigName = i === -1 ? `slaveConfig` : `slave${i}Config`;
    //     const slaveConfig = this.props[slaveConfigName];
    //     if (slaveConfig && commonUtils.isNotEmptyObject(slaveConfig) && slaveConfig.bGrd) {
    //       const child = {
    //         child: [],
    //         iconName: 'menu-unfold',
    //         sControlName: `BtnOut.slave${i === -1 ? '' : i}`,
    //         sName: `BtnOut.slave${i === -1 ? '' : i}`,
    //         showName: slaveConfig.showName
    //       };
    //       btnOutData.child.push(child);
    //     }
    //   }
    //   if (btnOutData.child.length === 1) {
    //     // 如果只有一张表，还是用原来的配置
    //     menuDataCopy = JSON.parse(JSON.stringify(menuData));
    //   }

    // }

    // 如果复制到的child为空，则隐藏掉复制到按钮
    let btnCopyToIndex = menuDataCopy.findIndex(item => item.sName === "BtnCopyTo");
    if (btnCopyToIndex !== -1) {
      const btnCopyTo = menuDataCopy[btnCopyToIndex];
      if (commonUtils.isEmptyArr(btnCopyTo.child)) {
        menuDataCopy.splice(btnCopyToIndex, 1);
      }
    }

    const { tabModalConfig, tabModalRecord } = this.props;
    const sActiveId = tabModalConfig?.sActiveId;
    let sActiveKey = tabModalConfig?.sActiveKey;
    let tabModalTitle = tabModalConfig?.showName ? tabModalConfig.showName : "数据展示";
    const sFormId =
      sActiveId === "1" ? (commonUtils.isEmpty(tabModalRecord?.sFormId) ? tabModalRecord?.sSrcFormId : tabModalRecord?.sFormId) : sActiveId;
    if (commonUtils.isNotEmptyObject(sActiveKey) && sActiveKey.includes(".")) {
      const index = sActiveKey.lastIndexOf(".");
      sActiveKey = sActiveKey.substring(index + 1, sActiveKey.length);
    }

    const tabModalProps = {
      app: {
        ...this.props.app,
        currentPane: {
          ...this.props.app.currentPane,
          formId: sFormId,
          route: "/indexPage/commonList",
          name: "CommonList",
          sModelsType: "sales/autoView",
          selectCancel: this.handleFilfileManageCancel.bind(this, "bTabModal"),
          checkedId: tabModalRecord?.[sActiveKey],
        },
      },
      bTabModal: bTabModal,
      token: this.props.app.token,
      dispatch: this.props.dispatch,
      content: this.props.content,
      id: new Date().getTime().toString(),
      pageLoading: false,
    };

    if (this.props.customRender) return this.props.customRender({ ...this.props, menuDataCopy, getMenuProps: this.getMenuProps, handleClick: this.handleClick });

    return (
      <div className={styles.toolBar} onMouseEnter={this.handleMouseEnterTooBar}>
        <Spin spinning={loading === undefined ? false : loading}>
          <Menu
            mode="horizontal"
            onClick={throttle(this.handleClick, 1000)}
            onKeyDown={this.handleToolBarKeyDown}
            className={`${styles.toolMenu} ${this.props.className ? this.props.className : ""}`}
          >
            {menuDataCopy.map(item => {
              const { child, iconName, showName, sIcon } = item;
              const imageDom = this.getImageDom(sIcon) || <SvgIcon className="toolbarIcon" iconClass={iconName} />;
              return child.length > 1 ? (
                <SubMenu {...this.getMenuProps(item, "icon")}>
                  {child.map(eachChild => {
                    if (eachChild.sControlName === "BtnBsOperation.BtnUpCheck" || eachChild.sControlName === "BtnBsOperation.BtnDownCheck") {
                      return (
                        <SubMenu {...this.getMenuProps(eachChild, "title")}>
                          {eachChild.child.map(threeChild => {
                            if (
                              commonUtils.isNotEmptyObject(searchUpDownData) &&
                              commonUtils.isNotEmptyArr(searchUpDownData[threeChild.sControlName])
                            ) {
                              return (
                                <MenuItemGroup {...this.getMenuProps(threeChild, "title")}>
                                  {searchUpDownData[threeChild.sControlName].map(fourMenuItem => {
                                    return (
                                      <Menu.Item {...this.getMenuProps(fourMenuItem, "key")}>
                                        <span>{fourMenuItem.showName}</span>
                                      </Menu.Item>
                                    );
                                  })}
                                </MenuItemGroup>
                              );
                            } else {
                              return "";
                            }
                          })}
                        </SubMenu>
                      );
                    } else {
                      return (
                        <Menu.Item {...this.getMenuProps(eachChild, "key")}>
                          <span>{eachChild.showName}</span>
                          {eachChild.sControlName.indexOf("BtnPrint") > -1 ? (
                            <Checkbox onClick={this.radioClick.bind(this, eachChild)} style={{ float: "right", marginTop: "8px" }} />
                          ) : (
                            ""
                          )}
                        </Menu.Item>
                      );
                    }
                  })}
                </SubMenu>
              ) : child.length === 1 ? (
                <Menu.Item {...this.getMenuProps(child[0], "key")}>
                  {imageDom}
                  {item.sName === "BtnPrint" ? showName : child[0].showName}
                </Menu.Item>
              ) : (
                [""].map(() => {
                  const menuItemProps = this.getMenuProps(item, "key");
                  const { name } = menuItemProps;
                  const showNameNew = name || showName;
                  const myStyle = {};
                  if (item?.sControlName === "BtnLook") {
                    /* 查看全部 */
                    if (!this.props.bSecondMainMaterials) {
                      myStyle.color = "#1890FF";
                    } else {
                      myStyle.color = "#fff";
                    }
                  } else if (item?.sControlName === "BtnLookSwitch") {
                    /* 查看二级 */
                    if (this.props.bSecondMainMaterials) {
                      myStyle.color = "#1890FF";
                    } else {
                      myStyle.color = "#fff";
                    }
                  }

                  return (
                    <Menu.Item {...menuItemProps}>
                      {commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.indexOf("BtnUpPbOrder") > -1 ? (
                        <div className={styles.toolBarUpload}>
                          <Upload {...upPbOrderProps}>
                            <a {...this.getDisabledProps("BtnUpPbOrder")}>
                              <UploadOutlined /> {showNameNew}
                            </a>
                          </Upload>
                        </div>
                      ) : commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.indexOf("BtnUploadApi") > -1 ? (
                        <div className={styles.toolBarUpload}>
                          <Upload {...upInvoiceProps}>
                            <a style={{ color: "#ffffff" }}>
                              <UploadOutlined fill="#fff" /> {showNameNew}
                            </a>
                          </Upload>
                        </div>
                      ) : commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.indexOf("BtnUploadPic") > -1 ? (
                        <div>
                          <Upload {...uploadPicProps}>
                            {imageDom}
                            <span style={{ color: this.props.enabled ? "#fff" : "#a2a2a2" }}>{showNameNew}</span>
                          </Upload>
                        </div>
                      ): commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.indexOf("BtnImportFile") > -1 ? (
                        <div>
                          <Upload {...uploadFilesProps}>
                            <a className={styles.uploadlink} style={{ color: "#ffffff"}}>
                              <UploadOutlined fill="#fff"/> {showNameNew}
                            </a>
                          </Upload>
                        </div>
                      ) : commonUtils.isNotEmptyObject(item.sControlName) && item.sControlName.indexOf("BtnDlPbOrder") > -1 ? (
                        <div className={styles.toolBarUpload}>
                          <a {...this.getDisabledProps("BtnDlPbOrder")} onClick={() => this.handleBtnDownload()}>
                            {" "}
                            <DownloadOutlined />
                            {showNameNew}
                          </a>
                        </div>
                      ) : item.sControlName === "BtnUploadicon" ? (
                        <div>
                          <Upload {...uploadIconProps}>
                            {imageDom}
                            <span style={{ color: this.props.enabled ? "#fff" : "#a2a2a2" }}>{showNameNew}</span>
                          </Upload>
                        </div>
                      ) : (
                        <div style={myStyle}>
                          {imageDom}
                          {showNameNew}
                        </div>
                      )}
                    </Menu.Item>
                  );
                })
              );
            })}
          </Menu>
          <AffixMenu {...this.props} className={styles.affixMenu} />
        </Spin>
        <StatementInfo {...this.props} />
        <BatchPriceUpdate {...this.props} />
        <BatchNPriceUpdate {...this.props} />
        <BatchWorkListPriceUpdate {...this.props} />
        {commonUtils.isNotEmptyObject(btnUploadConfig) && (pane?.notCurrentPane ? false : visibleFilfile) ? (
          <AntdDraggableModal
            width={1300}
            title={filfileManageTitle}
            visible={pane?.notCurrentPane ? false : visibleFilfile}
            onCancel={this.handleFilfileManageCancel.bind(this, "visibleFilfile")}
            footer={null}
          >
            <FilfileManageInfo {...filfilemanageType} />
          </AntdDraggableModal>
        ) : (
          ""
        )}
        {commonUtils.isNotEmptyObject(btnUploadOtherConfig) && (pane?.notCurrentPane ? false : visibleOtherFilfile) ? (
          <AntdDraggableModal
            width={1300}
            title={filfileManageTitle}
            visible={pane?.notCurrentPane ? false : visibleOtherFilfile}
            onCancel={this.handleFilfileManageCancel.bind(this, "visibleOtherFilfile")}
            footer={null}
          >
            <FilfileManageInfo {...filfilemanageOtherType} />
          </AntdDraggableModal>
        ) : (
          ""
        )}

        {commonUtils.isNotEmptyObject(btnDialogConfig) && (pane?.notCurrentPane ? false : visibleInterfaceDialog) ? (
          <AntdDraggableModal
            width={1300}
            title={intefaceDialogType?.app?.currentPane?.config?.sActiveName || "获取接口数据"}
            visible={pane?.notCurrentPane ? false : visibleInterfaceDialog}
            onCancel={this.handleDialogCancel.bind(this, "visibleInterfaceDialog")}
            footer={null}
          >
            <CommonListSelect {...intefaceDialogType} />
          </AntdDraggableModal>
        ) : (
          ""
        )}

        {commonUtils.isNotEmptyObject(btnGetApiDialogConfig) && (pane?.notCurrentPane ? false : visibleApiDialog) ? (
          <AntdDraggableModal
            width={1300}
            title={getApiDialogType?.app?.currentPane?.config?.sActiveName || "查询发票"}
            visible={pane?.notCurrentPane ? false : visibleApiDialog}
            onCancel={this.handleFilfileManageCancel.bind(this, "visibleApiDialog")}
            footer={null}
          >
            <CommonListSelect {...getApiDialogType} />
          </AntdDraggableModal>
        ) : (
          ""
        )}

        {pane?.notCurrentPane ? (
          false
        ) : copyFromChooseVisible ? (
          <AntdDraggableModal
            width={1200}
            title={copyFromTitle}
            visible={copyFromChooseVisible}
            onCancel={this.handleFilfileManageCancel.bind(this, "copyFromChooseVisible")}
            footer={null}
            wrapClassName="worker-order-pack-modal"
          >
            <CommonListSelect {...copyFromType} />
          </AntdDraggableModal>
        ) : (
          ""
        )}
        {visibleGetGoods ? (
          <AntdDraggableModal title={getGoodsTitle} visible={visibleGetGoods} onOk={this.handleOk} onCancel={this.handleCancel}>
            <Input placeholder={getGoodsPlaceholder} value={this.state.inputChange} onChange={this.handleInputChange} />
          </AntdDraggableModal>
        ) : (
          ""
        )}
        {bTabModal ? (
          <AntdDraggableModal
            width="95%"
            title={tabModalTitle}
            visible={bTabModal}
            onCancel={this.handleFilfileManageCancel.bind(this, "bTabModal")}
            onOk={this.handleFilfileManageCancel.bind(this, "bTabModal")}
            bodyStyle={{
              height: "70vh",
              overflowY: "auto",
            }}
            style={{
              top: "10vh",
            }}
          >
            <div style={{}}>
              查看
              {/*<CommonList {...tabModalProps} />*/}
            </div>
          </AntdDraggableModal>
        ) : (
          ""
        )}
        {!commonUtils.isEmpty(this.props.routing) ? (
          ""
        ) : (
          <SlaveMemo
            fromToorBar="true"
            onGetMemo={this.handleGetMemo}
            onGetMemoCancel={this.handleGetMemoCancel}
            onBtnEent={this.handleBtnEent}
            {...this.props}
          />
        )}
        {!commonUtils.isEmpty(this.props.routing) ? (
          ""
        ) : (
          <SlaveMemo1
            fromToorBar="true"
            onGetMemo={this.handleGetMemo1}
            onGetMemoCancel={this.handleGetMemoCancel1}
            onBtnEent={this.handleBtnEent}
            {...this.props}
          />
        )}
        {!commonUtils.isEmpty(this.props.routing) ? "" : <EditorModal fromToorBar="true" {...this.props} />}
        <FileImposition {...this.props} {...fileImpositionData} />
        {makeUpPDFData?.pdfMakeUpVisible && <MakeUpPDF {...makeUpPDFData} />}
        {BtnBoxData?.boxVisible && <BoxDesignCompontent {...BtnBoxData} />}
        {
            <PersonCenterAddFace
              {...this.props}
              addFaceVisible={addFaceVisible}
              onCancel={this.handleFilfileManageCancel.bind(this, "addFaceVisible")}
              handelCance={this.handleFilfileManageCancel.bind(this, "addFaceVisible")}
              onSaveFaceSuccess={this.onSaveFaceSuccess}
              app={app}
              formItemLayout={this.formItemLayout}
              tailFormItemLayout={this.tailFormItemLayout}
            />
        }
      </div>
    );
  }
}

export default ToolBarComponent;
