Blame view

src/components/work/addOwnerRepair.vue 8.54 KB
4927ce37   wuxw   开发完成报修功能
1
2
  <template>
    <el-dialog :title="$t('addOwnerRepair.title')" :visible.sync="visible" width="50%" @close="closeDialog">
47b8eddb   wuxw   优化完成 平凉客户反馈bug
3
      <el-form ref="form" :model="formData" :rules="rules" label-width="120px">
4927ce37   wuxw   开发完成报修功能
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
        <el-form-item :label="$t('addOwnerRepair.repairScope')" prop="repairObjType" required>
          <el-select v-model="formData.repairObjType" style="width:100%" @change="changeRepairObjType">
            <el-option v-for="item in repairObjTypes" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
  
        <el-form-item v-if="formData.repairObjType && formData.repairObjType !== '001'"
          :label="$t('addOwnerRepair.belongBuilding')">
          <el-select v-model="formData.floorId" style="width:100%" @change="handleFloorChange">
            <el-option v-for="item in floors" :key="item.floorId" :label="item.floorNum" :value="item.floorId" />
          </el-select>
        </el-form-item>
  
        <el-form-item v-if="formData.repairObjType === '003' || formData.repairObjType === '004'"
          :label="$t('addOwnerRepair.belongUnit')">
          <el-select v-model="formData.unitId" style="width:100%" @change="handleUnitChange">
            <el-option v-for="item in units" :key="item.unitId" :label="item.unitNum" :value="item.unitId" />
          </el-select>
        </el-form-item>
  
        <el-form-item v-if="formData.repairObjType === '004'" :label="$t('addOwnerRepair.belongRoom')">
          <el-select v-model="formData.roomId" style="width:100%" @change="handleRoomChange">
            <el-option v-for="item in rooms" :key="item.roomId" :label="item.roomName" :value="item.roomId" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('addOwnerRepair.repairType')" prop="repairType" required>
          <el-select v-model="formData.repairType" style="width:100%">
            <el-option v-for="item in repairSettings" :key="item.repairType" :label="item.repairTypeName"
              :value="item.repairType" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('addOwnerRepair.repairName')" prop="repairName" required>
47b8eddb   wuxw   优化完成 平凉客户反馈bug
38
          <el-input v-model.trim="formData.repairName" :placeholder="$t('addOwnerRepair.placeholder.repairName')" />
4927ce37   wuxw   开发完成报修功能
39
40
41
        </el-form-item>
  
        <el-form-item :label="$t('addOwnerRepair.tel')" prop="tel" required>
47b8eddb   wuxw   优化完成 平凉客户反馈bug
42
          <el-input v-model.trim="formData.tel" type="tel" :placeholder="$t('addOwnerRepair.placeholder.tel')" />
4927ce37   wuxw   开发完成报修功能
43
44
45
46
47
48
49
50
        </el-form-item>
  
        <el-form-item :label="$t('addOwnerRepair.appointmentTime')" prop="appointmentTime" required>
          <el-date-picker v-model="formData.appointmentTime" type="datetime" style="width:100%"
            :placeholder="$t('addOwnerRepair.placeholder.appointmentTime')" value-format="yyyy-MM-dd HH:mm:ss" />
        </el-form-item>
  
        <el-form-item :label="$t('addOwnerRepair.context')" prop="context" required>
47b8eddb   wuxw   优化完成 平凉客户反馈bug
51
          <el-input v-model.trim="formData.context" type="textarea" rows="4" :placeholder="$t('addOwnerRepair.placeholder.context')" />
4927ce37   wuxw   开发完成报修功能
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        </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="saveOwnerRepairInfo">{{ $t('common.submit') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import * as ownerRepairManageApi from '@/api/work/ownerRepairManageApi'
  import { getCommunityName } from '@/api/community/communityApi'
  import {getFloors, getUnits, queryRooms} from '@/api/room/roomApi'
72de60dc   wuxw   优化报修完成
66
  //import {getDateYYYYMMDD} from '@/utils/dateUtil'
4927ce37   wuxw   开发完成报修功能
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
  
  export default {
    name: 'AddOwnerRepair',
    data() {
      return {
        visible: false,
        formData: {
          repairType: '',
          repairName: '',
          tel: '',
          appointmentTime: '',
          context: '',
          repairObjType: '',
          repairObjId: '',
          repairObjName: '',
          repairChannel: 'T',
          floorId: '',
          unitId: '',
          roomId: ''
        },
        repairSettings: [],
        repairObjTypes: [
          { value: '001', label: this.$t('addOwnerRepair.community') },
          { value: '002', label: this.$t('addOwnerRepair.building') },
          { value: '003', label: this.$t('addOwnerRepair.unit') },
          { value: '004', label: this.$t('addOwnerRepair.room') }
        ],
        floors:[],
        units:[],
47b8eddb   wuxw   优化完成 平凉客户反馈bug
96
97
98
99
100
101
102
103
104
        rooms:[],
        rules: {
          repairObjType: [{ required: true, message: this.$t('addOwnerRepair.placeholder.repairScope'), trigger: 'change' }],
          repairType: [{ required: true, message: this.$t('addOwnerRepair.placeholder.repairType'), trigger: 'change' }],
          repairName: [{ required: true, message: this.$t('addOwnerRepair.placeholder.repairName'), trigger: 'blur' }],
          tel: [{ required: true, message: this.$t('addOwnerRepair.placeholder.tel'), trigger: 'blur' }],
          appointmentTime: [{ required: true, message: this.$t('addOwnerRepair.placeholder.appointmentTime'), trigger: 'change' }],
          context: [{ required: true, message: this.$t('addOwnerRepair.placeholder.context'), trigger: 'blur' }]
        }
4927ce37   wuxw   开发完成报修功能
105
106
107
108
109
110
      }
    },
    methods: {
      open() {
        this.visible = true
        this.resetForm()
72de60dc   wuxw   优化报修完成
111
       // this.formData.appointmentTime =getDateYYYYMMDD()
4927ce37   wuxw   开发完成报修功能
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
        this.listRepairSettings('T')
      },
      closeDialog() {
        this.$refs.form.resetFields()
      },
      resetForm() {
        this.formData = {
          repairType: '',
          repairName: '',
          tel: '',
          appointmentTime: '',
          context: '',
          repairObjType: '',
          repairObjId: '',
          repairObjName: '',
47b8eddb   wuxw   优化完成 平凉客户反馈bug
127
128
129
130
          repairChannel: 'T',
          floorId: '',
          unitId: '',
          roomId: ''
4927ce37   wuxw   开发完成报修功能
131
        }
47b8eddb   wuxw   优化完成 平凉客户反馈bug
132
        this.$refs.form && this.$refs.form.resetFields()
4927ce37   wuxw   开发完成报修功能
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
      },
      handleFloorChange(floorId) {
        if (this.formData.repairObjType == '002') {
          this.formData.repairObjId = floorId
          this.formData.repairObjName = this.floors.find(item => item.floorId == floorId).floorNum + this.$t('addOwnerRepair.buildingSuffix')
        }else{
          this.listUnits()
        }
      },
      handleUnitChange(unitId) {
        if (this.formData.repairObjType == '003') {
          this.formData.repairObjId = unitId
          this.formData.repairObjName = this.units.find(item => item.unitId == unitId).unitNum + this.$t('addOwnerRepair.unitSuffix')
        }else{
          this.listRooms()
        }
      },
      handleRoomChange(roomId) {
        if (this.formData.repairObjType === '004') {
          this.formData.repairObjId = roomId
          this.formData.repairObjName =this.rooms.find(item => item.roomId == roomId).roomNum + this.$t('addOwnerRepair.roomSuffix')
32e6d877   wuxw   v1.9 电话报修 业主信息没有带...
154
155
          this.formData.repairName = this.rooms.find(item => item.roomId == roomId).ownerName
          this.formData.tel = this.rooms.find(item => item.roomId == roomId).link
4927ce37   wuxw   开发完成报修功能
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
        }
      },
      changeRepairObjType() {
        this.formData.repairType = ''
        const publicArea = this.formData.repairObjType === '004' ? 'F' : 'T'
        this.listRepairSettings(publicArea)
        this.listFloors()
      },
      async listFloors() {
        const params = {
          communityId: this.getCommunityId(),
          page: 1,
          row: 200
        }
        const { apiFloorDataVoList } = await getFloors(params);
        this.floors = apiFloorDataVoList
      },
      async listUnits() {
        const params = {
          communityId: this.getCommunityId(),
          floorId: this.formData.floorId,
          page: 1,
          row: 200
        }
        const  data  = await getUnits(params);
        this.units = data
      },
      async listRooms() {
        const params = {
          communityId: this.getCommunityId(),
          unitId: this.formData.unitId,
          page: 1,
          row: 500
        }
        const { rooms } = await queryRooms(params);
        this.rooms = rooms
      },
      async listRepairSettings(publicArea) {
        const params = {
          page: 1,
          row: 50,
          publicArea: publicArea,
          communityId: this.getCommunityId()
        }
        const { data } = await ownerRepairManageApi.listRepairSettings(params);
        this.repairSettings = data
      },
      saveOwnerRepairInfo() {
        if (this.formData.repairObjType === '001') {
          this.formData.repairObjId = this.getCommunityId()
          this.formData.repairObjName = getCommunityName()
        }
        this.formData.communityId = this.getCommunityId()
  
        this.$refs.form.validate(valid => {
          if (valid) {
            ownerRepairManageApi.saveOwnerRepair(this.formData).then(res => {
              if (res.code === 0) {
                this.$message.success(this.$t('common.addSuccess'))
                this.visible = false
                this.$emit('success')
              } else {
                this.$message.error(res.msg)
              }
            })
          }
        })
      }
    }
  }
  </script>