97151af6
李宇
feat(lqInventory)...
|
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
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
|
queryParams: {
currentPage: 1,
pageSize: 300, // 写死为300
year: getCurrentYear(),
month: getCurrentMonth(), // yyyyMM 格式
storeId: ''
}
}
},
created() {
this.getStoreList()
this.getList()
},
methods: {
// 获取门店列表
async getStoreList() {
try {
const response = await getStoreSelector()
this.storeList = response.data.list || []
} catch (error) {
console.error('获取门店列表失败:', error)
this.storeList = []
}
},
// 获取列表数据
async getList() {
this.loading = true
try {
// 处理年月:从month选择器中提取年份和月份
let year = ''
let month = ''
if (this.queryParams.month && this.queryParams.month.length === 6) {
// yyyyMM 格式,如 202512
year = this.queryParams.month.substring(0, 4)
month = this.queryParams.month.substring(4, 6)
} else if (this.queryParams.year && this.queryParams.month) {
// 分别选择年份和月份
year = this.queryParams.year
month = this.queryParams.month.length === 6
? this.queryParams.month.substring(4, 6)
: this.queryParams.month
} else {
// 使用默认值(当前年月)
const now = new Date()
year = now.getFullYear().toString()
month = String(now.getMonth() + 1).padStart(2, '0')
}
const params = {
currentPage: this.queryParams.currentPage,
pageSize: this.queryParams.pageSize,
Year: year,
Month: month,
StoreId: this.queryParams.storeId || ''
}
const response = await getTechTeacherSalaryList(params)
if (response.code === 200) {
this.list = response.data.list || []
this.total = (response.data.pagination && response.data.pagination.total) || 0
} else {
this.$message.error(response.msg || '获取数据失败')
}
} catch (error) {
console.error('获取科技老师工资列表失败:', error)
this.$message.error('获取数据失败')
} finally {
this.loading = false
}
},
// 搜索
handleQuery() {
this.queryParams.currentPage = 1
this.getList()
},
// 重置搜索
resetQuery() {
const getCurrentYear = () => {
return new Date().getFullYear().toString()
}
const getCurrentMonth = () => {
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
return `${year}${month}`
}
this.queryParams = {
currentPage: 1,
pageSize: 300, // 写死为300
year: getCurrentYear(),
month: getCurrentMonth(),
storeId: ''
}
this.getList()
},
// 显示计算工资弹窗
showCalculateDialog() {
const getCurrentYear = () => {
return new Date().getFullYear().toString()
}
const getCurrentMonth = () => {
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
return `${year}${month}`
}
this.calculateYear = getCurrentYear()
this.calculateMonth = getCurrentMonth()
this.calculateDialogVisible = true
},
// 关闭计算工资弹窗
handleCalculateDialogClose() {
this.calculateDialogVisible = false
},
// 确认计算工资
async handleCalculateConfirm() {
if (!this.calculateYear || !this.calculateMonth) {
this.$message.warning('请选择年份和月份')
return
}
// 从calculateMonth中提取月份(yyyyMM格式,如202512)
const year = this.calculateYear
const month = this.calculateMonth.length === 6
? this.calculateMonth.substring(4, 6)
: this.calculateMonth
this.calculateLoading = true
try {
const response = await calculateTechTeacherSalary(year, month)
if (response.code === 200) {
this.$message.success('计算工资成功')
this.calculateDialogVisible = false
this.getList()
} else {
this.$message.error(response.msg || '计算工资失败')
}
} catch (error) {
console.error('计算工资失败:', error)
this.$message.error(error.message || '计算工资失败')
} finally {
this.calculateLoading = false
}
},
// 导出功能
async handleExport() {
if (!this.list || this.list.length === 0) {
this.$message.warning('暂无数据可导出')
return
}
this.exportLoading = true
try {
// 动态导入 xlsx 库
const XLSX = await import('xlsx')
// 构建表头
const headers = [
'门店名称',
'员工姓名',
'岗位',
'开单业绩',
'消耗业绩',
'退卡业绩',
'总业绩',
'项目数',
'底薪档位',
'底薪',
'业绩提成比例',
'业绩提成金额',
'消耗提成比例',
'消耗提成金额',
'手工费',
'提成合计',
'在店天数',
'请假天数',
'车补',
'少休费',
'全勤奖',
'当月培训补贴',
'当月交通补贴',
'上月培训补贴',
'上月交通补贴',
'补贴合计',
'核算应发工资',
'保底工资',
'保底请假扣款',
'保底底薪',
'保底补差',
'最终应发工资',
'缺卡扣款',
'迟到扣款',
'请假扣款',
'扣社保',
'扣除奖励',
'扣住宿费',
'扣学习期费用',
'扣工作服费用',
'扣款合计',
'发奖金',
'退手机押金',
'退住宿押金',
'补发上月',
'实发工资',
'当月是否发放',
'支付金额',
'待支付金额',
'当月支付总额',
'是否新店',
'新店保护阶段',
'锁定状态',
'离职状态'
]
// 构建数据行
const dataRows = this.list.map(item => [
item.StoreName || '无',
item.EmployeeName || '无',
item.Position || '无',
this.formatMoney(item.OrderAchievement),
this.formatMoney(item.ConsumeAchievement),
this.formatMoney(item.RefundAchievement),
this.formatMoney(item.TotalPerformance),
item.ProjectCount || '0',
item.BaseSalaryLevel || '0',
this.formatMoney(item.BaseSalary),
this.formatPercent(item.PerformanceCommissionRate),
this.formatMoney(item.PerformanceCommissionAmount),
this.formatPercent(item.ConsumeCommissionRate),
this.formatMoney(item.ConsumeCommissionAmount),
this.formatMoney(item.HandworkFee),
this.formatMoney(item.TotalCommission),
item.WorkingDays || '0',
item.LeaveDays || '0',
this.formatMoney(item.TransportationAllowance),
this.formatMoney(item.LessRest),
this.formatMoney(item.FullAttendance),
this.formatMoney(item.MonthlyTrainingSubsidy),
this.formatMoney(item.MonthlyTransportSubsidy),
this.formatMoney(item.LastMonthTrainingSubsidy),
this.formatMoney(item.LastMonthTransportSubsidy),
this.formatMoney(item.TotalSubsidy),
this.formatMoney(item.CalculatedGrossSalary),
this.formatMoney(item.GuaranteedSalary),
this.formatMoney(item.GuaranteedLeaveDeduction),
this.formatMoney(item.GuaranteedBaseSalary),
this.formatMoney(item.GuaranteedSupplement),
this.formatMoney(item.FinalGrossSalary),
this.formatMoney(item.MissingCard),
this.formatMoney(item.LateArrival),
this.formatMoney(item.LeaveDeduction),
this.formatMoney(item.SocialInsuranceDeduction),
this.formatMoney(item.RewardDeduction),
this.formatMoney(item.AccommodationDeduction),
this.formatMoney(item.StudyPeriodDeduction),
this.formatMoney(item.WorkClothesDeduction),
this.formatMoney(item.TotalDeduction),
this.formatMoney(item.Bonus),
this.formatMoney(item.ReturnPhoneDeposit),
this.formatMoney(item.ReturnAccommodationDeposit),
this.formatMoney(item.LastMonthSupplement),
this.formatMoney(item.ActualSalary),
item.MonthlyPaymentStatus || '无',
this.formatMoney(item.PaidAmount),
this.formatMoney(item.PendingAmount),
this.formatMoney(item.MonthlyTotalPayment),
item.IsNewStore || '无',
item.NewStoreProtectionStage || '0',
item.IsLocked === 1 ? '已锁定' : '未锁定',
item.IsTerminated === 1 ? '已离职' : '在职'
])
// 合并表头和数据
const excelData = [headers, ...dataRows]
// 创建工作表
const ws = XLSX.utils.aoa_to_sheet(excelData)
// 设置列宽
const colWidths = headers.map(() => ({ wch: 15 }))
ws['!cols'] = colWidths
// 创建工作簿
const wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '科技老师工资')
// 生成文件名
const now = new Date()
const timestamp = now.getFullYear() +
String(now.getMonth() + 1).padStart(2, '0') +
String(now.getDate()).padStart(2, '0') +
String(now.getHours()).padStart(2, '0') +
String(now.getMinutes()).padStart(2, '0') +
String(now.getSeconds()).padStart(2, '0')
const fileName = `科技老师工资_${timestamp}.xlsx`
// 导出文件
XLSX.writeFile(wb, fileName)
this.$message.success('导出成功')
} catch (error) {
console.error('导出失败:', error)
this.$message.error('导出失败,请重试')
} finally {
this.exportLoading = false
}
},
// 格式化金额
formatMoney(value) {
if (value === null || value === undefined || value === '') {
return '0.00'
}
return Number(value).toFixed(2)
},
// 格式化百分比
formatPercent(value) {
if (value === null || value === undefined || value === '') {
return '0.00%'
}
|