Blame view

src/components/oa/notepadOwnerRepair.vue 5.81 KB
0bf7e6a5   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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  <template>
    <el-dialog
      :title="$t('notepadManage.ownerRepair.title')"
      :visible.sync="visible"
      width="50%"
      @close="handleClose"
    >
      <el-form
        ref="form"
        :model="formData"
        :rules="rules"
        label-width="120px"
      >
        <el-form-item
          :label="$t('notepadManage.ownerRepair.repairType')"
          prop="repairType"
        >
          <el-select
            v-model="formData.repairType"
            style="width:100%"
          >
            <el-option
              :label="$t('notepadManage.ownerRepair.selectRepairType')"
              disabled
              value=""
            />
            <el-option
              v-for="(item,index) in repairSettings"
              :key="index"
              :label="item.repairTypeName"
              :value="item.repairType"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          :label="$t('notepadManage.ownerRepair.repairObjName')"
          prop="repairObjName"
        >
          <el-input
            v-model="formData.repairObjName"
            :placeholder="$t('notepadManage.ownerRepair.repairObjNamePlaceholder')"
          />
        </el-form-item>
        <el-form-item
          :label="$t('notepadManage.ownerRepair.repairName')"
          prop="repairName"
        >
          <el-input
            v-model="formData.repairName"
            :placeholder="$t('notepadManage.ownerRepair.repairNamePlaceholder')"
          />
        </el-form-item>
        <el-form-item
          :label="$t('notepadManage.ownerRepair.tel')"
          prop="tel"
        >
          <el-input
            v-model="formData.tel"
            :placeholder="$t('notepadManage.ownerRepair.telPlaceholder')"
          />
        </el-form-item>
        <el-form-item
          :label="$t('notepadManage.ownerRepair.appointmentTime')"
          prop="appointmentTime"
        >
          <el-date-picker
            v-model="formData.appointmentTime"
            type="datetime"
            style="width:100%"
            :placeholder="$t('notepadManage.ownerRepair.selectTime')"
            value-format="yyyy-MM-dd HH:mm:ss"
          />
        </el-form-item>
        <el-form-item
          :label="$t('notepadManage.ownerRepair.context')"
          prop="context"
        >
          <el-input
            v-model="formData.context"
            type="textarea"
            rows="5"
            :placeholder="$t('notepadManage.ownerRepair.contextPlaceholder')"
          />
        </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.submit') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { saveOwnerRepair, listRepairSettings } from '@/api/oa/notepadManageApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'NotepadOwnerRepair',
    data() {
      return {
        visible: false,
        formData: {
          repairType: '',
          repairName: '',
          tel: '',
          appointmentTime: '',
          context: '',
          repairObjType: '004',
          repairObjId: '',
          repairObjName: '',
          repairChannel: 'T',
          noteId: '',
          communityId: ''
        },
        repairSettings: [],
        rules: {
          repairType: [
            { required: true, message: this.$t('notepadManage.validate.repairType'), trigger: 'blur' }
          ],
          repairObjName: [
            { required: true, message: this.$t('notepadManage.validate.repairObjName'), trigger: 'blur' }
          ],
          repairName: [
            { required: true, message: this.$t('notepadManage.validate.repairName'), trigger: 'blur' },
            { min: 2, max: 10, message: this.$t('notepadManage.validate.repairNameLength'), trigger: 'blur' }
          ],
          tel: [
            { required: true, message: this.$t('notepadManage.validate.tel'), trigger: 'blur' },
            { pattern: /^1[3-9]\d{9}$/, message: this.$t('notepadManage.validate.telFormat'), trigger: 'blur' }
          ],
          appointmentTime: [
            { required: true, message: this.$t('notepadManage.validate.appointmentTime'), trigger: 'blur' }
          ],
          context: [
            { required: true, message: this.$t('notepadManage.validate.context'), trigger: 'blur' },
            { max: 2000, message: this.$t('notepadManage.validate.contextMaxLength'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(data) {
        this.visible = true
        this.formData = {
          ...this.formData,
          repairObjName: data.roomName,
          repairObjId: data.roomId,
          tel: data.link,
          repairName: data.objName,
          context: data.title,
          noteId: data.noteId,
          communityId: getCommunityId()
        }
        this.loadRepairSettings()
      },
      async loadRepairSettings() {
        try {
          const params = {
            page: 1,
            row: 50,
            communityId: this.formData.communityId,
            publicArea: 'F'
          }
          const { data } = await listRepairSettings(params)
          this.repairSettings = data
        } catch (error) {
          console.error('获取报修设置失败:', error)
        }
      },
      async handleSubmit() {
        this.$refs.form.validate(async valid => {
          if (valid) {
            try {
              await saveOwnerRepair(this.formData)
              this.$message.success(this.$t('common.submitSuccess'))
              this.visible = false
              this.$emit('success')
            } catch (error) {
              console.error('提交报修单失败:', error)
            }
          }
        })
      },
      handleClose() {
        this.$refs.form.resetFields()
        this.formData = {
          repairType: '',
          repairName: '',
          tel: '',
          appointmentTime: '',
          context: '',
          repairObjType: '004',
          repairObjId: '',
          repairObjName: '',
          repairChannel: 'T',
          noteId: '',
          communityId: ''
        }
      }
    }
  }
  </script>