WorkOrderSystemDetail.js
31.3 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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
/* eslint-disable */
import { useEffect, useState, useRef } from "react";
import { Button, Form, Space, Upload, Select, Switch, message, DatePicker, Modal, Spin, Input, Image, InputNumber } from "antd-v4";
import { CheckOutlined, CloseCircleOutlined, EditOutlined, SendOutlined, SaveOutlined, MinusOutlined, ThunderboltOutlined } from "@ant-design/icons";
import BackIcon from "@/assets/back.svg";
import CopyAllIcon from "@/assets/copyallWhite.svg";
import moment from "moment";
import BraftEditor from "braft-editor";
import "braft-editor/dist/index.css";
import gStyles from "@/index.less";
import styles from "./index.less";
import commonConfig from "@/utils/config";
import * as commonUtils from "@/utils/utils";
import AntdDraggableModal from "@/components/Common/AntdDraggableModal";
import WorkOrderSystemService from "./WorkOrderSystemService";
import WorkOrderSystemConfig from "./WorkOrderSystemConfig";
// 主入口
const WorkOrderSystemDetail = props => {
const [loading, setLoading] = useState(false);
// 详情弹窗id
const { current: detailModalId } = useRef("detailModalId_" + Math.random().toString(36).substring(2));
// 最小化状态
const [bMin, setBMin] = useState(false);
window.setBMin = setBMin;
// 强制更新视图
const [updater, setUpdater] = useState(0);
const forceUpdate = () => {
setUpdater(updater + 1);
};
// 刷新页面
const [refresher, setRefresher] = useState(0);
const refresh = () => {
setRefresher(refresher + 1);
};
const [form] = Form.useForm();
const [formEnabled, setFormEnabled] = useState(false);
const { sId, app, refreshSlaveTable, gdsjurisdiction } = props;
const { userinfo } = app;
const { sUserName: sMakePerson } = userinfo;
const [detailData, setDetailData] = useState({});
const {
sTitle,
fileData = [],
replyData = [],
sContentMemo,
sCustomerId,
sCustomerName,
sModuleId,
sModuleName,
sHanldeId,
sRDUserId,
sCopyHanldeId,
bVsersion,
sBug,
sType,
tDevHandleDate,
tHandleDate,
sStatus,
} = detailData;
const [customerOption, setCustomerOption] = useState([]); // 【所属客户】下拉选项
const [moduleOption, setModuleOption] = useState([]); // 【所属模块】下拉选项
const [userOption, setUserOption] = useState([]); // 【处理人、抄送人】下拉选项
const { priorityOption, sBugOption } = WorkOrderSystemConfig; // 各种固定下拉选项
const [replyModalVisible, setReplyModalVisible] = useState(false); // 回复弹窗状态
const [assignmentModalVisible, setAssignmentModalVisible] = useState(false); // 指派弹窗状态
const [resolutionModalVisible, setResolutionModalVisible] = useState(false); // 解决弹窗状态
const enabled = !["已关闭"].includes(sStatus); // 是否可操作
const [bSoluted, setSolutedState] = useState(false); // 是否已解决状态
// 富文本看点击图片事件
const [imageVisible, setImageVisible] = useState(false);
const [imageSrc, setImageSrc] = useState(null);
useEffect(() => {
const showImage = e => {
if (e.target && e.target.nodeName === "IMG") {
const { src } = e.target;
if (src) {
setImageSrc(src);
setImageVisible(true);
}
}
};
document.addEventListener("dblclick", showImage);
return () => {
document.removeEventListener("dblclick", showImage);
};
}, []);
// 判断是否已解决
useEffect(() => {
let result = ["已解决"].includes(sStatus);
if (!result) {
// 如果状态不是已解决,查看历史记录中最后一个非已指派的是否是已解决
replyData.forEach(item => {
const { sResult } = item;
if (sResult === "已解决") {
result = true;
} else if (sResult === "已激活") {
result = false;
}
});
}
setSolutedState(result);
}, [detailData]);
// 显示的按钮
const [btnShowData, setBtnShowData] = useState([]);
// 过滤掉没有权限的按钮
useEffect(() => {
let defaultBtnData = ["BtnReplyd", "BtnEdit", "BtnAssign", "BtnSolve", "BtnClose"];
if (!enabled) {
setBtnShowData([]);
return;
} else if (bSoluted) {
defaultBtnData = ["BtnAssign", "BtnActive", "BtnClose"];
}
if (gdsjurisdiction) {
gdsjurisdiction.forEach(child => {
const index = defaultBtnData.findIndex(item => item === child.sAction);
if (index > -1) {
defaultBtnData.splice(index, 1);
}
});
}
setBtnShowData(defaultBtnData);
}, [gdsjurisdiction, enabled, bSoluted]);
// 指派/解决
const addReplyHanle = async values => {
if (values.sContentMemo === "<p></p>") {
delete values.sContentMemo;
}
const response = await WorkOrderSystemService.addReplyHanle({
...values,
sId,
sMakePerson,
});
setLoading(false);
if (commonUtils.isNotEmptyObject(response)) {
refreshSlaveTable();
if (["已激活"].includes(values.sResult)) {
refresh();
} else {
props.onSaveState({
workOrderSystemDetailModalVisible: false,
});
}
}
};
// 初始化加载数据
useEffect(() => {
const handleDetailData = async () => {
setDetailData(await WorkOrderSystemService.getDetailData({ sId }));
setCustomerOption(
(await WorkOrderSystemService.getsCustomerData()).map(item => ({
label: item.sCustomerName,
value: item.sCustomerId || item.sId,
item,
}))
);
setModuleOption(
(await WorkOrderSystemService.getsModuleData()).map(item => ({
label: item.sModuleName,
value: item.sModuleId,
item,
}))
);
setUserOption(
(await WorkOrderSystemService.getUserData()).map(item => ({
label: item.sHanldeName,
value: item.sHanldeId,
item,
}))
);
};
handleDetailData();
}, [refresher]);
// detailData变化时,给表单赋值
useEffect(() => {
if (commonUtils.isNotEmptyArr(detailData) && commonUtils.isNotEmptyArr(customerOption) && commonUtils.isNotEmptyArr(moduleOption)) {
const temp = {};
replyData.forEach((item, index) => {
const { tCreateDate, sMakePerson: sMakePersonTemp, sResult, sContentMemo: sContentMemoTemp, sAssignedBy } = item;
temp[`reply${index}`] = (
<span>
{index + 1}.{tCreateDate} <span>由</span> <strong>{sMakePersonTemp}</strong> {sResult.replace("已", "")}
{[""].map(() => {
if (!sAssignedBy) {
return "";
} else if (sAssignedBy && sResult.includes("解决") && sMakePersonTemp === sAssignedBy) {
return "";
} else if (sAssignedBy && sResult.includes("解决")) {
return (
<>
<span>并指派给 </span>
<strong>{sAssignedBy}</strong>
</>
);
} else {
return (
<>
<span>给 </span>
<strong>{sAssignedBy}</strong>
</>
);
}
})}
</span>
);
if (sContentMemoTemp) {
temp[`replyContentMemo${index}`] = BraftEditor.createEditorState(sContentMemoTemp);
}
});
const addState = {};
if (sCustomerId) {
if (customerOption.find(item => item.value === sCustomerId)) {
addState.sCustomerId = sCustomerId;
} else {
setCustomerOption(prevState => [
...prevState,
{
value: sCustomerId,
label: sCustomerName,
item: {
sCustomerId,
sCustomerName,
},
},
]);
}
}
if (sModuleId) {
if (moduleOption.find(item => item.value === sModuleId)) {
addState.sModuleId = sModuleId;
} else {
setModuleOption(prevState => [
...prevState,
{
value: sModuleId,
label: sModuleName,
item: {
sModuleId,
sModuleName,
},
},
]);
}
}
form.setFieldsValue({
sTitle,
sContentMemo: BraftEditor.createEditorState(sContentMemo),
...addState,
sHanldeId,
sCopyHanldeId: sCopyHanldeId ? sCopyHanldeId.split(",") : [],
sRDUserId,
bVsersion,
sBug,
sType: sType !== undefined ? parseInt(sType) : "",
tDevHandleDate: tDevHandleDate ? moment(tDevHandleDate) : "",
tHandleDate: tHandleDate ? moment(tHandleDate) : "",
...temp,
});
forceUpdate();
}
}, [detailData, customerOption, moduleOption]);
const [fileList, setFileList] = useState([]); // 附件列表
const [fileAdd, setFileAdd] = useState([]); // 新增附件
// fileData变化时,给附件列表赋值
useEffect(() => {
setFileList(
[...fileData].map(item => {
const { sId: uid, sPictureName: name, sPicturePath } = item;
return {
uid,
name,
url: `${commonConfig.feedback_host}file/download?savePathStr=${sPicturePath}&sModelsId=100`,
status: "done",
item,
};
})
);
}, [fileData]);
// fileAdd变化时,调用新增附件接口
useEffect(() => {
if (!fileAdd.length) return;
const handleFileAdd = async () => {
setFileAdd([]);
const _fileData = await WorkOrderSystemService.uploadAdd(fileAdd, {
sId,
sMakePerson,
});
setFileList([
...fileList,
..._fileData.map(item => {
const { sId: uid, sPictureName: name, sPicturePath } = item;
return {
uid,
name,
url: `${commonConfig.feedback_host}file/download?savePathStr=${sPicturePath}&sModelsId=100`,
status: "done",
item,
};
}),
]);
};
handleFileAdd();
}, [fileAdd]);
// 附件props
const uploadProps = {
accept: "*/*",
multiple: true,
fileList,
disabled: !btnShowData.includes("BtnEdit"),
beforeUpload: file => {
setFileAdd(prevState => [...prevState, file]);
return false;
},
onRemove: file => {
Modal.confirm({
title: "确认删除",
onOk() {
WorkOrderSystemService.deleteFile(file.item, sId, () => {
setFileList(fileList.filter(item => item.uid !== file.uid));
message.success("附件删除成功");
});
},
});
},
};
// 回复props
const replyProps = {
...props,
replyModalVisible,
detailData,
detailModalId,
setReplyModalVisible,
refresh,
bMin,
setBMin,
};
// 指派props
const assignmentProps = {
...props,
bMin,
setBMin,
userOption,
visible: assignmentModalVisible,
setVisible: setAssignmentModalVisible,
detailData,
onFinish: values => {
setLoading(true);
setAssignmentModalVisible(false);
const { value, label } = userOption.find(item => item.value === values.sHanldeId);
const copyDataAdd = {};
const copyData = userOption.filter(item => values.sCopyHanldeId.includes(item.value));
if (commonUtils.isNotEmptyArr(copyData)) {
copyDataAdd.sCopyFor = copyData.map(item => item.label).toString();
copyDataAdd.sCopyForId = copyData.map(item => item.value).toString();
}
addReplyHanle({
sAssignedBy: label,
sAssignedById: value,
...copyDataAdd,
sContentMemo: values.sContentMemo ? values.sContentMemo.toHTML() : "<p></p>",
sResult: "已指派",
});
},
};
// 解决props
const resolutionModalProps = {
...props,
bResolution: true,
userOption,
visible: resolutionModalVisible,
setVisible: setResolutionModalVisible,
detailData,
bMin,
setBMin,
onFinish: values => {
setLoading(true);
setResolutionModalVisible(false);
const { value, label } = userOption.find(item => item.value === values.sHanldeId);
const copyDataAdd = {};
const copyData = userOption.filter(item => values.sCopyHanldeId.includes(item.value));
if (commonUtils.isNotEmptyArr(copyData)) {
copyDataAdd.sCopyFor = copyData.map(item => item.label).toString();
copyDataAdd.sCopyForId = copyData.map(item => item.value).toString();
}
addReplyHanle({
sAssignedBy: label,
sAssignedById: value,
dSolveHourSj: values.dSolveHourSj,
...copyDataAdd,
sContentMemo: values.sContentMemo ? values.sContentMemo.toHTML() : "<p></p>",
sResult: "已解决",
});
},
};
// 图片弹窗props
const imageModalProps = {
imageSrc,
imageVisible,
setImageVisible,
};
// 修改后保存
const onFinish = async values => {
setLoading(true);
const {
sContentMemo,
sCustomerId,
sModuleId,
sHanldeId,
sCopyHanldeId,
sRDUserId,
bVsersion,
sBug,
sType,
tDevHandleDate,
tHandleDate,
dSolveHour,
} = values;
const response = await WorkOrderSystemService.detailUpdate({
sId,
sMakePerson,
sTitle,
sContentMemo: sContentMemo.toHTML(),
...customerOption.find(item => item.value === sCustomerId).item,
...moduleOption.find(item => item.value === sModuleId).item,
...userOption.find(item => item.value === sHanldeId).item,
sCopyHanldeId: sCopyHanldeId.toString(),
sCopyHanldeName: userOption
.filter(item => sCopyHanldeId.includes(item.value))
.map(item => item.label)
.toString(),
sRDUserId,
sRDUserName: userOption.find(item => sRDUserId === item.value)?.label,
bVsersion,
sBug,
sType,
tDevHandleDate: tDevHandleDate ? moment(tDevHandleDate).format("YYYY-MM-DD") : undefined,
tHandleDate: tDevHandleDate ? moment(tHandleDate).format("YYYY-MM-DD") : undefined,
dSolveHour,
sStatus: "已修改",
});
setLoading(false);
if (commonUtils.isNotEmptyObject(response)) {
setFormEnabled(false);
refresh();
refreshSlaveTable();
}
};
return (
<Spin spinning={loading}>
<Form
form={form}
onFinish={onFinish}
labelCol={{
span: 3,
}}
wrapperCol={{
span: 21,
}}
className={`${styles.workOrderSystemDetail} ${detailModalId}`}
>
<Form.Item
name="sTitle"
labelCol={{
span: 0,
}}
wrapperCol={{
span: 24,
}}
>
<Input.TextArea
disabled
bordered={false}
autoSize={{ minRows: 1, maxRows: 10 }}
style={{
fontSize: 16,
fontWeight: "bold",
resize: "none",
color: "#000",
}}
/>
</Form.Item>
<Form.Item
name="sContentMemo"
labelCol={{
span: 0,
}}
wrapperCol={{
span: 24,
}}
>
<BraftEditor className={styles.braftEditorReadOnly} readOnly={true} controls={[]} />
</Form.Item>
<Form.Item className={styles.formItemHalf} name="sCustomerId" label="所属客户" rules={[{ required: formEnabled }]}>
<Select
allowClear
showSearch={true}
options={customerOption}
optionFilterProp="label"
placeholder="请选择所属客户"
disabled={!formEnabled}
/>
</Form.Item>
<Form.Item className={styles.formItemHalf} name="sModuleId" label="所属模块" rules={[{ required: formEnabled }]}>
<Select
mode={formEnabled ? "tags" : ""}
showSearch={true}
options={moduleOption}
optionFilterProp="label"
placeholder="请选择所属模块"
disabled={!formEnabled}
onChange={value => {
if (value.length) {
form.setFieldValue("sModuleId", value[value.length - 1]);
}
}}
/>
</Form.Item>
<Form.Item className={styles.formItemHalf} name="sHanldeId" label="处理人" rules={[{ required: formEnabled }]}>
<Select allowClear showSearch={true} options={userOption} optionFilterProp="label" placeholder="请选择处理人" disabled={!formEnabled} />
</Form.Item>
<Form.Item className={styles.formItemHalf} name="sCopyHanldeId" label="抄送人">
<Select
allowClear
showSearch={true}
options={userOption}
optionFilterProp="label"
mode="multiple"
placeholder={formEnabled ? "请选择抄送人" : ""}
disabled={!formEnabled}
/>
</Form.Item>
<Form.Item
// className={styles.formItemHalf}
name="sRDUserId"
label="研发人员"
>
<Select allowClear showSearch={true} options={userOption} optionFilterProp="label" placeholder="请选择研发人员" disabled={!formEnabled} />
</Form.Item>
<Form.Item className={styles.formItemAQuarter} name="bVsersion" label="标版同样问题" valuePropName="checked">
<Switch checkedChildren="是" unCheckedChildren="否" disabled={!formEnabled} />
</Form.Item>
<Form.Item className={styles.formItemBug} name="sBug" label="是否bug">
<Select options={sBugOption} optionFilterProp="label" disabled={!formEnabled} />
</Form.Item>
<Form.Item className={styles.formItemAQuarter} name="sType" label="优先级">
<Select
className={styles.sTypeSelect}
popupClassName={styles.sTypedDropdown}
options={priorityOption}
optionFilterProp="label"
disabled={!formEnabled}
/>
</Form.Item>
<Form.Item
className={styles.formItemAQuarter1}
name="tDevHandleDate"
label="开发截止日期"
rules={[
{
validator: (_, chooseDate) => {
const tHandleDate = form.getFieldValue().tHandleDate;
if (chooseDate && tHandleDate && chooseDate.isAfter(tHandleDate)) {
return Promise.reject(new Error("【开发截止日期】不能晚于【截止日期】"));
} else {
return Promise.resolve();
}
},
},
]}
>
<DatePicker placeholder={formEnabled ? "请选择开发截止日期" : ""} disabled={!formEnabled} />
</Form.Item>
<Form.Item
className={styles.formItemAQuarter1}
name="tHandleDate"
label="截止日期"
rules={[
{
validator: (_, chooseDate) => {
const tDevHandleDate = form.getFieldValue().tDevHandleDate;
if (chooseDate && tDevHandleDate && chooseDate.isBefore(tDevHandleDate)) {
return Promise.reject(new Error("【截止日期】不能早于【开发截止日期】"));
} else {
return Promise.resolve();
}
},
},
]}
>
<DatePicker placeholder={formEnabled ? "请选择截止日期" : ""} disabled={!formEnabled} />
</Form.Item>
<div className={styles.replyDiv}>
<div className={styles.replyTitle}>历史记录</div>
{replyData.map((item, index) => {
const { sContentMemo: sContentMemoTemp } = item;
const itemName = `reply${index}`;
const itemName1 = `replyContentMemo${index}`;
const itemDom = form.getFieldValue()[itemName];
return (
itemDom && (
<>
<Form.Item name={itemName} key={index}>
<div style={{ fontSize: 14 }}>{itemDom}</div>
</Form.Item>
{sContentMemoTemp ? (
<Form.Item name={itemName1}>
<BraftEditor className={styles.detailBraftEditorReply} readOnly={true} controls={[]} />
</Form.Item>
) : (
""
)}
</>
)
);
})}
</div>
<Form.Item name="fileData" label="附件" className={styles.annex}>
<Upload {...uploadProps}>{btnShowData.includes("BtnEdit") && <a>添加附件</a>}</Upload>
</Form.Item>
<Form.Item />
<Form.Item className={styles.fixedBtns}>
<Space>
{!formEnabled && (
<Button
type="primary"
icon={<img src={BackIcon} />}
className={styles.iconBtn}
style={{ background: "#838A9D", borderColor: "#838A9D" }}
onClick={() => {
props.onSaveState({
workOrderSystemDetailModalVisible: false,
});
}}
>
返回
</Button>
)}
{!formEnabled && btnShowData.includes("BtnReplyd") && (
<Button
type="primary"
icon={<img src={CopyAllIcon} />}
className={styles.iconBtn}
style={{ background: "#ff822d", borderColor: "#ff822d" }}
onClick={() => {
setReplyModalVisible(true);
}}
>
回复
</Button>
)}
{!formEnabled && btnShowData.includes("BtnEdit") && (
<Button
type="primary"
icon={<EditOutlined />}
className={styles.iconBtn}
onClick={() => {
setFormEnabled(true);
document.querySelector(`.${detailModalId}`).scrollTop = 0;
}}
>
修改
</Button>
)}
{formEnabled && (
<Button
type="primary"
htmlType="submit"
icon={<SaveOutlined />}
style={{ background: "#ff822d", borderColor: "#ff822d" }}
className={styles.iconBtn}
>
保存
</Button>
)}
{formEnabled && (
<Button
type="primary"
icon={<CloseCircleOutlined />}
className={styles.iconBtn}
onClick={() => {
setFormEnabled(false);
refresh();
}}
>
取消
</Button>
)}
{!formEnabled && btnShowData.includes("BtnAssign") && (
<Button
type="primary"
icon={<SendOutlined />}
className={styles.iconBtn}
onClick={() => {
setAssignmentModalVisible(true);
}}
>
指派
</Button>
)}
{!formEnabled && btnShowData.includes("BtnSolve") && (
<Button
type="primary"
icon={<CheckOutlined />}
className={styles.iconBtn}
onClick={() => {
setResolutionModalVisible(true);
}}
>
解决
</Button>
)}
{!formEnabled && btnShowData.includes("BtnActive") && (
<Button
type="primary"
icon={<ThunderboltOutlined />}
className={styles.iconBtn}
onClick={() => {
addReplyHanle({
sResult: "已激活",
});
}}
>
激活
</Button>
)}
{!formEnabled && btnShowData.includes("BtnClose") && (
<Button
type="primary"
icon={<CloseCircleOutlined />}
className={styles.iconBtn}
onClick={() => {
Modal.confirm({
title: "确认关闭工单",
onOk() {
const evaluate = async () => {
const result = await WorkOrderSystemService.evaluate({
dEvaluate: 5,
sId,
sMakePerson,
});
if (result) {
refreshSlaveTable();
props.onSaveState({
workOrderSystemDetailModalVisible: false,
});
}
};
evaluate();
},
});
}}
>
关闭工单
</Button>
)}
</Space>
</Form.Item>
</Form>
{replyModalVisible && <ReplyModal {...replyProps} />}
{assignmentModalVisible && <AssignmentModal {...assignmentProps} />}
{resolutionModalVisible && <AssignmentModal {...resolutionModalProps} />}
{imageVisible && <ImageModal {...imageModalProps} />}
</Spin>
);
};
// 回复弹窗
const ReplyModal = props => {
const { replyModalVisible, detailData, detailModalId, setReplyModalVisible, refresh, bMin, setBMin } = props;
const { sId, sTitle } = detailData;
const [loading, setLoading] = useState(false);
const closeModal = () => {
setReplyModalVisible(false);
};
const onFinish = async values => {
setLoading(true);
const { app } = props;
const { userinfo } = app;
const { sUserName: sMakePerson, sId: sLoginId } = userinfo;
const returnData = await WorkOrderSystemService.addReply({
sContentMemo: values.sContentMemo.toHTML(),
sMakePerson,
sLoginId,
sId,
status: "回复",
});
setLoading(false);
if (commonUtils.isNotEmptyArr(returnData)) {
message.success("成功");
refresh();
setTimeout(() => {
document.querySelector(`.${detailModalId}`).scrollTop = 9999;
}, 500);
closeModal();
}
};
return (
replyModalVisible && (
<AntdDraggableModal
title={
<>
<span>
{sTitle}
-回复内容
</span>
<Button
type="link"
style={{
position: "absolute",
right: 30,
top: 6,
color: "#4a495f",
}}
onClick={() => {
props.onSaveState({ bMin: true }, () => {
setBMin(true);
});
}}
>
<MinusOutlined />
</Button>
</>
}
open={replyModalVisible && !bMin}
className={`${gStyles.workOrderSystemModal} ${styles.replyModal}`}
style={{ top: "10vh" }}
width="80vw"
footer={null}
onCancel={closeModal}
>
<Spin spinning={loading}>
<Form onFinish={onFinish}>
<Form.Item
name="sContentMemo"
label=""
rules={[
{
required: true,
validator: (_, sContentMemo) => {
if (sContentMemo.toHTML() === "<p></p>") {
return Promise.reject(new Error("请输入内容"));
} else {
return Promise.resolve();
}
},
},
]}
>
<BraftEditor
className={styles.replyBraftEditor}
readOnly={false}
media={{
uploadFn: WorkOrderSystemService.uploadFn,
}}
/>
</Form.Item>
<Form.Item className={styles.flexCener}>
<Space>
<Button onClick={closeModal}>取消</Button>
<Button htmlType="submit" type="primary">
确认
</Button>
</Space>
</Form.Item>
</Form>
</Spin>
</AntdDraggableModal>
)
);
};
// 指派弹窗
const AssignmentModal = props => {
const { visible, userOption, detailData, onFinish, setVisible, bResolution, setBMin, bMin } = props;
const { sTitle, sCopyHanldeId } = detailData;
const initialValues = {
sCopyHanldeId: sCopyHanldeId ? sCopyHanldeId.split(",") : [],
};
const closeModal = () => {
setVisible(false);
};
return (
visible && (
<AntdDraggableModal
title={
<>
<span>{bResolution ? "已解决确认" : `${sTitle}-指派人选择`}</span>
<Button
type="link"
style={{
position: "absolute",
right: 30,
top: 6,
color: "#4a495f",
}}
onClick={() => {
props.onSaveState({ bMin: true }, () => {
setBMin(true);
});
}}
>
<MinusOutlined />
</Button>
</>
}
open={visible && !bMin}
className={`${gStyles.workOrderSystemModal} ${styles.assignmentModal}`}
style={{ top: "10vh" }}
width="80vw"
footer={null}
onCancel={closeModal}
>
<Form
initialValues={initialValues}
onFinish={onFinish}
labelCol={{
span: 2,
}}
wrapperCol={{
span: 22,
}}
>
<Form.Item name="sHanldeId" label="指派人" rules={[{ required: true }]}>
<Select allowClear showSearch={true} options={userOption} optionFilterProp="label" placeholder="请选择指派人" />
</Form.Item>
<Form.Item name="sCopyHanldeId" label="抄送人">
<Select allowClear mode="multiple" showSearch={true} options={userOption} optionFilterProp="label" placeholder="请选择抄送人" />
</Form.Item>
{bResolution ? (
<Form.Item name="dSolveHour" label="研发时间" rules={[{ required: true }]}>
<InputNumber addonAfter="小时" style={{ width: 200 }} />
</Form.Item>
) : (
""
)}
<Form.Item name="sContentMemo" label="备注">
<BraftEditor
className={styles.replyBraftEditor}
readOnly={false}
media={{
uploadFn: WorkOrderSystemService.uploadFn,
}}
/>
</Form.Item>
<Form.Item className={styles.flexCener}>
<Space>
<Button onClick={closeModal}>取消</Button>
<Button htmlType="submit" type="primary">
确认
</Button>
</Space>
</Form.Item>
</Form>
</AntdDraggableModal>
)
);
};
// 图片弹窗
const ImageModal = ({ imageSrc, imageVisible, setImageVisible }) => {
return (
<Image
style={{ display: "none" }}
preview={{
visible: imageVisible,
scaleStep: 0.2,
src: imageSrc,
onVisibleChange: () => {
setImageVisible(false);
},
}}
/>
);
};
export default WorkOrderSystemDetail;