diff --git a/src/views/erp/stock/move/components/StockMoveItemForm.vue b/src/views/erp/stock/move/components/StockMoveItemForm.vue index aa501f8c..a48e1b66 100644 --- a/src/views/erp/stock/move/components/StockMoveItemForm.vue +++ b/src/views/erp/stock/move/components/StockMoveItemForm.vue @@ -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) { diff --git a/src/views/iot/deviceParamAnalysis/index.vue b/src/views/iot/deviceParamAnalysis/index.vue index 5b69fdb3..e04dc2d4 100644 --- a/src/views/iot/deviceParamAnalysis/index.vue +++ b/src/views/iot/deviceParamAnalysis/index.vue @@ -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) {