import { connect } from 'umi';
import { Icon as LegacyIcon } from '@ant-design/compatible';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { Tabs, Modal } from 'antd';
import IndexCenter from '@/routes/indexCenter/indexCenter';/* 首页 */
import TabComponent from '@/components/Tab/TabComponent';
import CommonListEdit from '@/routes/commonList/commonListEdit'; /* 可编辑公共列表 */
import CommonList from '@/routes/commonList/commonList';/* 公共列表 */
import CommonListA from '@/routes/commonList/commonListA'; /* 无需注册模块验证的公共列表 */
import CommonListTab from '@/routes/commonList/commonListTab'; /* 多个列表 */
import CommonBill from '@/routes/commonList/commonBill';/* 通用单据页 */
import CommonNewBill from '@/routes/commonList/commonNewBill';/* 通用单据页 */
import CommonClassify from '@/routes/commonClassify/commonClassify';/* 公共分类 */
import CustomerInfo from '@/routes/basicInfoSetting/customerInfo/customerInfo';/* 客户信息 */
import CommonColumnList from '@/routes/commonColumnList/commonColumnList';/* 公共自定义标题列表 */
import CommonListTree from '@/routes/commonListTree/commonListTree';/* 两层通用结构commonListTree,功能如物料需求计划 */
import CommonListLeft from '@/routes/commonList/commonListLeft';/* 左侧树形 */
import CommonGatte from '@/routes/commonGatte/commonGatte';/* 甘特图列表 */
import MaterialRequirementsPlanning from '@/routes/materialRequirementsPlanning/materialRequirementsPlanning';/* 物料需求计划 */
import TestStandInfo from '@/routes/basicInfoSetting/teststandInfo/teststandInfo';/* 刀模信息 */
import Employee from '@/routes/basicInfoSetting/employee/employee';/* 职员信息 */
import Materiel from '@/routes/basicInfoSetting/materiel/materiel';/* 物料信息 */
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 CheckModel from '@/routes/basicInfoSetting/checkModel/checkModel';/* 审核模板 */
import CheckPhase from '@/routes/basicInfoSetting/checkPhase/checkPhase';/* 审核阶段 */
import SftLoginInfo from '@/routes/basicInfoSetting/sftLoginInfo/sftLoginInfo';/* 用户管理 */
import Commonstyle from '@/routes/basicInfoSetting/commonStyle/commonStyle';/* 常用规格 */
import ProductClassify from '@/routes/basicInfoSetting/productClassify/productClassify';/* 印件分类信息 */
import CommonCheckBill from '@/routes/common/commonCheckBill';/* 通用预览单据页 */
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 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 ProductionPlan from '@/routes/productionPlan/productionPlan';/* 生产排程 */
import styles from '@/index.less';
import { sendWebSocketMessage } from '@/components/Common/commonFunc';
import { isNotEmptyObject, isNotEmptyArr } from '@/utils/utils'; /* 通用方法 */
import KnifemouldInfo from '@/routes/basicInfoSetting/knifemouldInfo/knifemouldInfo';/* 刀模信息 */
import CommonChar from '@/routes/commonChar/commonChar';/* 通用图表页 */
import QuotationPackTableTree from '@/routes/quoQuotation/quotationPackTableTree/quotationPackTableTree';
/* 计算方案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);
const routeList = {
'/indexPage/commonList': ,
'/indexPage/commonListA': ,
'/indexPage/commonNewBill': ,
'/indexPage/commonBill' : ,
'/indexPage/commonListEdit' : ,
'/indexPage/commonClassify' : ,
'/indexPage/eleknifemould' : ,
'/indexPage/elecustomer' : ,
'/indexPage/commonListTab' : ,
'/indexPage/commonColumnList' : ,
'/indexPage/commonListTree' : ,
'/indexPage/commonListLeft' : ,
'/indexPage/commonGatte': ,
'/indexPage/materialRequirementsPlanning' : ,
'/indexPage/eleteststand' : ,
'/indexPage/eleemployee' : ,
'/indexPage/elematerials' : ,
'/indexPage/eleproduct' : ,
'/indexPage/syssystemsettings' : ,
'/indexPage/elesupply' : ,
'/indexPage/eleprocess' : ,
'/indexPage/elecheckmodel' : ,
'/indexPage/sischeckphase' : ,
'/indexPage/sftlogininfo' : ,
'/indexPage/siscommonstyle' : ,
'/indexPage/sisproductclassify' : ,
'/indexPage/commonCheckBill' : ,
'/indexPage/workOrderNew' : ,
'/indexPage/workOrderPack' : ,
'/indexPage/workOrderPackTableTree' : ,
'/indexPage/workOrderResearchTableTree' : ,
'/indexPage/processCard' : ,
'/indexPage/processCardPack' : ,
'/indexPage/processCardPackTableTree' : ,
'/indexPage/processCardPackTableTreeNew' : ,
'/indexPage/workOrderPackTableTreeNew' : ,
'/indexPage/productionPlan' : ,
'/indexPage/commonChar' : ,
'/indexPage/quotationPackTableTree' : ,
}
const content = routeList[pane.route] || ;
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);