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

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

@ -625,10 +625,11 @@ 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
map.set(String(productId), {
...item, ...item,
id: productId, id: productId,
productId, productId,
@ -636,9 +637,9 @@ function normalizeStockProductOptions(list) {
unitName: item.unitName || item.purchaseUnitName, unitName: item.unitName || item.purchaseUnitName,
subCategoryName: item.subCategoryName || item.categoryName, subCategoryName: item.subCategoryName || item.categoryName,
stockDisplay: item.stockDisplay || item.totalBaseCount || item.count || item.stockCount 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,24 +345,22 @@ 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