From 3170982ed5683650e623e1a14b80c60256e8288d Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期二, 28 四月 2026 16:01:17 +0800
Subject: [PATCH] 先排产 排产根据机台绑定生产人 报工根据生产排产选择的生产人来选择对应的报工人

---
 src/views/productionManagement/workOrder/index.vue |   80 ++++++++++++++++++++++++++++++++-------
 1 files changed, 65 insertions(+), 15 deletions(-)

diff --git a/src/views/productionManagement/workOrder/index.vue b/src/views/productionManagement/workOrder/index.vue
index 2b56480..20c3cf8 100644
--- a/src/views/productionManagement/workOrder/index.vue
+++ b/src/views/productionManagement/workOrder/index.vue
@@ -441,6 +441,7 @@
 import {ElMessageBox, ElMessage} from "element-plus";
 import Pagination from "@/components/PIMTable/Pagination.vue";
 import dayjs from "dayjs";
+import { processList } from '@/api/productionManagement/productionProcess.js'
 import {
   productWorkOrderPage,
   updateProductWorkOrder,
@@ -1014,9 +1015,14 @@
       {
         name: "鐢熶骇鎺掍骇",
         clickFun: row => {
+          if (!row.canSchedule) {
+            ElMessage.warning("褰撳墠鐢ㄦ埛涓嶅湪璇ュ伐搴忎汉鍛樹腑锛屼笉鑳界敓浜ф帓浜�");
+            return;
+          }
           openScheduleDialog(row);
         },
-      },
+        disabled: row => !row.canSchedule
+      }
       // {
       //   name:"瀹℃牳",
       //   color: "#f56c6c",
@@ -1260,18 +1266,27 @@
   page.size = obj.limit;
   getList();
 };
-const getList = () => {
+const getList = async () => {
   tableLoading.value = true;
-  const params = {...searchForm.value, ...page};
-  productWorkOrderPage(params)
-      .then(res => {
-        tableLoading.value = false;
-        tableData.value = res.data.records;
-        page.total = res.data.total;
-      })
-      .catch(() => {
-        tableLoading.value = false;
-      });
+
+  try {
+    await ensureCurrentUser();
+    await processLists();
+
+    const params = { ...searchForm.value, ...page };
+    const res = await productWorkOrderPage(params);
+
+    const records = Array.isArray(res?.data?.records) ? res.data.records : [];
+
+    tableData.value = records.map(row => ({
+      ...row,
+      canSchedule: canScheduleByWorkOrderNo(row)
+    }));
+
+    page.total = res?.data?.total || 0;
+  } finally {
+    tableLoading.value = false;
+  }
 };
 
 // 涓嬭浇骞舵墦鍗板伐鍗曟祦杞崱锛堟枃浠舵祦锛�
@@ -1520,9 +1535,44 @@
   }
 }
 
-onMounted(() => {
-  ensureCurrentUser();
-  getList();
+const processData = ref([]);
+
+// 鏌ヨ鎵�鏈夊伐搴�
+const processLists = async () => {
+  console.log(processData.value)
+  if (processData.value.length > 0) {
+    return processData.value;
+  }
+  const res = await processList();
+
+  processData.value = Array.isArray(res?.data) ? res.data : [];
+  return processData.value;
+};
+
+// 鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁鑳芥帓浜�
+const canScheduleByWorkOrderNo = (row) => {
+  if (!row) return false;
+
+  const uid = String(currentUserId.value || "");
+  if (!uid) return false;
+
+  const currentProcess = processData.value.find(item =>
+      String(item.id) === String(row.processId)
+  );
+
+  if (!currentProcess) return false;
+
+  const ids = normalizeArray(currentProcess.userIds)
+      .map(id => String(id).trim())
+      .filter(Boolean);
+
+  return ids.includes(uid);
+};
+
+onMounted(async () => {
+  await ensureCurrentUser();
+  await processLists();
+  await getList();
   getUserList();
   getDeviceList();
 });

--
Gitblit v1.9.3