| | |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { HrmSalaryCalculationApi } from '#/api/hrm/salary/calculation'; |
| | | |
| | | import { ref } from 'vue'; |
| | | import { ref, watch } from 'vue'; |
| | | |
| | | import { Page } from '#/packages/effects/common-ui/src'; |
| | | import { downloadFileFromBlobPart } from '#/packages/utils/src'; |
| | |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | calculateSalary, |
| | | confirmSalary, |
| | | deleteSalaryCalculation, |
| | | exportSalaryCalculation, |
| | |
| | | const previewLoading = ref(false); |
| | | const previewData = ref<HrmSalaryCalculationApi.SalaryCalculation[]>([]); |
| | | const submitLoading = ref(false); |
| | | const calculateLoading = ref(false); |
| | | |
| | | // 打开核算弹窗 |
| | | async function openCalculateModal() { |
| | |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** 执行薪酬核算(自动计算并保存) */ |
| | | async function handleCalculate() { |
| | | if (!calculatePeriod.value) { |
| | | message.warning('请选择核算周期'); |
| | | return; |
| | | } |
| | | calculateLoading.value = true; |
| | | try { |
| | | await calculateSalary({ |
| | | period: calculatePeriod.value, |
| | | deptId: calculateDeptId.value, |
| | | }); |
| | | message.success('薪酬核算执行成功'); |
| | | calculateVisible.value = false; |
| | | handleRefresh(); |
| | | } finally { |
| | | calculateLoading.value = false; |
| | | } |
| | | } |
| | | |
| | | /** 预览核算数据 */ |
| | | /** 预览核算数据(核算唯一入口:必须先预览,再保存) */ |
| | | async function handlePreview() { |
| | | if (!calculatePeriod.value) { |
| | | message.warning('请选择核算周期'); |
| | |
| | | previewLoading.value = false; |
| | | } |
| | | } |
| | | |
| | | // 周期/部门一变,已有的预览结果就作废,避免把旧周期的数据按新周期保存 |
| | | watch([calculatePeriod, calculateDeptId], () => { |
| | | previewData.value = []; |
| | | }); |
| | | |
| | | /** 计算实发工资 */ |
| | | function calculateActualSalary(record: HrmSalaryCalculationApi.SalaryCalculation) { |
| | |
| | | :maskClosable="false" |
| | | > |
| | | <Alert |
| | | message="两种核算方式:1. 执行核算 - 自动计算并保存;2. 预览数据 - 手动调整后保存" |
| | | message="核算流程:选择核算周期后点「预览数据」查看核算结果,确认或调整各员工的工资项目后点「保存核算」才会写入数据;未预览不能保存。" |
| | | type="info" |
| | | show-icon |
| | | style="margin-bottom: 16px" |
| | |
| | | /> |
| | | </FormItem> |
| | | <FormItem> |
| | | <a-button type="primary" :loading="calculateLoading" @click="handleCalculate"> |
| | | 执行核算 |
| | | </a-button> |
| | | </FormItem> |
| | | <FormItem> |
| | | <a-button :loading="previewLoading" @click="handlePreview"> |
| | | <a-button type="primary" :loading="previewLoading" @click="handlePreview"> |
| | | 预览数据 |
| | | </a-button> |
| | | </FormItem> |