From bd1012f4b22bac3b40aba28ea4598e77ca92c824 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 23 三月 2026 13:47:36 +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 | 401 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 196 insertions(+), 205 deletions(-)
diff --git a/src/views/productionManagement/processRoute/Edit.vue b/src/views/productionManagement/processRoute/Edit.vue
index 0c0fe0f..4ce5098 100644
--- a/src/views/productionManagement/processRoute/Edit.vue
+++ b/src/views/productionManagement/processRoute/Edit.vue
@@ -1,71 +1,64 @@
<template>
<div>
- <el-dialog
- v-model="isShow"
- title="缂栬緫宸ヨ壓璺嚎"
- width="400"
- @close="closeModal"
- >
- <el-form label-width="140px" :model="formState" label-position="top" ref="formRef">
- <el-form-item
- label="浜у搧鍚嶇О"
- prop="productModelId"
- :rules="[
+ <el-dialog v-model="isShow"
+ title="缂栬緫宸ヨ壓璺嚎"
+ width="400"
+ @close="closeModal">
+ <el-form label-width="140px"
+ :model="formState"
+ label-position="top"
+ ref="formRef">
+ <el-form-item label="浜у搧绫诲瀷"
+ prop="dictCode"
+ :rules="[
{
required: true,
- message: '璇烽�夋嫨浜у搧',
+ message: '璇烽�夋嫨浜у搧绫诲瀷',
trigger: 'change',
}
- ]"
- >
- <el-button type="primary" @click="showProductSelectDialog = true">
- {{ formState.productName && formState.productModelName
- ? `${formState.productName} - ${formState.productModelName}`
- : '閫夋嫨浜у搧' }}
- </el-button>
+ ]">
+ <el-select v-model="formState.dictCode"
+ placeholder="璇烽�夋嫨浜у搧绫诲瀷"
+ clearable
+ style="width: 100%"
+ @change="handleProductTypeChange">
+ <el-option v-for="item in productTypeOptions"
+ :key="item.dictCode"
+ :label="item.dictLabel"
+ :value="item.dictCode" />
+ </el-select>
</el-form-item>
-
- <el-form-item
- label="BOM"
- prop="bomId"
- :rules="[
+ <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 v-model="formState.bomId"
+ placeholder="璇烽�夋嫨BOM"
+ clearable
+ :disabled="!formState.dictCode || 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 label="澶囨敞"
+ prop="description">
+ <el-input v-model="formState.description"
+ type="textarea" />
</el-form-item>
</el-form>
-
- <!-- 浜у搧閫夋嫨寮圭獥 -->
- <ProductSelectDialog
- v-model="showProductSelectDialog"
- @confirm="handleProductSelect"
- single
- />
+
<template #footer>
<div class="dialog-footer">
- <el-button type="primary" @click="handleSubmit">纭</el-button>
+ <el-button type="primary"
+ @click="handleSubmit">纭</el-button>
<el-button @click="closeModal">鍙栨秷</el-button>
</div>
</template>
@@ -74,179 +67,177 @@
</template>
<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 ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
+ import {
+ ref,
+ computed,
+ getCurrentInstance,
+ onMounted,
+ nextTick,
+ watch,
+ } from "vue";
+ import { update } from "@/api/productionManagement/processRoute.js";
+ import { listPage } from "@/api/productionManagement/productBom.js";
+ import { getDicts } from "@/api/system/dict/data.js";
-const props = defineProps({
- visible: {
- type: Boolean,
- required: true,
- },
+ const props = defineProps({
+ visible: {
+ type: Boolean,
+ required: true,
+ },
- record: {
- type: Object,
- required: true,
- }
-});
+ record: {
+ type: Object,
+ required: true,
+ },
+ });
-const emit = defineEmits(['update:visible', 'completed']);
+ const emit = defineEmits(["update:visible", "completed"]);
-// 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
-const formState = ref({
- productId: undefined,
- productModelId: undefined,
- productName: "",
- productModelName: "",
- bomId: undefined,
- description: '',
-});
+ // 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
+ const formState = ref({
+ dictCode: undefined,
+ dictLabel: "",
+ bomId: undefined,
+ description: "",
+ });
-const isShow = computed({
- get() {
- return props.visible;
- },
- set(val) {
- emit('update:visible', val);
- },
-});
+ const isShow = computed({
+ get() {
+ return props.visible;
+ },
+ set(val) {
+ emit("update:visible", val);
+ },
+ });
-const showProductSelectDialog = ref(false);
-const bomOptions = ref([]);
+ const productTypeOptions = ref([]);
+ const bomOptions = ref([]);
-let { proxy } = getCurrentInstance()
+ let { proxy } = getCurrentInstance();
-const closeModal = () => {
- isShow.value = false;
-};
-
-// 璁剧疆琛ㄥ崟鏁版嵁
-const setFormData = () => {
- if (props.record) {
- formState.value = {
- ...props.record,
- productId: props.record.productId,
- productModelId: props.record.productModelId,
- productName: props.record.productName || "",
- // 娉ㄦ剰锛歳ecord涓殑瀛楁鏄痬odel锛岄渶瑕佹槧灏勫埌productModelName
- productModelName: props.record.model || props.record.productModelName || "",
- bomId: props.record.bomId,
- description: props.record.description || '',
- };
- // 濡傛灉鏈変骇鍝佸瀷鍙稩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;
+ // 鑾峰彇浜у搧绫诲瀷瀛楀吀
+ const getProductTypeOptions = () => {
+ getDicts("product_type")
+ .then(res => {
+ if (res.code === 200) {
+ productTypeOptions.value = res.data;
}
- bomOptions.value = bomList;
- showProductSelectDialog.value = false;
- // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
- proxy.$refs["formRef"]?.validateField('productModelId');
- } else {
- proxy.$modal.msgError("璇ヤ骇鍝佹病鏈塀OM锛岃鍏堝垱寤築OM");
+ })
+ .catch(err => {
+ console.error("鑾峰彇浜у搧绫诲瀷瀛楀吀澶辫触锛�", err);
+ });
+ };
+
+ // 鏍规嵁浜у搧绫诲瀷鑾峰彇BOM鍒楄〃
+ const getBomListByProductType = async dictCode => {
+ if (!dictCode) {
+ bomOptions.value = [];
+ return;
+ }
+ try {
+ // 浣跨敤listPage鎺ュ彛锛屾牴鎹甦ictCode鏌ヨBOM
+ const res = await listPage({ dictCode });
+ // 澶勭悊杩斿洖鐨凚OM鏁版嵁
+ let bomList = [];
+ if (res.data && res.data.records) {
+ bomList = res.data.records;
+ }
+ bomOptions.value = bomList;
+ if (bomList.length === 0) {
+ proxy.$modal.msgError("璇ヤ骇鍝佺被鍨嬫病鏈塀OM锛岃鍏堝垱寤築OM");
}
} catch (error) {
// 濡傛灉鎺ュ彛杩斿洖404鎴栧叾浠栭敊璇紝璇存槑娌℃湁BOM
- proxy.$modal.msgError("璇ヤ骇鍝佹病鏈塀OM锛岃鍏堝垱寤築OM");
+ proxy.$modal.msgError("璇ヤ骇鍝佺被鍨嬫病鏈塀OM锛岃鍏堝垱寤築OM");
+ bomOptions.value = [];
}
- }
-};
+ };
-const handleSubmit = () => {
- proxy.$refs["formRef"].validate(valid => {
- if (valid) {
- // 楠岃瘉鏄惁閫夋嫨浜嗕骇鍝佸拰BOM
- if (!formState.value.productModelId) {
- proxy.$modal.msgError("璇烽�夋嫨浜у搧");
- return;
+ const closeModal = () => {
+ isShow.value = false;
+ };
+
+ // 璁剧疆琛ㄥ崟鏁版嵁
+ const setFormData = () => {
+ if (props.record) {
+ formState.value = {
+ ...props.record,
+ dictCode: props.record.dictCode,
+ dictLabel: props.record.dictLabel || "",
+ bomId: props.record.bomId,
+ description: props.record.description || "",
+ };
+ // 濡傛灉鏈変骇鍝佺被鍨嬶紝鍔犺浇BOM鍒楄〃
+ if (props.record.dictCode) {
+ getBomListByProductType(props.record.dictCode);
}
- if (!formState.value.bomId) {
- proxy.$modal.msgError("璇烽�夋嫨BOM");
- return;
- }
- update(formState.value).then(res => {
- // 鍏抽棴妯℃�佹
- isShow.value = false;
- // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
- emit('completed');
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- })
}
- })
-};
+ };
-defineExpose({
- closeModal,
- handleSubmit,
- isShow,
-});
+ // 浜у搧绫诲瀷閫夋嫨澶勭悊
+ const handleProductTypeChange = async dictCode => {
+ if (dictCode) {
+ const selectedType = productTypeOptions.value.find(item => item.dictCode === dictCode);
+ if (selectedType) {
+ formState.value.dictLabel = selectedType.dictLabel;
+ }
+ // 濡傛灉褰撳墠閫夋嫨鐨凚OM涓嶅湪鏂板垪琛ㄤ腑锛屽垯閲嶇疆BOM閫夋嫨
+ formState.value.bomId = undefined;
+ await getBomListByProductType(dictCode);
+ // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
+ proxy.$refs["formRef"]?.validateField("dictCode");
+ } else {
+ formState.value.dictLabel = "";
+ bomOptions.value = [];
+ }
+ };
-
-// 鐩戝惉寮圭獥鎵撳紑锛屽垵濮嬪寲琛ㄥ崟鏁版嵁
-watch(() => props.visible, (visible) => {
- if (visible && props.record) {
- nextTick(() => {
- setFormData();
+ const handleSubmit = () => {
+ proxy.$refs["formRef"].validate(valid => {
+ if (valid) {
+ // 楠岃瘉鏄惁閫夋嫨浜嗕骇鍝佺被鍨嬪拰BOM
+ if (!formState.value.dictCode) {
+ proxy.$modal.msgError("璇烽�夋嫨浜у搧绫诲瀷");
+ return;
+ }
+ if (!formState.value.bomId) {
+ proxy.$modal.msgError("璇烽�夋嫨BOM");
+ return;
+ }
+ update(formState.value).then(res => {
+ // 鍏抽棴妯℃�佹
+ isShow.value = false;
+ // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
+ emit("completed");
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ });
+ }
});
- }
-}, { immediate: true });
+ };
-onMounted(() => {
- if (props.visible && props.record) {
- setFormData();
- }
-});
+ defineExpose({
+ closeModal,
+ handleSubmit,
+ isShow,
+ });
+
+ // 鐩戝惉寮圭獥鎵撳紑锛屽垵濮嬪寲琛ㄥ崟鏁版嵁
+ watch(
+ () => props.visible,
+ visible => {
+ if (visible && props.record) {
+ nextTick(() => {
+ setFormData();
+ });
+ }
+ },
+ { immediate: true }
+ );
+
+ onMounted(() => {
+ getProductTypeOptions();
+ if (props.visible && props.record) {
+ setFormData();
+ }
+ });
</script>
--
Gitblit v1.9.3