index.js
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* @Author: Sakura
* @LastEditors: Sakura
* @Date: 2024-02-28 8:55:50
* @Description: 路由组件配置界面
*/
import React, { useEffect, useState } from "react";
import * as commonUtils from "@/utils/utils";
import CommonModelComponent from "@/mes/common/commonModelComponent";
import MachineTasks from "@/mes/scheduledTasks/machineTasks";
// import ProcessInstructionBook from "@/mes/scheduledTasks/processInstructionBook";
import ProcessInstructionBookNew from "@/mes/scheduledTasks/processInstructionBookNew";
import PrenatalReminderInfo from "@/mes/scheduledTasks/prenatalReminderInfo";
import ProductionExecMain from "@/mes/productionExec/productionExecMain";
import AbnormalEventReporting from "@/mes/scheduledTasks/abnormalEventReporting";
import RunningStatus from "@/mes/common/RunningStatus";
// 枚举所有特殊定义页面
const types = {
// 计划任务 ---- 机台任务
machineTasks: ({ sModelsId, props }) => (
<MachineTasks key={sModelsId} {...props} />
),
// 计划任务 ---- 工艺作业指导书
processInstructionBook: ({ sModelsId, props }) => (
// <ProcessInstructionBook key={sModelsId} {...props} />
<ProcessInstructionBookNew key={sModelsId} {...props} />
),
// 计划任务 ---- 产前提醒信息
prenatalReminderInfo: ({ sModelsId, props }) => (
<PrenatalReminderInfo key={sModelsId} {...props} />
),
// 生产执行 ---- 生产执行
productionExec: ({ sModelsId, props }) => (
<ProductionExecMain key={sModelsId} {...props} />
),
abnormalEventReporting: ({ sModelsId, props }) => (
<AbnormalEventReporting key={sModelsId} {...props} />
)
};
const RouterComponent = props => {
const { sModelType = "", sModelsId } = props;
const [keyId, setKeyId] = useState(sModelsId);
const userinfo = commonUtils.getAppData("userinfo");
const { bRefreshPage } = userinfo;
useEffect(
() => {
if (sModelsId) {
setKeyId(sModelsId);
}
},
[sModelsId]
);
useEffect(
() => {
if (!bRefreshPage) return;
setKeyId(commonUtils.createSid());
props.dispatch({
type: "app/saveUserinfo",
payload: { ...userinfo, bRefreshPage: false }
});
},
[bRefreshPage]
);
const selectedType = Object.keys(types).find(type =>
sModelType.includes(type)
);
if (selectedType) {
return types[selectedType]({ sModelsId: keyId, props });
} else if (sModelsId === "12710101117126502477360") {
return <RunningStatus {...props} />;
} else {
return <CommonModelComponent key={keyId} {...props} />;
}
};
export default RouterComponent;