index.js
5.26 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import React, { useEffect, useRef } from "react";
import * as commonUtils from "@/utils/utils";
import useCommonBase from "@/components/Common/CommonHooks/useCommonBase";
import * as commonFunc from '@/components/Common/commonFunc';
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"
];
// 定义多语言映射
const translations = {
sEnglish: {
"生产执行": "Production Execution",
"质量巡检": "Quality Inspection",
"拼版图": "Assembly Drawing",
"产品图": "Product Drawing",
"报工任务": "Work Reporting ïTask",
"班组报工": "Team Production Reporting"
},
sBig5: {
"生产执行": "生產執行",
"质量巡检": "質量巡檢",
"拼版图": "拼版圖",
"产品图": "產品圖",
"报工任务": "報工任務",
"班组报工": "班組報工",
}
};
function translateList(language) {
// 原始中文列表
const list = ["生产执行", "质量巡检", "拼版图", "产品图", "报工任务"];
// 根据语言设置进行转换
if (translations[language]) {
return list.map(item => translations[language][item] || item);
}
// 默认返回原始列表
return list;
}
function translateTipList(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);
const tipList = translateTipList(sLanguage);
const no = commonFunc.showLocalMessage(props, 'No', '暂无');
return (
<div className={sLanguage === 'sEnglish' ? styles.quickSwitchTabEngComponent : styles.quickSwitchTabComponent} ref={ref}>
{list.map((title, index) => {
const currentId = listId[index];
const currentMesPane = commonUtils.convertStrToObj(
localStorage.xlybusinesscurrentMesPane
);
const { sModelsId } = currentMesPane;
const tip = tipList[index];
const getPath = (path) => {
if (sLanguage === "sChinese") return path;
return translations[sLanguage][path];
}
return (
<div
className={currentId === sModelsId ? styles.active : ""}
title={tip}
onClick={() => {
if (currentId) {
props.onChangeRouter({
type: "name",
path: [getPath("生产执行"), title === getPath("报工任务") ? getPath("班组报工") : title]
});
} else {
props.onGetFileUrl(title, url => {
if (!url) {
message.info(`${no}${title}`);
return;
}
props.onOpenCommonModal({
type: "commonFilePreviewModal",
url
});
});
}
}}
>
{title}
</div>
);
})}
</div>
);
};
export default QuickSwitchTabComponent;