style:设备台账-产线分类-树状结果添加“全部”

test
黄伟杰 2 weeks ago
parent 0c54297178
commit 47432c5c63

@ -1257,6 +1257,7 @@ export default {
// Equipment Ledger
EquipmentLedger: {
lineCategory: 'Production Line Category',
lineCategoryAll: 'All',
createLineCategory: 'Add Production Line Category',
updateLineCategory: 'Edit Production Line Category',
emptyDeviceData: 'No device data',

@ -1247,6 +1247,7 @@ export default {
// 设备台账
EquipmentLedger: {
lineCategory: '产线分类',
lineCategoryAll: '全部',
createLineCategory: '新增产线分类',
updateLineCategory: '修改产线分类',
emptyDeviceData: '暂无设备数据',

@ -17,7 +17,7 @@
<template #default="{ node, data }">
<span class="custom-tree-node">
<span class="tree-node-label">{{ node.label }}</span>
<span class="tree-node-actions">
<span v-if="!isAllTypeNode(data)" class="tree-node-actions">
<el-button link type="primary" size="small" @click.stop="handleTreeAdd(data)">
<Icon icon="ep:plus" />
</el-button>
@ -453,6 +453,7 @@ const treeSelectProps = { label: 'name', children: 'children' }
const typeTreeExpandedKeys = ref<number[]>([])
const deviceTypeTree = ref<DeviceTypeTreeVO[]>([])
const deviceTypeNameMap = ref<Record<number, string>>({})
const ALL_TYPE_NODE_ID = -1
const buildDeviceTypeNameMap = (nodes: DeviceTypeTreeVO[]) => {
const map: Record<number, string> = {}
@ -465,15 +466,32 @@ const buildDeviceTypeNameMap = (nodes: DeviceTypeTreeVO[]) => {
deviceTypeNameMap.value = map
}
const isAllTypeNode = (node: any) => Number(node?.id) === ALL_TYPE_NODE_ID
const buildTypeTreeWithAll = (nodes: DeviceLineTreeVO[]) => {
return [
{
id: ALL_TYPE_NODE_ID,
code: '',
isCode: false,
name: t('EquipmentManagement.EquipmentLedger.lineCategoryAll'),
qrcodeUrl: '',
remark: '',
sort: 0,
parentId: 0,
parentChain: '0',
children: nodes
}
] as DeviceLineTreeVO[]
}
const getTypeTree = async () => {
typeTreeLoading.value = true
try {
const data = await DeviceLineApi.getDeviceLineTree()
const treeData = JSON.parse(JSON.stringify(data ?? []))
typeTreeData.value = treeData
if (treeData.length > 0) {
typeTreeExpandedKeys.value = [treeData[0].id]
}
typeTreeData.value = buildTypeTreeWithAll(treeData)
typeTreeExpandedKeys.value = treeData.length > 0 ? [ALL_TYPE_NODE_ID, treeData[0].id] : [ALL_TYPE_NODE_ID]
} finally {
typeTreeLoading.value = false
}
@ -487,6 +505,13 @@ const getDeviceTypeTree = async () => {
}
const handleTypeNodeClick = (node: any) => {
if (isAllTypeNode(node)) {
selectedDeviceLineId.value = undefined
queryParams.deviceLine = undefined
queryParams.pageNo = 1
getList()
return
}
const id = node?.id
selectedDeviceLineId.value = id
queryParams.deviceLine = id

Loading…
Cancel
Save