Преглед на файлове

快捷出库: 统计总数量

lxf преди 1 година
родител
ревизия
3de425eabc
променени са 1 файла, в които са добавени 37 реда и са изтрити 0 реда
  1. 37 0
      src/views/production/operation/batching/quick.vue

+ 37 - 0
src/views/production/operation/batching/quick.vue

@@ -25,6 +25,7 @@
         </template>
         <template #inOutStorageBomList>
           <div style="width: 100%; padding: 0 20px">
+            <div style="margin-bottom: 10px">{{ statisticalQuantity() }}</div>
             <el-table :data="inOutStorageBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
               <el-table-column label="BOM品号" prop="bomSpecCode" width="180" />
               <el-table-column label="BOM品名" prop="bomSpecName" min-width="220" />
@@ -155,6 +156,42 @@ const changeDepartment = () => {
     inOutStorageBomList.value = Object.freeze(res);
   });
 };
+const statisticalQuantity = () => {
+  let quantity = 0;
+  let material = {};
+  if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
+    let principal = formData.data.inOutStorageBomList.filter((item) => item.classifyParentId == "1");
+    if (principal && principal.length > 0) {
+      for (let j = 0; j < principal.length; j++) {
+        if (principal[j].outQuantity) {
+          quantity = Number(Math.round(quantity + principal[j].outQuantity));
+        }
+      }
+    }
+    let auxiliaryMaterial = formData.data.inOutStorageBomList.filter((item) => item.classifyParentId != "1");
+    if (auxiliaryMaterial && auxiliaryMaterial.length > 0) {
+      for (let i = 0; i < auxiliaryMaterial.length; i++) {
+        if (material[auxiliaryMaterial[i].classifyId]) {
+          material[auxiliaryMaterial[i].classifyId].quantity = Number(
+            Math.round(material[auxiliaryMaterial[i].classifyId].quantity + auxiliaryMaterial[i].outQuantity)
+          );
+        } else {
+          material[auxiliaryMaterial[i].classifyId] = {
+            name: auxiliaryMaterial[i].classifyName,
+            quantity: auxiliaryMaterial[i].outQuantity,
+          };
+        }
+      }
+    }
+  }
+  let text = "主材数量: " + quantity;
+  for (let key in material) {
+    if (key && material[key].name) {
+      text = text + ", " + material[key].name + ": " + material[key].quantity;
+    }
+  }
+  return text;
+};
 </script>
 
 <style lang="scss" scoped>