visitOwnerRepair.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
<template>
<el-dialog :title="$t('repairReturnVisit.visit')" :visible.sync="visible" width="600px" @close="resetForm">
<el-form ref="visitForm" :model="formData" :rules="rules" label-width="100px" label-position="right">
<el-form-item :label="$t('repairReturnVisit.satisfaction')" prop="visitType">
<el-select v-model="formData.visitType" :placeholder="$t('repairReturnVisit.satisfaction')"
style="width:100%">
<el-option :label="$t('repairReturnVisit.satisfied')" value="1001" />
<el-option :label="$t('repairReturnVisit.unsatisfied')" value="2002" />
</el-select>
</el-form-item>
<el-form-item :label="$t('repairReturnVisit.visitContent')" prop="context">
<el-input v-model="formData.context" type="textarea" :rows="4"
:placeholder="$t('repairReturnVisit.visitContent')" />
</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="submitVisit">
{{ $t('common.submit') }}
</el-button>
</div>
</el-dialog>
</template>
<script>
import { saveRepairReturnVisit } from '@/api/work/repairReturnVisitApi'
export default {
name: 'VisitOwnerRepair',
data() {
return {
visible: false,
formData: {
repairId: '',
visitType: '',
context: ''
},
rules: {
visitType: [
{ required: true, message: this.$t('repairReturnVisit.satisfactionRequired'), trigger: 'change' }
],
context: [
{ required: true, message: this.$t('repairReturnVisit.visitContentRequired'), trigger: 'blur' },
{ max: 1000, message: this.$t('repairReturnVisit.visitContentMaxLength'), trigger: 'blur' }
]
}
}
},
methods: {
open(repairPool) {
this.formData = {
repairId: repairPool.repairId,
visitType: '',
context: '',
communityId: this.getCommunityId()
}
this.visible = true
},
resetForm() {
this.$refs.visitForm.resetFields()
},
submitVisit() {
this.$refs.visitForm.validate(async valid => {
if (valid) {
try {
await saveRepairReturnVisit(this.formData)
this.$message.success(this.$t('common.operationSuccess'))
this.visible = false
this.$emit('success')
} catch (error) {
console.error('保存回访记录失败:', error)
}
}
})
}
}
}
</script>