【issues/828】解决卡死问题

pull/859/head
zhangdaiscott 2023-11-04 17:36:21 +08:00
parent 734068c685
commit 0b1c464e2c
1 changed files with 25 additions and 5 deletions

View File

@ -432,6 +432,7 @@ export function useCustomSelection(
// 设置选择的key
function setSelectedRowKeys(rowKeys: string[]) {
const isSomeRowKeys = selectedKeys.value === rowKeys;
selectedKeys.value = rowKeys;
const allSelectedRows = findNodeAll(
toRaw(unref(flattedData)).concat(toRaw(unref(selectedRows))),
@ -445,14 +446,33 @@ export function useCustomSelection(
const found = allSelectedRows.find((item) => getRecordKey(item) === key);
found && trueSelectedRows.push(found);
});
// update-begin--author:liaozhiyang---date:20230823---for【QQYUN-6283】点击表格清空rowSelect里面的selectedRowKeys没置空。
// update-begin--author:liaozhiyang---date:20230811---for【issues/657】浏览器卡死问题
if (trueSelectedRows.length || !rowKeys.length) {
// update-begin--author:liaozhiyang---date:20231103---for【issues/828】解决卡死问题
if (!(isSomeRowKeys && equal(selectedRows.value, trueSelectedRows))) {
selectedRows.value = trueSelectedRows;
emitChange();
}
// update-end--author:liaozhiyang---date:20230811---for【issues/657】】浏览器卡死问题
// update-end--author:liaozhiyang---date:20230823---for【QQYUN-6283】点击表格清空rowSelect里面的selectedRowKeys没置空。
// update-end--author:liaozhiyang---date:20231103---for【issues/828】解决卡死问题
}
/**
*2023-11-03
*
*selectedRows.valuetrueSelectedRows
*/
function equal(oldVal, newVal) {
let oldKeys = [],
newKeys = [];
if (oldVal.length === newVal.length) {
oldKeys = oldVal.map((item) => getRecordKey(item));
newKeys = newVal.map((item) => getRecordKey(item));
for (let i = 0, len = oldKeys.length; i < len; i++) {
const findItem = newKeys.find((item) => item === oldKeys[i]);
if (!findItem) {
return false;
}
}
return true;
}
return false;
}
function getSelectRows<T = Recordable>() {