| | |
| | | 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; |
| | | // 核算成果只允许在「预览 → 保存」之间流转:改了周期/部门就必须重新预览, |
| | | // 否则会把上一轮的预览结果按新的周期存下去 |
| | | watch([calculatePeriod, calculateDeptId], () => { |
| | | if (previewData.value.length > 0) { |
| | | previewData.value = []; |
| | | message.info('核算周期或部门已变更,请重新预览数据'); |
| | | } |
| | | 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() { |
| | |
| | | :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> |