visit-frequency-member-list-dialog.vue
7.49 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
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
<template>
<el-dialog
:visible.sync="visibleSync"
:title="`到店${visitCount}次的会员列表`"
:width="'1200px'"
append-to-body
custom-class="visit-frequency-member-dialog"
:close-on-click-modal="false"
@closed="handleClosed"
>
<div v-loading="loading" class="member-list-wrapper">
<NCC-table
v-loading="loading"
:data="memberList"
:header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
>
<!-- 会员编码 -->
<el-table-column label="会员编码" width="150" align="center">
<template slot-scope="scope">
<div class="member-code-info">
<i class="el-icon-postcard member-code-icon"></i>
<span class="text-nowrap">{{ scope.row.MemberId || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 会员名称 -->
<el-table-column label="会员名称" min-width="120" align="center">
<template slot-scope="scope">
<div class="member-name-info">
<i class="el-icon-user-solid member-name-icon"></i>
<span class="text-nowrap">{{ scope.row.MemberName || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 手机号 -->
<el-table-column label="手机号" width="130" align="center">
<template slot-scope="scope">
<div class="phone-info">
<i class="el-icon-phone phone-icon"></i>
<span class="text-nowrap">{{ scope.row.Mobile || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 归属门店 -->
<el-table-column label="归属门店" min-width="150" align="center">
<template slot-scope="scope">
<div class="store-info">
<i class="el-icon-office-building store-icon"></i>
<span class="text-nowrap">{{ scope.row.StoreName || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 到店次数 -->
<el-table-column label="到店次数" width="100" align="center">
<template slot-scope="scope">
<el-tag type="info" size="small">{{ scope.row.VisitCount || 0 }}次</el-tag>
</template>
</el-table-column>
<!-- 首次到店时间 -->
<el-table-column label="首次到店时间" width="160" align="center">
<template slot-scope="scope">
<div class="time-info">
<i class="el-icon-time time-icon"></i>
<span class="text-nowrap">{{ formatDateTime(scope.row.FirstVisitTime) || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 最后到店时间 -->
<el-table-column label="最后到店时间" width="160" align="center">
<template slot-scope="scope">
<div class="time-info">
<i class="el-icon-time time-icon"></i>
<span class="text-nowrap">{{ formatDateTime(scope.row.LastVisitTime) || '无' }}</span>
</div>
</template>
</el-table-column>
</NCC-table>
<!-- 分页 -->
<div class="pagination-wrapper" v-if="pagination.total > 0">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pagination.pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pagination.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.total"
></el-pagination>
</div>
</div>
</el-dialog>
</template>
<script>
import request from '@/utils/request'
import dayjs from 'dayjs'
export default {
name: 'VisitFrequencyMemberListDialog',
props: {
visible: { type: Boolean, default: false },
visitCount: { type: Number, default: 0 },
startTime: { type: [Date, String], default: null },
endTime: { type: [Date, String], default: null },
storeIds: { type: Array, default: () => [] }
},
data() {
return {
visibleSync: false,
loading: false,
memberList: [],
pagination: {
pageIndex: 1,
pageSize: 20,
total: 0
}
}
},
watch: {
visible: {
immediate: true,
handler(v) {
this.visibleSync = v
if (v && this.visitCount > 0) {
this.pagination.pageIndex = 1
this.fetchData()
}
}
},
visitCount: {
handler() {
if (this.visibleSync && this.visitCount > 0) {
this.pagination.pageIndex = 1
this.fetchData()
}
}
}
},
methods: {
async fetchData() {
if (!this.visitCount || this.visitCount <= 0) {
this.$message.warning('到店次数不能为空')
return
}
this.loading = true
try {
const res = await request({
url: '/api/Extend/LqReport/get-visit-frequency-member-list',
method: 'POST',
data: {
visitCount: this.visitCount,
startTime: this.startTime ? dayjs(this.startTime).toDate() : null,
endTime: this.endTime ? dayjs(this.endTime).toDate() : null,
storeIds: this.storeIds || [],
pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize
}
})
if (res.code === 200 && res.data) {
this.memberList = res.data.List || []
this.pagination.total = res.data.Total || 0
} else {
this.$message.error(res.msg || '获取会员列表失败')
}
} catch (error) {
console.error('获取会员列表失败:', error)
this.$message.error('获取会员列表失败: ' + (error.message || '未知错误'))
} finally {
this.loading = false
}
},
handleSizeChange(val) {
this.pagination.pageSize = val
this.pagination.pageIndex = 1
this.fetchData()
},
handleCurrentChange(val) {
this.pagination.pageIndex = val
this.fetchData()
},
handleClosed() {
this.memberList = []
this.pagination = {
pageIndex: 1,
pageSize: 20,
total: 0
}
this.$emit('update:visible', false)
},
formatDateTime(dateTime) {
if (!dateTime) return ''
return dayjs(dateTime).format('YYYY-MM-DD HH:mm:ss')
}
}
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog {
border-radius: 14px;
}
.visit-frequency-member-dialog {
.el-dialog {
border-radius: 12px;
overflow: hidden;
}
.el-dialog__header {
padding: 20px 24px;
border-bottom: 1px solid #e4e7ed;
background: #409EFF;
color: #fff;
.el-dialog__title {
color: #fff;
font-size: 18px;
font-weight: 600;
}
.el-dialog__close {
color: #fff;
font-size: 20px;
&:hover {
color: rgba(255, 255, 255, 0.8);
}
}
}
.el-dialog__body {
padding: 24px;
background: #f5f7fa;
}
}
.member-list-wrapper {
background: #fff;
border-radius: 8px;
padding: 20px;
min-height: 400px;
.member-code-info,
.member-name-info,
.phone-info,
.store-info,
.time-info {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
i {
color: #409EFF;
font-size: 16px;
}
.text-nowrap {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.pagination-wrapper {
margin-top: 20px;
display: flex;
justify-content: flex-end;
}
}
</style>