import React from 'react';
import { connect } from 'dva';
import { Icon as LegacyIcon } from '@ant-design/compatible';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { Tabs, Modal } from 'antd';
import CommonList from '@/routes/commonList/commonList';/* 公共列表 */
import CommonListA from '@/routes/commonList/commonListA'; /* 无需注册模块验证的公共列表 */
import CommonListEdit from '@/routes/commonList/commonListEdit'; /* 可编辑公共列表 */
import CommonListTab from '@/routes/commonList/commonListTab'; /* 多个列表 */
import CommonListLeft from '@/routes/commonList/commonListLeft';/* 左侧树形 */
import CommonColumnList from '@/routes/commonColumnList/commonColumnList';/* 公共自定义标题列表 */
import CommonListTree from '@/routes/commonListTree/commonListTree';/* 两层通用结构commonListTree,功能如物料需求计划 */
import CommonGatte from '@/routes/commonGatte/commonGatte';/* 甘特图列表 */
import MaterialRequirementsPlanning from '@/routes/materialRequirementsPlanning/materialRequirementsPlanning';/* 物料需求计划 */
import CommonClassify from '@/routes/commonClassify/commonClassify';/* 公共分类 */
import CustomerInfo from '@/routes/basicInfoSetting/customerInfo/customerInfo';/* 客户信息 */
import KnifemouldInfo from '@/routes/basicInfoSetting/knifemouldInfo/knifemouldInfo';/* 刀模信息 */
import TestStandInfo from '@/routes/basicInfoSetting/teststandInfo/teststandInfo';/* 刀模信息 */
import Materiel from '@/routes/basicInfoSetting/materiel/materiel';/* 物料信息 */
import Employee from '@/routes/basicInfoSetting/employee/employee';/* 职员信息 */
import PrintInfo from '@/routes/basicInfoSetting/printInfo/printInfo';/* 印件信息 */
import SystemSetting from '@/routes/basicInfoSetting/systemSetting/systemSetting';/* 印件信息 */
import SupplyInfo from '@/routes/basicInfoSetting/supplyInfo/supplyInfo';/* 权限分配 */
import ProcessInfo from '@/routes/basicInfoSetting/processInfo/processInfo';/* 工序信息 */
import SftLoginInfo from '@/routes/basicInfoSetting/sftLoginInfo/sftLoginInfo';/* 用户管理 */
import Commonstyle from '@/routes/basicInfoSetting/commonStyle/commonStyle';/* 常用规格 */
import CheckModel from '@/routes/basicInfoSetting/checkModel/checkModel';/* 审核模板 */
import CheckPhase from '@/routes/basicInfoSetting/checkPhase/checkPhase';/* 审核阶段 */
import WorkOrderNew from '@/routes/manufacture/workOrder/workOrder';/* 生产施工单 */
import WorkOrderPack from '@/routes/manufacture/workOrderPack/workOrderPack';/* 包装施工单 */
import WorkOrderPackTableTree from '@/routes/manufacture/workOrderPackTableTree/workOrderPackTableTree';/* 包装施工单 */
import WorkOrderResearchTableTree from '@/routes/manufacture/workOrderResearchTableTree/workOrderResearchTableTree';/* 研发工单 */
import ProductClassify from '@/routes/basicInfoSetting/productClassify/productClassify';/* 印件分类信息 */
import IndexCenter from '@/routes/indexCenter/indexCenter';/* 首页 */
import TabComponent from '@/components/Tab/TabComponent';
import styles from '@/index.less';
import CommonBill from '@/routes/common/commonBill';/* 通用单据页 */
import CommonCheckBill from '@/routes/common/commonCheckBill';/* 通用预览单据页 */
import CommonChar from '@/routes/commonChar/commonChar';/* 通用图表页 */
import CommonAuto from '@/routes/commonAuto/commonAuto';/* 通用自定义界面 */
import ProductionPlan from '@/routes/productionPlan/productionPlan';/* 生产排程 */
import EleteamInfo from '@/routes/common/eleteamInfo';/* 班组信息页 新 */
import SisFormulaInfo from '@/routes/basicInfoSetting/sisFormula/sisFormulaInfo';
import EleMachineInfo from '@/routes/basicInfoSetting/machineInfo/eleMachineInfo';/* 设备信息 */
import SystemPermissionInfo from '@/routes/basicInfoSetting/systemPermission/systemPermissionInfo';/* 设备信息 */
import ImportDataInfo from '@/routes/importData/importData';/* 设备信息 */
import PaymentTermsInfo from '@/routes/basicInfoSetting/paymentInfo/paymentInfoTerms';
import ProductionReport from '@/routes/basicInfoSetting/productReport/productReport';/* 产量上报 */
import ProductionMainPlan from '@/routes/productionMainPlan/productionMainPlan';/* 新生产主计划 */
import ProductionPlanInfo from '@/routes/productionPlan/productionPlanInfo';/* 新生产排程 */
import ProductionPlanOutside from '@/routes/productionPlan/productionPlanOutside';/* 发外排程 */
import ProductionSchedule from '@/routes/productionSchedule/productionScheduleInfo';/* 生产排程甘特图 */
import ProductionScheduleTree from '@/routes/productionScheduleTree/productionScheduleTree';/* 生产排程tree(金宣发) */
import ProductionPlanChangeMachine from '@/routes/productionPlan/productionPlanChangeMachineInfo';/* 新生产排程 更换班组机台 */
import AuditInformation from '@/routes/basicInfoSetting/auditInformation/auditInformation';/* 审核信息 */
import Quotation from '@/routes/quoQuotation/quotation/quotation';/* 审核信息 */
import QuotationPackTableTree from '@/routes/quoQuotation/quotationPackTableTree/quotationPackTableTree';/* 报价单(包装) */
import QuotationPack from '@/routes/quoQuotation/quotationPack/quotationPack';/* 报价单(套装) */
// import QuotationPack from '@/routes/quoQuotation/quotationPackTableTree/quotationPackTableTree';/* 报价单(包装)s */
// import QuotationPackTableTree from '@/routes/quoQuotation/quoQuotation/quoQuotation';/* 报价单(包装) */
import ProductionUnifiedPlanning from '@/routes/productionMainPlan/productionUnifiedPlanning';/* 主计划统一规划 */
import CommonNewBill from '@/routes/common/commonNewBill';/* 通用单据页 */
import CommonNewTabBill from '@/routes/common/commonNewTabBill';/* 通用单据页 */
import CommonCostomTabBill from '@/routes/common/commonCostomTabBill';
import CommonNewListBill from '@/routes/common/commonNewListBill';/* 通用单据页 */
import CommonGroupBill from '@/routes/common/commonGroupBill';/* 通用单据页 */
import CommonBillDeliver from '@/routes/common/commonBillDeliver'; /* 送货单个性化 */
import CommonSubBill from '@/routes/common/commonSubBill'; /* 通用嵌套子表单据 */
import ProcessCardInfo from '@/routes/manufacture/processCard/processCardInfo';
import ProcessCardInfoPack from '@/routes/manufacture/processCardPack/processCardInfoPack';
import ProcessCardPackTableTree from '@/routes/manufacture/processCardPackTableTree/processCardPackTableTree';
import ProcessCardPackTableTreeNew from '@/routes/manufacture/processCardPackTableTreeNew/processCardPackTableTreeNew';
import WorkOrderPackTableTreeNew from '@/routes/manufacture/workOrderPackTableTreeNew/workOrderPackTableTreeNew';
import SysMsgInfo from '@/routes/basicInfoSetting/mailMsg/sysMsgInfo';
import PrintLabel from '@/routes/basicInfoSetting/printLabel/printLabel';
import MonthEndingClosing from '@/routes/basicInfoSetting/closeAccounts/monthEndingClosing';
import { sendWebSocketMessage } from '@/components/Common/commonFunc';
import { isNotEmptyObject, isNotEmptyArr } from '@/utils/utils'; /* 通用方法 */
import PrintPdf from '../printPdf/printPdf'; /* 单预览 */
import Feedback from '../feedback/feedback';
/* 计算方案s */
const { confirm } = Modal;
const { TabPane } = Tabs;
function Tab({ dispatch, app }) {
const { panes } = app;
let paneType = '';
const tagArr = panes.filter(item => item.newRecordFlag !== undefined);
const tagLastKey = tagArr !== undefined && tagArr.length > 0 ? tagArr[tagArr.length - 1].key : '';
const tabpanes = panes.map((pane) => {
const bRecordFlagDisabled = (tagArr.length > 0 && pane.key !== tagLastKey);
let content = '';
if (pane.route === '/indexPage/commonList') {
content = ;
} else if (pane.route === '/indexPage/commonListA') {
content = ;
} else if (pane.route === '/indexPage/commonListEdit') {
content = ;
} else if (pane.route === '/indexPage/commonListTab') {
content = ;
} else if (pane.route === '/indexPage/commonColumnList') {
content = ;
} else if (pane.route === '/indexPage/commonListTree') {
content = ;
} else if (pane.route === '/indexPage/commonListLeft') {
content = ;
} else if (pane.route === '/indexPage/commonGatte') {
content = ;
} else if (pane.route === '/indexPage/materialRequirementsPlanning') {
content = ;
} else if (pane.route === '/indexPage/commonClassify') {
content = ;
} else if (pane.route === '/indexPage/elecustomer') {
content = ;
} else if (pane.route === '/indexPage/eleknifemould') {
content = ;
} else if (pane.route === '/indexPage/eleteststand') {
content = ;
} else if (pane.route === '/indexPage/eleemployee') {
content = ;
} else if (pane.route === '/indexPage/elematerials') {
content = ;
} else if (pane.route === '/indexPage/eleproduct') {
content = ;
} else if (pane.route === '/indexPage/syssystemsettings') {
content = ;
} else if (pane.route === '/indexPage/elesupply') {
content = ;
} else if (pane.route === '/indexPage/eleprocess') {
content = ;
} else if (pane.route === '/indexPage/elecheckmodel') {
content = ;
} else if (pane.route === '/indexPage/sischeckphase') {
content = ;
} else if (pane.route === '/indexPage/sftlogininfo') {
content = ;
} else if (pane.route === '/indexPage/siscommonstyle') {
content = ;
} else if (pane.route === '/indexPage/sisproductclassify') {
content = ;
} else if (pane.route === '/indexPage/commonBill') {
content = ;
} else if (pane.route === '/indexPage/commonCheckBill') {
content = ;
} else if (pane.route === '/indexPage/workOrderNew') {
content = ;
} else if (pane.route === '/indexPage/workOrderPack') {
content = ;
} else if (pane.route === '/indexPage/workOrderPackTableTree') {
content = ;
} else if (pane.route === '/indexPage/workOrderResearchTableTree') {
content = ;
} else if (pane.route === '/indexPage/processCard') {
content = ;
} else if (pane.route === '/indexPage/processCardPack') {
content = ;
} else if (pane.route === '/indexPage/processCardPackTableTree') {
content = ;
} else if (pane.route === '/indexPage/processCardPackTableTreeNew') {
content = ;
} else if (pane.route === '/indexPage/workOrderPackTableTreeNew') {
content = ;
} else if (pane.route === '/indexPage/productionPlan') {
content = ;
} else if (pane.route === '/indexPage/commonChar') {
content = ;
} else if (pane.route === '/indexPage/commonAuto') {
content = ;
} else if (pane.route === '/indexPage/eleteamInfo') {
content = ;
} else if (pane.route === '/indexPage/sisformulaInfo') {
content = ;
} else if (pane.route === '/indexPage/elemachineInfo') {
content = ;
} else if (pane.route === '/indexPage/systemPermission') {
content = ;
} else if (pane.route === '/indexPage/importData') {
content = ;
} else if (pane.route === '/indexPage/sispaymentTerms') {
content = ;
} else if (pane.route === '/indexPage/productionReport') {
content = ;
} else if (pane.route === '/indexPage/productionMainPlan') {
content = ;
} else if (pane.route === '/indexPage/productionPlanInfo') {
content = ;
} else if (pane.route === '/indexPage/productionPlanOutside') {
content = ;
} else if (pane.route === '/indexPage/productionSchedule') {
content = ;
} else if (pane.route === '/indexPage/productionScheduleTree') {
content = ;
} else if (pane.route === '/indexPage/auditInformation') {
content = ;
} else if (pane.route === '/indexPage/mailMsg') {
content = ;
} else if (pane.route === '/indexPage/printlabel') {
content = ;
} else if (pane.route === '/indexPage/monthEndingClosing') {
content = ;
} else if (pane.route === '/indexPage/quotation') {
content = ;
} else if (pane.route === '/indexPage/quotationPack') {
content = ;
} else if (pane.route === '/indexPage/quotationPackTableTree') {
content = ;
} else if (pane.route === '/indexPage/unifiedPlanning') {
content = ;
} else if (pane.route === '/indexPage/productionPlanChangeMachine') {
content = ;
} else if (pane.route === '/indexPage/commonBillDeliver') {
content = ;
} else if (pane.route === '/indexPage/commonSubBill') {
content = ;
} else if (pane.route === '/indexPage/commonNewBill') {
content = ;
} else if (pane.route === '/indexPage/commonNewTabBill') {
content = ;
} else if (pane.route === '/indexPage/commonCostomTabBill') {
content = ;
} else if (pane.route === '/indexPage/commonNewListBill') {
content = ;
} else if (pane.route === '/indexPage/commonGroupBill') {
content = ;
} else if (pane.route === '/indexPage/printPdf') {
content = ;
} else if (pane.route === '/indexPage/feedback') {
content = ;
} else {
content = ;
}
if (pane.paneType) {
paneType = {pane.title};
} else {
paneType = {pane.title};
}
return (
{content}
);
});
const totalProps = {
tabpanes,
app,
onSaveCurrentPane: saveCurrentPane,
onRemove: removePane,
};
const handleSendSocketMessage = (flag, showType, sId, sendTo, msgInfo, param) => {
const { token } = app;
const sendws = handleSendWebSocketMsg;
if (isNotEmptyObject(token)) {
if (app.webSocket !== null && app.webSocket.readyState === WebSocket.OPEN) {
sendws(flag, showType, msgInfo, sId, sendTo, param);
} else {
dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } });
setTimeout(() => {
sendws(flag, showType, msgInfo, sId, sendTo, param);
}, 30000);
}
}
};
const handleSendWebSocketMsg = (flag, showType, msgInfo, sId, sendTo, param) => {
const { webSocket, userinfo, currentPane } = app;
const { key } = currentPane;
sendWebSocketMessage(webSocket, key, flag, showType, userinfo.sId, msgInfo, sId, sendTo, param);
};
function saveCurrentPane(currentPane) {
dispatch({ type: 'app/saveCurrentPane', payload: { currentPane } });
}
const clearWebSocketMsg = (i) => {
const { userinfo } = app;
const { copyTo } = i;
if (isNotEmptyObject(copyTo)) {
const {
slaveData, srcFormRoute, copyOtherData, masterData, copyToDataSid,
} = copyTo;
const sIdArray = [...copyToDataSid || []];
if (!i?.checkedId) {
if (isNotEmptyObject(srcFormRoute) && srcFormRoute.includes('materialRequirementsPlanning')) { /* 物料需求计划用sWorkOrderMaterialId作为唯一键 */
if (isNotEmptyArr(copyOtherData) && copyOtherData[0]?.name === 'detail' && isNotEmptyArr(copyOtherData[0]?.data)) {
const slaveDetailData = copyOtherData[0].data;
slaveDetailData.forEach((item) => {
const redisKey = item.sWorkOrderMaterialId;
sIdArray.push(redisKey);
});
} else { /* 变更单、采购申请单 */
slaveData.forEach((item) => {
const redisKey = item.sWorkOrderMaterialId;
sIdArray.push(redisKey);
});
}
}
}
if (isNotEmptyObject(masterData) &&
isNotEmptyObject(masterData.sSrcSlaveId)) {
sIdArray.push(masterData.sSrcSlaveId);
}
if (Array.isArray(slaveData)) {
slaveData.forEach((item) => {
const redisKey = item.sSlaveId;
sIdArray.push(redisKey);
});
}
const sId = [...new Set(sIdArray)].filter(Boolean).toString();
handleSendSocketMessage('copyfinish', 'noAction', sId, userinfo.sId, null, null);
}
handleSendSocketMessage('release', 'noAction', i?.checkedId || '', userinfo.sId, null, null);
handleSendSocketMessage('release', 'noAction', i?.formId || '', userinfo.sId, null, null);
};
function removePane(changePanes, currentPane, removePane) {
const removeData = Array.isArray(removePane) ? removePane.filter(Boolean) : [];
if (removePane && removePane.length === 1 && removePane[0] && removePane[0].fromKey) {
const currentPaneNew = changePanes.find(item => item.key === removePane[0].fromKey);
if (currentPaneNew) {
currentPane = currentPaneNew;
}
}
if (removePane && removePane[0]) {
const isProductionScheduleTree = removePane[0].route.indexOf('systemPermission') > -1 ||
(removePane[0].route.indexOf('production') > -1);
if (isProductionScheduleTree) {
removeData.forEach((i) => {
clearWebSocketMsg(i);
});
dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } });
return;
}
}
if (app.diffMap && removePane[0] && app.diffMap.get(removePane[0].key)) {
confirm({
icon: ,
content: '内容未保存,是否离开?',
onOk() {
removeData.forEach((i) => {
clearWebSocketMsg(i);
});
dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } });
},
onCancel() {
console.log('取消关闭');
},
});
} else {
removeData.forEach((i) => {
clearWebSocketMsg(i);
});
dispatch({ type: 'app/removePane', payload: { changePanes, currentPane } });
}
}
return (
);
}
export default connect(({ app }) => ({ app }))(Tab);