member-rights-dialog.vue
5.54 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
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
187
188
189
190
191
192
<template>
<el-dialog title="会员权益" :visible.sync="visible" :close-on-click-modal="false" width="1200px">
<div v-loading="loading">
<div class="member-info" v-if="memberData.MemberId">
<el-descriptions :column="2" border>
<el-descriptions-item label="会员ID">
<i class="el-icon-postcard"></i>
{{ memberData.MemberId }}
</el-descriptions-item>
<el-descriptions-item label="会员姓名">
<i class="el-icon-user"></i>
{{ memberData.MemberName }}
</el-descriptions-item>
</el-descriptions>
</div>
<div class="rights-table">
<el-table
:data="memberData.RemainingItems"
border
style="margin-top: 20px;"
v-loading="loading"
empty-text="暂无权益信息">
<el-table-column prop="ItemName" label="项目名称" align="center" min-width="120">
<template slot-scope="scope">
<i class="el-icon-goods"></i>
{{ scope.row.ItemName || '无' }}
</template>
</el-table-column>
<el-table-column prop="ItemPrice" label="单价" align="center" min-width="100">
<template slot-scope="scope">
<span style="color: #409EFF;">{{ formatMoney(scope.row.ItemPrice) }}</span>
</template>
</el-table-column>
<el-table-column prop="SourceType" label="来源类型" align="center" min-width="100">
<template slot-scope="scope">
<el-tag :type="scope.row.SourceType === '购买' ? 'success' : 'info'" size="small">
{{ scope.row.SourceType }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="TotalPurchased" label="总购买" align="center" min-width="100">
<template slot-scope="scope">
<span>{{ formatNumber(scope.row.TotalPurchased) }}</span>
</template>
</el-table-column>
<el-table-column prop="ConsumedCount" label="已消费" align="center" min-width="100">
<template slot-scope="scope">
<span style="color: #67C23A;">{{ formatNumber(scope.row.ConsumedCount) }}</span>
</template>
</el-table-column>
<el-table-column prop="RefundedCount" label="已退款" align="center" min-width="100">
<template slot-scope="scope">
<span style="color: #E6A23C;">{{ formatNumber(scope.row.RefundedCount) }}</span>
</template>
</el-table-column>
<el-table-column prop="DeductCount" label="已扣除" align="center" min-width="100">
<template slot-scope="scope">
<span style="color: #909399;">{{ formatNumber(scope.row.DeductCount) }}</span>
</template>
</el-table-column>
<el-table-column prop="RemainingCount" label="剩余" align="center" min-width="100">
<template slot-scope="scope">
<el-tag type="primary" size="small">{{ formatNumber(scope.row.RemainingCount) }}</el-tag>
</template>
</el-table-column>
</el-table>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="visible = false">关闭</el-button>
</div>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
export default {
name: 'MemberRightsDialog',
data() {
return {
visible: false,
loading: false,
memberData: {
MemberId: '',
MemberName: '',
RemainingItems: []
}
}
},
methods: {
init(memberId) {
this.visible = true
this.loading = true
this.memberData = {
MemberId: '',
MemberName: '',
RemainingItems: []
}
request({
url: `/api/Extend/lqkhxx/GetMemberRemainingItems`,
method: 'GET',
data: { memberId }
}).then(res => {
if (res.code === 200 && res.data) {
this.memberData = res.data
} else {
this.$message.error(res.msg || '获取会员权益失败')
this.memberData = { MemberId: '', MemberName: '', RemainingItems: [] }
}
this.loading = false
}).catch(err => {
console.error('获取会员权益失败:', err)
this.$message.error('获取会员权益失败')
this.loading = false
})
},
formatMoney(amount) {
if (!amount && amount !== 0) return '¥0.00'
const num = parseFloat(amount)
if (isNaN(num)) return '¥0.00'
return '¥' + num.toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
})
},
formatNumber(num) {
if (!num && num !== 0) return '0'
const number = parseFloat(num)
if (isNaN(number)) return '0'
return number.toString()
}
}
}
</script>
<style lang="scss" scoped>
.member-info {
margin-bottom: 20px;
i {
margin-right: 6px;
color: #409EFF;
font-size: 16px;
}
}
::v-deep .el-descriptions {
.el-descriptions__label {
font-weight: 600;
color: #606266;
}
.el-descriptions__content {
color: #303133;
}
}
.dialog-footer {
text-align: right;
}
.rights-table {
::v-deep .el-table {
font-size: 14px;
th {
background-color: #f5f7fa;
color: #606266;
font-weight: 600;
}
td {
i {
margin-right: 4px;
color: #409EFF;
}
}
}
::v-deep .el-tag {
font-weight: 600;
}
}
::v-deep .el-dialog__body {
padding: 20px;
}
</style>