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 @@
-
+
+
+
+
+
@@ -38,7 +42,7 @@
{{ t('moldOperate.productionLine') }}
- {{ textValue(selectedDevice.workshopName) }}
+ {{ getTopLineName(selectedDevice.deviceLine) }}
{{ t('moldOperate.deviceStatus') }}
@@ -140,9 +144,70 @@ import { onShow } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import NavBar from '@/components/common/NavBar.vue'
import { getLowerMoldList, getDeviceLedgerList, createMoldOperate } from '@/api/mes/moldoperate'
+import { getDeviceLineTree } from '@/api/mes/deviceLine'
const { t } = useI18n()
+const lineInfoMap = ref(new Map()) // deviceLine id → { name, parentId, parentChain }
+
+// 递归拍平产线树(保存完整节点信息用于向上追溯)
+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)
+ }
+ }
+}
+
+// 根据设备产线节点,向上追溯顶层产线名称(参考后端 fillTopCategoryInfo 逻辑)
+function getTopLineName(deviceLineId) {
+ if (deviceLineId == null) return '-'
+ const node = lineInfoMap.value.get(String(deviceLineId))
+ if (!node) return String(deviceLineId)
+
+ // 策略1:通过 parentChain 取第一个 ID(最顶层)
+ if (node.parentChain) {
+ const firstId = node.parentChain.split(',')[0]?.trim()
+ if (firstId) {
+ const topNode = lineInfoMap.value.get(firstId)
+ if (topNode) return topNode.name
+ }
+ }
+
+ // 策略2:通过 parentId 向上遍历直到根节点
+ 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 || String(deviceLineId)
+}
+
+// 加载产线树
+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 selectedDevice = ref({})
const deviceOptions = ref([])
@@ -376,6 +441,10 @@ function handleSelectDeviceFirst() {
openDevicePicker()
}
+function goToHistory() {
+ uni.navigateTo({ url: '/pages_function/pages/moldoperate/history?type=down' })
+}
+
// ---- 提交 ----
function validForm() {
if (!selectedDevice.value?.id) {
@@ -392,10 +461,13 @@ function validForm() {
async function handleConfirm() {
if (!validForm()) return
try {
+ const device = selectedDevice.value
const payload = {
operateType: '2',
- deviceId: String(selectedDevice.value.id),
- moldId: String(selectedMold.value.id)
+ deviceId: String(device.id),
+ moldId: String(selectedMold.value.id),
+ lineId: device.deviceLine != null ? String(device.deviceLine) : undefined,
+ lineName: device.deviceLine != null ? getTopLineName(device.deviceLine) : (device.lineName || undefined)
}
console.log('[下模] 提交参数 =', JSON.stringify(payload))
await createMoldOperate(payload)
@@ -420,7 +492,7 @@ async function handleConfirm() {
}
onShow(async () => {
- await Promise.allSettled([loadDevices()])
+ await Promise.allSettled([loadDevices(), loadLineTree()])
// 从 globalData 读取设备选择页回传的设备
const device = getApp().globalData._deviceSelectResult
if (device) {
@@ -431,6 +503,11 @@ onShow(async () => {
diff --git a/src/pages_function/pages/moldoperate/index.vue b/src/pages_function/pages/moldoperate/index.vue
index fbf033c..8a5d030 100644
--- a/src/pages_function/pages/moldoperate/index.vue
+++ b/src/pages_function/pages/moldoperate/index.vue
@@ -6,7 +6,7 @@
<
{{ t('moldOperate.tabUp') }}
-
+
@@ -279,7 +279,9 @@ async function handleConfirmMount() {
const payload = {
operateType: '1',
deviceId: String(selectedDevice.value.id),
- moldId: moldIds.length === 1 ? String(moldIds[0]) : moldIds.map(String).join(',')
+ moldId: moldIds.length === 1 ? String(moldIds[0]) : moldIds.map(String).join(','),
+ lineName: selectedDevice.value.workshopName || '',
+ lineId: selectedDevice.value.deviceLine || ''
}
console.log('=== 上模提交参数 ===', JSON.stringify(payload))
console.log('=== deviceId type:', typeof payload.deviceId, 'value:', payload.deviceId)
@@ -348,6 +350,10 @@ function goBack() {
uni.navigateBack({ fail: () => uni.switchTab({ url: '/pages/index/index' }) })
}
+function goToHistory() {
+ uni.navigateTo({ url: '/pages_function/pages/moldoperate/history?type=up' })
+}
+
onShow(async () => {
await Promise.allSettled([loadDevices()])
// 从 globalData 读取设备选择页回传的设备
@@ -400,8 +406,9 @@ onShow(async () => {
font-weight: 600;
}
- .nav-placeholder {
- width: 60rpx;
+ .nav-right-icon {
+ width: 40rpx;
+ height: 40rpx;
}
}
diff --git a/static/logo/history.png b/static/logo/history.png
new file mode 100644
index 0000000..13a7873
Binary files /dev/null and b/static/logo/history.png differ