InquiryButton.vue
5.03 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
<template>
<div class="approval-button-item inquiry-button">
<el-button :disabled="disabled" :size="btnSize" @click="handleInquiry">
{{ name }}
</el-button>
<el-drawer
:title="$t('task.InquirySettings')"
: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="100px"
data-vv-scope="InquiryForm"
>
<ht-form-item :label="$t('task.InquiryUser')">
<ht-user-selector-input
v-model="users"
single
quick-search-props="fullname,account"
:append-to-body="true"
:config="{ id: 'formData.userId' }"
permission="b"
></ht-user-selector-input>
</ht-form-item>
<ht-form-item
v-if="isShowInquiryType"
:label="$t('task.InquiryType')"
>
<ht-radio
v-model="inquiryType"
validate="required"
:rdlist="JSON.stringify(inquiryTypeOptions)"
></ht-radio>
</ht-form-item>
<ht-form-item
:label="$t('task.InquiryDescription')"
class="opinion-label"
label-width="80px"
>
<approval-comments
:approval-opinion="approvalOpinion"
@get-opinion="getOpinion"
></approval-comments>
</ht-form-item>
<ht-form-item :label="$t('task.InquiryAttachmentUpload')">
<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>
</div>
</template>
<script>
import approvalButton from '@/mixins/approvalButton'
import { savaInquiry } from '@/api/process'
import { resultJudge } from '@/utils/event.js'
const INQUIRY_TYPE_OPTIONS = [
{
key: 'direct',
value: '直接返回',
},
{
key: 'step',
value: '逐级返回',
},
]
export default {
name: 'InquiryButton',
mixins: [approvalButton],
data() {
return {
inquiryTypeOptions: INQUIRY_TYPE_OPTIONS,
users: '',
inquiryType: 'direct',
formData: {
userId: '',
},
fileUploading: false,
}
},
computed: {
status() {
return this.$route.query.status
},
isShowInquiryType() {
return this.status !== 'TRANSFORMEDINQU'
},
},
methods: {
async handleInquiry() {
let res = true
if (this.beforeClick) {
res = await resultJudge(this.beforeClick(this.alias))
}
if (!res) return
this.dialogVisible = true
},
confirm() {
const params = {
taskId: this.taskId,
opinion: this.opinionValue,
userIds: this.formData.userId,
action: 'back',
files: this.fileList && JSON.stringify(this.fileList),
data: JSON.stringify(this.data),
inquType: this.isShowInquiryType ? this.inquiryType : '',
}
this.$root.$validator.validateAll('InquiryForm').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.doSubmit(params)
} else {
this.loading = false
}
})
} else {
this.doSubmit(params)
}
})
},
doSubmit(params) {
savaInquiry(params)
.then((res) => {
if (!res.state) return this.$message.error(res.message)
this.filterHasHandleTask()
this.$message.success(res.message)
this.handleClose()
this.dialogModeApprovalCompletionToMyTask()
this.dialogAfterClick(this.alias)
})
.finally(() => {
this.loading = false
})
},
},
}
</script>
<style lang="scss" scoped></style>