Bladeren bron

单批单改

wangxin 1 jaar geleden
bovenliggende
commit
f58fc75b5d
1 gewijzigde bestanden met toevoegingen van 43 en 31 verwijderingen
  1. 43 31
      src/views/business/daywork/form.vue

+ 43 - 31
src/views/business/daywork/form.vue

@@ -262,6 +262,7 @@ import {
   getDayworkItemRejectList,
   updateDayworkItemInfo,
   getEquipmentInfo,
+  getIsFirstOrder,
 } from "@/api/business/daywork.js";
 
 const { proxy } = getCurrentInstance();
@@ -274,6 +275,7 @@ const { waste_causes } = proxy.useDict("waste_causes");
 const detailInfo = ref({});
 const loading = ref(false);
 const processList = ref([]);
+const lotId = ref(null);
 const equipmentList = ref([]);
 const visible = ref(false);
 const editStatus = ref(true);
@@ -305,11 +307,16 @@ const validateQualifiedNum = (rule, value, callback) => {
   const max = maxQuailifiedNum.value;
   if (value < 0) {
     callback(new Error("合格数量应大于/等于0"));
-  } else if (value > max && detailInfo.value.firstProcessId != form.value.processId) {
-    callback(new Error("合格数量不应大于投产量的103%,即" + max));
   } else {
     callback();
   }
+
+  // else if (
+  //   value > max &&
+  //   detailInfo.value.firstProcessId != form.value.processId
+  // ) {
+  //   callback(new Error("合格数量不应大于投产量的103%,即" + max));
+  // }
 };
 const validateEndTime = (rule, value, callback) => {
   if (form.value.status > 1) {
@@ -375,10 +382,12 @@ const open = (row) => {
   reset();
   loading.value = true;
   if (row.id) {
+    lotId.value = row.lotId;
     //页面操作是编辑还是删除
+    console.log("row", row);
     editStatus.value = row.editStatus;
     detailInfo.value = proxy.deepClone(row);
-    console.log(detailInfo.value)
+    console.log(detailInfo.value);
     //是否是当前工序
     currentDept.value = row.currentDept;
     form.value.id = row.id;
@@ -473,6 +482,7 @@ function reset() {
 
 /** 提交按钮 */
 const handleSave = () => {
+  const max = maxQuailifiedNum.value;
   proxy.$refs["dayworkItemRef"].validate((valid) => {
     if (valid) {
       rejectAmount.value = 0;
@@ -497,16 +507,6 @@ const handleSave = () => {
         flag = false;
         proxy.$modal.msgError("该道序状态已有工序已完成");
       }
-      // if (form.value.status <= 1) {
-      //   if (form.value.qualifiedNum > 0) {
-      //     flag = false;
-      //     proxy.$modal.msgError("该状态合格数应为0");
-      //   }
-      //   if (form.value.groupRejectList.length > 0) {
-      //     flag = false;
-      //     proxy.$modal.msgError("废品信息应为空");
-      //   }
-      // } else {
       for (let i = 0; i < form.value.groupRejectList.length; i++) {
         rejectAmount.value += form.value.groupRejectList[i].rejectNum;
         if (form.value.groupRejectList[i].rejectNum <= 0) {
@@ -538,17 +538,7 @@ const handleSave = () => {
           "废品总数不能超过投产数,当前废品总数为" + rejectAmount.value
         );
       }
-      // else {
-      //   if (parseInt(form.value.prodNum) - rejectAmount.value < 0) {
-      //     proxy.$modal.msgError("废品总数加合格数不能超过投产数");
-      //     form.value.qualifiedNum = 0;
-      //   }
-      // }
-      // }
-      //workinghours
-      // if (form.value.status == 0 || form.value.status == 1) {
-      //   form.value.workHoursTimestamp = 0;
-      // }
+
       form.value.workingHours = form.value.workHoursTimestamp;
       //设备id和code
       for (let i = 0; i < equipmentList.value.length; i++) {
@@ -566,15 +556,37 @@ const handleSave = () => {
           form.value.dayworkId = detailInfo.value.dayworkId;
           form.value.flag = true;
         }
-        updateDayworkItemInfo(form.value).then((res) => {
-          if (res.code == 200) {
-            proxy.$modal.msgSuccess("保存成功!");
-            visible.value = false;
-            emit("handleSaveSuccess");
+        let data = form.value;
+        data.lotId = lotId.value;
+
+        console.log("qualifiedNum", form.value.qualifiedNum, "max", max);
+        console.log(
+          "firstProcessId",
+          detailInfo.value.firstProcessId,
+          "processId",
+          form.value.processId
+        );
+        if (
+          form.value.qualifiedNum > max &&
+          detailInfo.value.firstProcessId == form.value.processId
+        ) {
+          let num = form.value.qualifiedNum - max; //prodNum
+          // 弹出确认对话框
+          if (confirm("合格数量不应大于投产量的" + num)) {
           } else {
-            proxy.$modal.msgError("保存失败!");
+            return;
           }
-        });
+        }
+        // getIsFirstOrder(data).then((res) => {});
+        // updateDayworkItemInfo(form.value).then((res) => {
+        //   if (res.code == 200) {
+        //     proxy.$modal.msgSuccess("保存成功!");
+        //     visible.value = false;
+        //     emit("handleSaveSuccess");
+        //   } else {
+        //     proxy.$modal.msgError("保存失败!");
+        //   }
+        // });
       }
     }
   });