Blame view

src/views/fee/batchPayFeeOrderList.vue 15.9 KB
24d3590f   wuxw   房屋收费页面开发完成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  <template>
    <div class="batch-pay-fee-order-container">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-card class="payer-object-card">
            <div class="card-title">收费对象</div>
            <div class="checkbox-list">
              <el-checkbox-group v-model="batchPayFeeOrderInfo.payerObjNames" @change="_chanagePayerObjName">
                <el-checkbox v-for="(item, index) in batchPayFeeOrderInfo.payObjs" :key="index" :label="item"
                  class="checkbox-item">{{ item }}</el-checkbox>
              </el-checkbox-group>
            </div>
          </el-card>
        </el-col>
        <el-col :span="20">
          <el-card>
            <div slot="header" class="flex justify-between">
              <span>{{ $t('batchPayFeeOrder.title') }}</span>
              <el-button type="primary" size="small" class="float-right" @click="_goBack">{{ $t('common.back')
              }}</el-button>
            </div>
  
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
23
24
            <el-table :data="batchPayFeeOrderInfo.batchFees" border style="width: 100%" v-loading="loading"
              @selection-change="handleSelectionChange" ref="batchFeeTable">
24d3590f   wuxw   房屋收费页面开发完成
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
              <el-table-column type="selection" width="55" align="center"></el-table-column>
              <el-table-column prop="feeTypeCdName" :label="$t('batchPayFeeOrder.feeType')"
                align="center"></el-table-column>
              <el-table-column prop="feeName" :label="$t('batchPayFeeOrder.feeItem')" align="center"></el-table-column>
              <el-table-column prop="feeFlagName" :label="$t('batchPayFeeOrder.feeFlag')"
                align="center"></el-table-column>
              <el-table-column :label="$t('batchPayFeeOrder.payerObj')" align="center">
                <template slot-scope="scope">
                  {{ _getBatchPayFeeRoomName(scope.row) }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('batchPayFeeOrder.receivablePeriod')" align="center" width="180">
                <template slot-scope="scope">
                  <div>{{ _getEndTime(scope.row) }}</div>
                  <div>{{ _getDeadlineTime(scope.row) }}</div>
                </template>
              </el-table-column>
              <el-table-column :label="$t('batchPayFeeOrder.receivable')" align="center">
                <template slot-scope="scope">
                  {{ scope.row.receivableAmount }}/{{ scope.row.amountOwed }}
                </template>
              </el-table-column>
              <el-table-column :label="$t('batchPayFeeOrder.paymentCycle')" align="center" width="150">
                <template slot-scope="scope">
                  <div v-if="scope.row.feeFlag != '2006012'">
                    <div v-if="scope.row.tempCycle == '-102'" class="cycle-text">周期:{{ scope.row.cycles }}个月</div>
                    <div v-else-if="scope.row.tempCycle == '-101'" class="custom-amount">
                      自定义金额<br>{{ scope.row.receivedAmount }}</div>
                    <div v-else-if="scope.row.tempCycle == '-103'" class="custom-end-time">
                      结束时间<br>{{ scope.row.custEndTime }}</div>
                    <el-select v-else v-model="scope.row.cycles" @change="_changeMonth(scope.row.cycles, scope.row)"
                      style="width:100%">
                      <el-option v-for="item in _getBatchPaymentCycles(scope.row)" :key="item"
                        :label="`${item}${$t('batchPayFeeOrder.month')}`" :value="item"></el-option>
                    </el-select>
                    <el-button type="text" icon="el-icon-setting" @click="_settingsFeeCycle(scope.row)"></el-button>
                  </div>
                  <div v-else>-</div>
                </template>
              </el-table-column>
              <el-table-column :label="$t('batchPayFeeOrder.actualAmount')" align="center" width="150">
                <template slot-scope="scope">
                  <el-input v-if="scope.row.receivedAmountSwitch == '1'" v-model="scope.row.receivedAmount"
                    :placeholder="$t('batchPayFeeOrder.enterActualAmount')" @change="_doComputeTotalFee"></el-input>
                  <span v-else>{{ scope.row.receivedAmount }}</span>
                </template>
              </el-table-column>
              <el-table-column :label="$t('batchPayFeeOrder.remark')" align="center" width="200">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.remark" :placeholder="$t('batchPayFeeOrder.enterRemark')"></el-input>
                </template>
              </el-table-column>
            </el-table>
          </el-card>
          <div class="margin-top">
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
80
81
            <pay-fee-user-account ref="payFeeUserAccount"
              @changeUserAmountPrice="changeUserAmountPrice"></pay-fee-user-account>
24d3590f   wuxw   房屋收费页面开发完成
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
          </div>
          <pay-fee-deposit ref="payFeeDeposit"></pay-fee-deposit>
  
          <el-row class="footer-row text-left">
            <el-col :span="16">
              <div class="tips">
                <p>温馨提示:批量缴费不支持优惠折扣和优惠券抵扣功能,如需要请到缴费页面缴费</p>
                <p><b>缴费金额:缴费金额等于所有实收</b></p>
              </div>
            </el-col>
            <el-col :span="4">
              <div class="total-amount">
                缴费金额:<span class="amount">{{ batchPayFeeOrderInfo.feePrices }}元</span>
              </div>
            </el-col>
            <el-col :span="4" class="text-right">
              <el-button type="success" size="medium" @click="_openPayFee('qrCode')">{{ $t('batchPayFeeOrder.scanPay')
              }}</el-button>
              <el-button type="primary" size="medium" @click="_openPayFee('common')">{{ $t('batchPayFeeOrder.submitPay')
              }}</el-button>
            </el-col>
          </el-row>
  
        </el-col>
      </el-row>
  
      <batch-pay-confirm ref="batchPayConfirm"></batch-pay-confirm>
      <batch-fee-cycle ref="batchFeeCycle"></batch-fee-cycle>
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import PayFeeUserAccount from '@/components/fee/payFeeUserAccount'
  import PayFeeDeposit from '@/components/fee/payFeeDeposit'
  import BatchPayConfirm from '@/components/fee/batchPayConfirm'
  import BatchFeeCycle from '@/components/fee/batchFeeCycle'
  import { listFee, listFeeObj } from '@/api/fee/batchPayFeeOrderApi'
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
120
  import { dateFormat, dateAdd } from '@/utils/dateUtil'
24d3590f   wuxw   房屋收费页面开发完成
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
  
  export default {
    name: 'BatchPayFeeOrderList',
    components: {
      PayFeeUserAccount,
      PayFeeDeposit,
      BatchPayConfirm,
      BatchFeeCycle
    },
    data() {
      return {
        loading: false,
        batchPayFeeOrderInfo: {
          batchFees: [],
          allBatchFees: [],
          selectPayFeeIds: [],
          feePrices: 0.00,
          communityId: '',
          ownerId: '',
          payerObjType: '',
          remark: '',
          payerObjNames: [],
          payObjs: [],
          accountAmount: 0.0,
          acctId: ''
        }
      }
    },
    created() {
      this.communityId = getCommunityId()
      this._initData()
    },
    methods: {
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
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
      // 新增:处理表格选择变化
      handleSelectionChange(selection) {
        console.log('选中的行:', selection)
  
        // 更新 selectPayFeeIds 数组
        this.batchPayFeeOrderInfo.selectPayFeeIds = selection.map(item => item.feeId)
  
        console.log('更新后的 selectPayFeeIds:', this.batchPayFeeOrderInfo.selectPayFeeIds)
  
        // 重新计算总费用
        this._doComputeTotalFee()
      },
  
      // 新增:设置表格选中状态
      setTableSelection() {
        // 根据 selectPayFeeIds 设置表格的选中状态
        this.$nextTick(() => {
          if (this.$refs.batchFeeTable) {
            this.batchPayFeeOrderInfo.batchFees.forEach(row => {
              if (this.batchPayFeeOrderInfo.selectPayFeeIds.includes(row.feeId)) {
                this.$refs.batchFeeTable.toggleRowSelection(row, true)
              }
            })
          }
        })
      },
  
24d3590f   wuxw   房屋收费页面开发完成
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
      async _initData() {
        const ownerId = this.$route.query.ownerId
        const payerObjType = this.$route.query.payerObjType
  
        if (!ownerId) {
          this.$message.error('非法操作')
          this.$router.go(-1)
          return
        }
  
        this.batchPayFeeOrderInfo.ownerId = ownerId
        this.batchPayFeeOrderInfo.payerObjType = payerObjType
  
        await this._loadBatchFees()
  
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
196
197
198
199
        setTimeout(() => {
          this.$refs.payFeeUserAccount.open({ ownerId: this.batchPayFeeOrderInfo.ownerId })
          this.$refs.payFeeDeposit.open({ payerObjId: this.batchPayFeeOrderInfo.ownerId, payerObjType: this.batchPayFeeOrderInfo.payerObjType })
        }, 1000)
24d3590f   wuxw   房屋收费页面开发完成
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
      },
  
      async _loadBatchFees() {
        this.loading = true
        try {
          const params = {
            page: 1,
            row: 500,
            communityId: this.communityId,
            ownerId: this.batchPayFeeOrderInfo.ownerId,
            payerObjType: this.batchPayFeeOrderInfo.payerObjType,
            state: '2008001'
          }
  
          const res = await listFee(params)
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
215
  
24d3590f   wuxw   房屋收费页面开发完成
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
          let _batchFees = []
          let _selectPayFeeIds = []
  
          res.fees.sort(this._batchRoomFeeCompare).forEach(feeItem => {
            _batchFees.push({
              ...feeItem,
              cycles: feeItem.paymentCycle,
              receivableAmount: feeItem.feeTotalPrice,
              receivedAmount: feeItem.feeTotalPrice,
              tempCycle: '-100'
            })
            _selectPayFeeIds.push(feeItem.feeId)
          })
  
          this.batchPayFeeOrderInfo = {
            ...this.batchPayFeeOrderInfo,
            allBatchFees: _batchFees,
            selectPayFeeIds: _selectPayFeeIds,
            batchFees: _batchFees
          }
  
          this._pushPayObjs()
          this._doComputeTotalFee()
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
239
240
241
  
          // 设置表格选中状态
          this.setTableSelection()
24d3590f   wuxw   房屋收费页面开发完成
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
271
272
273
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
        } catch (error) {
          console.error('请求失败:', error)
        } finally {
          this.loading = false
        }
      },
  
      _batchRoomFeeCompare(a, b) {
        if (a.payerObjName < b.payerObjName) return -1
        if (a.payerObjName > b.payerObjName) return 1
        return 0
      },
  
      _pushPayObjs() {
        const _allBatchFees = this.batchPayFeeOrderInfo.allBatchFees
        const _payObjs = []
        const _payerObjNames = []
  
        _allBatchFees.forEach(fee => {
          if (!fee.feeAttrs) return
  
          let _payerObjName = ''
          fee.feeAttrs.forEach(item => {
            if (item.specCd === '390012') {
              _payerObjName = item.value
            }
          })
  
          if (_payerObjName && !this._hasPayObjsIn(_payerObjName, _payObjs)) {
            _payObjs.push(_payerObjName)
            _payerObjNames.push(_payerObjName)
          }
        })
  
        this.batchPayFeeOrderInfo.payObjs = _payObjs
        this.batchPayFeeOrderInfo.payerObjNames = _payerObjNames
      },
  
      _hasPayObjsIn(payerObjName, payObjs) {
        return payObjs.includes(payerObjName)
      },
  
      _hasPayObjNamesIn(payerObjName) {
        return this.batchPayFeeOrderInfo.payerObjNames.includes(payerObjName)
      },
  
      _chanagePayerObjName() {
        const _allBatchFees = this.batchPayFeeOrderInfo.allBatchFees
        const _batchFees = []
  
        _allBatchFees.forEach(fee => {
          let _payerObjName = ''
          if (fee.feeAttrs) {
            fee.feeAttrs.forEach(item => {
              if (item.specCd === '390012') {
                _payerObjName = item.value
              }
            })
          }
  
          if (_payerObjName && this._hasPayObjNamesIn(_payerObjName)) {
            _batchFees.push(fee)
          }
        })
  
        this.batchPayFeeOrderInfo.batchFees = _batchFees
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
308
309
310
311
312
313
314
  
        // 更新 selectPayFeeIds,只保留当前显示的费用ID
        const currentFeeIds = _batchFees.map(fee => fee.feeId)
        this.batchPayFeeOrderInfo.selectPayFeeIds = this.batchPayFeeOrderInfo.selectPayFeeIds.filter(id =>
          currentFeeIds.includes(id)
        )
  
24d3590f   wuxw   房屋收费页面开发完成
315
        this._doComputeTotalFee()
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
316
317
318
  
        // 重新设置表格选中状态
        this.setTableSelection()
24d3590f   wuxw   房屋收费页面开发完成
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
      },
  
      _openPayFee(payType) {
        if (this.batchPayFeeOrderInfo.selectPayFeeIds.length <= 0) {
          this.$message.warning('未选择费用')
          return
        }
  
        const _payerObjName = this.batchPayFeeOrderInfo.payerObjNames.join(',')
        const params = {
          fees: this._getPayFees(),
          payType: payType,
          feePrices: this.batchPayFeeOrderInfo.feePrices,
          payerObjName: _payerObjName,
          acctId: this.batchPayFeeOrderInfo.acctId,
          accountAmount: this.batchPayFeeOrderInfo.accountAmount
        }
  
        this.$refs.batchPayConfirm.open(params)
      },
  
      _getPayFees() {
        const _selectPayFeeIds = this.batchPayFeeOrderInfo.selectPayFeeIds
        const _batchFees = this.batchPayFeeOrderInfo.batchFees
        const _fees = []
  
        _selectPayFeeIds.forEach(id => {
          _batchFees.forEach(fee => {
            if (id === fee.feeId) {
              _fees.push(fee)
            }
          })
        })
  
        return _fees
      },
  
      _goBack() {
        this.$router.go(-1)
      },
  
      _getDeadlineTime(fee) {
        if (fee.amountOwed === 0 && fee.endTime === fee.deadlineTime) return "-"
        if (fee.state === '2009001') return "-"
        return dateFormat(fee.deadlineTime)
      },
  
      _getEndTime(fee) {
        if (fee.state === '2009001') return "-"
        return dateFormat(fee.endTime)
      },
  
      _getBatchPayFeeRoomName(fee) {
        if (!fee.feeAttrs) return ""
  
        let _feeName = ''
        fee.feeAttrs.forEach(item => {
          if (item.specCd === '390012') {
            _feeName = item.value
          }
        })
  
        return _feeName
      },
  
      _getBatchPaymentCycles(fee) {
        const paymentCycles = []
        for (let i = 1; i < 13; i++) {
          paymentCycles.push(i * parseFloat(fee.paymentCycle))
        }
        return paymentCycles
      },
  
      _doComputeTotalFee() {
        const _selectPayFeeIds = this.batchPayFeeOrderInfo.selectPayFeeIds
        const _batchFees = this.batchPayFeeOrderInfo.batchFees
        const _accountAmount = this.batchPayFeeOrderInfo.accountAmount
  
        let _totalFee = 0
  
        _selectPayFeeIds.forEach(id => {
          _batchFees.forEach(fee => {
            if (id === fee.feeId && fee.receivedAmount) {
              _totalFee += parseFloat(fee.receivedAmount)
            }
          })
        })
  
        if (_accountAmount) {
          _totalFee = _totalFee - parseFloat(_accountAmount)
        }
  
        this.batchPayFeeOrderInfo.feePrices = Math.max(0, _totalFee).toFixed(2)
      },
  
      async _changeMonth(cycles, fee) {
        if (!cycles) {
          cycles = fee.cycles
        }
  
        if (fee.tempCycle === '-101') {
          this._doComputeTotalFee()
          return
        }
  
        try {
          const params = {
            communityId: this.communityId,
            feeId: fee.feeId,
            page: 1,
            row: 1,
            cycle: cycles
          }
  
          if (fee.tempCycle === '-103') {
            params.custEndTime = dateAdd(fee.custEndTime)
          }
  
          const res = await listFeeObj(params)
          if (res.code === 0) {
            fee.receivableAmount = res.data.feeTotalPrice
            fee.receivedAmount = fee.receivableAmount
            this._doComputeTotalFee()
          }
        } catch (error) {
          console.error('请求失败:', error)
        }
      },
  
      _settingsFeeCycle(batchFee) {
        this.$refs.batchFeeCycle.open(batchFee)
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
450
451
452
453
454
455
456
457
458
459
460
461
      },
  
      changeUserAmountPrice(data) {
        this.batchPayFeeOrderInfo.accountAmount = data.totalUserAmount;
        if (data.selectAccount && data.selectAccount.length > 0) {
          data.selectAccount.forEach(_acct => {
            if (_acct.acctType == '2003') {
              this.batchPayFeeOrderInfo.acctId = _acct.acctId;
            }
          })
        }
        this._doComputeTotalFee();
24d3590f   wuxw   房屋收费页面开发完成
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .batch-pay-fee-order-container {
    padding: 20px;
  
    .payer-object-card {
      height: 100%;
  
      .card-title {
        padding: 10px;
        font-weight: bold;
      }
  
      .checkbox-list {
        padding: 10px;
  
        .checkbox-item {
          display: block;
          margin: 5px 0;
        }
      }
    }
  
    .footer-row {
      margin-top: 20px;
      padding: 20px;
      background: #f5f7fa;
      border-radius: 4px;
  
      .tips {
        color: #666;
        line-height: 1.6;
      }
  
      .total-amount {
        font-size: 16px;
  
        .amount {
          font-size: 30px;
          color: #f56c6c;
          margin-left: 5px;
        }
      }
    }
  
    .cycle-text,
    .custom-amount,
    .custom-end-time {
      line-height: 1.5;
      padding: 5px 0;
    }
  }
  </style>