From 278cfc7b1d36ce98ad62749ec816d60aa09173ea Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期三, 29 四月 2026 09:27:15 +0800
Subject: [PATCH] fix(workOrder): 修复生产数量验证和表单初始化问题
---
src/views/productionManagement/workOrder/index.vue | 103 ++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 81 insertions(+), 22 deletions(-)
diff --git a/src/views/productionManagement/workOrder/index.vue b/src/views/productionManagement/workOrder/index.vue
index 2b56480..6a9eed8 100644
--- a/src/views/productionManagement/workOrder/index.vue
+++ b/src/views/productionManagement/workOrder/index.vue
@@ -337,10 +337,8 @@
</el-button>
</el-col>
</el-row>
-
<el-table :data="scheduleRows" border style="width: 100%" v-loading="scheduleLoading">
- <el-table-column type="index" label="搴忓彿" width="70" align="center" />
-
+ <el-table-column type="index" label="搴忓彿" width="70" align="center" :index="indexMethod" />
<el-table-column label="鏈涓婃満鏈哄彴" min-width="220">
<template #default="{ row }">
<el-select
@@ -441,6 +439,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,
@@ -672,8 +671,7 @@
return;
}
- const rows = buildScheduleRowsFromRecords(records);
-
+ const rows = records.map(record => mapMachineRecordToScheduleRow(record));
scheduleRows.value = rows.length > 0 ? rows : [createScheduleRow({})];
} catch (error) {
console.error("鑾峰彇鎺掍骇璁板綍澶辫触", error);
@@ -814,6 +812,10 @@
}
return payload;
+};
+
+const indexMethod = (index) => {
+ return (schedulePage.current - 1) * schedulePage.size + index + 1;
};
const mapMachineRecordToScheduleRow = (record) => {
@@ -1008,15 +1010,20 @@
showReportDialog(row);
},
// 鐢ㄦ埛褰撳墠id
- disabled: row => row.completeQuantity === row.planQuantity ||
+ disabled: row => row.completeQuantity !==0 ||
!isCurrentUserInUserIds(row)
},
{
name: "鐢熶骇鎺掍骇",
clickFun: row => {
+ if (!row.canSchedule) {
+ ElMessage.warning("褰撳墠鐢ㄦ埛涓嶅湪璇ュ伐搴忎汉鍛樹腑锛屼笉鑳界敓浜ф帓浜�");
+ return;
+ }
openScheduleDialog(row);
},
- },
+ disabled: row => !row.canSchedule || row.completeQuantity >= row.planQuantity
+ }
// {
// name:"瀹℃牳",
// color: "#f56c6c",
@@ -1177,6 +1184,12 @@
if (isNaN(num)) {
return;
}
+ // 濡傛灉瓒呰繃寰呯敓浜ф暟閲�
+ if (num > reportForm.planQuantity) {
+ proxy.$modal.msgWarning("鏈鐢熶骇鏁伴噺涓嶈兘澶т簬寰呯敓浜ф暟閲�");
+ reportForm.quantity = reportForm.planQuantity;
+ return;
+ }
// 濡傛灉灏忎簬1锛屾竻闄�
if (num < 1) {
reportForm.quantity = null;
@@ -1260,18 +1273,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;
+ }
};
// 涓嬭浇骞舵墦鍗板伐鍗曟祦杞崱锛堟枃浠舵祦锛�
@@ -1362,13 +1384,15 @@
};
const showReportDialog = row => {
+
currentReportRowData.value = row;
reportForm.planQuantity = row.planQuantity - row.completeQuantity;
- reportForm.quantity = row.quantity !== undefined && row.quantity !== null ? row.quantity : null;
+ reportForm.quantity = row.planQuantity !== undefined && row.planQuantity !== null ? row.planQuantity : null;
reportForm.productProcessRouteItemId = row.productProcessRouteItemId;
reportForm.workOrderId = row.id;
reportForm.reportWork = row.reportWork;
reportForm.productMainId = row.productMainId;
+ reportForm.planQuantity = row.planQuantity;
reportForm.startTime = "";
reportForm.endTime = "";
reportForm.replenishQty = 0;
@@ -1520,9 +1544,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