tuqin
23 小时以前 057ef771c0d3c2d3c49be6b450b21029b642a746
fix(hrm): 薪酬核算「确认」前自动保存行内修改(方案A)

- 单个确认:若记录待确认,先提交本行修改再确认,避免「改了没保存就确认」导致金额丢失
- 批量确认:先保存勾选中的待确认记录,再统一确认
- 抽出 saveRowEdits 复用保存逻辑
已修改1个文件
20 ■■■■■ 文件已修改
src/views/hrm/salary/calculation/index.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/hrm/salary/calculation/index.vue
@@ -152,20 +152,36 @@
  previewData.value = [];
}
/** 确认薪酬核算 */
/** 把行内编辑的文本值归一为数字后提交保存 */
async function saveRowEdits(row: any) {
  const payload: any = { ...row };
  EDITABLE_NUMBER_FIELDS.forEach((f) => {
    payload[f] = toNumberOrZero(payload[f]);
  });
  await updateSalaryCalculation(payload);
}
/** 确认薪酬核算(方案A:确认前先保存当前行的修改,避免「改了没保存就确认」导致金额丢失) */
async function handleConfirm(row: HrmSalaryCalculationApi.SalaryCalculation) {
  if (row.status === 0) {
    await saveRowEdits(row);
  }
  await confirmSalary([row.id!]);
  message.success('确认成功');
  handleRefresh();
}
/** 批量确认选中的记录 */
/** 批量确认选中的记录(同样先保存勾选的待确认记录,再确认) */
async function handleBatchConfirm() {
  const records = gridApi.grid.getCheckboxRecords() as HrmSalaryCalculationApi.SalaryCalculation[];
  if (records.length === 0) {
    message.warning('请选择要确认的记录');
    return;
  }
  const pending = records.filter((r) => r.status === 0);
  for (const row of pending) {
    await saveRowEdits(row);
  }
  const ids = records.map((r) => r.id!);
  await confirmSalary(ids);
  message.success('确认成功');