From e1b1a29203de502457d8ede2508ba1fa2c55db47 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 27 四月 2026 14:41:53 +0800
Subject: [PATCH] 1

---
 src/views/productionManagement/workOrderManagement/index.vue |  166 ++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 120 insertions(+), 46 deletions(-)

diff --git a/src/views/productionManagement/workOrderManagement/index.vue b/src/views/productionManagement/workOrderManagement/index.vue
index 6def04c..a9610e3 100644
--- a/src/views/productionManagement/workOrderManagement/index.vue
+++ b/src/views/productionManagement/workOrderManagement/index.vue
@@ -1,3 +1,4 @@
+// 鐢熶骇鎶ュ伐
 <template>
   <div class="app-container">
     <div class="search_form">
@@ -28,6 +29,15 @@
           <el-progress :percentage="toProgressPercentage(row?.completionStatus)"
                        :color="progressColor(toProgressPercentage(row?.completionStatus))"
                        :status="toProgressPercentage(row?.completionStatus) >= 100 ? 'success' : ''" />
+        </template>
+        <template #todayReportState="{ row }">
+          <el-tag :type="todayReportStateTagType(row?.todayReportState)"
+                  size="small">
+            {{ formatTodayReportState(row?.todayReportState) }}
+          </el-tag>
+        </template>
+        <template #totalReportDurationMinutes="{ row }">
+          {{ formatDurationHours(row?.totalReportDurationMinutes) }}
         </template>
       </PIMTable>
     </div>
@@ -110,7 +120,7 @@
     
     <!-- 鎶ュ伐寮圭獥 -->
     <el-dialog v-model="reportDialogVisible"
-               title="鎶ュ伐"
+               :title="reportDialogTitle"
                width="500px">
       <el-form ref="reportFormRef"
                :model="reportForm"
@@ -121,7 +131,8 @@
                     readonly
                     style="width: 300px" />
         </el-form-item>
-        <el-form-item label="鏈鐢熶骇鏁伴噺"
+        <el-form-item v-if="currentReportState !== 1"
+                      label="鏈鐢熶骇鏁伴噺"
                       prop="quantity">
           <el-input v-model.number="reportForm.quantity"
                     type="number"
@@ -131,7 +142,8 @@
                     placeholder="璇疯緭鍏ユ湰娆$敓浜ф暟閲�"
                     @input="handleQuantityInput" />
         </el-form-item>
-        <el-form-item label="鎶ュ簾鏁伴噺"
+        <el-form-item v-if="currentReportState !== 1"
+                      label="鎶ュ簾鏁伴噺"
                       prop="scrapQty">
           <el-input v-model.number="reportForm.scrapQty"
                     type="number"
@@ -176,6 +188,7 @@
     productWorkOrderPage,
     addProductMain,
     downProductWorkOrder,
+    reportState,
   } from "@/api/productionManagement/workOrder.js";
   import { getUserProfile, userListNoPageByTenantId } from "@/api/system/user.js";
   import QRCode from "qrcode";
@@ -188,6 +201,13 @@
       label: "宸ュ崟绫诲瀷",
       prop: "workOrderType",
       width: "80",
+    },
+    {
+      label: "鎶ュ伐鐘舵��",
+      prop: "todayReportState",
+      dataType: "slot",
+      slot: "todayReportState",
+      width: "110",
     },
     {
       label: "宸ュ崟缂栧彿",
@@ -232,6 +252,18 @@
       dataType: "slot",
       slot: "completionStatus",
       width: "140",
+    },
+    {
+      label: "璁″垝宸ユ椂(灏忔椂)",
+      prop: "salaryQuota",
+      width: "140",
+    },
+    {
+      label: "绯荤粺鏍哥畻鏃堕棿(灏忔椂)",
+      prop: "totalReportDurationMinutes",
+      dataType: "slot",
+      slot: "totalReportDurationMinutes",
+      width: "160",
     },
     {
       label: "璁″垝寮�濮嬫椂闂�",
@@ -290,6 +322,8 @@
   const transferCardQrUrl = ref("");
   const transferCardRowData = ref(null);
   const reportDialogVisible = ref(false);
+  const currentReportState = ref(2);
+  const reportDialogTitle = ref("鎶ュ伐");
   const workOrderFilesRef = ref(null);
   const reportFormRef = ref(null);
   const userOptions = ref([]);
@@ -422,6 +456,25 @@
     if (p < 80) return "#409eff";
     return "#67c23a";
   };
+  const formatTodayReportState = val => {
+    const state = Number(val);
+    if (state === 1) return "鏈紑濮�";
+    if (state === 2) return "宸插紑濮�";
+    if (state === 3) return "宸茬粨鏉�";
+    return "-";
+  };
+  const formatDurationHours = val => {
+    const minutes = Number(val);
+    if (!Number.isFinite(minutes) || minutes < 0) return "-";
+    return (minutes / 60).toFixed(2);
+  };
+  const todayReportStateTagType = val => {
+    const state = Number(val);
+    if (state === 1) return "info";
+    if (state === 2) return "success";
+    if (state === 3) return "warning";
+    return "info";
+  };
 
   // 鏌ヨ鍒楄〃
   /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -438,7 +491,7 @@
   
   const getList = () => {
     tableLoading.value = true;
-    const params = { ...searchForm.value, ...page };
+    const params = { ...searchForm.value, ...page, type: 2 };
     productWorkOrderPage(params)
       .then(res => {
         tableLoading.value = false;
@@ -518,7 +571,7 @@
     workOrderFilesRef.value?.openDialog(row);
   };
 
-  const showReportDialog = row => {
+  const showReportDialog = async row => {
     currentReportRowData.value = row;
     reportForm.planQuantity = row.planQuantity;
     reportForm.quantity =
@@ -532,6 +585,23 @@
     nextTick(() => {
       reportFormRef.value?.clearValidate();
     });
+    try {
+      const reportStateRes = await reportState({
+        workOrderId: row.id,
+        productProcessRouteItemId: row.productProcessRouteItemId,
+      });
+      const state = reportStateRes?.data?.state;
+      currentReportState.value = state === 1 ? 1 : 2;
+      reportDialogTitle.value = currentReportState.value === 1 ? "寮�濮嬫姤宸�" : "缁撴潫鎶ュ伐";
+      if (currentReportState.value === 1) {
+        reportForm.quantity = null;
+        reportForm.scrapQty = null;
+      }
+    } catch (error) {
+      currentReportState.value = 2;
+      reportDialogTitle.value = "缁撴潫鎶ュ伐";
+      console.error("鑾峰彇鎶ュ伐鐘舵�佸け璐�", error);
+    }
     // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛淇℃伅锛岃缃负榛樿閫変腑
     getUserProfile()
       .then(res => {
@@ -560,48 +630,52 @@
         return;
       }
 
-      // 楠岃瘉鏈鐢熶骇鏁伴噺
-      if (
-        reportForm.quantity === null ||
-        reportForm.quantity === undefined ||
-        reportForm.quantity === ""
-      ) {
-        ElMessageBox.alert("璇疯緭鍏ユ湰娆$敓浜ф暟閲�", "鎻愮ず", {
-          confirmButtonText: "纭畾",
-        });
-        return;
-      }
+      let quantity = 0;
+      let scrapQty = 0;
+      if (currentReportState.value !== 1) {
+        // 楠岃瘉鏈鐢熶骇鏁伴噺
+        if (
+          reportForm.quantity === null ||
+          reportForm.quantity === undefined ||
+          reportForm.quantity === ""
+        ) {
+          ElMessageBox.alert("璇疯緭鍏ユ湰娆$敓浜ф暟閲�", "鎻愮ず", {
+            confirmButtonText: "纭畾",
+          });
+          return;
+        }
 
-      const quantity = Number(reportForm.quantity);
+        quantity = Number(reportForm.quantity);
 
-      if (isNaN(quantity) || quantity <= 0) {
-        ElMessageBox.alert("鏈鐢熶骇鏁伴噺蹇呴』澶т簬0", "鎻愮ず", {
-          confirmButtonText: "纭畾",
-        });
-        return;
-      }
+        if (isNaN(quantity) || quantity <= 0) {
+          ElMessageBox.alert("鏈鐢熶骇鏁伴噺蹇呴』澶т簬0", "鎻愮ず", {
+            confirmButtonText: "纭畾",
+          });
+          return;
+        }
 
-      if (quantity > reportForm.planQuantity) {
-        ElMessageBox.alert("鏈鐢熶骇鏁伴噺涓嶈兘瓒呰繃寰呯敓浜ф暟閲�", "鎻愮ず", {
-          confirmButtonText: "纭畾",
-        });
-        return;
-      }
+        if (quantity > reportForm.planQuantity) {
+          ElMessageBox.alert("鏈鐢熶骇鏁伴噺涓嶈兘瓒呰繃寰呯敓浜ф暟閲�", "鎻愮ず", {
+            confirmButtonText: "纭畾",
+          });
+          return;
+        }
 
-      // 楠岃瘉鎶ュ簾鏁伴噺
-      const scrapQty = Number(reportForm.scrapQty);
-      if (!isNaN(scrapQty) && scrapQty < 0) {
-        ElMessageBox.alert("鎶ュ簾鏁伴噺涓嶈兘灏忎簬0", "鎻愮ず", {
-          confirmButtonText: "纭畾",
-        });
-        return;
-      }
+        // 楠岃瘉鎶ュ簾鏁伴噺
+        scrapQty = Number(reportForm.scrapQty);
+        if (!isNaN(scrapQty) && scrapQty < 0) {
+          ElMessageBox.alert("鎶ュ簾鏁伴噺涓嶈兘灏忎簬0", "鎻愮ず", {
+            confirmButtonText: "纭畾",
+          });
+          return;
+        }
 
-      if (!isNaN(scrapQty) && scrapQty > quantity) {
-        ElMessageBox.alert("鎶ュ簾鏁伴噺涓嶈兘澶т簬鏈鐢熶骇鏁伴噺", "鎻愮ず", {
-          confirmButtonText: "纭畾",
-        });
-        return;
+        if (!isNaN(scrapQty) && scrapQty > quantity) {
+          ElMessageBox.alert("鎶ュ簾鏁伴噺涓嶈兘澶т簬鏈鐢熶骇鏁伴噺", "鎻愮ず", {
+            confirmButtonText: "纭畾",
+          });
+          return;
+        }
       }
 
       const params = {
@@ -617,14 +691,13 @@
 
       addProductMain(params)
         .then(res => {
-          proxy.$modal.msgSuccess("鎶ュ伐鎴愬姛");
+          proxy.$modal.msgSuccess(
+            currentReportState.value === 1 ? "寮�濮嬫姤宸ユ垚鍔�" : "缁撴潫鎶ュ伐鎴愬姛"
+          );
           reportDialogVisible.value = false;
           getList();
         })
         .catch(() => {
-          ElMessageBox.alert("鎶ュ伐澶辫触", "鎻愮ず", {
-            confirmButtonText: "纭畾",
-          });
         });
     });
   };
@@ -704,6 +777,7 @@
     text-align: center;
     margin-top: 20px;
   }
+
 </style>
 
 <style  lang="scss">

--
Gitblit v1.9.3