From 7f6313626df7f49b0e45e1d9d9f197753152e29e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 04 十一月 2026 15:19:00 +0800
Subject: [PATCH] 九鸿:薪酬核算表按客户工资表重排字段,员工档案补标准项
---
src/api/hrm/employee/index.ts | 10 +
src/api/hrm/salary/calculation/index.ts | 56 ++++++
src/views/hrm/salary/calculation/data.ts | 148 ++++++++++++----
src/views/hrm/employee/modules/detail.vue | 7
src/views/hrm/salary/calculation/index.vue | 254 ++++++++++++---------------
src/views/hrm/employee/data.ts | 60 ++++++
6 files changed, 355 insertions(+), 180 deletions(-)
diff --git a/src/api/hrm/employee/index.ts b/src/api/hrm/employee/index.ts
index 4c0360a..9cc7078 100644
--- a/src/api/hrm/employee/index.ts
+++ b/src/api/hrm/employee/index.ts
@@ -31,6 +31,16 @@
sickLeaveBalance?: number;
salaryStructureId?: number;
baseSalary?: number;
+ /** 鏍囧噯宸ヨ祫 */
+ standardSalary?: number;
+ /** 宀椾綅宸ヨ祫 */
+ postSalary?: number;
+ /** 鍔犵彮宸ヨ祫鏍囧噯锛堝厓/灏忔椂锛� */
+ overtimeHourlyRate?: number;
+ /** 瀹夊叏鐜繚濂栨爣鍑� */
+ safetyAwardStandard?: number;
+ /** 缁╂晥鏍囧噯 */
+ performanceStandard?: number;
roleIds?: number[];
roleNames?: string[];
bankName?: string;
diff --git a/src/api/hrm/salary/calculation/index.ts b/src/api/hrm/salary/calculation/index.ts
index 76d4fdd..f403821 100644
--- a/src/api/hrm/salary/calculation/index.ts
+++ b/src/api/hrm/salary/calculation/index.ts
@@ -12,6 +12,62 @@
userName?: string;
deptId?: number;
deptName?: string;
+ /** 鍏ヨ亴鏃ユ湡 */
+ hireDate?: string;
+ /** 宀椾綅鍚嶇О */
+ postName?: string;
+ // ===== 涔濇硴宸ヨ祫琛細鏍囧噯椤癸紙鍙栬嚜鍛樺伐妗f锛� =====
+ /** 鏍囧噯宸ヨ祫 */
+ standardSalary?: number;
+ /** 宀椾綅宸ヨ祫 */
+ postSalary?: number;
+ /** 鍔犵彮宸ヨ祫鏍囧噯锛堝厓/灏忔椂锛� */
+ overtimeHourlyRate?: number;
+ /** 瀹夊叏鐜繚濂栨爣鍑� */
+ safetyAwardStandard?: number;
+ /** 缁╂晥鏍囧噯 */
+ performanceStandard?: number;
+ // ===== 涔濇硴宸ヨ祫琛細鍑哄嫟涓庤钖� =====
+ /** 璁¤柂鍑哄嫟锛堝ぉ锛� */
+ paidAttendanceDays?: number;
+ /** 鏍囧噯鍑哄嫟鏃堕暱锛堝皬鏃讹級 */
+ standardWorkHours?: number;
+ /** 娉曞畾鍋囨棩鏃堕暱锛堝皬鏃讹級 */
+ legalHolidayHours?: number;
+ /** 鏍囧噯鍑哄嫟宸ヨ祫 */
+ standardAttendancePay?: number;
+ /** 娉曞畾鍋囧伐璧� */
+ legalHolidayPay?: number;
+ /** 瀹夊叏鐜繚濂� */
+ safetyAward?: number;
+ /** 娴姩缁╂晥宸ヨ祫 */
+ floatingPerformancePay?: number;
+ /** 搴斾粯宸ヨ祫 */
+ payableSalary?: number;
+ // ===== 涔濇硴宸ヨ祫琛細鍔犻」 / 鎵i」 =====
+ /** 宸ラ緞宸ヨ祫 */
+ seniorityPay?: number;
+ /** 澶滅彮琛ュ姪 */
+ nightShiftAllowance?: number;
+ /** 瀛﹀巻琛ヨ创 */
+ educationAllowance?: number;
+ /** 浣撴 */
+ healthCheckAllowance?: number;
+ /** 浼樼鍛樺伐濂� */
+ excellentEmployeeAward?: number;
+ /** 鍏朵粬琛ュ姪 */
+ otherSubsidy?: number;
+ /** 閮ㄩ棬缁╂晥 */
+ deptPerformance?: number;
+ /** 鍔犻」鍚堣 */
+ additionTotal?: number;
+ /** 婕忔墦鍗� */
+ missedPunchDeduction?: number;
+ /** 杩熷埌鏃╅�� */
+ lateEarlyDeduction?: number;
+ /** 鎵f鍚堣 */
+ deductionTotal?: number;
+ // ===== 鍏煎鏃у瓧娈� =====
baseSalary?: number;
performanceSalary?: number;
overtimePay?: number;
diff --git a/src/views/hrm/employee/data.ts b/src/views/hrm/employee/data.ts
index 7474ca7..cc5f0ab 100644
--- a/src/views/hrm/employee/data.ts
+++ b/src/views/hrm/employee/data.ts
@@ -268,6 +268,66 @@
},
},
{
+ fieldName: 'postSalary',
+ label: '宀椾綅宸ヨ祫',
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ矖浣嶅伐璧�',
+ min: 0,
+ precision: 2,
+ style: { width: '100%' },
+ },
+ help: '涓庡熀鏈伐璧勪竴璧锋瀯鎴愬伐璧勮〃涓殑鏍囧噯宸ヨ祫',
+ },
+ {
+ fieldName: 'standardSalary',
+ label: '鏍囧噯宸ヨ祫',
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '涓嶅~鍒欒嚜鍔ㄦ寜銆屽熀鏈伐璧� + 宀椾綅宸ヨ祫銆嶈绠�',
+ min: 0,
+ precision: 2,
+ style: { width: '100%' },
+ },
+ help: '宸ヨ祫琛ㄤ腑鎸夎钖嚭鍕ゆ姌绠楃殑鍩烘暟锛涚暀绌烘椂鍙栧熀鏈伐璧� + 宀椾綅宸ヨ祫',
+ },
+ {
+ fieldName: 'overtimeHourlyRate',
+ label: '鍔犵彮宸ヨ祫鏍囧噯',
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '璇疯緭鍏ユ瘡灏忔椂鍔犵彮鍗曚环锛堝厓/灏忔椂锛�',
+ min: 0,
+ precision: 2,
+ style: { width: '100%' },
+ },
+ help: '鍏�/灏忔椂锛涚暀绌烘椂鎸夈�屽熀鏈伐璧� / 21.75 / 8銆嶆姌绠�',
+ },
+ {
+ fieldName: 'safetyAwardStandard',
+ label: '瀹夊叏鐜繚濂栨爣鍑�',
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ畨鍏ㄧ幆淇濆鏍囧噯',
+ min: 0,
+ precision: 2,
+ style: { width: '100%' },
+ },
+ help: '鎸夎钖嚭鍕ゆ瘮渚嬫姌绠楀悗璁″叆搴斾粯宸ヨ祫',
+ },
+ {
+ fieldName: 'performanceStandard',
+ label: '缁╂晥鏍囧噯',
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '璇疯緭鍏ョ哗鏁堟爣鍑�',
+ min: 0,
+ precision: 2,
+ style: { width: '100%' },
+ },
+ help: '鎸夎钖嚭鍕ゆ瘮渚嬫姌绠楀悗璁″叆銆屾诞鍔ㄧ哗鏁堝伐璧勩��',
+ },
+ {
fieldName: 'bankName',
label: '寮�鎴烽摱琛�',
component: 'Input',
diff --git a/src/views/hrm/employee/modules/detail.vue b/src/views/hrm/employee/modules/detail.vue
index ccd7122..b8afb13 100644
--- a/src/views/hrm/employee/modules/detail.vue
+++ b/src/views/hrm/employee/modules/detail.vue
@@ -64,6 +64,13 @@
<DescriptionsItem label="杞鏃ユ湡">{{ employee.regularDate || '-' }}</DescriptionsItem>
<DescriptionsItem label="绂昏亴鏃ユ湡">{{ employee.leaveDate || '-' }}</DescriptionsItem>
<DescriptionsItem label="鍩烘湰宸ヨ祫">{{ employee.baseSalary ? `楼${employee.baseSalary.toFixed(2)}` : '-' }}</DescriptionsItem>
+ <DescriptionsItem label="宀椾綅宸ヨ祫">{{ employee.postSalary ? `楼${employee.postSalary.toFixed(2)}` : '-' }}</DescriptionsItem>
+ <DescriptionsItem label="鏍囧噯宸ヨ祫">
+ {{ employee.standardSalary ? `楼${employee.standardSalary.toFixed(2)}` : (employee.baseSalary || employee.postSalary ? `楼${((employee.baseSalary || 0) + (employee.postSalary || 0)).toFixed(2)}锛堝熀鏈�+宀椾綅鑷姩鍚堟垚锛塦 : '-') }}
+ </DescriptionsItem>
+ <DescriptionsItem label="鍔犵彮宸ヨ祫鏍囧噯">{{ employee.overtimeHourlyRate ? `楼${employee.overtimeHourlyRate.toFixed(2)}/灏忔椂` : '-' }}</DescriptionsItem>
+ <DescriptionsItem label="瀹夊叏鐜繚濂栨爣鍑�">{{ employee.safetyAwardStandard ? `楼${employee.safetyAwardStandard.toFixed(2)}` : '-' }}</DescriptionsItem>
+ <DescriptionsItem label="缁╂晥鏍囧噯">{{ employee.performanceStandard ? `楼${employee.performanceStandard.toFixed(2)}` : '-' }}</DescriptionsItem>
<DescriptionsItem label="鐢ㄦ埛瑙掕壊" :span="2">
{{ Array.isArray(employee.roleNames) ? employee.roleNames.join('銆�') : employee.roleNames || '-' }}
</DescriptionsItem>
diff --git a/src/views/hrm/salary/calculation/data.ts b/src/views/hrm/salary/calculation/data.ts
index bd96225..0115d14 100644
--- a/src/views/hrm/salary/calculation/data.ts
+++ b/src/views/hrm/salary/calculation/data.ts
@@ -1,3 +1,4 @@
+import type { TableColumnsType } from 'ant-design-vue';
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { HrmSalaryCalculationApi } from '#/api/hrm/salary/calculation';
@@ -67,29 +68,49 @@
];
}
-/** 鍒楄〃鐨勫瓧娈� */
+/** 鍒楄〃鐨勫瓧娈碉紙鎸変節娉撳伐璧勮〃鍒楅『搴忥級 */
export function useGridColumns(): VxeTableGridOptions<HrmSalaryCalculationApi.SalaryCalculation>['columns'] {
return [
- { type: 'checkbox', width: 50 },
- { field: 'no', title: '鏍哥畻鍗曞彿', minWidth: 140 },
- { field: 'period', title: '鏍哥畻鍛ㄦ湡', width: 100 },
- { field: 'userName', title: '鍛樺伐濮撳悕', minWidth: 100 },
- { field: 'deptName', title: '閮ㄩ棬', minWidth: 120 },
+ { type: 'checkbox', width: 50, fixed: 'left' },
+ { field: 'no', title: '鏍哥畻鍗曞彿', width: 150, fixed: 'left' },
+ { field: 'period', title: '鏍哥畻鍛ㄦ湡', width: 100, fixed: 'left' },
+ { field: 'userName', title: '濮撳悕', width: 90, fixed: 'left' },
+ { field: 'hireDate', title: '鍏ヨ亴鏃ユ湡', width: 110 },
+ { field: 'postName', title: '宀椾綅', width: 110 },
+ { field: 'deptName', title: '閮ㄩ棬', width: 120 },
+ { field: 'workDays', title: '鏍囧噯鍑哄嫟澶╂暟', width: 110 },
+ { field: 'paidAttendanceDays', title: '璁¤柂鍑哄嫟', width: 100, formatter: 'formatAmount2' },
+ { field: 'standardSalary', title: '鏍囧噯宸ヨ祫', width: 100, formatter: 'formatAmount2' },
{ field: 'baseSalary', title: '鍩烘湰宸ヨ祫', width: 100, formatter: 'formatAmount2' },
- { field: 'performanceSalary', title: '缁╂晥宸ヨ祫', width: 100, formatter: 'formatAmount2' },
- { field: 'overtimePay', title: '鍔犵彮璐�', width: 100, formatter: 'formatAmount2' },
- { field: 'mealAllowance', title: '椁愯ˉ', width: 80, formatter: 'formatAmount2' },
- { field: 'transportAllowance', title: '浜ら�氳ˉ璐�', width: 80, formatter: 'formatAmount2' },
- { field: 'otherAllowance', title: '鍏朵粬琛ヨ创', width: 80, formatter: 'formatAmount2' },
- { field: 'socialSecurityDeduction', title: '绀句繚鎵f', width: 100, formatter: 'formatAmount2' },
- { field: 'housingFundDeduction', title: '鍏Н閲戞墸娆�', width: 100, formatter: 'formatAmount2' },
- { field: 'taxDeduction', title: '涓◣鎵f', width: 100, formatter: 'formatAmount2' },
- { field: 'otherDeduction', title: '鍏朵粬鎵f', width: 80, formatter: 'formatAmount2' },
- { field: 'leaveDeduction', title: '璇峰亣鎵f', width: 100, formatter: 'formatAmount2' },
- { field: 'actualSalary', title: '瀹炲彂宸ヨ祫', width: 100, formatter: 'formatAmount2' },
- { field: 'workDays', title: '鍑哄嫟澶╂暟', width: 80 },
- { field: 'overtimeHours', title: '鍔犵彮鏃堕暱(h)', width: 100 },
- { field: 'totalWorkHours', title: '鎺掔彮宸ユ椂(h)', width: 100 },
+ { field: 'postSalary', title: '宀椾綅宸ヨ祫', width: 100, formatter: 'formatAmount2' },
+ { field: 'overtimeHourlyRate', title: '鍔犵彮宸ヨ祫(鏍囧噯)', width: 120, formatter: 'formatAmount2' },
+ { field: 'safetyAwardStandard', title: '瀹夊叏鐜繚濂�(鏍囧噯)', width: 130, formatter: 'formatAmount2' },
+ { field: 'performanceStandard', title: '缁╂晥(鏍囧噯)', width: 110, formatter: 'formatAmount2' },
+ { field: 'standardWorkHours', title: '鏍囧噯鍑哄嫟鏃堕暱', width: 120, formatter: 'formatAmount2' },
+ { field: 'overtimeHours', title: '鍔犵彮鏃堕暱', width: 100 },
+ { field: 'legalHolidayHours', title: '娉曞畾鍋囨棩鏃堕暱', width: 120 },
+ { field: 'standardAttendancePay', title: '鏍囧噯鍑哄嫟宸ヨ祫', width: 120, formatter: 'formatAmount2' },
+ { field: 'overtimePay', title: '鍔犵彮宸ヨ祫', width: 100, formatter: 'formatAmount2' },
+ { field: 'legalHolidayPay', title: '娉曞畾鍋囧伐璧�', width: 110, formatter: 'formatAmount2' },
+ { field: 'safetyAward', title: '瀹夊叏鐜繚濂�', width: 110, formatter: 'formatAmount2' },
+ { field: 'floatingPerformancePay', title: '娴姩缁╂晥宸ヨ祫', width: 120, formatter: 'formatAmount2' },
+ { field: 'payableSalary', title: '搴斾粯宸ヨ祫', width: 100, formatter: 'formatAmount2' },
+ { field: 'seniorityPay', title: '宸ラ緞宸ヨ祫', width: 100, formatter: 'formatAmount2' },
+ { field: 'nightShiftAllowance', title: '澶滅彮琛ュ姪', width: 100, formatter: 'formatAmount2' },
+ { field: 'educationAllowance', title: '瀛﹀巻琛ヨ创', width: 100, formatter: 'formatAmount2' },
+ { field: 'healthCheckAllowance', title: '浣撴', width: 90, formatter: 'formatAmount2' },
+ { field: 'excellentEmployeeAward', title: '浼樼鍛樺伐濂�', width: 110, formatter: 'formatAmount2' },
+ { field: 'otherSubsidy', title: '鍏朵粬琛ュ姪', width: 100, formatter: 'formatAmount2' },
+ { field: 'deptPerformance', title: '閮ㄩ棬缁╂晥', width: 100, formatter: 'formatAmount2' },
+ { field: 'additionTotal', title: '鍔犻」鍚堣', width: 100, formatter: 'formatAmount2' },
+ { field: 'missedPunchDeduction', title: '婕忔墦鍗�', width: 90, formatter: 'formatAmount2' },
+ { field: 'lateEarlyDeduction', title: '杩熷埌鏃╅��', width: 100, formatter: 'formatAmount2' },
+ { field: 'otherDeduction', title: '鍏朵粬鎵f', width: 100, formatter: 'formatAmount2' },
+ { field: 'deductionTotal', title: '鎵f鍚堣', width: 100, formatter: 'formatAmount2' },
+ { field: 'socialSecurityDeduction', title: '绀句繚', width: 100, formatter: 'formatAmount2' },
+ { field: 'housingFundDeduction', title: '鍏Н閲�', width: 100, formatter: 'formatAmount2' },
+ { field: 'taxDeduction', title: '涓◣', width: 100, formatter: 'formatAmount2' },
+ { field: 'actualSalary', title: '绋庡悗宸ヨ祫', width: 110, formatter: 'formatAmount2', fixed: 'right' },
{
field: 'status',
title: '鐘舵��',
@@ -110,25 +131,78 @@
];
}
-/** 棰勮琛ㄦ牸鐨勫垪瀹氫箟锛堢敤浜嶢nt Design Table锛� */
-export function usePreviewColumns() {
+/** 棰勮琛ㄦ牸閲屽厑璁告墜宸ヨ皟鏁寸殑瀛楁锛堝叾浣欏潎涓鸿嚜鍔ㄨ绠楋級 */
+export const PREVIEW_EDITABLE_FIELDS = [
+ 'floatingPerformancePay',
+ 'seniorityPay',
+ 'nightShiftAllowance',
+ 'educationAllowance',
+ 'healthCheckAllowance',
+ 'excellentEmployeeAward',
+ 'otherSubsidy',
+ 'deptPerformance',
+ 'missedPunchDeduction',
+ 'lateEarlyDeduction',
+ 'otherDeduction',
+] as const;
+
+/** 鍔犻」瀛楁锛堟眹鎬讳负銆屽姞椤瑰悎璁°�嶏級 */
+export const PREVIEW_ADDITION_FIELDS = [
+ 'seniorityPay',
+ 'nightShiftAllowance',
+ 'educationAllowance',
+ 'healthCheckAllowance',
+ 'excellentEmployeeAward',
+ 'otherSubsidy',
+ 'deptPerformance',
+] as const;
+
+/** 鎵f瀛楁锛堟眹鎬讳负銆屾墸娆惧悎璁°�嶏級 */
+export const PREVIEW_DEDUCTION_FIELDS = [
+ 'missedPunchDeduction',
+ 'lateEarlyDeduction',
+ 'otherDeduction',
+] as const;
+
+/** 棰勮琛ㄦ牸鐨勫垪瀹氫箟锛堢敤浜嶢nt Design Table锛屾寜涔濇硴宸ヨ祫琛ㄥ垪椤哄簭锛� */
+export function usePreviewColumns(): TableColumnsType {
return [
- { title: '鍛樺伐濮撳悕', dataIndex: 'userName', width: 100, fixed: 'left' },
+ { title: '濮撳悕', dataIndex: 'userName', width: 90, fixed: 'left' },
+ { title: '鍏ヨ亴鏃ユ湡', dataIndex: 'hireDate', width: 110 },
+ { title: '宀椾綅', dataIndex: 'postName', width: 110 },
{ title: '閮ㄩ棬', dataIndex: 'deptName', width: 120 },
- { title: '鍩烘湰宸ヨ祫', dataIndex: 'baseSalary', width: 110 },
- { title: '缁╂晥宸ヨ祫', dataIndex: 'performanceSalary', width: 110 },
- { title: '鍔犵彮璐�', dataIndex: 'overtimePay', width: 110 },
- { title: '椁愯ˉ', dataIndex: 'mealAllowance', width: 100 },
- { title: '浜ら�氳ˉ璐�', dataIndex: 'transportAllowance', width: 100 },
- { title: '鍏朵粬琛ヨ创', dataIndex: 'otherAllowance', width: 100 },
- { title: '绀句繚鎵f', dataIndex: 'socialSecurityDeduction', width: 110 },
- { title: '鍏Н閲戞墸娆�', dataIndex: 'housingFundDeduction', width: 110 },
- { title: '涓◣鎵f', dataIndex: 'taxDeduction', width: 110 },
- { title: '鍏朵粬鎵f', dataIndex: 'otherDeduction', width: 100 },
- { title: '璇峰亣鎵f', dataIndex: 'leaveDeduction', width: 110 },
- { title: '鍑哄嫟澶╂暟', dataIndex: 'workDays', width: 90 },
+ { title: '鏍囧噯鍑哄嫟澶╂暟', dataIndex: 'workDays', width: 110 },
+ { title: '璁¤柂鍑哄嫟', dataIndex: 'paidAttendanceDays', width: 100 },
+ { title: '鏍囧噯宸ヨ祫', dataIndex: 'standardSalary', width: 100 },
+ { title: '鍩烘湰宸ヨ祫', dataIndex: 'baseSalary', width: 100 },
+ { title: '宀椾綅宸ヨ祫', dataIndex: 'postSalary', width: 100 },
+ { title: '鍔犵彮宸ヨ祫(鏍囧噯)', dataIndex: 'overtimeHourlyRate', width: 120 },
+ { title: '瀹夊叏鐜繚濂�(鏍囧噯)', dataIndex: 'safetyAwardStandard', width: 130 },
+ { title: '缁╂晥(鏍囧噯)', dataIndex: 'performanceStandard', width: 110 },
+ { title: '鏍囧噯鍑哄嫟鏃堕暱', dataIndex: 'standardWorkHours', width: 120 },
{ title: '鍔犵彮鏃堕暱', dataIndex: 'overtimeHours', width: 100 },
- { title: '鎺掔彮宸ユ椂(h)', dataIndex: 'totalWorkHours', width: 100 },
- { title: '瀹炲彂宸ヨ祫', dataIndex: 'actualSalary', width: 100, fixed: 'right' },
+ { title: '娉曞畾鍋囨棩鏃堕暱', dataIndex: 'legalHolidayHours', width: 120 },
+ { title: '鏍囧噯鍑哄嫟宸ヨ祫', dataIndex: 'standardAttendancePay', width: 120 },
+ { title: '鍔犵彮宸ヨ祫', dataIndex: 'overtimePay', width: 100 },
+ { title: '娉曞畾鍋囧伐璧�', dataIndex: 'legalHolidayPay', width: 110 },
+ { title: '瀹夊叏鐜繚濂�', dataIndex: 'safetyAward', width: 110 },
+ { title: '娴姩缁╂晥宸ヨ祫', dataIndex: 'floatingPerformancePay', width: 120 },
+ { title: '搴斾粯宸ヨ祫', dataIndex: 'payableSalary', width: 100 },
+ { title: '宸ラ緞宸ヨ祫', dataIndex: 'seniorityPay', width: 100 },
+ { title: '澶滅彮琛ュ姪', dataIndex: 'nightShiftAllowance', width: 100 },
+ { title: '瀛﹀巻琛ヨ创', dataIndex: 'educationAllowance', width: 100 },
+ { title: '浣撴', dataIndex: 'healthCheckAllowance', width: 90 },
+ { title: '浼樼鍛樺伐濂�', dataIndex: 'excellentEmployeeAward', width: 110 },
+ { title: '鍏朵粬琛ュ姪', dataIndex: 'otherSubsidy', width: 100 },
+ { title: '閮ㄩ棬缁╂晥', dataIndex: 'deptPerformance', width: 100 },
+ { title: '鍔犻」鍚堣', dataIndex: 'additionTotal', width: 100 },
+ { title: '婕忔墦鍗�', dataIndex: 'missedPunchDeduction', width: 90 },
+ { title: '杩熷埌鏃╅��', dataIndex: 'lateEarlyDeduction', width: 100 },
+ { title: '鍏朵粬鎵f', dataIndex: 'otherDeduction', width: 100 },
+ { title: '鎵f鍚堣', dataIndex: 'deductionTotal', width: 100 },
+ { title: '绀句繚', dataIndex: 'socialSecurityDeduction', width: 100 },
+ { title: '鍏Н閲�', dataIndex: 'housingFundDeduction', width: 100 },
+ { title: '涓◣', dataIndex: 'taxDeduction', width: 100 },
+ { title: '绋庡悗宸ヨ祫', dataIndex: 'actualSalary', width: 110, fixed: 'right' },
];
}
diff --git a/src/views/hrm/salary/calculation/index.vue b/src/views/hrm/salary/calculation/index.vue
index 3b58d12..e76c2f6 100644
--- a/src/views/hrm/salary/calculation/index.vue
+++ b/src/views/hrm/salary/calculation/index.vue
@@ -26,7 +26,14 @@
import { handleTree } from '#/packages/utils/src';
import { $t } from '#/locales';
-import { useGridColumns, useGridFormSchema, usePreviewColumns } from './data';
+import {
+ PREVIEW_ADDITION_FIELDS,
+ PREVIEW_DEDUCTION_FIELDS,
+ PREVIEW_EDITABLE_FIELDS,
+ useGridColumns,
+ useGridFormSchema,
+ usePreviewColumns,
+} from './data';
// 鏍哥畻寮圭獥鐩稿叧
const calculateVisible = ref(false);
@@ -75,6 +82,8 @@
period: calculatePeriod.value,
deptId: calculateDeptId.value,
});
+ // 棰勮琛屽厛鎸夊綋鍓嶅彛寰勯噸绠楀悎璁★紝淇濊瘉寮圭獥閲屾樉绀虹殑鍚堣涓庝繚瀛樼粨鏋滀竴鑷�
+ previewData.value.forEach((record) => recalculateRecord(record));
if (previewData.value.length === 0) {
message.info('璇ユ潯浠朵笅娌℃湁闇�瑕佹牳绠楃殑鍛樺伐');
}
@@ -83,26 +92,89 @@
}
}
-/** 璁$畻瀹炲彂宸ヨ祫 */
-function calculateActualSalary(record: HrmSalaryCalculationApi.SalaryCalculation) {
- const income = (record.baseSalary || 0) +
- (record.performanceSalary || 0) +
- (record.overtimePay || 0) +
- (record.mealAllowance || 0) +
- (record.transportAllowance || 0) +
- (record.otherAllowance || 0);
- const deduction = (record.socialSecurityDeduction || 0) +
- (record.housingFundDeduction || 0) +
- (record.taxDeduction || 0) +
- (record.otherDeduction || 0) +
- (record.leaveDeduction || 0);
- return income - deduction;
+/** 棰勮琛ㄤ腑鎸夊師鏍峰睍绀虹殑瀛楁锛堥潪閲戦锛� */
+const PLAIN_FIELDS = [
+ 'userName',
+ 'hireDate',
+ 'postName',
+ 'deptName',
+ 'workDays',
+ 'paidAttendanceDays',
+ 'standardWorkHours',
+ 'overtimeHours',
+ 'legalHolidayHours',
+];
+
+/** 鏄惁涓哄彲鎵嬪伐璋冩暣鐨勫垪 */
+function isEditableField(field: string) {
+ return (PREVIEW_EDITABLE_FIELDS as readonly string[]).includes(field);
}
-/** 鏇存柊琛屾暟鎹苟璁$畻瀹炲彂宸ヨ祫 */
-function updateFieldValue(record: HrmSalaryCalculationApi.SalaryCalculation, field: keyof HrmSalaryCalculationApi.SalaryCalculation, value: number) {
- (record as any)[field] = value;
- record.actualSalary = calculateActualSalary(record);
+/** 璇诲彇琛屽瓧娈靛�� */
+function fieldValue(
+ record: HrmSalaryCalculationApi.SalaryCalculation,
+ field: string,
+): number | string | undefined {
+ return (record as unknown as Record<string, number | string | undefined>)[
+ field
+ ];
+}
+
+/** 閲戦灞曠ず锛氫繚鐣欎袱浣嶅皬鏁� */
+function formatAmount(value?: number | string) {
+ if (value === null || value === undefined || value === '' || Number.isNaN(Number(value))) {
+ return '-';
+ }
+ return Number(value).toFixed(2);
+}
+
+/** 姹傚拰锛堢┖鍊兼寜 0 璁★級 */
+function sumFields(
+ record: HrmSalaryCalculationApi.SalaryCalculation,
+ fields: readonly string[],
+) {
+ return fields.reduce(
+ (total, field) =>
+ total + Number((record as Record<string, unknown>)[field] ?? 0),
+ 0,
+ );
+}
+
+/**
+ * 鎸変節娉撳伐璧勮〃鍙e緞閲嶇畻锛�
+ * 搴斾粯宸ヨ祫 = 鏍囧噯鍑哄嫟宸ヨ祫 + 鍔犵彮宸ヨ祫 + 娉曞畾鍋囧伐璧� + 瀹夊叏鐜繚濂� + 娴姩缁╂晥宸ヨ祫
+ * 鍔犻」鍚堣 = 宸ラ緞宸ヨ祫 + 澶滅彮琛ュ姪 + 瀛﹀巻琛ヨ创 + 浣撴 + 浼樼鍛樺伐濂� + 鍏朵粬琛ュ姪 + 閮ㄩ棬缁╂晥
+ * 鎵f鍚堣 = 婕忔墦鍗� + 杩熷埌鏃╅�� + 鍏朵粬鎵f
+ * 绋庡悗宸ヨ祫 = 搴斾粯宸ヨ祫 + 鍔犻」鍚堣 - 鎵f鍚堣 - 绀句繚 - 鍏Н閲� - 涓◣
+ */
+function recalculateRecord(
+ record: HrmSalaryCalculationApi.SalaryCalculation,
+) {
+ record.payableSalary =
+ Number(record.standardAttendancePay ?? 0) +
+ Number(record.overtimePay ?? 0) +
+ Number(record.legalHolidayPay ?? 0) +
+ Number(record.safetyAward ?? 0) +
+ Number(record.floatingPerformancePay ?? 0);
+ record.additionTotal = sumFields(record, PREVIEW_ADDITION_FIELDS);
+ record.deductionTotal = sumFields(record, PREVIEW_DEDUCTION_FIELDS);
+ record.actualSalary =
+ record.payableSalary +
+ record.additionTotal -
+ record.deductionTotal -
+ Number(record.socialSecurityDeduction ?? 0) -
+ Number(record.housingFundDeduction ?? 0) -
+ Number(record.taxDeduction ?? 0);
+}
+
+/** 鏇存柊琛屾暟鎹苟閲嶇畻鍚堣 */
+function updateFieldValue(
+ record: HrmSalaryCalculationApi.SalaryCalculation,
+ field: string,
+ value: number,
+) {
+ (record as Record<string, unknown>)[field] = value;
+ recalculateRecord(record);
}
/** 鎻愪氦钖叕鏍哥畻锛堟墜鍔ㄨ皟鏁村悗淇濆瓨锛� */
@@ -256,12 +328,12 @@
<Modal
v-model:open="calculateVisible"
title="钖叕鏍哥畻"
- width="1200px"
+ width="95%"
:footer="null"
:maskClosable="false"
>
<Alert
- message="鏍哥畻娴佺▼锛氶�夊ソ鏍哥畻鍛ㄦ湡涓庨儴闂ㄥ悗鐐广�岄瑙堟暟鎹�嶁啋 鏍稿/璋冩暣鍚勯」閲戦 鈫� 鐐广�屼繚瀛樻牳绠椼�嶈惤搴�"
+ message="鏍哥畻娴佺▼锛氶�夊ソ鏍哥畻鍛ㄦ湡涓庨儴闂ㄥ悗鐐广�岄瑙堟暟鎹�嶁啋 鏍稿鑷姩璁$畻缁撴灉锛屽彲鎵嬪伐璋冩暣娴姩缁╂晥銆佸姞椤逛笌鎵f 鈫� 鐐广�屼繚瀛樻牳绠椼�嶈惤搴撱�傛爣鍑嗗伐璧�/宀椾綅宸ヨ祫/鍔犵彮宸ヨ祫(鏍囧噯)/瀹夊叏鐜繚濂�(鏍囧噯)/缁╂晥(鏍囧噯) 鍦ㄥ憳宸ユ。妗堜腑缁存姢銆�"
type="info"
show-icon
style="margin-bottom: 16px"
@@ -301,144 +373,40 @@
:columns="usePreviewColumns()"
:data-source="previewData"
:pagination="{ pageSize: 20, showSizeChanger: true, showTotal: (t) => `鍏� ${t} 浜篳 }"
- :scroll="{ x: 1800, y: 400 }"
+ :scroll="{ x: 4000, y: 420 }"
size="small"
row-key="userId"
bordered
class="mb-4"
>
<template #bodyCell="{ column, record }">
- <template v-if="column.dataIndex === 'baseSalary'">
+ <template v-if="isEditableField(String(column.dataIndex))">
<InputNumber
- v-model:value="record.baseSalary"
+ :value="fieldValue(record, String(column.dataIndex)) as number"
:min="0"
:precision="2"
size="small"
style="width: 90px"
- @change="(val: number) => updateFieldValue(record, 'baseSalary', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'performanceSalary'">
- <InputNumber
- v-model:value="record.performanceSalary"
- :min="0"
- :precision="2"
- size="small"
- style="width: 90px"
- @change="(val: number) => updateFieldValue(record, 'performanceSalary', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'overtimePay'">
- <InputNumber
- v-model:value="record.overtimePay"
- :min="0"
- :precision="2"
- size="small"
- style="width: 90px"
- @change="(val: number) => updateFieldValue(record, 'overtimePay', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'mealAllowance'">
- <InputNumber
- v-model:value="record.mealAllowance"
- :min="0"
- :precision="2"
- size="small"
- style="width: 80px"
- @change="(val: number) => updateFieldValue(record, 'mealAllowance', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'transportAllowance'">
- <InputNumber
- v-model:value="record.transportAllowance"
- :min="0"
- :precision="2"
- size="small"
- style="width: 80px"
- @change="(val: number) => updateFieldValue(record, 'transportAllowance', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'otherAllowance'">
- <InputNumber
- v-model:value="record.otherAllowance"
- :min="0"
- :precision="2"
- size="small"
- style="width: 80px"
- @change="(val: number) => updateFieldValue(record, 'otherAllowance', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'socialSecurityDeduction'">
- <InputNumber
- v-model:value="record.socialSecurityDeduction"
- :min="0"
- :precision="2"
- size="small"
- style="width: 90px"
- @change="(val: number) => updateFieldValue(record, 'socialSecurityDeduction', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'housingFundDeduction'">
- <InputNumber
- v-model:value="record.housingFundDeduction"
- :min="0"
- :precision="2"
- size="small"
- style="width: 90px"
- @change="(val: number) => updateFieldValue(record, 'housingFundDeduction', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'taxDeduction'">
- <InputNumber
- v-model:value="record.taxDeduction"
- :min="0"
- :precision="2"
- size="small"
- style="width: 90px"
- @change="(val: number) => updateFieldValue(record, 'taxDeduction', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'otherDeduction'">
- <InputNumber
- v-model:value="record.otherDeduction"
- :min="0"
- :precision="2"
- size="small"
- style="width: 80px"
- @change="(val: number) => updateFieldValue(record, 'otherDeduction', val)"
- />
- </template>
- <template v-else-if="column.dataIndex === 'leaveDeduction'">
- <InputNumber
- v-model:value="record.leaveDeduction"
- :min="0"
- :precision="2"
- size="small"
- style="width: 90px"
- @change="(val: number) => updateFieldValue(record, 'leaveDeduction', val)"
+ @change="
+ (val: number | string | null) =>
+ updateFieldValue(
+ record,
+ String(column.dataIndex),
+ Number(val ?? 0),
+ )
+ "
/>
</template>
<template v-else-if="column.dataIndex === 'actualSalary'">
- <span class="font-bold text-green-600">{{ record.actualSalary?.toFixed(2) }}</span>
+ <span class="font-bold text-green-600">{{
+ formatAmount(record.actualSalary)
+ }}</span>
</template>
- <template v-else-if="column.dataIndex === 'workDays'">
- <InputNumber
- v-model:value="record.workDays"
- :min="0"
- :max="31"
- :precision="0"
- size="small"
- style="width: 70px"
- />
+ <template v-else-if="PLAIN_FIELDS.includes(String(column.dataIndex))">
+ {{ fieldValue(record, String(column.dataIndex)) ?? '-' }}
</template>
- <template v-else-if="column.dataIndex === 'overtimeHours'">
- <InputNumber
- v-model:value="record.overtimeHours"
- :min="0"
- :precision="1"
- size="small"
- style="width: 80px"
- />
+ <template v-else>
+ {{ formatAmount(fieldValue(record, String(column.dataIndex))) }}
</template>
</template>
</Table>
--
Gitblit v1.9.3