瀏覽代碼

fix: 补货操作replenishItems数组越界导致Cannot read property quantity错误

- 移除.filter()确保replenishItems与inventoryList长度一致
- 无product_id的项填充空对象而非从数组中删除
- 修复https://github.com/... issues

Co-Authored-By: Claude <noreply@anthropic.com>
skyline 14 小時之前
父節點
當前提交
bc76089f12
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      haha-admin-mp/src/pages/replenish/operation.vue

+ 6 - 2
haha-admin-mp/src/pages/replenish/operation.vue

@@ -188,7 +188,9 @@ const loadOrderItems = async (oid: string) => {
 
     // 重新匹配库存并更新数量
     const list = inventoryList.value;
-    replenishItems.value = list.filter((it: any) => it.product_id || it.productId).map((it: any) => {
+    replenishItems.value = list.map((it: any) => {
+      const hasProduct = it.product_id || it.productId;
+      if (!hasProduct) return { productId: null, productCode: '', productName: '', quantity: 0, shelfNum: null, position: null };
       const code = (it.product_code || it.productCode || '').trim();
       const m = items.find((oi: any) => oi.productCode.toUpperCase() === code.toUpperCase());
       return {
@@ -314,7 +316,9 @@ onMounted(async () => {
       }
     }
 
-    replenishItems.value = list.filter((it: any) => it.product_id || it.productId).map((it: any) => {
+    replenishItems.value = list.map((it: any) => {
+      const hasProduct = it.product_id || it.productId;
+      if (!hasProduct) return { productId: null, productCode: '', productName: '', quantity: 0, shelfNum: null, position: null };
       const code = (it.product_code || it.productCode || '').trim();
       const m = orderItems.find((oi: any) => oi.productCode.toUpperCase() === code.toUpperCase());
       return {