style:设备运行参数分析-默认展开到设备层

main
黄伟杰 2 days ago
parent 29e0d17d60
commit ceb8b3fdb9

@ -625,20 +625,21 @@ function getProductOptionRowKey(row) {
}
function normalizeStockProductOptions(list) {
return (list || [])
.map((item) => {
const productId = getProductOptionId(item)
return {
...item,
id: productId,
productId,
name: item.name || item.productName,
unitName: item.unitName || item.purchaseUnitName,
subCategoryName: item.subCategoryName || item.categoryName,
stockDisplay: item.stockDisplay || item.totalBaseCount || item.count || item.stockCount
}
const map = new Map()
;(list || []).forEach((item) => {
const productId = getProductOptionId(item)
if (!productId || map.has(String(productId))) return
map.set(String(productId), {
...item,
id: productId,
productId,
name: item.name || item.productName,
unitName: item.unitName || item.purchaseUnitName,
subCategoryName: item.subCategoryName || item.categoryName,
stockDisplay: item.stockDisplay || item.totalBaseCount || item.count || item.stockCount
})
.filter((item) => item.productId)
})
return Array.from(map.values())
}
function normalizeProductStockList(data) {

@ -345,23 +345,21 @@ const buildTreeFromApi = (orgs: ApiTreeOrg[]): DeviceTreeNode[] => {
return Array.isArray(orgTree) ? orgTree.map(toOrgNode) : []
}
const hasOrgClassInSubtree = (node: DeviceTreeNode, targetOrgClass: string): boolean => {
const hasEquipmentInSubtree = (node: DeviceTreeNode): boolean => {
const children = Array.isArray(node?.children) ? node.children : []
for (const child of children) {
if (child?.orgClass === targetOrgClass) return true
if (hasOrgClassInSubtree(child, targetOrgClass)) return true
if (child?.tag === 'equipment') return true
if (hasEquipmentInSubtree(child)) return true
}
return false
}
const buildDefaultExpandedKeys = (nodes: DeviceTreeNode[], stopOrgClass: string): string[] => {
const buildDefaultExpandedKeys = (nodes: DeviceTreeNode[]): string[] => {
const keys: string[] = []
const walk = (list: DeviceTreeNode[]) => {
for (const node of list) {
if (node?.type === 'device' && node?.orgClass && node.orgClass !== stopOrgClass) {
if (hasOrgClassInSubtree(node, stopOrgClass)) {
keys.push(node.id)
}
if (node?.type === 'device' && node?.tag !== 'equipment' && hasEquipmentInSubtree(node)) {
keys.push(node.id)
}
const children = Array.isArray(node?.children) ? node.children : []
if (children.length) walk(children)
@ -388,7 +386,7 @@ const loadTree = async () => {
filterNoDeviceLine: 1
})
treeData.value = buildTreeFromApi(extractApiOrgs(res))
defaultExpandedKeys.value = buildDefaultExpandedKeys(treeData.value, 'pipeline')
defaultExpandedKeys.value = buildDefaultExpandedKeys(treeData.value)
await nextTick()
treeRef.value?.setExpandedKeys?.(defaultExpandedKeys.value)
if (keyword.value) {

Loading…
Cancel
Save