index.js
10.8 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
import React, { useEffect, useState } from "react";
import { Modal, Button, Input, message } from "antd";
import * as commonFunc from "@/components/Common/commonFunc";
import * as commonUtils from "@/utils/utils";
import * as commonBusiness from "@/components/Common/commonBusiness";
import StaticEditTable from "@/components/Common/CommonTable";
import CommonViewTable from "@/components/Common/CommonViewTable";
import useCommonBase from "@/components/Common/CommonHooks/useCommonBase";
import styles from "./index.less";
import { cloneDeep } from "lodash";
const teamInfoSid = "12710101117087385123610";
// 业务层
const useTeamInfoEvent = props => {
const { formData } = props;
useEffect(
async () => {
if (commonUtils.isNotEmptyArr(formData)) {
const colunmData = handleGetColumnData(formData, true);
const result = await handleGetData(formData, true);
const addState = {
bFinish: true,
...colunmData,
...result
};
props.onSaveState(addState);
}
},
[formData]
);
// 默认选中签样部门第一条数据
const { slave0Data = [], slave0SelectedRowKeys = [] } = props;
const sIds = slave0Data.map(item => item.sId).join(",");
useEffect(
() => {
if (
commonUtils.isNotEmptyArr(slave0Data) &&
!slave0SelectedRowKeys.length
) {
onSelectRowChange("slave0", [slave0Data[0].sId]);
}
},
[sIds]
);
// 获取表头数据
const handleGetColumnData = (formData = [], isWait) => {
let addState = {};
for (let i = 0; i < formData.length; i++) {
const config = formData[i];
const column = commonFunc.getHeaderConfig(config);
addState = {
...addState,
[`slave${i}Column`]: column,
[`slave${i}Config`]: config
};
}
if (isWait) {
return addState;
} else {
props.onSaveState(addState);
}
};
// 获取数据集
const handleGetData = async (formData = [], isWait, extraConditions = {}) => {
let addState = {};
for (let i = 0; i < formData.length; i++) {
const config = formData[i];
if (!config) continue;
const conditonValues = props.onGetSqlConditionValues(config);
const staticValues = {
sWorkshopId: props.app.userinfo.sWorkshopId
};
const result =
(await props.onGetDataSet({
name: `slave${i}`,
configData: config,
condition: {
sSqlCondition: {
...conditonValues,
...staticValues,
...extraConditions
}
},
isWait: true
})) || {};
props.setTempRef(result);
addState = { ...addState, ...result };
}
props.setTempRef({}, true);
if (isWait) {
return addState;
} else {
props.onSaveState(addState);
}
};
// 刷新指定表格
const handleRefreshTableOne = (slaveIndex, extraConditions = {}) => {
const formDataNew = new Array(slaveIndex + 1)
.fill("")
.map((_, index) => (index === slaveIndex ? formData[index] : ""));
handleGetData(formDataNew, false, extraConditions);
};
// 初始化后执行一次指令集
useEffect(
() => {
if (!props.bFinish) return;
const { sOnShowInstruct } = formData[0];
if (sOnShowInstruct) {
props.onExecInstructSet({
btnConfig: { sInstruct: sOnShowInstruct, showName: "页面初始化" }
});
}
},
[props.bFinish]
);
const onSelectRowChange = (name, selectedRowKeys) => {
props.onTableSelectRowChange(name, selectedRowKeys);
const selectedData = props.slave0Data.find(
item => item.sId === selectedRowKeys[0]
);
handleRefreshTableOne(1, {
iOrgeh: selectedData.sNo,
sId: selectedRowKeys[0]
});
};
// 如果父页面是签样/完成,发送成功后刷新父页面
const handleSearchParentTable = () => {
const oTab = document.querySelector(
'.ant-tabs-tabpane[id*="签样/完成列表"]'
);
if (!oTab) return;
const oRightBar = oTab.querySelector(".rightBar");
if (!oRightBar) return;
const oSearchBtnList = oRightBar.querySelectorAll(".ant-space-item");
if (oSearchBtnList.length === 0) return;
const oSearchBtnLength = oSearchBtnList.length;
oSearchBtnList[oSearchBtnLength - 1].childNodes[0].click();
};
return {
...props,
// 其他对象
onRefreshTableOne: handleRefreshTableOne,
onSearchParentTable: handleSearchParentTable,
onSelectRowChange
};
};
const firstNoticeModal = _props => {
if (!_props.modalValue) return "";
const props = useTeamInfoEvent(
useCommonBase({ ..._props, sModelsId: teamInfoSid })
);
// 人员
const [employeeName, setEmployeeName] = useState("");
const [filterEmployeeName, setFilterEmployeeName] = useState("");
const tableBaseProps = commonBusiness.getTableTypes("slave1", props);
const tablePropsCrew = {
...tableBaseProps,
data:
tableBaseProps?.data?.filter(item =>
item.sEmployeeName?.includes(filterEmployeeName) || item.sEmployeeNo?.includes(filterEmployeeName)
) || [],
tableProps: {
onChange: () => {},
tableHeight: "100%"
},
onSelectRowChange: (name, selectedRowKeys) => {
props.onTableSelectRowChange(name, selectedRowKeys);
const {
slave1Data = [],
slave2Data = [],
slave2SelectedRowKeys = []
} = props;
const slave2DataCopy = cloneDeep(slave2Data);
slave1Data.forEach(item => {
if (
selectedRowKeys.includes(item.sId) &&
!slave2SelectedRowKeys.includes(item.sId)
) {
slave2DataCopy.push(item);
}
if (
!selectedRowKeys.includes(item.sId) &&
slave2SelectedRowKeys.includes(item.sId)
) {
slave2DataCopy.splice(
slave2DataCopy.findIndex(i => i.sId === item.sId),
1
);
}
});
props.onSaveState({
slave2Data: slave2DataCopy,
slave2SelectedRowKeys: selectedRowKeys
});
}
};
// 收信人
const tablePropsCollect = {
...commonBusiness.getTableTypes("slave2", props),
// data: commonFunc.getTableSelectedData({ props, tableName: "slave1" }),
tableProps: {
onChange: () => {},
tableHeight: "100%"
},
onSelectRowChange: (name, selectedRowKeys) => {
props.onTableSelectRowChange(name, selectedRowKeys);
props.onSaveState({
slave2Data: props.slave2Data.filter(item =>
selectedRowKeys.includes(item.sId)
),
slave1SelectedRowKeys: selectedRowKeys
});
}
};
// 岗位
const tablePropsPost = {
...commonBusiness.getTableTypes("slave0", props),
tableProps: {
onChange: () => {},
tableHeight: "100%"
},
onSelectRowChange: props.onSelectRowChange
};
// 通知列表
const tableProps = {
...commonBusiness.getTableTypes("slave4", props),
tableProps: {
onChange: () => {},
tableHeight: "100%"
}
};
const viewName = "slave3";
const config = props[`${viewName}Config`] || {};
const viewConfigs =
config?.gdsconfigformslave?.filter(item => item.sName && item.bVisible) ||
[];
const viewRow = props[`${viewName}Data`]
? props[`${viewName}Data`][0] || {}
: {};
const viewProps = {
...props,
enabled: true,
viewConfigs,
tableConfig: config,
iColValueView: 24,
viewRow,
tableName: viewName
};
const firstNotice = commonFunc.showLocalMessage(props, 'firstNotice', '首签样通知');
const firstNoticeList = commonFunc.showLocalMessage(props, 'firstNoticeList', '版材消耗登记');
return (
<Modal
title={firstNotice}
footer={null}
open={props.modalValue}
width="65%"
onCancel={() => props.setModalShow(false)}
className="mesCommonModal"
>
<div className={styles.firstNoticeBox}>
<div className="noticeInfo">
<div className="post">
{/* <h2>签样岗位</h2> */}
<div className="post_table">
<StaticEditTable {...tablePropsPost} />
</div>
</div>
<div className="postUser">
<div className="postUser_box">
<div className="postTable">
<StaticEditTable {...tablePropsCrew} />
</div>
<div className="userTable">
<StaticEditTable {...tablePropsCollect} />
</div>
</div>
<div className="postUser-foot">
<Button
size="large"
type="primary"
onClick={() => {
setEmployeeName("");
setFilterEmployeeName("");
}}
>
全 部
</Button>
<Input
size="large"
placeholder="员工名称/工号"
style={{ border: "1px solid #AAA", borderRadius: 5 }}
value={employeeName}
onChange={e => {
setEmployeeName(e.target.value);
}}
/>
<Button
size="large"
type="primary"
onClick={() => {
setFilterEmployeeName(employeeName);
}}
>
查 询
</Button>
</div>
</div>
<div className="postFrom">
<div class="postFrom_box">
<CommonViewTable {...viewProps} />
</div>
<div className="postFrom-foot">
<Button
size="large"
type="primary"
onClick={() => props.setModalShow(false)}
style={{ background: "#ff7800", "border-color": "#ff7800" }}
>
取 消
</Button>
<Button
size="large"
type="primary"
onClick={() => {
if (commonUtils.isEmptyObject(tablePropsCollect.data)) {
message.info("请先选择接收人!");
return;
}
const btnSendConfig = props.slave3Config.gdsconfigformslave.find(
item => item.sControlName === "BtnSend"
);
props.onExecInstructSet({
btnConfig: btnSendConfig,
callback: () => {
props.onRefreshTableOne(4);
props.onSearchParentTable();
}
});
}}
>
发 送
</Button>
</div>
</div>
</div>
<div class="noticeList">
<h2>{firstNoticeList}</h2>
<div>
<StaticEditTable {...tableProps} />
</div>
</div>
</div>
</Modal>
);
};
export default firstNoticeModal;