AgreeButton.vue
7.99 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
<template>
<div class="approval-button-item agree-button">
<el-button
:type="buttonType[alias]"
:disabled="disabled"
:size="btnSize"
:plain="alias === 'oppose' ? true : false"
:class="{ 'plain-danger-btn': alias === 'oppose' }"
:title="name.length > 4 ? name : ''"
@click="handleAgree"
>
{{ name.length > 4 ? `${name.substring(0, 4)}...` : name }}
</el-button>
<el-drawer
:title="dialogTitle"
:visible.sync="dialogVisible"
:before-close="handleClose"
:append-to-body="true"
:modal="false"
:close-on-click-modal="false"
:size="380"
:wrapper-closable="false"
class="right-drawer-wrap"
:class="{
'dialog-model-drawer': isDialog && !isFromTaskManager,
'horizontal-layout-drawer': layout === 'horizontal',
'flow-module-drawer': isFromApplicationModule,
}"
>
<div class="dialog__content">
<el-form
v-form="{ inputsDisplay: 'block' }"
:model="formData"
label-width="100px"
:data-vv-scope="formScope"
@submit.native.prevent
>
<ht-form-item
:label="$t('taskToComplete.ApprovedComments')"
class="opinion-label"
>
<approval-comments
:approval-opinion="approvalOpinion"
:approval-maxlength="approvalMaxlength"
@get-opinion="getOpinion"
></approval-comments>
</ht-form-item>
<ht-form-item
v-if="isShowSignature"
:label="$t('taskToComplete.SignatureAndPassword')"
>
<ht-input
v-model="signaturePassword"
validate="required"
show-password
></ht-input>
</ht-form-item>
<ht-form-item :label="$t('taskToComplete.ApprovedUpload')">
<ht-file
v-model="fileList"
:uploading.sync="fileUploading"
type="list"
:downloadable="false"
/>
</ht-form-item>
</el-form>
</div>
<div class="dialog-footer__btns">
<el-button
type="primary"
:loading="loading || fileUploading"
@click="confirm"
>
{{ $t('Common.Confirm') }}
</el-button>
<el-button :disabled="loading || fileUploading" @click="handleClose">
{{ $t('Common.Cancel') }}
</el-button>
</div>
</el-drawer>
<!-- 选择领导代审批弹窗 -->
<leader-dialog ref="leaderDialog" />
<!-- 选择路径跳转 -->
<select-path-to-jump
ref="selectPathJump"
:alias="alias"
:opinion-field="opinionField"
:data="data"
/>
<el-dialog
title="执行人为空时由发起人指定"
:visible.sync="executorIsEmptyDialog"
:close-on-click-modal="false"
:show-close="false"
append-to-body
>
<el-form v-form>
<ht-form-item label="审批人员">
<ht-user-selector-input
v-model="userSelectValue"
permission="b"
:config="{ id: 'user.id', fullname: 'user.fullname' }"
:append-to-body="true"
single
></ht-user-selector-input>
</ht-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" size="small" @click="confirmOk">
{{ $t('Common.Confirm') }}
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import req from '@/utils/request'
import approvalButton from '@/mixins/approvalButton'
import { BUTTON_TYPE, BUTTON_NAME_MAP, ACTION_MAP } from './const'
import SelectPathToJump from './SelectPathToJump.vue'
import { resultJudge } from '@/utils/event.js'
import { getCurrentSeal } from '@/api/uc.js'
export default {
name: 'AgreeButton',
components: { SelectPathToJump },
mixins: [approvalButton],
data() {
return {
buttonType: BUTTON_TYPE,
buttonNameMap: BUTTON_NAME_MAP,
formData: {},
dialogTitle: '审批同意',
executorIsEmptyDialog: false,
user: {
id: '',
fullname: '',
},
userSelectValue: '',
EipUserSelectorData: {},
executorIsEmptyInsts: {},
executorIsEmptyRow: {},
fileUploading: false,
approvalMaxlength: 500,
}
},
computed: {
formScope() {
return `${this.alias}Form`
},
},
methods: {
handleAgree() {
if (this.beforeClick) {
resultJudge(this.beforeClick(this.alias)).then((result) => {
if (result) {
this.getTaskIsLock('agree')
} else {
this.loading = false
}
})
} else {
this.getTaskIsLock('agree')
}
},
//打开弹窗
openAgreeDialog() {
let aliasList = ['opposeTrans', 'agreeTrans']
this.dialogVisible = true
this.loading = false
this.setDialogTitle()
this.afterOpenDialog()
},
//设置弹窗标题
setDialogTitle() {
this.dialogTitle = `审批${ACTION_MAP[this.alias]}`
//获取表单数据,审批意见
},
//获取表单,审批意见
getData() {
//completaData,opinionField,boData,appendOptinion
},
//打开弹窗后获取审批意见
afterOpenDialog() {
this.getApprovalOpinionByInstIdAndTaskId()
},
//点击确定按钮
confirm(alias) {
this.$root.$validator.validateAll(this.formScope).then((result) => {
this.loading = true
if (!result) {
this.loading = false
return this.$message.error('有必填的内容未填写。')
}
// if (this.beforeClick) {
if (this.dialogBeforeClick) {
// resultJudge(this.beforeClick(alias)).then((result) => {
resultJudge(this.dialogBeforeClick(this.alias)).then((result) => {
if (result) {
this.doSubmit()
} else {
this.loading = false
}
})
} else {
this.doSubmit()
}
})
},
doSubmit(alias) {
if (this.alias === 'agree' && this.signatureField) {
this.handleSignature()
}
if (this.isShowSignature) {
getCurrentSeal(this.signaturePassword, this.secretFree).then(
(res) => {
if (res.state) {
setTimeout(() => {
this.submitBefore('agree', 'agreeForm')
}, 500)
} else {
this.loading = false
this.$message.error(res.message)
}
this.submitAfter('agree')
}
)
} else {
setTimeout(() => {
this.submitBefore('agree', 'agreeForm')
}, 500)
this.submitAfter('agree')
}
},
//处理人配置审批人后确认事件
confirmOk() {
if (!(this.user.fullname && this.user.id)) {
this.$message.warning('请选择审批人员')
return
}
let map = {
userId: this.user.id,
userName: this.user.fullname,
taskId: this.executorIsEmptyRow.assignTaskId,
instId: this.instId,
}
req
.post(
window.context.bpmRunTime + '/runtime/instance/v1/assignBpmTask',
map
)
.then((res) => {
if (res.state) {
this.$message.success(res.message)
this.$nextTick(() => {
this.getNextTaskByDefKeyAndDefId()
})
} else {
this.$message.error(res.message)
}
this.executorIsEmptyDialog = false
})
.catch((e) => {
this.executorIsEmptyDialog = false
// this.getNextTaskByDefKeyAndDefId()
})
},
},
}
</script>
<style lang="scss" scoped></style>