ReplyRepairAppraise.vue
2.2 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
<template>
<el-dialog
:title="$t('adminRepairDetail.replyAppraise')"
:visible.sync="visible"
width="50%"
@close="resetForm"
>
<el-form :model="form" :rules="rules" ref="form" label-width="120px">
<el-form-item :label="$t('adminRepairDetail.content')" prop="replyContext">
<el-input
type="textarea"
:rows="5"
v-model="form.replyContext"
:placeholder="$t('adminRepairDetail.replyPlaceholder')"
></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="submitForm">{{ $t('common.submit') }}</el-button>
</div>
</el-dialog>
</template>
<script>
import { replyRepairAppraise } from '@/api/work/adminRepairDetailApi'
export default {
name: 'ReplyRepairAppraise',
data() {
return {
visible: false,
form: {
repairId: '',
ruId: '',
replyContext: ''
},
rules: {
replyContext: [
{ required: true, message: this.$t('adminRepairDetail.replyRequired'), trigger: 'blur' },
{ max: 512, message: this.$t('adminRepairDetail.replyMaxLength'), trigger: 'blur' }
]
}
}
},
methods: {
open(data) {
this.form.repairId = data.repairId
this.form.ruId = data.ruId
this.visible = true
this.$nextTick(() => {
this.$refs.form && this.$refs.form.clearValidate()
})
},
submitForm() {
this.$refs.form.validate(async valid => {
if (!valid) return
try {
await replyRepairAppraise({
...this.form,
communityId: this.getCommunityId()
})
this.$message.success(this.$t('common.operationSuccess'))
this.visible = false
this.$emit('success')
} catch (error) {
this.$message.error(error.message || this.$t('adminRepairDetail.replyError'))
}
})
},
resetForm() {
this.form = {
repairId: '',
ruId: '',
replyContext: ''
}
this.$refs.form && this.$refs.form.clearValidate()
}
}
}
</script>