Browse Source

Merge remote-tracking branch 'origin/master'

guoyujia 1 năm trước cách đây
mục cha
commit
4f8d848683
1 tập tin đã thay đổi với 46 bổ sung26 xóa
  1. 46 26
      src/views/business/daywork/form.vue

+ 46 - 26
src/views/business/daywork/form.vue

@@ -482,7 +482,6 @@ function reset() {
 
 /** 提交按钮 */
 const handleSave = () => {
-  const max = maxQuailifiedNum.value;
   proxy.$refs["dayworkItemRef"].validate((valid) => {
     if (valid) {
       rejectAmount.value = 0;
@@ -517,6 +516,7 @@ const handleSave = () => {
         if (!form.value.groupRejectList[i].reason) {
           flag = false;
           proxy.$modal.msgError("第" + (i + 1) + "行废品原因不能为空");
+
           return;
         }
         if (reasonList.indexOf(form.value.groupRejectList[i].reason) >= 0) {
@@ -559,39 +559,59 @@ const handleSave = () => {
         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)) {
+        const max = maxQuailifiedNum.value;
+        //判断是否超过最大合格量
+        if (form.value.qualifiedNum > max) {
+          //判断是否为首序
+          if (detailInfo.value.firstProcessId == form.value.processId) {
+            let sunm =
+              detailInfo.value.totalQuailifiedNum + form.value.qualifiedNum; //计算总合格数
+            let num = sunm - form.value.prodNum; //多出来的数量
+            let percent = ((sunm / form.value.prodNum) * 100).toFixed(2); //合格率
+            // 弹出确认对话框
+            proxy.$modal
+              .confirm(
+                "合格数为投产量" +
+                  percent +
+                  "%,超出投产量" +
+                  num +
+                  "。 是否继续保存!"
+              )
+              .then(function () {
+                updateDayworkItem();
+              })
+              .then(() => {
+                return;
+              })
+              .catch(() => {
+                return;
+              });
           } else {
-            return;
+            proxy.$modal.msgError(
+              "合格数不能超过投产量的103%,最大合格数为" + max
+            );
           }
+        } else {
+          updateDayworkItem();
         }
-        // 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("保存失败!");
-        //   }
-        // });
       }
     }
   });
 };
 
+//页面提交方法
+function updateDayworkItem() {
+  updateDayworkItemInfo(form.value).then((res) => {
+    if (res.code == 200) {
+      proxy.$modal.msgSuccess("保存成功!");
+      visible.value = false;
+      emit("handleSaveSuccess");
+    } else {
+      proxy.$modal.msgError("保存失败!");
+    }
+  });
+}
+
 //删除废弃信息
 function handleDeleteReject(row) {
   form.value.groupRejectList.splice(form.value.groupRejectList.indexOf(row), 1);