index.js
4.48 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
import React, { useEffect, useState } from "react";
import { Modal, Form, Button, message } from "antd";
import * as commonUtils from "@/utils/utils";
import FaceDetect from "@/components/FaceDetect";
import ShowType from "@/components/Common/CommonComponent";
import useCommonBase from "@/components/Common/CommonHooks/useCommonBase";
import * as commonFunc from "@/components/Common/commonFunc";
import styles from "./index.less";
const FaceCollectionEvent = props => {
const { formData = [] } = props;
const faceCollectionConfigIndex = formData.findIndex(
item => item.sGrd === "faceCollection"
);
useEffect(
async () => {
if (faceCollectionConfigIndex === -1) return;
const { sTeamId } = commonUtils.getAppData("userinfo");
const result =
(await props.onGetDataSet({
name: "faceCollection",
configData: formData[faceCollectionConfigIndex],
condition: {
sSqlCondition: { sTeamId }
},
isWait: true
})) || {};
const { faceCollectionData = [] } = result;
props.onSaveState({ faceCollectionData });
},
[faceCollectionConfigIndex]
);
return {
...props
};
};
const FaceCollectionComponent = baseProps => {
const { visible, onCancel } = baseProps;
if (!visible) return "";
const props = FaceCollectionEvent(
useCommonBase({
...baseProps,
sModelsId: "17086669370007136849817837261000"
})
);
const { faceCollectionData = [] } = props;
const faceCollection = commonFunc.showLocalMessage(props, 'faceCollection', '人脸采集');
const faceCollectionSucess = commonFunc.showLocalMessage(props, 'faceCollectionSucess', '人脸采集成功');
const selectUser = commonFunc.showLocalMessage(props, 'selectUser', '请选择用户');
const BtnCancel = commonFunc.showLocalMessage(props, 'BtnCancel', '取消');
const BtnNext = commonFunc.showLocalMessage(props, 'BtnNext', '下一步');
const showDropDown = faceCollectionData.reduce((pre, item) => {
return {
...pre,
[item.sEmployeeId]: `${item.sUserName}-${item.sEmployeeNo}`
};
}, {});
const [dataValue, setDataValue] = useState("");
const showTypeProps = {
app: {},
bNewForm: true,
iColValue: 24,
record: {},
name: "master",
formId: props.sModelsId,
getSqlDropDownData: props.getSqlDropDownData,
getSqlCondition: props.getSqlCondition,
handleSqlDropDownNewRecord: props.handleSqlDropDownNewRecord,
getFloatNum: props.getFloatNum,
getDateFormat: props.getDateFormat,
onChange: (...args) => {
setDataValue(args[2].sName);
},
showConfig: {
sName: "sName",
sDropDownType: "const",
showDropDown: JSON.stringify(showDropDown)
},
formItemLayout: { labelCol: { span: 0 }, wrapperCol: { span: 24 } },
textArea: false,
enabled: true,
dataValue,
bTable: true,
bViewTable: true,
onFilterDropDownData: props.onFilterDropDownData,
onSaveState: props.onSaveState,
bPassWord: false,
style: { backgroundColor: "#eaeaea" }
};
const handleNexStep = async () => {
if (!dataValue) {
message.error({selectUser});
return;
}
const userinfo = commonUtils.getAppData("userinfo");
const employeeInfo = faceCollectionData.find(
item => item.sEmployeeId === dataValue
);
const modal = Modal.info({
title: faceCollection,
keyboard: false,
content: (
<FaceDetect
app={{
userinfo: {
...userinfo,
...employeeInfo
}
}}
loginAfterInit
onSaveFaceSuccess={() => {
message.success(faceCollectionSucess);
modal.destroy();
onCancel();
}}
actionType={"saveFace"}
/>
),
wrapClassName: "xlyFaceAuthModal",
okText: BtnCancel,
onOk() {
modal.destroy();
}
});
};
return (
<Modal
open={visible}
title={faceCollection}
width={400}
height={250}
className="mesCommonModal mesLoginForm"
footer={
<Button type="primary" size="large" onClick={handleNexStep}>
{BtnNext}
</Button>
}
onCancel={onCancel}
>
<div className={styles.faceCollection}>
<Form layout="vertical" size="large">
<Form.Item label={selectUser}>
<ShowType {...showTypeProps} />
</Form.Item>
</Form>
</div>
</Modal>
);
};
export default FaceCollectionComponent;