Blame view

src/components/oa/ReplyComplaintAppraise.vue 2.24 KB
e5d43009   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
  <template>
    <el-dialog
      :title="$t('replyComplaintAppraise.title')"
      :visible.sync="visible"
      width="50%"
      @close="resetForm"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item :label="$t('replyComplaintAppraise.content')" prop="replyContext">
          <el-input
            type="textarea"
            :rows="5"
            v-model="form.replyContext"
            :placeholder="$t('replyComplaintAppraise.placeholder')"
          />
        </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="submitForm" :loading="submitting">
          {{ $t('common.submit') }}
        </el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { replyComplaintAppraise } from '@/api/oa/complaintDetailApi'
  
  export default {
    name: 'ReplyComplaintAppraise',
    data() {
      return {
        visible: false,
        submitting: false,
        form: {
          appraiseId: '',
          replyContext: '',
          communityId: ''
        },
        rules: {
          replyContext: [
            { required: true, message: this.$t('replyComplaintAppraise.required'), trigger: 'blur' },
            { max: 512, message: this.$t('replyComplaintAppraise.maxLength'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(row) {
        this.form.appraiseId = row.appraiseId
        this.form.communityId = getCommunityId()
        this.visible = true
        this.$nextTick(() => {
          this.$refs.form && this.$refs.form.clearValidate()
        })
      },
      async submitForm() {
        try {
          const valid = await this.$refs.form.validate()
          if (!valid) return
  
          this.submitting = true
          await replyComplaintAppraise(this.form)
          this.$message.success(this.$t('replyComplaintAppraise.success'))
          this.visible = false
          this.$emit('success')
        } catch (error) {
          console.error('回复评价失败:', error)
        } finally {
          this.submitting = false
        }
      },
      resetForm() {
        this.form.replyContext = ''
        this.$refs.form && this.$refs.form.clearValidate()
      }
    }
  }
  </script>