/* eslint-disable */

import React, { Component, useState, useRef, useEffect } from "react";
import { Form } from "@ant-design/compatible";
// import '@ant-design/compatible/assets/index.css';
import { Row, Col, Checkbox, Layout, Spin, Tabs, Dropdown, Avatar, Button, Menu, Table, Upload } from "antd-v4";
import { message } from "@/utils/common/message";
import { DownOutlined, UploadOutlined } from "@ant-design/icons";
import CommonNewSales from "@/components/Common/CommonNewBillEvent"; /* 继承销售模块业务功能 */
import * as commonFunc from "@/components/Common/commonFunc"; /* 通用单据方法 */ /* 通用单据方法 */
import Toolbar from "@/components/Common/ToolBar/ToolBarNew";
import CommobileToolBar from '../CommobileToolBar';
import StaticEditTable from "@/components/Common/CommonTable"; /* 可编辑表格 */
import styles from "@/index.less";
import stylesNew from "./index.less"
import AssignmentField from "@/components/Common/AssignmentField";
import CommonView from "@/components/Common/CommonView";
import CommonViewTable from "@/components/Common/CommonViewTable";
import CommonBase from "@/components/Common/CommonBase"; /* 获取配置及数据 */
import * as commonBusiness from "@/components/Common/commonBusiness"; /* 单据业务功能 */
import commonConfig from "@/utils/config";
import * as commonUtils from "@/utils/utils"; /* 通用方法 */
import * as commonServices from "@/services/services"; /*   服务类   */
import AddIcon from "@/assets/add.svg";
import DisableAddIcon from "@/assets/disableadd.svg";
import CopyIcon from "@/assets/copy.svg";
import CopyAllIcon from "@/assets/copyall.svg";
import DisableCopyIcon from "@/assets/disablecopy.svg";
import DisableCopyAllIcon from "@/assets/disablecopyall.svg";
import DelIcon from "@/assets/delete.svg";
import DisableDelIcon from "@/assets/disabledelete.svg"; /* 获取配置及数据 */
import AntdDraggableModal from "@/components/Common/AntdDraggableModal";
import CommonListSelect from "@/components/Common/CommonListSelect";
import WorkCalendar from "@/components/Common/WorkCalendar/WorkCalendar";
import ContextMenuModal from "@/components/Common/ContextMenuModal";
import CommonViewDragable from "@/components/Common/CommonViewDragable";
import CommonExamInfo from "@/components/Common/CommonExamInfo";
import JsonFormatter from "@/components/Common/Json/JsonFormatter";
import lodash from "lodash";
import userImgs from "@/assets/user.svg";

// import ProcessIcon from '../../assets/process.svg';
// import DisableProcessIcon from '../../assets/disableprocess.svg';
// import MateriallIcon from '../../assets/material.svg';
// import DisableMateriallIcon from '../../assets/disablematerial.svg';
// import SlaveMemo from './SlaveMemo';

const width = "18px";
const height = "18px";
const setAdd = {
  title: "增加",
  width: { width },
  height: { height },
  img: <img src={AddIcon} alt="添加" width={width} height={height} />,
  disableimg: <img src={DisableAddIcon} alt="删除" width={width} height={height} />,
};
const setCopy = {
  title: "复制",
  width: { width },
  height: { height },
  img: <img src={CopyIcon} alt="复制" width="20px" height="20px" />,
  disableimg: <img src={DisableCopyIcon} alt="复制" width="20px" height="20px" />,
};
const setCopyAll = {
  title: "复制部件",
  width: { width },
  height: { height },
  img: <img src={CopyAllIcon} alt="复制部件" width="16px" height="16px" />,
  disableimg: <img src={DisableCopyAllIcon} alt="复制部件" width="16px" height="16px" />,
};
const setDelete = {
  title: "删除",
  width: { width },
  height: { height },
  img: <img src={DelIcon} alt="删除" width={width} height={height} />,
  disableimg: <img src={DisableDelIcon} alt="删除" width={width} height={height} />,
};
// const setProcess = {
//   title: '工序',
//   width: { width },
//   height: { height },
//   img: <img src={ProcessIcon} alt="选择工序" width="16px" height="16px" />,
//   disableimg: <img src={DisableProcessIcon} alt="删除" width="16px" height="16px" />,
// };
// const setMaterial = {
//   title: '材料',
//   width: { width },
//   height: { height },
//   img: <img src={MateriallIcon} alt="选择材料" width="22px" height="22px" />,
//   disableimg: <img src={DisableMateriallIcon} alt="选择材料" width="22px" height="22px" />,
// };

// console.log('btn; ', setAdd, setDelete, setCopy);
const { Header, Content } = Layout;
const { TabPane } = Tabs;

let _this = {};

// const { confirm } = Modal;
class CommonNewBill0 extends Component {
  constructor(props) {
    super(props);
    this.state = {
      currentTab: "",
    };
    _this = this;
  }

  componentDidUpdate() {
    // 没有默认页签情况下, 非编辑状态进入，展示第一个tab
    const { enabled, masterConfig } = this.props;
    // 获取默认展开tab
    const defaultTabConfig =
      masterConfig &&
      masterConfig.gdsconfigformslave.find(
        item =>
          ["MainContent", "zMaterials", "zCheck", ...new Array(10).fill("").map((_, index) => `zSlaveInfo${index}`)].includes(item.sControlName) &&
          item.sDefault
      );
    if (!enabled && !this.firstLoaded && commonUtils.isEmptyObject(defaultTabConfig)) {
      clearTimeout(this.timer);
      this.timer = setTimeout(() => {
        this.firstLoaded = true;
        if (this.slaveTabsRef) {
          const oFirstTab = this.slaveTabsRef.querySelector(".ant-tabs-nav-list")?.querySelector(".ant-tabs-tab");
          if (oFirstTab) {
            // 创建一个自定义的 click 事件
            const clickEvent = new Event("click", { bubbles: true, cancelable: true });
            // 触发该元素的 click 事件
            oFirstTab.dispatchEvent(clickEvent);
          }
        }
      }, 500);
    }
  }

  /**   行选择   */
  onRowClick = (name, record) => {
    if (name === "control") {
      this.props.onTableSelectRowChange(name, [record.sId]);
    }
  };

  onChange = checkedValues => {
    this.props.onSaveState({
      dataPersonArray: checkedValues,
    });
  };
  getMenuStatus = menu => {
    if (menu.sControlName === "BtnImport") {
      return !this.props.enabled;
    }
  };

  /**   上传后执行函数    */
  // handleUploadChange = (info) => {
  //   const { file } = info;
  //   console.log(info, 'infoinfoinfoinfoinfoinfoinfoinfoinfo');
  //   const { masterData, sModelsId, slaveConfig } = this.props;
  //   if (file.response) {
  //     if (file.response.code === 1) {
  //       /*   数据查询成功   */
  //       const errorInfo = file.response.dataset.rows[0].nocanbeInsert;
  //       if (commonUtils.isNotEmptyObject(errorInfo)) {
  //         message.error(errorInfo[0].sReason);
  //         return;
  //       }
  //       const returnData = file.response.dataset.rows[0].canbeInsert;
  //       returnData.forEach(async (tableDataRow) => {
  //         tableDataRow.handleType = 'add';
  //         tableDataRow.sId = commonUtils.createSid();
  //         tableDataRow.sParentId = masterData.sId;
  //         tableDataRow.key = tableDataRow.sId;
  //         for (const child of Object.keys(tableDataRow)) {
  //           const index = child.indexOf('_sRealValue_');
  //           if (index > -1) {
  //             const property = child.substring(0, child.length - 12);
  //             tableDataRow[property] = tableDataRow[child];
  //           }
  //         }
  //         // const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', 'sProductId');
  //         let productIdDropDown;
  //         const slaveIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === 'sProductId');
  //         if (slaveIndex > -1) {
  //           const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, 'slave', slaveConfig.gdsconfigformslave[slaveIndex]);
  //           productIdDropDown = sqlDropDownData.dropDownData;
  //         }
  //         if (productIdDropDown !== undefined) {
  //           const iProductIdIndex = productIdDropDown.findIndex(item => item.sId === tableDataRow.sProductId);
  //           if (iProductIdIndex === -1) {
  //             tableDataRow.sProductInfo = JSON.stringify({
  //               sProductId: tableDataRow.sProductName,
  //               sProductName: tableDataRow.sProductName,
  //               sProductStyle: tableDataRow.sProductStyle,
  //               sProductUnit: tableDataRow.sProductUnit,
  //               sProductNo: tableDataRow.sProductNo,
  //               sCustomerProductNo: tableDataRow.sCustomerProductNo,
  //               sProductClassifyId: tableDataRow.sProductClassifyId,
  //               sProductClassifyName: tableDataRow.sProductClassifyName,
  //             });
  //           }
  //         }
  //       });
  //       this.props.onSaveState({ slaveData: returnData });
  //     } else { /*   失败   */
  //       this.props.getServiceError(file.response);
  //     }
  //   }
  // };
  /**   图片上传后执行函数    */
  handleUploadChange = (info, name) => {
    const { file } = info;
    if (file.response && file.response.code === 1) {
      const sPicturePath = file.response.dataset.rows[0].savePathStr;
      const uploadInfo = {
        sPicturePath,
        sFileName: file.name,
      };
      const tableDataRow = this.props.onDataRowAdd(name, true);
      const { [`${name}Column`]: tableColumn, masterData, [`${name}Data`]: tableData } = this.props;
      tableColumn.forEach(slaveChild => {
        const ckey = slaveChild.dataIndex;
        if (ckey === "sProductNo" || ckey === "sProductName") {
          tableDataRow[ckey] = masterData[ckey] !== undefined ? masterData[ckey] : "";
        } else if (ckey === "iOrder") {
          tableDataRow[ckey] = "";
        } else if (file.response && file.response.code === 1) {
          if (uploadInfo[ckey] !== undefined) {
            tableDataRow[ckey] = uploadInfo[ckey];
          }
        }
      });
      tableData.push(tableDataRow);
      this.props.onSaveState({ [`${name}Data`]: tableData, enabled: true });
    } else if (file.response && file.response.code === -1) {
      message.error(file.response.msg);
    }
  };
  handleUploadPropsSales = () => {
    const { masterData, sModelsType } = this.props;
    if (commonUtils.isNotEmptyObject(masterData)) {
      const sCustomerId = commonUtils.isEmptyStr(masterData.sCustomerId) ? undefined : masterData.sCustomerId;
      let existCustomerId = false;
      if (sModelsType.includes("sales/") && commonUtils.isNotEmptyStr(sCustomerId)) {
        existCustomerId = true;
      } else if (!sModelsType.includes("sales/")) {
        existCustomerId = true;
      }
      return {
        disabled: !this.props.enabled || !existCustomerId /*   是否可用   */,
        style: { display: commonUtils.convertBooleanToDisplayBlock(true) } /*   是否显示   */,
      };
    }
  };

  handleOk = async (flag, tmpCheck, isWait) => {
    const { sModelsId, masterData, app, checkConditions, sCheckModelId, checkPersonData, currentId, masterConfig, slaveConfig, checkConfig } =
      this.props;
    const { currentPane } = app;
    const bCkxTmpCheck = app.systemData.filter(item => item.sName === "CkxTmpCheck")[0].sValue;
    if (bCkxTmpCheck === "1") {
      const returnData = await this.props.onDataAudit(flag, tmpCheck, isWait);
      if (returnData.code === 1) {
        if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) {
          this.props.onGetData(masterConfig, slaveConfig, checkConfig);
          message.success(returnData.msg);
        } else {
          message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn);
        }
      } else {
        /*   失败   */
        this.props.getServiceError(returnData);
      }
    } else {
      const dataPersonArray = commonUtils.isEmptyObject(this.props.dataPersonArray) ? [] : this.props.dataPersonArray;
      if (commonUtils.isEmptyObject(dataPersonArray)) {
        checkPersonData.forEach(item => {
          dataPersonArray.push(item.sUserId);
        });
      }
      const dataPersonString = dataPersonArray.join(",");
      const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
      const value = {
        sProName: "Sp_System_AutoSendCheckMsg",
        paramsMap: {
          sFormGuid: sModelsId,
          sBillKey: currentPane.sProcName,
          sTbName: masterConfig.sTbName,
          sGuid: masterData.sId,
          sBillNo: masterData.sBillNo,
          sCheckCondition: checkConditions,
          sMemo: "",
          sCheckModelGuid: sCheckModelId,
          sCheckPerson: dataPersonString,
        },
      };

      const returnData = (await commonServices.postValueService(app.token, value, url)).data;
      if (returnData.code === 1) {
        const noCheckMsg = commonFunc.showMessage(app.commonConst, "NoCheckMsg"); /* 您有消息待审核 */
        if (returnData.dataset.rows[0].dataSet.outData[0].sCode === 1) {
          this.props.handleSendSocketMessage("examine", "showImg", currentId, dataPersonString, noCheckMsg, null);
          const urlCanCheckBill = `${commonConfig.server_host}checkModel/getCanCheckBill?sModelsId=${sModelsId}`;
          const valueCanCheckBill = { sCheckModelId, checkPersonData, sBillId: masterData.sId };
          const returnCanCheckBill = (await commonServices.postValueService(app.token, valueCanCheckBill, urlCanCheckBill)).data;
          if (returnCanCheckBill.code === 1) {
            if (returnCanCheckBill.dataset.rows[0].iCount === 1) {
              this.props.onDataAudit(1, 1);
              this.props.onSaveState({
                visible: false,
              });
              return;
            }
          } else {
            /*   失败   */
            this.props.getServiceError(returnCanCheckBill);
          }
          this.props.handleSendSocketMessage("reflush", "showImg", currentId, dataPersonString, noCheckMsg, null);
          message.success(returnData.msg);
        } else {
          message.error(returnData.dataset.rows[0].dataSet.outData[0].sReturn);
        }
      } else {
        /*   失败   */
        this.props.getServiceError(returnData);
      }
    }
    this.props.onSaveState({
      visible: false,
    });
  };

  handleCancel = () => {
    this.props.onSaveState({
      visible: false,
    });
  };
  handleTableModal = async () => {
    const { sModelsId, controlData, masterData, slaveData, controlConfig, slaveSelectedRowKeys, enabled, slaveConfig } = this.props;
    const addState = {};
    if (this.props.sModelsType === "sales/salesOrder") {
      const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
      const iIndex = controlData.findIndex(item => item.sSlaveId === slaveSelectedRowKeys[0]);
      if (iIndex === -1 && iSlaveIndex > -1 && enabled) {
        const allTableData = {};
        allTableData.master = masterData;
        allTableData.slaveData = slaveData;
        // let dropdownProductClassifyId = commonUtils.getStoreDropDownData(sModelsId, 'slave', 'sProductClassifyId');
        let dropdownProductClassifyId;
        const slaveIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === "sProductClassifyId");
        if (slaveIndex > -1) {
          const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, "slave", slaveConfig.gdsconfigformslave[slaveIndex]);
          dropdownProductClassifyId = sqlDropDownData.dropDownData;
        }
        if (commonUtils.isEmptyArr(dropdownProductClassifyId)) {
          const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === "sProductClassifyName");
          if (iIndex > -1) {
            const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, "slave", slaveConfig.gdsconfigformslave[iIndex]);
            dropdownProductClassifyId = sqlDropDownData.dropDownData;
          }
          // dropdownProductClassifyId = commonUtils.getStoreDropDownData(sModelsId, 'slave', 'sProductClassifyName');
        }
        if (commonUtils.isNotEmptyArr(dropdownProductClassifyId)) {
          const iProductClassifyIdIndex = dropdownProductClassifyId.findIndex(item => item.sId === slaveData[iSlaveIndex].sProductClassifyId);
          if (commonUtils.isNotEmptyObject(dropdownProductClassifyId[iProductClassifyIdIndex])) {
            const sAllPartsName = dropdownProductClassifyId[iProductClassifyIdIndex].sAllPartsName;
            if (commonUtils.isNotEmptyStr(sAllPartsName)) {
              const sAssignFieldObj = sAllPartsName.split(",");
              for (const child of sAssignFieldObj) {
                const tableDataRowAdd = commonFunc.getDefaultData(controlConfig, allTableData);
                tableDataRowAdd.handleType = "add";
                tableDataRowAdd.sId = commonUtils.createSid();
                tableDataRowAdd.sParentId = masterData && masterData.sId ? masterData.sId : null;
                tableDataRowAdd.sSlaveId = slaveSelectedRowKeys[0];
                tableDataRowAdd.key = tableDataRowAdd.sId;
                tableDataRowAdd.bDefault = false;
                tableDataRowAdd.iOrder = 0;
                tableDataRowAdd.sPartsName = child;
                tableDataRowAdd.dPartsQty = slaveData[iSlaveIndex].dProductQty;
                controlData.push(tableDataRowAdd);
              }
            }
          }
        }
        addState.controlData = controlData;
      }

      if (controlData !== undefined) {
        const iControlIndex = controlData.findIndex(item => item.sSlaveId === slaveSelectedRowKeys[0]);
        if (iControlIndex > -1) {
          addState.controlSelectedRowKeys = [controlData[iControlIndex].sId];
        }
      }
    }

    this.props.onSaveState({
      visibleModal: true,
      ...addState,
    });
  };
  handleTableChooseProcess = () => {
    const { processConfig } = this.props;
    const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sControlName === "BtnChooseProcess");

    if (iIndex > -1) {
      this.props.onBtnChoose("process", "BtnChooseProcess", processConfig.gdsconfigformslave[iIndex]);
    }
  };
  handleCancelModal = modelVisible => {
    this.props.onSaveState({
      [modelVisible]: false,
    });
  };
  handleOkModal = () => {
    const { controlData, slave0Data, processData, sModelsId, slaveData, slaveSelectedRowKeys, materialsConfig, processConfig } = this.props;
    const ctData = controlData.filter(item => item.handleType !== "del" && item.sSlaveId === slaveSelectedRowKeys[0]);
    const mtData = slave0Data.filter(item => item.handleType !== "del" && item.sSlaveId === slaveSelectedRowKeys[0]);
    const pData = processData.filter(item => item.handleType !== "del" && item.sSlaveId === slaveSelectedRowKeys[0] && item.sType === "2");
    if (commonUtils.isNotEmptyArr(ctData)) {
      let mDetail = "";
      let pDetail = "";
      const slaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
      ctData.forEach(async (controlItem, n) => {
        if (commonUtils.isNotEmptyObject(controlItem.sPartsName)) {
          const qz = n === 0 ? "" : " ";
          if (commonUtils.isNotEmptyObject(controlItem.sPartsName)) {
            const yDetail = `${mDetail}${qz}#${controlItem.sPartsName}:`;
            const gDetail = `${pDetail}${qz}#${controlItem.sPartsName}:`;
            let imDetail = "";
            let ipDetail = "";
            const materials = mtData.filter(materialsItem => materialsItem.sControlId === controlItem.sId);
            // const materialsIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'materials', 'sMaterialsName');
            let materialsIdDropDown;
            const materialsIndex = materialsConfig.gdsconfigformslave.findIndex(item => item.sName === "sMaterialsName");
            if (materialsIndex > -1) {
              const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, "materials", materialsConfig.gdsconfigformslave[materialsIndex]);
              materialsIdDropDown = sqlDropDownData.dropDownData;
            }
            materials.forEach((mItem, i) => {
              const fh = i === 0 ? "" : ",";
              if (materialsIdDropDown) {
                const materialsIdIndex = materialsIdDropDown.findIndex(item => item.sId === mItem.sMaterialsId);
                if (materialsIdIndex > -1) {
                  imDetail = `${imDetail}${fh} ${materialsIdDropDown[materialsIdIndex].sMaterialsName}`;
                }
              }
            });
            // processPropsType
            const process = pData.filter(processItem => processItem.sControlId === controlItem.sId);
            // const processIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'process', 'sProcessName');
            let processIdDropDown;
            const processIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === "sProcessName");
            if (processIndex > -1) {
              const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, "process", processConfig.gdsconfigformslave[processIndex]);
              processIdDropDown = sqlDropDownData.dropDownData;
            }
            process.forEach((pItem, i) => {
              const fh = i === 0 ? "" : ",";
              if (processIdDropDown) {
                const processIdIndex = processIdDropDown.findIndex(item => item.sId === pItem.sProcessId);
                if (processIdIndex > -1) {
                  ipDetail = `${ipDetail}${fh} ${processIdDropDown[processIdIndex].sProcessName}`;
                }
              }
            });
            if (commonUtils.isNotEmptyObject(imDetail)) {
              mDetail = `${yDetail}${imDetail}`;
            }
            if (commonUtils.isNotEmptyObject(ipDetail)) {
              pDetail = `${gDetail}${ipDetail}`;
            }
          }
        }
      });
      slaveData[slaveIndex].sMaterialsMemo = mDetail;
      slaveData[slaveIndex].sProcessMemo = pDetail;
      slaveData[slaveIndex].handleType = commonUtils.isEmpty(slaveData[slaveIndex].handleType) ? "update" : slaveData[slaveIndex].handleType;
    } else if (commonUtils.isNotEmptyArr(controlData) && commonUtils.isEmptyArr(ctData)) {
      const sSlaveId = controlData[0].sSlaveId;
      const slaveIndex = slaveData.findIndex(item => item.sId === sSlaveId);
      slaveData[slaveIndex].sMaterialsMemo = "";
      slaveData[slaveIndex].sProcessMemo = "";
      slaveData[slaveIndex].handleType = commonUtils.isEmpty(slaveData[slaveIndex].handleType) ? "update" : slaveData[slaveIndex].handleType;
    }
    this.props.onSaveState({
      visibleModal: false,
      controlData,
      slave0Data,
      processData,
      slaveData,
    });
  };
  /** 控制选择控制表时，显示部件工序与成品工序 */
  handleFilterSlaveData = (name, dataIndex, value, record) => {
    return commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(value.toLowerCase());
  };
  /** 控制选择控制表时，显示部件工序与成品工序 */
  // eslint-disable-next-line no-unused-vars
  handleFilterData = (name, dataIndex, value, record) => {
    return true;
    // const { slaveSelectedRowKeys } = this.props;
    // if (name === 'process') {
    //   return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '3' &&
    //     commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase())) ||
    //     (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()) &&
    //       commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase()));
    // } else {
    //   return (commonUtils.isNotEmptyStr(record.sType) && record.sType === '2' &&
    //     commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase())) ||
    //     (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()) &&
    //       commonUtils.isNotEmptyStr(record.sSlaveId) && record.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString().toLowerCase()));
    // }
    // (commonUtils.isNotEmptyStr(record.sControlId) && record.sControlId.toString().toLowerCase().includes(value.toLowerCase()));
  };
  /* 控制表过滤材料表 工序表数据 */
  handleGetFilterData = name => {
    const { [`${name}Data`]: data, controlSelectedRowKeys, slaveSelectedRowKeys } = this.props;
    if (data !== undefined) {
      const newArr = data.filter(item => {
        if (name === "control") {
          return commonUtils.isNotEmptyStr(item.sSlaveId) && item.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString());
        } else {
          return (
            commonUtils.isNotEmptyStr(item.sControlId) &&
            item.sControlId.toString().toLowerCase().includes(controlSelectedRowKeys.toString()) &&
            commonUtils.isNotEmptyStr(item.sSlaveId) &&
            item.sSlaveId.toString().toLowerCase().includes(slaveSelectedRowKeys.toString())
          );
        }
      });
      return newArr.length;
    }
  };
  /**   添加表格空行   */
  handleTableAdd = async (name, flag) => {
    /*   外置处理业务   */
    const {
      sModelsId,
      sModelsType,
      gdsformconst,
      slaveData,
      controlData,
      controlSelectedRowKeys,
      [`${name}Data`]: tableData,
      slaveSelectedRowKeys,
      slaveConfig,
    } = this.props;
    let tableDataRow = {};
    if (name === "control") {
      tableDataRow = this.props.onDataRowAdd(name, true);
      if (commonUtils.isEmptyObject(tableDataRow)) {
        return;
      }
      let dPartsQty = 0;
      if (commonUtils.isNotEmptyArr(slaveData)) {
        slaveData.forEach(item => {
          dPartsQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
        });
        // const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', 'sProductName');
        let productIdDropDown;
        const slaveIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === "sProductName");
        if (slaveIndex > -1) {
          const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, "slave", slaveConfig.gdsconfigformslave[slaveIndex]);
          productIdDropDown = sqlDropDownData.dropDownData;
        }
        if (productIdDropDown) {
          const iProductIdIndex = productIdDropDown.findIndex(item => item.sId === slaveData[0].sProductId);
          if (iProductIdIndex > -1) {
            tableDataRow.sPartsName = productIdDropDown[iProductIdIndex].sProductName;
          }
        }
      }
      const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
      if (iSlaveIndex > -1) {
        if (sModelsType === "sales/salesOrder") {
          if (!commonUtils.isEmpty(slaveData[iSlaveIndex].dProductQty)) {
            tableDataRow.dPartsQty =
              commonUtils.isNull(slaveData[iSlaveIndex].dProductQty, 0) + commonUtils.isNull(slaveData[iSlaveIndex].dGiveQty, 0);
          }
        } else {
          tableDataRow.dPartsQty = dPartsQty;
        }
        tableDataRow.sSlaveId = slaveData[iSlaveIndex].sId;
      }
      tableData.push(tableDataRow);
      this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] });
    } else if (name === "materials" || name === "process") {
      tableDataRow = this.props.onDataRowAdd(name, true);
      if (commonUtils.isEmptyArr(controlSelectedRowKeys)) {
        const msg = commonFunc.showMessage(gdsformconst, "pleaseChooseParts");
        message.warn(msg === "" ? "请选择部件" : msg); // 请选择部件
        return;
      }
      const iIndex = controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]);
      const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
      if (iIndex > -1 && iSlaveIndex > -1) {
        if (commonUtils.isEmpty(controlData[iIndex].sPartsName) === "") {
          message.warn(commonFunc.showMessage(gdsformconst, "partsNameNotNull")); // 部件名称不能为空
          return;
        }
        tableDataRow.sSlaveId = slaveData[iSlaveIndex].sId;
        tableDataRow.sControlId = controlData[iIndex].sId;
        tableDataRow.sPartsName = controlData[iIndex].sPartsName;
      }
      tableData.push(tableDataRow);
      this.props.onSaveState({ [`${name}Data`]: tableData, [`${name}SelectedRowKeys`]: [tableDataRow.sId] });
    } else {
      this.props.onDataRowAdd(name, flag);
    }
  };
  /**   删除表格数据   */
  otherTableDel = (name, tableSelectedRowKeys) => {
    const tableData = this.props[`${name}Data`];
    let tableDelData = this.props[`${name}DelData`];
    tableDelData = commonUtils.isEmptyArr(tableDelData) ? [] : tableDelData;
    for (const sId of tableSelectedRowKeys) {
      /*   看看删除集合和从表中是否都存在该条数据   */
      let tableDataIndex = tableData.findIndex(item => item.sControlId === sId);
      while (tableDataIndex > -1) {
        /*   删除从表中的数据并存入删除集合中   */
        const slaveDataFilter = tableData[tableDataIndex];
        tableData.splice(tableDataIndex, 1);
        slaveDataFilter.handleType = "del";
        tableDelData.push(slaveDataFilter);
        tableDataIndex = tableData.findIndex(item => item.sControlId === sId);
      }
    }
    return { [`${name}Data`]: tableData, [`${name}DelData`]: tableDelData, [`${name}SelectedRowKeys`]: [] };
  };
  /**   删除表格数据   */
  handleTableDel = (name, isWait, tableSelectedRowKeys) => {
    const { slaveSelectedRowKeys, slaveData, slaveConfig, sModelsId, masterData } = this.props;
    if (name === "control") {
      const tableSelectedRowKeys = this.props[`${name}SelectedRowKeys`];
      if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) {
        const materialsReturnData = this.otherTableDel("materials", tableSelectedRowKeys);
        const processReturnData = this.otherTableDel("process", tableSelectedRowKeys);
        const controlReturnData = this.props.onDataRowDel(name, isWait, tableSelectedRowKeys);
        this.props.onSaveState({
          ...materialsReturnData,
          ...processReturnData,
          ...controlReturnData,
        });
        return true;
      } else {
        return false;
      }
    } else if (name === "slave") {
      /* 删除子表 */
      if (slaveConfig.sTableType === "single") {
        /* 单表删除 */
        if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
          let slaveSelectedRowNewKeys = slaveSelectedRowKeys;
          const newSelectedRowKeys = this.handleDelSlaveChild(slaveData, slaveSelectedRowKeys[0], slaveSelectedRowKeys);
          if (commonUtils.isNotEmptyArr(newSelectedRowKeys)) {
            slaveSelectedRowNewKeys = newSelectedRowKeys;
          }
          const slaveReturnData = this.props.onDataRowDel(name, isWait, slaveSelectedRowNewKeys);
          this.props.onSaveState({
            ...slaveReturnData,
          });
          return true;
        }
      } else if (sModelsId === "12710101117000994807090") {
        /* 从表删除 更新主表入仓数量 */
        const slaveReturnData = this.props.onDataRowDel(name, true, slaveSelectedRowKeys);
        if (
          commonUtils.isNotEmptyObject(slaveReturnData) &&
          commonUtils.isNotEmptyArr(slaveReturnData.slaveData) &&
          commonUtils.isNotEmptyObject(masterData)
        ) {
          let dSumProductQty = 0;
          slaveReturnData.slaveData.forEach((item, index) => {
            dSumProductQty = commonUtils.convertFixNum(
              commonUtils.convertFixNum(commonUtils.isNull(dSumProductQty, 0), 6) + commonUtils.convertFixNum(commonUtils.isNull(item.dSampleQty), 6),
              6
            );
          });
          masterData.dInspectQty = commonUtils.convertFixNum(dSumProductQty * 10000, 6);
          masterData.handleType = commonUtils.isEmpty(masterData.handleType) ? "update" : masterData.handleType;
          slaveReturnData.masterData = masterData;
        }
        this.props.onSaveState({
          ...slaveReturnData,
        });
        return true;
      } else {
        const slaveReturnData = this.props.onDataRowDel(name, isWait, slaveSelectedRowKeys);
        this.props.onSaveState({
          ...slaveReturnData,
        });
        return true;
      }
    } else {
      return this.props.onDataRowDel(name, isWait, tableSelectedRowKeys);
    }
  };

  /* 迭代删除从表子表数据  */
  handleDelSlaveChild = (tableData, sId, tableSelectedKeys) => {
    const filterData = tableData.filter(item => item.sFatherSlaveId === sId);
    filterData.forEach(item => {
      tableSelectedKeys.push(item.sId);
      this.handleDelSlaveChild(tableData, item.sId, tableSelectedKeys);
    });
    return tableSelectedKeys;
  };

  /**   销售订单删除从表数据时也删除控制材料工序表数据   */
  handleSlaveTableDel = (name, isWait, tableSelectedRowKeys) => {
    const { sModelsType, controlData, processData, materialsData } = this.props;
    if (sModelsType === "sales/salesOrder" && name === "slave") {
      const controlDataDel = controlData.filter(item => item.sSlaveId === tableSelectedRowKeys[0]);
      const controlDataSelectedRowKeys = [];
      if (!commonUtils.isEmpty(controlDataDel)) {
        for (const item of controlDataDel) {
          const materialsDataSelectedRowKey = item.sId;
          controlDataSelectedRowKeys.push(materialsDataSelectedRowKey);
        }
        if (commonUtils.isNotEmptyArr(controlDataSelectedRowKeys)) {
          this.props.onDataRowDel("control", isWait, controlDataSelectedRowKeys, true);
        }
        const materialsDataDel = materialsData.filter(item => item.sSlaveId === tableSelectedRowKeys[0]);
        const materialsDataSelectedRowKeys = [];
        if (!commonUtils.isEmpty(materialsDataDel)) {
          for (const item of materialsDataDel) {
            const materialsDataSelectedRowKey = item.sId;
            materialsDataSelectedRowKeys.push(materialsDataSelectedRowKey);
          }
        }
        if (commonUtils.isNotEmptyArr(materialsDataSelectedRowKeys)) {
          this.props.onDataRowDel("materials", isWait, materialsDataSelectedRowKeys, true);
        }
        const processDataDel = processData.filter(item => item.sSlaveId === tableSelectedRowKeys[0]);
        const processDataSelectedRowKeys = [];
        if (!commonUtils.isEmpty(processDataDel)) {
          for (const item of processDataDel) {
            const processDataSelectedRowKey = item.sId;
            processDataSelectedRowKeys.push(processDataSelectedRowKey);
          }
        }
        if (commonUtils.isNotEmptyArr(processDataSelectedRowKeys)) {
          this.props.onDataRowDel("process", isWait, processDataSelectedRowKeys, true);
        }
      }
    }
    return this.props.onDataRowDel(name, isWait, tableSelectedRowKeys);
  };
  handleSelect = async (name, selectConfig, selectData) => {
    const {
      [`${name}Data`]: tableData,
      [`${name}Config`]: tableConfig,
      masterData,
      masterConfig,
      controlSelectedRowKeys,
      sModelsId,
      token,
      app,
    } = this.props;
    const tableSelectedRowKeys = [];
    if (name === "productProcessInfo") {
      if (commonUtils.isNotEmptyArr(selectData)) {
        let slaveData = [];
        let controlData = [];
        let materialsData = [];
        let processData = [];
        let sConfigMasterIdSlave = "";
        let sConfigMasterIdControl = "";
        let sConfigMasterIdMaterials = "";
        let sConfigMasterIdProcess = "";
        const selectRowData = selectData[0];
        const sConfigIdString = masterConfig.gdsconfigformslave.filter(item => item.sName === "sConfigId")[0].showDropDown;
        if (commonUtils.isNotEmptyStr(sConfigIdString)) {
          const sConfigId = JSON.parse(sConfigIdString);
          sConfigMasterIdSlave = sConfigId.sConfigMasterIdSlave;
          sConfigMasterIdControl = sConfigId.sConfigMasterIdControl;
          sConfigMasterIdMaterials = sConfigId.sConfigMasterIdMaterials;
          sConfigMasterIdProcess = sConfigId.sConfigMasterIdProcess;
        }
        if (commonUtils.isEmptyStr(sConfigMasterIdSlave)) {
          message.warning(commonFunc.showMessage(app.commonConst, "slaveParameterErro"));
        }
        if (commonUtils.isEmptyStr(sConfigMasterIdControl)) {
          message.warning(commonFunc.showMessage(app.commonConst, "controlParameterErro"));
        }
        if (commonUtils.isEmptyStr(sConfigMasterIdMaterials)) {
          message.warning(commonFunc.showMessage(app.commonConst, "materialsParameterErro"));
        }
        if (commonUtils.isEmptyStr(sConfigMasterIdProcess)) {
          message.warning(commonFunc.showMessage(app.commonConst, "processParameterErro"));
        }
        const slaveUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdSlave}?sModelsId=${sModelsId}`;
        const value = { sSqlCondition: { sParentId: selectRowData.sId } };
        const slaveReturnData = (await commonServices.postValueService(token, value, slaveUrl)).data;
        if (slaveReturnData.code === 1) {
          slaveData = slaveReturnData.dataset.rows[0].dataSet;
          slaveData.forEach(item => {
            item.handleType = "add";
            item.sId = commonUtils.createSid();
            item.sParentId = masterData.sId;
          });
        } else {
          this.props.getServiceError(slaveReturnData);
        }

        const controlUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdControl}?sModelsId=${sModelsId}`;
        const controlReturnData = (await commonServices.postValueService(token, value, controlUrl)).data;
        if (controlReturnData.code === 1) {
          controlData = controlReturnData.dataset.rows[0].dataSet;
          controlData.forEach(item => {
            item.handleType = "add";
            item.sId = commonUtils.createSid();
            item.sParentId = masterData.sId;
          });
        } else {
          this.props.getServiceError(controlReturnData);
        }
        const materialsUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdMaterials}?sModelsId=${sModelsId}`;
        const materialsReturnData = (await commonServices.postValueService(token, value, materialsUrl)).data;
        if (materialsReturnData.code === 1) {
          materialsData = materialsReturnData.dataset.rows[0].dataSet;
          materialsData.forEach(item => {
            item.handleType = "add";
            item.sId = commonUtils.createSid();
            item.sParentId = masterData.sId;
          });
        } else {
          this.props.getServiceError(materialsReturnData);
        }
        const processUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${sConfigMasterIdProcess}?sModelsId=${sModelsId}`;
        const processReturnData = (await commonServices.postValueService(token, value, processUrl)).data;
        if (processReturnData.code === 1) {
          processData = processReturnData.dataset.rows[0].dataSet;
          processData.forEach(item => {
            item.handleType = "add";
            item.sId = commonUtils.createSid();
            item.sParentId = masterData.sId;
          });
        } else {
          this.props.getServiceError(processReturnData);
        }
        this.props.onSaveState({
          processData,
          materialsData,
          controlData,
          slaveData,
          [`${name}ChooseVisible`]: false,
          [`${name}SelectedRowKeys`]: tableSelectedRowKeys,
        });
      }
    } else {
      const { controlData, slaveData, slaveSelectedRowKeys } = this.props;
      const iIndex = commonUtils.isNotEmptyArr(controlSelectedRowKeys) ? controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]) : -1;
      if (commonUtils.isNotEmptyArr(selectData)) {
        selectData.forEach(item => {
          const newCopyTo = {};
          newCopyTo.master = masterData;
          if (iIndex > -1) {
            newCopyTo.control = controlData[iIndex];
          }
          let tableDataRow = commonFunc.getDefaultData(tableConfig, newCopyTo); // 取默认值
          tableDataRow = { ...tableDataRow, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段
          tableDataRow.handleType = "add";
          tableDataRow.sId = commonUtils.createSid();
          tableDataRow.sParentId = masterData.sId;
          if (this.props.sModelsType === "sales/salesOrder") {
            const iSlaveIndex = commonUtils.isNotEmptyArr(slaveSelectedRowKeys)
              ? slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0])
              : -1;
            if (iSlaveIndex > -1) {
              tableDataRow.sSlaveId = slaveData[iSlaveIndex].sId;
            }
          }
          if (iIndex > -1 && tableDataRow.sType !== "3") {
            tableDataRow.sControlId = controlData[iIndex].sId;
            tableDataRow.sPartsName = controlData[iIndex].sPartsName;
            tableData.push(tableDataRow);
          } else if (tableDataRow.sType === "3") {
            tableData.push(tableDataRow);
          }
          tableSelectedRowKeys.push(tableDataRow.sId);
        });
      }
      const tableDataNew = this.sortData(controlData, tableData);
      this.props.onSaveState({ [`${name}Data`]: tableDataNew, [`${name}ChooseVisible`]: false, [`${name}SelectedRowKeys`]: tableSelectedRowKeys });
    }
  };

  sortData = (tableData, processData) => {
    processData.sort((g1, g2) => {
      const iIndex1 = tableData.findIndex(item => item.sId === g1.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g1.sControlId);
      let sPartOrder1 = `0000${iIndex1}`;
      sPartOrder1 = sPartOrder1.substring(sPartOrder1.length - 3);
      let sOrder1 = `000${g1.iOrder}`;
      sOrder1 = sOrder1.substring(sOrder1.length - 3);

      const iIndex2 = tableData.findIndex(item => item.sId === g2.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g2.sControlId);
      let sPartOrder2 = `0000${iIndex2}`;
      sPartOrder2 = sPartOrder2.substring(sPartOrder2.length - 3);
      let sOrder2 = `000${g2.iOrder}`;
      sOrder2 = sOrder2.substring(sOrder2.length - 3);
      return parseInt(sPartOrder1 + g1.sType + sOrder1, 10) - parseInt(sPartOrder2 + g2.sType + sOrder2, 10);
    });
    return processData;
  };
  /**   上传后执行函数    */
  handleBeforeUpload = () => {
    // const isLt10M = file.size / 1024 / 1024 < 10;
    // if (!isLt10M) {
    //   message.error(commonFunc.showMessage(this.props.app.commonConst, 'picMax'));/* 图片大小需小于10MB! */
    // }
  };

  handleTabChange = key => {
    setTimeout(() => {
      this.setState({
        currentTab: key,
      });
    }, 0);
  };

  handleMenuClick = e => {
    let { sId } = this.props.masterData;
    const Type = e.key;
    const { token } = this.props.app;
    const { sType } = this.props.app.userinfo;
    if (Type === "formSlave") {
      /* 根据从表勾选数据 生成从表数据 */
      const { slaveSelectedRowKeys } = this.props;
      if (commonUtils.isEmptyObject(slaveSelectedRowKeys)) {
        message.warn("请选择数据");
        return;
      }
      sId = slaveSelectedRowKeys;
    }
    const downloadUrl = `${commonConfig.server_host}sqlfile/scriptSqlDownload?methodName=${Type}&sId=${sId}&token=${token}&sType=${sType}`;
    window.open(downloadUrl);
    this.props.onSaveState({
      downloadUrl,
    });
  };
  handleSlaveInit = async name => {
    const { app, masterData, [`${name}Data`]: slaveData } = this.props;
    if (masterData.sName !== null && masterData.sName !== undefined) {
      message.warn("该节点不能初始化！");
      return;
    }
    // const comfiled = service.service_path.filter(item => (item.route ===
    //   app.currentPane.route)).length <= 0 ? {} :
    //   service.service_path.filter(item => (item.route ===
    //     app.currentPane.route))[0];
    const comfiled = {
      path: "gdsconfigform",
      pathTwo: "Gdsconfigformmaster",
      pathSlave: "Gdsconfigformslave",
      pathCustom: "Customslave",
      pathInit: "GdsconfigformslaveByMaster",
      pathSlaveSelect: "gdsmodule",
      pathSlaveSelectTwo: "SelectFormData",
    };
    const url = `${commonConfig.server_host}${comfiled.path}/get${comfiled.pathInit}?sParentId=${masterData.sId}&sTbName=${masterData.sTbName}&sType=${masterData.sType}`;
    const dataReturn = (await commonServices.getService(this.props.app.token, url)).data;
    if (dataReturn.code === 1) {
      /*   数据查询成功   */
      if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows)) {
        const tempData = dataReturn.dataset.rows;
        const initData = [];
        tempData.forEach(item => {
          item.handleType = "add";
          initData.push(item);
        });
        const newData = [...slaveData, ...initData];
        this.props.onSaveState({ slaveData: newData, enabled: true });
        message.success("初始化成功！");
      } else {
        message.warn("当前表格无需初始化！");
      }
    } else {
      /*   失败   */
      this.props.getServiceError(dataReturn);
    }
  };
  handleCopyRow = (name, toname) => {
    this.props.onCopyRow(name, toname);
  };
  handleCopy2Custom = () => {
    let toname = "slave2";
    for (let i = 0; i < 10; i++) {
      const slaveConfigName = `slave${i}Config`;
      const slaveConfig = this.props[slaveConfigName];
      if (slaveConfig && commonUtils.isNotEmptyObject(slaveConfig)) {
        if (slaveConfig.sTbName === "gdsconfigformcustomslave") {
          toname = `slave${i}`;
          break;
        }
      }
    }
    this.props.onCopyRow("slave", toname);
  };
  /**   添加行   */
  handleAddRow = (name, index) => {
    this.props.onDataRowAdd(name, null, index);
  };
  /**   删除行   */
  handleDelRow = name => {
    const { [`${name}SelectedRowKeys`]: tableSelectedRowKeys } = this.props;
    if (this.props.onDataRowDel(name, false, tableSelectedRowKeys)) {
      message.success("删除成功！");
    }
  };

  /* 字段双击弹出 */
  handleFieldDoubleClick = (sValue, showConfig, tbName) => {
    const { [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, [`${tbName}Data`]: tableData } = this.props;
    if (commonUtils.isNotEmptyObject(showConfig) && showConfig.sName === "sAssignField") {
      let tableDataRow = {};
      if (commonUtils.isNotEmptyArr(tableData)) {
        const tableFilterData = tableData.filter(item => tableSelectedRowKeys.includes(item.sId));
        if (commonUtils.isNotEmptyArr(tableFilterData)) {
          tableDataRow = tableFilterData[0];
        }
      }
      const sAssignFieldColumn = [
        {
          sId: commonUtils.createSid(),
          sParentId: tableDataRow.sId,
          dataIndex: "sNewName",
          title: "现字段",
          width: "220px",
          editable: true,
          bNotSort: true,
        },
        {
          sId: commonUtils.createSid(),
          sParentId: tableDataRow.sId,
          dataIndex: "sOldName",
          title: "源字段",
          width: "220px",
          editable: true,
          bNotSort: true,
        },
      ];
      const sAssignFieldData = [];
      if (commonUtils.isNotEmptyObject(tableDataRow) && commonUtils.isNotEmptyObject(sValue)) {
        const selectedRowKeys = [];
        const sAssignFieldDataTemp = sValue.split(",");
        sAssignFieldDataTemp.forEach(index => {
          const aAssignFieldObj = {};
          const splitData = index.split(":");
          if (commonUtils.isNotEmptyArr(splitData)) {
            aAssignFieldObj.sId = commonUtils.createSid();
            aAssignFieldObj.sNewName = splitData[0];
            aAssignFieldObj.sOldName = splitData[1];
            sAssignFieldData.push(aAssignFieldObj);
          }
          selectedRowKeys[0] = sAssignFieldData[0].sId;
        });
        const { enabled } = this.props;
        this.props.onSaveState({
          sAssignFieldColumn,
          visibleAssignmentField: true,
          sAssignFieldData,
          sAssignFieldName: tbName,
          sAssignFieldRowId: tableDataRow.sId /* 选中行的sId */,
          enabled,
        });
      } else {
        this.props.onSaveState({
          sAssignFieldColumn,
          visibleAssignmentField: true,
          sAssignFieldData: [],
          sAssignFieldName: tbName,
          sAssignFieldRowId: tableDataRow.sId /* 选中行的sId */,
        });
      }
    } else if (showConfig?.sName === "sInstruct") {
      /* 指令集弹窗 */
      // const sInstructJsonString = sValue;
      // this.props.onSaveState({
      //   visibleInstructField: true,
      //   sInstructJsonString,
      // });
    }
  };
  /* 拿到赋值字段 */
  handleGetsAssignField = (data, sFieldName) => {
    if (sFieldName === "sAssignField") {
      const { sAssignFieldRowId, sAssignFieldName } = this.props; /* 双击弹出赋值窗体的行ID */
      const { [`${sAssignFieldName}Data`]: tableData } = this.props;
      if (commonUtils.isNotEmptyArr(tableData)) {
        const iIndex = tableData.findIndex(item => item.sId === sAssignFieldRowId);
        const newData = {};
        /* 将数组变成赋值字符串 */
        let sAssignFieldStr = "";
        const len = data.length;
        data.forEach((item, index) => {
          sAssignFieldStr += `${item.sNewName}:${item.sOldName}`;
          if (index !== len - 1) {
            sAssignFieldStr += ",";
          }
        });
        newData.sAssignField = sAssignFieldStr;
        newData.handleType = commonUtils.isEmpty(tableData[iIndex].handleType) ? "update" : tableData[iIndex].handleType;
        tableData[iIndex] = { ...tableData[iIndex], ...newData };
        this.props.onSaveState({ [`${sAssignFieldName}Data`]: tableData });
      }
    }
  };

  handleUploadPropsSales = () => {
    const { masterData, sModelsType } = this.props;
    if (commonUtils.isNotEmptyObject(masterData)) {
      const sCustomerId = commonUtils.isEmptyStr(masterData.sCustomerId) ? undefined : masterData.sCustomerId;
      let existCustomerId = false;
      if (sModelsType.includes("sales/") && commonUtils.isNotEmptyStr(sCustomerId)) {
        existCustomerId = true;
      } else if (!sModelsType.includes("sales/")) {
        existCustomerId = true;
      }
      return {
        disabled: !this.props.enabled || !existCustomerId /*   是否可用   */,
        style: { display: commonUtils.convertBooleanToDisplayBlock(true) } /*   是否显示   */,
      };
    }
  };

  handleUploadChangeFile = async info => {
    const { file } = info;
    const { formData = [] } = this.props;

    const templateData = formData.filter(item => item.sGrd === 'importTemplate');
    const name = commonUtils.isNotEmptyArr(templateData) ? templateData[0].sTableAlias : 'slave'
    const {
      masterData, sModelsId, app, token, sModelsType,
      [`${name}Config`]: slaveConfig, [`${name}Data`]: slaveData
    } = this.props;
    if (file.response) {
      if (file.response.code === 1) {
        if (file.response.dataset.rows.length > 1) {
          const addState = {};
          for (let i = 0; i < file.response.dataset.rows.length; i++) {
            const row = file.response.dataset.rows[i];
            /*   数据查询成功   */
            const errorInfo = row.nocanbeInsert;
            if (commonUtils.isNotEmptyObject(errorInfo)) {
              const importErrorData = errorInfo;
              this.props.onSaveState({
                showImportErrorVisible: true,
                importData: importErrorData,
              });
              return;
            }

            const tableName = ["", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
              .filter(item => {
                const name = `slave${item}Config`;
                const config = this.props[name] || {};
                return config.sGrd === row.sGrd || config.sTableName === row.sTableName;
              })
              .map(item => `slave${item}`)[0];

            if (!tableName) continue;

            const tableDelData = [];
            const { [`${tableName}Data`]: tableData = [], [`${tableName}Config`]: tableConfig } = this.props;
            /* 把之前存放的数据删除 */
            addState[`${tableName}DelData`] = [];
            tableData.forEach(item => {
              if (item.handleType !== "add") {
                item.handleType = "del";
                tableDelData.push(item);
              }
            });

            const returnData = row.canbeInsert;
            let iCount = 0;
            let productIdDropDown;
            if (productIdDropDown === undefined && commonUtils.isNotEmptyArr(returnData)) {
              /* 无论导入多少条数据 都只调用1次接口,获取产品下拉数据集 */
              const iIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === "sProductName");
              if (iIndex > -1) {
                const sqlDropDownData = await this.props.getSqlDropDownData(
                  sModelsId,
                  tableName,
                  tableConfig.gdsconfigformslave[iIndex],
                  returnData[0]
                );
                productIdDropDown = sqlDropDownData.dropDownData;
              }
            }

            await returnData.forEach(async tableDataRow => {
              tableDataRow.handleType = "add";
              tableDataRow.sId = commonUtils.createSid();
              tableDataRow.sParentId = masterData.sId;
              tableDataRow.key = tableDataRow.sId;
              /* 若导入模板没有序号，则序号从1自增 */
              if (commonUtils.isEmptyObject(tableDataRow.iOrder)) {
                iCount += 1;
                tableDataRow.iOrder = iCount;
              }
              for (const child of Object.keys(tableDataRow)) {
                const index = child.indexOf("_sRealValue_");
                if (index > -1) {
                  const property = child.substring(0, child.length - 12);
                  tableDataRow[property] = tableDataRow[child];
                }
              }
              if (productIdDropDown !== undefined) {
                const iProductIdIndex = productIdDropDown.findIndex(
                  item =>
                    (item.sId === tableDataRow.sProductId || item.sNId === tableDataRow.sProductId) &&
                    item.sProductStyle === tableDataRow.sProductStyle
                );
                if (iProductIdIndex === -1 && commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes("sales/salesOrder")) {
                  /* 只有销售模块生成新产品 盘点 ，期间 不生成新的产品 */
                  tableDataRow.sProductId = tableDataRow.sProductName;
                  tableDataRow.sProductInfo = JSON.stringify({
                    sProductId: tableDataRow.sProductName,
                    sProductName: tableDataRow.sProductName,
                    sProductStyle: tableDataRow.sProductStyle,
                    sProductUnit: tableDataRow.sProductUnit,
                    sProductNo: tableDataRow.sProductNo,
                    sCustomerProductNo: tableDataRow.sCustomerProductNo,
                    sProductClassifyId: tableDataRow.sProductClassifyId,
                    sProductClassifyName: tableDataRow.sProductClassifyName,
                  });
                }
              }
              // if (!tableDataRow.dNProductPrice) {
              //   tableDataRow.dNProductPrice = tableDataRow.dProductForeignPrice;
              // }
              // const models = sModelsType.includes('sales/') || sModelsType.includes('manufacture/') || sModelsType.includes('quotation/') || sModelsType.includes('productStock/') ? 'Product' : 'Materials';
              // if (sModelsType.includes('purchase/') || sModelsType.includes('quotation/') || sModelsType.includes('manufacture/') || sModelsType.includes('materialsStock/') || sModelsType.includes('outside/')) {
              //   tableDataRow = await this.props.onMaterialsChange(tableDataRow, sModelsId, masterData, {}, 'dAuxiliaryQty', app, token, models);
              //   tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dAuxiliaryQty', masterData, tableDataRow);
              // } else {
              //   tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dProductQty', masterData, tableDataRow);
              // }
            });

            addState[`${tableName}Data`] = returnData;
            addState[`${tableName}DelData`] = tableDelData;
          }
          this.props.onSaveState(addState);
        } else {
          /*   数据查询成功   */
          const errorInfo = file.response.dataset.rows[0].nocanbeInsert;
          if (commonUtils.isNotEmptyObject(errorInfo)) {
            // message.error(errorInfo[0].sReason);
            const importErrorData = errorInfo;
            this.props.onSaveState({
              showImportErrorVisible: true,
              importData: importErrorData,
            });
            return;
          }
          /* 把之前存放的数据删除 */
          const slaveDelData = [];
          if (commonUtils.isNotEmptyArr(slaveData)) {
            slaveData.forEach(item => {
              if (commonUtils.isEmptyObject(item.handleType)) {
                item.handleType = "del";
                slaveDelData.push(item);
              }
            });
          }
          const returnData = file.response.dataset.rows[0].canbeInsert;
          let iCount = 0;
          let productIdDropDown;
          if (productIdDropDown === undefined && commonUtils.isNotEmptyArr(returnData)) {
            /* 无论导入多少条数据 都只调用1次接口,获取产品下拉数据集 */
            const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sName === "sProductName");
            if (iIndex > -1) {
              const sqlDropDownData = await this.props.getSqlDropDownData(sModelsId, "slave", slaveConfig.gdsconfigformslave[iIndex], returnData[0]);
              productIdDropDown = sqlDropDownData.dropDownData;
            }
          }
          await returnData.forEach(async tableDataRow => {
            tableDataRow.handleType = "add";
            tableDataRow.sId = commonUtils.createSid();
            tableDataRow.sParentId = masterData.sId;
            tableDataRow.key = tableDataRow.sId;
            /* 若导入模板没有序号，则序号从1自增 */
            if (commonUtils.isEmptyObject(tableDataRow.iOrder)) {
              iCount += 1;
              tableDataRow.iOrder = iCount;
            }
            for (const child of Object.keys(tableDataRow)) {
              const index = child.indexOf("_sRealValue_");
              if (index > -1) {
                const property = child.substring(0, child.length - 12);
                tableDataRow[property] = tableDataRow[child];
              }
            }
            if (productIdDropDown !== undefined) {
              const iProductIdIndex = productIdDropDown.findIndex(
                item =>
                  (item.sId === tableDataRow.sProductId || item.sNId === tableDataRow.sProductId) && item.sProductStyle === tableDataRow.sProductStyle
              );
              if (iProductIdIndex === -1 && commonUtils.isNotEmptyObject(sModelsType) && sModelsType.includes("sales/salesOrder")) {
                /* 只有销售模块生成新产品 盘点 ，期间 不生成新的产品 */
                tableDataRow.sProductId = tableDataRow.sProductName;
                tableDataRow.sProductInfo = JSON.stringify({
                  sProductId: tableDataRow.sProductName,
                  sProductName: tableDataRow.sProductName,
                  sProductStyle: tableDataRow.sProductStyle,
                  sProductUnit: tableDataRow.sProductUnit,
                  sProductNo: tableDataRow.sProductNo,
                  sCustomerProductNo: tableDataRow.sCustomerProductNo,
                  sProductClassifyId: tableDataRow.sProductClassifyId,
                  sProductClassifyName: tableDataRow.sProductClassifyName,
                });
              }
            }
            if (!tableDataRow.dNProductPrice) {
              tableDataRow.dNProductPrice = tableDataRow.dProductForeignPrice;
            }
            const models =
              sModelsType.includes("sales/") ||
                sModelsType.includes("manufacture/") ||
                sModelsType.includes("quotation/") ||
                sModelsType.includes("productStock/")
                ? "Product"
                : "Materials";
            if (
              sModelsType.includes("purchase/") ||
              sModelsType.includes("quotation/") ||
              sModelsType.includes("manufacture/") ||
              sModelsType.includes("materialsStock/") ||
              sModelsType.includes("outside/")
            ) {
              tableDataRow = await this.props.onMaterialsChange(tableDataRow, sModelsId, masterData, {}, "dAuxiliaryQty", app, token, models);
              tableDataRow = commonBusiness.getCalculateAllMoney(app, models, "dAuxiliaryQty", masterData, tableDataRow);
            } else {
              tableDataRow = commonBusiness.getCalculateAllMoney(app, models, "dProductQty", masterData, tableDataRow);
            }
          });
          this.props.onSaveState({ slaveData: returnData, slaveDelData });
        }
      } else {
        /*   失败s   */
        this.props.getServiceError(file.response);
      }
    }
  };

  handleSetTabNumList = tabNumList => {
    this.tabNumList = tabNumList;
  };

  /**   通用下载    */
  handleDownload = (name, flag, tableSelectedRowKeys) => {
    const { [`${name}Data`]: tableData, sModelsId, app } = this.props;
    if (tableSelectedRowKeys === undefined || tableSelectedRowKeys.length !== 1) {
      message.warn(commonFunc.showMessage(app.commonConst, "selectedRowKeysNo")); /* 请先选择一条数据 */
      return;
    }
    const dataSelect = tableData.filter(item => item.sId === tableSelectedRowKeys[0]);
    const { token } = this.props.app;
    const { sPicturePath } = dataSelect[0];
    const urlPrint = `${commonConfig.file_host}file/download?sModelsId=${sModelsId}&token=${token}&savePathStr=${sPicturePath}`;
    window.open(urlPrint);
  };
  handleJSONModalOk = value => {
    const { masterData } = this.props;
    const textAreaValue = value; // 获取 textarea 的值
    const handleType = commonUtils.isEmpty(masterData.handleType) ? "update" : masterData.handleType;
    const newMasterData = { ...masterData, sInstruct: textAreaValue, handleType }; // 更新 masterData.sInstruct
    this.props.onSaveState({ masterData: newMasterData, visibleInstructField: false }); // 关闭弹窗
  };

  // ----------------------------数据修改回带wend  ---------------------------- //

  render() {
    const { pageLoading, visible, checkConditions, checkPersonData, app } = this.props;
    const checkCondition = commonFunc.showMessage(app.commonConst, "checkCondition"); /* 审核条件 */
    const checkSmemo = commonFunc.showMessage(app.commonConst, "checkSmemo"); /* 备注 */
    const columns = [
      {
        title: checkCondition,
        dataIndex: "condition",
        key: "condition",
      },
      {
        title: checkSmemo,
        dataIndex: "sMemo",
        key: "sMemo",
      },
    ];
    const btnSure = commonFunc.showMessage(app.commonConst, "btnSure"); /* 确认 */
    const check = commonFunc.showMessage(app.commonConst, "check"); /* 审核 */
    const BtnClose = commonFunc.showMessage(app.commonConst, "BtnClose"); /* 关闭 */
    const checkPerson = commonFunc.showMessage(app.commonConst, "checkPerson"); /* 审核人 */
    return (
      <div>
        <Spin spinning={pageLoading}>
          <div>
            <BillComponent
              {...this.props}
              {...this.state}
              onUploadChangeFile={this.handleUploadChangeFile} /* xls文件导入 */
              onTabChange={this.handleTabChange}
              onUploadChange={this.handleUploadChange}
              getMenuStatus={this.getMenuStatus}
              onBeforeUpload={this.handleBeforeUpload}
              onUploadPropsSales={this.handleUploadPropsSales}
              onDataRowModal={this.handleTableModal}
              onDataRowDel={this.handleSlaveTableDel}
              handleMenuClick={this.handleMenuClick}
              handleSlaveInit={this.handleSlaveInit}
              handleCopy2Custom={this.handleCopy2Custom}
              handleCopyRow={this.handleCopyRow}
              handleAddRow={this.handleAddRow}
              handleDelRow={this.handleDelRow}
              getSlaveInfos={this.getSlaveInfos}
              onGetsAssignField={this.handleGetsAssignField}
              handleFieldDoubleClick={this.handleFieldDoubleClick}
              onGetTabNumList={() => this.tabNumList}
              onSetTabNumList={this.handleSetTabNumList}
              onDataRowDownload={this.handleDownload}
              onDelRow={this.handleTableDel}
              onJsonModalOk={this.handleJSONModalOk}
            />
            {visible ? (
              <AntdDraggableModal
                title={check}
                visible={visible}
                onCancel={this.handleCancel}
                footer={[
                  <Button key="back" onClick={this.handleCancel}>
                    {BtnClose}
                  </Button>,
                  <Button key="submit" type="primary" onClick={this.handleOk.bind(this, 1, 1, true)}>
                    {btnSure}
                  </Button>,
                ]}
              >
                <Table columns={columns} dataSource={checkConditions} bordered pagination={false} className={styles.checkTable} />
                <div style={{ float: "left", width: "15%" }}>{checkPerson}</div>
                <div style={{ float: "left", width: "60%" }}>
                  <Checkbox.Group style={{ width: "100%" }} onChange={this.onChange}>
                    <Row>
                      {commonUtils.isNotEmptyObject(checkPersonData)
                        ? checkPersonData.map(item => {
                          return (
                            <Col span={8}>
                              <Checkbox value={item.sUserId}>{item.sUserName}</Checkbox>
                            </Col>
                          );
                        })
                        : ""}
                    </Row>
                  </Checkbox.Group>
                </div>
              </AntdDraggableModal>
            ) : (
              ""
            )}
          </div>
        </Spin>
      </div>
    );
  }
}

const BillComponent = Form.create({
  mapPropsToFields(props) {
    const { masterData, masterConfig } = props;
    const obj = commonFunc.mapPropsToFields(masterData, Form, masterConfig);
    return obj;
  },
})(props => {
  const {
    form,
    onReturnForm,
    AutoTableHeight,
    onlySlave,
    onlySlave0,
    onlySlave1,
    onlyslave2,
    onlyslave3,
    onlyslave4,
    onlyslave5,
    onlyslave6,
    onlyslave7,
    onlyslave8,
    onlyslave9,
    onlyslave10,
    slaveData,
    slave0Data,
    slave1Data,
    slave2Data,
    slave3Data,
    slave4Data,
    slave5Data,
    slave6Data,
    slave7Data,
    slave8Data,
    slave9Data,
    slave10Data,
    slaveConfig,
    slave0Config,
    slave1Config,
    slave2Config,
    slave3Config,
    slave4Config,
    slave5Config,
    slave6Config,
    slave7Config,
    slave8Config,
    slave9Config,
    slave10Config,
    slaveSelectedRowKeys,
    slave0SelectedRowKeys,
    slave1SelectedRowKeys,
    slave2SelectedRowKeys,
    slave3SelectedRowKeys,
    slave4SelectedRowKeys,
    app,
    slavePagination,
    slave0Pagination,
    slave1Pagination,
    slave2Pagination,
    slave3Pagination,
    slave4Pagination,
    slave5Pagination,
    slave6Pagination,
    slave7Pagination,
    slave8Pagination,
    slave9Pagination,
    slave10Pagination,
    slavePageSize,
    slave0PageSize,
    slave1PageSize,
    slave2PageSize,
    slave3PageSize,
    slave4PageSize,
    slave5PageSize,
    slave6PageSize,
    slave7PageSize,
    slave8PageSize,
    slave9PageSize,
    slave10PageSize,
    sModelsType,
    sModelsId,
    bDelegate,
    sInstructJsonString = "",
  } = props;
  const masterConfig = props.onMergeMasterConfig();
  const masterConfigOld = { ...masterConfig };
  /*   回带表单   */
  onReturnForm(form);
  const autoHeight = `calc( ${AutoTableHeight} - 96px)`;
  const isSmall = false;
  let pageSize = commonConfig.pageSize;
  if (props.slaveConfig && props.slaveConfig.iPageSize) {
    pageSize = props.slaveConfig.iPageSize;
  }

  const { currentPane } = app;
  let bFlow = currentPane?.bFlow; /* 是否需要展示审批流程信息 */
  if (bDelegate) {
    bFlow = false;
  }

  const bPagination = commonUtils.isNotEmptyObject(slaveConfig) ? slaveConfig.bPagination : false;
  const bPagination0 = commonUtils.isNotEmptyObject(slave0Config) ? slave0Config.bPagination : false;
  const bPagination1 = commonUtils.isNotEmptyObject(slave1Config) ? slave1Config.bPagination : false;
  const bPagination2 = commonUtils.isNotEmptyObject(slave2Config) ? slave2Config.bPagination : false;
  const bPagination3 = commonUtils.isNotEmptyObject(slave3Config) ? slave3Config.bPagination : false;
  const bPagination4 = commonUtils.isNotEmptyObject(slave4Config) ? slave4Config.bPagination : false;
  const bPagination5 = commonUtils.isNotEmptyObject(slave5Config) ? slave5Config.bPagination : false;
  const bPagination6 = commonUtils.isNotEmptyObject(slave6Config) ? slave6Config.bPagination : false;
  const bPagination7 = commonUtils.isNotEmptyObject(slave7Config) ? slave7Config.bPagination : false;
  const bPagination8 = commonUtils.isNotEmptyObject(slave8Config) ? slave8Config.bPagination : false;
  const bPagination9 = commonUtils.isNotEmptyObject(slave9Config) ? slave9Config.bPagination : false;
  const bPagination10 = commonUtils.isNotEmptyObject(slave10Config) ? slave10Config.bPagination : false;

  const pagination = !bPagination
    ? false
    : {
      pageSize,
      total: commonUtils.isEmptyArr(slaveData) ? 0 : slaveData.length,
      current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current,
      ...slavePagination,
      // showQuickJumper: true,
      hideOnSinglePage: false,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination0 = !bPagination0
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave0PageSize) && slave0PageSize !== 0 ? slave0PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave0Data) ? 0 : slave0Data.length,
      current: commonUtils.isEmptyObject(slave0Pagination) ? 1 : slave0Pagination.current,
      ...slave0Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: false,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination1 = !bPagination1
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave1PageSize) && slave1PageSize !== 0 ? slave1PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave1Data) ? 0 : slave1Data.length,
      current: commonUtils.isEmptyObject(slave1Pagination) ? 1 : slave1Pagination.current,
      ...slave1Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination2 = !bPagination2
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave2PageSize) && slave2PageSize !== 0 ? slave2PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave2Data) ? 0 : slave2Data.length,
      current: commonUtils.isEmptyObject(slave2Pagination) ? 1 : slave2Pagination.current,
      ...slave2Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination3 = !bPagination3
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave3PageSize) && slave3PageSize !== 0 ? slave3PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave3Data) ? 0 : slave3Data.length,
      current: commonUtils.isEmptyObject(slave3Pagination) ? 1 : slave3Pagination.current,
      ...slave3Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination4 = !bPagination4
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave4PageSize) && slave4PageSize !== 0 ? slave4PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave4Data) ? 0 : slave4Data.length,
      current: commonUtils.isEmptyObject(slave4Pagination) ? 1 : slave4Pagination.current,
      ...slave4Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };

  const pagination5 = !bPagination5
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave5PageSize) && slave5PageSize !== 0 ? slave5PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave5Data) ? 0 : slave5Data.length,
      current: commonUtils.isEmptyObject(slave5Pagination) ? 1 : slave5Pagination.current,
      ...slave5Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination6 = !bPagination6
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave6PageSize) && slave6PageSize !== 0 ? slave6PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave6Data) ? 0 : slave6Data.length,
      current: commonUtils.isEmptyObject(slave6Pagination) ? 1 : slave6Pagination.current,
      ...slave6Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination7 = !bPagination7
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave7PageSize) && slave7PageSize !== 0 ? slave7PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave7Data) ? 0 : slave7Data.length,
      current: commonUtils.isEmptyObject(slave7Pagination) ? 1 : slave7Pagination.current,
      ...slave7Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination8 = !bPagination8
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave8PageSize) && slave8PageSize !== 0 ? slave8PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave8Data) ? 0 : slave8Data.length,
      current: commonUtils.isEmptyObject(slave8Pagination) ? 1 : slave8Pagination.current,
      ...slave8Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination9 = !bPagination9
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave9PageSize) && slave9PageSize !== 0 ? slave9PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave9Data) ? 0 : slave9Data.length,
      current: commonUtils.isEmptyObject(slave9Pagination) ? 1 : slave9Pagination.current,
      ...slave9Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };
  const pagination10 = !bPagination10
    ? false
    : {
      pageSize: commonUtils.isNotEmptyNumber(slave10PageSize) && slave10PageSize !== 0 ? slave10PageSize : commonConfig.pageSize,
      total: commonUtils.isEmptyArr(slave10Data) ? 0 : slave10Data.length,
      current: commonUtils.isEmptyObject(slave10Pagination) ? 1 : slave10Pagination.current,
      ...slave10Pagination,
      // showQuickJumper: true,
      hideOnSinglePage: true,
      size: isSmall ? "small" : "large",
      pageSizeOptions: commonConfig.pageSizeOptions,
      showSizeChanger: !isSmall,
      showQuickJumper: !isSmall,
    };

  /* 表1-commonView显示区域 */
  const ableConfigs = commonUtils.isNotEmptyObject(slaveConfig)
    ? slaveConfig.gdsconfigformslave.filter(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1)
    : [];
  /* 选中行 */
  let showAll = true; /* 只显示表格 */
  let bShowLeft = true; /* 表格显示在左侧 */
  let iColValueView = 12;
  let iColValueTable = 12;
  let slaveRow = {};
  if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
    const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId));
    if (iIndex > -1) {
      slaveRow = slaveData[iIndex];
    } else {
      slaveRow = slaveData[0];
    }
  } else if (commonUtils.isNotEmptyArr(slaveData)) {
    slaveRow = slaveData[0];
  }
  if (commonUtils.isNotEmptyObject(slaveConfig) && commonUtils.isNotEmptyArr(slaveConfig.gdsconfigformslave)) {
    const iIndexArea = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName !== "" && item.sControlName.includes("bShow"));
    if (iIndexArea > -1) {
      showAll = false;
    }
    if (commonUtils.isNotEmptyObject(slaveConfig) && commonUtils.isNotEmptyArr(slaveConfig.gdsconfigformslave)) {
      const iShowLeft = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === "bShowLeft" && item.bVisible);
      const iShowRight = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === "bShowRight" && item.bVisible);
      if (iShowLeft > -1) {
        bShowLeft = true;
        iColValueTable = slaveConfig.gdsconfigformslave[iShowLeft].iColValue;
      } else if (iShowRight > -1) {
        bShowLeft = false;
        iColValueTable = slaveConfig.gdsconfigformslave[iShowRight].iColValue;
      }
    }
  }
  iColValueView = commonUtils.isNotEmptyNumber(iColValueTable) ? 24 - iColValueTable : 12;
  const iShowOrder = bShowLeft ? 1 : 100;

  /* 表2-commonView显示区域 */
  const ableConfigs0 = commonUtils.isNotEmptyObject(slave0Config)
    ? slave0Config.gdsconfigformslave.filter(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1)
    : [];
  let showAll0 = true; /* 只显示表格 */
  let bShowLeft0 = true; /* 表格显示在左侧 */
  let iColValueView0 = 12;
  let iColValueTable0 = 12;
  let slave0Row = {};
  if (commonUtils.isNotEmptyArr(slave0SelectedRowKeys)) {
    const iIndex = slave0Data.findIndex(item => slave0SelectedRowKeys.includes(item.sId));
    if (iIndex > -1) {
      slave0Row = slave0Data[iIndex];
    } else {
      slave0Row = slave0Data[0];
    }
  } else if (commonUtils.isNotEmptyArr(slave0Data)) {
    slave0Row = slave0Data[0];
  }
  if (commonUtils.isNotEmptyObject(slave0Config) && commonUtils.isNotEmptyArr(slave0Config.gdsconfigformslave)) {
    const iIndexArea = slave0Config.gdsconfigformslave.findIndex(item => item.sControlName !== "" && item.sControlName.includes("bShow"));
    if (iIndexArea > -1) {
      showAll0 = false;
    }
    if (commonUtils.isNotEmptyObject(slave0Config) && commonUtils.isNotEmptyArr(slave0Config.gdsconfigformslave)) {
      const iShowLeft0 = slave0Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowLeft" && item.bVisible);
      const iShowRight0 = slave0Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowRight" && item.bVisible);
      if (iShowLeft0 > -1) {
        bShowLeft0 = true;
        iColValueTable0 = slave0Config.gdsconfigformslave[iShowLeft0].iColValue;
      } else if (iShowRight0 > -1) {
        bShowLeft0 = false;
        iColValueTable0 = slave0Config.gdsconfigformslave[iShowRight0].iColValue;
      }
    }
  }
  iColValueView0 = commonUtils.isNotEmptyNumber(iColValueTable0) ? 24 - iColValueTable0 : 12;
  const iShowOrder0 = bShowLeft0 ? 1 : 100;

  /* 表3-commonView显示区域 */
  const ableConfigs1 = commonUtils.isNotEmptyObject(slave1Config)
    ? slave1Config.gdsconfigformslave.filter(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1)
    : [];
  let showAll1 = true; /* 只显示表格 */
  let bShowLeft1 = true; /* 表格显示在左侧 */
  let iColValueView1 = 12;
  let iColValueTable1 = 12;
  let slave1Row = {};
  if (commonUtils.isNotEmptyArr(slave1SelectedRowKeys)) {
    const iIndex = slave1Data.findIndex(item => slave1SelectedRowKeys.includes(item.sId));
    if (iIndex > -1) {
      slave1Row = slave1Data[iIndex];
    } else {
      slave1Row = slave1Data[0];
    }
  } else if (commonUtils.isNotEmptyArr(slave1Data)) {
    slave1Row = slave1Data[0];
  }
  if (commonUtils.isNotEmptyObject(slave1Config) && commonUtils.isNotEmptyArr(slave1Config.gdsconfigformslave)) {
    const iIndexArea = slave1Config.gdsconfigformslave.findIndex(item => item.sControlName !== "" && item.sControlName.includes("bShow"));
    if (iIndexArea > -1) {
      showAll1 = false;
    }
    if (commonUtils.isNotEmptyObject(slave1Config) && commonUtils.isNotEmptyArr(slave1Config.gdsconfigformslave)) {
      const iShowLeft1 = slave1Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowLeft" && item.bVisible);
      const iShowRight1 = slave1Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowRight" && item.bVisible);
      if (iShowLeft1 > -1) {
        bShowLeft1 = true;
        iColValueTable1 = slave1Config.gdsconfigformslave[iShowLeft1].iColValue;
      } else if (iShowRight1 > -1) {
        bShowLeft1 = false;
        iColValueTable1 = slave1Config.gdsconfigformslave[iShowRight1].iColValue;
      }
    }
  }
  iColValueView1 = commonUtils.isNotEmptyNumber(iColValueTable1) ? 24 - iColValueTable1 : 12;
  const iShowOrder1 = bShowLeft1 ? 1 : 100;

  /* 表4-commonView显示区域 */
  const ableConfigs2 = commonUtils.isNotEmptyObject(slave2Config)
    ? slave2Config.gdsconfigformslave.filter(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1)
    : [];
  let showAll2 = true; /* 只显示表格 */
  let bShowLeft2 = true; /* 表格显示在左侧 */
  let iColValueView2 = 12;
  let iColValueTable2 = 12;
  let slave2Row = {};
  if (commonUtils.isNotEmptyArr(slave2SelectedRowKeys)) {
    const iIndex = slave2Data.findIndex(item => slave2SelectedRowKeys.includes(item.sId));
    if (iIndex > -1) {
      slave2Row = slave2Data[iIndex];
    } else {
      slave2Row = slave2Data[0];
    }
  } else if (commonUtils.isNotEmptyArr(slave2Data)) {
    slave2Row = slave2Data[0];
  }
  if (commonUtils.isNotEmptyObject(slave2Config) && commonUtils.isNotEmptyArr(slave2Config.gdsconfigformslave)) {
    const iIndexArea = slave2Config.gdsconfigformslave.findIndex(item => item.sControlName !== "" && item.sControlName.includes("bShow"));
    if (iIndexArea > -1) {
      showAll2 = false;
    }
    if (commonUtils.isNotEmptyObject(slave2Config) && commonUtils.isNotEmptyArr(slave2Config.gdsconfigformslave)) {
      const iShowLeft2 = slave2Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowLeft" && item.bVisible);
      const iShowRight2 = slave2Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowRight" && item.bVisible);
      if (iShowLeft2 > -1) {
        bShowLeft2 = true;
        iColValueTable2 = slave2Config.gdsconfigformslave[iShowLeft2].iColValue;
      } else if (iShowRight2 > -1) {
        bShowLeft2 = false;
        iColValueTable2 = slave2Config.gdsconfigformslave[iShowRight2].iColValue;
      }
    }
  }
  iColValueView2 = commonUtils.isNotEmptyNumber(iColValueTable2) ? 24 - iColValueTable2 : 12;
  if (slave2Config && slave2Config.sChinese === "上批对比") {
    iColValueView2 = iColValueView1;
  }
  const iShowOrder2 = bShowLeft2 ? 1 : 100;

  /* 表5-commonView显示区域 */
  const ableConfigs3 = commonUtils.isNotEmptyObject(slave3Config)
    ? slave3Config.gdsconfigformslave.filter(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1)
    : [];
  let showAll3 = true; /* 只显示表格 */
  let bShowLeft3 = true; /* 表格显示在左侧 */
  let iColValueView3 = 12;
  let iColValueTable3 = 12;
  let slave3Row = {};
  if (commonUtils.isNotEmptyArr(slave3SelectedRowKeys)) {
    const iIndex = slave3Data.findIndex(item => slave3SelectedRowKeys.includes(item.sId));
    if (iIndex > -1) {
      slave3Row = slave3Data[iIndex];
    } else {
      slave3Row = slave3Data[0];
    }
  } else if (commonUtils.isNotEmptyArr(slave3Data)) {
    slave3Row = slave3Data[0];
  }
  if (commonUtils.isNotEmptyObject(slave3Config) && commonUtils.isNotEmptyArr(slave3Config.gdsconfigformslave)) {
    const iIndexArea = slave3Config.gdsconfigformslave.findIndex(item => item.sControlName !== "" && item.sControlName.includes("bShow"));
    if (iIndexArea > -1) {
      showAll3 = false;
    }
    if (commonUtils.isNotEmptyObject(slave3Config) && commonUtils.isNotEmptyArr(slave3Config.gdsconfigformslave)) {
      const iShowLeft3 = slave3Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowLeft" && item.bVisible);
      const iShowRight3 = slave3Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowRight" && item.bVisible);
      if (iShowLeft3 > -1) {
        bShowLeft3 = true;
        iColValueTable3 = slave3Config.gdsconfigformslave[iShowLeft3].iColValue;
      } else if (iShowRight3 > -1) {
        bShowLeft3 = false;
        iColValueTable3 = slave3Config.gdsconfigformslave[iShowRight3].iColValue;
      }
    }
  }
  iColValueView3 = commonUtils.isNotEmptyNumber(iColValueTable3) ? 24 - iColValueTable3 : 12;
  const iShowOrder3 = bShowLeft3 ? 1 : 100;

  /* 表6-commonView显示区域 */
  const ableConfigs4 = commonUtils.isNotEmptyObject(slave4Config)
    ? slave4Config.gdsconfigformslave.filter(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1)
    : [];
  let showAll4 = true; /* 只显示表格 */
  let bShowLeft4 = true; /* 表格显示在左侧 */
  let iColValueView4 = 12;
  let iColValueTable4 = 12;
  let slave4Row = {};
  if (commonUtils.isNotEmptyArr(slave4SelectedRowKeys)) {
    const iIndex = slave4Data.findIndex(item => slave4SelectedRowKeys.includes(item.sId));
    if (iIndex > -1) {
      slave4Row = slave4Data[iIndex];
    } else {
      slave4Row = slave4Data[0];
    }
  } else if (commonUtils.isNotEmptyArr(slave4Data)) {
    slave4Row = slave4Data[0];
  }
  if (commonUtils.isNotEmptyObject(slave4Config) && commonUtils.isNotEmptyArr(slave4Config.gdsconfigformslave)) {
    const iIndexArea = slave4Config.gdsconfigformslave.findIndex(item => item.sControlName !== "" && item.sControlName.includes("bShow"));
    if (iIndexArea > -1) {
      showAll4 = false;
    }
    if (commonUtils.isNotEmptyObject(slave4Config) && commonUtils.isNotEmptyArr(slave4Config.gdsconfigformslave)) {
      const iShowLeft4 = slave4Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowLeft" && item.bVisible);
      const iShowRight4 = slave4Config.gdsconfigformslave.findIndex(item => item.sControlName === "bShowRight" && item.bVisible);
      if (iShowLeft4 > -1) {
        bShowLeft4 = true;
        iColValueTable4 = slave4Config.gdsconfigformslave[iShowLeft4].iColValue;
      } else if (iShowRight4 > -1) {
        bShowLeft4 = false;
        iColValueTable4 = slave4Config.gdsconfigformslave[iShowRight4].iColValue;
      }
    }
  }
  iColValueView4 = commonUtils.isNotEmptyNumber(iColValueTable4) ? 24 - iColValueTable4 : 12;
  const iShowOrder4 = bShowLeft4 ? 1 : 100;

  const listType = "commonMultiList";
  const bCheck = commonUtils.isNotEmptyObject(slaveConfig) && slaveConfig.sTbName === "sysbillcheckresult" ? true : false;

  const bSingleTree = commonUtils.isNotEmptyObject(slaveConfig) && slaveConfig.sTableType === "single"; /* 单表数据 */
  const bShowTreeAddChild =
    commonUtils.isNotEmptyObject(slaveConfig) &&
      commonUtils.isNotEmptyArr(slaveConfig.gdsconfigformslave.filter(item => item.sControlName.includes("BtnAddChildNode") && item.bVisible))
      ? true
      : false; /* 是否是树形的单据 */

  const bSlaveSort = slaveConfig?.gdsconfigformslave?.find(item => item.sControlName === "handleSort")?.bVisible || false;

  const slaveTableProps = {
    ...commonBusiness.getTableTypes("slave", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      bShowTreeAddChild: bShowTreeAddChild,
      pagination,
      onChange: props.onTitleChange.bind(this, "slave"),
      dragTableHeight: 344
    },
    noVlistTable: bPagination,
    onDelRow: props.onDelRow,
    data: bSingleTree && commonUtils.isNotEmptyArr(slaveData) ? commonUtils.genTreeByArr(slaveData, "sId", "sFatherSlaveId") : slaveData,
    onTreeAddChild: props.onDataRowAddChild,
    customConfig: props.customConfig,
    isDragAndDrop: bSlaveSort,
    onMoveRow: props.onMoveRow,
    isSettingFunctions: true
  };

  const bCheck0 = commonUtils.isNotEmptyObject(slave0Config) && slave0Config.sTbName === "sysbillcheckresult" ? true : false;
  const slave0TableProps = {
    ...commonBusiness.getTableTypes("slave0", props),
    tableBelone: sModelsType === listType || bCheck ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination0,
      onChange: props.onTitleChange.bind(this, "slave0"),
    },
  };
  const bCheck1 = commonUtils.isNotEmptyObject(slave1Config) && slave1Config.sTbName === "sysbillcheckresult" ? true : false;
  const slave1TableProps = {
    ...commonBusiness.getTableTypes("slave1", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination1,
      onChange: props.onTitleChange.bind(this, "slave1"),
    },
  };
  const bCheck2 = commonUtils.isNotEmptyObject(slave2Config) && slave2Config.sTbName === "sysbillcheckresult" ? true : false;
  const slave2TableProps = {
    ...commonBusiness.getTableTypes("slave2", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination2,
      onChange: props.onTitleChange.bind(this, "slave2"),
    },
  };
  const slave3TableProps = {
    ...commonBusiness.getTableTypes("slave3", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination3,
      onChange: props.onTitleChange.bind(this, "slave3"),
    },
  };
  const slave4TableProps = {
    ...commonBusiness.getTableTypes("slave4", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination4,
      onChange: props.onTitleChange.bind(this, "slave4"),
    },
  };
  const slave5TableProps = {
    ...commonBusiness.getTableTypes("slave5", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination5,
      onChange: props.onTitleChange.bind(this, "slave5"),
    },
  };

  const slave6TableProps = {
    ...commonBusiness.getTableTypes("slave6", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination6,
      onChange: props.onTitleChange.bind(this, "slave6"),
    },
  };

  const slave7TableProps = {
    ...commonBusiness.getTableTypes("slave7", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination7,
      onChange: props.onTitleChange.bind(this, "slave7"),
    },
  };

  const slave8TableProps = {
    ...commonBusiness.getTableTypes("slave8", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination8,
      onChange: props.onTitleChange.bind(this, "slave8"),
    },
  };

  const slave9TableProps = {
    ...commonBusiness.getTableTypes("slave9", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination9,
      onChange: props.onTitleChange.bind(this, "slave9"),
    },
  };

  const slave10TableProps = {
    ...commonBusiness.getTableTypes("slave10", props),
    tableBelone: sModelsType === listType ? "list" : "" /*  新需求：做个1带N的只可查看不可编辑的表格，模块类型名：commonMultiList */,
    tableProps: {
      setAdd,
      setCopy,
      setCopyAll,
      setDelete,
      pagination: pagination10,
      onChange: props.onTitleChange.bind(this, "slave10"),
    },
  };

  /* 从表view */
  const slaveViewProps = {
    ...props,
    viewConfigs: ableConfigs,
    tableConfig: slaveConfig,
    iColValueView,
    viewRow: slaveRow,
    tableName: "slave",
    handleFieldDoubleClick: props.handleFieldDoubleClick,
  };

  /* 第二张表 */
  const slave0ViewProps = {
    ...props,
    viewConfigs: ableConfigs0,
    tableConfig: slave0Config,
    iColValueView: iColValueView0,
    viewRow: slave0Row,
    tableName: "slave0",
  };
  /*  */
  const slave1ViewProps = {
    ...props,
    viewConfigs: ableConfigs1,
    tableConfig: slave1Config,
    iColValueView: iColValueView1,
    viewRow: slave1Row,
    tableName: "slave1",
  };
  /* 从表view */
  const slave2ViewProps = {
    ...props,
    viewConfigs: ableConfigs2,
    tableConfig: slave2Config,
    iColValueView: iColValueView2,
    viewRow: slave2Row,
    tableName: "slave2",
  };

  /* pack表view */
  const slave3ViewProps = {
    ...props,
    viewConfigs: ableConfigs3,
    tableConfig: slave3Config,
    iColValueView: iColValueView3,
    viewRow: slave3Row,
    tableName: "slave3",
  };

  const slave4ViewProps = {
    ...props,
    viewConfigs: ableConfigs4,
    tableConfig: slave4Config,
    iColValueView: iColValueView4,
    viewRow: slave4Row,
    tableName: "slave4",
  };

  /*   获取AssignmentField中的props   */
  const assignmentFieldProps = {
    visibleAssignmentField: props.visibleAssignmentField /*   是否展示   */,
    sAssignFieldData: props.sAssignFieldData /*   数据   */,
    sAssignFieldColumn: props.sAssignFieldColumn /* 表头   */,
    selectedRowKeys: props.selectedRowKeys /* 选中   */,
    sAssignFieldSelectedRowKeys: props.selectedRowKeys /* 选中   */,
    onSaveState: props.onSaveState /*   保存数据方法   */,
    onDataRowAdd: props.handleAddRow.bind(this, "sAssignField"),
    onDataRowDel: props.handleDelRow.bind(this, "sAssignField"),
    onDataRowCopy: props.handleCopyRow.bind(this, "sAssignField"),
    // onRowClick: props.handleRowClick.bind(this, 'sAssignField'),
    config: props.config,
    app: props.app,
    enabled: props.enabled,
    onDataChange: props.onChange,
    onGetsAssignField: props.onGetsAssignField,
    handleFieldDoubleClick: props.handleFieldDoubleClick,
  };

  // const slaveInfo = commonFunc.showMessage(app.commonConst, 'MainContent'); /* 从表信息 */
  // const materialsInfo = commonFunc.showMessage(app.commonConst, 'zMaterials'); /* 材料表 */
  // const checkInfo = commonFunc.showMessage(app.commonConst, 'zCheck'); /* 审核表 */
  // const slaveInfo0 = commonFunc.showMessage(app.commonConst, 'zSlaveInfo0'); /* 工序表 */
  // const slaveInfo1 = commonFunc.showMessage(app.commonConst, 'zSlaveInfo1'); /* 表二 */
  // const slaveInfo2 = commonFunc.showMessage(app.commonConst, 'zSlaveInfo2'); /* 表三 */
  let slaveInfo = "";
  let materialsInfo = "";
  let checkInfo = "";
  let slaveInfo0 = "";
  let slaveInfo1 = "";
  let slaveInfo2 = "";
  let slaveInfo3 = "";
  let slaveInfo4 = "";
  let slaveInfo5 = "";
  let slaveInfo6 = "";
  let slaveInfo7 = "";
  let slaveInfo8 = "";

  let defaultTab = "";

  if (commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave)) {
    slaveInfo = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "MainContent"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "MainContent")[0].showName
      : commonFunc.showMessage(app.commonConst, "MainContent"); /* 从表信息 */
    materialsInfo = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zMaterials"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zMaterials")[0].showName
      : commonFunc.showMessage(app.commonConst, "zMaterials"); /* 表一 */
    checkInfo = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zCheck"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zCheck")[0].showName
      : commonFunc.showMessage(app.commonConst, "zCheck"); /* 表二 */
    slaveInfo0 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo0"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo0")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo0"); /* 表三 */
    slaveInfo1 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo1"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo1")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo1"); /* 表四 */
    slaveInfo2 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo2"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo2")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo2"); /* 表五 */
    slaveInfo3 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo3"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo3")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo3"); /* 表六 */
    slaveInfo4 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo4"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo4")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo4"); /* 表七 */
    slaveInfo5 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo5"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo5")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo5"); /* 表八 */
    slaveInfo6 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo6"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo6")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo6"); /* 表九 */
    slaveInfo7 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo7"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo7")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo7"); /* 表十 */
    slaveInfo8 = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo8"))
      ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === "zSlaveInfo8")[0].showName
      : commonFunc.showMessage(app.commonConst, "zSlaveInfo8"); /* 表十一 */

    // 获取默认展开tab
    const defaultTabConfig = masterConfig.gdsconfigformslave.find(
      item =>
        ["MainContent", "zMaterials", "zCheck", ...new Array(10).fill("").map((_, index) => `zSlaveInfo${index}`)].includes(item.sControlName) &&
        item.sDefault
    );
    if (defaultTabConfig) {
      if (defaultTabConfig.sControlName === "MainContent") {
        defaultTab = "10";
      } else if (defaultTabConfig.sControlName === "zMaterials") {
        defaultTab = "20";
      } else if (defaultTabConfig.sControlName === "zCheck") {
        defaultTab = "30";
      } else {
        try {
          defaultTab = `${Number(defaultTabConfig.sControlName.split("zSlaveInfo")[1]) * 10 + 40}`;
        } catch (error) { }
      }
    }
    if (defaultTab && props.currentTab === "") {
      props.onTabChange(defaultTab);
    }
  }

  let productProcessInfoType = {};
  let productProcessInfoConfig = {};
  let processCardSearchResult = commonFunc.showMessage(app.commonConst, "processCardSearchResult"); /* 复制从工艺卡查询结果 */
  if (commonUtils.isNotEmptyObject(props.productProcessInfoChooseData)) {
    const productProcessInfoCopyFromKey = props.productProcessInfoCopyFromKey;
    const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === productProcessInfoCopyFromKey);
    if (iIndex > -1) {
      productProcessInfoConfig = masterConfig.gdsconfigformslave[iIndex];
      processCardSearchResult =
        commonUtils.isNotEmptyObject(productProcessInfoConfig) && commonUtils.isNotEmptyObject(productProcessInfoConfig.sActiveName)
          ? productProcessInfoConfig.sActiveName
          : processCardSearchResult;
    }
    productProcessInfoType = {
      app: {
        ...props.app,
        currentPane: {
          name: "productProcessInfo",
          config: productProcessInfoConfig,
          conditonValues: props.getSqlCondition(productProcessInfoConfig),
          title: props.productProcessInfoChooseData.sMenuName,
          route: props.productProcessInfoChooseData.sName,
          formId: props.productProcessInfoChooseData.sId,
          key: props.sModelsId + props.productProcessInfoChooseData.sId,
          sModelsType: props.productProcessInfoChooseData.sModelType,
          select: props.onSelect,
          selectCancel: props.onSelectCancel,
        },
      },
      dispatch: props.dispatch,
      content: props.content,
      id: new Date().getTime().toString(),
    };
  }

  let isSysSetting = false;
  if (
    props &&
    props.app &&
    props.app.currentPane &&
    props.app.currentPane.title &&
    props.app.currentPane &&
    props.app.currentPane.title === "功能模块界面设置单据"
  ) {
    isSysSetting = true;
  }
  const templateProps = props.formData.filter(item => item.sGrd === "importTemplate")[0];
  let gdsconfigformmasterId = "";
  if (templateProps !== undefined) {
    gdsconfigformmasterId = templateProps.sId;
  }
  const sNotEmpty = "sParentId,sProductId";
  let uploadUrl = `${commonConfig.server_host}import/checkExcel?sModelsId=${sModelsId}&gdsconfigformmasterId=${gdsconfigformmasterId}&sNotEmpty=${sNotEmpty}&token=${app.token}`;
  /* 送货单需要传客户id  */
  if (commonUtils.isNotEmptyObject(sModelsType) && sModelsType === "sales/salesSgoods" && commonUtils.isNotEmptyObject(masterData)) {
    const sCustomerId = masterData.sCustomerId;
    if (commonUtils.isNotEmptyObject(sCustomerId)) {
      uploadUrl = `${commonConfig.server_host}import/checkExcel?sModelsId=${sModelsId}&gdsconfigformmasterId=${gdsconfigformmasterId}&sNotEmpty=${sNotEmpty}&sCustomerId=${sCustomerId}&token=${app.token}`;
    }
  }
  const outProps = {
    action: uploadUrl,
    onChange: props.onUploadChangeFile /* 文件上传 */,
    accept: "xls/*",
    showUploadList: false,
    beforeUpload: () => {
      /* 查看时不可上传 */
      if (!props.enabled) return false;
    },
  };

  const uploadPropsSales = props.onUploadPropsSales();
  const BtnimportData = commonFunc.showMessage(app.commonConst, "importData"); /* 导入数据 */
  const ImportData = commonUtils.isNotEmptyObject(masterConfig)
    ? masterConfig.gdsconfigformslave.filter(item => item.sControlName.includes("ImportData") && item.bVisible)
    : ""; /* 后台是否配置导入 */

  /* 显示导入报错信息 */
  let importExcelProps = {};
  let importExcelTitle = commonUtils.isNotEmptyObject(commonFunc.showMessage(app.commonConst, "processCardSearchResult"))
    ? commonFunc.showMessage(app.commonConst, "importErrorMsg")
    : "导入校验信息"; /* 导入校验信息 */
  if (commonUtils.isNotEmptyObject(props)) {
    importExcelProps = {
      ...commonBusiness.getTableTypes("import", props),
      tableProps: {
        pagination: null,
        AutoTableHeight: 400,
      },
      // data: bSingleTree && commonUtils.isNotEmptyArr(slaveData) ?  commonUtils.genTreeByArr(slaveData, 'sId', 'sFatherSlaveId') : slaveData,
      onDelRow: props.onDelRow,
      onKeyDown: props.onKeyDown,
      onContextMenu: props.onContextMenu,
      masterData: props.masterData, // 为通用弹窗提供主表数据(孟总需求：产品新增需要带上客户信息)
      tableBelone: "list",
    };
  }
  const sProcessParams = commonFunc.showMessage(app.commonConst, "sProcessParams"); /* 选择工艺参数标题 */

  const sProcessParamsNew = commonUtils.isNotEmptyObject(commonFunc.showMessage(app.commonConst, "sProcessParamsNew"))
    ? commonFunc.showMessage(app.commonConst, "sProcessParamsNew")
    : "选择新的工艺参数"; /* 选择工艺参数标题 */
  /* 新方式的工艺参数 */
  const sParamProps = {
    ...commonBusiness.getTableTypes("sParam", props),
    tableProps: {
      rowKey: "sId",
      // pagination,
      onChange: props.onTitleChange,
      sModelsType,
      AutoTableHeight: 350,
    },
    bRowClick: true,
    enabled: false,
  };

  const sParamNewProps = {
    ...commonBusiness.getTableTypes("sParamNew", props),
    tableProps: {
      rowKey: "sId",
      // pagination,
      onChange: props.onTitleChange,
      sModelsType,
      AutoTableHeight: 350,
    },
    bRowClick: true,
  };
  //
  // const menu = (
  //   <Menu onClick={props.handleMenuClick}>
  //     <Menu.Item key="formMaster"><a href={props.downloadUrl}>生成主表当前数据(完全)</a></Menu.Item>
  //     <Menu.Item key="fromMasterSlave"><a href={props.downloadUrl}>生成整表当前数据(完全)</a></Menu.Item>
  //     <Menu.Item key="formSlave"><a href={props.downloadUrl}>生成从表当前数据</a></Menu.Item>
  //   </Menu>
  // );
  /* 取 masterConfig中有多少个Tab页签配置 */
  const masterShowConfig = commonUtils.isNotEmptyObject(masterConfigOld)
    ? masterConfigOld.gdsconfigformslave.filter(item => item.bVisible && item.sName !== "")
    : [];
  const diliverConfigTypeArr = []; /* 有Tab的配置 */
  masterShowConfig.forEach(child => {
    if (child.sControlName.indexOf("_") > -1) {
      const tableType = child.sControlName.split("_")[1];
      const isIndex = diliverConfigTypeArr.findIndex(item => item === tableType);
      if (isIndex === -1) {
        diliverConfigTypeArr.push(tableType);
      }
    }
  });

  /* 主表页签+表格页签排序规则，表格页签以10位一个间隔，10,20,30,40,50,60，如果想进行排序 则页签顺序介入其间即可 */
  /* 找到各个主表页签Tab所处的区间 */
  let diliverConfigTypeArr1 = [];
  let diliverConfigTypeArr2 = [];
  let diliverConfigTypeArr3 = [];
  let diliverConfigTypeArr4 = [];
  let diliverConfigTypeArr5 = [];
  let diliverConfigTypeArr6 = [];
  for (const item of diliverConfigTypeArr) {
    let numStr = item.replace(/[^\d]/g, "").trim();
    let num = Number(numStr);
    if (!commonUtils.isEmpty(num)) {
      if (num < 10) {
        /* 0- 10 */
        diliverConfigTypeArr1.push(item);
      } else if (num < 20) {
        /* 10- 20 */
        diliverConfigTypeArr2.push(item);
      } else if (num < 30) {
        /* 20- 30 */
        diliverConfigTypeArr3.push(item);
      } else if (num < 40) {
        /* 30- 40 */
        diliverConfigTypeArr4.push(item);
      } else if (num < 50) {
        /* 40- 50 */
        diliverConfigTypeArr5.push(item);
      } else if (num < 60) {
        /* 50- 60 */
        diliverConfigTypeArr6.push(item);
      }
    }
  }

  const tabNumList = [
    ...diliverConfigTypeArr1,
    onlySlave ? "10" : "",
    ...diliverConfigTypeArr2,
    onlySlave0 ? "20" : "",
    ...diliverConfigTypeArr3,
    onlySlave1 ? "30" : "",
    ...diliverConfigTypeArr4,
    onlyslave2 ? "40" : "",
    ...diliverConfigTypeArr5,
    onlyslave3 ? "50" : "",
    ...diliverConfigTypeArr6,
    onlyslave4 ? "60" : "",
    onlyslave5 ? "70" : "",
    onlyslave6 ? "80" : "",
    onlyslave7 ? "90" : "",
    onlyslave8 ? "100" : "",
    onlyslave9 ? "110" : "",
    onlyslave10 ? "150" : "",
  ].filter(item => item);
  const { enabled } = props.masterData || {};
  if (enabled) {
    // 只有修改状态才会根据数据改变tab页
    const tabNumListOld = props.onGetTabNumList(tabNumList);
    if (tabNumListOld && JSON.stringify(tabNumListOld) !== JSON.stringify(tabNumList)) {
      const addData = tabNumList.find(item => tabNumListOld.indexOf(item) === -1);
      props.onSetTabNumList(tabNumList);
      if (addData) {
        const activeKey = addData.replace(/[^\d]/g, "").trim();
        props.onTabChange(activeKey);
      } else if (!tabNumList.some(item => props.currentTab === item.replace(/[^\d]/g, "").trim())) {
        const activeKey = tabNumList[0].replace(/[^\d]/g, "").trim();
        props.onTabChange(activeKey);
      }
    }
  }

  if (!defaultTab && props.currentTab === "" && commonUtils.isNotEmptyArr(tabNumList)) {
    const activeKey = tabNumList[0].replace(/[^\d]/g, "").trim();
    props.onSetTabNumList(tabNumList);
    props.onTabChange(activeKey);
  }

  // 组件展示是否单独Tab页
  let bControlSeparateTab = false;
  let bControlSeparateTab0 = false;
  let bControlSeparateTab1 = false;
  let bControlSeparateTab2 = false;
  let bControlSeparateTab3 = false;
  let bControlSeparateTab4 = false;
  let bControlSeparateTab5 = false;
  let bControlSeparateTab6 = false;
  let bControlSeparateTab7 = false;
  let bControlSeparateTab8 = false;
  let bControlSeparateTab9 = false;
  let bControlSeparateTab10 = false;

  let separateTabName,
    separateTabName0,
    separateTabName1,
    separateTabName2,
    separateTabName3,
    separateTabName4,
    separateTabName5,
    separateTabName6,
    separateTabName7,
    separateTabName8,
    separateTabName9,
    separateTabName10;

  if (commonUtils.isNotEmptyObject(slaveConfig) && commonUtils.isNotEmptyArr(slaveConfig.gdsconfigformslave)) {
    const iIndex = slaveConfig.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slaveConfig.gdsconfigformslave[iIndex];
      bControlSeparateTab = true;
      separateTabName = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave0Config) && commonUtils.isNotEmptyArr(slave0Config.gdsconfigformslave)) {
    const iIndex = slave0Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave0Config.gdsconfigformslave[iIndex];
      bControlSeparateTab0 = true;
      separateTabName0 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave1Config) && commonUtils.isNotEmptyArr(slave1Config.gdsconfigformslave)) {
    const iIndex = slave1Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave1Config.gdsconfigformslave[iIndex];
      bControlSeparateTab1 = true;
      separateTabName1 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave2Config) && commonUtils.isNotEmptyArr(slave2Config.gdsconfigformslave)) {
    const iIndex = slave2Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave2Config.gdsconfigformslave[iIndex];
      bControlSeparateTab2 = true;
      separateTabName2 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave3Config) && commonUtils.isNotEmptyArr(slave3Config.gdsconfigformslave)) {
    const iIndex = slave3Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave3Config.gdsconfigformslave[iIndex];
      bControlSeparateTab3 = true;
      separateTabName3 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave4Config) && commonUtils.isNotEmptyArr(slave4Config.gdsconfigformslave)) {
    const iIndex = slave4Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave4Config.gdsconfigformslave[iIndex];
      bControlSeparateTab4 = true;
      separateTabName4 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave5Config) && commonUtils.isNotEmptyArr(slave5Config.gdsconfigformslave)) {
    const iIndex = slave5Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave5Config.gdsconfigformslave[iIndex];
      bControlSeparateTab5 = true;
      separateTabName5 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave6Config) && commonUtils.isNotEmptyArr(slave6Config.gdsconfigformslave)) {
    const iIndex = slave6Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave6Config.gdsconfigformslave[iIndex];
      bControlSeparateTab6 = true;
      separateTabName6 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave7Config) && commonUtils.isNotEmptyArr(slave7Config.gdsconfigformslave)) {
    const iIndex = slave7Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave7Config.gdsconfigformslave[iIndex];
      bControlSeparateTab7 = true;
      separateTabName7 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave8Config) && commonUtils.isNotEmptyArr(slave8Config.gdsconfigformslave)) {
    const iIndex = slave8Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave8Config.gdsconfigformslave[iIndex];
      bControlSeparateTab8 = true;
      separateTabName8 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave9Config) && commonUtils.isNotEmptyArr(slave9Config.gdsconfigformslave)) {
    const iIndex = slave9Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave9Config.gdsconfigformslave[iIndex];
      bControlSeparateTab9 = true;
      separateTabName9 = separateTabConfig.showName;
    }
  }
  if (commonUtils.isNotEmptyObject(slave10Config) && commonUtils.isNotEmptyArr(slave10Config.gdsconfigformslave)) {
    const iIndex = slave10Config.gdsconfigformslave.findIndex(item => item.sControlName === "bControlSeparateTab");
    if (iIndex !== -1) {
      const separateTabConfig = slave10Config.gdsconfigformslave[iIndex];
      bControlSeparateTab10 = true;
      separateTabName10 = separateTabConfig.showName;
    }
  }

  const flexRowStyle = bFlow ? { display: "flex", flexDirection: "row" } : {};
  const flexContentStyle = bFlow ? { width: "75%" } : {};
  // 设置初始宽度
  const [containerWidth, setContainerWidth] = useState(410);
  const containerRef = useRef(null);
  const dividerRef = useRef(null);
  const [isDragging, setIsDragging] = useState(false);
  const [startX, setStartX] = useState(0);
  const [initialWidth, setInitialWidth] = useState(0);
  const handleMouseDown = e => {
    setIsDragging(true);
    setStartX(e.clientX);
    if (containerRef.current) {
      setInitialWidth(containerRef.current.offsetWidth);
    }
  };
  const handleMouseMove = e => {
    if (!isDragging) return;
    // 当前鼠标移动位置
    const currentX = e.clientX;
    // 移动距离
    const diffX = currentX - startX;
    const newWidth = initialWidth + diffX;
    // 限制宽度在一定范围内最小宽度为200
    if (newWidth < 200) {
      setContainerWidth(200);
      return;
    }
    setContainerWidth(newWidth);
  };
  const handleMouseUp = () => {
    setIsDragging(false);
    document.removeEventListener("mousemove", handleMouseMove);
    document.removeEventListener("mouseup", handleMouseUp);
  };

  useEffect(() => {
    document.addEventListener("mousemove", handleMouseMove);
    document.addEventListener("mouseup", handleMouseUp);
    return () => {
      document.removeEventListener("mousemove", handleMouseMove);
      document.removeEventListener("mouseup", handleMouseUp);
    };
  }, [isDragging]);
  return (
    <Form>
      <Layout>
        <Header className={styles.header}>
          <div className="billToolBar">
            <Toolbar
              {...props}
              className="billBtnGroup btnGroupHasImport"
              style={{ backgroundColor: "#646464", color: "rgb(255,255,255)" }}
              pageFrom="billList"
            />
          </div>
          {commonUtils.isNotEmptyArr(ImportData) ? (
            <div id="btnImportData" className={`importData ${props.enabled}`}>
              <Upload {...outProps}>
                <UploadOutlined />
                {BtnimportData}
                <Button {...uploadPropsSales} />
              </Upload>
            </div>
          ) : (
            ""
          )}
        </Header>

        <Layout className={styles.clayout} style={flexRowStyle}>
          <Content className={styles.content} style={flexContentStyle}>
            <div
              style={{
                border: "1px solid #c2c3c5",
                margin: "0 8px",
                marginTop: 8,
                backgroundColor: "#fff",
              }}
            >
              <div className="bill-search-group" style={{ display: 'flex' }}>
                <div style={{ flex: 1 }}>
                  <CommonView {...props} />
                </div>
                {
                  ["contacts"].includes(props.sModelsType) && (
                    <img
                      style={{ width: 202 / 1.336, height: 202, margin: '5px 5px 0 -40px' }}
                      src={`${commonConfig.file_host}file/download?savePathStr=${props.masterData?.sPicturePath}&sModelsId=100&token=${props.token}`}
                      onError={event => {
                        event.target.src = userImgs;
                      }}
                    />
                  )
                }
              </div>
            </div>
            {props.sModelsType === "element/workcalendar" ? (
              <div className={`${styles.bShow}`}>
                <div>
                  <Avatar src={props.imgSrc} />
                </div>
                <WorkCalendar {...props} />
              </div>
            ) : (
              <div
                id="slaveTabs"
                className={`${styles.bShow} commonNewBillContainer`}
                ref={ref => {
                  _this.slaveTabsRef = ref;
                }}
              >
                <div>
                  {props.imgSrc && <Avatar src={props.imgSrc} />}
                </div>
                <Tabs activeKey={props.currentTab} onChange={props.onTabChange} className={styles.slaveTabs} tabBarStyle={{ margin: "0 8px" }}>
                  {commonUtils.isNotEmptyArr(diliverConfigTypeArr1)
                    ? diliverConfigTypeArr1.map(item => {
                      // 匹配数字
                      // eslint-disable-next-line no-unused-vars
                      let num = item.replace(/[^\d]/g, "").trim();
                      let tabName = item.replace(/\d+/g, "");
                      /* 从主表配置 找到控件名=tabName,否则取他的showName */
                      const tableConfigArr = masterConfig?.gdsconfigformslave.filter(row => row.sControlName === item.trim());
                      if (commonUtils.isNotEmptyArr(tableConfigArr)) {
                        tabName = tableConfigArr[0].showName;
                      }
                      return (
                        <TabPane tab={tabName} key={num} className="xly-bill-list">
                          <div>
                            <CommonView
                              {...props}
                              // 使高度和从表高度一直
                              // isAutoHeight="ture"
                              tableConfigType={item}
                              tableConfigTypeArr={diliverConfigTypeArr}
                            />
                          </div>
                        </TabPane>
                      );
                    })
                    : ""}
                  {onlySlave ? (
                    <>
                      <TabPane tab={slaveInfo} className="xly-bill-list" key={10}>
                        <div className="TabPaneStyle">
                          {app.currentPane.title !== "功能模块界面设置单据" ? (
                            <Row gutter={[8, 0]}>
                              <Col span={showAll ? 24 : iColValueTable} order={iShowOrder}>
                                <StaticEditTable
                                  {...slaveTableProps}
                                  noVlist
                                  setOpterationColumn={props.sModelsType !== "cost/cosexpenseshare" && sModelsType !== listType && !bCheck ? "Y" : ""}
                                />
                              </Col>
                              {!bControlSeparateTab && <CommonViewTable {...slaveViewProps} />}
                            </Row>
                          ) : (
                            <div className="SetModelTable">
                              <div
                                style={{
                                  width: `${containerWidth}px`,
                                  marginRight: "10px",
                                  borderRight: "1px solid #e8e8e8",
                                  paddingRight: "4px",
                                  position: "relative",
                                  maxWidth: "100%",
                                }}
                                ref={containerRef}
                              >
                                <div
                                  ref={dividerRef}
                                  style={{
                                    position: "absolute",
                                    right: "-5px",
                                    top: "0",
                                    bottom: "0",
                                    width: "10px",
                                    cursor: "col-resize",
                                    background: "linear-gradient(to right, transparent, #e8e8e8, transparent)",
                                  }}
                                  onMouseDown={handleMouseDown}
                                />
                                <StaticEditTable
                                  {...slaveTableProps}
                                  noVlist
                                  setOpterationColumn={props.sModelsType !== "cost/cosexpenseshare" && sModelsType !== listType && !bCheck ? "Y" : ""}
                                />
                              </div>
                              {!bControlSeparateTab && <CommonViewTable {...slaveViewProps} style={{ flex: 1 }} />}
                            </div>
                          )}
                        </div>
                      </TabPane>
                      {bControlSeparateTab && (
                        <TabPane tab={separateTabName} className="xly-bill-list" key={11}>
                          <CommonViewTable {...slaveViewProps} iColValueView={24} />
                        </TabPane>
                      )}
                    </>
                  ) : (
                    ""
                  )}
                  {commonUtils.isNotEmptyArr(diliverConfigTypeArr2)
                    ? diliverConfigTypeArr2.map(item => {
                      // 匹配数字
                      // eslint-disable-next-line no-unused-vars
                      let num = item.replace(/[^\d]/g, "").trim();
                      let tabName = item.replace(/\d+/g, "");
                      /* 从主表配置 找到控件名=tabName,否则取他的showName */
                      const tableConfigArr = masterConfig?.gdsconfigformslave.filter(row => row.sControlName === item.trim());
                      if (commonUtils.isNotEmptyArr(tableConfigArr)) {
                        tabName = tableConfigArr[0].showName;
                      }
                      return (
                        <TabPane tab={tabName} key={num} className="xly-bill-list">
                          <div>
                            <CommonView
                              {...props}
                              // 使高度和从表高度一直
                              // isAutoHeight="ture"
                              tableConfigType={item}
                              tableConfigTypeArr={diliverConfigTypeArr2}
                            />
                          </div>
                        </TabPane>
                      );
                    })
                    : ""}
                  {onlySlave0 ? (
                    <>
                      <TabPane tab={materialsInfo} className="xly-bill-list" key={20}>
                        <div className="TabPaneStyle">
                          {app.currentPane.title !== "功能模块界面设置单据" ? (
                            <Row gutter={[8, 0]}>
                              <Col span={showAll0 ? 24 : iColValueTable0} order={iShowOrder0}>
                                <StaticEditTable
                                  {...slave0TableProps}
                                  noVlist
                                  setOpterationColumn={sModelsType !== listType && !bCheck0 ? "Y" : ""}
                                />
                              </Col>
                              {!bControlSeparateTab0 && <CommonViewTable {...slave0ViewProps} />}
                              {getChildTableComponent(props, "slave0")}
                            </Row>
                          ) : (
                            <div className="SetModelTable">
                              <div
                                style={{
                                  width: `${containerWidth}px`,
                                  marginRight: "10px",
                                  borderRight: "1px solid #e8e8e8",
                                  paddingRight: "4px",
                                  position: "relative",
                                  maxWidth: "100%",
                                }}
                                ref={containerRef}
                              >
                                <div
                                  ref={dividerRef}
                                  style={{
                                    position: "absolute",
                                    right: "-5px",
                                    top: "0",
                                    bottom: "0",
                                    width: "10px",
                                    cursor: "col-resize",
                                    background: "linear-gradient(to right, transparent, #e8e8e8, transparent)",
                                  }}
                                  onMouseDown={handleMouseDown}
                                />
                                <StaticEditTable
                                  {...slave0TableProps}
                                  noVlist
                                  setOpterationColumn={sModelsType !== listType && !bCheck0 ? "Y" : ""}
                                />
                              </div>
                              {!bControlSeparateTab0 && <CommonViewTable {...slave0ViewProps} style={{ flex: 1 }} />}
                            </div>
                          )}
                        </div>
                      </TabPane>
                      {bControlSeparateTab0 && (
                        <TabPane tab={separateTabName0} className="xly-bill-list" key={21}>
                          <CommonViewTable {...slave0ViewProps} iColValueView={24} />
                        </TabPane>
                      )}
                    </>
                  ) : (
                    ""
                  )}
                  {commonUtils.isNotEmptyArr(diliverConfigTypeArr3)
                    ? diliverConfigTypeArr3.map(item => {
                      // 匹配数字
                      // eslint-disable-next-line no-unused-vars
                      let num = item.replace(/[^\d]/g, "").trim();
                      let tabName = item.replace(/\d+/g, "");
                      /* 从主表配置 找到控件名=tabName,否则取他的showName */
                      const tableConfigArr = masterConfig?.gdsconfigformslave.filter(row => row.sControlName === item.trim());
                      if (commonUtils.isNotEmptyArr(tableConfigArr)) {
                        tabName = tableConfigArr[0].showName;
                      }
                      return (
                        <TabPane tab={tabName} key={num} className="xly-bill-list">
                          <div>
                            <CommonView
                              {...props}
                              // 使高度和从表高度一直
                              // isAutoHeight="ture"
                              tableConfigType={item}
                              tableConfigTypeArr={diliverConfigTypeArr3}
                            />
                          </div>
                        </TabPane>
                      );
                    })
                    : ""}
                  {onlySlave1 ? (
                    <>
                      <TabPane tab={checkInfo} className="xly-bill-list" key={30}>
                        <div className="TabPaneStyle">
                          {props.app.currentPane.title !== "功能模块界面设置单据" ? (
                            <div>
                              <Row gutter={[8, 0]}>
                                <Col span={showAll1 ? 24 : iColValueTable1} order={iShowOrder1}>
                                  <StaticEditTable
                                    {...slave1TableProps}
                                    noVlist
                                    setOpterationColumn={sModelsType !== listType && !bCheck1 ? "Y" : ""}
                                  />
                                </Col>
                                {!bControlSeparateTab1 && <CommonViewTable {...slave1ViewProps} />}
                                {getChildTableComponent(props, "slave1")}
                              </Row>
                              {/* <Row gutter={[8, 0]}>
                                        {slave2Config && slave2Config.sChinese === '上批对比' && <CommonViewTable {...slave2ViewProps} />}
                                    </Row> */}
                            </div>
                          ) : (
                            <div className="SetModelTable">
                              <div
                                style={{
                                  width: `${containerWidth}px`,
                                  marginRight: "10px",
                                  borderRight: "1px solid #e8e8e8",
                                  paddingRight: "4px",
                                  position: "relative",
                                  maxWidth: "100%",
                                }}
                                ref={containerRef}
                              >
                                <div
                                  ref={dividerRef}
                                  style={{
                                    position: "absolute",
                                    right: "-5px",
                                    top: "0",
                                    bottom: "0",
                                    width: "10px",
                                    cursor: "col-resize",
                                    background: "linear-gradient(to right, transparent, #e8e8e8, transparent)",
                                  }}
                                  onMouseDown={handleMouseDown}
                                />
                                <StaticEditTable
                                  {...slave1TableProps}
                                  noVlist
                                  setOpterationColumn={sModelsType !== listType && !bCheck0 ? "Y" : ""}
                                />
                              </div>
                              {!bControlSeparateTab1 && <CommonViewTable {...slave1ViewProps} style={{ flex: 1 }} />}
                            </div>
                          )}
                        </div>
                      </TabPane>
                      {bControlSeparateTab1 && (
                        <TabPane tab={separateTabName1} className="xly-bill-list" key={31}>
                          <CommonViewTable {...slave1ViewProps} iColValueView={24} />
                        </TabPane>
                      )}
                    </>
                  ) : (
                    ""
                  )}
                  {commonUtils.isNotEmptyArr(diliverConfigTypeArr4)
                    ? diliverConfigTypeArr4.map(item => {
                      // 匹配数字
                      // eslint-disable-next-line no-unused-vars
                      let num = item.replace(/[^\d]/g, "").trim();
                      let tabName = item.replace(/\d+/g, "");
                      /* 从主表配置 找到控件名=tabName,否则取他的showName */
                      const tableConfigArr = masterConfig?.gdsconfigformslave.filter(row => row.sControlName === item.trim());
                      if (commonUtils.isNotEmptyArr(tableConfigArr)) {
                        tabName = tableConfigArr[0].showName;
                      }
                      return (
                        <TabPane tab={tabName} key={num} className="xly-bill-list">
                          <div>
                            <CommonView
                              {...props}
                              // 使高度和从表高度一直
                              // isAutoHeight="ture"
                              tableConfigType={item}
                              tableConfigTypeArr={diliverConfigTypeArr4}
                            />
                          </div>
                        </TabPane>
                      );
                    })
                    : ""}
                  {onlyslave2 ? (
                    <>
                      <TabPane tab={slaveInfo0} className="xly-bill-list" key={40}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll2 ? 24 : iColValueTable2} order={iShowOrder2}>
                              <StaticEditTable {...slave2TableProps} noVlist setOpterationColumn={sModelsType !== listType && !bCheck2 ? "Y" : ""} />
                            </Col>
                            {!bControlSeparateTab2 && <CommonViewTable {...slave2ViewProps} />}
                            {getChildTableComponent(props, "slave2")}
                          </Row>
                        </div>
                      </TabPane>
                      {bControlSeparateTab2 && (
                        <TabPane tab={separateTabName2} className="xly-bill-list" key={41}>
                          <CommonViewTable {...slave2ViewProps} iColValueView={24} />
                        </TabPane>
                      )}
                    </>
                  ) : (
                    ""
                  )}
                  {commonUtils.isNotEmptyArr(diliverConfigTypeArr5)
                    ? diliverConfigTypeArr5.map(item => {
                      // 匹配数字
                      // eslint-disable-next-line no-unused-vars
                      let num = item.replace(/[^\d]/g, "").trim();
                      let tabName = item.replace(/\d+/g, "");
                      /* 从主表配置 找到控件名=tabName,否则取他的showName */
                      const tableConfigArr = masterConfig?.gdsconfigformslave.filter(row => row.sControlName === item.trim());
                      if (commonUtils.isNotEmptyArr(tableConfigArr)) {
                        tabName = tableConfigArr[0].showName;
                      }
                      return (
                        <TabPane tab={tabName} key={num} className="xly-bill-list">
                          <div>
                            <CommonView
                              {...props}
                              // 使高度和从表高度一直
                              // isAutoHeight="ture"
                              tableConfigType={item}
                              tableConfigTypeArr={diliverConfigTypeArr5}
                            />
                          </div>
                        </TabPane>
                      );
                    })
                    : ""}
                  {onlyslave3 ? (
                    <>
                      <TabPane tab={slaveInfo1} className="xly-bill-list" key={50}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll3 ? 24 : iColValueTable3} order={iShowOrder3}>
                              <StaticEditTable {...slave3TableProps} noVlist setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            {!bControlSeparateTab3 && <CommonViewTable {...slave3ViewProps} />}
                            {getChildTableComponent(props, "slave3")}
                          </Row>
                        </div>
                      </TabPane>
                      {bControlSeparateTab3 && (
                        <TabPane tab={separateTabName3} className="xly-bill-list" key={51}>
                          <CommonViewTable {...slave3ViewProps} iColValueView={24} />
                        </TabPane>
                      )}
                    </>
                  ) : (
                    ""
                  )}
                  {commonUtils.isNotEmptyArr(diliverConfigTypeArr6)
                    ? diliverConfigTypeArr6.map(item => {
                      // 匹配数字
                      // eslint-disable-next-line no-unused-vars
                      let num = item.replace(/[^\d]/g, "").trim();
                      let tabName = item.replace(/\d+/g, "");
                      /* 从主表配置 找到控件名=tabName,否则取他的showName */
                      const tableConfigArr = masterConfig?.gdsconfigformslave.filter(row => row.sControlName === item.trim());
                      if (commonUtils.isNotEmptyArr(tableConfigArr)) {
                        tabName = tableConfigArr[0].showName;
                      }
                      return (
                        <TabPane tab={tabName} key={num} className="xly-bill-list">
                          <div>
                            <CommonView
                              {...props}
                              // 使高度和从表高度一直
                              // isAutoHeight="ture"
                              tableConfigType={item}
                              tableConfigTypeArr={diliverConfigTypeArr6}
                            />
                          </div>
                        </TabPane>
                      );
                    })
                    : ""}
                  {onlyslave4 ? (
                    <>
                      <TabPane tab={slaveInfo2} className="xly-bill-list" key={60}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll4 ? 24 : iColValueTable4} order={iShowOrder4}>
                              <StaticEditTable {...slave4TableProps} setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            {!bControlSeparateTab4 && <CommonViewTable {...slave4ViewProps} />}
                            {getChildTableComponent(props, "slave4")}
                          </Row>
                        </div>
                      </TabPane>
                      {bControlSeparateTab4 && (
                        <TabPane tab={separateTabName4} className="xly-bill-list" key={61}>
                          <CommonViewTable {...slave4ViewProps} iColValueView={24} />
                        </TabPane>
                      )}
                    </>
                  ) : (
                    ""
                  )}
                  {onlyslave5 ? (
                    <>
                      <TabPane tab={slaveInfo3} className="xly-bill-list" key={70}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll4 ? 24 : iColValueTable4} order={iShowOrder4}>
                              <StaticEditTable {...slave5TableProps} setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            <CommonViewTable {...slave4ViewProps} />
                          </Row>
                        </div>
                      </TabPane>
                    </>
                  ) : (
                    ""
                  )}
                  {onlyslave6 ? (
                    <>
                      <TabPane tab={slaveInfo4} className="xly-bill-list" key={80}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll4 ? 24 : iColValueTable4} order={iShowOrder4}>
                              <StaticEditTable {...slave6TableProps} setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            <CommonViewTable {...slave4ViewProps} />
                          </Row>
                        </div>
                      </TabPane>
                    </>
                  ) : (
                    ""
                  )}
                  {onlyslave7 ? (
                    <>
                      <TabPane tab={slaveInfo5} className="xly-bill-list" key={90}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll4 ? 24 : iColValueTable4} order={iShowOrder4}>
                              <StaticEditTable {...slave7TableProps} setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            <CommonViewTable {...slave4ViewProps} />
                          </Row>
                        </div>
                      </TabPane>
                    </>
                  ) : (
                    ""
                  )}
                  {onlyslave8 ? (
                    <>
                      <TabPane tab={slaveInfo6} className="xly-bill-list" key={100}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll4 ? 24 : iColValueTable4} order={iShowOrder4}>
                              <StaticEditTable {...slave8TableProps} setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            <CommonViewTable {...slave4ViewProps} />
                          </Row>
                        </div>
                      </TabPane>
                    </>
                  ) : (
                    ""
                  )}
                  {onlyslave9 ? (
                    <>
                      <TabPane tab={slaveInfo7} className="xly-bill-list" key={110}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll4 ? 24 : iColValueTable4} order={iShowOrder4}>
                              <StaticEditTable {...slave9TableProps} setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            <CommonViewTable {...slave4ViewProps} />
                          </Row>
                        </div>
                      </TabPane>
                    </>
                  ) : (
                    ""
                  )}
                  {onlyslave10 ? (
                    <>
                      <TabPane tab={slaveInfo8} className="xly-bill-list" key={150}>
                        <div className="TabPaneStyle">
                          <Row gutter={[8, 0]}>
                            <Col span={showAll4 ? 24 : iColValueTable4} order={iShowOrder4}>
                              <StaticEditTable {...slave10TableProps} setOpterationColumn={sModelsType !== listType ? "Y" : ""} />
                            </Col>
                            <CommonViewTable {...slave4ViewProps} />
                          </Row>
                        </div>
                      </TabPane>
                    </>
                  ) : (
                    ""
                  )}
                </Tabs>
              </div>
            )}
          </Content>
          {bFlow ? (
            <div
              id="examInfo"
              style={{ width: "25%", textAlign: "center", height: "900px", maxHeight: "calc(100vh - 130px)", backgroundColor: "#f0f0f0" }}
            >
              <CommonExamInfo {...props} />
            </div>
          ) : (
            ""
          )}
          {props.productProcessInfoChooseVisible ? (
            <AntdDraggableModal
              width={1200}
              title={processCardSearchResult}
              visible={props.productProcessInfoChooseVisible}
              onCancel={props.onCancelProductProcessInfoChooseModal}
              footer={null}
            >
              <CommonListSelect {...productProcessInfoType} />
            </AntdDraggableModal>
          ) : (
            ""
          )}
          {props.showImportErrorVisible ? (
            <AntdDraggableModal
              width={1480}
              zIndex={1000}
              title={importExcelTitle}
              bodyStyle={{ height: "450px" }}
              visible={props.showImportErrorVisible}
              onCancel={props.handleCancelModal.bind(this, "showImportErrorVisible")}
              onOk={props.handleCancelModal.bind(this, "showImportErrorVisible")}
              onSaveState={props.onSaveState}
            // footer={null}
            >
              <StaticEditTable {...importExcelProps} />
            </AntdDraggableModal>
          ) : (
            ""
          )}
          {false && props.sParamsModalVisible ? (
            <AntdDraggableModal
              width="920px"
              className="paramModal"
              title={sProcessParams}
              visible={props.sParamsModalVisible}
              onOk={props.onParamsOk}
              onCancel={props.onCancelModal.bind(this, "sParamsModalVisible")}
            // footer={null}
            >
              <div className="xly-bill-list">
                <StaticEditTable {...sParamProps} footer="hidden" noVlist />
              </div>
            </AntdDraggableModal>
          ) : (
            ""
          )}

          {false && props.sParamsNewModalVisible ? (
            <AntdDraggableModal
              width="920px"
              className="paramModal"
              title={sProcessParamsNew}
              visible={props.sParamsNewModalVisible}
              onOk={props.onParamsNewOk}
              onCancel={props.onCancelModal.bind(this, "sParamsNewModalVisible")}
            // footer={null}
            >
              <div className="xly-bill-list">
                <StaticEditTable {...sParamNewProps} footer="hidden" noVlist />
              </div>
            </AntdDraggableModal>
          ) : (
            ""
          )}

          {props.contextMenuModalVisible ? <ContextMenuModal {...props} /> : ""}
          {props.visibleInstructField ? (
            <AntdDraggableModal width="1500px" className="paramModal" title="JSON格式化" visible={props.visibleInstructField} footer={null}>
              <div>
                <JsonFormatter
                  onJsonFormatOk={props.onJsonModalOk}
                  onJsonFormatCancel={props.onCancelModal.bind(this, "visibleInstructField")}
                  initialJsonString={sInstructJsonString}
                />
              </div>
            </AntdDraggableModal>
          ) : (
            ""
          )}
          <div>
            <AssignmentField {...assignmentFieldProps} />
          </div>
          <ModalComponent {...props} />
          <CommonEffectEvent {...props} />
        </Layout>
      </Layout>
    </Form>
  );
});

// 函数式组件
const CommonEffectEvent = props => {
  const { masterData = {} } = props;
  const { sBmRule } = masterData;

  const [watchFields, setWatchFields] = useState([]);
  const preValue = useRef("");

  useEffect(() => {
    if (!sBmRule) {
      setWatchFields([]);
      preValue.current = "";
      return;
    }

    const sBmRuleObj = commonUtils.convertStrToObj(sBmRule);
    const { showName = "" } = sBmRuleObj;
    setWatchFields(showName.split(","));
  }, [sBmRule]);

  useEffect(() => {
    if (!watchFields.length) return;
    const newValue = watchFields.map(key => masterData[key] || "").join("");
    if (preValue.current === newValue) return;
    preValue.current = newValue;

    const sBmRuleObj = commonUtils.convertStrToObj(sBmRule);
    const addState = Object.keys(sBmRuleObj).filter(key => key !== "showName").reduce((result, key) => {
      const list = sBmRuleObj[key]?.split("+") || [];
      result[key] = list.map(item => item.trim().replace(/\'/g, '')).map(item => {
        if (item !== '.' && item?.includes('.')) {
          const [tableName, sFieldName] = item.split('.');
          return props[`${tableName}Data`]?.[sFieldName] || "";
        }
        return item;
      }).join('');
      return result;
    }, {});

    props.onSaveState({
      masterData: {
        ...masterData,
        ...addState,
        handleType: masterData.handleType || 'update',
      }
    });

  }, [watchFields, masterData]);

  return null;
}

// 工艺参数弹窗
const ModalComponent = props => {
  if (!props.sParamsModalVisible && !props.sParamsNewModalVisible) return "";

  const sProcessParams = props.sParamsModalVisible ? "原工艺参数" : "工艺参数新";
  const bVisible = props.sParamsModalVisible || props.sParamsNewModalVisible;
  return bVisible ? (
    <AntdDraggableModal
      width="80%"
      className="commonParamDrag"
      title={sProcessParams}
      visible={bVisible}
      onCancel={() => {
        props.onSaveState({
          sParamsModalVisible: false,
          sParamsNewModalVisible: false,
        });
      }}
      footer={
        // <div style={{display:'flex',  justifyContent: 'space-between'}}>
        //   <div className='oper'>
        //     <Button type='primary' onClick={() => { handleBtnParamPage(props, props.processTableId, 'first')}} >首条</Button>
        //     <Button type='primary' onClick={() => { handleBtnParamPage(props, props.processTableId, 'before')}} >上一条</Button>
        //     <Button type='primary' onClick={() => { handleBtnParamPage(props, props.processTableId, 'next')}} >下一条</Button>
        //     <Button type='primary' onClick={() => { handleBtnParamPage(props, props.processTableId, 'last')}} >末条</Button>
        //   </div>

        //   <div style={{ width: '20%'}}>
        //     <Button
        //       type="primary"
        //       onClick={() => {
        //         props.onSaveState({ [modalName]: false });
        //       }}
        //     >
        //       确定
        //     </Button>
        //   </div>

        // </div>
        <Button
          type="primary"
          onClick={() => {
            props.onSaveState({
              sParamsModalVisible: false,
              sParamsNewModalVisible: false,
            });
          }}
        >
          确定
        </Button>
      }
    >
      {[""].map(() => {
        const commonViewDragableProps = {
          ...props,
          hideTabsNav: true,
          comparedTableId: props.processTableId,
          sParamData: [
            {
              sParamType: "sWorkOrder",
              sParamName: "工单参数",
            },
          ],
          tableName: "slave",
        };

        // 如果是工艺参数新
        if (props.sParamsNewModalVisible) {
          const { slaveData = [] } = props;
          const slaveDataNew = lodash.cloneDeep(slaveData);
          slaveDataNew.forEach(item => {
            item.handleType = commonUtils.isEmpty(item.handleType) ? "update" : item.handleType;
            item.sParams = item.sParamsNew;
            item.sWorkOrderParams = item.sWorkOrderParamsNew;
          });
          commonViewDragableProps.slaveData = slaveDataNew;
          commonViewDragableProps.onCostomSaveData = tableData => {
            const slaveDataTemp = lodash.cloneDeep(slaveData);
            slaveDataTemp.forEach(item => {
              const rowData = tableData.find(i => i.sId === item.sId);
              item.handleType = commonUtils.isEmpty(item.handleType) ? "update" : item.handleType;
              item.sParamsNew = rowData.sParams;
              item.sWorkOrderParamsNew = rowData.sWorkOrderParams;
            });
            props.onSaveState({ slaveData: slaveDataTemp });
          };
        }
        return <CommonViewDragable {...commonViewDragableProps} />;
      })}
    </AntdDraggableModal>
  ) : (
    ""
  );
};

/**
 * 加载子从表格组件
 */
const getChildTableComponent = (props, tableName) => {
  const {
    sModelsType,
    addStateMap,
    bHasChildSlave,
    slaveChildOrder,
    salveIColValue,
    [`${tableName}Config`]: fatherConfig,
    masterData,
    masterConfig = [],
    slaveConfig,
    slaveSelectedRowKeys,
    slaveData,
  } = props;

  if (commonUtils.isEmptyStr(tableName)) {
    return null;
  }
  let slaveRow = {};
  if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
    const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId));
    if (iIndex > -1) {
      slaveRow = slaveData[iIndex];
    } else {
      slaveRow = slaveData[0];
    }
  } else if (commonUtils.isNotEmptyArr(slaveData)) {
    slaveRow = slaveData[0];
  }
  // 是否有表单字段
  const bHasViewConfigs = fatherConfig.gdsconfigformslave.some(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1);

  /* 找到父层下面有多少子级 */
  const slaveChildNameArr = Object.keys(addStateMap).filter(
    key => commonUtils.isNotEmptyObject(fatherConfig.sChildTableName) && fatherConfig.sChildTableName.split(",").includes(addStateMap[key].sGrd)
  );

  if (slaveChildNameArr.length === 0) {
    return null; // 如果没有有效配置，返回 null 避免渲染
  }
  return slaveChildNameArr.map(slaveChildName => {
    let viewConfigs = [];
    // 是否展示操作按钮
    const config = props[`${slaveChildName}`];
    const { gdsconfigformslave = [] } = config;

    if (commonUtils.isNotEmptyArr(gdsconfigformslave)) {
      viewConfigs = gdsconfigformslave.filter(item => item.sName !== "" && item.bControl && item.sControlName.indexOf("Btn") === -1);
      if (viewConfigs.length === 0) {
        return null; // 如果没有有效配置，返回 null 避免渲染
      }
    }

    /* 从表view */
    const tableViewProps = {
      ...props,
      viewConfigs,
      tableConfig: config,
      iColValueView: 24,
      viewRow: slaveRow,
      tableName: slaveChildName,
      // handleFieldDoubleClick: props.handleFieldDoubleClick
    };

    /* 区分TabPane1 还是单纯的commonView */

    return (
      // 新增标题行和子 CommonViewTable
      <Col key={config?.sId} span={24} order={10} style={{ textAlign: "center", background: "#ffffff" }}>
        <div style={{ fontWeight: "bold", fontSize: "16px" }}>上批数据</div>
        <CommonViewTable {...tableViewProps} />
      </Col>
    );
  });
};

const useCommonNewBillEvent = (props) => {
  return {
    ...props,
  }
};

const CommonNewBill = Form.create({
  mapPropsToFields(props) {
    const { masterData, masterConfig } = props;
    const obj = commonFunc.mapPropsToFields(masterData, Form, masterConfig);
    return obj;
  },
})((props) => {
  const {
    onReturnForm, form
  } = props;
  onReturnForm(form);
  return <CommonNewBillComponent {...props} />
})

const CommonNewBillComponent = (baseProps) => {
  const props = useCommonNewBillEvent(baseProps);
  const {
    enabled,
    billType = "add",
    masterConfig,
    masterData = {},
  } = props;

  if (commonUtils.isEmptyObject(masterConfig)) {
    return null;
  }

  const bCheckModel = false;
  const { bSubmit, bCheck } = masterData;
  const bStatus = bCheckModel ? bCheck : bSubmit;

  return <div className={stylesNew.verifyScrapBill}>
    <div className={stylesNew.billForm}>
      <div>
        <FormComponent {...props} />
      </div>
      <div>
        <Toolbar
          {...props}
          pageFrom="padBill"
          customRender={(params) => {
            const { menuDataCopy, getMenuProps, handleClick } = params;
            return menuDataCopy.filter(item => commonUtils.isEmptyArr(item.child)).map(item => {
              const { showName } = item;
              const menuItemProps = getMenuProps(item, "key");
              // 如果child包含BtnUpdPic，使用CommobileToolBar
              if (item?.sControlName.includes('BtnUpdPic')) {
                return (
                  <CommobileToolBar
                    key={item.key}
                    {...props}
                    buttonConfig={[item]}
                  />
                );
              }else {
                return <div>
                  <Button
                    type="primary"
                    size="large"
                    {...menuItemProps}
                    onClick={() => {
                      handleClick(menuItemProps);
                    }}
                  >
                    {showName}
                  </Button>
                </div>
              }

            })
          }}
        />
      </div>
    </div>
    <div className={stylesNew.table} key={masterData.sWorkOrderNo}>
      <TabsComponent {...props} />
      {/* <TableComponent {...props} /> */}
    </div>
  </div>
};

// 表单
const FormComponent = props => {
  const { masterConfig, masterData = {} } = props;
  const viewConfigs = masterConfig.gdsconfigformslave.filter(
    item =>
      item.sName &&
      item.bVisible &&
      item.sControlName.indexOf("Btn") === -1 &&
      item.sControlName.indexOf("_") === -1
  );

  const viewProps = {
    ...props,
    viewConfigs,
    tableConfig: masterConfig,
    iColValueView: 24,
    viewRow: masterData,
    tableName: "master",
    onDataChange: props.onChange,
  };

  return <CommonViewTable {...viewProps} />;
};

// Tabs
const TabsComponent = props => {
  const { slaveConfig } = props;
  const tableList = [];
  if (slaveConfig?.showName) {
    tableList.push('slave');
  }
  for (let i = 0; i < 12; i++) {
    const tableName = `slave${i}`;
    const tableConfigName = `slave${i}Config`;
    if (props[tableConfigName]?.showName) {
      tableList.push(tableName);
    }
  }

  return <Tabs onChange={props.onTabChange} className={styles.slaveTabs} tabBarStyle={{ margin: "0 8px" }}>
    {
      tableList.map(tableName => {
        const config = props[`${tableName}Config`];
        const { showName } = config;
        return <TabPane tab={showName} className="xly-bill-list" key={tableName}>
          <TableComponent {...props} tableName={tableName} />
        </TabPane>
      })
    }
  </Tabs>
};

// 表格
const TableComponent = props => {
  const { tableName } = props;
  const baseProps = commonBusiness.getTableTypes(tableName, {
    ...props,
    noStorageColumn: true
  });
  const tableProps = {
    ...baseProps,
    setOpterationColumn: "Y",
    tableProps: {
      onChange: props.onTitleChange.bind(this, tableName),
    },
    fixedHeight: "calc(100vh - 350px)"
  };
  return <StaticEditTable {...tableProps} />;
};

export default CommonBase(CommonNewSales(CommonNewBill));
