liu
2026-09-03 a806a54c13a832b423d9cf1dfbe510a32ee63b30
fix(仓储物流): 修复条码配置“自动生成”开关切换报500

CellSwitch 的 beforeChange 调用约定为 (newVal, row),原实现把开关新值(1/0)
误当成整行 row 传给 updateBarcodeConfig,请求体被序列化为数字 1/0,
后端反序列化 MesWmBarcodeConfigSaveReqVO 失败返回 500“系统异常”。
现按 (newVal, row) 取值并发送 {...row, autoGenerateFlag} 完整行对象。

Co-Authored-By: Claude <noreply@anthropic.com>
已修改2个文件
16 ■■■■ 文件已修改
src/views/wls/barcode/config/index.vue 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/barcode/data.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/wls/barcode/config/index.vue
@@ -22,17 +22,26 @@
  destroyOnClose: true,
});
/** 自动生成开关变更 */
/**
 * 自动生成开关变更
 *
 * 注意:CellSwitch 的 beforeChange 调用约定为 (newVal, row)
 * —— 第一个参数是开关新值(antd Switch 配置 checkedValue=1/unCheckedValue=0,
 * 因此取值是数字 1/0),第二个参数才是整行数据。原先把 newVal 当成了 row,
 * 导致 updateBarcodeConfig(row) 的请求体被序列化成数字 1/0,后端解析 500。
 */
async function handleAutoGenerateChange(
  newVal: number | boolean,
  row: MesWmBarcodeConfigApi.BarcodeConfig,
): Promise<boolean> {
  const text = row.autoGenerateFlag ? '启用' : '停用';
  const next = newVal === true || newVal === 1; // 统一转成布尔
  const text = next ? '启用' : '停用';
  try {
    await confirm(`确认要${text}自动生成吗?`);
  } catch {
    return false;
  }
  await updateBarcodeConfig(row);
  await updateBarcodeConfig({ ...row, autoGenerateFlag: next });
  message.success(`${text}成功`);
  return true;
}
src/views/wls/barcode/data.ts
@@ -609,6 +609,7 @@
/** 配置列表的字段 */
export function useConfigGridColumns(
  onAutoGenerateChange: (
    newVal: number | boolean,
    row: MesWmBarcodeConfigApi.BarcodeConfig,
  ) => Promise<boolean>,
): VxeTableGridOptions<MesWmBarcodeConfigApi.BarcodeConfig>['columns'] {