index.js
2.87 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
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;
}
}, []);
const list = ["生产执行", "质量巡检", "拼版图", "产品图", "报工任务"];
const listId = [
"12710101117087374661080",
"12710101117089395856660",
"",
"",
"12710101117087404588200"
];
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;