/* eslint-disable */
/* eslint-disable array-callback-return,no-undef,object-curly-newline,prefer-destructuring,no-unused-vars */
import React, { Component } from 'react';
import { DownOutlined, LoadingOutlined, MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
import { Form, Icon } from '@ant-design/compatible';
// import '@ant-design/compatible/assets/index.css';
import { Modal, Layout, Spin, Card, Row, Col, message, Tree, Switch, Pagination } from 'antd-v4'; // Switch Select, Tabs,
import styles from '@/index.less';
import selfstyles from '@/components/productionMainPlan/index.less';
import * as commonFunc from '@/components/Common/commonFunc';
import CommonBase from '@/components/Common/CommonBase';
import * as commonBusiness from '@/components/Common/commonBusiness';/* 单据业务功能 */
import StaticEditTable from '@/components/Common/CommonTable';/* 可编辑表格 */
import CommonProductionPlanTreeEvent from '@/components/Common/CommonProductionPlanTreeEvent';
import Toolbar from '@/components/Common/ToolBar/ToolBarNew';
import MoveUp from '@/assets/processUp.svg';
import MoveDown from '@/assets/processDown.svg';
import DisableMoveUp from '@/assets/disableprocessUp.svg';
import DisableMoveDown from '@/assets/disableprocessDown.svg';
import MoveTop from '@/assets/processTop.svg';
import DisableMoveTop from '@/assets/disableprocessTop.svg';
import MoveBottom from '@/assets/processBottom.svg';
import DisableMoveBottom from '@/assets/disableprocessBottom.svg';

import ChangeMachine from '@/assets/plan/change.png';
import DisableChangeMachine from '@/assets/plan/change_1.png';
import ChangeMachineEnglish from '@/assets/plan/change_english.svg';
import DisableChangeMachineEnglish from '@/assets/plan/change_english_1.svg';

import SetSave from '@/assets/plan/save.png';
import DisableSetSave from '@/assets/plan/save_1.png';
import SetSaveEnglish from '@/assets/plan/save_english.svg';
import DisableSetSaveEnglish from '@/assets/plan/save_english_1.svg';

import SetLock from '@/assets/plan/lock.png';
import DisableSetLock from '@/assets/plan/lock_1.png';
import SetLockEnglish from '@/assets/plan/lock_english.svg';
import DisableSetLockEnglish from '@/assets/plan/lock_english_1.svg';

import SetOverExec from '@/assets/plan/over.png';
import DisableSetOverExec from '@/assets/plan/over_1.png';
import SetOverExecEnglish from '@/assets/plan/over_english.svg';
import DisableSetOverExecEnglish from '@/assets/plan/over_english_1.svg';

import ShowGantt from '@/assets/gantt.svg';
import DisableShowGantt from '@/assets/disablegantt.svg';

import ShowCheckModel from '@/assets/plan/check.png';
import DisableShowCheckModel from '@/assets/plan/check_1.png';
import ShowCheckModelEnglish from '@/assets/plan/check_english.svg';
import DisableShowCheckModelEnglish from '@/assets/plan/check_english_1.svg';

import ShowTimer from '@/assets/plan/cal.png';
import DisableShowTimer from '@/assets/plan/cal_1.png';
import ShowTimerEnglish from '@/assets/plan/cal_english.svg';
import DisableShowTimerEnglish from '@/assets/plan/cal_english_1.svg';

import ShowList from '@/assets/list.svg';
import DisableShowList from '@/assets/disablelist.svg';
import Reset from '@/assets/reset.svg';
import DisableReset from '@/assets/disablereset.svg';
import * as commonUtils from '@/utils/utils';
import ShowType from '@/components/Common/CommonComponent';
import commonConfig from '@/utils/config';
import AntdDraggableModal from '@/components/Common/AntdDraggableModal';
import Gantt from '@/components/Charts/Gantt';
import * as commonServices from '@/services/services';
import CommonListSelect from '@/components/Common/CommonListSelect';
import SearchComponent from '@/components/Common/SearchComponent';
import tab from '@/routes/tab/tab';
import GanttStyles from './index.less';
import moment from 'moment';

const { TreeNode } = Tree;

const { Header, Content, Sider } = Layout;

class ProductionSchedule extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isRender: 0,
      treeData: [],
      pageSize: 20,
      pageNum: 1,
      expandAll: true,
      expandedTreeKeys: [],
      checkModelStatus: false,
      defaultKey: 'unset',
      slideFlag: localStorage.getItem('treeSlide_' + this.props.sModelsId) ? +localStorage.getItem('treeSlide_' + this.props.sModelsId) : 0,
    };
    this.treeDiv = null;
    this.requested = false
    this.bMachine = false;
    if (props && props.app && props.app.currentPane && props.app.currentPane.copyTo && props.app.currentPane.copyTo.sWorkCenterName) {
      this.bMachine = true
    }
    this.showSetMachine = false;
    this.form = {};
  }
  componentWillReceiveProps(props) {
    if (props.slaveInfoSelectedRowKeys && props.slaveSelectedData && (props.slaveInfoSelectedRowKeys.length || props.slaveSelectedData.length)) {
      this.showSetMachine = true;
    } else {
      this.showSetMachine = false;
    }
    if (props.app && props.app.currentPane && props.app.currentPane.copyTo && props.app.currentPane.copyTo.treeKey) {
      if (this.state.defaultKey === 'unset') {
        this.setState({
          defaultKey: [props.app.currentPane.copyTo.treeKey]
        });
      }
    }
    if (Array.isArray(this.state.defaultKey) && props.treeData.length && props.app.currentPane.copyTo.treeKey && !this.requested) {
      let selectedItem = '';
      props.treeData.forEach(item => {
        if (item.children) {
          item.children.forEach(item2 => {
            if (item2.sId + item2.sWorkCenterId == props.app.currentPane.copyTo.treeKey) {
              selectedItem = item2;
            }
          })
        }
      })
      this.handleTabsCallback(selectedItem);
      this.requested = true;
    }
    if (this.state.expandedTreeKeys.length === 0 && this.state.expandAll) {
      const arr = [];
      props.treeData.forEach((item) => {
        arr.push(item.sId + item.sWorkCenterId);
      });
      this.setState({
        expandedTreeKeys: arr,
      });
    }
  }
  shouldComponentUpdate(nextProps) {
    const { slaveColumn, masterConfig } = nextProps;
    return commonUtils.isNotEmptyArr(slaveColumn) || commonUtils.isNotEmptyObject(masterConfig);
  }
  onDoubleClick = (name, record) => {
    if (this.props.onDoubleClick !== undefined) {
      this.props.onDoubleClick(record);
    }
  };
  onRowClick = (name, record, bRowClick) => {
    const { slaveData } = this.props;
    let { slaveSelectedRowKeys, slaveInfoSelectedRowKeys } = this.props;
    slaveInfoSelectedRowKeys = commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) ? slaveInfoSelectedRowKeys : [];
    if (name === 'slave') {
      if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
        const keys = [];
        keys.push(record.sSlaveId);
        slaveSelectedRowKeys = keys;
        const sIds = record.sSlaveId.split('-');
        slaveInfoSelectedRowKeys.push(...sIds);
      } else {
        const indexKey = slaveSelectedRowKeys.indexOf(record.sSlaveId);
        if (indexKey === -1) {
          slaveSelectedRowKeys.push(record.sSlaveId);
          const sIds = record.sSlaveId.split('-');
          slaveInfoSelectedRowKeys.push(...sIds);
          sIds.forEach((item) => {
            const iIndex = slaveInfoSelectedRowKeys.findIndex(e => e === item);
            if (iIndex === -1) {
              slaveInfoSelectedRowKeys.push(item);
            }
          });
        } else if (indexKey !== -1) {
          if (!bRowClick) {
            slaveSelectedRowKeys.splice(indexKey, 1);
          }
          const sIds = record.sSlaveId.split('-');
          sIds.forEach((item) => {
            const index = slaveInfoSelectedRowKeys.findIndex(e => e === item);
            if (!bRowClick) {
              slaveInfoSelectedRowKeys.splice(index, 1);
            }
          });
        }
      }
    } else if (name === 'slaveInfo') {
      if (commonUtils.isEmptyArr(slaveInfoSelectedRowKeys)) {
        const keys = [];
        keys.push(record.sId);
        slaveInfoSelectedRowKeys = keys;
        const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId));
        if (commonUtils.isNotEmptyArr(slaveDataNews)) {
          slaveSelectedRowKeys = [slaveDataNews[0].sSlaveId];
        }
      } else {
        const indexKey = slaveInfoSelectedRowKeys.indexOf(record.sId);
        if (indexKey === -1) {
          slaveInfoSelectedRowKeys.push(record.sId);
          const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId));
          if (commonUtils.isNotEmptyArr(slaveDataNews)) {
            const iIndex = slaveSelectedRowKeys.findIndex(item => item === slaveDataNews[0].sSlaveId);
            if (iIndex === -1) {
              slaveSelectedRowKeys.push(slaveDataNews[0].sSlaveId);
            }
          }
        } else if (indexKey !== -1) {
          slaveInfoSelectedRowKeys.splice(indexKey, 1);
          const slaveDataNews = slaveData.filter(item => item.sSlaveId.split('-').includes(record.sId));
          if (commonUtils.isNotEmptyArr(slaveDataNews)) {
            const sSlaveIds = slaveDataNews[0].sSlaveId.split('-');
            if (slaveInfoSelectedRowKeys.length === 0 || sSlaveIds.length === 1) {
              const iIndex = slaveSelectedRowKeys.indexOf(item => slaveDataNew[0].sSlaveId === item);
              slaveSelectedRowKeys.splice(iIndex, 1);
            } else {
              let bdel = true;
              for (const sId of sSlaveIds) {
                if (slaveInfoSelectedRowKeys.findIndex(item => item === sId && item !== record.sId)) {
                  bdel = false;
                  break;
                }
              }
              if (bdel) {
                const iIndex = slaveSelectedRowKeys.indexOf(item => slaveDataNew[0].sSlaveId === item);
                slaveSelectedRowKeys.splice(iIndex, 1);
              }
            }
          }
        }
      }
    }
    let machineEnabled = false;
    if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
      const currSlave = slaveData.filter(item => item.sSlaveId === slaveSelectedRowKeys[0])[0];
      const processSlave = slaveData.filter(item => item.sProcessId === currSlave.sProcessId && slaveSelectedRowKeys.includes(item.sSlaveId));
      if (processSlave.length === slaveSelectedRowKeys.length) {
        machineEnabled = true;
      }
    }
    const { sModelsId } = this.props;
    commonUtils.setStoreDropDownData(sModelsId, 'master', 'sMachineId', []);
    commonUtils.setStoreDropDownData(sModelsId, 'master', 'sWorkCenterId', []);
    this.props.onSaveState({ slaveSelectedRowKeys, slaveInfoSelectedRowKeys, machineEnabled });
  };

  onRowMouseEnter= (name, record) => { // recor

    if (this.timerSelectRowChange) {
      clearTimeout(this.timerSelectRowChange);
    }
    this.timerSelectRowChange = setTimeout(() => {
      this.props.onSaveState({
        rowHoverSid: record.sSlaveId,
      });
      // console.log('=====record', record);
      // this.handleSelectRowChange(this.props.name, [record[this.rowKey]]);
    }, 150);
  }

  onRowMouseLeave= () => {
    if (this.timerSelectRowChange) {
      this.props.onSaveState({
        rowHoverSid: '',
      });
      clearTimeout(this.timerSelectRowChange);
    }
  }

  onCloseChangeMachine = () => {
    const { masterData } = this.props;
    delete masterData.tStartDate;
    delete masterData.iSplitNum;
    delete masterData.bSplit;
    this.props.onSaveState({ isChangeMachine: false, masterData: { ...masterData, sWorkCenterId: '',  sMachineId: '', sTeamId: '' } });
  }
  onPageChange = (pageNum) => {
    this.setState({
      pageNum,
    });
  }
  onTableSelectRowChange = (name, selectedRowKeys) => {
    const { slaveData, slaveSelectedRowKeys, slaveInfoConfig } = this.props;
    if (name === 'slave') {
      const addState = this.props.onTableSelectRowChange(name, selectedRowKeys, true);
      const slaveInfoSelectedRowKeys = [];
      /* 找到勾选掉的Id */
      let oldSelectRowkeys = []; /* 取消勾选行 */
      if(commonUtils.isEmptyObject(slaveInfoConfig) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
        oldSelectRowkeys = slaveSelectedRowKeys.filter(item => !selectedRowKeys.includes(item)); // 历史数据中删除的数据
        if(commonUtils.isNotEmptyArr(oldSelectRowkeys) ) { /* 单层表格时 */
          oldSelectRowkeys.forEach((oldSelectRowkey) => {
            if(commonUtils.isNotEmptyObject(oldSelectRowkey) && oldSelectRowkey.includes('sDivRow')) { /* 找到勾选掉的sDivRow汇总行 */
              const slaveRemoveData = slaveData.filter(item => item.sDivRowParentId === oldSelectRowkey);
              if(commonUtils.isNotEmptyArr(slaveRemoveData)) {
                slaveRemoveData.forEach((itemChild) => {
                  const indexKey = selectedRowKeys.indexOf(itemChild.sSlaveId);
                  if(indexKey > -1) {
                    selectedRowKeys.splice(indexKey, 1);
                  }
                });
              }
            } else {
              const indexKey = selectedRowKeys.indexOf(oldSelectRowkey);
              if(indexKey > -1) {
                selectedRowKeys.splice(indexKey, 1);
              }
            }
          });
        }
      }
      if (commonUtils.isNotEmptyArr(selectedRowKeys)) {
        selectedRowKeys.forEach((selectedRow) => {
          const sIds = selectedRow.split('-');
          slaveInfoSelectedRowKeys.push(...sIds);
          if (commonUtils.isEmptyObject(slaveInfoConfig) && commonUtils.isEmptyArr(oldSelectRowkeys)) { /* 单层结构 sDivRow控制 */
            if (commonUtils.isNotEmptyObject(selectedRow) && selectedRow.includes('sDivRow')) {
              const slaveChildData = slaveData.filter(item => item.sDivRowParentId === selectedRow);
              if (commonUtils.isNotEmptyArr(slaveChildData)) {
                slaveChildData.forEach((itemChild) => {
                  const indexKey = selectedRowKeys.indexOf(itemChild.sSlaveId);
                  if (indexKey === -1) {
                    selectedRowKeys.push(itemChild.sSlaveId);
                  }
                });
              }
            }
          }
        });
      }
      addState.slaveInfoSelectedRowKeys = slaveInfoSelectedRowKeys;
      addState.slaveSelectedRowKeys = selectedRowKeys;
      this.props.onSaveState({ ...addState });
    } else {
      this.props.onTableSelectRowChange(name, selectedRowKeys);
    }
    // let record = {};
    // let key;
    // if (name === 'slave') {
    //   if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isEmptyArr(slaveSelectedRowKeys) && selectedRowKeys.length === 1) {
    //     key = selectedRowKeys[0];
    //   } else if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && commonUtils.isEmptyArr(selectedRowKeys) && slaveSelectedRowKeys.length === 1) {
    //     key = slaveSelectedRowKeys[0];
    //   } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && selectedRowKeys.length > slaveSelectedRowKeys.length) {
    //     key = selectedRowKeys.filter(item => !slaveSelectedRowKeys.includes(item))[0];
    //   } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveSelectedRowKeys) && selectedRowKeys.length < slaveSelectedRowKeys.length) {
    //     key = slaveSelectedRowKeys.filter(item => !selectedRowKeys.includes(item))[0];
    //   }
    //   record = tableData.filter(item => key === item.sSlaveId)[0];
    //   this.onRowClick(name, record);
    // } else if (name === 'slaveInfo') {
    //   if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isEmptyArr(slaveInfoSelectedRowKeys) && selectedRowKeys.length === 1) {
    //     key = selectedRowKeys[0];
    //   } else if (commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) && commonUtils.isEmptyArr(selectedRowKeys) && slaveInfoSelectedRowKeys.length === 1) {
    //     key = slaveInfoSelectedRowKeys[0];
    //   } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) && selectedRowKeys.length > slaveInfoSelectedRowKeys.length) {
    //     key = selectedRowKeys.filter(item => !slaveInfoSelectedRowKeys.includes(item))[0];
    //   } else if (commonUtils.isNotEmptyArr(selectedRowKeys) && commonUtils.isNotEmptyArr(slaveInfoSelectedRowKeys) && selectedRowKeys.length < slaveInfoSelectedRowKeys.length) {
    //     key = slaveInfoSelectedRowKeys.filter(item => !selectedRowKeys.includes(item))[0];
    //   }
    //   record = tableData.filter(item => key === item.sId)[0];
    //   this.onRowClick(name, record);
    // } else {
    //   this.props.onTableSelectRowChange(name, selectedRowKeys);
    // }
  };
  onTreeExpandChange = () => {
    const oldState = this.state.expandAll;
    const arr = [];
    if (!oldState) {
      this.props.treeData.forEach((item) => {
        arr.push(item.sId + item.sProcessId + item.iOrder);
      });
    }
    this.setState({
      expandAll: !oldState,
      expandedTreeKeys: arr,
    });
  }
  onTreeExpand = (e) => {
    this.setState({
      expandedTreeKeys: e,
    });
  }
  /**   处理选择行发生改变s   */
  handleTableFilterData = (name, data, record) => {
    /*   外置处理业务   */
    if (name === 'slave') {
      let slaveInfoDataNew = [];
      if (commonUtils.isNotEmptyArr(data)) {
        slaveInfoDataNew = data.filter(item => record.sSlaveId.split('-').includes(item.sId));
      }
      return slaveInfoDataNew;
    }
  };
  // 根据配置解析拼接具体参数
  handleProParams = (sKey, arr) => {
    const { [`${sKey}Data`]: tableData, [`${sKey}SelectedRowKeys`]: selectedRowKeys } = this.props;
    const keyData = tableData.filter(item => selectedRowKeys.includes(item.sId) || selectedRowKeys.includes(item.sSlaveId));
    if (commonUtils.isNotEmptyArr(keyData)) {
      const addState = {};
      addState.key = sKey;
      const val = [];
      keyData.forEach((currData) => {
        const currVal = {};
        arr.forEach((filed) => {
          currVal[`${filed}`] = currData[`${filed}`];
        });
        val.push(currVal);
      });
      addState.value = val;
      return addState;
    } else {
      return undefined;
    }
  };
  /* 甘特图数据改变出发事件 */
  logDataUpdate = (type, action, item, id) => {
    const { charGanttData } = this.props;
    /* 记录更新的数据 */
    if (action === 'update') {
      if (commonUtils.isNotEmptyArr(charGanttData)) {
        const { data } = charGanttData;
        if (commonUtils.isNotEmptyArr(data) && data.length > 0) {
          const iIndex = data.findIndex(child => child.id === id);
          if (iIndex > -1) {
            if (commonUtils.isNotEmptyObject(item.start_date)) {
              data[iIndex].start_date = item.start_date;
            }
            if (commonUtils.isNotEmptyObject(item.end_date)) {
              data[iIndex].end_date = item.end_date;
            }
            charGanttData.tasks.data = data;
            this.props.onSaveState({ charGanttData });
          }
        }
      }
    }
    const text = item && item.text ? ` (${item.text})` : '';
    let message = `${type} ${action}: ${id} ${text}`;
    if (type === 'link' && action !== 'delete') {
      message += ` ( source: ${item.source}, target: ${item.target} )`;
    }
    this.addMessage(message);
  }
  logTaskUpdate = (id, mode, task) => {
    const text = task && task.text ? ` (${task.text})` : '';
    const message = `Task ${mode}: ${id} ${text}`;
    this.addMessage(message);
  }
  logLinkUpdate = (id, mode, link) => {
    let message = `Link ${mode}: ${id}`;
    if (link) {
      message += ` ( source: ${link.source}, target: ${link.target} )`;
      this.addMessage(message);
    }
  }
  addMessage = (message) => {
    const maxLogLength = 5;
    const newMessate = { message };
    const messages = [
    ];
    messages.push(newMessate);
    if (messages.length > maxLogLength) {
      messages.length = maxLogLength;
    }
    this.props.onSaveState({ messages });
  }
  sortData = (tempData) => {
    tempData.sort((g1, g2) => {
      return g1.iOrder - g2.iOrder;
    });
    return tempData;
  };
  /* 控制排序 */
  orderData = (e, name, type) => {
    const { [`${name}SelectedRowKeys`]: tableselectedRowKeys, app, slavePagination: slavePaginationOld } = this.props;
    let { [`${name}Data`]: currentData } = this.props;
    if (name === 'slave') {
      if (commonUtils.isEmptyArr(tableselectedRowKeys)) {
        message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请勾选要移动数据 */
        return;
      }
      if (commonUtils.isEmptyArr(currentData)) {
        message.warn(commonFunc.showMessage(app.commonConst, 'NoProcessData'));/* 请填写工序表数据 */
        return;
      }
      const tempData = [];

      for (const sId of tableselectedRowKeys) {
        let index = 0;
        const tableDataIndex = currentData.findIndex(item => item.sId === sId);
        if (tableDataIndex > -1) {
          const tableDataRow = JSON.parse(JSON.stringify(currentData[tableDataIndex]));
          if(commonUtils.isNotEmptyObject(tableDataRow)) {
            const iSelectedOrder = tableDataRow.iOrder + index + 100;
            const row = {...tableDataRow, iSelectedOrder : iSelectedOrder }
            tempData.push(row);
          }
        }
        index +=1;
      }

      const tempNew = commonUtils.isNotEmptyArr(tempData) ? JSON.parse(JSON.stringify(tempData)) : [];
      if (commonUtils.isEmptyArr(tempNew)) {
        message.warn(commonFunc.showMessage(app.commonConst, 'pleaseChooseMoveData'));/* 请选择要移动数据 */
        return;
      }
      const len = currentData.length;
      currentData = this.orderNum(currentData);
      const newLen = tempNew.length;
      let num = 0.01;/* 循环增加体 */
      let targetiOrder = -1;
      if (type === 1) { /*  上移 */
        const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[0].sSlaveId);/* 选中第一个节点的下标 */
        if (iIndex === 0) {
          if (newLen === 1) {
            message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */
            return;
          } else {
            targetiOrder = 0;
          }
        } else if (iIndex === 1 && currentData[0].sDivRowNew) {
          message.warn(commonFunc.showMessage(app.commonConst, 'NoUp'));/* 无需上移 */
          return;
        } else {
          targetiOrder = currentData[iIndex - 1].iOrder - 1; /* 目标排序号 */
        }
      } else if (type === 2) { /*  下移 */
        const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[newLen - 1].sSlaveId);/* 选中最后一个节点的下标 */
        if (iIndex === len - 1) {
          if (newLen === 1) {
            message.warn(commonFunc.showMessage(app.commonConst, 'NoDown')); /* 无需下移 */
            return;
          } else {
            targetiOrder = currentData[iIndex].iOrder;
          }
        } else {
          targetiOrder = currentData[iIndex + 1].iOrder;
        }
      } else if (type === 0) { /*  置顶 */
        const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[0].sSlaveId);/* 选中第一个节点的下标 */
        if (iIndex === 0) {
          if (newLen === 1) {
            message.warn(commonFunc.showMessage(app.commonConst, 'NoTop')); /* 无需置顶 */
            return;
          } else {
            targetiOrder = currentData[iIndex].iOrder;
          }
        } else if (iIndex === 1 && currentData[0].sDivRowNew) {
          message.warn(commonFunc.showMessage(app.commonConst, 'NoTop'));/* 无需置顶 */
          return;
        } else if (currentData[0].sDivRowNew) { /* 如果顶层有分割 */
          targetiOrder = currentData[1].iOrder - 1;
        } else {
          targetiOrder = currentData[0].iOrder - 1;
        }
      } else if (type === 3) { /*  置底 */
        const iIndex = currentData.findIndex(item => item.sSlaveId === tempNew[newLen - 1].sSlaveId);/* 选中最后一个节点的下标 */
        if (iIndex === len - 1) {
          if (newLen === 1) {
            message.warn(commonFunc.showMessage(app.commonConst, 'NoBottom')); /* 无需置底 */
            return;
          } else {
            targetiOrder = currentData[iIndex].iOrder;
          }
        } else {
          targetiOrder = currentData[len - 1].iOrder + 1;
        }
      }
      tempNew.forEach((item) => {
        const index1 = currentData.findIndex(item1 => item1.sSlaveId === item.sSlaveId);
        currentData[index1] = { ...item, iOrder: targetiOrder + num, handleType: 'update' };
        num += 0.01;
      });
      currentData = this.sortData(currentData);
      currentData = this.orderNum(currentData);
      const iIndex = currentData.findIndex(item => item.sSlaveId === tableselectedRowKeys[0]);
      const slavePagination = { ...slavePaginationOld };
      slavePagination.current = Math.ceil((iIndex + 1) / commonConfig.pageSize);
      this.props.onSaveState({ [`${name}Data`]: currentData, slavePagination });
    } else if (name === 'slaveInfo') {
      const { slaveData, slaveSelectedRowKeys, masterData }= this.props;
      if(commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
        message.error('请选择一行数据!');
        return;
      }
      if(commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(masterData)) {
        const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId) && commonUtils.isEmptyObject(item.sDivRowNew)); /* 找不是sDivRow的选中行第一条 */
        if (iIndex > -1) {
          masterData.sMachineId = slaveData[iIndex].sMachineId;
          masterData.sMachineName = slaveData[iIndex].sMachineName;
          masterData.sWorkCenterId = slaveData[iIndex].sWorkCenterId;
          masterData.sWorkCenterName = slaveData[iIndex].sWorkCenterName;
        }
      }
      this.props.onSaveState({ isChangeMachine: true, masterData });
    }
  };
  /* 自定义排序号 */
  orderNum = (tableData) => {
    const {slaveColumn} = this.props;
    tableData.forEach((item, index) => {
      item.iOrder = index + 1;
      item.handleType = 'update';
    });
    /* 移动后 重新计算分割间隔条数及用时逻辑 */
    const returnFilterData = tableData.filter(item => commonUtils.isNotEmptyObject(item.sDivRowNew) && item.sDivRowNew !=='');
    if (commonUtils.isNotEmptyArr(returnFilterData)) {
      returnFilterData.forEach((tableDataRow, index) => {
        /* 找到白班与晚班区间的汇总条数与工时 */
        let startIndex = 0; /* 找到开始下标 */
        let endindex = 0; /* 找到结束下标 */
        let sliceData =[];
        startIndex = tableData.findIndex(item => item.sId === returnFilterData[index].sId);
        if(index +1 < returnFilterData.length) {
          endindex = tableData.findIndex(item => item.sId === returnFilterData[index + 1].sId);
        }
        if(index === returnFilterData.length -1) {
          endindex =  tableData.length;
        }
        if(startIndex < endindex) {
          sliceData= tableData.slice(startIndex + 1, endindex);
        }
        let num =  0;
        let dTime = 0;
        let dPlateQty = 0; /* 付版 */
        let dProcessQty = 0;
        let endTime;
        /* 找到第二个字段 */
        const scheduleShow = ['16508090850002295893127095467000'].includes(this.props?.sModelsId);
        let timeSName = 'dHour1';
        if (scheduleShow) timeSName = 'dSumHour';
        if(commonUtils.isNotEmptyArr(sliceData)) {
          num = sliceData.length;
          sliceData.forEach((item) => {
            if (commonUtils.isNotEmptyNumber(item[timeSName])) {
              dTime += item[timeSName];
              dPlateQty += item.dPlateQty;
              dProcessQty  += item.dProcessQty;
              if (item?.tEndDate) {
                let value = item.tEndDate;
                if (endTime) {
                  value = moment.max(moment(endTime), moment(item.tEndDate));
                }
                endTime = value;
              }
              const iSrcIndex = tableData.findIndex(itemReturn => itemReturn.sSlaveId === item.sSlaveId); /* 汇总的每行上都加newRow的sSlaveId作为父级Id */
              if(iSrcIndex > -1) {
                tableData[iSrcIndex] = {...tableData[iSrcIndex], sDivRowParentId : tableDataRow.sSlaveId, sDivRowTmp : tableDataRow.sDivRowNew}
              }
            }
          });
          let sCount = '';
          if(num > 0) {
            sCount += 'F'+ num + '单';
          }
          if(dProcessQty > 0) {
            sCount += ' - '+ dProcessQty;
          }
          if(sliceData[0].sType === "1" && !scheduleShow) {
            sCount += ' - ' + dPlateQty +'付版';
          }
          if(dTime > 0) {
            if (scheduleShow) {
              sCount +=  ' - ' + Math.floor(dTime / 24) + "d" + (dTime % 24).toFixed(2) + 'h';
            } else {
              sCount +=  ' - ' +  (dTime/60).toFixed(2) + 'h';
            };

          }
          if (endTime) {
            sCount += ' - ' + moment(endTime).format('MM月DD日');
          }
          const sFileName = commonUtils.isNotEmptyArr(slaveColumn) && slaveColumn.length > 2 ?  slaveColumn[1].dataIndex : '';
          if(sCount && sFileName) {
            const addState ={};
            addState[sFileName] = tableDataRow.sDivRowNew + sCount;
            tableData[startIndex] = {...tableData[startIndex] , ...addState}
          }
        }
      });
    }
    return tableData;
  };
  /* 切换甘特图/列表视图 */
  changeGantt = (e, type) => {
    let bGantt = false;
    if (type === 'gantt') {
      const { slaveFilterCondition } = this.props;
      bGantt = true;
      /* 调用获取甘特图数据 */
      const chart = {};
      chart.sProcedureName = 'Sp_Process_CommonGtChar';
      chart.paramsMap = {
      };
      this.props.onGanttChar(chart, slaveFilterCondition).finally(() => {
        this.props.onSaveState({ pageLoading: false });
      });
    } else if (type === 'list') {
      bGantt = false;
    }
    this.props.onSaveState({ bGantt });
  };
  /* 切换稽查列表 */
  changeCheckModel= async (e, type) => {
    if (type === 'checkModel') {
      if (this.state.checkModelStatus) {
        return;
      }
      this.setState({
        checkModelStatus: true
      })
      const { slaveFilterCondition } = this.props;
      /* 调用获取甘特图数据 */
      const chart = {};
      chart.sProcedureName = 'Sp_Manufacture_GetAPSstate';
      chart.paramsMap = {
      };
      await this.props.onCheckModel(chart, slaveFilterCondition);
      this.setState({
        checkModelStatus: false
      })
    }
  };
  /* 弹出重算时间弹窗 */
  showTimerModal= (e, type) => {
    if (type === 'changeTimer') {
      this.props.onChangeTimerPro();
    }
  };
  /* 侧边保存 */
  showSave= (e, type) => {
    if (type === 'save') {
      this.props.onSaveState({
        pageLoading: true,
      });
      setTimeout(async() => {
        this.props.onSubmit(); /* 调用保存 */
      }, 500);
    }
  };
  /* 侧边保存 */
  showLock= (e, type) => {
    if (type === 'lock') {
      this.props.onShowLockPro();
    }
  };

  showLock= (e, type) => {
    if (type === 'lock') {
      this.props.onShowLockPro();
    }
  };
  showOverExec= (e, type) => {
    if (this.props.onShowOverExecPro) {
      this.props.onShowOverExecPro();
    }
  };
  /**   处理选择行发生改变   */
  // handleTableFilterData = (name, data, record) => {
  //   /*   外置处理业务   */
  //   if (name === 'slave') {
  //     let slaveInfoDataNew = '';
  //     slaveInfoDataNew = data.filter(item => record.sSlaveId.split(',').includes(item.sId));
  //     return slaveInfoDataNew;
  //   }
  // };
  /**   处理card点击事件 */
  handleTabsCallback = (child) => {
    // if (commonUtils.isNotEmptyArr(this.props.teamData)) {
    //   child.cardSelectedColor = '#fff7e6';
    //   const iIndex = this.props.teamData.findIndex(item => item.sId === child.sId);
    //   const teamDataNew = this.props.teamData;
    //   teamDataNew.forEach((item, index) => {
    //     if (index !== iIndex) { item.cardSelectedColor = ''; }
    //   });
    // }
    // this.props.onSaveState({ Loading: true });
    this.props.onTabsCallback(child);
  };

  toggleSlide = () => {
    let flag = this.state.slideFlag ? 0 : 1;
    localStorage.setItem('treeSlide_' + this.props.sModelsId, flag);
    this.setState({
      slideFlag: flag
    })
  }

  handleSlideToggle = () => {
    if (this.state.slideFlag) {
      this.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].style.display = 'block';
      const originWidth = this.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].offsetWidth;
      this.treeDiv.getElementsByClassName('productionScheduleTree-content')[0].style.width = `calc(100% - ${originWidth + 10}px)`;
      this.toggleSlide();
    } else {
      this.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].style.display = 'none';
      this.treeDiv.getElementsByClassName('productionScheduleTree-content')[0].style.width = `calc(100%)`;
      this.toggleSlide();
    }
  }

  resetTreeKey = () => {
    this.setState({
      defaultKey: 'selected'
    })
  }

  setBMachine = (flag) => {
    this.bMachine = flag
  }

  componentDidMount() {
    if (!this.state.slideFlag) {
      this.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].style.display = 'block';
      const originWidth = this.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].offsetWidth;
      this.treeDiv.getElementsByClassName('productionScheduleTree-content')[0].style.width = `calc(100% - ${originWidth + 10}px)`;
    } else {
      this.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].style.display = 'none';
      this.treeDiv.getElementsByClassName('productionScheduleTree-content')[0].style.width = `calc(100%)`;
    }
  }
  // handleGanttChar = async (ganttChart) => {
  //   const { token, sModelsId, formRoute, slaveFilterCondition } = this.props;
  //   let charGanttData = {};
  //   const value = {
  //     sProName: ganttChart.sProcedureName,
  //     paramsMap: ganttChart.prodParamsMap,
  //     bFilter: slaveFilterCondition,
  //   };
  //   const url = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}&sName=${formRoute}`;
  //   const { data: returnData } = await commonServices.postValueService(token, value, url);
  //   console.log('returnData', returnData);
  //   if (returnData.code === 1) {
  //     const { dataset } = returnData;
  //     if (commonUtils.isNotEmptyObject(dataset)) {
  //       const outData = returnData.dataset.rows[0].dataSet.outData[0];
  //       if (outData.sCode === -1) {
  //         message.error(outData.sReturn);
  //       } else {
  //         charGanttData = commonUtils.isEmpty(outData.sReturn) ? [] : JSON.parse(outData.sReturn);
  //       }
  //     }
  //   } else {
  //     message.error(returnData.msg);
  //   }
  //   console.log('charGanttData', charGanttData);
  //   this.props.onSaveState({ charGanttData });
  // };
  // renderCards = (data) => {
  //   let showInfo = '';
  //   data.map((item) => {
  //     showInfo += (
  //       <Col span={4}>
  //         <Card title={item.sTeamName} bordered={false}>
  //           {item.sTeamName} {item.dHour} {'30%'}
  //         </Card>
  //       </Col>
  //     );
  //   });
  //   return showInfo;
  // }
  render() {
    const { pageLoading, treeLoading } = this.props;
    return (
      <div className="product-plan-info-box">
        <Spin spinning={pageLoading || treeLoading} style={{ height: '100%' }}>
          <div ref={(ref) => this.treeDiv = ref} style={{ height: '100%' }}>
            <ProductionScheduleComponent
              style={{ height: '100%' }}
              {...this.props}
              {...this.state}
              treeDiv={this.treeDiv}
              toggleSlide={this.toggleSlide }
              handleSlideToggle={this.handleSlideToggle}
              bMachine={this.bMachine}
              showSetMachine={this.showSetMachine}
              setBMachine={this.setBMachine}
              filterCondition={this.filterCondition}
              onTableFilterData={this.handleTableFilterData}
              onRowClick={this.onRowClick}
              onDoubleClick={this.onDoubleClick}
              resetTreeKey={this.resetTreeKey}
              onRowMouseEnter={this.onRowMouseEnter}
              onRowMouseLeave={this.onRowMouseLeave}
              orderData={this.orderData}
              onTreeExpand={this.onTreeExpand}
              onPageChange={this.onPageChange}
              changeGantt={this.changeGantt}
              onCheckModel={this.changeCheckModel}
              onChangeTimer={this.changeTimer}
              onShowTimerModal={this.showTimerModal}
              onShowSave ={this.showSave}
              onShowLock ={this.showLock}
              onShowOverExec ={this.showOverExec}
              onCloseChangeMachine={this.onCloseChangeMachine}
              onTabsCallback={this.handleTabsCallback}
              onTableSelectRowChange={this.onTableSelectRowChange}
              onTreeExpandChange={this.onTreeExpandChange}
              onDataUpdated={this.logDataUpdate}
              onTaskUpdated={this.logTaskUpdate}
              onLinkUpdated={this.logLinkUpdate}
              treeData={this.props.treeData}
              refreshTreeData={this.props.refreshTreeData}
            />
          </div>
        </Spin>
      </div>
    );
  }
}

const ProductionScheduleComponent = Form.create({
  mapPropsToFields(props) {
    const { masterData } = props;
    const obj = commonFunc.mapPropsToFields(masterData, Form);
    return obj;
  },
})((props) => {
  const {
    form, onReturnForm, app, masterData, slaveData, slaveSelectedRowKeys, sModelsId, masterConfig, teamSelectedRowKeys, clearArray, slavePagination, planLoadingSate, bGantt, charGanttData, messages, slavePageSize, workOutsideSize, workOutConfirmSize,
    Loading, treeData, defaultSid, treeChild, pageSize, pageNum, onPageChange, sortEnabled, workOutsideColumn, workOutConfirmColumn, onTreeExpandChange, expandAll, onTreeExpand, expandedTreeKeys, gdsjurisdiction,
  } = props;
  const moveEnabled = commonUtils.isNotEmptyArr(slaveSelectedRowKeys);
  /*   回带表单s */
  onReturnForm(form);
  // const pageFlag = sStateSelect === '0' || sStateSelect === '1' || sStateSelect === '2';
  const pagination = {
    pageSize: commonConfig.pageSize,
    ...slavePagination,
    size: 'large',
    pageSizeOptions: commonConfig.pageSizeOptions,
    // showQuickJumper: true,
    hideOnSinglePage: false,
    showSizeChanger: true,
    current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current,
  };

  const paginationSlave = {
    pageSize: commonUtils.isNotEmptyNumber(slavePageSize) && slavePageSize !== 0 ? slavePageSize : commonConfig.pageSize,
    ...slavePagination,
    size: 'large',
    pageSizeOptions: commonConfig.pageSizeOptions,
    // showQuickJumper: true,
    hideOnSinglePage: false,
    showSizeChanger: true,
    current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current,
  };
  const paginationWorkOutside = {
    pageSize: commonUtils.isNotEmptyNumber(workOutsideSize) && workOutsideSize !== 0 ? workOutsideSize : commonConfig.pageSize,
    ...slavePagination,
    size: 'large',
    pageSizeOptions: commonConfig.pageSizeOptions,
    // showQuickJumper: true,
    hideOnSinglePage: false,
    showSizeChanger: true,
    current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current,
  };
  const paginationWorkOutConfirm = {
    pageSize: commonUtils.isNotEmptyNumber(workOutConfirmSize) && workOutConfirmSize !== 0 ? workOutConfirmSize : commonConfig.pageSize,
    ...slavePagination,
    size: 'large',
    pageSizeOptions: commonConfig.pageSizeOptions,
    // showQuickJumper: true,
    hideOnSinglePage: false,
    showSizeChanger: true,
    current: commonUtils.isEmptyObject(slavePagination) ? 1 : slavePagination.current,
  };
  const width = '18px';
  const height = '18px';
  const sLanguage = app?.userinfo?.sLanguage || 'sChinese';
  const moveUp = {
    title: '上移',
    width: { width },
    height: { height },
    img: <img src={MoveUp} alt="上移" width="24px" height="24px" />,
    disableimg: <img src={DisableMoveUp} alt="上移" width="24px" height="24px" />,
  };
  const moveDown = {
    title: '下移',
    width: { width },
    height: { height },
    img: <img src={MoveDown} alt="下移" width="24px" height="24px" />,
    disableimg: <img src={DisableMoveDown} alt="下移" width="24px" height="24px" />,
  };
  const moveTop = {
    title: '置顶',
    width: { width },
    height: { height },
    img: <img src={MoveTop} alt="置顶" width="24px" height="24px" />,
    disableimg: <img src={DisableMoveTop} alt="置顶" width="24px" height="24px" />,
  };
  const moveBottom = {
    title: '置底',
    width: { width },
    height: { height },
    img: <img src={MoveBottom} alt="置底" width="24px" height="24px" />,
    disableimg: <img src={DisableMoveBottom} alt="置底" width="24px" height="24px" />,
  };
  const changeMachine = {
    title: sLanguage === 'sEnglish' ? 'ChangeMachine' : '更换机台' ,
    width: { width },
    height: { height },
    img: <img src={sLanguage === 'sEnglish' ? ChangeMachineEnglish :ChangeMachine} alt="更换机台" style={{ width: '24px' }} />,
    disableimg: <img src={sLanguage === 'sEnglish' ? DisableChangeMachineEnglish : DisableChangeMachine} alt="更换机台" style={{ width: '24px' }} />,
  };
  const slideSave = {
    title: '侧边保存',
    width: { width },
    height: { height },
    img: <img src={sLanguage === 'sEnglish' ? SetSaveEnglish : SetSave} alt="保存" style={{ width: '24px' }} />,
    disableimg: <img src={sLanguage === 'sEnglish' ? DisableSetSaveEnglish : DisableSetSave} alt="保存" style={{ width: '24px' }} />,
  };
  const slideLock = {
    title: '侧边锁定',
    width: { width },
    height: { height },
    img: <img src={sLanguage === 'sEnglish' ? SetLockEnglish : SetLock} alt="锁定" style={{ width: '24px' }} />,
    disableimg: <img src={sLanguage === 'sEnglish' ? DisableSetLockEnglish :DisableSetLock} alt="锁定" style={{ width: '24px' }} />,
  };
  const slideOverExec = {
    title: '侧边超能力',
    width: { width },
    height: { height },
    img: <img src={sLanguage === 'sEnglish' ? SetOverExecEnglish : SetOverExec} alt="超能力" style={{ width: '24px' }} />,
    disableimg: <img src={sLanguage === 'sEnglish' ? DisableSetOverExecEnglish : DisableSetOverExec} alt="超能力" style={{ width: '24px' }} />,
  };
  const showGantt = {
    title: '查看Gantt',
    width: { width },
    height: { height },
    img: <img src={ShowGantt} alt="更换机台" width="24px" height="24px" />,
    disableimg: <img src={DisableShowGantt} alt="更换机台" width="24px" height="24px" />,
  };

  const showCheckModel = {
    title: '齐套稽查',
    width: { width },
    height: { height },
    img: <img src={sLanguage === 'sEnglish' ? ShowCheckModelEnglish : ShowCheckModel} alt="齐套稽查" width="24px" height="24px" />,
    disableimg: <img src={sLanguage === 'sEnglish' ? DisableShowCheckModelEnglish : DisableShowCheckModel} alt="齐套稽查" width="24px" height="24px" />,
  };

  const showTimer = {
    title: '重算时间',
    width: { width },
    height: { height },
    img: <img src={sLanguage === 'sEnglish' ? ShowTimerEnglish : ShowTimer} alt="重算时间" width="24px" height="24px" />,
    disableimg: <img src={sLanguage === 'sEnglish' ? DisableShowTimerEnglish : DisableShowTimer} alt="重算时间" width="24px" height="24px" />,
  };
  const showList = {
    title: '查看列表',
    width: { width },
    height: { height },
    img: <img src={ShowList} alt="更换机台" width="24px" height="24px" />,
    disableimg: <img src={DisableShowList} alt="更换机台" width="24px" height="24px" />,
  };
  const resetSearch = {
    title: '重置搜索',
    width: { width },
    height: { height },
    img: <img src={Reset} alt="重置搜索" width="24px" height="24px" />,
    disableimg: <img src={DisableReset} alt="重置搜索" width="24px" height="24px" />,
  };
  const addProps = {};
  //
  // 前端假分页数据
  // let tablePageData = commonBusiness.getTableTypes('slave', props).data;
  // if (tablePageData) {
  //   tablePageData = commonBusiness.getTableTypes('slave', props).data.slice(pageSize * (pageNum - 1), pageSize * pageNum);
  // }

  // 从表原始数据
  const tableProps = {
    ...commonBusiness.getTableTypes('slave', props),
    // onTableFilterData: props.onTableFilterData,
    bMutiSelect1: true,
    tableProps: {
      rowKey: 'sSlaveId',
      pagination: paginationSlave,
      sortSelf: true,
      onRow: (record) => {
        return {
          onClick: () => { props.onRowClick('slave', record, true); },
          // onDoubleClick: () => { props.onDoubleClick('slave', record); },
          // onMouseEnter: () => { props.onRowMouseEnter('slave', record); },
          // onMouseLeave: () => { props.onRowMouseLeave('slave',record); },
        };
      },
      onChange: props.onTitleChange.bind(this, 'slave'),
    },
    rowHoverSid : props.rowHoverSid,
    clearArray: props.clearArray,
  };

  const workOutsideProps = {
    ...commonBusiness.getTableTypes('slave', props),
    onTableFilterData: props.onTableFilterData,
    bMutiSelect1: true,
    tableProps: {
      rowKey: 'sSlaveId',
      pagination: paginationWorkOutside,
      sortSelf: true,
      onRow: (record) => {
        return {
          onClick: () => { props.onRowClick('slave', record, true); },
          onDoubleClick: () => { props.onDoubleClick('slave', record); },
          // onMouseEnter: () => { props.onRowMouseEnter('slave', record); },
        };
      },
      onChange: props.onTitleChange.bind(this, 'slave'),
    },
    headerColumn: workOutsideColumn,
    clearArray: props.clearArray,
  };

  const workOutConfirmProps = {
    ...commonBusiness.getTableTypes('slave', props),
    onTableFilterData: props.onTableFilterData,
    bMutiSelect1: true,
    tableProps: {
      rowKey: 'sSlaveId',
      pagination: paginationWorkOutConfirm,
      sortSelf: true,
      onRow: (record) => {
        return {
          onClick: () => { props.onRowClick('slave', record, true); },
          onDoubleClick: () => { props.onDoubleClick('slave', record); },
          // onMouseEnter: () => { props.onRowMouseEnter('slave', record); },
        };
      },
      onChange: props.onTitleChange.bind(this, 'slave'),
    },
    headerColumn: workOutConfirmColumn,
    clearArray: props.clearArray,
  };
  const tableInfoProps = {
    ...commonBusiness.getTableTypes('slaveInfo', props),
    bMutiSelect1: true,
    tableProps: {
      rowKey: 'sId',
      pagination,
      planLoadingSate,
      onRow: (record) => {
        return {
          onClick: () => { props.onRowClick('slaveInfo', record); },
          onDoubleClick: () => { props.onDoubleClick('slaveInfo', record); },
          // onMouseEnter: () => { props.onRowMouseEnter('slaveInfo', record); },
        };
      },
      onChange: props.onTitleChange.bind(this, 'slaveInfo'),
    },
    // data: commonUtils.isNotEmptyObject(props.slaveInfoDataNew) ? props.slaveInfoDataNew : props.slaveInfoData,
  };
  let zoom = {};
  zoom.scale = 'Minutes';
  zoom.step = '10'; /* 间隔 */
  if (commonUtils.isNotEmptyObject(charGanttData)) {
    zoom = charGanttData.zoom;
  }
  const ganttProps = {
    // ...commonBusiness.getGanttTypes('slave', props),
    tasks: commonUtils.isNotEmptyObject(charGanttData) ? charGanttData : {}, /* 甘特图数据源 */
    zoom: commonUtils.isNotEmptyObject(zoom) ? zoom : {},
    onDataUpdated: props.onDataUpdated,
  };
  const gridStyle = {
    width: '100%',
    textAlign: 'left',
  };
  const setUp = commonFunc.showMessage(app.commonConst, 'setUp');/* 上移 */
  const setDown = commonFunc.showMessage(app.commonConst, 'setDown');/* 下移 */
  const setTop = commonFunc.showMessage(app.commonConst, 'setTop');/* 置顶 */
  const setBottom = commonFunc.showMessage(app.commonConst, 'setBottom');/* 置底 */
  const setMachine = commonFunc.showMessage(app.commonConst, 'changeMachine');/* 更换机台 */
  const setCheck = commonFunc.showMessage(app.commonConst, 'fullCheck');/* 齐套稽查 */
  const setCalTime = commonFunc.showMessage(app.commonConst, 'calTime');/* 重算时间 */
  const setSave = commonUtils.isNotEmptyObject(commonFunc.showMessage(app.commonConst, 'setSave')) ? commonFunc.showMessage(app.commonConst, 'setSave') : '保存';/* 保存 */
  const setLock = commonFunc.showMessage(app.commonConst, 'setLock') ? commonFunc.showMessage(app.commonConst, 'setLock')  : '锁定';/* 锁定 */
  const setOverExec = commonFunc.showMessage(app.commonConst, 'setOverExec') ? commonFunc.showMessage(app.commonConst, 'setOverExec') :'超能力';/* 超 */
  // const resetSearchEnabled = clearArray.length > 0;

  const setResetSearch = commonFunc.showMessage(app.commonConst, 'setResetSearch');/* 重置搜索 */
  const resetSearchEnabled = true;
  // const iMachineIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sMachineId');
  const iMachineIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sMachineName'); /* 以sMachineName */


  /* 根据权限控制 */
  let bSetTop = true; /* 置顶 */
  let bSetDown = true; /* 置底 */
  let bSetUp = true; /* 上移  */
  let bSetBottom = true; /* 下移 */
  let bSetMachine = true; /* 更换机台
  // let bResetSearch = true; */
  let bSetList = true; /* 显示列表 */
  let bSetGantt = true;  /* 显示甘特图 */
  let bSetCheckModel = true; /* 齐套稽查 */
  let bSetTimer = true; /* 改变时间 */
  let bSetOverExec = true; /* 超能力 */
  let bSetSave = true; /* 保存 */
  let bSetLock = true; /* 锁定 */
  if (commonUtils.isNotEmptyArr(gdsjurisdiction)){
    bSetTop = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetTop') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetDown = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetDown') === -1 ? true : false;
    bSetUp = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetUp') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetBottom = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetBottom') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetMachine = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetMachine') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetList = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetList') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetGantt = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetGantt') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetCheckModel = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetCheckModel') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetTimer = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetTimer') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetSave = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetSave') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetOverExec = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetOverExec') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
    bSetLock = gdsjurisdiction.findIndex(item => item.sAction === 'BtnSlideSetLock') === -1 ? true : false; /* 没显示 代表有权限  否则没有权限 */
  }

  const machineShowTypeProps = {
    app,
    record: masterData,
    name: 'master',
    form: props.form,
    formId: sModelsId,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getFloatNum: props.getFloatNum,
    getDateFormat: props.getDateFormat,
    onChange: props.onChange,
    showConfig: iMachineIndex > -1 ? masterConfig.gdsconfigformslave[iMachineIndex] : {},
    formItemLayout: {},
    enabled: true,
    dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sMachineName,
    bTable: false,
    onFilterDropDownData: props.onFilterDropDownData,
  };
  const iTeamIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sTeamId');
  const teamShowTypeProps = {
    app,
    record: masterData,
    name: 'master',
    form: props.form,
    formId: sModelsId,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getFloatNum: props.getFloatNum,
    getDateFormat: props.getDateFormat,
    onChange: props.onChange,
    showConfig: iTeamIndex > -1 ? masterConfig.gdsconfigformslave[iTeamIndex] : {},
    formItemLayout: {},
    enabled: true,
    dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sTeamId,
    bTable: false,
    onFilterDropDownData: props.onFilterDropDownData,
  };
  const iWorkCenterIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'sWorkCenterName');
  // if(commonUtils.isNotEmptyArr(slaveData) && commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmptyObject(masterData.sMachineId)) {
  //   const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId) && commonUtils.isEmptyObject(item.sDivRowNew)); /* 找不是sDivRow的选中行第一条 */
  //   if (iIndex > -1) {
  //     if (slaveData[iIndex] && slaveData[iIndex].sMachineId) {
  //       masterData.sMachineId = slaveData[iIndex].sMachineId;
  //       masterData.sMachineName = slaveData[iIndex].sMachineName;
  //       masterData.sWorkCenterId = slaveData[iIndex].sWorkCenterId;
  //       masterData.sWorkCenterName = slaveData[iIndex].sWorkCenterName;
  //     }
  //   }
  // }
  const workCenterProps = {
    app,
    record: masterData,
    name: 'master',
    form: props.form,
    formId: sModelsId,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getFloatNum: props.getFloatNum,
    getDateFormat: props.getDateFormat,
    onChange: props.onChange,
    showConfig: iWorkCenterIndex > -1 ? masterConfig.gdsconfigformslave[iWorkCenterIndex] : {},
    formItemLayout: {},
    enabled: true,
    dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.sWorkCenterName,
    bTable: false,
    onFilterDropDownData: props.onFilterDropDownData,
  };

  const iStartIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'tStartDate');
  const startShowTypeProps = {
    app,
    record: masterData,
    name: 'master',
    form: props.form,
    formId: sModelsId,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getFloatNum: props.getFloatNum,
    getDateFormat: props.getDateFormat,
    onChange: props.onChange,
    showConfig: iStartIndex > -1 ? masterConfig.gdsconfigformslave[iStartIndex] : {},
    formItemLayout: {},
    enabled: true,
    dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.tStartDate,
    bTable: false,
    onFilterDropDownData: props.onFilterDropDownData,
  };

  const bSplitIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'bSplit');
  const splitShowTypeProps = {
    app,
    record: masterData,
    name: 'master',
    form: props.form,
    formId: sModelsId,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getFloatNum: props.getFloatNum,
    getDateFormat: props.getDateFormat,
    onChange: props.onChange,
    showConfig: bSplitIndex > -1 ? masterConfig.gdsconfigformslave[bSplitIndex] : {},
    formItemLayout: {},
    enabled: true,
    dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.bSplit,
    bTable: false,
    onFilterDropDownData: props.onFilterDropDownData,
  };

  const iSplitNumIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'iSplitNum');
  const splitNumShowTypeProps = {
    app,
    record: masterData,
    name: 'master',
    form: props.form,
    formId: sModelsId,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getFloatNum: props.getFloatNum,
    getDateFormat: props.getDateFormat,
    onChange: props.onChange,
    showConfig: iSplitNumIndex > -1 ? masterConfig.gdsconfigformslave[iSplitNumIndex] : {},
    formItemLayout: {},
    enabled: true,
    dataValue: commonUtils.isEmptyObject(masterData) ? '' : masterData.iSplitNum,
    bTable: false,
    onFilterDropDownData: props.onFilterDropDownData,
  };

  const iProcessSyQtyIndex = commonUtils.isEmptyObject(masterConfig) ? -1 : masterConfig.gdsconfigformslave.findIndex(item => item.sName === 'dProcessSyQty');
  /* 剩余数量 */
  const iProcessSyQtyProps = {
    app,
    record: masterData,
    name: 'master',
    form: props.form,
    formId: sModelsId,
    getSqlDropDownData: props.getSqlDropDownData,
    getSqlCondition: props.getSqlCondition,
    handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
    getFloatNum: props.getFloatNum,
    getDateFormat: props.getDateFormat,
    onChange: props.onChange,
    showConfig: iProcessSyQtyIndex > -1 ? masterConfig.gdsconfigformslave[iProcessSyQtyIndex] : {},
    formItemLayout: {},
    enabled: true,
    dataValue: commonUtils.isEmptyObject(masterData) ? 0 :  masterData.dProcessSyQty,
    bTable: false,
    onFilterDropDownData: props.onFilterDropDownData,
  };



  let searchWorkSchedule = {};
  let workScheduleConfig = {};
  let searchWorkTitle = '';
  if (commonUtils.isNotEmptyObject(props.workScheduleConfig)) {
    workScheduleConfig = props.workScheduleConfig;
    searchWorkTitle = workScheduleConfig.sActiveName;
    const sWorkOrderId = commonUtils.isNotEmptyObject(props.workScheduleRecord) ? props.workScheduleRecord.sWorkOrderId : '';
    searchWorkSchedule = {
      app: {
        ...props.app,
        currentPane: {
          name: 'workSchedule',
          config: workScheduleConfig,
          conditonValues: props.getSqlCondition(workScheduleConfig),
          title: workScheduleConfig.sActiveName,
          route: '/indexPage/commonList',
          formRoute: '/indexPage/commonList',
          formId: workScheduleConfig.sActiveId,
          key: sModelsId + workScheduleConfig.sId,
          sModelsType: 'search/workSchedule',
          bFilterProName: 'p_sWorkOrderId_pro',
          bFilterProValue: sWorkOrderId,
          // select: props.onSelect,
          // selectCancel: props.onSelectCancel,
        },
      },
      dispatch: props.dispatch,
      content: props.content,
      id: new Date().getTime().toString(),
      realizeHeight: props.realizeHeight, /* 拖动偏移高度s */
      bNotShowBtn: true,
      rowSelection: null,
    };
  }

  let searchWorkMaterialsStatus = {};
  let workMaterialsStatusConfig = {};
  let searchMaterialsStatusTitle = '';
  if (commonUtils.isNotEmptyObject(props.workMaterialsStatusConfig)) {
    workMaterialsStatusConfig = props.workMaterialsStatusConfig;
    searchMaterialsStatusTitle = workScheduleConfig.sActiveName;
    // const sWorkOrderId = commonUtils.isNotEmptyObject(props.workMaterialsStatusRecord) ? props.workMaterialsStatusRecord.sWorkOrderId : '';
    searchWorkMaterialsStatus = {
      app: {
        ...props.app,
        currentPane: {
          name: 'workSchedule',
          config: workMaterialsStatusConfig,
          conditonValues: props.getSqlCondition(workMaterialsStatusConfig),
          title: workScheduleConfig.sActiveName,
          route: '/indexPage/commonList',
          formRoute: '/indexPage/commonList',
          formId: workMaterialsStatusConfig.sActiveId,
          key: sModelsId + workMaterialsStatusConfig.sId,
          sModelsType: 'search/workSchedule',
          bFilterProName: 'p_sWorkOrderId_pro',
          // bFilterProValue: sWorkOrderId,
          // select: props.onSelect,
          // selectCancel: props.onSelectCancel,
        },
      },
      dispatch: props.dispatch,
      content: props.content,
      id: new Date().getTime().toString(),
      realizeHeight: props.realizeHeight, /* 拖动偏移高度s */
      bNotShowBtn: true,
      rowSelection: null,
    };
  }


  /* 历史日产量 */
  let sHistoryQtyProps = {};
  let sHistoryQtyConfig = {};
  let sHistoryQtyTitle = '';
  if (commonUtils.isNotEmptyObject(props.sHistoryQtyConfig)) {
    sHistoryQtyConfig = props.sHistoryQtyConfig;
    sHistoryQtyTitle = sHistoryQtyConfig.sActiveName;
    const sHistoryQtyRecord = props.sHistoryQtyRecord;
    sHistoryQtyProps = {
      app: {
        ...props.app,
        currentPane: {
          name: 'workSchedule',
          config: workScheduleConfig,
          conditonValues: props.getSqlCondition(sHistoryQtyConfig, 'slave', sHistoryQtyRecord),
          title: sHistoryQtyConfig.sActiveName,
          route: '/indexPage/commonList',
          formRoute: '/indexPage/commonList',
          formId: sHistoryQtyConfig.sActiveId,
          key: sModelsId + sHistoryQtyConfig.sId,
          sModelsType: 'search/sHistoryQty',
        },
      },
      dispatch: props.dispatch,
      content: props.content,
      id: new Date().getTime().toString(),
      realizeHeight: props.realizeHeight, /* 拖动偏移高度s */
      bNotShowBtn: true,
      rowSelection: null,
    };
  }

  let selectedRowKey = {};
  if (commonUtils.isNotEmptyArr(teamSelectedRowKeys)) {
    selectedRowKey = teamSelectedRowKeys[0];
  }

  let teamDataNum = 0;
  if (commonUtils.isNotEmptyArr(props.teamData)) {
    // 取得导航按钮的行数
    if (props.teamData.length % 8 === 0) {
      teamDataNum = (props.teamData.length / 8);
    } else {
      teamDataNum = Math.ceil(props.teamData.length / 8);
    }
  }

  const handleTreeOnSelect = (keys, e) => {
    window.vlistNewSearh = true;
    props.resetTreeKey();
    props.setBMachine(e.node.sType == "machine")
    const child = e.selectedNodes.length ? e.node.props.dataRef : false;
    if (child) {
      props.onTabsCallback(child);
      onPageChange(1);
    }
  };

  const renderTreeNodes = (data, pid) =>
    data.map((item, index) => {
      if (item.children) {
        return (
          <TreeNode
            title={
              <div className={`${item.sType}-node`}>
                {item.sShowName}
                {item.dHour ? <span className="hour-info">{item.dHour}</span> : ''}
                {(item.dSumProductionReportQty && item.dHour) ? <span className="hour-info">/</span> : ''}
                {item.dSumProductionReportQty ? <span className="hour-info">{item.dSumProductionReportQty}</span> : ''}
              </div>
          }
            key={item.sId + item.sWorkCenterId}
            dataRef={{ ...item, pid: pid || 0 }}
          >
            {renderTreeNodes(item.children, item.sId)}
          </TreeNode>
        );
      }
      return <TreeNode title={
        <div className={`${item.sType}-node`}>
          {item.sShowName}
          {item.dHour ? <span className="hour-info">{item.dHour}</span> : ''}
          {(item.dSumProductionReportQty && item.dHour) ? <span className="hour-info">/</span> : ''}
          {item.dSumProductionReportQty ? <span className="hour-info">{item.dSumProductionReportQty}</span> : ''}
        </div>
      } dataRef={{ ...item, pid: pid || 0 }} {...item} key={item.sId + item.sWorkCenterId} />;
    });

  const handleResizeLayout = (e) => {
    const originX = e.pageX;
    const originWidth = props.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].offsetWidth;
    let offset = 0;
    window.onmousemove = function (e2) {
      offset = e2.pageX - originX;
      props.treeDiv.getElementsByClassName('productionScheduleTree-sider')[0].style.width = `${originWidth + offset}px`;
      props.treeDiv.getElementsByClassName('productionScheduleTree-content')[0].style.width = `calc(100% - ${originWidth + offset + 10}px)`;
    };
    window.onmouseup = function () {
      window.onmousemove = null;
      window.onmousemove = null;
      localStorage.setItem('customProductionScheduleTreeWidth_' + props.sModelsId, originWidth + offset + 10);
    };
  };

  let customWidth = 224;
  if (localStorage.getItem('customProductionScheduleTreeWidth_' + props.sModelsId) !== '') {
    customWidth = localStorage.getItem('customProductionScheduleTreeWidth_' + props.sModelsId);
  }

  const renderTable = () => {
    let res = '';
    if (treeChild.sType === 'workoutsid') {
      res = (<StaticEditTable {...workOutsideProps} className="subForm" slaveInfo={props.slaveInfoConfig ? tableInfoProps : undefined} skipSlaveInfo={props.slaveInfoConfig ? false: true} setExpandedRowRender={props.slaveInfoConfig ? "Y" : 'N'} />);
    } else if (treeChild.sType === 'workoutconfirm') {
      res = (<StaticEditTable {...workOutConfirmProps} className="subForm" slaveInfo={props.slaveInfoConfig ? tableInfoProps : undefined} skipSlaveInfo={props.slaveInfoConfig ? false: true} setExpandedRowRender={props.slaveInfoConfig ? "Y" : 'N'} />);
    } else {
      res = (<StaticEditTable {...tableProps} className="subForm" slaveInfo={props.slaveInfoConfig ? tableInfoProps : undefined} skipSlaveInfo={props.slaveInfoConfig ? false: true} setExpandedRowRender={props.slaveInfoConfig ? "Y" : 'N'}/>);
    }
    return res;
  };
  /* 增加Modal按钮样式 */
  const okProps = {};
  if (props.loadingTimer !== undefined) {
    // okProps.disabled = !props.bChangeTimerEnable;
    okProps.loading = props.loadingTimer;
  }
  const WorkCenter = commonFunc.showLocalMessage(props, "WorkCenter", "工作中心");
  return (
    <Form style={{ height: '100%' }}>
      <Layout style={{ height: '100%' }} className="xly-productionPlan-list productionScheduleTree">
        <Header className={styles.header} style={{ backgroundColor: 'rgb(100, 100, 100)' }}>
          <Toolbar {...props} className="billBtnGroup" style={{ backgroundColor: '#646464', color: 'rgb(255,255,255)' }} />
        </Header>
        <Layout className={styles.clayout} style={{ height: '100%' }} >
          <div className="search-container">
            <SearchComponent {...props} />
          </div>
          <div className="productionScheduleTree-container">
            <div className="productionScheduleTree-sider" style={{ width: `${customWidth}px`, marginRight: '10px' }}>
              <div className="resize-controller" onMouseDown={handleResizeLayout} />
              <div className="productionScheduleTree-sider-title">
                <Icon type={expandAll ? 'minus-square' : 'plus-square'} className="control-icon" onClick={onTreeExpandChange} />
                <span>{WorkCenter}</span>
              </div>
              <div className="productionScheduleTree-sider-content">
                {
                  props.slideFlag == 0 && treeData.length > 0 && (
                    <Tree
                      showLine
                      onSelect={handleTreeOnSelect}
                      onExpand={onTreeExpand}
                      // selectedKeys={[treeChild.sId + treeChild.sProcessId + treeChild.iOrder]}
                      selectedKeys={Array.isArray(props.defaultKey) ? props.defaultKey : [treeChild.sId + treeChild.sWorkCenterId]}
                      defaultExpandAll={expandAll}
                      expandedKeys={expandedTreeKeys}
                    >
                      {renderTreeNodes(treeData)}
                    </Tree>
                  )
                }
              </div>
            </div>
            <div className="productionScheduleTree-content" style={{ width: props.slideFlag == 0 ? `calc(100% - ${customWidth}px - 10px)` : `calc(100%)` }}>
              <Layout style={{marginLeft: 0}} className={['processList', 'processListTable'].join(' ')}>
                <Sider className="process">
                  <a onClick={props.handleSlideToggle}>
                    {props.slideFlag == 0 && <MenuFoldOutlined style={{ fontSize: '20px', color: '#08c', position: 'relative', left: '4px' }} />}
                    {props.slideFlag == 1 && <MenuUnfoldOutlined style={{ fontSize: '20px', color: '#08c', position: 'relative', left: '4px' }} />}
                  </a>
                  <a title={setResetSearch} {...addProps} onClick={resetSearchEnabled ? e => props.onResetTableSearch() : null}>{ resetSearchEnabled ? resetSearch.img : resetSearch.disableimg}</a>&nbsp;
                  { bSetTop ? <a title={setTop} {...addProps} onClick={moveEnabled && sortEnabled ? e => props.orderData(e, 'slave', 0) : null}>{ moveEnabled && sortEnabled ? moveTop.img : moveTop.disableimg}</a> : '' }
                  { bSetUp ? <a title={setUp} {...addProps} onClick={moveEnabled && sortEnabled ? e => props.orderData(e, 'slave', 1) : null}>{ moveEnabled && sortEnabled ? moveUp.img : moveUp.disableimg }</a> : ''}
                  { bSetDown ?  <a title={setDown} {...addProps} onClick={moveEnabled && sortEnabled ? e => props.orderData(e, 'slave', 2) : null}>{moveEnabled && sortEnabled ? moveDown.img : moveDown.disableimg }</a>  : ''}
                  { bSetBottom ? <a title={setBottom} {...addProps} onClick={moveEnabled && sortEnabled ? e => props.orderData(e, 'slave', 3) : null}>{moveEnabled && sortEnabled ? moveBottom.img : moveBottom.disableimg }</a> : ''} &nbsp;&nbsp;
                  { bSetMachine ? <a title={setMachine} {...addProps} onClick={props.showSetMachine ? e => props.orderData(e, 'slaveInfo', 0) : null}>{props.showSetMachine ? changeMachine.img : changeMachine.disableimg }</a> : ''} &nbsp;&nbsp;
                  { bSetSave ? <a title={setSave} {...addProps} onClick={ e =>props.onShowSave(e, 'save', 0)}>{slideSave.img}</a> : ''} &nbsp;&nbsp;
                  { bSetLock ? <a title={setLock} {...addProps} onClick={commonUtils.isEmptyObject(props.sortedInfo) ? e => props.onShowLock(e, 'lock', 0) : null}>{commonUtils.isEmptyObject(props.sortedInfo) ? slideLock.img : slideLock.disableimg }</a> : ''} &nbsp;&nbsp;
                  { bSetTimer ?
                    <a title={setCalTime} {...addProps} onClick={commonUtils.isEmptyObject(props.sortedInfo) ? e => props.onShowTimerModal(e, 'changeTimer') : null}>{commonUtils.isEmptyObject(props.sortedInfo) ? showTimer.img : showTimer.disableimg }</a>
                    : ''}&nbsp;&nbsp;
                  { bSetOverExec ? <a title={setOverExec} {...addProps} onClick={commonUtils.isEmptyObject(props.sortedInfo) ? e => props.onShowOverExec(e, 'overExec', 0) : null}>{commonUtils.isEmptyObject(props.sortedInfo)  ? slideOverExec.img : slideOverExec.disableimg }</a> : ''} &nbsp;&nbsp;
                  { bSetCheckModel ?<a title={setCheck} {...addProps} onClick={commonUtils.isEmptyObject(props.sortedInfo) && props.bMachine ? e => props.onCheckModel(e, 'checkModel') : null}>
                    {props.checkModelStatus ?
                      <LoadingOutlined style={{ fontSize: 16 }} spin></LoadingOutlined> : commonUtils.isEmptyObject(props.sortedInfo) && props.bMachine ? showCheckModel.img : showCheckModel.disableimg
                    }
                  </a> : ''}&nbsp;&nbsp;
                  { bSetList ? <a title="查看列表" {...addProps} onClick={props.bGantt ? e => props.changeGantt(e, 'list', 0) : null}>{props.bGantt ? showList.img : showList.disableimg }</a>  : ''} &nbsp;&nbsp;
                  { bSetGantt ?<a title="查看甘特图" {...addProps} onClick={props.bMachine && !props.bGantt ? e => props.changeGantt(e, 'gantt', 0) : null}>{props.bMachine && !props.bGantt ? showGantt.img : showGantt.disableimg }</a> : ''} &nbsp;&nbsp;
                  &nbsp;&nbsp;

                </Sider>
                {
                  bGantt && commonUtils.isNotEmptyObject(charGanttData) ?
                    <Content style={{ height: 'calc( 100vh - 230px )' }} className={GanttStyles.ganttList} >
                      {/* <StaticEditTable {...tableProps} tableBelone="list" /> */}
                      <div className="gantt-container" style={{ width: '100vm', height: '100%' }} >
                        <Gantt {...ganttProps} />
                      </div>
                    </Content> :
                    <Content
                      className="xly-normal-list productPlan"
                      style={{paddingRight: '0px'}}
                    >
                      <div className={`tree-pagination-container ${(tableProps.data && tableProps.data.length) <= 1 ? 'tree-pagination-container-nopage' : ''}`}>
                        { renderTable() }
                        {/* <div className="pagination-item"> */}
                        {/*  <Pagination simple pageSize={pageSize} onChange={onPageChange} current={pageNum} defaultCurrent={1} total={tableProps.data ? tableProps.data.length : 1} /> */}
                        {/* </div> */}
                      </div>
                    </Content>
                }
              </Layout>
            </div>
          </div>
        </Layout>
        {
          props.isChangeMachine ?
            <AntdDraggableModal
              width={500}
              title="换机台"
              visible={props.isChangeMachine}
              onCancel={props.onCloseChangeMachine}
              onOk={props.onChangeMachine}
              okButtonProps={commonUtils.isNotEmptyObject(masterData) && (commonUtils.isNotEmptyStr(masterData.sMachineId) || (masterData.bSplit && commonUtils.isNotEmptyStr(masterData.iSplitNum))) ? { disabled: false } : { disabled: true }}
            >
              { commonUtils.isEmptyObject(masterConfig) || iWorkCenterIndex < 0 ? '' : <ShowType {...workCenterProps} /> }
              { commonUtils.isEmptyObject(masterConfig) || iMachineIndex < 0 ? '' : <ShowType {...machineShowTypeProps} /> }
              { commonUtils.isEmptyObject(masterConfig) ? '' : <ShowType {...teamShowTypeProps} /> }
              {/* { commonUtils.isEmptyObject(masterConfig) ? '' : <ShowType {...startShowTypeProps} /> } */}
              { commonUtils.isEmptyObject(masterConfig) ? '' : <ShowType {...splitShowTypeProps} /> }
              { commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyObject(masterData) && masterData.bSplit ? <ShowType {...splitNumShowTypeProps} /> : '' }
              { commonUtils.isNotEmptyObject(masterConfig) && commonUtils.isNotEmptyObject(masterData) && masterData.bSplit && iProcessSyQtyIndex > -1 ? <ShowType {...iProcessSyQtyProps} /> : '' }
            </AntdDraggableModal>
            : ''
        }
        {
          props.changeTimerVisible ?
            <AntdDraggableModal
              width={500}
              title="重算时间"
              visible
              onCancel={props.onCloseModel.bind(this, 'changeTimerVisible')}
              onOk={props.onChangeTimerPro}
              okButtonProps={okProps}
            >
              { commonUtils.isEmptyObject(masterConfig) ? '' : <ShowType {...startShowTypeProps} showTime /> }
            </AntdDraggableModal>
            : ''
        }
        {
          props.workScheduleVisible ?
            <AntdDraggableModal
              className="workScheduleModal"
              width={1300}
              title={commonUtils.isEmptyObject(searchWorkSchedule) ? searchWorkTitle : searchWorkSchedule.app.currentPane.title}
              visible
              onCancel={props.onCloseModel.bind(this, 'workScheduleVisible')}
              onSaveState={props.onSaveState}
              footer={null}
            >
              <CommonListSelect {...searchWorkSchedule} />
            </AntdDraggableModal> : null
        }
        {
          props.sHistoryQtyVisible ?
            <AntdDraggableModal
              className="workScheduleModal"
              width={1300}
              title={commonUtils.isEmptyObject(sHistoryQtyTitle) ? sHistoryQtyTitle : sHistoryQtyProps.app.currentPane.title}
              visible
              onCancel={props.onCloseModel.bind(this, 'sHistoryQtyVisible')}
              onSaveState={props.onSaveState}
              footer={null}
            >
              <CommonListSelect {...sHistoryQtyProps} />
            </AntdDraggableModal> : null
        }
      </Layout>
    </Form>
  );
});

export default CommonBase(CommonProductionPlanTreeEvent(ProductionSchedule));
