From 36b909e117c3ccc22dd266a94479e2a02335d261 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 26 三月 2026 18:03:34 +0800
Subject: [PATCH] 军泰伟业 1.生产订单新增编辑逻辑重写

---
 src/views/productionManagement/productionOrder/index.vue |  190 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 143 insertions(+), 47 deletions(-)

diff --git a/src/views/productionManagement/productionOrder/index.vue b/src/views/productionManagement/productionOrder/index.vue
index 51b42ac..8ba6699 100644
--- a/src/views/productionManagement/productionOrder/index.vue
+++ b/src/views/productionManagement/productionOrder/index.vue
@@ -3,32 +3,8 @@
     <div class="search_form">
       <el-form :model="searchForm"
                :inline="true">
-        <el-form-item label="瀹㈡埛鍚嶇О:">
-          <el-input v-model="searchForm.customerName"
-                    placeholder="璇疯緭鍏�"
-                    clearable
-                    prefix-icon="Search"
-                    style="width: 160px;"
-                    @change="handleQuery" />
-        </el-form-item>
-        <el-form-item label="鍚堝悓鍙�:">
-          <el-input v-model="searchForm.salesContractNo"
-                    placeholder="璇疯緭鍏�"
-                    clearable
-                    prefix-icon="Search"
-                    style="width: 160px;"
-                    @change="handleQuery" />
-        </el-form-item>
         <el-form-item label="浜у搧鍚嶇О:">
           <el-input v-model="searchForm.productCategory"
-                    placeholder="璇疯緭鍏�"
-                    clearable
-                    prefix-icon="Search"
-                    style="width: 160px;"
-                    @change="handleQuery" />
-        </el-form-item>
-        <el-form-item label="瑙勬牸:">
-          <el-input v-model="searchForm.specificationModel"
                     placeholder="璇疯緭鍏�"
                     clearable
                     prefix-icon="Search"
@@ -41,6 +17,8 @@
         </el-form-item>
       </el-form>
       <div>
+        <el-button type="primary" @click="isShowNewModal = true">鏂板</el-button>
+        <el-button type="danger" @click="handleDelete">鍒犻櫎</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
       </div>
     </div>
@@ -50,6 +28,9 @@
                 :tableData="tableData"
                 :page="page"
                 :tableLoading="tableLoading"
+                :row-class-name="tableRowClassName"
+                :isSelection="true"
+                @selection-change="handleSelectionChange"
                 @pagination="pagination">
         <template #completionStatus="{ row }">
           <el-progress
@@ -85,6 +66,11 @@
         </span>
       </template>
     </el-dialog>
+
+    <new-product-order v-if="isShowNewModal"
+                         v-model:visible="isShowNewModal"
+                         type="qualified"
+                         @completed="handleQuery" />
   </div>
 </template>
 
@@ -97,12 +83,17 @@
     productOrderListPage,
     listProcessRoute,
     bindingRoute,
-    listProcessBom,
+    listProcessBom, delProductOrder, startOrPause,
   } from "@/api/productionManagement/productionOrder.js";
   import { listMain as getOrderProcessRouteMain } from "@/api/productionManagement/productProcessRoute.js";
+  import {fileDel} from "@/api/financialManagement/revenueManagement.js";
+  import PIMTable from "@/components/PIMTable/PIMTable.vue";
+  const NewProductOrder = defineAsyncComponent(() => import("@/views/productionManagement/productionOrder/New.vue"));
+
   const { proxy } = getCurrentInstance();
 
   const router = useRouter();
+  const isShowNewModal = ref(false);
 
   const tableColumn = ref([
     {
@@ -111,24 +102,14 @@
       width: '120px',
     },
     {
-      label: "閿�鍞悎鍚屽彿",
-      prop: "salesContractNo",
-      width: '150px',
-    },
-    {
-      label: "瀹㈡埛鍚嶇О",
-      prop: "customerName",
-      width: '200px',
-    },
-    {
       label: "浜у搧鍚嶇О",
       prop: "productCategory",
       width: '120px',
     },
     {
-      label: "瑙勬牸",
+      label: "鍥剧焊缂栧彿",
       prop: "specificationModel",
-      width: '120px',
+      width: '160px',
     },
     {
       label: "宸ヨ壓璺嚎缂栧彿",
@@ -142,6 +123,10 @@
     {
       label: "瀹屾垚鏁伴噺",
       prop: "completeQuantity",
+    },
+    {
+      label: "搴撳瓨鏁伴噺",
+      prop: "inventoryQuantity",
     },
     {
       dataType: "slot",
@@ -163,12 +148,34 @@
       width: 120,
     },
     {
+      label: "浜や粯鏃ユ湡",
+      prop: "deliveryDate",
+      formatData: val => (val ? dayjs(val).format("YYYY-MM-DD") : ""),
+      width: 120,
+    },
+    {
       dataType: "action",
       label: "鎿嶄綔",
       align: "center",
       fixed: "right",
-      width: 200,
+      width: 240,
       operation: [
+        {
+          name: "寮�濮�",
+          type: "text",
+          showHide: row => row.status === '寰呯敓浜�',
+          clickFun: row => {
+            handleStartOrPause(row);
+          },
+        },
+        {
+          name: "鏆傚仠",
+          type: "text",
+          showHide: row => row.status === '鐢熶骇涓�',
+          clickFun: row => {
+            handleStartOrPause(row);
+          },
+        },
         {
           name: "宸ヨ壓璺嚎",
           type: "text",
@@ -185,7 +192,7 @@
           },
         },
         {
-          name: "浜у搧缁撴瀯",
+          name: "鐗╂枡娓呭崟",
           type: "text",
           clickFun: row => {
             showProductStructure(row);
@@ -201,14 +208,12 @@
     size: 100,
     total: 0,
   });
+  const selectedRows = ref([]);
 
   const data = reactive({
     searchForm: {
-      customerName: "",
-      salesContractNo: "",
       projectName: "",
       productCategory: "",
-      specificationModel: "",
     },
   });
   const { searchForm } = toRefs(data);
@@ -228,6 +233,25 @@
     if (p < 50) return "#e6a23c";
     if (p < 80) return "#409eff";
     return "#67c23a";
+  };
+
+  // 娣诲姞琛ㄨ绫诲悕鏂规硶
+  const tableRowClassName = ({ row }) => {
+    if (!row.deliveryDate) return '';
+    if (row.isFh) return '';
+
+    const diff = row.deliveryDaysDiff;
+    if (diff === undefined || diff === null || diff === '' || diff < 0) return '';
+    
+    if (diff === 15) {
+      return 'yellow';
+    } else if (diff === 10) {
+      return 'pink';
+    } else if (diff === 2) {
+      return 'purple';
+    } else if (diff < 2) {
+      return 'red';
+    }
   };
 
   // 缁戝畾宸ヨ壓璺嚎寮规
@@ -325,17 +349,19 @@
     const orderId = row.id;
     try {
       const res = await getOrderProcessRouteMain(orderId);
-      const data = res.data || {};
-      if (!data || !data.id) {
+      const dataList = res.data || [];
+      if (!dataList || dataList.length === 0 || !dataList[0].id) {
         proxy.$modal.msgWarning("鏈壘鍒板叧鑱旂殑宸ヨ壓璺嚎");
         return;
       }
+      const data = dataList[0];
       router.push({
         path: "/productionManagement/processRouteItem",
         query: {
           id: data.id,
           processRouteCode: data.processRouteCode || "",
           productName: data.productName || "",
+          drawingNumber: data.drawingNumber || "",
           model: data.model || "",
           bomNo: data.bomNo || "",
           description: data.description || "",
@@ -349,17 +375,70 @@
     }
   };
 
-  const showProductStructure = row => {
+  const handleStartOrPause = async (row) => {
+    const operation = row.status === '寰呯敓浜�' ? 1 : 2;
+    const operationText = operation === 1 ? "寮�濮�" : "鏆傚仠";
+    try {
+      await startOrPause({ id: row.id, operation });
+      proxy.$modal.msgSuccess(`${operationText}鎴愬姛`);
+      getList();
+    } catch (e) {
+      console.error(`${operationText}澶辫触锛歚, e);
+      proxy.$modal.msgError(`${operationText}澶辫触`);
+    }
+  };
+
+  const showProductStructure = async row => {
+    let bomNo = row.bomNo || "";
+    if (!bomNo && row.id) {
+      try {
+        const res = await getOrderProcessRouteMain(row.id);
+        const dataList = res.data || [];
+        if (dataList && dataList.length > 0 && dataList[0].bomNo) {
+          bomNo = dataList[0].bomNo;
+        }
+      } catch (e) {
+        console.error("鑾峰彇BOM缂栧彿澶辫触锛�", e);
+      }
+    }
     router.push({
       path: "/productionManagement/productStructureDetail",
       query: {
         id: row.id,
-        bomNo: row.bomNo || "",
+        bomNo: bomNo,
+        drawingNumber: row.drawingNumber || "",
         productName: row.productCategory || "",
         productModelName: row.specificationModel || "",
         orderId: row.id,
         type: "order",
       },
+    });
+  };
+
+  // 琛ㄦ牸閫夋嫨鏁版嵁
+  const handleSelectionChange = (selection) => {
+    selectedRows.value = selection;
+  };
+
+  const handleDelete = () => {
+    let ids = [];
+    if (selectedRows.value.length > 0) {
+      ids = selectedRows.value.map((item) => item.id);
+    } else {
+      proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+      return;
+    }
+    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+    }).then(() => {
+      delProductOrder(ids).then((res) => {
+        proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+        getList();
+      });
+    }).catch(() => {
+      proxy.$modal.msg("宸插彇娑�");
     });
   };
 
@@ -388,4 +467,21 @@
 <style scoped lang="scss">
 .search_form{
   align-items: start;
-}</style>
+}
+
+:deep(.yellow) {
+  background-color: #FAF0DE;
+}
+
+:deep(.pink) {
+  background-color: #FAE1DE;
+}
+
+:deep(.red) {
+  background-color: #FFCCCC;
+}
+
+:deep(.purple){
+  background-color: #F4DEFA;
+}
+</style>

--
Gitblit v1.9.3