index.js
3.82 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React, { useEffect, useRef } from "react";
import * as commonUtils from "@/utils/utils";
import useCommonBase from "@/components/Common/CommonHooks/useCommonBase";
import styles from "./index.less";
import { message } from "antd";
const useQuickSwitchTabEvent = props => {
const { formData = [] } = props;
const handleGetFileUrl = async (title, cb) => {
let url = "";
if (!formData.length) {
cb(url);
return;
}
const config = formData.find(item => item.sGrd === "cppbt01");
if (!config) {
cb(url);
return;
}
const result = await props.onGetDataSet({
name: "cppbt01",
configData: config,
condition: {
sSqlCondition: {
sWorkOrderSlaveId: commonUtils.convertStrToObj(
localStorage.xlybusinessglobalData
).currentWorkOrderInfo.sWorkOrderSlaveId
}
},
isWait: true
});
const { cppbt01Data: tableData } = result;
if (commonUtils.isEmptyArr(tableData)) {
cb(url);
return;
}
const data = tableData.find(item => item.sType === title);
url = data?.sPicturePath;
cb(url);
};
return {
...props,
onGetFileUrl: handleGetFileUrl
};
};
const QuickSwitchTabComponent = baseProps => {
const props = useQuickSwitchTabEvent(
useCommonBase({ ...baseProps, sModelsId: "12710101117087374661080" })
);
const ref = useRef(null);
useEffect(() => {
if (ref.current) {
ref.current.onselectstart = () => false;
}
}, []);
let list = ["生产执行", "质量巡检", "拼版图", "产品图", "报工任务"];
const listId = [
"12710101117087374661080",
"12710101117089395856660",
"",
"",
"12710101117087404588200"
];
function translateList(language) {
// 原始中文列表
const list = ["生产执行", "质量巡检", "拼版图", "产品图", "报工任务"];
// 定义多语言映射
const translations = {
sEnglish: {
"生产执行": "Production Execution",
"质量巡检": "Quality Inspection",
"拼版图": "Assembly Drawing",
"产品图": "Product Drawing",
"报工任务": "Work Reporting Task"
},
sBig5: {
"生产执行": "生產執行",
"质量巡检": "質量巡檢",
"拼版图": "拼版圖",
"产品图": "產品圖",
"报工任务": "報工任務"
}
};
// 根据语言设置进行转换
if (translations[language]) {
return list.map(item => translations[language][item] || item);
}
// 默认返回原始列表
return list;
}
const sLanguage = props.app.userinfo.sLanguage || 'sChinese';
list = translateList(sLanguage);
return (
<div className={styles.quickSwitchTabComponent} ref={ref}>
{list.map((title, index) => {
const currentId = listId[index];
const currentMesPane = commonUtils.convertStrToObj(
localStorage.xlybusinesscurrentMesPane
);
const { sModelsId } = currentMesPane;
return (
<div
className={currentId === sModelsId ? styles.active : ""}
onClick={() => {
if (currentId) {
props.onChangeRouter({
type: "name",
path: ["生产执行", title === "报工任务" ? "班组报工" : title]
});
} else {
props.onGetFileUrl(title, url => {
if (!url) {
message.info(`暂无${title}`);
return;
}
props.onOpenCommonModal({
type: "commonFilePreviewModal",
url
});
});
}
}}
>
{title}
</div>
);
})}
</div>
);
};
export default QuickSwitchTabComponent;