ExchangeButton.vue
7.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
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
<template>
<div class="approval-button-item exchange-button">
<el-button :disabled="disabled" :size="btnSize" @click="handleExchange">
{{ name }}
</el-button>
<el-drawer
title="流转设置"
:visible.sync="dialogVisible"
:before-close="handleClose"
: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,
}"
append-to-body
>
<div class="dialog__content">
<el-form
v-form="{ inputsDisplay: 'block' }"
:model="formData"
label-width="140px"
data-vv-scope="exchangeForm"
>
<ht-form-item label="任务通过规则">
<ht-radio
v-model="formData.radioVote"
validate="required"
:options="voteOptions"
@change="handleVoteChange"
></ht-radio>
</ht-form-item>
<template v-if="isCoustomVote">
<ht-form-item label="计票策略">
<ht-radio
v-model="formData.decideType"
validate="required"
:options="decideTypeOptions"
></ht-radio>
</ht-form-item>
<ht-form-item label="投票类型">
<ht-radio
v-model="formData.voteType"
validate="required"
:options="voteTypeOptions"
></ht-radio>
</ht-form-item>
<ht-form-item label="票数">
<ht-input
v-model="formData.voteAmount"
validate="required"
class="vote-amount"
:class="{ 'is-percent': formData.voteType === 'percent' }"
></ht-input>
</ht-form-item>
</template>
<ht-form-item label="流转类型">
<ht-radio
v-model="formData.signType"
validate="required"
:options="signTypeOptions"
></ht-radio>
</ht-form-item>
<ht-form-item label="流转结束后的动作">
<ht-radio
v-model="formData.action"
validate="required"
:options="actionOptions"
></ht-radio>
</ht-form-item>
<ht-form-item label="流转人员">
<ht-user-selector-input
v-model="users"
quick-search-props="fullname,account"
:append-to-body="true"
:config="{ id: 'formData.userIds' }"
permission="b"
></ht-user-selector-input>
</ht-form-item>
<ht-form-item
label="流转意见"
class="opinion-label"
label-width="80px"
>
<approval-comments
:approval-opinion="approvalOpinion"
@get-opinion="getOpinion"
></approval-comments>
</ht-form-item>
<ht-form-item label="附件上传">
<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"
>
确定
</el-button>
<el-button :disabled="loading || fileUploading" @click="handleClose">
取消
</el-button>
</div>
</el-drawer>
</div>
</template>
<script>
import approvalButton from '@/mixins/approvalButton'
import { savaExchange } from '@/api/process'
import {
VOTE_OPTIONS,
DECIDE_TYPE_OPTIONS,
VOTE_TYPE_OPTIONS,
SIGN_TYPE_OPTIONS,
ACTION_OPTIONS,
VETO_DECIDE_TYPE, //一票否决时计票策略默认值
CUSTOM,
PASS_UNANIMOUSLY,
ONE_VOTE_VETO,
ONE_VOTE_AGREE,
} from './const'
import { resultJudge } from '@/utils/event.js'
export default {
name: 'ExchangeButton',
mixins: [approvalButton],
data() {
return {
voteOptions: VOTE_OPTIONS, //任务通过规则选项
decideTypeOptions: DECIDE_TYPE_OPTIONS, //计票策略选项
voteTypeOptions: VOTE_TYPE_OPTIONS, //投票类型选项
signTypeOptions: SIGN_TYPE_OPTIONS, //流转类型选项
actionOptions: ACTION_OPTIONS, //流转结束后的动作选项
formData: {
userIds: '',
radioVote: '1', //任务通过规则 1-全票通过,2-一票否决,3-一票同意,4-自定义
decideType: 'agree', //计票策略
voteType: 'percent', //投票类型
voteAmount: '100', //票数
signType: 'parallel', //流转类型
action: 'submit', //流转结束后的动作
},
users: '',
isCoustomVote: false, //是否自定义投票
fileUploading: false,
}
},
methods: {
handleExchange() {
if (this.beforeClick) {
resultJudge(this.beforeClick(this.alias)).then((result) => {
if (result) {
this.dialogVisible = true
}
})
} else {
this.dialogVisible = true
}
},
handleVoteChange(vote) {
this.isCoustomVote = false
// 全票通过1。 即需要100%同意
if (vote === PASS_UNANIMOUSLY) {
this.formData.voteType = 'percent'
this.formData.decideType = 'agree'
this.formData.voteAmount = '100'
} else if (vote === ONE_VOTE_VETO) {
this.formData.voteType = 'amount'
this.formData.decideType = 'refuse'
this.formData.voteAmount = '1'
} else if (vote === ONE_VOTE_AGREE) {
this.formData.voteType = 'amount'
this.formData.decideType = 'agree'
this.formData.voteAmount = '1'
} else if (vote === CUSTOM) {
this.isCoustomVote = true
}
},
confirm() {
this.$root.$validator.validateAll('exchangeForm').then((result) => {
this.loading = true
if (!result) {
this.loading = false
return this.$message.error('有必填的内容未填写。')
}
if (this.dialogBeforeClick) {
resultJudge(this.dialogBeforeClick(this.alias)).then((result) => {
if (result) {
//提交前执行前置脚本
this.submitBefore('startTrans', 'exchangeForm')
} else {
this.loading = false
}
})
} else {
//提交前执行前置脚本
this.submitBefore('startTrans', 'exchangeForm')
}
this.submitAfter('startTrans')
})
},
handleSubmitting() {
const params = {
taskId: this.taskId,
opinion: this.opinionValue,
files: JSON.stringify(this.fileList),
...this.formData,
data: Base64.encode(JSON.stringify(this.data)),
}
savaExchange(params)
.then((res) => {
if (!res.state) return this.$message.error(res.message)
this.$message.success(res.message)
this.filterHasHandleTask()
// this.$router.go(-1)
this.dialogModeApprovalCompletionToPre()
this.dialogVisible = false
this.dialogAfterClick(this.alias)
})
.finally(() => {
this.loading = false
})
},
},
}
</script>
<style lang="scss" scoped>
.exchange-button {
.vote-amount {
width: 12%;
}
}
.is-percent {
::v-deep {
.el-input {
position: relative;
&::after {
position: absolute;
content: '%';
top: 0;
right: -16px;
}
}
}
}
</style>