form2.vue
10.3 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
319
320
321
322
323
324
325
326
327
328
329
330
331
<template>
<div class="NCC-common-layout">
<div class="NCC-common-layout-center">
<!-- 筛选条件 -->
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="门店" required>
<el-select v-model="query.storeId" placeholder="请选择门店" clearable filterable>
<el-option v-for="store in storeOptions" :key="store.id" :label="store.dm" :value="store.id" />
</el-select>
</el-form-item>
</el-col>
<!-- <el-col :span="6">
<el-form-item label="会员号">
<el-input v-model="query.memberNo" placeholder="请输入会员号" clearable @keyup.enter.native="search()" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="会员姓名">
<el-input v-model="query.memberName" placeholder="请输入会员姓名" clearable @keyup.enter.native="search()" />
</el-form-item>
</el-col> -->
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<!-- 数据表格 -->
<div class="NCC-common-layout-main NCC-flex-main">
<NCC-table v-loading="listLoading" :data="list" has-c>
<!-- <el-table-column prop="kdhy" label="会员号" width="140" /> -->
<el-table-column prop="kdhyc" label="会员姓名" />
<el-table-column prop="kdhysjh" label="手机号" width="140"/>
<el-table-column prop="jsj" label="金三角" width="140"/>
<el-table-column prop="gjlx" label="顾客类型" >
<template slot-scope="scope">
<el-tag :type="scope.row.gjlx === '会员' ? 'success' : 'info'" size="small">
{{ scope.row.gjlx || '无' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="kdrq" label="开单日期" width="160">
<template slot-scope="scope">
{{ formatTime(scope.row.kdrq) }}
</template>
</el-table-column>
<el-table-column prop="zdyj" label="指定业绩" >
<template slot-scope="scope">
<span class="amount-value">¥{{ formatMoney(scope.row.zdyj) }}</span>
</template>
</el-table-column>
<el-table-column prop="sfyj" label="实付业绩" >
<template slot-scope="scope">
<span class="amount-paid">¥{{ formatMoney(scope.row.sfyj) }}</span>
</template>
</el-table-column>
<el-table-column prop="qk" label="欠款" >
<template slot-scope="scope">
<span class="amount-debt">¥{{ formatMoney(scope.row.qk) }}</span>
</template>
</el-table-column>
<el-table-column prop="paidDebt" label="已付欠款" >
<template slot-scope="scope">
<span class="amount-paid">¥{{ formatMoney(scope.row.paidDebt) }}</span>
</template>
</el-table-column>
<el-table-column prop="deductAmount" label="扣款金额" >
<template slot-scope="scope">
<span class="amount-value">¥{{ formatMoney(scope.row.deductAmount) }}</span>
</template>
</el-table-column>
<el-table-column prop="fkfs" label="付款方式" >
<template slot-scope="scope">
{{ scope.row.fkfs || '无' }}
</template>
</el-table-column>
<el-table-column prop="ckfs" label="充值方式" >
<template slot-scope="scope">
{{ scope.row.ckfs || '无' }}
</template>
</el-table-column>
<el-table-column prop="tjr" label="推荐人" >
<template slot-scope="scope">
{{ scope.row.tjr || '无' }}
</template>
</el-table-column>
<el-table-column prop="khly" label="客户来源" >
<template slot-scope="scope">
{{ scope.row.khly || '无' }}
</template>
</el-table-column>
<el-table-column prop="sfskdd" label="是否收款单" >
<template slot-scope="scope">
{{ scope.row.sfskdd || '无' }}
</template>
</el-table-column>
<el-table-column prop="activityName" label="活动名称" >
<template slot-scope="scope">
{{ scope.row.activityName || '无' }}
</template>
</el-table-column>
<el-table-column prop="jj" label="简介" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.jj || '无' }}
</template>
</el-table-column>
<el-table-column prop="bz" label="备注" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.bz || '无' }}
</template>
</el-table-column>
<el-table-column prop="createUserName" label="创建人" >
<template slot-scope="scope">
{{ scope.row.createUserName || '无' }}
</template>
</el-table-column>
<el-table-column label="操作" width="120" fixed="right">
<template slot-scope="scope">
<el-button
type="danger"
size="small"
icon="el-icon-delete"
:disabled="!scope.row.qk || scope.row.qk <= 0"
@click="handleClearDebt(scope.row)"
>
清空欠款
</el-button>
</template>
</el-table-column>
</NCC-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="query.currentPage"
:limit.sync="query.pageSize" @pagination="getList" />
</div>
</div>
</div>
</template>
<script>
import request from '@/utils/request'
import Pagination from '@/components/Pagination'
export default {
name: 'DebtRecord',
components: {
Pagination
},
data() {
return {
query: {
storeId: undefined,
memberNo: '',
memberName: '',
currentPage: 1,
pageSize: 20
},
storeOptions: [],
list: [],
total: 0,
listLoading: false
}
},
created() {
this.initStoreOptions()
},
methods: {
// 初始化门店选项
initStoreOptions() {
request({
url: '/api/Extend/LqMdxx',
method: 'GET',
data: {
currentPage: 1,
pageSize: 1000
}
}).then(res => {
this.storeOptions = res.data.list || []
}).catch(err => {
console.error('获取门店列表失败:', err)
})
},
// 获取欠款记录列表
getList() {
if (!this.query.storeId) {
this.$message({
type: 'warning',
message: '请选择门店',
duration: 1500
})
return
}
this.listLoading = true
const params = {
StoreId: this.query.storeId,
currentPage: this.query.currentPage,
pageSize: this.query.pageSize
}
request({
url: '/api/Extend/lqkdkdjlb/GetDebtRecordByStoreId',
method: 'GET',
data: params
}).then(res => {
if (res.data && res.data.list) {
let data = res.data.list
this.list = data
this.total = (res.data.pagination && res.data.pagination.total) || 0
} else {
this.list = []
this.total = 0
}
this.listLoading = false
}).catch(err => {
console.error('查询失败:', err)
this.$message({
type: 'error',
message: '查询失败,请重试',
duration: 1500
})
this.listLoading = false
})
},
// 查询
search() {
this.query.currentPage = 1
this.getList()
},
// 重置查询条件
reset() {
this.query = {
storeId: undefined,
memberNo: '',
memberName: '',
currentPage: 1,
pageSize: 20
}
this.list = []
this.total = 0
},
// 格式化金额
formatMoney(amount) {
if (!amount && amount !== 0) return '0.00'
return Number(amount).toFixed(2)
},
// 格式化时间
formatTime(timestamp) {
if (!timestamp) return '无'
const date = new Date(timestamp)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
},
// 清空欠款
handleClearDebt(row) {
if (!row.id) {
this.$message({
type: 'error',
message: '数据异常,无法清空欠款',
duration: 1500
})
return
}
this.$confirm(`确定要清空会员"${row.kdhyc || '无'}"的欠款吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
request({
url: `/api/Extend/lqkdkdjlb/clear-debt/${row.id}`,
method: 'POST'
}).then(res => {
this.$message({
type: 'success',
message: '清空欠款成功',
duration: 1500
})
// 刷新列表
this.getList()
}).catch(err => {
console.error('清空欠款失败:', err)
this.$message({
type: 'error',
message: err.msg || '清空欠款失败,请重试',
duration: 1500
})
})
}).catch(() => {
// 用户取消操作
})
}
}
}
</script>
<style lang="scss" scoped>
.amount-value {
color: #409EFF;
font-weight: 500;
}
.amount-paid {
color: #67C23A;
font-weight: 500;
}
.amount-debt {
color: #F56C6C;
font-weight: 500;
}
</style>