Blame view

src/components/oa/editComplaint.vue 4.04 KB
0a06b2d1   wuxw   开发完成投诉建议
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
  <template>
    <el-dialog
      :title="$t('complaint.edit.title')"
      :visible.sync="visible"
      width="50%"
      @close="handleClose"
    >
      <el-form 
        ref="form" 
        :model="form" 
        label-width="120px"
        :rules="rules"
      >
        <el-form-item 
          :label="$t('complaint.edit.type')" 
          prop="typeCd"
        >
          <el-select 
            v-model="form.typeCd" 
            style="width:100%"
            :placeholder="$t('complaint.edit.typePlaceholder')"
          >
            <el-option 
              v-for="item in complaintTypes" 
              :key="item.typeCd"
              :label="item.typeName"
              :value="item.typeCd"
            />
          </el-select>
        </el-form-item>
        <el-form-item 
          :label="$t('complaint.edit.contact')" 
          prop="complaintName"
        >
          <el-input 
            v-model="form.complaintName" 
            :placeholder="$t('complaint.edit.contactPlaceholder')"
          />
        </el-form-item>
        <el-form-item 
          :label="$t('complaint.edit.phone')" 
          prop="tel"
        >
          <el-input 
            v-model="form.tel" 
            :placeholder="$t('complaint.edit.phonePlaceholder')"
          />
        </el-form-item>
        <el-form-item 
          :label="$t('complaint.edit.content')" 
          prop="context"
        >
          <el-input
            type="textarea"
            :rows="4"
            v-model="form.context"
            :placeholder="$t('complaint.edit.contentPlaceholder')"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { updateComplaint } from '@/api/oa/complaintApi'
  import { listComplaintTypes } from '@/api/oa/complaintApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'EditComplaint',
    data() {
      return {
        visible: false,
        communityId: '',
        complaintTypes: [],
        form: {
          complaintId: '',
          typeCd: '',
          complaintName: '',
          tel: '',
          context: '',
          communityId: ''
        },
        rules: {
          typeCd: [
            { required: true, message: this.$t('complaint.validate.type'), trigger: 'blur' }
          ],
          complaintName: [
            { required: true, message: this.$t('complaint.validate.contact'), trigger: 'blur' },
            { max: 200, message: this.$t('complaint.validate.contactMax'), trigger: 'blur' }
          ],
          tel: [
            { required: true, message: this.$t('complaint.validate.phone'), trigger: 'blur' },
            { pattern: /^1[3-9]\d{9}$/, message: this.$t('complaint.validate.phoneFormat'), trigger: 'blur' }
          ],
          context: [
            { required: true, message: this.$t('complaint.validate.content'), trigger: 'blur' },
            { max: 4000, message: this.$t('complaint.validate.contentMax'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(row) {
        this.communityId = getCommunityId()
        this.form = {
          ...row,
          communityId: this.communityId
        }
        this.getComplaintTypes()
        this.visible = true
      },
      async getComplaintTypes() {
        try {
          const params = {
            page: 1,
            row: 100,
            communityId: this.communityId
          }
          const { data } = await listComplaintTypes(params)
          this.complaintTypes = data
        } catch (error) {
          console.error('获取投诉类型失败:', error)
        }
      },
      handleSubmit() {
        this.$refs.form.validate(async valid => {
          if (valid) {
            try {
              await updateComplaint(this.form)
              this.$message.success(this.$t('complaint.edit.success'))
              this.$emit('success')
              this.visible = false
            } catch (error) {
              console.error('更新投诉失败:', error)
            }
          }
        })
      },
      handleClose() {
        this.$refs.form.resetFields()
      }
    }
  }
  </script>