CountersignButton.vue
2.95 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
<template>
<div class="approval-button-item countersign-button">
<el-button :disabled="disabled" :size="btnSize" @click="handleCountersign">
{{ name }}
</el-button>
<approval-dialog
ref="approvalDialog"
:dialog-title="$t('task.SignatureSettings')"
is-show-user-selector
:user-label="$t('task.Signatory')"
:opinion-label="$t('task.SignatureDescription')"
:dialog-before-click="dialogBeforeClick"
:alias="alias"
:is-get-approval-btn="isGetApprovalBtn"
@submit-form="handleSubmitForm"
></approval-dialog>
</div>
</template>
<script>
import ApprovalDialog from './ApprovalDialog'
import approvalButton from '@/mixins/approvalButton'
import { savaCountersign, savaUserTaskCountersign } from '@/api/process'
import { resultJudge } from '@/utils/event.js'
export default {
name: 'CountersignButton',
components: {
ApprovalDialog,
},
mixins: [approvalButton],
methods: {
handleCountersign() {
if (this.beforeClick) {
resultJudge(this.beforeClick(this.alias)).then((result) => {
if (result) {
this.$refs.approvalDialog.openDialog()
}
})
} else {
this.$refs.approvalDialog.openDialog()
}
},
handleSubmitForm(dialogFormData, cb) {
const { userId, files, opinion } = dialogFormData
//用户任务加签
const data = {
taskId: this.taskId,
files,
opinion,
}
if (this.nodeType === 'USERTASK') {
const params = {
...data,
userIds: userId,
action: 'back',
cb: cb,
}
//提交前执行前置脚本
this.submitBefore('addSign', params)
this.submitAfter('addSign')
} else {
//会签任务加签
const params = {
...data,
userId,
}
this.handleJointlySignTask(params, cb)
}
},
//用户任务加签
onSubmit(params) {
const data = {
...params,
data: Base64.encode(JSON.stringify(this.data)),
}
delete data.cb
savaUserTaskCountersign(data)
.then((res) => {
if (!res.state) return this.$message.error(res.message)
this.$message.success(res.message)
this.dialogModeApprovalCompletionToMyTask()
this.dialogAfterClick(this.alias)
})
.finally(() => {
params.cb()
})
},
//会签任务加签
handleJointlySignTask(params, cb) {
savaCountersign(params)
.then((res) => {
if (!res.state) return this.$message.warning(res.message)
this.$message.success(res.message)
this.dialogAfterClick(this.alias)
})
.finally(() => {
cb()
})
},
},
}
</script>
<style lang="scss" scoped></style>