Blame view

src/components/fee/payFeeUserAccount.vue 4.95 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
2
3
4
    <div>
      <el-card v-if="accountList.length > 0" class="margin-bottom-sm">
        <div slot="header" class="flex justify-between">
1a0bdbe0   wuxw   优化缴费页面
5
          <span>{{ $t('payFeeUserAccount.accountInfo') }}</span>
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
6
          <el-button type="primary" size="small" style="float: right;" @click="queryPayFeeUserAccount">
1a0bdbe0   wuxw   优化缴费页面
7
8
9
10
            <i class="el-icon-refresh"></i>
            {{ $t('payFeeUserAccount.refresh') }}
          </el-button>
        </div>
24d3590f   wuxw   房屋收费页面开发完成
11
  
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
12
13
        <el-table :data="accountList" border style="width: 100%">
          <el-table-column align="center" :label="$t('payFeeUserAccount.select')" width="80">
1a0bdbe0   wuxw   优化缴费页面
14
            <template slot-scope="scope">
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
15
16
              <el-checkbox v-model="selectedAccounts" :value="scope.row.acctId"
                @change="(checked) => handleAccountChange(scope.row.acctId, checked)"></el-checkbox>
1a0bdbe0   wuxw   优化缴费页面
17
18
            </template>
          </el-table-column>
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
19
20
21
          <el-table-column prop="acctTypeName" align="center" :label="$t('payFeeUserAccount.accountType')" />
          <el-table-column prop="acctName" align="center" :label="$t('payFeeUserAccount.accountName')" />
          <el-table-column prop="amount" align="center" :label="$t('payFeeUserAccount.accountAmount')">
1a0bdbe0   wuxw   优化缴费页面
22
23
24
25
            <template slot-scope="scope">
              {{ scope.row.amount }} {{ $t('payFeeUserAccount.yuan') }}
            </template>
          </el-table-column>
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
26
          <el-table-column align="center" :label="$t('payFeeUserAccount.operation')" width="150">
1a0bdbe0   wuxw   优化缴费页面
27
            <template slot-scope="scope">
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
28
              <el-button type="primary" size="mini" @click="openAddUserAmountModal(scope.row)">
1a0bdbe0   wuxw   优化缴费页面
29
30
31
32
33
34
35
                <i class="el-icon-plus"></i>
                {{ $t('payFeeUserAccount.prestore') }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
36
    </div>
24d3590f   wuxw   房屋收费页面开发完成
37
38
39
40
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
41
  import { queryCommunityOwnerAccount } from '@/api/fee/payFeeOrderApi'
24d3590f   wuxw   房屋收费页面开发完成
42
43
44
45
46
  
  export default {
    name: 'PayFeeUserAccount',
    data() {
      return {
1a0bdbe0   wuxw   优化缴费页面
47
48
49
50
        accountList: [],
        feeId: '',
        ownerId: '',
        communityId: '',
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
51
        selectedAccounts: [] // 改为数组,支持多选
24d3590f   wuxw   房屋收费页面开发完成
52
53
      }
    },
24d3590f   wuxw   房屋收费页面开发完成
54
    methods: {
1a0bdbe0   wuxw   优化缴费页面
55
56
57
58
      open(params) {
        this.feeId = params.feeId
        this.ownerId = params.ownerId || ''
        this.listUserAccount()
1a0bdbe0   wuxw   优化缴费页面
59
60
61
62
63
      },
      close() {
        this.dialogVisible = false
      },
      async listUserAccount() {
24d3590f   wuxw   房屋收费页面开发完成
64
        try {
1a0bdbe0   wuxw   优化缴费页面
65
          this.communityId = await getCommunityId()
24d3590f   wuxw   房屋收费页面开发完成
66
          const params = {
1a0bdbe0   wuxw   优化缴费页面
67
68
69
70
71
            page: 1,
            row: 20,
            feeId: this.feeId,
            ownerId: this.ownerId,
            communityId: this.communityId
24d3590f   wuxw   房屋收费页面开发完成
72
73
          }
  
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
74
75
          const response = await queryCommunityOwnerAccount(params)
          this.accountList = response.data || []
24d3590f   wuxw   房屋收费页面开发完成
76
        } catch (error) {
1a0bdbe0   wuxw   优化缴费页面
77
          console.error('查询用户账户失败:', error)
24d3590f   wuxw   房屋收费页面开发完成
78
79
        }
      },
1a0bdbe0   wuxw   优化缴费页面
80
81
      queryPayFeeUserAccount() {
        this.listUserAccount()
24d3590f   wuxw   房屋收费页面开发完成
82
      },
1a0bdbe0   wuxw   优化缴费页面
83
      openAddUserAmountModal(userAccount) {
9d019fa6   wuxw   测试OA相关流程
84
        window.open(`/#/views/owner/ownerDetail?ownerId=${userAccount.objId}&currentTab=ownerDetailAccount`)
24d3590f   wuxw   房屋收费页面开发完成
85
      },
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
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
      // 新增:处理账户选择变化
      handleAccountChange(acctId, checked) {
        console.log('选中的账户ID:', acctId, '是否选中:', checked)
        console.log('当前selectedAccounts:', this.selectedAccounts)
        
        // 确保 selectedAccounts 是数组
        if (!Array.isArray(this.selectedAccounts)) {
          this.selectedAccounts = []
        }
        
        if (checked) {
          // 添加到选中数组
          if (!this.selectedAccounts.includes(acctId)) {
            this.selectedAccounts.push(acctId)
          }
        } else {
          // 从选中数组中移除
          const index = this.selectedAccounts.indexOf(acctId)
          if (index > -1) {
            this.selectedAccounts.splice(index, 1)
          }
        }
        
        console.log('更新后的selectedAccounts:', this.selectedAccounts)
        this.computeFeeUserAmount()
      },
      // 修复:computeFeeUserAmount 方法
      computeFeeUserAmount() {
        console.log('计算费用,选中的账户:', this.selectedAccounts)
        
1a0bdbe0   wuxw   优化缴费页面
116
117
        let totalUserAmount = 0.0
        let selectAccount = []
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
118
119
120
121
122
123
  
        // 确保 selectedAccounts 是数组
        if (!Array.isArray(this.selectedAccounts)) {
          this.selectedAccounts = []
        }
  
1a0bdbe0   wuxw   优化缴费页面
124
        this.accountList.forEach(item => {
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
125
          if (this.selectedAccounts.includes(item.acctId) && item.amount != 0) {
1a0bdbe0   wuxw   优化缴费页面
126
127
            totalUserAmount += parseFloat(item.amount)
            selectAccount.push(item)
24d3590f   wuxw   房屋收费页面开发完成
128
129
130
          }
        })
  
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
131
132
        console.log('计算的总金额:', totalUserAmount, '选中的账户列表:', selectAccount)
  
24d3590f   wuxw   房屋收费页面开发完成
133
        this.$emit('changeUserAmountPrice', {
1a0bdbe0   wuxw   优化缴费页面
134
135
          totalUserAmount,
          accountList: this.accountList,
24d3590f   wuxw   房屋收费页面开发完成
136
          integralAmount: 0,
1a0bdbe0   wuxw   优化缴费页面
137
          cashAmount: totalUserAmount,
24d3590f   wuxw   房屋收费页面开发完成
138
          couponAmount: 0,
1a0bdbe0   wuxw   优化缴费页面
139
          selectAccount
24d3590f   wuxw   房屋收费页面开发完成
140
141
        })
      },
1a0bdbe0   wuxw   优化缴费页面
142
143
      handleClose() {
        this.accountList = []
ab1ebb3c   wuxw   缴费支持 押金 优惠券 优惠折扣 ...
144
        this.selectedAccounts = [] // 清空选中的账户
1a0bdbe0   wuxw   优化缴费页面
145
146
        this.feeId = ''
        this.ownerId = ''
24d3590f   wuxw   房屋收费页面开发完成
147
148
149
150
151
      }
    }
  }
  </script>
  
1a0bdbe0   wuxw   优化缴费页面
152
153
154
  <style scoped>
  .el-table {
    margin-top: 20px;
24d3590f   wuxw   房屋收费页面开发完成
155
156
  }
  </style>