Commit 96514773072fd43ff7cb4055ee71ab465ef8d1da
1 parent
7cefa499
解决缴费页面账户选择bug
Showing
1 changed file
with
19 additions
and
42 deletions
src/components/fee/payFeeUserAccount.vue
| @@ -10,10 +10,14 @@ | @@ -10,10 +10,14 @@ | ||
| 10 | </div> | 10 | </div> |
| 11 | 11 | ||
| 12 | <el-table :data="accountList" border style="width: 100%"> | 12 | <el-table :data="accountList" border style="width: 100%"> |
| 13 | - <el-table-column align="center" :label="$t('payFeeUserAccount.select')" width="80"> | 13 | + <el-table-column align="center" :label="$t('payFeeUserAccount.select')" width="120"> |
| 14 | <template slot-scope="scope"> | 14 | <template slot-scope="scope"> |
| 15 | - <el-checkbox v-model="selectedAccounts" :value="scope.row.acctId" | ||
| 16 | - @change="(checked) => handleAccountChange(scope.row.acctId, checked)"></el-checkbox> | 15 | + <el-radio |
| 16 | + v-model="selectedAccount" | ||
| 17 | + :label="scope.row.acctId" | ||
| 18 | + @change="() => handleAccountChange(scope.row)" | ||
| 19 | + > | ||
| 20 | + </el-radio> | ||
| 17 | </template> | 21 | </template> |
| 18 | </el-table-column> | 22 | </el-table-column> |
| 19 | <el-table-column prop="acctTypeName" align="center" :label="$t('payFeeUserAccount.accountType')" /> | 23 | <el-table-column prop="acctTypeName" align="center" :label="$t('payFeeUserAccount.accountType')" /> |
| @@ -48,7 +52,7 @@ export default { | @@ -48,7 +52,7 @@ export default { | ||
| 48 | feeId: '', | 52 | feeId: '', |
| 49 | ownerId: '', | 53 | ownerId: '', |
| 50 | communityId: '', | 54 | communityId: '', |
| 51 | - selectedAccounts: [] // 改为数组,支持多选 | 55 | + selectedAccount: '' // 单选账户 |
| 52 | } | 56 | } |
| 53 | }, | 57 | }, |
| 54 | methods: { | 58 | methods: { |
| @@ -83,53 +87,26 @@ export default { | @@ -83,53 +87,26 @@ export default { | ||
| 83 | openAddUserAmountModal(userAccount) { | 87 | openAddUserAmountModal(userAccount) { |
| 84 | window.open(`/#/views/owner/ownerDetail?ownerId=${userAccount.objId}¤tTab=ownerDetailAccount`) | 88 | window.open(`/#/views/owner/ownerDetail?ownerId=${userAccount.objId}¤tTab=ownerDetailAccount`) |
| 85 | }, | 89 | }, |
| 86 | - // 新增:处理账户选择变化 | ||
| 87 | - handleAccountChange(acctId, checked) { | ||
| 88 | - console.log('选中的账户ID:', acctId, '是否选中:', checked) | ||
| 89 | - console.log('当前selectedAccounts:', this.selectedAccounts) | ||
| 90 | - | ||
| 91 | - // 确保 selectedAccounts 是数组 | ||
| 92 | - if (!Array.isArray(this.selectedAccounts)) { | ||
| 93 | - this.selectedAccounts = [] | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - if (checked) { | ||
| 97 | - // 添加到选中数组 | ||
| 98 | - if (!this.selectedAccounts.includes(acctId)) { | ||
| 99 | - this.selectedAccounts.push(acctId) | ||
| 100 | - } | 90 | + // 处理账户选择变化 |
| 91 | + handleAccountChange(account) { | ||
| 92 | + if (!account) { | ||
| 93 | + this.selectedAccount = '' | ||
| 101 | } else { | 94 | } else { |
| 102 | - // 从选中数组中移除 | ||
| 103 | - const index = this.selectedAccounts.indexOf(acctId) | ||
| 104 | - if (index > -1) { | ||
| 105 | - this.selectedAccounts.splice(index, 1) | ||
| 106 | - } | 95 | + this.selectedAccount = account.acctId |
| 107 | } | 96 | } |
| 108 | - | ||
| 109 | - console.log('更新后的selectedAccounts:', this.selectedAccounts) | ||
| 110 | this.computeFeeUserAmount() | 97 | this.computeFeeUserAmount() |
| 111 | }, | 98 | }, |
| 112 | - // 修复:computeFeeUserAmount 方法 | 99 | + // 计算费用使用金额 |
| 113 | computeFeeUserAmount() { | 100 | computeFeeUserAmount() { |
| 114 | - console.log('计算费用,选中的账户:', this.selectedAccounts) | ||
| 115 | - | ||
| 116 | let totalUserAmount = 0.0 | 101 | let totalUserAmount = 0.0 |
| 117 | let selectAccount = [] | 102 | let selectAccount = [] |
| 118 | 103 | ||
| 119 | - // 确保 selectedAccounts 是数组 | ||
| 120 | - if (!Array.isArray(this.selectedAccounts)) { | ||
| 121 | - this.selectedAccounts = [] | 104 | + const account = this.accountList.find(item => item.acctId === this.selectedAccount) |
| 105 | + if (account && Number(account.amount) !== 0) { | ||
| 106 | + totalUserAmount = parseFloat(account.amount) | ||
| 107 | + selectAccount = [account] | ||
| 122 | } | 108 | } |
| 123 | 109 | ||
| 124 | - this.accountList.forEach(item => { | ||
| 125 | - if (this.selectedAccounts.includes(item.acctId) && item.amount != 0) { | ||
| 126 | - totalUserAmount += parseFloat(item.amount) | ||
| 127 | - selectAccount.push(item) | ||
| 128 | - } | ||
| 129 | - }) | ||
| 130 | - | ||
| 131 | - console.log('计算的总金额:', totalUserAmount, '选中的账户列表:', selectAccount) | ||
| 132 | - | ||
| 133 | this.$emit('changeUserAmountPrice', { | 110 | this.$emit('changeUserAmountPrice', { |
| 134 | totalUserAmount, | 111 | totalUserAmount, |
| 135 | accountList: this.accountList, | 112 | accountList: this.accountList, |
| @@ -141,7 +118,7 @@ export default { | @@ -141,7 +118,7 @@ export default { | ||
| 141 | }, | 118 | }, |
| 142 | handleClose() { | 119 | handleClose() { |
| 143 | this.accountList = [] | 120 | this.accountList = [] |
| 144 | - this.selectedAccounts = [] // 清空选中的账户 | 121 | + this.selectedAccount = '' // 清空选中的账户 |
| 145 | this.feeId = '' | 122 | this.feeId = '' |
| 146 | this.ownerId = '' | 123 | this.ownerId = '' |
| 147 | } | 124 | } |