From fd422fae5ef4f801868415736d592248136bd2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Thu, 15 May 2025 10:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mes/materialBom/index.vue | 243 ++++++++++++++-------------- 1 file changed, 125 insertions(+), 118 deletions(-) diff --git a/src/views/mes/materialBom/index.vue b/src/views/mes/materialBom/index.vue index cc351a8..980fde2 100644 --- a/src/views/mes/materialBom/index.vue +++ b/src/views/mes/materialBom/index.vue @@ -4,7 +4,7 @@ - + @@ -36,13 +38,14 @@ - 父级物料 - + 父级物料 + - - + + + prop="materialBomId" /> + prop="materialTypeCode" :show-overflow-tooltip="true" /> + prop="materialTypeName" :show-overflow-tooltip="true" w /> + prop="materialId" :show-overflow-tooltip="true" /> @@ -222,18 +224,18 @@ - + + style="width:360px" /> + style="width:360px" /> @@ -277,22 +279,22 @@ import { addBatchMaterialBom, getUnitInfoList, getMaterialBomVersionList, getParentMaterialBom, deleteMaterialBoms, selectNextMaterialBomVersion -} from "@/api/mes/materialBom"; +} from '@/api/mes/materialBom'; -import {MaterialBomVO, MaterialBomForm, MaterialBomQuery} from '@/api/mes/materialBom/types'; -import {BaseMaterialTypeVO} from '@/api/mes/baseMaterialType/types'; +import { MaterialBomVO, MaterialBomForm, MaterialBomQuery } from '@/api/mes/materialBom/types'; +import { BaseMaterialTypeVO } from '@/api/mes/baseMaterialType/types'; import MaterialSelect from '@/views/mes/baseMaterialInfo/addMaterial.vue'; -import {to} from 'await-to-js'; -import {nextTick} from "vue"; -import {MaterialBomVersionVO} from "@/api/mes/materialBomVersion/types"; -import {BaseMeasurementUnitInfoVO} from "@/api/mes/baseMeasurementUnitInfo/types"; -import {BaseStructureBomTreeVO} from "@/api/mes/baseStructureBom/types"; +import { to } from 'await-to-js'; +import { nextTick } from 'vue'; +import { MaterialBomVersionVO } from '@/api/mes/materialBomVersion/types'; +import { BaseMeasurementUnitInfoVO } from '@/api/mes/baseMeasurementUnitInfo/types'; +import { BaseStructureBomTreeVO } from '@/api/mes/baseStructureBom/types'; const materialTypeId = ref(0);//此值是传给选择物料信息弹框使用 const router = useRouter(); -const {proxy} = getCurrentInstance() as ComponentInternalInstance; +const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { material_bom_active_flag } = toRefs(proxy?.useDict('material_bom_active_flag')); @@ -330,13 +332,13 @@ const SELECT_MATERIAL_MODEL = ref({ PARENT_SELECT: '1',//父级物料选择 CHILD_SELECT: '2',//子级物料选择 DIALOG_CHILD_SELECT: '3'//弹窗子级选择 -}) +}); const MATERIAL_BOM_ACTIVE_FLAG = ref({ ACTIVE: '1',//启用 HISTORY: '2',//历史 DESIGN: '3'//设计中 -}) +}); const addNewMaterialBomVersionBtnText = ref('新增中'); const addNewMaterialBomVersionBtnDisabled = ref(true); @@ -347,14 +349,14 @@ const initialMaterialBomVersion = ref('01'); // 列显隐信息 const columns = ref([ - {key: 0, label: `生产BOM_ID`, visible: false, children: []}, - {key: 1, label: `子物料类型编号`, visible: true, children: []}, - {key: 2, label: `子物料类型名称`, visible: true, children: []}, - {key: 3, label: `BOM版本`, visible: false, children: []}, - {key: 4, label: `子物料ID`, visible: false, children: []}, - {key: 5, label: `子物料名称`, visible: true, children: []}, - {key: 6, label: `子物料数量`, visible: true, children: []}, - {key: 7, label: `子物料单位`, visible: true, children: []} + { key: 0, label: `生产BOM_ID`, visible: false, children: [] }, + { key: 1, label: `子物料类型编号`, visible: true, children: [] }, + { key: 2, label: `子物料类型名称`, visible: true, children: [] }, + { key: 3, label: `BOM版本`, visible: false, children: [] }, + { key: 4, label: `子物料ID`, visible: false, children: [] }, + { key: 5, label: `子物料名称`, visible: true, children: [] }, + { key: 6, label: `子物料数量`, visible: true, children: [] }, + { key: 7, label: `子物料单位`, visible: true, children: [] } ]); const materialBomTreeRef = ref(); @@ -390,7 +392,7 @@ const initParentFormData: MaterialBomForm = { attachId: undefined, activeFlag: undefined, remark: undefined, - materialTypeName: undefined, + materialTypeName: undefined }; const initFormData: MaterialBomForm = { @@ -414,12 +416,12 @@ const initFormData: MaterialBomForm = { attachId: undefined, activeFlag: undefined, remark: undefined, - materialTypeName: undefined, + materialTypeName: undefined }; const data = reactive>({ - form: {...initFormData}, - parentForm: {...initParentFormData}, + form: { ...initFormData }, + parentForm: { ...initParentFormData }, queryParams: { materialBomId: undefined, parentId: undefined, @@ -432,31 +434,31 @@ const data = reactive>({ }, rules: { materialTypeId: [ - {required: true, message: "物料类型不能为空", trigger: "blur"} + { required: true, message: '物料类型不能为空', trigger: 'blur' } ], materialBomVersion: [ - {required: true, message: "BOM版本不能为空", trigger: "blur"} + { required: true, message: 'BOM版本不能为空', trigger: 'blur' } ], materialName: [ - {required: true, message: "物料名称不能为空", trigger: "blur"} + { required: true, message: '物料名称不能为空', trigger: 'blur' } ], standardAmount: [ - {required: true, message: "子物料数量不能为空", trigger: "blur"} + { required: true, message: '子物料数量不能为空', trigger: 'blur' } ] }, parentRules: { parentMaterialName: [ - {required: true, message: "父物料名称不能为空", trigger: "blur"} + { required: true, message: '父物料名称不能为空', trigger: 'blur' } ], materialBomVersion: [ - {required: true, message: "BOM版本不能为空", trigger: "blur"} + { required: true, message: 'BOM版本不能为空', trigger: 'blur' } ], parentStandardAmount: [ - {required: true, message: "父物料数量不能为空", trigger: "blur"} + { required: true, message: '父物料数量不能为空', trigger: 'blur' } ], parentUnitId: [ - {required: true, message: "父物料单位不能为空", trigger: "blur"} + { required: true, message: '父物料单位不能为空', trigger: 'blur' } ] } @@ -471,9 +473,9 @@ const parentQueryParams = ref({ materialName: undefined, materialBomVersion: undefined, params: {} -}) +}); -const {queryParams, form, rules, parentForm, parentRules} = toRefs(data); +const { queryParams, form, rules, parentForm, parentRules } = toRefs(data); /** 通过条件过滤节点 */ const filterNode = (value: string, data: any) => { @@ -502,7 +504,7 @@ const getTreeSelect = async () => { id: virtualTopNodeId,//materialBomId parentId: -1, materialId: 0, - label: "生产BOM", + label: '生产BOM', children: res.data }; materialBomOptions.value.push(initialTree); @@ -510,13 +512,13 @@ const getTreeSelect = async () => { // materialBomOptions.value = res.data; if (!focusKeyNode.value) {//如果之前没有focus - focusKeyNode.value = {treeKey: virtualTopNodeId}; + focusKeyNode.value = { treeKey: virtualTopNodeId }; } else { - const clickNode = findObjectByTreeKey(materialBomOptions.value, focusKeyNode.value.treeKey) + const clickNode = findObjectByTreeKey(materialBomOptions.value, focusKeyNode.value.treeKey); if (!clickNode) { focusKeyNode.value = undefined; - focusKeyNode.value = {treeKey: virtualTopNodeId}; + focusKeyNode.value = { treeKey: virtualTopNodeId }; } // if (!allTreeKeys || allTreeKeys.length <= 0) { // focusKeyNode.value = { @@ -532,9 +534,9 @@ const getTreeSelect = async () => { // const focusKeyNodeIndex = materialBomOptions.value.findIndex((optionItem) => focusKeyNode.value.treeKey === optionItem.treeKey);//有嵌套children的,有可能找不到 } - nextTick(function () { + nextTick(function() { materialBomTreeRef.value?.setCurrentKey(focusKeyNode.value.treeKey, true); - }) + }); loading.value = false; treeLoading.value = false; @@ -567,12 +569,12 @@ const getList = async () => { const resetParentQueryParams = () => { parentQueryParams.value.parentId = undefined;//是当前节点的materialId parentQueryParams.value.materialBomVersion = undefined; -} +}; const resetQueryParams = () => { queryParams.value.parentId = undefined;//materialid queryParams.value.parentMaterialTypeId = undefined; -} +}; /** 节点单击事件 */ const handleNodeClick = (data: MaterialBomVO) => { @@ -603,14 +605,14 @@ const handleNodeClick = (data: MaterialBomVO) => { parentMaterialDisabled.value = focusKeyNode.value.treeKey != -1; }; -const handleBtnStatus = () =>{ - if(parentForm.value.materialBomVersion && parentForm.value.materialBomVersion!==''){ +const handleBtnStatus = () => { + if (parentForm.value.materialBomVersion && parentForm.value.materialBomVersion !== '') { addNewMaterialBomVersionBtnDisabled.value = false; - addNewMaterialBomVersionBtnText.value = "新增版本"; + addNewMaterialBomVersionBtnText.value = '新增版本'; publishBtnDisplay.value = parentForm.value.activeFlag !== MATERIAL_BOM_ACTIVE_FLAG.value.ACTIVE; - }else{ + } else { addNewMaterialBomVersionBtnDisabled.value = true; - addNewMaterialBomVersionBtnText.value = "新增中"; + addNewMaterialBomVersionBtnText.value = '新增中'; publishBtnDisplay.value = false; } @@ -619,10 +621,10 @@ const handleBtnStatus = () =>{ const clickDisplay = () => { if (queryParams.value.parentId === 0) { parentFormDisplay.value = false; - childTableTitle.value = "顶级物料"; + childTableTitle.value = '顶级物料'; } else { parentFormDisplay.value = true; - childTableTitle.value = "子级物料"; + childTableTitle.value = '子级物料'; } }; @@ -664,7 +666,7 @@ const handleDelete = async (row?: MaterialBomVO) => { }); // alert(JSON.stringify(toDeleteMaterialBoms.value)) if (toDeleteMaterialBoms.value.length > 0) { - await deleteMaterialBoms(toDeleteMaterialBoms.value) + await deleteMaterialBoms(toDeleteMaterialBoms.value); await getTreeSelect(); } @@ -695,7 +697,7 @@ const handleSelectionChange = (selection: MaterialBomVO[]) => { /** 重置操作表单 */ const reset = () => { - form.value = {...initFormData}; + form.value = { ...initFormData }; materialBomFormRef.value?.resetFields(); }; /** 取消按钮 */ @@ -810,7 +812,7 @@ const handleMaterialSelect = (row, selectMode) => { } else if (selectMode === SELECT_MATERIAL_MODEL.value.CHILD_SELECT) {//子级选择物料需要传值materialTypeId materialTypeId.value = row.materialTypeId; } else { - materialTypeId.value = undefined + materialTypeId.value = undefined; } materialOpen.value = true; }; @@ -881,9 +883,9 @@ const submitBatchSaveMaterialBoms = async () => { await addBatchMaterialBom(saveMaterialBomList.value); proxy?.$modal.msgSuccess('操作成功'); - focusKeyNode.value.treeKey = parentForm.value.parentId + "-" + parentForm.value.materialBomVersion; + focusKeyNode.value.treeKey = parentForm.value.parentId + '-' + parentForm.value.materialBomVersion; focusKeyNode.value.materialId = parentForm.value.parentId; - focusKeyNode.value.materialTypeId = parentForm.value.parentMaterialTypeId + focusKeyNode.value.materialTypeId = parentForm.value.parentMaterialTypeId; focusKeyNode.value.materialBomVersion = parentForm.value.materialBomVersion; focusKeyNode.value.parentUnitId = parentForm.value.parentUnitId; focusKeyNode.value.parentStandardAmount = parentForm.value.parentStandardAmount; @@ -899,13 +901,13 @@ const submitBatchSaveMaterialBoms = async () => { } } }); -} +}; /** 初始化单位数据 */ const initUnitInfoData = async () => { if (unitInfoOptions.value === undefined || unitInfoOptions.value.length <= 0) { - const {data} = await getUnitInfoList(); + const { data } = await getUnitInfoList(); // alert(JSON.stringify(data)) unitInfoOptions.value = data; } @@ -915,7 +917,7 @@ const initUnitInfoData = async () => { const initMaterialBomVersionData = async () => { // alert(JSON.stringify(getMaterialBomVersionList)) if (materialBomVersionOptions.value === undefined || materialBomVersionOptions.value.length <= 0) { - const {data} = await getMaterialBomVersionList(); + const { data } = await getMaterialBomVersionList(); materialBomVersionOptions.value = data; if (materialBomVersionOptions.value.length > 0) { @@ -933,14 +935,14 @@ const getParentMaterialBomInfo = async () => { parentForm.value = res.data; handleBtnStatus(); - if(!parentForm.value.materialBomVersion || parentForm.value.materialBomVersion===''){ + if (!parentForm.value.materialBomVersion || parentForm.value.materialBomVersion === '') { parentForm.value.materialBomVersion = initialMaterialBomVersion.value; parentForm.value.activeFlag = MATERIAL_BOM_ACTIVE_FLAG.value.DESIGN; } - queryParams.value.parentId = parentForm.value.parentId - queryParams.value.parentMaterialTypeId = parentForm.value.parentMaterialTypeId - queryParams.value.materialBomVersion = parentForm.value.materialBomVersion + queryParams.value.parentId = parentForm.value.parentId; + queryParams.value.parentMaterialTypeId = parentForm.value.parentMaterialTypeId; + queryParams.value.materialBomVersion = parentForm.value.materialBomVersion; handleQuery(); btnLoading.value = false; }; @@ -955,18 +957,18 @@ const findObjectByTreeKey = (list, targetTreeKey) => { } } return null; -} +}; /** 基于当前父级物料和版本,新增物料bom版本 */ const addNewMaterialBomVersion = async () => { loading.value = true; - parentForm.value.activeFlag = MATERIAL_BOM_ACTIVE_FLAG.value.DESIGN; - await getNextMaterialBomVersion(); - materialBomList.value.forEach(childMaterialBom => { - childMaterialBom.materialBomId = undefined; - }); - loading.value = false; - console.log( materialBomList); + parentForm.value.activeFlag = MATERIAL_BOM_ACTIVE_FLAG.value.DESIGN; + await getNextMaterialBomVersion(); + materialBomList.value.forEach(childMaterialBom => { + childMaterialBom.materialBomId = undefined; + }); + loading.value = false; + console.log(materialBomList); }; // const getClickNode = (obj) => { @@ -997,4 +999,9 @@ const getColor = (e) => { }; - +