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>
| | |
| | | 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; |
| | | } |
| | |
| | | /** 配置列表的字段 */ |
| | | export function useConfigGridColumns( |
| | | onAutoGenerateChange: ( |
| | | newVal: number | boolean, |
| | | row: MesWmBarcodeConfigApi.BarcodeConfig, |
| | | ) => Promise<boolean>, |
| | | ): VxeTableGridOptions<MesWmBarcodeConfigApi.BarcodeConfig>['columns'] { |