From a14c5ce07d20e9f28058f6942dbc00197fac47f1 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 13 八月 2026 10:19:19 +0800
Subject: [PATCH] fix: 领料功能修改,移除订单领料,添加工序领料功能,支持按工序查询物料与已领料记录
---
src/views/productionManagement/processRoute/ItemsForm.vue | 112 ++++++++++++++++++++++++--------------------------------
1 files changed, 48 insertions(+), 64 deletions(-)
diff --git a/src/views/productionManagement/processRoute/ItemsForm.vue b/src/views/productionManagement/processRoute/ItemsForm.vue
index ed6e499..4d3229f 100644
--- a/src/views/productionManagement/processRoute/ItemsForm.vue
+++ b/src/views/productionManagement/processRoute/ItemsForm.vue
@@ -7,15 +7,7 @@
@close="closeModal"
>
<div class="operate-button">
- <el-button
- type="primary"
- @click="isShowProductSelectDialog = true"
- class="mb5"
- style="margin-bottom: 10px;"
- >
- 閫夋嫨浜у搧
- </el-button>
-
+ <span class="route-tip">鍚庣鏍规嵁BOM鐢熸垚宸ヨ壓璺嚎锛屽彲鍦ㄦ璋冩暣宸ュ簭鍜岄『搴�</span>
<el-switch
v-model="isTable"
inline-prompt
@@ -68,6 +60,7 @@
<el-select
v-model="scope.row[item.prop]"
style="width: 100%;"
+ @change="value => handleProcessChange(scope.row, value)"
@mousedown.stop
>
<el-option
@@ -102,16 +95,17 @@
<div class="step-content">
<div class="step-number">{{ index + 1 }}</div>
<el-card
- :header="item.productName"
+ :header="getProcessName(item)"
class="step-card"
style="cursor: move;"
>
<div class="step-card-content">
- <p>{{ item.model }}</p>
- <p>{{ item.unit }}</p>
+ <p>{{ item.productName || '-' }}</p>
+ <p>{{ item.model || '-' }}</p>
<el-select
v-model="item.processId"
style="width: 100%;"
+ @change="value => handleProcessChange(item, value)"
@mousedown.stop
>
<el-option
@@ -139,18 +133,12 @@
</div>
</template>
</el-dialog>
-
- <ProductSelectDialog
- v-model="isShowProductSelectDialog"
- @confirm="handelSelectProducts"
- />
</div>
</template>
<script setup>
import { ref, computed, getCurrentInstance, onMounted, onUnmounted, nextTick } from "vue";
-import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
-import { findProcessRouteItemList, addOrUpdateProcessRouteItem } from "@/api/productionManagement/processRouteItem.js";
+import { findProcessRouteItemList, saveProcessRouteItems } from "@/api/productionManagement/processRouteItem.js";
import { processList } from "@/api/productionManagement/productionProcess.js";
import Sortable from 'sortablejs';
@@ -171,7 +159,6 @@
const processOptions = ref([]);
const tableLoading = ref(false);
-const isShowProductSelectDialog = ref(false);
const routeItems = ref([]);
let tableSortable = null;
let stepsSortable = null;
@@ -191,8 +178,7 @@
const tableColumn = ref([
{ label: "浜у搧鍚嶇О", prop: "productName", width: 180 },
{ label: "瑙勬牸鍚嶇О", prop: "model", width: 150 },
- { label: "鍗曚綅", prop: "unit", width: 80 },
- { label: "宸ュ簭鍚嶇О", prop: "processId", width: 180 },
+ { label: "宸ュ簭鍚嶇О", prop: "processId", width: 220 },
{
dataType: "action",
label: "鎿嶄綔",
@@ -215,6 +201,21 @@
}
]);
+const getProcessName = item => {
+ if (item.processName || item.operationName) {
+ return item.processName || item.operationName;
+ }
+ const process = processOptions.value.find(process => process.id === item.processId);
+ return process?.name || "璇烽�夋嫨宸ュ簭";
+};
+
+const handleProcessChange = (row, value) => {
+ const process = processOptions.value.find(process => process.id === value);
+ row.processName = process?.name || "";
+ row.operationName = row.processName;
+ row.operationId = value;
+};
+
const removeItem = (index) => {
routeItems.value.splice(index, 1);
nextTick(() => initSortable());
@@ -232,46 +233,18 @@
isShow.value = false;
};
-const handelSelectProducts = (products) => {
- destroySortable();
-
- const newData = products.map(({ id, ...product }) => ({
- ...product,
- productModelId: id,
- routeId: props.record.id,
- id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
- processId: undefined
- }));
-
- console.log('閫夋嫨浜у搧鍓嶆暟缁�:', routeItems.value);
- routeItems.value.push(...newData);
- routeItems.value = [...routeItems.value];
- console.log('閫夋嫨浜у搧鍚庢暟缁�:', routeItems.value);
-
- // 寤惰繜鍒濆鍖栵紝纭繚DOM瀹屽叏娓叉煋
- nextTick(() => {
- // 寮哄埗閲嶆柊娓叉煋缁勪欢
- if (proxy?.$forceUpdate) {
- proxy.$forceUpdate();
- }
-
- const temp = [...routeItems.value];
- routeItems.value = [];
- nextTick(() => {
- routeItems.value = temp;
- initSortable();
- });
- });
-};
-
const findProcessRouteItems = () => {
tableLoading.value = true;
findProcessRouteItemList({ routeId: props.record.id })
.then(res => {
tableLoading.value = false;
- routeItems.value = res.data.map(item => ({
+ // 鍚庣杩斿洖 technologyOperationId / technologyOperationName锛岄〉闈㈢粺涓�鐢� processId / processName
+ routeItems.value = (res.data || []).map(item => ({
...item,
- processId: item.processId === 0 ? undefined : item.processId
+ productName: item.productName || "",
+ model: item.model || "",
+ processName: item.technologyOperationName || item.processName || "",
+ processId: item.technologyOperationId || (item.processId === 0 ? undefined : item.processId)
}));
// 寤惰繜鍒濆鍖栵紝纭繚DOM瀹屽叏娓叉煋
nextTick(() => {
@@ -302,10 +275,20 @@
proxy?.$modal?.msgError("璇蜂负鎵�鏈夐」鐩�夋嫨宸ュ簭");
return;
}
+ const processIds = routeItems.value.map(item => item.processId);
+ if (new Set(processIds).size !== processIds.length) {
+ proxy?.$modal?.msgError("鍚屼竴閬撳伐搴忎笉鑳介噸澶嶅嚭鐜板湪宸ヨ壓璺嚎涓�");
+ return;
+ }
- addOrUpdateProcessRouteItem({
- routeId: props.record.id,
- processRouteItem: routeItems.value.map(({ id, ...item }) => item)
+ // 鍏ㄩ噺鎻愪氦锛氬伐搴忛『搴忓嵆褰撳墠鍒楄〃椤哄簭锛屾湭鍥炰紶鐨勫伐搴忎細琚悗绔垹闄�
+ saveProcessRouteItems({
+ technologyRoutingId: props.record.id,
+ operationList: routeItems.value.map((item, index) => ({
+ id: item.id,
+ technologyOperationId: item.processId,
+ dragSort: index + 1
+ }))
})
.then(res => {
isShow.value = false;
@@ -349,7 +332,6 @@
const moveItem = routeItems.value.splice(evt.oldIndex, 1)[0];
routeItems.value.splice(evt.newIndex, 0, moveItem);
routeItems.value = [...routeItems.value];
- console.log('鎺掑簭鍚庢暟缁�:', routeItems.value);
}
});
} else {
@@ -385,10 +367,6 @@
routeItems.value = [...routeItems.value];
}
});
-
- // 璋冭瘯锛氭墦鍗板鍣ㄥ拰瀹炰緥锛岀‘璁ょ粦瀹氭垚鍔�
- console.log('姝ラ鏉℃嫋鎷藉鍣�:', stepsList);
- console.log('Sortable瀹炰緥:', stepsSortable);
}
};
@@ -438,6 +416,12 @@
display: flex;
align-items: center;
justify-content: space-between;
+ margin-bottom: 10px;
+}
+
+.route-tip {
+ color: #606266;
+ font-size: 13px;
}
/* 淇敼锛氳嚜瀹氫箟姝ラ鏉″鍣ㄦ牱寮� */
--
Gitblit v1.9.3