From a806a54c13a832b423d9cf1dfbe510a32ee63b30 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期四, 03 九月 2026 16:26:57 +0800
Subject: [PATCH] fix(仓储物流): 修复条码配置“自动生成”开关切换报500

---
 src/views/wls/barcode/data.ts          |    1 +
 src/views/wls/barcode/config/index.vue |   15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/views/wls/barcode/config/index.vue b/src/views/wls/barcode/config/index.vue
index b6cc804..1f00587 100644
--- a/src/views/wls/barcode/config/index.vue
+++ b/src/views/wls/barcode/config/index.vue
@@ -22,17 +22,26 @@
   destroyOnClose: true,
 });
 
-/** 鑷姩鐢熸垚寮�鍏冲彉鏇� */
+/**
+ * 鑷姩鐢熸垚寮�鍏冲彉鏇�
+ *
+ * 娉ㄦ剰锛欳ellSwitch 鐨� 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;
 }
diff --git a/src/views/wls/barcode/data.ts b/src/views/wls/barcode/data.ts
index dfd288c..c34a07b 100644
--- a/src/views/wls/barcode/data.ts
+++ b/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'] {

--
Gitblit v1.9.3