Audit.vue
2.55 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
<template>
<el-dialog
:title="$t('audit.title')"
:visible.sync="visible"
width="50%"
@close="closeDialog"
>
<el-form :model="auditInfo" label-width="120px">
<el-form-item :label="$t('audit.state')" required>
<el-select
v-model="auditInfo.state"
:placeholder="$t('audit.selectPlaceholder')"
style="width: 100%"
>
<el-option
:label="$t('audit.agree')"
value="1100"
/>
<el-option
:label="$t('audit.reject')"
value="1200"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t('audit.reason')" required>
<el-input
type="textarea"
:rows="4"
:placeholder="$t('audit.reasonPlaceholder')"
v-model="auditInfo.remark"
/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="closeDialog">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="submitAudit">{{ $t('common.submit') }}</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
name: 'AuditDialog',
data() {
return {
visible: false,
auditInfo: {
state: '',
remark: ''
}
}
},
watch: {
'auditInfo.state'(val) {
if (val === '1100') {
this.auditInfo.remark = this.$t('audit.agree')
} else if (val === '1200') {
this.auditInfo.remark = ''
}
}
},
methods: {
open() {
this.visible = true
},
closeDialog() {
this.visible = false
this.resetForm()
},
resetForm() {
this.auditInfo = {
state: '',
remark: ''
}
},
submitAudit() {
if (!this.validateForm()) {
return
}
const auditData = { ...this.auditInfo }
if (auditData.state === '1200') {
auditData.remark = `${this.$t('audit.reject')}: ${auditData.remark}`
}
this.$emit('submit', auditData)
this.closeDialog()
},
validateForm() {
if (!this.auditInfo.state) {
this.$message.error(this.$t('audit.stateRequired'))
return false
}
if (!this.auditInfo.remark) {
this.$message.error(this.$t('audit.reasonRequired'))
return false
}
if (this.auditInfo.remark.length > 200) {
this.$message.error(this.$t('audit.reasonMaxLength'))
return false
}
return true
}
}
}
</script>
<style scoped>
.el-select {
width: 100%;
}
</style>