| | |
| | | v-model="formState.bomId" |
| | | placeholder="请选择BOM" |
| | | clearable |
| | | :disabled="formState.selectedProducts.length !== 1 || bomOptions.length === 0" |
| | | :disabled="bomOptions.length === 0" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | |
| | | <script setup> |
| | | import { computed, getCurrentInstance, ref } from "vue"; |
| | | import { add } from "@/api/productionManagement/processRoute.js"; |
| | | import { getByModel } from "@/api/productionManagement/productBom.js"; |
| | | import { getByModelList } from "@/api/productionManagement/productBom.js"; |
| | | import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue"; |
| | | |
| | | const props = defineProps({ |
| | |
| | | isShow.value = false; |
| | | }; |
| | | |
| | | const loadBomList = async (productModelId) => { |
| | | if (!productModelId) { |
| | | const loadBomList = async (productModelIds) => { |
| | | if (!productModelIds?.length) { |
| | | bomOptions.value = []; |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | const res = await getByModel(productModelId); |
| | | const res = await getByModelList(productModelIds); |
| | | if (Array.isArray(res)) { |
| | | bomOptions.value = res; |
| | | return; |
| | |
| | | formState.value.productModelId = product.id; |
| | | formState.value.productName = product.productName; |
| | | formState.value.productModelName = product.model; |
| | | await loadBomList(product.id); |
| | | await loadBomList([product.id]); |
| | | } else { |
| | | formState.value.productId = undefined; |
| | | formState.value.productModelId = undefined; |
| | | formState.value.productName = ""; |
| | | formState.value.productModelName = ""; |
| | | bomOptions.value = []; |
| | | await loadBomList(products.map((product) => product.id)); |
| | | } |
| | | |
| | | showProductSelectDialog.value = false; |
| | |
| | | productModelName: formState.value.selectedProducts.length === 1 |
| | | ? formState.value.selectedProducts[0].model |
| | | : undefined, |
| | | bomId: formState.value.selectedProducts.length === 1 ? formState.value.bomId : undefined, |
| | | bomId: formState.value.bomId, |
| | | description: formState.value.description, |
| | | }) |
| | | .then(() => { |