Blame view

src/components/fee/addApplyRoomDiscount.vue 8.62 KB
43eaaadb   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
  <template>
    <el-dialog :title="$t('applyRoomDiscount.add.title')" :visible.sync="visible" width="60%" @close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item :label="$t('applyRoomDiscount.add.room')" prop="roomName">
          <el-input v-model.trim="form.roomName" :placeholder="$t('applyRoomDiscount.add.roomPlaceholder')"
            @blur="queryRoom" />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.applyType')" prop="applyType">
          <el-select v-model="form.applyType" :placeholder="$t('applyRoomDiscount.add.applyTypePlaceholder')"
            style="width:100%">
            <el-option v-for="item in applyTypes" :key="item.applyType" :label="item.typeName" :value="item.applyType" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.feeItem')" prop="feeId">
          <el-select v-model="form.feeId" :placeholder="$t('applyRoomDiscount.add.feeItemPlaceholder')"
            style="width:100%">
            <el-option v-for="item in feeTypeCds" :key="item.feeId"
              :label="`${item.feeName}(${item.endTime}至${item.deadlineTime})`" :value="item.feeId" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.createUser')" prop="createUserName">
          <el-input v-model.trim="form.createUserName" :placeholder="$t('applyRoomDiscount.add.createUserPlaceholder')"
            disabled />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.createUserTel')" prop="createUserTel">
          <el-input v-model.trim="form.createUserTel" :placeholder="$t('applyRoomDiscount.add.createUserTelPlaceholder')"
            disabled />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.startTime')" prop="startTime">
          <el-date-picker v-model="form.startTime" type="date"
            :placeholder="$t('applyRoomDiscount.add.startTimePlaceholder')" value-format="yyyy-MM-dd" style="width:100%"
            @change="validateDate" />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.endTime')" prop="endTime">
          <el-date-picker v-model="form.endTime" type="date" :placeholder="$t('applyRoomDiscount.add.endTimePlaceholder')"
            value-format="yyyy-MM-dd" style="width:100%" @change="validateDate" />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.createRemark')" prop="createRemark">
          <el-input v-model="form.createRemark" type="textarea"
            :placeholder="$t('applyRoomDiscount.add.createRemarkPlaceholder')" :rows="3" />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.add.images')">
          <upload-image-url ref="uploadImage" :image-count="4" @change="handleImageChange" />
        </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="submitForm">
          {{ $t('common.save') }}
        </el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { queryApplyRoomDiscountType ,listRoomsWhereFeeSet} from '@/api/fee/applyRoomDiscountManageApi'
  import UploadImageUrl from '@/components/upload/UploadImageUrl'
24d3590f   wuxw   房屋收费页面开发完成
69
  import { getCommunityId } from '@/api/community/communityApi'
43eaaadb   wuxw   开发房屋优惠折扣
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
  
  export default {
    name: 'AddApplyRoomDiscount',
    components: {
      UploadImageUrl
    },
    data() {
      return {
        visible: false,
        form: {
          roomName: '',
          roomId: '',
          applyType: '',
          createUserName: '',
          createUserTel: '',
          startTime: '',
          endTime: '',
          createRemark: '',
          feeId: '',
          photos: [],
          communityId: ''
        },
        applyTypes: [],
        feeTypeCds: [],
        rules: {
          roomName: [
            { required: true, message: this.$t('applyRoomDiscount.validate.roomRequired'), trigger: 'blur' },
            { max: 64, message: this.$t('applyRoomDiscount.validate.roomFormat'), trigger: 'blur' }
          ],
          applyType: [
            { required: true, message: this.$t('applyRoomDiscount.validate.applyTypeRequired'), trigger: 'change' }
          ],
          feeId: [
            { required: true, message: this.$t('applyRoomDiscount.validate.feeIdRequired'), trigger: 'change' }
          ],
          createUserName: [
            { required: true, message: this.$t('applyRoomDiscount.validate.createUserRequired'), trigger: 'blur' },
            { max: 64, message: this.$t('applyRoomDiscount.validate.createUserFormat'), trigger: 'blur' }
          ],
          createUserTel: [
            { required: true, message: this.$t('applyRoomDiscount.validate.createUserTelRequired'), trigger: 'blur' },
            { pattern: /^1[3-9]\d{9}$/, message: this.$t('applyRoomDiscount.validate.createUserTelFormat'), trigger: 'blur' }
          ],
          startTime: [
            { required: true, message: this.$t('applyRoomDiscount.validate.startTimeRequired'), trigger: 'change' }
          ],
          endTime: [
            { required: true, message: this.$t('applyRoomDiscount.validate.endTimeRequired'), trigger: 'change' }
          ],
          createRemark: [
            { required: true, message: this.$t('applyRoomDiscount.validate.createRemarkRequired'), trigger: 'blur' },
            { max: 512, message: this.$t('applyRoomDiscount.validate.createRemarkFormat'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open() {
        this.visible = true
        this.getApplyTypes()
      },
      handleClose() {
        this.$refs.form.resetFields()
        this.$refs.uploadImage.clear()
        this.form = {
          roomName: '',
          roomId: '',
          applyType: '',
          createUserName: '',
          createUserTel: '',
          startTime: '',
          endTime: '',
          createRemark: '',
          feeId: '',
          photos: [],
          communityId: ''
        }
      },
      async getApplyTypes() {
        try {
          const { data } = await queryApplyRoomDiscountType({
            page: 1,
            row: 50,
            communityId: this.form.communityId
          })
          this.applyTypes = data
        } catch (error) {
          console.error('获取申请类型失败:', error)
        }
      },
      async queryRoom() {
        if (!this.form.roomName) return
  
        const parts = this.form.roomName.split('-')
        if (parts.length !== 3) {
          this.$message.error(this.$t('applyRoomDiscount.validate.roomFormat'))
          this.form.roomName = ''
          return
        }
  
        try {
          const params = {
            page: 1,
            row: 1,
            communityId: this.form.communityId,
            flag: 0,
            floorNum: parts[0].trim(),
            unitNum: parts[1].trim(),
            roomNum: parts[2].trim()
          }
  
          const { rooms } = await listRoomsWhereFeeSet(params)
          if (rooms.length === 0) {
            this.$message.error(this.$t('applyRoomDiscount.validate.roomNotFound'))
            this.form.roomName = ''
            return
          }
  
          const room = rooms[0]
          this.form.roomId = room.roomId
          this.form.createUserName = room.ownerName
          this.form.createUserTel = room.link
          this.queryRoomFees()
        } catch (error) {
          console.error('查询房屋失败:', error)
        }
      },
      async queryRoomFees() {
        try {
          const params = {
            page: 1,
            row: 50,
            communityId: this.form.communityId,
            payerObjId: this.form.roomId,
            state: '2008001'
          }
  
          const { data } = await this.$api.fee.listFee(params)
          this.feeTypeCds = data.fees
        } catch (error) {
          console.error('查询费用项失败:', error)
        }
      },
      validateDate() {
        if (this.form.startTime && this.form.endTime) {
          const start = new Date(this.form.startTime)
          const end = new Date(this.form.endTime)
          if (start >= end) {
            this.$message.error(this.$t('applyRoomDiscount.validate.dateInvalid'))
            this.form.endTime = ''
          }
        }
      },
      handleImageChange(photos) {
        this.form.photos = photos
      },
      submitForm() {
        this.$refs.form.validate(valid => {
          if (valid) {
            this.saveApplyRoomDiscount()
          }
        })
      },
      async saveApplyRoomDiscount() {
        try {
24d3590f   wuxw   房屋收费页面开发完成
235
          this.form.communityId = getCommunityId()
43eaaadb   wuxw   开发房屋优惠折扣
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
          await this.$api.applyRoomDiscount.saveApplyRoomDiscount(this.form)
          this.$message.success(this.$t('applyRoomDiscount.message.saveSuccess'))
          this.visible = false
          this.$emit('success')
        } catch (error) {
          this.$message.error(error.message || this.$t('applyRoomDiscount.message.saveFailed'))
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .el-form-item {
    margin-bottom: 22px;
  }
  </style>