hy-virtual-tree 1.1.51 → 1.1.53
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 +14 -0
- package/dist/index.js +58 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1503,6 +1503,51 @@ function useCheck(props, tree) {
|
|
|
1503
1503
|
updateCheckedKeys();
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
|
+
// 获取切换选中后的值
|
|
1507
|
+
function getSwitchCheckedValue(node) {
|
|
1508
|
+
if (!isIndeterminate(node) || props.rowSelection.checkStrictly || !node.children?.length)
|
|
1509
|
+
return !isChecked(node);
|
|
1510
|
+
const { isAllSelect } = getNodeCheckInfo(node.children || []);
|
|
1511
|
+
console.log('isAllSelect', isAllSelect);
|
|
1512
|
+
return !isAllSelect;
|
|
1513
|
+
}
|
|
1514
|
+
// 获取当前项选中信息
|
|
1515
|
+
function getNodeCheckInfo(children) {
|
|
1516
|
+
const { checkStrictly } = props.rowSelection;
|
|
1517
|
+
let isAllDisabled = true;
|
|
1518
|
+
let isCanAllSelect = true;
|
|
1519
|
+
let isAllSelect = true;
|
|
1520
|
+
for (const node of children) {
|
|
1521
|
+
if (isChecked(node))
|
|
1522
|
+
continue;
|
|
1523
|
+
// 严格模式 或 非严格模式下没有子元素
|
|
1524
|
+
if (checkStrictly || (!checkStrictly && !node.children?.length)) {
|
|
1525
|
+
if (getDisabled(props, node)) {
|
|
1526
|
+
isCanAllSelect = false;
|
|
1527
|
+
}
|
|
1528
|
+
else if (!isChecked(node)) {
|
|
1529
|
+
isAllSelect = false;
|
|
1530
|
+
isAllDisabled = false;
|
|
1531
|
+
}
|
|
1532
|
+
if (!isAllDisabled && !isCanAllSelect && !isAllSelect) {
|
|
1533
|
+
break;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
// 递归子元素
|
|
1537
|
+
if (node.children?.length) {
|
|
1538
|
+
const checkInfo = getNodeCheckInfo(node.children);
|
|
1539
|
+
if (!checkStrictly) {
|
|
1540
|
+
isAllDisabled = checkInfo.isAllDisabled && isAllDisabled;
|
|
1541
|
+
isCanAllSelect = checkInfo.isCanAllSelect && isCanAllSelect;
|
|
1542
|
+
isAllSelect = checkInfo.isAllSelect && isAllSelect;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
if (!isAllDisabled && !isCanAllSelect && !isAllSelect) {
|
|
1546
|
+
break;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
return { isAllDisabled, isCanAllSelect, isAllSelect };
|
|
1550
|
+
}
|
|
1506
1551
|
return {
|
|
1507
1552
|
checkedKeys,
|
|
1508
1553
|
updateCheckedKeys,
|
|
@@ -1518,7 +1563,8 @@ function useCheck(props, tree) {
|
|
|
1518
1563
|
getHalfCheckedNodes,
|
|
1519
1564
|
setChecked,
|
|
1520
1565
|
setCheckedKeys,
|
|
1521
|
-
setCheckedNodes
|
|
1566
|
+
setCheckedNodes,
|
|
1567
|
+
getSwitchCheckedValue,
|
|
1522
1568
|
};
|
|
1523
1569
|
}
|
|
1524
1570
|
|
|
@@ -1805,16 +1851,20 @@ const useStatus = (config, data, node) => {
|
|
|
1805
1851
|
if (data.dataType !== 3)
|
|
1806
1852
|
return;
|
|
1807
1853
|
el.classList.add('hy-tree-node__status');
|
|
1808
|
-
|
|
1854
|
+
let { deviceStatus } = data;
|
|
1855
|
+
if (deviceStatus === DeviceStatus.ON_LINE && node.children?.some((item) => item.data.deviceStatus === DeviceStatus.BE_MONITOR)) {
|
|
1856
|
+
deviceStatus = DeviceStatus.BE_MONITOR;
|
|
1857
|
+
}
|
|
1858
|
+
if (deviceStatus === DeviceStatus.ON_LINE) {
|
|
1809
1859
|
el.classList.add('hy-text-success');
|
|
1810
1860
|
}
|
|
1811
|
-
else if (
|
|
1861
|
+
else if (deviceStatus === DeviceStatus.SOS) {
|
|
1812
1862
|
el.classList.add('hy-text-danger');
|
|
1813
1863
|
}
|
|
1814
|
-
else if (
|
|
1864
|
+
else if (deviceStatus !== DeviceStatus.OFF_LINE) {
|
|
1815
1865
|
el.classList.add('hy-text-gradient');
|
|
1816
1866
|
}
|
|
1817
|
-
el.innerHTML = deviceStatusMap[
|
|
1867
|
+
el.innerHTML = deviceStatusMap[deviceStatus];
|
|
1818
1868
|
return el;
|
|
1819
1869
|
}
|
|
1820
1870
|
};
|
|
@@ -9091,7 +9141,7 @@ class VirtualTree {
|
|
|
9091
9141
|
getCheckedKeys, getCheckedNodes,
|
|
9092
9142
|
// getHalfCheckedKeys,
|
|
9093
9143
|
// getHalfCheckedNodes,
|
|
9094
|
-
setChecked, setCheckedKeys, setCheckedNodes } = useCheck(config, this._tree);
|
|
9144
|
+
setChecked, setCheckedKeys, setCheckedNodes, getSwitchCheckedValue, } = useCheck(config, this._tree);
|
|
9095
9145
|
this._updateCheckedKeys = updateCheckedKeys;
|
|
9096
9146
|
this.getChecked = getChecked;
|
|
9097
9147
|
this.getCheckedKeys = getCheckedKeys;
|
|
@@ -9180,7 +9230,7 @@ class VirtualTree {
|
|
|
9180
9230
|
statusSlot = this._customRender(config.renderStatus, item, {
|
|
9181
9231
|
inset: true,
|
|
9182
9232
|
className: 'hy-tree-node__status',
|
|
9183
|
-
defaultFn: (data, node) => useStatus(config, data)
|
|
9233
|
+
defaultFn: (data, node) => useStatus(config, data, node)
|
|
9184
9234
|
});
|
|
9185
9235
|
}
|
|
9186
9236
|
// 右侧内容
|
|
@@ -9230,11 +9280,7 @@ class VirtualTree {
|
|
|
9230
9280
|
onClick: () => {
|
|
9231
9281
|
if (getDisabled(config, item))
|
|
9232
9282
|
return;
|
|
9233
|
-
item
|
|
9234
|
-
toggleCheckbox(item, item.checkedMark, true, true, false, this._hiddenNodeKeySet);
|
|
9235
|
-
if (isChecked(item) || isIndeterminate(item)) {
|
|
9236
|
-
item.checkedMark = true;
|
|
9237
|
-
}
|
|
9283
|
+
toggleCheckbox(item, getSwitchCheckedValue(item), true, true, false, this._hiddenNodeKeySet);
|
|
9238
9284
|
this.refresh();
|
|
9239
9285
|
}
|
|
9240
9286
|
}).mount(el);
|