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

main
黄伟杰 1 week ago
parent 29e0d17d60
commit ceb8b3fdb9

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

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

Loading…
Cancel
Save