net-analysis.vue
9.27 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<template>
<div class="net-wrapper">
<div class="net-stats">
<div class="stat-card net-billing">
<div class="stat-icon-circle">
<i class="el-icon-wallet"></i>
</div>
<div class="stat-content">
<div class="stat-title">开单总额</div>
<div class="stat-value">¥{{ formatMoney(extra.actualAmount || 0) }}</div>
</div>
</div>
<div class="stat-card net-refund">
<div class="stat-icon-circle">
<i class="el-icon-warning-outline"></i>
</div>
<div class="stat-content">
<div class="stat-title">退卡总额</div>
<div class="stat-value">¥{{ formatMoney(extra.refundAmount || 0) }}</div>
</div>
</div>
<div class="stat-card net-amount">
<div class="stat-icon-circle">
<i class="el-icon-trophy"></i>
</div>
<div class="stat-content">
<div class="stat-title">完成业绩(净额)</div>
<div class="stat-value">¥{{ formatMoney((extra.actualAmount || 0) - (extra.refundAmount || 0)) }}</div>
</div>
</div>
</div>
<div class="net-tabs">
<el-radio-group v-model="innerType" size="small" @change="resetAndFetch">
<el-radio-button label="billing">开单明细</el-radio-button>
<el-radio-button label="refund">退卡明细</el-radio-button>
</el-radio-group>
</div>
<div class="net-table-card">
<el-table v-loading="loading" :data="displayList" size="small" height="300" border stripe>
<el-table-column v-for="col in columns" :key="col.prop" :prop="col.prop" :label="col.label"
:width="col.width" :min-width="col.minWidth">
<template slot-scope="scope">
<span v-if="col.type === 'money'">¥{{ formatMoney(scope.row[col.prop]) }}</span>
<span v-else>{{ scope.row[col.prop] || '—' }}</span>
</template>
</el-table-column>
</el-table>
<div class="pagination-bar">
<el-pagination layout="total, sizes, prev, pager, next" :page-sizes="[10, 20, 50]" :total="pagination.total"
:current-page="pagination.pageIndex" :page-size="pagination.pageSize" @size-change="handleSizeChange"
@current-change="handleCurrentChange" />
</div>
</div>
</div>
</template>
<script>
import request from '@/utils/request'
import dayjs from 'dayjs'
import { kpiDrillMixin } from './mixins'
export default {
name: 'NetAnalysis',
mixins: [kpiDrillMixin],
props: {
filters: {
type: Object,
default: () => ({ startTime: null, endTime: null, storeIds: [], month: null })
},
extra: { type: Object, default: () => ({}) },
storeOptions: { type: Array, default: () => [] }
},
data() {
return {
loading: false,
list: [],
displayList: [],
pagination: { pageIndex: 1, pageSize: 10, total: 0 },
innerType: 'billing'
}
},
computed: {
columns() {
const base = {
billing: [
{ prop: 'billingTime', label: '开单时间', minWidth: 120 },
{ prop: 'storeName', label: '门店', minWidth: 120 },
{ prop: 'memberName', label: '会员', minWidth: 120 },
{ prop: 'itemName', label: '品项', minWidth: 140 },
{ prop: 'itemType', label: '品项类型', minWidth: 120 },
{ prop: 'projectNumber', label: '项目数', width: 90 },
{ prop: 'actualPrice', label: '实付金额', width: 110, type: 'money' },
{ prop: 'sourceType', label: '来源类型', minWidth: 110 },
{ prop: 'performanceType', label: '业绩类型', minWidth: 110 },
{ prop: 'beautyType', label: '科美类型', minWidth: 110 }
],
refund: [
{ prop: 'tksj', label: '退卡时间', minWidth: 120 },
{ prop: 'mdmc', label: '门店', minWidth: 120 },
{ prop: 'hymc', label: '会员', minWidth: 120 },
{ prop: 'gklx', label: '顾客类型', minWidth: 100 },
{ prop: 'tkje', label: '退款金额', width: 110, type: 'money' },
{ prop: 'tkyy', label: '退款原因', minWidth: 140 }
]
}
return base[this.innerType] || base.billing
}
},
watch: {
filters: {
deep: true,
handler() {
this.resetAndFetch()
}
},
innerType() {
this.resetAndFetch()
}
},
mounted() {
this.fetchData()
},
methods: {
resetAndFetch() {
this.pagination = { ...this.pagination, pageIndex: 1 }
this.fetchData()
},
handleSizeChange(size) {
this.pagination.pageSize = size
this.pagination.pageIndex = 1
this.fetchData()
},
handleCurrentChange(page) {
this.pagination.pageIndex = page
this.fetchData()
},
async fetchData() {
this.loading = true
try {
const range = this.buildDateRange()
const storeId = this.getStoreId()
let url = ''
let data = { currentPage: this.pagination.pageIndex, pageSize: this.pagination.pageSize }
if (this.innerType === 'billing') {
url = '/api/Extend/LqKdKdjlb/billing-item-detail-list'
if (range) {
data.startTime = `${range.start} 00:00:00`
data.endTime = `${range.end} 23:59:59`
}
if (storeId) data.StoreId = storeId
} else if (this.innerType === 'refund') {
url = '/api/Extend/LqHytkHytk'
if (range) {
data.tksj = `${range.startTs},${range.endTs}`
}
if (storeId) data.md = storeId
}
const res = await request({ url, method: 'GET', data })
await this.handleResponse(res, this.innerType, range)
} catch (error) {
console.error('Net analysis load error:', error)
this.$message.error(error.message || '加载数据失败')
this.list = []
this.displayList = []
} finally {
this.loading = false
}
},
async handleResponse(res, activeType, range) {
let list = []
let pagination = this.pagination
if (res && res.data) {
if (res.data.list && res.data.pagination) {
list = res.data.list
pagination = {
pageIndex: res.data.pagination.pageIndex || res.data.pagination.pageNumber || 1,
pageSize: res.data.pagination.pageSize || this.pagination.pageSize,
total: res.data.pagination.total || res.data.pagination.totalCount || 0
}
} else if (Array.isArray(res.data.list)) {
list = res.data.list
} else if (Array.isArray(res.data)) {
list = res.data
}
}
if (activeType === 'billing') {
list = list.map(i => ({
billingTime: i.billingTime || i.yjsj || i.CreateTime ? dayjs(i.billingTime || i.yjsj || i.CreateTime).format('YYYY-MM-DD HH:mm') : '',
storeName: i.storeName || i.djmdmc || i.store,
memberName: i.memberName || i.kdhyc || i.MemberName,
itemName: i.itemName || i.ItemName,
itemType: i.itemType || i.ItemType,
projectNumber: i.projectNumber || i.ProjectNumber,
actualPrice: i.actualPrice || i.ActualPrice || 0,
sourceType: i.sourceType || i.SourceType || '',
performanceType: i.performanceType || i.PerformanceType || '',
beautyType: i.beautyType || i.BeautyType || ''
}))
} else if (activeType === 'refund') {
// res.data.list 已经是退卡主表字段,直接使用
}
this.list = list
this.displayList = list
this.pagination = pagination
}
}
}
</script>
<style lang="scss" scoped>
.net-wrapper {
width: 100%;
display: flex;
flex-direction: column;
gap: 16px;
.net-stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-bottom: 8px;
}
.stat-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 10px;
padding: 16px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
display: flex;
align-items: center;
gap: 16px;
.stat-icon-circle {
width: 48px;
height: 48px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
flex-shrink: 0;
font-size: 24px;
}
.stat-content {
flex: 1;
min-width: 0;
}
.stat-title {
font-size: 13px;
color: #606266;
margin-bottom: 8px;
}
.stat-value {
font-size: 20px;
font-weight: 700;
color: #303133;
}
&.net-billing {
border-left: 4px solid #409EFF;
.stat-icon-circle {
background: #409EFF;
}
}
&.net-refund {
border-left: 4px solid #F56C6C;
.stat-icon-circle {
background: #F56C6C;
}
}
&.net-amount {
border-left: 4px solid #67C23A;
.stat-icon-circle {
background: #67C23A;
}
}
}
.net-tabs {
display: flex;
justify-content: center;
padding: 8px 0;
}
.net-table-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 10px;
padding: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
display: flex;
flex-direction: column;
min-height: 450px;
.pagination-bar {
flex-shrink: 0;
margin-top: 12px;
}
}
}
.pagination-bar {
display: flex;
justify-content: flex-end;
padding: 10px 0 4px 0;
}
</style>