hy-virtual-tree 1.1.39 → 1.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.1.40
4
+
5
+ _2025-10-24_
6
+
7
+ - 扩展[VirtualTree] 功能
8
+ (1)修复更新设备数据时,统计在线数据出错问题
9
+
3
10
  ### 1.1.39
4
11
 
5
12
  _2025-10-24_
package/dist/index.js CHANGED
@@ -1217,7 +1217,6 @@ function useFilter(config, filterMethod, tree = {
1217
1217
  nodes.forEach((node) => {
1218
1218
  const businessList = [];
1219
1219
  family.push(node);
1220
- // if (tree.hiddenNodeKeySet.has(node.key)) return
1221
1220
  if (isShow || (filterMethod && filterMethod(params, node.data, node))) {
1222
1221
  family.forEach((member) => {
1223
1222
  expandKeySet.add(member.key);
@@ -1251,12 +1250,14 @@ function useFilter(config, filterMethod, tree = {
1251
1250
  else if (!hiddenKeys.has(node.key)) {
1252
1251
  node.count = 0;
1253
1252
  node.total = 0;
1254
- // 统计
1255
- if (isCountFiler && countFilter) {
1256
- count += countFilter(node.data) ? 1 : 0;
1257
- }
1258
- if (isTotalFiler && totalFilter) {
1259
- total += totalFilter(node.data) ? 1 : 0;
1253
+ // 统计,当仅展示在线时,不统计离线的设备
1254
+ if (!tree.hiddenNodeKeySet.has(node.key)) {
1255
+ if (isCountFiler && countFilter) {
1256
+ count += countFilter(node.data) ? 1 : 0;
1257
+ }
1258
+ if (isTotalFiler && totalFilter) {
1259
+ total += totalFilter(node.data) ? 1 : 0;
1260
+ }
1260
1261
  }
1261
1262
  }
1262
1263
  if (!node.isLeaf) {
@@ -1325,9 +1326,11 @@ function useFilter(config, filterMethod, tree = {
1325
1326
  node.count = 0;
1326
1327
  node.total = 0;
1327
1328
  }
1328
- // 统计
1329
- count += node.count || 0;
1330
- total += node.total || 0;
1329
+ // 统计,当仅展示在线时,不统计离线的设备
1330
+ if (!tree.hiddenNodeKeySet.has(node.key)) {
1331
+ count += node.count || 0;
1332
+ total += node.total || 0;
1333
+ }
1331
1334
  }
1332
1335
  if (!node.isLeaf) {
1333
1336
  if (!expandKeySet.has(node.key)) {
@@ -1461,7 +1464,6 @@ var WorkerFactory = /*#__PURE__*/createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdp
1461
1464
  function updateDeviceTree(tree, data, config) {
1462
1465
  const deviceMap = tree.deviceMap || new Map();
1463
1466
  let beOnlineList = [], beOfflineList = [];
1464
- const { hiddenNodeKeySet } = config;
1465
1467
  const { countFilter, totalFilter, setDeviceStatus } = useHandleFun(config);
1466
1468
  const { sortByStatus, showOnlineState, integratedBusiness } = config.businessConfig;
1467
1469
  // 更新父节点统计
@@ -1471,7 +1473,7 @@ function updateDeviceTree(tree, data, config) {
1471
1473
  const parentKeySet = new Set();
1472
1474
  for (const key of keySet) {
1473
1475
  const target = tree.treeNodeMap.get(key);
1474
- if (!target || hiddenNodeKeySet.has(target.key))
1476
+ if (!target)
1475
1477
  continue;
1476
1478
  let count = isCountFiler ? 0 : target.data.count;
1477
1479
  let total = isTotalFiler ? 0 : target.data.total;
@@ -1481,8 +1483,6 @@ function updateDeviceTree(tree, data, config) {
1481
1483
  let children = target.children || [];
1482
1484
  for (let i = 0; i < children.length; i++) {
1483
1485
  const item = target.children[i];
1484
- if (hiddenNodeKeySet.has(item.key))
1485
- continue;
1486
1486
  count =
1487
1487
  isCountFiler && !tree.hiddenNodeKeySet.has(item.key) && countFilter
1488
1488
  ? count + (item.children ? item.count : countFilter(item.data))
@@ -1509,9 +1509,9 @@ function updateDeviceTree(tree, data, config) {
1509
1509
  }
1510
1510
  target.data.childrenDeviceList = businessList;
1511
1511
  }
1512
- // 在仅显示设备时,切换显隐状态
1513
- if (showOnlineState) {
1514
- tree.hiddenNodeKeySet[count === 0 ? 'add' : 'delete'](target.key);
1512
+ // 在仅显示设备时,设置 部门/群组 显示状态
1513
+ if (showOnlineState && count > 0) {
1514
+ tree.hiddenNodeKeySet.delete(target.key);
1515
1515
  }
1516
1516
  target.count = count;
1517
1517
  target.total = total;
@@ -1825,8 +1825,13 @@ class VirtualTree {
1825
1825
  }
1826
1826
  while (stack.length) {
1827
1827
  const node = stack.pop();
1828
- if (hiddenKeys.has(node.key) || this._tree.hiddenNodeKeySet.has(node.key))
1828
+ if (hiddenKeys.has(node.key) ||
1829
+ this._tree.hiddenNodeKeySet.has(node.key) ||
1830
+ (this._businessConfig?.showOnlineState &&
1831
+ /^(1|4)$/.test(node.data.dataType) &&
1832
+ !node.count)) {
1829
1833
  continue;
1834
+ }
1830
1835
  flattenNodes.push(node);
1831
1836
  if (node.children && expandedKeys.has(node.key)) {
1832
1837
  for (let i = node.children.length - 1; i >= 0; --i) {
@@ -2307,7 +2312,6 @@ class VirtualTree {
2307
2312
  count: this._props.count,
2308
2313
  total: this._props.total
2309
2314
  },
2310
- hiddenNodeKeySet: this._hiddenNodeKeySet,
2311
2315
  businessConfig: this._businessConfig
2312
2316
  });
2313
2317
  Object.assign(this._tree, tree);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hy-virtual-tree",
3
- "version": "1.1.39",
3
+ "version": "1.1.40",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",