index.vue
21.6 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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
<template>
<div class="app-container">
<!-- 页面头部 -->
<div class="page-header">
<div class="header-left">
<h2>总经理门店生命线设置</h2>
<p class="page-desc">管理总经理对各门店的生命线设置,支持3个生命线级别配置</p>
</div>
<div class="header-right">
<el-button
type="primary"
icon="el-icon-plus"
@click="showBatchCreateDialog"
>
一键创建
</el-button>
<el-button
type="primary"
icon="el-icon-refresh-left"
@click="showSyncDialog"
>
同步上月数据
</el-button>
<el-button
type="primary"
icon="el-icon-plus"
@click="handleAdd"
:loading="loading"
>
新增
</el-button>
<el-button
icon="el-icon-refresh"
@click="getList"
:loading="loading"
>
刷新
</el-button>
</div>
</div>
<!-- 搜索区域 -->
<div class="search-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="80px">
<el-form-item label="总经理" prop="generalManagerId">
<el-select
v-model="queryParams.generalManagerId"
placeholder="请选择总经理"
clearable
filterable
style="width: 200px"
>
<el-option
v-for="user in userList"
:key="user.id"
:label="`${user.realName} (${user.gw || '无岗位'})`"
:value="user.id"
>
<span style="float: left">{{ user.realName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ user.gw || '无岗位' }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="门店" prop="storeId">
<el-select
v-model="queryParams.storeId"
placeholder="请选择门店"
clearable
filterable
style="width: 200px"
>
<el-option
v-for="store in storeList"
:key="store.id"
:label="store.dm"
:value="store.id"
/>
</el-select>
</el-form-item>
<el-form-item label="月份" prop="month">
<el-date-picker
v-model="queryParams.month"
type="month"
placeholder="选择月份"
format="yyyyMM"
value-format="yyyyMM"
style="width: 200px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 数据表格 -->
<div class="table-container">
<NCC-table
v-loading="loading"
:data="list"
border
stripe
height="calc(100vh - 500px)"
:header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
>
<!-- 总经理 -->
<el-table-column label="总经理" width="140" align="center">
<template slot-scope="scope">
<div class="user-info">
<i class="el-icon-user-solid user-icon"></i>
<span>{{ getGeneralManagerName(scope.row.generalManagerId) || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 总经理类型 -->
<el-table-column label="总经理类型" width="140" align="center">
<template slot-scope="scope">
<div class="manager-type-item">
<i class="el-icon-user-solid manager-type-icon"></i>
<span>{{ scope.row.managerTypeName || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 门店名称 -->
<el-table-column label="门店名称" width="160" align="center">
<template slot-scope="scope">
<div class="store-name">
<i class="el-icon-shop store-icon"></i>
<span>{{ getStoreName(scope.row.storeId) || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 月份 -->
<el-table-column label="月份" width="120" align="center">
<template slot-scope="scope">
<div class="month-item">
<i class="el-icon-date month-icon"></i>
<span>{{ formatMonth(scope.row.month) || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 生命线1 -->
<el-table-column label="生命线1" align="center" width="140">
<template slot-scope="scope">
<div class="life-line-item">
<i class="el-icon-money life-line-icon"></i>
<span v-if="scope.row.lifeline1" class="amount">{{ formatMoney(scope.row.lifeline1) }}元</span>
<span v-else class="no-data">无</span>
</div>
</template>
</el-table-column>
<!-- 提成比例1 -->
<el-table-column label="提成比例1" align="center" width="120">
<template slot-scope="scope">
<div class="ratio-item">
<i class="el-icon-percent ratio-icon"></i>
<span v-if="scope.row.commissionRate1 !== null && scope.row.commissionRate1 !== undefined" class="ratio">{{ scope.row.commissionRate1 }}%</span>
<span v-else class="no-data">无</span>
</div>
</template>
</el-table-column>
<!-- 生命线2 -->
<el-table-column label="生命线2" align="center" width="140">
<template slot-scope="scope">
<div class="life-line-item">
<i class="el-icon-money life-line-icon"></i>
<span v-if="scope.row.lifeline2" class="amount">{{ formatMoney(scope.row.lifeline2) }}元</span>
<span v-else class="no-data">无</span>
</div>
</template>
</el-table-column>
<!-- 提成比例2 -->
<el-table-column label="提成比例2" align="center" width="120">
<template slot-scope="scope">
<div class="ratio-item">
<i class="el-icon-percent ratio-icon"></i>
<span v-if="scope.row.commissionRate2 !== null && scope.row.commissionRate2 !== undefined" class="ratio">{{ scope.row.commissionRate2 }}%</span>
<span v-else class="no-data">无</span>
</div>
</template>
</el-table-column>
<!-- 生命线3 -->
<el-table-column label="生命线3" align="center" width="140">
<template slot-scope="scope">
<div class="life-line-item">
<i class="el-icon-money life-line-icon"></i>
<span v-if="scope.row.lifeline3" class="amount">{{ formatMoney(scope.row.lifeline3) }}元</span>
<span v-else class="no-data">无</span>
</div>
</template>
</el-table-column>
<!-- 提成比例3 -->
<el-table-column label="提成比例3" align="center" width="120">
<template slot-scope="scope">
<div class="ratio-item">
<i class="el-icon-percent ratio-icon"></i>
<span v-if="scope.row.commissionRate3 !== null && scope.row.commissionRate3 !== undefined" class="ratio">{{ scope.row.commissionRate3 }}%</span>
<span v-else class="no-data">无</span>
</div>
</template>
</el-table-column>
<!-- 备注 -->
<el-table-column label="备注" min-width="160" show-overflow-tooltip>
<template slot-scope="scope">
<div class="remark-item">
<i class="el-icon-document remark-icon"></i>
<span>{{ scope.row.remark || '无' }}</span>
</div>
</template>
</el-table-column>
<!-- 操作 -->
<el-table-column label="操作" width="180" align="left" fixed="right">
<template slot-scope="scope">
<div class="action-buttons">
<el-button
type="text"
icon="el-icon-edit"
@click="handleEdit(scope.row)"
size="small"
class="edit-btn"
>
编辑
</el-button>
<el-button
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
size="small"
class="delete-btn"
>
删除
</el-button>
</div>
</template>
</el-table-column>
</NCC-table>
</div>
<!-- 分页 -->
<div class="pagination-container">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="queryParams.pageNum"
:page-sizes="[10, 20, 50, 100]"
:page-size="queryParams.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
/>
</div>
<!-- 月份选择弹窗 -->
<el-dialog
:title="batchDialogTitle"
:visible="batchDialogVisible"
width="500px"
:close-on-click-modal="false"
@close="handleBatchDialogClose"
>
<el-form label-width="100px" label-position="right">
<el-form-item label="选择月份" required>
<el-date-picker
v-model="batchOperationMonth"
type="month"
placeholder="请选择月份"
format="yyyyMM"
value-format="yyyyMM"
style="width: 100%"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleBatchDialogClose">取消</el-button>
<el-button
type="primary"
@click="handleBatchDialogConfirm"
:loading="batchCreateLoading || syncLoading"
>
确定
</el-button>
</div>
</el-dialog>
<!-- 编辑弹窗 -->
<edit-dialog
:visible="editVisible"
:form-data="currentRow"
:user-list="userList"
:store-list="storeList"
@close="editVisible = false"
@success="handleEditSuccess"
/>
</div>
</template>
<script>
import { lqYcsdMdmbsdApi } from '@/api/extend/lqYcsdMdmbsd'
import request from '@/utils/request'
import EditDialog from './components/edit-dialog.vue'
export default {
name: 'LqYcsdMdmbsd',
components: {
EditDialog
},
data() {
// 获取当前月份,格式为 yyyyMM
const getCurrentMonth = () => {
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
return `${year}${month}`
}
return {
loading: false,
batchCreateLoading: false,
syncLoading: false,
list: [],
total: 0,
userList: [],
storeList: [],
batchOperationMonth: getCurrentMonth(), // 批量操作使用的独立月份选择器
batchDialogVisible: false, // 批量操作弹窗显示状态
batchDialogTitle: '', // 批量操作弹窗标题
batchOperationType: '', // 批量操作类型:'create' 或 'sync'
queryParams: {
pageNum: 1,
pageSize: 20,
generalManagerId: '',
storeId: '',
month: getCurrentMonth()
},
editVisible: false,
currentRow: null
}
},
created() {
this.getUserList()
this.getStoreList()
this.getList()
},
methods: {
// 获取当前月份,格式为 yyyyMM
getCurrentMonth() {
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
return `${year}${month}`
},
// 获取总经理用户列表
async getUserList() {
try {
const response = await lqYcsdMdmbsdApi.getGeneralManagerList()
this.userList = response.data || []
console.log('获取总经理用户列表成功:', this.userList)
} catch (error) {
console.error('获取总经理用户列表失败:', error)
this.userList = []
}
},
// 获取门店列表
async getStoreList() {
try {
const response = await lqYcsdMdmbsdApi.getStoreList()
this.storeList = response.data.list || []
console.log('门店列表:', this.storeList)
} catch (error) {
console.error('获取门店列表失败:', error)
this.storeList = []
}
},
// 获取列表数据
async getList() {
this.loading = true
try {
const params = {
currentPage: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
generalManagerId: this.queryParams.generalManagerId || '',
storeId: this.queryParams.storeId || '',
month: this.queryParams.month || ''
}
const response = await lqYcsdMdmbsdApi.getPageList(params)
this.list = response.data.list || []
this.total = (response.data.pagination && response.data.pagination.total) || 0
} catch (error) {
console.error('获取列表失败:', error)
this.$message.error('获取列表失败')
} finally {
this.loading = false
}
},
// 搜索
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
// 重置搜索
resetQuery() {
this.queryParams = {
pageNum: 1,
pageSize: 20,
generalManagerId: '',
storeId: '',
month: this.getCurrentMonth()
}
this.list = []
this.total = 0
this.getList()
},
// 显示一键创建弹窗
showBatchCreateDialog() {
this.batchOperationMonth = this.getCurrentMonth()
this.batchDialogTitle = '一键创建'
this.batchOperationType = 'create'
this.batchDialogVisible = true
},
// 显示同步上月数据弹窗
showSyncDialog() {
this.batchOperationMonth = this.getCurrentMonth()
this.batchDialogTitle = '同步上月数据'
this.batchOperationType = 'sync'
this.batchDialogVisible = true
},
// 关闭批量操作弹窗
handleBatchDialogClose() {
this.batchDialogVisible = false
this.batchOperationType = ''
},
// 确认批量操作
async handleBatchDialogConfirm() {
if (!this.batchOperationMonth) {
this.$message.warning('请先选择月份')
return
}
if (this.batchOperationType === 'create') {
await this.handleBatchCreate()
} else if (this.batchOperationType === 'sync') {
await this.handleSyncLastMonthData()
}
},
// 一键创建
async handleBatchCreate() {
this.$confirm(`确定要为 ${this.formatMonth(this.batchOperationMonth)} 月份一键创建所有总经理门店生命线设置吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.batchCreateLoading = true
try {
const result = await lqYcsdMdmbsdApi.batchCreateFromTarget(this.batchOperationMonth)
this.$message.success((result.data && result.data.message) || '同步上月数据成功')
this.batchDialogVisible = false
this.getList()
} catch (error) {
console.error('一键创建失败:', error)
this.$message.error(error.message || '一键创建失败')
} finally {
this.batchCreateLoading = false
}
}).catch(() => {
// 用户取消操作
})
},
// 同步上月数据
async handleSyncLastMonthData() {
this.$confirm(`确定要将上月数据同步到 ${this.formatMonth(this.batchOperationMonth)} 月份吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.syncLoading = true
try {
const result = await lqYcsdMdmbsdApi.copyLastMonthData(this.batchOperationMonth)
this.$message.success((result.data && result.data.message) || '同步上月数据成功')
this.batchDialogVisible = false
this.getList()
} catch (error) {
console.error('同步上月数据失败:', error)
this.$message.error(error.message || '同步上月数据失败')
} finally {
this.syncLoading = false
}
}).catch(() => {
// 用户取消操作
})
},
// 新增
handleAdd() {
console.log('点击新增按钮')
this.currentRow = null
this.editVisible = true
console.log('editVisible:', this.editVisible)
},
// 编辑
handleEdit(row) {
console.log('编辑行数据:', row)
this.currentRow = { ...row }
this.editVisible = true
},
// 删除
handleDelete(row) {
this.$confirm('确定要删除这条生命线设置吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
try {
const id = row.id || row.Id
await lqYcsdMdmbsdApi.delete(id)
this.$message.success('删除成功')
this.getList()
} catch (error) {
console.error('删除失败:', error)
this.$message.error(error.message || '删除失败')
}
}).catch(() => {
this.$message.info('已取消删除')
})
},
// 编辑成功
handleEditSuccess() {
this.editVisible = false
this.getList()
this.$message.success('操作成功')
},
// 分页大小改变
handleSizeChange(val) {
this.queryParams.pageSize = val
this.getList()
},
// 当前页改变
handleCurrentChange(val) {
this.queryParams.pageNum = val
this.getList()
},
// 获取总经理名称
getGeneralManagerName(id) {
if (!id) return ''
const user = this.userList.find(u => u.id === id)
return user ? user.realName : ''
},
// 获取门店名称
getStoreName(id) {
if (!id) return ''
const store = this.storeList.find(s => s.id === id)
return store ? store.dm : ''
},
// 格式化金额
formatMoney(amount) {
if (!amount) return '0.00'
return Number(amount).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
})
},
// 格式化月份
formatMonth(month) {
if (!month) return ''
if (month.length === 6) {
return `${month.substring(0, 4)}-${month.substring(4, 6)}`
}
return month
}
}
}
</script>
<style lang="scss" scoped>
.app-container {
padding: 20px;
background: #f5f5f5;
// min-height: calc(100vh - 84px);
}
.page-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 20px;
padding: 20px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
.header-left {
h2 {
margin: 0 0 8px 0;
color: #303133;
font-size: 20px;
font-weight: 600;
}
.page-desc {
margin: 0;
color: #909399;
font-size: 14px;
}
}
.header-right {
display: flex;
gap: 12px;
}
}
.search-container {
padding: 20px;
background: #fff;
border-radius: 8px;
margin-bottom: 20px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.table-container {
background: #fff;
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
}
// 用户信息样式
.user-info {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
.user-icon {
color: #409EFF;
font-size: 16px;
}
span {
font-weight: 500;
color: #303133;
}
}
// 门店信息样式
.store-name {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
.store-icon {
color: #67C23A;
font-size: 16px;
}
span {
font-weight: 500;
color: #303133;
}
}
// 月份样式
.month-item {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
.month-icon {
color: #909399;
font-size: 16px;
}
span {
color: #606266;
}
}
// 生命线项目样式
.life-line-item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 6px;
min-height: 40px;
.life-line-icon {
color: #409EFF;
font-size: 16px;
}
.amount {
font-weight: 600;
color: #409EFF;
font-size: 14px;
}
}
// 提成比例样式
.ratio-item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 6px;
min-height: 40px;
.ratio-icon {
color: #67C23A;
font-size: 16px;
}
.ratio {
color: #67C23A;
font-size: 12px;
background: #f0f9ff;
padding: 2px 6px;
border-radius: 4px;
font-weight: 500;
}
}
// 备注样式
.remark-item {
display: flex;
align-items: center;
gap: 6px;
.remark-icon {
color: #909399;
font-size: 14px;
}
span {
color: #606266;
}
}
// 操作按钮样式
.action-buttons {
display: flex;
align-items: center;
gap: 8px;
.edit-btn {
color: #409EFF;
&:hover {
color: #66b1ff;
}
}
.delete-btn {
color: #F56C6C;
&:hover {
color: #f78989;
}
}
}
.no-data {
color: #C0C4CC;
font-size: 12px;
font-style: italic;
}
.pagination-container {
display: flex;
justify-content: center;
padding: 20px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
</style>