hy-virtual-tree 1.1.68 → 1.1.69
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 +9 -0
- package/dist/index.js +53 -32
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -197,6 +197,10 @@ let tooltipConfig = {
|
|
|
197
197
|
borderRadius: '4px',
|
|
198
198
|
padding: '7px 9px',
|
|
199
199
|
zIndex: 3200
|
|
200
|
+
},
|
|
201
|
+
props: {
|
|
202
|
+
// 偏移距离
|
|
203
|
+
offset: 0,
|
|
200
204
|
}
|
|
201
205
|
};
|
|
202
206
|
// 获取tooltip配置
|
|
@@ -211,6 +215,12 @@ const setGlobalTooltipConfig = (config) => {
|
|
|
211
215
|
...config.style
|
|
212
216
|
};
|
|
213
217
|
}
|
|
218
|
+
if (config?.props) {
|
|
219
|
+
const { offset } = config.props;
|
|
220
|
+
if (typeof offset === 'number') {
|
|
221
|
+
tooltipConfig.props.offset = offset;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
214
224
|
};
|
|
215
225
|
// 获取全局的配置
|
|
216
226
|
const getGlobalTreeConfig = () => {
|
|
@@ -1264,9 +1274,18 @@ const isShowSelect = (config, node = null) => {
|
|
|
1264
1274
|
return !!(isFunction(showSelect) && showSelect(node.data, node));
|
|
1265
1275
|
};
|
|
1266
1276
|
const isCheckLeaf = (config, node) => {
|
|
1267
|
-
|
|
1277
|
+
// 非通道业务
|
|
1278
|
+
if (config.business !== Business.CHANNEL)
|
|
1268
1279
|
return node.isLeaf;
|
|
1269
|
-
|
|
1280
|
+
// 未开启通道可选中
|
|
1281
|
+
if (!config.businessConfig.isShowChannelSelect) {
|
|
1282
|
+
return node.data.dataType === 3 ? true : node.isLeaf;
|
|
1283
|
+
}
|
|
1284
|
+
// 仅显示在线数据
|
|
1285
|
+
if (config.businessConfig?.showOnlineState) {
|
|
1286
|
+
return node.data.dataType === 3 && !node.count ? true : node.isLeaf;
|
|
1287
|
+
}
|
|
1288
|
+
return node.isLeaf;
|
|
1270
1289
|
};
|
|
1271
1290
|
function useCheck(props, instance) {
|
|
1272
1291
|
const tree = instance._tree;
|
|
@@ -2222,7 +2241,10 @@ function updateDeviceChannelTree(tree, data, config) {
|
|
|
2222
2241
|
const deviceMap = tree.deviceMap || new Map();
|
|
2223
2242
|
const channelMap = tree.channelMap || new Map();
|
|
2224
2243
|
let beOnlineList = [], beOfflineList = [];
|
|
2225
|
-
|
|
2244
|
+
// 是否触发选中事件
|
|
2245
|
+
let checkedChangeNode = undefined;
|
|
2246
|
+
let isCheckedChange = false;
|
|
2247
|
+
const { businessConfig, hiddenNodeKeySet, isChecked, isIndeterminate, toggleCheckbox } = config;
|
|
2226
2248
|
const { countFilter, totalFilter, setDeviceStatus } = useHandleFun(config);
|
|
2227
2249
|
const { sortByStatus, showOnlineState } = businessConfig;
|
|
2228
2250
|
// 是否参与统计
|
|
@@ -2292,7 +2314,8 @@ function updateDeviceChannelTree(tree, data, config) {
|
|
|
2292
2314
|
// 通道
|
|
2293
2315
|
if (v.channelId) {
|
|
2294
2316
|
const channel = channelMap.get(v.channelId);
|
|
2295
|
-
|
|
2317
|
+
const channelParent = channel.parent;
|
|
2318
|
+
if (!channel || !parent)
|
|
2296
2319
|
return;
|
|
2297
2320
|
Object.assign(channel, {
|
|
2298
2321
|
data: {
|
|
@@ -2311,9 +2334,15 @@ function updateDeviceChannelTree(tree, data, config) {
|
|
|
2311
2334
|
else {
|
|
2312
2335
|
tree.hiddenNodeKeySet.delete(channel.key);
|
|
2313
2336
|
beOnlineList.push(channel);
|
|
2337
|
+
// 设备在线,而设备下通道全部离线,且此时通道上线,自动勾选通道
|
|
2338
|
+
if (config.businessConfig.isShowChannelSelect && !channelParent.count && isChecked(channelParent)) {
|
|
2339
|
+
toggleCheckbox(channel, true, false, true, false);
|
|
2340
|
+
checkedChangeNode = channel;
|
|
2341
|
+
isCheckedChange = true;
|
|
2342
|
+
}
|
|
2314
2343
|
}
|
|
2315
2344
|
}
|
|
2316
|
-
|
|
2345
|
+
parentMap.set(channelParent.key, channelParent);
|
|
2317
2346
|
}
|
|
2318
2347
|
// 设备
|
|
2319
2348
|
else {
|
|
@@ -2353,7 +2382,7 @@ function updateDeviceChannelTree(tree, data, config) {
|
|
|
2353
2382
|
}
|
|
2354
2383
|
});
|
|
2355
2384
|
updateParnetCount(parentMap);
|
|
2356
|
-
return { tree, beOnlineList, beOfflineList };
|
|
2385
|
+
return { tree, beOnlineList, beOfflineList, checkedChangeNode, isCheckedChange };
|
|
2357
2386
|
}
|
|
2358
2387
|
// 用户树
|
|
2359
2388
|
function updateUserTree(tree, data, config) {
|
|
@@ -9344,9 +9373,7 @@ class VirtualTree {
|
|
|
9344
9373
|
return;
|
|
9345
9374
|
this._tree = await this._createTree(config.data);
|
|
9346
9375
|
this._flattenTree = this._genereateFlattenTree();
|
|
9347
|
-
const { checkedKeys, updateCheckedKeys, isIndeterminate, isChecked, toggleCheckbox, getChecked,
|
|
9348
|
-
// afterNodeCheck,
|
|
9349
|
-
getCheckedKeys, getCheckedNodes, getCheckedBusinessNodes,
|
|
9376
|
+
const { checkedKeys, updateCheckedKeys, isIndeterminate, isChecked, toggleCheckbox, getChecked, afterNodeCheck, getCheckedKeys, getCheckedNodes, getCheckedBusinessNodes,
|
|
9350
9377
|
// getHalfCheckedKeys,
|
|
9351
9378
|
// getHalfCheckedNodes,
|
|
9352
9379
|
setChecked, setCheckedKeys, setCheckedNodes, getSwitchCheckedValue, } = useCheck(config, this);
|
|
@@ -9394,10 +9421,7 @@ class VirtualTree {
|
|
|
9394
9421
|
const icon = document.createElement('div');
|
|
9395
9422
|
icon.classList.add('hy-tree-node__expand-icon');
|
|
9396
9423
|
el.appendChild(icon);
|
|
9397
|
-
|
|
9398
|
-
? item.isLeaf
|
|
9399
|
-
: this._businessConfig?.showOnlineState ? !item.count : !item.total;
|
|
9400
|
-
if (isHideIcon || this._hiddenExpandIconKeySet.has(item.key)) {
|
|
9424
|
+
if (isCheckLeaf(config, item) || this._hiddenExpandIconKeySet.has(item.key)) {
|
|
9401
9425
|
el.style.setProperty('visibility', 'hidden');
|
|
9402
9426
|
}
|
|
9403
9427
|
else {
|
|
@@ -9566,21 +9590,22 @@ class VirtualTree {
|
|
|
9566
9590
|
if (config.onNodeClick) {
|
|
9567
9591
|
await config.onNodeClick(getNodeData(item), item, e);
|
|
9568
9592
|
}
|
|
9593
|
+
const isLeaf = isCheckLeaf(config, item);
|
|
9569
9594
|
if (!getDisabled(config, item) && isShowSelect(config, item)) {
|
|
9570
9595
|
if (config.checkOnClickNode) {
|
|
9571
9596
|
toggleCheckbox(item, !(isChecked(item) || isIndeterminate(item)), true, true);
|
|
9572
|
-
if (!config.expandOnClickNode ||
|
|
9597
|
+
if (!config.expandOnClickNode || isLeaf) {
|
|
9573
9598
|
this.refresh();
|
|
9574
9599
|
}
|
|
9575
9600
|
}
|
|
9576
|
-
else if (
|
|
9601
|
+
else if (isLeaf && config.checkOnClickLeaf) {
|
|
9577
9602
|
toggleCheckbox(item, !isChecked(item), true, true);
|
|
9578
|
-
if (!config.expandOnClickNode ||
|
|
9603
|
+
if (!config.expandOnClickNode || isLeaf) {
|
|
9579
9604
|
this.refresh();
|
|
9580
9605
|
}
|
|
9581
9606
|
}
|
|
9582
9607
|
}
|
|
9583
|
-
if (config.expandOnClickNode && !
|
|
9608
|
+
if (config.expandOnClickNode && !isLeaf) {
|
|
9584
9609
|
this._expandedHandle(item);
|
|
9585
9610
|
this._refreshVirtualScroll();
|
|
9586
9611
|
}
|
|
@@ -9604,7 +9629,7 @@ class VirtualTree {
|
|
|
9604
9629
|
return;
|
|
9605
9630
|
e.stopPropagation();
|
|
9606
9631
|
if ((getDisabled(config, item) ||
|
|
9607
|
-
item
|
|
9632
|
+
isCheckLeaf(config, item) ||
|
|
9608
9633
|
!config.checkOnDblclickParentNode) &&
|
|
9609
9634
|
!config.onNodeDblClick) {
|
|
9610
9635
|
nodeClickHandle(e);
|
|
@@ -9633,7 +9658,7 @@ class VirtualTree {
|
|
|
9633
9658
|
await config.onNodeDblClick(getNodeData(item), item, e);
|
|
9634
9659
|
}
|
|
9635
9660
|
if (getDisabled(config, item) ||
|
|
9636
|
-
item
|
|
9661
|
+
isCheckLeaf(config, item) ||
|
|
9637
9662
|
!config.checkOnDblclickParentNode ||
|
|
9638
9663
|
!isShowSelect(config, item)) {
|
|
9639
9664
|
return;
|
|
@@ -9726,7 +9751,7 @@ class VirtualTree {
|
|
|
9726
9751
|
reject({});
|
|
9727
9752
|
return;
|
|
9728
9753
|
}
|
|
9729
|
-
const { tree } = updateMethod(this._tree, data, {
|
|
9754
|
+
const { tree, checkedChangeNode, isCheckedChange } = updateMethod(this._tree, data, {
|
|
9730
9755
|
business: this._business,
|
|
9731
9756
|
props: {
|
|
9732
9757
|
value: this._props.value,
|
|
@@ -9736,21 +9761,17 @@ class VirtualTree {
|
|
|
9736
9761
|
total: this._props.total
|
|
9737
9762
|
},
|
|
9738
9763
|
businessConfig: this._businessConfig,
|
|
9739
|
-
hiddenNodeKeySet: this._hiddenNodeKeySet
|
|
9764
|
+
hiddenNodeKeySet: this._hiddenNodeKeySet,
|
|
9765
|
+
isChecked,
|
|
9766
|
+
isIndeterminate,
|
|
9767
|
+
toggleCheckbox
|
|
9740
9768
|
});
|
|
9741
9769
|
Object.assign(this._tree, tree);
|
|
9742
|
-
// 设备离线时取消勾选状态
|
|
9743
|
-
// let updateNode = null
|
|
9744
|
-
// for (const node of (beOfflineList || [])) {
|
|
9745
|
-
// if (checkedKeys.has(node.key)) {
|
|
9746
|
-
// checkedKeys.delete(node.key)
|
|
9747
|
-
// updateNode = node
|
|
9748
|
-
// }
|
|
9749
|
-
// }
|
|
9750
9770
|
updateCheckedKeys();
|
|
9751
|
-
//
|
|
9752
|
-
|
|
9753
|
-
|
|
9771
|
+
// 选中数据更新,触发选中事件
|
|
9772
|
+
if (checkedChangeNode && isCheckedChange) {
|
|
9773
|
+
afterNodeCheck(checkedChangeNode, true);
|
|
9774
|
+
}
|
|
9754
9775
|
resolve({});
|
|
9755
9776
|
return;
|
|
9756
9777
|
}
|