diff --git a/src/locales/en-US.js b/src/locales/en-US.js index e3c3036..362ec8e 100644 --- a/src/locales/en-US.js +++ b/src/locales/en-US.js @@ -368,7 +368,19 @@ export default { changeTarget: 'Change Dismount Target', confirmDismount: 'Confirm Dismount', clickSelectDeviceFirst: 'Please select a device first', - noMoldOnDevice: 'No mold on this device' + noMoldOnDevice: 'No mold on this device', + historySuffix: ' History', + historyTitle: 'Mold Operate History', + searchPlaceholder: 'Search device/mold name', + filterAll: 'All', + filterToday: 'Today', + filterWeek: 'This Week', + historyEmpty: 'No history records', + totalPrefix: 'Total: ', + totalSuffix: '', + confirmDeleteHistory: 'Confirm delete this history record?', + operateTime: 'Operate Time', + operator: 'Operator' }, moldInspectionItems: { moduleName: 'Inspection Items', diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js index 38cee89..01e0b99 100644 --- a/src/locales/zh-CN.js +++ b/src/locales/zh-CN.js @@ -368,7 +368,19 @@ export default { changeTarget: '更换下模对象', confirmDismount: '确认下模', clickSelectDeviceFirst: '请先选择设备', - noMoldOnDevice: '该设备暂无在机模具' + noMoldOnDevice: '该设备暂无在机模具', + historySuffix: '历史', + historyTitle: '上下模历史', + searchPlaceholder: '搜索设备/模具名称', + filterAll: '全部', + filterToday: '今天', + filterWeek: '本周', + historyEmpty: '暂无历史记录', + totalPrefix: '共 ', + totalSuffix: ' 条', + confirmDeleteHistory: '确认删除该历史记录吗?', + operateTime: '操作时间', + operator: '操作人' }, moldInspectionItems: { moduleName: '点检项库', diff --git a/src/pages.json b/src/pages.json index 65543ff..5ca6cd6 100644 --- a/src/pages.json +++ b/src/pages.json @@ -610,6 +610,13 @@ "navigationStyle": "custom" } }, + { + "path": "moldoperate/history", + "style": { + "navigationBarTitleText": "上下模历史", + "navigationStyle": "custom" + } + }, { "path": "moldRepair/index", "style": { diff --git a/src/pages_function/pages/moldoperate/deviceSelect.vue b/src/pages_function/pages/moldoperate/deviceSelect.vue index 8ff61e4..a8d5afa 100644 --- a/src/pages_function/pages/moldoperate/deviceSelect.vue +++ b/src/pages_function/pages/moldoperate/deviceSelect.vue @@ -33,7 +33,7 @@ {{ t('moldOperate.productionLine') }} - {{ textValue(device.workshopName) }} + {{ getTopLineName(device.deviceLine) }} {{ t('moldOperate.currentMold') }} @@ -68,6 +68,7 @@ import { onShow } from '@dcloudio/uni-app' import { useI18n } from 'vue-i18n' import NavBar from '@/components/common/NavBar.vue' import { getDeviceLedgerList } from '@/api/mes/moldoperate' +import { getDeviceLineTree } from '@/api/mes/deviceLine' const { t } = useI18n() @@ -76,6 +77,8 @@ const selectedId = ref(null) const searchText = ref('') const loading = ref(false) +const lineInfoMap = ref(new Map()) + function textValue(v) { if (v === 0) return '0' if (v == null) return '-' @@ -163,13 +166,64 @@ function getCurrentMold(device) { return staticMold === '-' ? t('moldOperate.noMoldOnDevice') : staticMold } +function flattenLineTree(nodes, parentId) { + if (!Array.isArray(nodes)) return + for (const node of nodes) { + if (node.id != null && node.name != null) { + lineInfoMap.value.set(String(node.id), { + id: node.id, + name: node.name, + parentId: node.parentId != null ? node.parentId : (parentId || null), + parentChain: node.parentChain || '' + }) + } + if (Array.isArray(node.children)) { + flattenLineTree(node.children, node.id) + } + } +} + +function getTopLineName(deviceLineId) { + if (deviceLineId == null) return '-' + const node = lineInfoMap.value.get(String(deviceLineId)) + if (!node) return '-' + if (node.parentChain) { + const firstId = node.parentChain.split(',')[0]?.trim() + if (firstId) { + const topNode = lineInfoMap.value.get(firstId) + if (topNode) return topNode.name + } + } + let current = node + const visited = new Set() + while (current.parentId != null && current.parentId > 0 && !visited.has(current.id)) { + visited.add(current.id) + const parent = lineInfoMap.value.get(String(current.parentId)) + if (!parent) break + current = parent + } + return current.name || '-' +} + +async function loadLineTree() { + if (lineInfoMap.value.size > 0) return + try { + const res = await getDeviceLineTree() + const tree = (res && res.data !== undefined) ? res.data : res + const nodes = Array.isArray(tree) ? tree : (tree?.list || tree?.children || []) + flattenLineTree(nodes) + } catch (e) { + console.error('load line tree error', e) + } +} + const filteredList = computed(() => { const keyword = searchText.value.trim().toLowerCase() if (!keyword) return deviceList.value return deviceList.value.filter((d) => { return (d.deviceName || '').toLowerCase().includes(keyword) || (d.deviceCode || '').toLowerCase().includes(keyword) || - (d.workshopName || '').toLowerCase().includes(keyword) + (getTopLineName(d.deviceLine) || '').toLowerCase().includes(keyword) }) }) @@ -203,13 +257,19 @@ function handleConfirm() { return } const device = deviceList.value.find((d) => d.id === selectedId.value) + if (device) { + const lineName = getTopLineName(device.deviceLine) + if (lineName && lineName !== '-') { + device.workshopName = lineName + } + } // 存入 globalData 后再返回,目标页 onShow 中读取 getApp().globalData._deviceSelectResult = device || null uni.navigateBack() } onShow(async () => { - await loadDevices() + await Promise.allSettled([loadDevices(), loadLineTree()]) }) diff --git a/src/pages_function/pages/moldoperate/dismount.vue b/src/pages_function/pages/moldoperate/dismount.vue index e802b79..4db7a38 100644 --- a/src/pages_function/pages/moldoperate/dismount.vue +++ b/src/pages_function/pages/moldoperate/dismount.vue @@ -1,6 +1,10 @@