From cd9ee0b4268c6b0ccdaf75115aea4680ce40cb83 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期三, 27 五月 2026 13:38:20 +0800
Subject: [PATCH] Merge branch 'dev_天津_君歌化工' of http://114.132.189.42:9002/r/product-inventory-management into dev_天津_君歌化工
---
src/views/productionManagement/processRoute/Edit.vue | 204 +++++++++++++++++++++++++++------------------------
1 files changed, 108 insertions(+), 96 deletions(-)
diff --git a/src/views/productionManagement/processRoute/Edit.vue b/src/views/productionManagement/processRoute/Edit.vue
index 0c0fe0f..f84719b 100644
--- a/src/views/productionManagement/processRoute/Edit.vue
+++ b/src/views/productionManagement/processRoute/Edit.vue
@@ -3,7 +3,7 @@
<el-dialog
v-model="isShow"
title="缂栬緫宸ヨ壓璺嚎"
- width="400"
+ width="800"
@close="closeModal"
>
<el-form label-width="140px" :model="formState" label-position="top" ref="formRef">
@@ -25,35 +25,54 @@
</el-button>
</el-form-item>
- <el-form-item
- label="BOM"
- prop="bomId"
- :rules="[
- {
- required: true,
- message: '璇烽�夋嫨BOM',
- trigger: 'change',
- }
- ]"
- >
- <el-select
- v-model="formState.bomId"
- placeholder="璇烽�夋嫨BOM"
- clearable
- :disabled="!formState.productModelId || bomOptions.length === 0"
- style="width: 100%"
- >
- <el-option
- v-for="item in bomOptions"
- :key="item.id"
- :label="item.bomNo || `BOM-${item.id}`"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
-
<el-form-item label="澶囨敞" prop="description">
<el-input v-model="formState.description" type="textarea" />
+ </el-form-item>
+
+ <!-- 宸ュ簭閰嶇疆 -->
+ <el-form-item label="宸ュ簭閰嶇疆" required>
+ <el-table :data="formState.processRouteItemList" border size="small" style="width: 100%">
+ <el-table-column label="閮ㄤ欢" min-width="200">
+ <template #default="{ row }">
+ <el-select
+ v-model="row.processId"
+ placeholder="璇烽�夋嫨閮ㄤ欢"
+ clearable
+ filterable
+ style="width: 100%"
+ >
+ <el-option
+ v-for="process in processOptions"
+ :key="process.id"
+ :label="formatProcessOptionLabel(process)"
+ :value="process.id"
+ />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column label="璐ㄦ" width="80" align="center">
+ <template #default="{ row }">
+ <el-switch v-model="row.isQuality" :active-value="true" inactive-value="false"/>
+ </template>
+ </el-table-column>
+ <el-table-column label="澶囨敞" min-width="150">
+ <template #default="{ row }">
+ <el-input v-model="row.remark" placeholder="璇疯緭鍏ュ娉�" size="small"/>
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" width="60" align="center">
+ <template #default="{ $index }">
+ <el-button type="danger" link size="small" @click="removeProcessItem($index)">
+ <el-icon><Delete /></el-icon>
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <div style="margin-top: 8px;">
+ <el-button type="primary" link size="small" @click="addProcessItem">
+ <el-icon><Plus /></el-icon> 娣诲姞宸ュ簭
+ </el-button>
+ </div>
</el-form-item>
</el-form>
@@ -76,7 +95,7 @@
<script setup>
import {ref, computed, getCurrentInstance, onMounted, nextTick, watch} from "vue";
import {update} from "@/api/productionManagement/processRoute.js";
-import {getByModel} from "@/api/productionManagement/productBom.js";
+import {processList} from "@/api/productionManagement/productionProcess.js";
import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
const props = defineProps({
@@ -99,8 +118,8 @@
productModelId: undefined,
productName: "",
productModelName: "",
- bomId: undefined,
description: '',
+ processRouteItemList: [],
});
const isShow = computed({
@@ -113,9 +132,49 @@
});
const showProductSelectDialog = ref(false);
-const bomOptions = ref([]);
+const processOptions = ref([]);
let { proxy } = getCurrentInstance()
+
+// 鑾峰彇宸ュ簭鍒楄〃
+const getProcessOptions = async () => {
+ try {
+ const res = await processList();
+ processOptions.value = res.data || [];
+ } catch (error) {
+ console.error("鑾峰彇宸ュ簭鍒楄〃澶辫触", error);
+ processOptions.value = [];
+ }
+};
+
+// 鏍煎紡鍖栧伐搴忛�夐」鏍囩
+const formatProcessOptionLabel = (process) => {
+ if (!process) return '';
+ const typeMap = {
+ 1: '鍔犲伐',
+ 2: '鍒澘鍐疯姱鍒朵綔',
+ 3: '绠¤矾缁勫',
+ 4: '缃愪綋杩炴帴鍙婅皟璇�',
+ 5: '娴嬭瘯鎵撳帇',
+ 6: '鍏朵粬',
+ };
+ const typeText = typeMap[process.type] || '';
+ return `${process.name} ${process.no ? '(' + process.no + ')' : ''} ${typeText ? '[' + typeText + ']' : ''}`;
+};
+
+// 娣诲姞宸ュ簭
+const addProcessItem = () => {
+ formState.value.processRouteItemList.push({
+ processId: undefined,
+ isQuality: false,
+ remark: '',
+ });
+};
+
+// 绉婚櫎宸ュ簭
+const removeProcessItem = (index) => {
+ formState.value.processRouteItemList.splice(index, 1);
+};
const closeModal = () => {
isShow.value = false;
@@ -131,90 +190,42 @@
productName: props.record.productName || "",
// 娉ㄦ剰锛歳ecord涓殑瀛楁鏄痬odel锛岄渶瑕佹槧灏勫埌productModelName
productModelName: props.record.model || props.record.productModelName || "",
- bomId: props.record.bomId,
description: props.record.description || '',
+ processRouteItemList: props.record.processRouteItemList || [],
};
- // 濡傛灉鏈変骇鍝佸瀷鍙稩D锛屽姞杞紹OM鍒楄〃
- if (props.record.productModelId) {
- loadBomList(props.record.productModelId);
- }
}
}
-
-// 鍔犺浇BOM鍒楄〃
-const loadBomList = async (productModelId) => {
- if (!productModelId) {
- bomOptions.value = [];
- return;
- }
- try {
- const res = await getByModel(productModelId);
- // 澶勭悊杩斿洖鐨凚OM鏁版嵁锛氬彲鑳芥槸鏁扮粍銆佸璞℃垨鍖呭惈data瀛楁
- let bomList = [];
- if (Array.isArray(res)) {
- bomList = res;
- } else if (res && res.data) {
- bomList = Array.isArray(res.data) ? res.data : [res.data];
- } else if (res && typeof res === 'object') {
- bomList = [res];
- }
- bomOptions.value = bomList;
- } catch (error) {
- console.error("鍔犺浇BOM鍒楄〃澶辫触锛�", error);
- bomOptions.value = [];
- }
-};
// 浜у搧閫夋嫨澶勭悊
const handleProductSelect = async (products) => {
if (products && products.length > 0) {
const product = products[0];
- // 鍏堟煡璇OM鍒楄〃锛堝繀閫夛級
- try {
- const res = await getByModel(product.id);
- // 澶勭悊杩斿洖鐨凚OM鏁版嵁锛氬彲鑳芥槸鏁扮粍銆佸璞℃垨鍖呭惈data瀛楁
- let bomList = [];
- if (Array.isArray(res)) {
- bomList = res;
- } else if (res && res.data) {
- bomList = Array.isArray(res.data) ? res.data : [res.data];
- } else if (res && typeof res === 'object') {
- bomList = [res];
- }
-
- if (bomList.length > 0) {
- formState.value.productModelId = product.id;
- formState.value.productName = product.productName;
- formState.value.productModelName = product.model;
- // 濡傛灉褰撳墠閫夋嫨鐨凚OM涓嶅湪鏂板垪琛ㄤ腑锛屽垯閲嶇疆BOM閫夋嫨
- const currentBomExists = bomList.some(bom => bom.id === formState.value.bomId);
- if (!currentBomExists) {
- formState.value.bomId = undefined;
- }
- bomOptions.value = bomList;
- showProductSelectDialog.value = false;
- // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
- proxy.$refs["formRef"]?.validateField('productModelId');
- } else {
- proxy.$modal.msgError("璇ヤ骇鍝佹病鏈塀OM锛岃鍏堝垱寤築OM");
- }
- } catch (error) {
- // 濡傛灉鎺ュ彛杩斿洖404鎴栧叾浠栭敊璇紝璇存槑娌℃湁BOM
- proxy.$modal.msgError("璇ヤ骇鍝佹病鏈塀OM锛岃鍏堝垱寤築OM");
- }
+ formState.value.productModelId = product.id;
+ formState.value.productName = product.productName;
+ formState.value.productModelName = product.model;
+ showProductSelectDialog.value = false;
+ // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
+ proxy.$refs["formRef"]?.validateField('productModelId');
}
};
const handleSubmit = () => {
proxy.$refs["formRef"].validate(valid => {
if (valid) {
- // 楠岃瘉鏄惁閫夋嫨浜嗕骇鍝佸拰BOM
+ // 楠岃瘉鏄惁閫夋嫨浜嗕骇鍝�
if (!formState.value.productModelId) {
proxy.$modal.msgError("璇烽�夋嫨浜у搧");
return;
}
- if (!formState.value.bomId) {
- proxy.$modal.msgError("璇烽�夋嫨BOM");
+ // 楠岃瘉鏄惁閰嶇疆浜嗗伐搴�
+ if (!formState.value.processRouteItemList || formState.value.processRouteItemList.length === 0) {
+ proxy.$modal.msgError("璇疯嚦灏戦厤缃竴涓伐搴�");
+ return;
+ }
+ // 楠岃瘉鎵�鏈夊伐搴忔槸鍚﹂�夋嫨浜嗛儴浠�
+ const invalidItem = formState.value.processRouteItemList.find(item => !item.processId);
+ if (invalidItem) {
+ proxy.$modal.msgError("璇烽�夋嫨鎵�鏈夊伐搴忕殑閮ㄤ欢");
return;
}
update(formState.value).then(res => {
@@ -245,6 +256,7 @@
}, { immediate: true });
onMounted(() => {
+ getProcessOptions();
if (props.visible && props.record) {
setFormData();
}
--
Gitblit v1.9.3