diff --git a/src/views/mes/mixTrace/index.vue b/src/views/mes/mixTrace/index.vue index c5b6192..f83bed9 100644 --- a/src/views/mes/mixTrace/index.vue +++ b/src/views/mes/mixTrace/index.vue @@ -12,23 +12,33 @@ - + - + + + - + + + - + + + - + + + + + + + + + @@ -329,6 +348,13 @@ import { computed, getCurrentInstance, nextTick, onBeforeUnmount, onMounted, rea import type { ComponentInternalInstance } from 'vue'; import * as echarts from 'echarts'; import { getMixTraceDetail, getSpcCapability, getSpcRunChart, getSpcXbarR, listMixTrace, listSpcSamples } from '@/api/mes/mixTrace'; +import { getProdBaseMachineInfoList } from '@/api/mes/prodBaseMachineInfo'; +import { getBaseShiftInfoList } from '@/api/mes/baseShiftInfo'; +import { getBaseClassTeamInfoList } from '@/api/mes/baseClassTeamInfo'; +import type { ProdBaseMachineInfoVO } from '@/api/mes/prodBaseMachineInfo/types'; +import type { BaseShiftInfoVO } from '@/api/mes/baseShiftInfo/types'; +import type { BaseClassTeamInfoVO } from '@/api/mes/baseClassTeamInfo/types'; +import MaterialSelect from '@/views/mes/recipeInfo/components/MaterialSelect.vue'; import type { MixTraceDetailQuery, MixTraceDetailVO, @@ -357,6 +383,13 @@ const traceTableRef = ref(); const treeFilterText = ref(''); const trayBarcode = ref(''); +/** 下拉框数据 */ +const machineOptions = ref([]); +const shiftOptions = ref([]); +const classTeamOptions = ref([]); +const materialSelectRef = ref(); +const materialDialogVisible = ref(false); + const traceLoading = ref(false); const traceList = ref([]); const traceTotal = ref(0); @@ -538,6 +571,60 @@ const handleTrayTrace = () => { handleTraceQuery(); }; +/** 加载机台下拉选项 */ +const loadMachineOptions = async () => { + try { + const res = await getProdBaseMachineInfoList({}); + machineOptions.value = (res as any).data || []; + } catch { + machineOptions.value = []; + } +}; + +/** 加载班次下拉选项 */ +const loadShiftOptions = async () => { + try { + const res = await getBaseShiftInfoList({}); + shiftOptions.value = (res as any).data || []; + } catch { + shiftOptions.value = []; + } +}; + +/** 加载班组下拉选项 */ +const loadClassTeamOptions = async () => { + try { + const res = await getBaseClassTeamInfoList({}); + classTeamOptions.value = (res as any).data || []; + } catch { + classTeamOptions.value = []; + } +}; + +/** 打开物料选择对话框 */ +const openMaterialSelect = () => { + materialDialogVisible.value = true; + nextTick(() => { + materialSelectRef.value?.getList(); + }); +}; + +/** 确认物料选择 */ +const handleMaterialConfirm = () => { + const selected = materialSelectRef.value?.getSelected(); + if (selected) { + traceQuery.materialName = selected.materialName; + materialDialogVisible.value = false; + } else { + proxy?.$modal?.msgWarning?.('请选择物料'); + } +}; + +/** 清除物料选择 */ +const clearMaterialSelect = () => { + traceQuery.materialName = undefined; +}; + /** 从列表数据构建配方树(父=配方编码+物料名,子=该配方下的记录) */ const buildRecipeTree = (list: any[]) => { const grouped = new Map(); @@ -892,6 +979,10 @@ watch( /** 列表数据变化时构建配方树 */ watch(traceList, (list) => { + // 点击配方树后会按 recipeId 过滤列表,此时不重建树,避免只剩当前配方 + if (traceQuery.recipeId && recipeTreeData.value.length > 0) { + return; + } buildRecipeTree(list); }); @@ -911,6 +1002,10 @@ watch(detailTab, async (tab) => { onMounted(() => { getTraceList(); window.addEventListener('resize', handleResize); + // 加载下拉框数据 + loadMachineOptions(); + loadShiftOptions(); + loadClassTeamOptions(); // 重置查询时清除选中状态 watch(() => traceQuery.pageNum, () => { selectedRow.value = null; diff --git a/src/views/mes/mixTrace/lot/index.vue b/src/views/mes/mixTrace/lot/index.vue index ee36941..b85e8c1 100644 --- a/src/views/mes/mixTrace/lot/index.vue +++ b/src/views/mes/mixTrace/lot/index.vue @@ -6,7 +6,9 @@ 按生产机台 - + + + @@ -25,12 +27,16 @@ 按班组 - + + + 按班次 - + + + @@ -116,6 +122,12 @@ import { ArrowRight, DArrowRight } from '@element-plus/icons-vue'; import * as echarts from 'echarts'; import { getMixTraceDetail, listMixTrace } from '@/api/mes/mixTrace'; import type { MixTraceDetailQuery, MixTraceDetailVO, MixTraceQuery, MixTraceStepItem } from '@/api/mes/mixTrace/types'; +import { getProdBaseMachineInfoList } from '@/api/mes/prodBaseMachineInfo'; +import { getBaseShiftInfoList } from '@/api/mes/baseShiftInfo'; +import { getBaseClassTeamInfoList } from '@/api/mes/baseClassTeamInfo'; +import type { ProdBaseMachineInfoVO } from '@/api/mes/prodBaseMachineInfo/types'; +import type { BaseShiftInfoVO } from '@/api/mes/baseShiftInfo/types'; +import type { BaseClassTeamInfoVO } from '@/api/mes/baseClassTeamInfo/types'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; @@ -151,6 +163,11 @@ const records = ref([]); const currentIndex = ref(-1); const currentRow = computed(() => (currentIndex.value >= 0 && currentIndex.value < records.value.length) ? records.value[currentIndex.value] : null); +/** 下拉框数据 */ +const machineOptions = ref([]); +const shiftOptions = ref([]); +const classTeamOptions = ref([]); + /* ======================== 详情数据 ======================== */ const detailData = ref(null); const summary = computed(() => detailData.value?.summaryInfo || {}); @@ -232,6 +249,36 @@ const handleReset = () => { detailData.value = null; }; +/** 加载机台下拉选项 */ +const loadMachineOptions = async () => { + try { + const res = await getProdBaseMachineInfoList({}); + machineOptions.value = (res as any).data || []; + } catch { + machineOptions.value = []; + } +}; + +/** 加载班次下拉选项 */ +const loadShiftOptions = async () => { + try { + const res = await getBaseShiftInfoList({}); + shiftOptions.value = (res as any).data || []; + } catch { + shiftOptions.value = []; + } +}; + +/** 加载班组下拉选项 */ +const loadClassTeamOptions = async () => { + try { + const res = await getBaseClassTeamInfoList({}); + classTeamOptions.value = (res as any).data || []; + } catch { + classTeamOptions.value = []; + } +}; + /* 导航按钮 */ const goFirst = () => { if (records.value.length > 0) currentIndex.value = 0; }; const goPrev = () => { if (currentIndex.value > 0) currentIndex.value--; }; @@ -323,6 +370,10 @@ const handleResize = () => { curveChart?.resize(); }; onMounted(() => { window.addEventListener('resize', handleResize); + // 加载下拉框数据 + loadMachineOptions(); + loadShiftOptions(); + loadClassTeamOptions(); }); onBeforeUnmount(() => {