ezhizao_zx 11 months ago
parent
commit
f3015cdc89
1 changed files with 16 additions and 167 deletions
  1. 16 167
      src/views/business/firstOutsource/form.vue

+ 16 - 167
src/views/business/firstOutsource/form.vue

@@ -132,7 +132,7 @@
             <el-table-column label="箱数" align="center" prop="carrierNum" width="100">
             <el-table-column label="箱数" align="center" prop="carrierNum" width="100">
               <template #default="scope">
               <template #default="scope">
                 <el-input-number v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" :min="0"
                 <el-input-number v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" :min="0"
-                  v-model="scope.row.carrierNum" :controls="false" placeholder="箱数" />
+                  v-model="scope.row.carrierNum" :controls="false" placeholder="箱数" @blur="handleCarrierNumChange" />
                 <span v-else>{{ scope.row.carrierNum }}</span>
                 <span v-else>{{ scope.row.carrierNum }}</span>
               </template>
               </template>
             </el-table-column>
             </el-table-column>
@@ -296,16 +296,7 @@ function getForm() {
     });
     });
     form.value.details.forEach((item) => {
     form.value.details.forEach((item) => {
       item.editStatus = false;
       item.editStatus = false;
-      if (!form.value.id) {
-        item.carrierNum = item.originalCarrier.split(",").length;
-      } else {
-        if (item.newCarrier != null) {
-          item.carrierNum = item.newCarrier.split(",").length;
-        } else {
-          item.carrierNum = item.originalCarrier.split(",").length;
-        }
-      }
-      totalCarriersNum.value += item.carrierNum;
+      totalCarriersNum.value += item.carrierNum == null ? 0 : item.carrierNum;
     });
     });
 
 
     editStatus.value = form.value.isSubmit == 1;
     editStatus.value = form.value.isSubmit == 1;
@@ -343,13 +334,8 @@ function handleChangePackagingMethod() {
   }
   }
   console.log(form.value.details)
   console.log(form.value.details)
   for (let i = 0; i < form.value.details.length; i++) {
   for (let i = 0; i < form.value.details.length; i++) {
-    if (form.value.packagingMethod == 1) {
-      form.value.details[i].carrierNum = form.value.details[i].newCarriers ? form.value.details[i].newCarriers.length : 0
-    } else {
-      form.value.details[i].carrierNum = form.value.details[i].newCarriers && form.value.details[i].newCarriers.length > 0 ? form.value.details[i].newCarriers.length : form.value.details[i].originalCarrier.split(",").length
-    }
     console.log(form.value.details)
     console.log(form.value.details)
-    totalCarriersNum.value += form.value.details[i].carrierNum
+    totalCarriersNum.value += form.value.details[i].carrierNum == null ? 0 : form.value.details[i].carrierNum
   }
   }
 }
 }
 //改变送货方式
 //改变送货方式
@@ -379,7 +365,7 @@ function cancel() {
 }
 }
 
 
 const handleDelete = (index) => {
 const handleDelete = (index) => {
-  totalCarriersNum.value -= form.value.details[index].carrierNum;
+  totalCarriersNum.value -= (form.value.details[index].carrierNum == null ? 0 : form.value.details[index].carrierNum);
   if (form.value.deliveryMethod == 1) {
   if (form.value.deliveryMethod == 1) {
     form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
     form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
   } else {
   } else {
@@ -507,14 +493,10 @@ function handleSubmit() {
               return;
               return;
             }
             }
           }
           }
-          if (form.value.packagingMethod == 1) {
-            console.log("form.value.details", form.value.details);
-            for (const item of form.value.details) {
-              if (item.newCarriers.length == 0) {
-                proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
-                return;
-              }
-            }
+          // 判断是否有批次没有炉号
+          const unfurnace = form.value.details.find(v => v.furnaceNoInfo == null)
+          if (unfurnace != null) {
+            proxy.$modal.msgError("请选择" + unfurnace.lotCode + "批次的炉号")
           }
           }
           if (valid) {
           if (valid) {
             console.log(form.value)
             console.log(form.value)
@@ -611,147 +593,6 @@ const handleMultipleSelectedProducts = (selection) => {
 
 
 };
 };
 
 
-/***************************** 外协箱子对话框相关 *****************************/
-// 打开外协箱子选择对话框
-const handleShowDialogOutsourceCarriers = (row) => { };
-
-function remoteCarriers(code, newCarrier, row) {
-  loadingCarrier.value = true;
-  // console.log(row, carriers.value)
-  console.log("row", row);
-  // if (true) {
-  //   carriers.value = [{ value: '"1747500987856662535"', label: '000319' }]
-  //   return
-  // }
-  let categoryId;
-  if (form.value.packagingMethod == 1) {
-    categoryId = "1783783697558847489";
-  } else {
-    categoryId = "2";
-  }
-  if (code == "") {
-    return;
-  }
-  carrierForOutsource({
-    categoryId: categoryId,
-    code: code,
-    dayworkId: row.dayworkId
-  }).then((res) => {
-    if (res.code === 200) {
-      carriers.value = res.rows.map((v) => ({ value: v.id, label: v.code }));
-      row.carriers = res.rows.map((v) => ({ value: v.id, label: v.code }));
-      if (Array.isArray(newCarrier)) {
-        // 安全地更新 carriers
-        row.carriers.push(
-          ...newCarrier
-            .filter((v) => !row.carriers.map((e) => e.value).includes(v.id))
-            .map((v) => ({ value: v.id, label: v.code }))
-        );
-      }
-    } else {
-      row.carriers = [];
-      row.carriers.push(...newCarrier);
-    }
-    loadingCarrier.value = false;
-  });
-}
-//换箱
-function handleChangeCarrier(row) {
-  console.log(row);
-  if (editStatus.value && !form.value.id) {
-    if (form.value.packagingMethod == 0) {
-      row.newCarriers.push(
-        ...row.originalCarrierList.map((v) => ({
-          id: v.carrierId,
-          code: v.carrierCode,
-        }))
-      );
-      row.carriers.push(
-        ...row.originalCarrierList.map((v) => ({
-          value: v.carrierId,
-          label: v.carrierCode,
-        }))
-      );
-      row.carrierIds = row.originalCarrierList.map((info) => {
-        return info.carrierId;
-      });
-    } else {
-      row.newCarriers = null;
-    }
-  }
-  if (editStatus.value && form.value.id) {
-    row.carriers = [];
-    row.newCarriers.map((v) => ({ id: v.value, code: v.label }));
-    console.log(row.newCarriers);
-    row.carriers = row.newCarriers.map((v) => ({ value: v.id, label: v.code }));
-    row.carrierIds = row.newCarriers.map((info) => {
-      return info.id;
-    });
-    console.log(row);
-  }
-  row.editStatus = true;
-}
-function handleCarrierChange(arg, item) {
-  totalCarriersNum.value = 0;
-  item.newCarriers = item.carriers
-    .filter((v) => arg.includes(v.value))
-    .map((v) => ({ id: v.value, code: v.label }));
-  console.log(item.newCarriers);
-  item.carrierNum = item.newCarriers.length;
-
-  for (let i = 0; i < form.value.details.length; i++) {
-    if (form.value.packagingMethod == 1) {
-      form.value.details[i].carrierNum = form.value.details[i].newCarriers
-        ? form.value.details[i].newCarriers.length
-        : 0;
-    } else {
-      //原厂蓝箱
-      form.value.details[i].carrierNum = form.value.details[i].newCarriers
-        ? form.value.details[i].newCarriers.length
-        : form.value.details[i].originalCarrier.split(",").length;
-    }
-    console.log(form.value.details);
-    totalCarriersNum.value += form.value.details[i].carrierNum;
-  }
-  if (form.value.deliveryMethod == 1) {
-    form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
-  } else {
-    form.value.freightAmount = 0.0;
-  }
-}
-
-/** 使用新方式 */
-// const handleShowDialogOutsourceCarriers = (row) => {
-//   // 确保 form.details 存在且不是 undefined
-//   let allNewCarriers;
-//   if (form.value && form.value.details && Array.isArray(form.value.details)) {
-//     allNewCarriers = form.value.details
-//       .flatMap((detail) =>
-//         detail.newCarriers ? detail.newCarriers.filter((item) => item) : []
-//       )
-//       .filter(Boolean);
-
-//     // 现在 allNewCarriers 包含了所有非空的 newCarriers 数组的元素
-//   }
-//   // form.value.details.newCarriers
-//   // const allNewCarriers = form.details.flatMap((detail) => detail.newCarriers);
-//   console.log("allNewCarriers", allNewCarriers);
-//   proxy.$refs.dialogCarrierRef.open(row.lotId, from.value.deliveryMethod);
-// };
-
-// 箱子选择带回
-const handleMultipleSelectedOutsourceCarriers = (selection, lotId) => {
-  const carrierNames = selection.map((item) => item.code);
-  let carrierNamesString = carrierNames.join(",");
-  form.value.details.map((item) => {
-    if (item.lotId == lotId) {
-      item.newCarrier = carrierNamesString;
-      item.newCarrierCount = selection.length;
-      item.newCarriers = selection;
-    }
-  });
-};
-
 /***************************** 外协工序对话框相关 *****************************/
 /***************************** 外协工序对话框相关 *****************************/
 // 打开外协工序选择对话框
 // 打开外协工序选择对话框
 const handleShowDialogProcesses = (row) => {
 const handleShowDialogProcesses = (row) => {
@@ -810,6 +651,14 @@ const handleSingleSelectFurnaceNoInfo = (details, info) => {
   })
   })
 }
 }
 
 
+function handleCarrierNumChange() {
+  let sumNum = 0
+  form.value.details.forEach(v => {
+    sumNum += (v.carrierNum == null ? 0 : v.carrierNum)
+  })
+  totalCarriersNum.value = sumNum
+}
+
 /** 暴露给父组件的方法 */
 /** 暴露给父组件的方法 */
 defineExpose({
 defineExpose({
   open,
   open,