Browse Source

采购调整

lxf 1 year ago
parent
commit
a5a5c4d958
1 changed files with 24 additions and 4 deletions
  1. 24 4
      src/components/process/purchase.vue

+ 24 - 4
src/components/process/purchase.vue

@@ -96,7 +96,11 @@
                 <div>{{ moneyFormat(Number(Math.round(((row.unitPrice * 100) / (100 + row.taxRate)) * 100) / 100)) }}</div>
               </template>
             </el-table-column>
-            <el-table-column label="可采购数量" prop="quantity" width="100" />
+            <el-table-column label="可采购数量" width="100">
+              <template #default="{ row }">
+                {{ Number(Math.round(row.quantity - row.purchasedQuantity - row.frozenQuantity)) }}
+              </template>
+            </el-table-column>
             <el-table-column label="采购数量" width="120">
               <template #default="{ row, $index }">
                 <el-form-item
@@ -112,7 +116,6 @@
                     style="width: 100%"
                     :controls="false"
                     :min="0"
-                    :max="row.quantity"
                     :precision="0" />
                 </el-form-item>
               </template>
@@ -131,11 +134,11 @@
                 </div>
               </template>
             </el-table-column>
-            <!-- <el-table-column label="操作" align="center" fixed="right" width="60">
+            <el-table-column label="操作" align="center" fixed="right" width="60">
               <template #default="{ $index }">
                 <el-button type="danger" @click="clickDelete($index)" text>删除</el-button>
               </template>
-            </el-table-column> -->
+            </el-table-column>
           </el-table>
         </div>
       </template>
@@ -472,6 +475,19 @@ const handleSubmit = async (flag) => {
       if (!(formData.data.purchaseBomList && formData.data.purchaseBomList.length > 0)) {
         ElMessage("请添加采购清单");
         return false;
+      } else {
+        for (let i = 0; i < formData.data.purchaseBomList.length; i++) {
+          if (
+            Number(
+              Math.round(
+                formData.data.purchaseBomList[i].quantity - formData.data.purchaseBomList[i].purchasedQuantity - formData.data.purchaseBomList[i].frozenQuantity
+              )
+            ) < formData.data.purchaseBomList[i].purchaseQuantity
+          ) {
+            ElMessage("采购数量不能大于可采购数量");
+            return false;
+          }
+        }
       }
       return true;
     } else {
@@ -504,6 +520,8 @@ watch(
               for (let j = 0; j < res.applyBuyBomList.length; j++) {
                 if (formData.data.purchaseBomList[i].applyBuyBomId === res.applyBuyBomList[j].id) {
                   formData.data.purchaseBomList[i].quantity = res.applyBuyBomList[j].quantity;
+                  formData.data.purchaseBomList[i].purchasedQuantity = res.applyBuyBomList[j].purchaseQuantity;
+                  formData.data.purchaseBomList[i].frozenQuantity = res.applyBuyBomList[j].frozenQuantity;
                 }
               }
             }
@@ -535,6 +553,8 @@ onMounted(() => {
             bomSpecWidth: item.bomSpecWidth,
             bomSpecHeight: item.bomSpecHeight,
             quantity: item.quantity,
+            purchasedQuantity: item.purchaseQuantity,
+            frozenQuantity: item.frozenQuantity,
           };
         });
       }