payFeeUserAccount.vue
4.02 KB
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
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
<template>
<div>
<el-card v-if="accountList.length > 0" class="margin-bottom-sm">
<div slot="header" class="flex justify-between">
<span>{{ $t('payFeeUserAccount.accountInfo') }}</span>
<el-button type="primary" size="small" style="float: right;" @click="queryPayFeeUserAccount">
<i class="el-icon-refresh"></i>
{{ $t('payFeeUserAccount.refresh') }}
</el-button>
</div>
<el-table :data="accountList" border style="width: 100%">
<el-table-column align="center" :label="$t('payFeeUserAccount.select')" width="120">
<template slot-scope="scope">
<el-radio
v-model="selectedAccount"
:label="scope.row.acctId"
@change="() => handleAccountChange(scope.row)"
>
</el-radio>
</template>
</el-table-column>
<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')">
<template slot-scope="scope">
{{ scope.row.amount }} {{ $t('payFeeUserAccount.yuan') }}
</template>
</el-table-column>
<el-table-column align="center" :label="$t('payFeeUserAccount.operation')" width="150">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="openAddUserAmountModal(scope.row)">
<i class="el-icon-plus"></i>
{{ $t('payFeeUserAccount.prestore') }}
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</div>
</template>
<script>
import { getCommunityId } from '@/api/community/communityApi'
import { queryCommunityOwnerAccount } from '@/api/fee/payFeeOrderApi'
export default {
name: 'PayFeeUserAccount',
data() {
return {
accountList: [],
feeId: '',
ownerId: '',
communityId: '',
selectedAccount: '' // 单选账户
}
},
methods: {
open(params) {
this.feeId = params.feeId
this.ownerId = params.ownerId || ''
this.listUserAccount()
},
close() {
this.dialogVisible = false
},
async listUserAccount() {
try {
this.communityId = await getCommunityId()
const params = {
page: 1,
row: 20,
feeId: this.feeId,
ownerId: this.ownerId,
communityId: this.communityId
}
const response = await queryCommunityOwnerAccount(params)
this.accountList = response.data || []
} catch (error) {
console.error('查询用户账户失败:', error)
}
},
queryPayFeeUserAccount() {
this.listUserAccount()
},
openAddUserAmountModal(userAccount) {
window.open(`/#/views/owner/ownerDetail?ownerId=${userAccount.objId}¤tTab=ownerDetailAccount`)
},
// 处理账户选择变化
handleAccountChange(account) {
if (!account) {
this.selectedAccount = ''
} else {
this.selectedAccount = account.acctId
}
this.computeFeeUserAmount()
},
// 计算费用使用金额
computeFeeUserAmount() {
let totalUserAmount = 0.0
let selectAccount = []
const account = this.accountList.find(item => item.acctId === this.selectedAccount)
if (account && Number(account.amount) !== 0) {
totalUserAmount = parseFloat(account.amount)
selectAccount = [account]
}
this.$emit('changeUserAmountPrice', {
totalUserAmount,
accountList: this.accountList,
integralAmount: 0,
cashAmount: totalUserAmount,
couponAmount: 0,
selectAccount
})
},
handleClose() {
this.accountList = []
this.selectedAccount = '' // 清空选中的账户
this.feeId = ''
this.ownerId = ''
}
}
}
</script>
<style scoped>
.el-table {
margin-top: 20px;
}
</style>