ApprovalForm.vue
36.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
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
<template>
<div class="approval-form">
<div
class="approval-form__content"
:class="{ 'two-column-layout__content': currentShowDialogAlias }"
>
<el-row class="approval-form__top-row">
<el-col :span="4">
<i class="icon-task-back back-icon" @click="handleBack"></i>
<span class="top-title">{{ $t('flowButton.ApprovalForm') }}</span>
</el-col>
<el-col :span="20" class="top-col">
<el-button
v-if="isShowCopyBtn"
type="text"
icon="el-icon-document-copy"
@click="instanceCopy"
>
{{ $t('flowButton.Copy') }}
</el-button>
<el-button
type="text"
icon="icon-task-circulate"
@click="handleCirculate"
>
{{ $t('flowButton.Circulate') }}
</el-button>
<el-button
type="text"
icon="icon-task-communicate"
@click="handleCommunication"
>
{{ $t('flowButton.Communication') }}
</el-button>
<el-button type="text" icon="icon-task-follow" @click="handleFllow">
{{ $t('flowButton.Tracking') }}
</el-button>
<el-button
v-show="false"
ref="printBtn"
v-print="'#flow-form-container'"
type="text"
icon="icon-print"
>
{{ $t('flowButton.Print') }}
</el-button>
<el-button type="text" icon="icon-print" @click="showPrintDialog()">
{{ $t('flowButton.Print') }}
</el-button>
<el-button
v-show="false"
ref="printBtn"
v-print="'#flow-form-container'"
type="text"
icon="icon-print"
@click="showPrintDialog"
>
{{ $t('flowButton.Print') }}
</el-button>
<el-button
type="text"
icon="icon-shenpiyuce"
@click="showFigureDialog()"
>
<span class="predictButton">预测图</span>
</el-button>
<el-button
type="text"
icon="icon-task-flow-chart"
@click="handleFlowChart"
>
{{ $t('flowButton.FlowChart') }}
</el-button>
<template v-if="!['circulate', 'delegate'].includes(from)">
<el-button
v-if="!taskId"
type="text"
icon="icon-task-reminders"
@click="handleUrgent"
>
{{ $t('flowButton.Urgent') }}
</el-button>
</template>
<el-button
type="text"
icon="icon-shujushitu1"
@click="processInfoDialog"
>
{{ $t('flowButton.ProcessInfo') }}
</el-button>
<!-- <el-button
v-if="!(approvalType == 'request' || approvalType == 'done')"
type="text"
icon="icon-task-deal-record"
@click="previewProcessDialog"
>
流程预演
</el-button> -->
</el-col>
</el-row>
<flow-form
ref="approvalFlowForm"
:form="form"
:data.sync="data"
:inst-id="procInstId"
:permission="permission"
:is-dialog-model="isDialogModel"
:record-data="recordData"
:done-data-version="doneDataVersion"
:node-options="nodeList"
:current-select-node="currentSelectNode"
:current-task-id="taskId"
@getInstStatus="getInstStatus"
@node-change="handleNodeChange"
@updateHeaderData="updateHeaderData"
@get-process-sponsor="getProcessSponsor"
/>
<approval-button
ref="approvalButton"
:class="[
currentShowDialogAlias ? 'hide-approval-btn' : 'show-approval-btn',
]"
:node-type="nodeType"
:form-key="formKey"
:form-type="formType"
:read-id="readId"
:data.sync="data"
:instance-status="instanceStatus"
:process-inst-status="processInstStatus"
:is-get-approval-button="Boolean(currentTaskId)"
:before-click="handleBeforeClick"
:dialog-before-click="(alias) => dialogClick('before', alias)"
:dialog-after-click="(alias) => dialogClick('after', alias)"
v-bind="$attrs"
:opinion-field="opinionField"
:append-opinion="appendOpinion"
:current-node-info="currentNodeInfo"
:node-id="nodeId"
:proc-def-key="procDefKey"
:approval-button-list="approvalButtonList"
v-on="$listeners"
@load-Data="loadData"
></approval-button>
</div>
<!-- 流程信息 -->
<process-info
:show.sync="isShowProcessInfo"
:inst-id="procInstId"
:is-get-approval-btn="Boolean(isGetApprovalBtn)"
:is-show-urge-info="type != 'read' && !myReadType"
></process-info>
<!-- 流程审批人和路径预演 -->
<node-path
ref="nodePath"
:inst-id="procInstId"
:node-id="nodeId"
:form-data="data"
/>
<!-- 催办记录 -->
<urgent-record ref="urgentrecord" :inst-id="procInstId" />
<!-- 处理记录 -->
<process-record-dialog
ref="processRecordDialog"
:inst-id="procInstId"
:task-id="taskId"
:refer-opinion="referOpinion"
:node-type="nodeType"
:def-id="defId"
:node-id="nodeId"
/>
<!-- 催办 -->
<task-urgent
ref="taskUrgent"
:def-id="defId"
:subject="subject"
:inst-id="procInstId"
/>
<!-- 审批预测 -->
<processForecast
ref="processForecast"
:inst-id="instId"
:def-id="defId"
:data="data"
:node-id="nodeId"
:header-data="headerData"
:bpmn-inst-id="bpmnInstId"
></processForecast>
<!-- 跟踪设置 -->
<fllow-setting ref="fllowSetting" :def-id="defId" :inst-id="procInstId" />
<!-- 沟通 -->
<communication
ref="communication"
:def-id="defId"
:inst-id="procInstId"
:node-id="nodeId"
:notice-id="noticeId"
:is-get-approval-btn="Boolean(isGetApprovalBtn)"
@submit-after="handleSubmitAfter"
/>
<!-- 传阅 -->
<circulate
ref="circulate"
:task-id="copyTaskId"
:inst-id="procInstId"
:node-id="nodeId"
:notice-id="noticeId"
:is-get-approval-btn="Boolean(isGetApprovalBtn)"
@submit-after="handleSubmitAfter"
/>
<!-- 流程图 -->
<ht-flow-chart
ref="flowChart"
:inst-id="procInstId"
:bpmn-inst-id="bpmnInstId"
/>
<!-- 表单打印 -->
<form-print
v-if="form"
ref="formPrint"
:data="formPrintTemplateList"
:form-data="data"
:def-id="defId"
:node-id="nodeId"
:proc-inst-id="instId"
:form-id="form.id"
:refer-opinion="referOpinion"
:node-type="nodeType"
:task-id="taskId"
:def-key="flowDefKey"
:record-data="recordData"
:form-key="formKey"
:form="form"
:instance-status="instanceStatus"
@printCurForm="handleCurFormPrint"
@loadTempalte="loadPrintTemplate"
></form-print>
</div>
</template>
<script>
import { mapActions, mapState, mapMutations } from 'vuex'
import ApprovalButton from './components/ApprovalButton'
import UrgentRecord from '@/views/matter/components/UrgentRecord'
import ProcessRecordDialog from '@/components/flow/processRecordDialog'
import Circulate from './components/Circulate'
import TaskUrgent from './components/TaskUrgent'
import FllowSetting from './components/FllowSetting'
import Communication from './components/Communication'
import FlowForm from './form/FlowForm.vue'
import FormPrint from './print/FormPrint.vue'
import processForecast from './processForecast/processForecast.vue'
import NodePath from '@/components/flow/nodePath.vue'
import ProcessInfo from '@/views/matter/components/ProcessInfo'
import { getNotice, getFlowStatus, checkTaskAuth } from '@/api/flow'
import {
markTaskAsRead,
getDoneByInstId,
getDoneByInstIdAndAccount,
setRead,
getNoticeTodoReadById,
getNodePrintTemplate,
} from '@/api/process'
import { getFormPrintList } from '@/api/form'
import {
processIsOver,
getInstanceByInstId,
getTaskDetailBo,
getInstFormAndBO,
} from '@/api/process'
import { getFlowGlobalTemplate, getApprovalButtons } from '@/api/flow'
import print from '@/assets/print'
import { Base64 } from 'js-base64'
export default {
name: 'ApprovalForm',
components: {
ApprovalButton,
UrgentRecord,
ProcessRecordDialog,
Circulate,
TaskUrgent,
FllowSetting,
Communication,
FlowForm,
UrgentRecord,
ProcessRecordDialog,
TaskUrgent,
FormPrint,
NodePath,
processForecast,
ProcessInfo,
},
directives: {
print,
},
provide() {
return {
headerData: this.headerData,
nodeId: this.nodeId,
data: this.data,
instId: this.instId,
}
},
props: {
type: {
type: String,
default: '',
},
myReadType: Boolean,
currentTaskId: {
type: String,
default: '',
},
currentInstId: {
type: String,
default: '',
},
currentLearderId: {
type: String,
default: '',
},
},
data() {
return {
test: `同意qweqweq\r\n超级管理员 2021-10-11 19:11:57\n\n同意确认通过\n超级管理员 2021-10-11 19:13:43`,
form: null,
formKey: '',
formType: '',
data: null,
permission: null,
headerData: {
id: '',
creator: '',
updateTime: '',
procDefName: '',
status: '',
currentNode: '',
},
defId: '',
execId: '',
status: '',
subject: '',
bpmnInstId: '',
instStatus: '',
flowDefKey: '',
copyTaskId: '',
procInstId: '',
// isOpen: false, //是否打开处理记录弹窗
nodeId: '', //当前任务节点
nodeType: '', //当前任务类型
procDefKey: '', //流程名称
jumpType: '',
secretFree: '',
referOpinion: true, //允许参考意见 (选择否,则审批时不允许参考同环节其他会签人员的意见)
approvalArea: '', //审批区域显示的内容
opinionField: '', //审批意见反填字段
appendOpinion: false, //是否覆盖审批意见
choiceExcutor: '',
signatureField: '', //自动签章字段
signatureCover: '', //自动签章是否覆盖
showModifyRecord: false, // 是否显示表单修改记录
processInstStatus: null, //流程实例状态
instanceStatus: null, // 流程实例状态的信息
printCurForm: false,
formPrintTemplateList: [],
isSkipStart: false, // 是否跳过第一个节点
opinionMap: {},
notice: null,
dialogModeAutoApprovalTaskId: '', //弹窗模式自动获取下一条任务的任务id
dialogModeAutoApprovalInstId: '', //弹窗模式自动获取下一条任务的实例id
doneDataVersion: '',
currentSelectNode: '', //当前选择节点
nodeList: [], //审批节点
currentNodeInfo: {},
noticeId: this.$route.query.readId,
isShowCopyBtn: false,
isShowProcessInfo: false,
showDialogAlias: '',
approvalButtonList: [], //审批按钮
}
},
computed: {
...mapState('process', ['bpmTask', 'curNodeDef']),
...mapState('user', ['userInfo']),
...mapState('matter', [
'isFromApplicationModule',
'currentShowDialogAlias',
]),
...mapState('routes', ['fullScreenState']),
readId() {
return this.$route.query.readId
},
dialogModeTaskId() {
return this.dialogModeAutoApprovalTaskId || this.currentTaskId
},
dialogModeInstId() {
return this.dialogModeAutoApprovalInstId || this.currentInstId
},
taskId() {
return this.$route.query.taskId || this.dialogModeTaskId
},
instId() {
return this.$route.query.instId || this.dialogModeInstId
},
leaderId() {
return this.$route.query.leaderId || this.currentLearderId || 0
},
//来源
from() {
return this.$route.query.from
},
//是否获取审批按钮
isGetApprovalBtn() {
return this.$route.query.isGetApprovalBtn || this.currentTaskId
},
//是否是我的申请
myApplication() {
return this.$route.query.myApplication || false
},
//审批类型
approvalType() {
if (this.type) {
return this.type
} else if (this.$route.query && this.$route.query.type) {
return this.$route.query.type
}
return ''
},
isDialogModel() {
return this.currentTaskId ? true : false
},
isDialog() {
// 是否弹框审批模式
const isDialogModel = localStorage.getItem('isDialog')
return (
isDialogModel &&
this.isDialogModel &&
JSON.parse(isDialogModel) === true
)
},
// 审批意见控件需要的参数处理记录参数
recordData() {
return {
instId: this.instId,
taskId: this.taskId,
referOpinion: this.referOpinion,
nodeType: this.nodeType,
defId: this.defId,
nodeId: this.nodeId,
initFillData:
this.notice &&
this.notice.curNodeDef &&
this.notice.curNodeDef.localProperties &&
this.notice.curNodeDef.localProperties.initFillData,
}
},
isUnRead() {
return this.$route.query.isRead === '0'
},
},
watch: {
currentShowDialogAlias(val) {
if (val) {
if (val !== 'processInfo') {
this.isShowProcessInfo = false
}
}
},
},
created() {
this.procInstId = this.instId
this.copyTaskId = this.taskId
this.initData()
//发布一个加载数据的事件
this.$baseEventBus.$on('approval-form-load-data', (data) => {
if (data) {
this.dialogModeAutoApprovalTaskId = data.taskId
this.dialogModeAutoApprovalInstId = data.procInstId
}
this.initData()
})
this.setCurrentShowDialogAlias('')
},
methods: {
...mapMutations('matter', ['setCurrentShowDialogAlias']),
...mapActions({
getApprovalButtonByTaskId: 'matter/getApprovalButtonByTaskId',
getTaskIsLockStatus: 'matter/getTaskIsLockStatus',
getFlowKey: 'process/getFlowKey',
getTaskDetail: 'process/getTaskDetail',
}),
processInfoDialog() {
this.showDialogAlias = 'processInfo'
this.setCurrentShowDialogAlias('processInfo')
this.isShowProcessInfo = true
},
previewProcessDialog() {
this.$refs.nodePath.showNodePath(this.instId)
},
loadData() {
this.initData()
},
async initData() {
if (this.taskId) {
if (!this.leaderId && !this.approvalType) {
//验证当前用户是否有该任务处理权限
const { value } = await checkTaskAuth(this.taskId)
if (!value) {
this.$message.warning('您没有执行该任务的权限!')
this.$router.push(`/matter/myTask`)
return
}
}
const data = await getNotice(this.taskId).catch((err) => {
window.location.href = '/front/matter/myTask'
})
this.notice = data
this.procDefKey = this.notice.bpmTask.procDefKey
this.getTaskDetail(data)
this.handleTaskData(data)
// 获取表单数据
this.getTaskForm()
this.markTaskAsReadByTaskId()
} else {
this.getNodePrintTemplateByInstIdAndNodeId()
getInstanceByInstId(this.instId, (instData) => {
this.handleInstData(instData)
})
// 获取实例表单
this.getInstanceForm()
}
//获取审批按钮
if (this.isGetApprovalBtn) {
this.getApprovalButtonByTaskId()
this.getTaskIsLockStatus({
taskId: this.taskId,
leaderId: this.leaderId,
})
}
//获取flowKey根据procInstId
this.getFlowKey({ procInstId: this.instId })
this.getFlowStatusByInstIdAndTaskId()
//标为已阅
if (this.isUnRead) {
setRead(this.readId).then((res) => {})
}
},
getApprovalButtonByTaskId() {
getApprovalButtons(
{
taskId: this.taskId,
leaderId: this.leaderId,
},
(res) => {
this.approvalButtonList = res?.buttons || []
}
)
},
handleTaskData(data) {
const { bpmTask, curNodeDef } = data
this.execId = bpmTask.execId
this.status = bpmTask.status
this.defId = bpmTask.procDefId
this.subject = bpmTask.subject
this.procInstId = bpmTask.procInstId
this.bpmnInstId = bpmTask.bpmnInstId
this.instStatus = bpmTask.instStatus
this.flowDefKey = bpmTask.flowDefKey
if (curNodeDef && curNodeDef.nodeProperties) {
this.nodeId = curNodeDef.nodeId
this.nodeType = curNodeDef.type
const nodeProps =
curNodeDef.nodeProperties[0] || curNodeDef.localProperties
this.jumpType = nodeProps.jumpType
this.secretFree = nodeProps.secretFree
this.referOpinion = nodeProps.referOpinion
this.opinionField = nodeProps.opinionField
this.approvalArea = nodeProps.approvalArea
this.appendOpinion = nodeProps.appendOpinion
this.choiceExcutor = nodeProps.choiceExcutor
this.signatureField = nodeProps.signatureField
this.signatureCover = nodeProps.signatureCover
}
},
handleInstData(data) {
this.defId = data.procDefId
this.subject = data.subject
this.formKey = data.formKey
this.bpmnInstId = data.bpmnInstId
this.instStatus = data.instStatus
this.approvalArea = 'processRecord'
this.showModifyRecord = data.showModifyRecord
},
// 催办
handleUrgent() {
processIsOver(this.procInstId, (res) => {
if (res.state) {
this.$refs.taskUrgent.handleOpen()
} else {
this.$message.warning(res.message)
}
})
},
// 沟通
handleCommunication() {
this.showDialogAlias = 'communication'
// this.setCurrentShowDialogAlias('communication')
this.$refs.communication.handleOpen()
},
// 传阅
handleCirculate() {
this.showDialogAlias = 'circulate'
// this.setCurrentShowDialogAlias('circulate')
console.log('open')
this.$refs.circulate.handleOpen()
},
// 跟踪设置
handleFllow() {
processIsOver(this.procInstId, (res) => {
if (res.state) {
this.$refs.fllowSetting.handleOpen()
} else {
this.$message.warning('流程已结束')
}
})
},
// 流程图
handleFlowChart() {
this.$refs.processForecast.handleOpen(
this.instId,
this.data,
this.nodeId ? this.nodeId : this.headerData.nodeId,
false,
'flowChart'
)
},
//处理记录信息
processRecordDialog() {
this.$refs.processRecordDialog.handleOpen() //父组件调用子组件方法
},
//催办记录
urgentRecord() {
this.$refs.urgentrecord.handleOpen() //父组件调用子组件方法
},
//预测图
showFigureDialog() {
this.$refs.processForecast.handleOpen(
this.instId,
this.data,
this.nodeId ? this.nodeId : this.headerData.nodeId,
false
) //父组件调用子组件方法
},
handleFormDetail(res) {
if (res.state) {
const { value } = res
this.formKey = value?.form?.formKey
this.formType = value?.form?.type
this.form = value?.form
this.data = value?.data
this.permission =
value && value.permission ? JSON.parse(value.permission) : null
let diyJs = this.form?.diyJs
diyJs && this.handlerJs(diyJs)
this.$nextTick(() => {
if (this.form.formCss) {
let style = document.createElement('style')
style.id = 'online-form-addStyle'
style.type = 'text/css'
style.innerHTML = `div[name='online-form'] ${this.form.formCss}`
document.head.appendChild(style)
}
})
}
},
handlerJs(diyJs) {
this.$nextTick(() => {
const userInfo = this.userInfo
const currentUser = userInfo?.user
let data = this.data
let _this = this
const $ = require('jquery')
eval(diyJs)
})
},
//获取任务详情
getTaskForm() {
getTaskDetailBo({
taskId: this.taskId,
leaderId: this.leaderId,
reqParams: '',
isDefAuthorize: this.$route.query.isDefAuthorize || '',
}).then(
(res) => this.handleFormDetail(res),
(e) => {
const { data } = e.response
if (data && data.errorCode && data.errorCode == '5034') {
this.$router.push(`/matter/myTask`)
}
}
)
},
// 获取实例表单
getInstanceForm() {
const params = {
querys: [
{
property: 'wfInst.id_',
value: this.instId,
group: 'typeId',
operation: 'IN',
relation: 'AND',
},
],
}
if (this.from == 'received') {
//当收到传阅时,需要增加传阅人参数,后端不能取当前用户
getNoticeTodoReadById(this.readId).then((res) => {
getDoneByInstIdAndAccount(params, res.ownerId).then((res) => {
if (res.rows && res.rows.length > 0) {
this.nodeList = res.rows.filter(
(item) => item.nodeType && item.nodeType !== 'END'
)
}
this.getFormDataByInstId(res.rows)
})
})
} else {
getDoneByInstId(params).then((res) => {
if (res.rows && res.rows.length > 0) {
this.nodeList = res.rows.filter(
(item) => item.nodeType && item.nodeType !== 'END'
)
}
this.getFormDataByInstId(res.rows)
})
}
},
getFormDataByInstId(data) {
if (data && data.length === 1 && data[0].opinionStatus === 'start') {
this.isSkipStart = true
}
this.setOpinionMap(data)
this.nodeId = this.$route.query.nodeId
if (
this.nodeId &&
(this.from == 'received' || this.from == 'circulate') &&
this.nodeList &&
this.nodeList.length > 0
) {
//传阅事项-我收到的 和我传阅的
this.currentSelectNode = this.nodeId
this.currentNodeInfo = this.nodeList.find(
(item) => item.taskKey === this.nodeId
)
} else if (this.nodeList && this.nodeList.length > 0) {
this.currentSelectNode = this.nodeList[0].taskKey
this.currentNodeInfo = this.nodeList[0]
} else if (data && data.length > 0) {
this.currentSelectNode = data[0].taskKey
this.currentNodeInfo = data[0]
}
this.getFormByNodeIdAndInstId()
},
getFormByNodeIdAndInstId() {
getInstFormAndBO({
instId: this.instId,
getStartForm: this.isSkipStart,
includData: true,
myApplication: this.myApplication,
nodeId: this.nodeId || this.currentSelectNode,
isDefAuthorize: this.$route.query.isDefAuthorize || '',
}).then((res) => {
this.doneDataVersion = res.value.doneDataVersion
if (this.myApplication) {
//我的申请处理
this.nodeId = res.value.form.nodeId
this.currentSelectNode = res.value.form.nodeId
}
if (res.value.doneDataVersion === 'history') {
const findCurrentForm = this.nodeList.find(
(item) => item.taskKey === this.currentSelectNode
)
if (findCurrentForm && findCurrentForm.formData) {
res.value.data = JSON.parse(
Base64.decode(findCurrentForm.formData)
)
}
}
this.handleFormDetail(res)
})
},
setOpinionMap(data) {
data.forEach((item) => {
const opinionStatusList = [
'signRecoverCancel',
'retracted',
'start',
'end',
'awaiting_feedback',
'copyto',
'end_revoke',
'start_commu',
'awaiting_check',
'copyto_reply',
'',
]
if (
!opinionStatusList.includes(item.opinionStatus) &&
this.opinionMap[item.taskKey]
) {
if (item.opinionStatus === 'skip' && item.skipType !== 'first')
return true
if (item.formData) {
item.formData = JSON.parse(Base64.decode(item.formData))
}
this.opinionMap[item.taskKey] = item
}
})
},
handleBeforeClick(alias) {
// 启动流程前校验表单
return this.$refs.approvalFlowForm
.getData(true, alias ? alias + '-before' : '')
.then(() => {
return true
})
.catch(() => {
return false
})
},
dialogClick(type, alias) {
if (this.form.type === 'FRAME') {
const frm = document.querySelectorAll("[name='flowFrameForm']")[0]
const frmControl = document.querySelectorAll("[name='iframeControl']")
if (!frm && !frmControl) {
this.$message.error('当前URL表单加载不正确。')
return
}
const aliasSuffix = type === 'after' ? '-after' : '-submission'
// 发送保存数据成功的的消息
frm.contentWindow.postMessage(
{
messageName: 'saveData',
alias: alias ? alias + aliasSuffix : '',
},
'*'
)
}
// if (type === 'after') {
// // 客户场景,弹窗里用 iframe 嵌套表单审批页面,需求是 表单页处理完后需要通知进行 关闭弹窗
// window.parent && window.parent.postMessage('close', '*')
// }
return true
},
//进入审批页面时通过实例id和任务id获取流程状态
getFlowStatusByInstIdAndTaskId() {
const query = {
instId: this.instId,
taskId: this.taskId,
}
getFlowStatus(query, (res) => {
this.processInstStatus = res
})
},
handleSubmitAfter() {
this.initData()
},
markTaskAsReadByTaskId() {
markTaskAsRead(this.taskId)
},
handleBack() {
if (this.isDialog) {
this.$emit('close-dialog')
} else {
if (this.isFromApplicationModule || this.fullScreenState) {
this.$router.go(-1)
} else {
this.$tabs.replace()
}
}
},
// 流程复制
instanceCopy() {
const this_ = this
const { instId, defId } = this
this.$confirm('使用当前数据发起新流程?', '提示')
.then(() => {
this_.$router.push(
`/matter/startProcess?defId=${defId}©InstId=${instId}`
)
})
.catch(() => {})
},
getInstStatus(data) {
this.instanceStatus = data
},
showPrintDialog() {
this.$refs['formPrint'].showDialog()
// if (!this.formKey) {
// this.$watch('formKey', (newVal) => {
// newVal && this.$refs['formPrint'].showDialog()
// })
// } else {
// this.$refs['formPrint'].showDialog()
// }
},
loadPrintTemplate(params, cb) {
const this_ = this
let futures = [
this.getFormPrintListByFormKey(),
this.resolveNodePrintTemplate(),
this.getFlowGlobalTemplate(),
]
Promise.all(futures).then((resps) => {
let rows = []
resps.forEach((item) => {
rows = rows.concat(item || [])
})
//去重
const map = new Map()
const rowsSet = rows.filter(
(item) =>
!item.fileId || (!map.has(item.fileId) && map.set(item.fileId, 1))
)
this_.$set(this_, 'formPrintTemplateList', rowsSet)
cb && cb(!!rowsSet.length)
})
},
getFlowGlobalTemplate() {
return new Promise((resolve) => {
getFlowGlobalTemplate(this.defId).then((resp) => {
const templates = resp.value || []
if (!templates.length) {
resolve(templates)
} else {
let result = []
templates.forEach((template) => {
if (template.fileJson && template.fileJson != []) {
const file = JSON.parse(template.fileJson)[0]
let fileName = file.name
let extName =
fileName.split('.')[fileName.split('.').length - 1]
let printType = ''
if (extName == 'docx' || extName == 'doc') {
printType = 'word'
} else if (extName == 'xlsx' || extName == 'xls') {
printType = 'excel'
}
result.push({
fileId: file.id,
fileName: template.name,
name: template.desc,
printType,
createTime: template.createTime,
allowDownload: template.allowDownload,
allowPreview: template.allowPreview,
scriptStr: template.scriptStr,
templateId: template.id,
})
}
})
resolve(result)
}
})
})
},
getFormPrintListByFormKey() {
const pageBean = {
page: 1,
pageSize: -1,
}
const param = {
pageBean,
querys: [
{
group: 'defaultQueryGroup',
operation: 'EQUAL',
relation: 'AND',
property: 'formKey',
value: this.formKey,
},
],
}
return new Promise((resolve) => {
getFormPrintList(param).then((resp) => {
if (resp && resp.rows) {
resolve(resp.rows)
} else {
resolve(new Array())
}
})
})
},
resolveNodePrintTemplate() {
return new Promise((resolve) => {
if (
this.curNodeDef &&
this.curNodeDef.localProperties &&
this.curNodeDef.localProperties.printTemplate
) {
const printTemplate = JSON.parse(
Base64.decode(this.curNodeDef.localProperties.printTemplate)
)
printTemplate.forEach((item) => {
item['fileName'] = item['name']
})
resolve(printTemplate)
} else {
resolve([])
}
})
},
handleCurFormPrint() {
this.$refs['printBtn'].$el.click()
},
handleNodeChange(key) {
this.currentSelectNode = key
this.nodeId = key
this.currentNodeInfo =
this.nodeList.find((item) => item.taskKey === key) || {}
this.getFormByNodeIdAndInstId()
},
// 更新表单头部信息
updateHeaderData(data) {
this.headerData = data
},
getProcessSponsor(account) {
this.isShowCopyBtn = account === this.userInfo.user.account
},
getNodePrintTemplateByInstIdAndNodeId() {
const query = {
instId: this.instId,
nodeId: this.nodeId || this.$route.query.nodeId,
}
getNodePrintTemplate(query).then((res) => {
if (res.state) {
this.curNodeDef.localProperties =
res.value && res.value.localProperties
}
})
},
},
beforeDestroy() {
if (
document.getElementById('online-form-addStyle') &&
document.getElementsByTagName('head') &&
document.getElementsByTagName('head').item
) {
document
.getElementsByTagName('head')
.item(0)
.removeChild(document.getElementById('online-form-addStyle'))
}
},
}
</script>
<style lang="scss" scoped>
$top-btn-height: 48px;
$top-btn-bg: #e6e6e6;
$bottom-btn-height: 80px;
.approval-form {
// border: 1px solid $base-border-color;
// border-radius: 2px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
height: 100%;
overflow: hidden;
// margin-bottom: $base-margin;
background: $base-color-white;
.approval-form__content {
height: 100%;
display: flex;
flex-direction: column;
.form-container {
height: calc(100% - #{$top-btn-height} - #{$bottom-btn-height});
overflow: auto;
width: 100%;
transition: width 0.5s;
}
.approval-buttons {
display: flex;
justify-content: center;
height: $bottom-btn-height;
line-height: $bottom-btn-height;
box-shadow: 0px -2px 6px rgba(149, 149, 149, 0.16);
position: fixed;
z-index: 9;
bottom: $base-content-margin;
background: $base-color-white;
width: calc(
100% - #{$base-left-menu-width} - #{$base-content-margin}* 2
);
}
.app-model {
width: 100%;
bottom: 0;
}
}
.two-column-layout__content {
.form-container {
height: calc(100% - #{$top-btn-height});
width: calc(100% - 380px);
}
}
.approval-form__top-row {
background: $base-color-white;
height: $top-btn-height;
line-height: $top-btn-height;
padding: 0 32px;
border-bottom: 1px solid $top-btn-bg;
.top-col {
margin-top: 8px;
display: flex;
justify-content: flex-end;
::v-deep {
.el-button {
font-size: 14px;
padding-right: 14px;
&:last-child {
padding-right: 0;
}
}
.el-button [class*='icon-'] + span {
margin-left: 0;
}
}
}
.back-icon {
color: var(--themeColor);
cursor: pointer;
}
.top-title {
font-size: $base-font-size-big;
font-weight: bold;
color: $base-dark-title-color;
padding-left: 6px;
}
}
}
.horizontal-container {
.approval-form {
.approval-buttons {
width: 92%;
bottom: 0;
}
}
}
.is-collapse-main {
.approval-form {
.approval-buttons {
width: calc(
100% - #{$base-left-menu-width-min} - #{$base-content-margin}* 2
);
}
}
}
.mobile {
.is-collapse-main {
.approval-form {
.approval-buttons {
width: calc(100% - #{$base-content-margin}* 2);
}
}
}
}
.predictButton {
line-height: 16px;
height: 16px;
margin-left: 3px;
}
.hide-approval-btn {
animation: fadeOut 1s ease-in-out forwards;
}
.show-approval-btn {
animation: fadeIn 0.3s ease-in-out forwards;
}
@keyframes fadeOut {
0% {
opacity: 1;
transform: translateY(0);
}
100% {
opacity: 0;
transform: translateY(80px);
}
}
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(80px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@media (max-width: 1360px) {
.approval-form .two-column-layout__content .form-container {
::v-deep {
.form-content {
width: 730px;
.status-wrap {
margin-right: 16px;
}
}
}
}
}
</style>