# 薪酬核算功能 ## 涉及页面 - 薪酬核算列表页面 - 薪酬核算详情页面 ## API | 方法 | 路径 | 说明 | |------|------|------| | POST | /hrm/salary/calculation/calculate | 执行薪酬核算 | | POST | /hrm/salary/calculation/confirm | 确认薪酬核算 | | POST | /hrm/salary/calculation/save | 批量保存薪酬核算记录 | | GET | /hrm/salary/calculation/page | 获取薪酬核算分页列表 | | GET | /hrm/salary/calculation/get | 获取薪酬核算详情 | | GET | /hrm/salary/calculation/preview | 预览部门下所有员工的薪资核算信息 | | GET | /hrm/salary/calculation/export-excel | 导出薪酬核算 Excel | **薪酬核算请求参数:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | period | String | 是 | 核算周期,格式如 2024-01 | | deptId | Long | 否 | 部门ID,为空则核算所有部门 | **预览接口请求参数:** | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | period | String | 是 | 核算周期,格式如 2024-01 | | deptId | Long | 是 | 部门ID | **批量保存接口请求体:** ```json { "period": "2024-01", "list": [ { "id": null, "userId": 1, "deptId": 100, "baseSalary": 10000.00, "performanceSalary": 2000.00, "overtimePay": 500.00, "mealAllowance": 300.00, "transportAllowance": 200.00, "otherAllowance": 0.00, "socialSecurityDeduction": 1050.00, "housingFundDeduction": 1200.00, "taxDeduction": 290.00, "otherDeduction": 0.00, "actualSalary": 10460.00, "workDays": 22, "overtimeHours": 8.00, "remark": "" } ] } ``` **薪酬核算记录响应字段:** | 字段 | 类型 | 说明 | |------|------|------| | id | Long | 核算ID | | no | String | 核算单号 | | period | String | 核算周期 | | userId | Long | 员工ID | | deptId | Long | 部门ID | | baseSalary | BigDecimal | 基本工资 | | performanceSalary | BigDecimal | 绩效工资 | | overtimePay | BigDecimal | 加班工资 | | mealAllowance | BigDecimal | 餐补 | | transportAllowance | BigDecimal | 交通补贴 | | otherAllowance | BigDecimal | 其他补贴 | | socialSecurityDeduction | BigDecimal | 社保扣除 | | housingFundDeduction | BigDecimal | 公积金扣除 | | taxDeduction | BigDecimal | 个税扣除 | | otherDeduction | BigDecimal | 其他扣除 | | actualSalary | BigDecimal | 实发工资 | | workDays | Integer | 出勤天数 | | overtimeHours | BigDecimal | 加班时长 | | status | Integer | 状态:0-待确认,10-已确认,20-已发放 | ## 前端修改点 ### 1. 薪酬核算按钮(添加部门选择) ```html 执行核算 ``` ### 2. data 数据 ```js data() { return { calculationPeriod: '', // 核算周期 calculationDeptId: null, // 核算部门ID deptList: [], // 部门列表 } } ``` ### 3. 方法 ```js // 执行薪酬核算 handleCalculate() { if (!this.calculationPeriod) { this.$message.warning('请选择核算周期') return } const params = { period: this.calculationPeriod } if (this.calculationDeptId) { params.deptId = this.calculationDeptId } request.post('/hrm/salary/calculation/calculate', null, { params }) .then(res => { this.$message.success('薪酬核算执行成功') this.getList() // 刷新列表 }) .catch(err => { this.$message.error(err.message || '薪酬核算执行失败') }) } ``` ## 核算逻辑说明 1. **获取员工**:查询所有在职(状态=1)和试用期(状态=2)员工 2. **获取薪酬档案**:通过 `selectLatestByUserId(userId)` 获取员工最新生效的薪酬档案 3. **薪酬档案不存在时**:使用员工表的 `baseSalary` 字段作为基本工资,其他薪资项目设为 0 4. **计算实发工资**:实发工资 = 基本工资 + 绩效工资 + 各项补贴 - 各项扣除 5. **防止重复核算**:同一员工同一周期只生成一条核算记录 6. **核算状态**:初始状态为待确认(0),确认后变为已确认(10) ## 注意事项 - 薪酬核算前需要确保员工有薪酬档案或员工表中有基本工资 - 社保、公积金、个税扣除目前设为 0,后续需要对接具体计算服务 - 核算周期格式为 YYYY-MM(如 2024-01) - 同一员工同一周期只能核算一次,重复调用会跳过已核算员工