Blame view

src/components/fee/reviewApplyRoomDiscount.vue 10.8 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
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
  <template>
    <el-dialog :title="$t('applyRoomDiscount.review.title')" :visible.sync="visible" width="70%" @close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <template v-if="form.state !== '5'">
          <el-form-item :label="$t('applyRoomDiscount.review.discountType')" prop="discountType">
            <el-select v-model="form.discountType" :placeholder="$t('applyRoomDiscount.review.discountTypePlaceholder')"
              style="width:100%" @change="handleDiscountTypeChange">
              <el-option :label="$t('applyRoomDiscount.discountType.discount')" value="3003" />
            </el-select>
          </el-form-item>
  
          <el-form-item :label="$t('applyRoomDiscount.review.discountName')" prop="discountId">
            <el-select v-model="form.discountId" :placeholder="$t('applyRoomDiscount.review.discountNamePlaceholder')"
              style="width:100%">
              <el-option v-for="item in discounts" :key="item.discountId" :label="item.discountName"
                :value="item.discountId" />
            </el-select>
          </el-form-item>
  
          <el-form-item :label="$t('applyRoomDiscount.review.returnWay')" prop="returnWay">
            <el-select v-model="form.returnWay" :placeholder="$t('applyRoomDiscount.review.returnWayPlaceholder')"
              style="width:100%">
              <el-option :label="$t('applyRoomDiscount.returnWay.discount')" value="1001" />
              <el-option :label="$t('applyRoomDiscount.returnWay.account')" value="1002" />
            </el-select>
          </el-form-item>
  
          <div v-show="form.returnWay === '1002'">
            <el-form-item :label="$t('applyRoomDiscount.review.paymentRecords')">
              <div class="checkbox-group">
                <el-checkbox v-for="item in fees" :key="item.detailId" v-model="form.selectedFees" :label="item.detailId"
                  @change="handleFeeSelection(item)">
                  【{{ item.feeName }}】<span class="text-danger">{{ item.receivedAmount }}{{ $t('common.yuan') }}</span> -
                  {{ item.createTime }}
                </el-checkbox>
              </div>
            </el-form-item>
  
            <el-form-item :label="$t('applyRoomDiscount.review.refundAmount')" prop="refundAmount">
              <el-input v-model="form.refundAmount"
                :placeholder="$t('applyRoomDiscount.review.refundAmountPlaceholder')" />
            </el-form-item>
          </div>
        </template>
  
        <el-form-item :label="$t('applyRoomDiscount.review.startTime')" prop="startTime">
          <el-date-picker v-model="form.startTime" type="datetime"
            :placeholder="$t('applyRoomDiscount.review.startTimePlaceholder')" value-format="yyyy-MM-dd HH:mm:ss"
            style="width:100%" />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.review.endTime')" prop="endTime">
          <el-date-picker v-model="form.endTime" type="datetime"
            :placeholder="$t('applyRoomDiscount.review.endTimePlaceholder')" value-format="yyyy-MM-dd HH:mm:ss"
            style="width:100%" />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.review.state')" prop="state">
          <el-select v-model="form.state" :placeholder="$t('applyRoomDiscount.review.statePlaceholder')"
            style="width:100%">
            <el-option :label="$t('applyRoomDiscount.status.reviewPass')" value="4" />
            <el-option :label="$t('applyRoomDiscount.status.reviewReject')" value="5" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.review.createRemark')">
          <el-input v-model="form.createRemark" type="textarea" :rows="2" disabled />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.review.checkRemark')">
          <el-input v-model="form.checkRemark" type="textarea" :rows="2" disabled />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.review.reviewRemark')" prop="reviewRemark">
          <el-input v-model="form.reviewRemark" type="textarea"
            :placeholder="$t('applyRoomDiscount.review.reviewRemarkPlaceholder')" :rows="3" />
        </el-form-item>
  
        <el-form-item :label="$t('applyRoomDiscount.review.images')">
          <div class="image-preview-group">
            <div v-for="(url, index) in form.images" :key="index" class="image-preview-item">
              <img :src="getImageUrl(url)" @click="showImage(url)" />
            </div>
          </div>
        </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>
  
      <view-image ref="viewImage" />
    </el-dialog>
  </template>
  
  <script>
  //import { getDict } from '@/api/community/communityApi'
  import { queryFeeDiscount, updateReviewApplyRoomDiscount } from '@/api/fee/applyRoomDiscountManageApi'
  import ViewImage from '@/components/system/viewImage'
24d3590f   wuxw   房屋收费页面开发完成
105
  import { getCommunityId } from '@/api/community/communityApi'
76d4c8fc   wuxw   优惠需要申请测试中
106
  import { queryFeeDetail } from '@/api/fee/propertyFeeApi'
43eaaadb   wuxw   开发房屋优惠折扣
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
  
  export default {
    name: 'ReviewApplyRoomDiscount',
    components: {
      ViewImage
    },
    data() {
      return {
        visible: false,
        form: {
          ardId: '',
          discountId: '',
          discountType: '',
          startTime: '',
          endTime: '',
          createRemark: '',
          checkRemark: '',
          reviewRemark: '',
          refundAmount: '',
          state: '',
          roomId: '',
          discounts: [],
          fees: [],
          selectedFees: [],
          images: [],
          returnWay: '1001',
          feeId: ''
        },
        discounts: [],
        fees: [],
        rules: {
          discountId: [
            { required: true, message: this.$t('applyRoomDiscount.validate.discountIdRequired'), trigger: 'change' }
          ],
          discountType: [
            { required: true, message: this.$t('applyRoomDiscount.validate.discountTypeRequired'), trigger: 'change' }
          ],
          returnWay: [
            { required: true, message: this.$t('applyRoomDiscount.validate.returnWayRequired'), trigger: 'change' }
          ],
          refundAmount: [
            {
              required: true,
              message: this.$t('applyRoomDiscount.validate.refundAmountRequired'),
              trigger: 'blur',
              validator: (rule, value, callback) => {
                if (this.form.returnWay === '1002' && !value) {
                  callback(new Error(this.$t('applyRoomDiscount.validate.refundAmountRequired')))
                } else {
                  callback()
                }
              }
            },
            {
              pattern: /^\d+(\.\d{1,2})?$/,
              message: this.$t('applyRoomDiscount.validate.refundAmountFormat'),
              trigger: 'blur'
            }
          ],
          startTime: [
            { required: true, message: this.$t('applyRoomDiscount.validate.startTimeRequired'), trigger: 'change' }
          ],
          endTime: [
            { required: true, message: this.$t('applyRoomDiscount.validate.endTimeRequired'), trigger: 'change' }
          ],
          state: [
            { required: true, message: this.$t('applyRoomDiscount.validate.stateRequired'), trigger: 'change' }
          ],
          reviewRemark: [
            { required: true, message: this.$t('applyRoomDiscount.validate.reviewRemarkRequired'), trigger: 'blur' },
            { max: 512, message: this.$t('applyRoomDiscount.validate.reviewRemarkFormat'), trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      open(data) {
        this.form = {
          ...this.form,
          ...data,
24d3590f   wuxw   房屋收费页面开发完成
187
          communityId: getCommunityId(),
43eaaadb   wuxw   开发房屋优惠折扣
188
          selectedFees: [],
745b8235   wuxw   v1.9 优化优惠申请 bug
189
190
          refundAmount: '',
          state:''
43eaaadb   wuxw   开发房屋优惠折扣
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
        }
        this.visible = true
        this.loadDiscounts()
        this.loadFees()
      },
      handleClose() {
        this.$refs.form.resetFields()
        this.form = {
          ardId: '',
          discountId: '',
          discountType: '',
          startTime: '',
          endTime: '',
          createRemark: '',
          checkRemark: '',
          reviewRemark: '',
          refundAmount: '',
          state: '',
          roomId: '',
          discounts: [],
          fees: [],
          selectedFees: [],
          images: [],
          returnWay: '1001',
          feeId: ''
        }
      },
      async loadDiscounts() {
        try {
          const { data } = await queryFeeDiscount({
            page: 1,
            row: 100,
            communityId: this.form.communityId,
            discountType: this.form.discountType || '3003'
          })
          this.discounts = data
        } catch (error) {
          console.error('加载折扣信息失败:', error)
        }
      },
      async loadFees() {
        try {
76d4c8fc   wuxw   优惠需要申请测试中
233
          const { feeDetails } = await queryFeeDetail({
43eaaadb   wuxw   开发房屋优惠折扣
234
235
236
237
238
239
            page: 1,
            row: 50,
            communityId: this.form.communityId,
            feeId: this.form.feeId,
            state: '1400'
          })
76d4c8fc   wuxw   优惠需要申请测试中
240
          this.fees = feeDetails
43eaaadb   wuxw   开发房屋优惠折扣
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
        } catch (error) {
          console.error('加载缴费记录失败:', error)
        }
      },
      handleDiscountTypeChange() {
        this.form.discountId = ''
        this.loadDiscounts()
      },
      handleFeeSelection(item) {
        console.log(item)
        this.calculateRefundAmount()
      },
      calculateRefundAmount() {
        if (this.form.returnWay !== '1002') return
  
        let total = 0
        this.fees.forEach(item => {
          if (this.form.selectedFees.includes(item.detailId)) {
            total += parseFloat(item.receivedAmount) || 0
          }
        })
        this.form.refundAmount = total.toFixed(2)
      },
      getImageUrl(url) {
        if (url.startsWith('http') || url.startsWith('https') || url.startsWith('data:')) {
          return url
        }
        return `/callComponent/download/getFile/file?fileId=${url}&communityId=-1&time=${new Date().getTime()}`
      },
      showImage(url) {
76d4c8fc   wuxw   优惠需要申请测试中
271
272
273
        setTimeout(() => {
          this.$refs.viewImage.open(this.getImageUrl(url))
        }, 100)
43eaaadb   wuxw   开发房屋优惠折扣
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
      },
      submitForm() {
        this.$refs.form.validate(valid => {
          if (valid) {
            this.updateReview()
          }
        })
      },
      async updateReview() {
        try {
          await updateReviewApplyRoomDiscount(this.form)
          this.$message.success(this.$t('applyRoomDiscount.message.reviewSuccess'))
          this.visible = false
          this.$emit('success')
        } catch (error) {
          this.$message.error(error.message || this.$t('applyRoomDiscount.message.reviewFailed'))
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .el-form-item {
    margin-bottom: 22px;
  }
  
  .checkbox-group {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    padding: 10px;
  
    .el-checkbox {
      display: block;
      margin: 5px 0;
    }
  }
  
  .text-danger {
    color: #f56c6c;
  }
  
  .image-preview-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  
    .image-preview-item {
      width: 60px;
      height: 60px;
      border: 1px solid #dcdfe6;
      border-radius: 4px;
      overflow: hidden;
      cursor: pointer;
  
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
  }
  </style>