chore: updateCheckedNumber

This commit is contained in:
dap 2025-01-04 19:25:45 +08:00
parent a48a7a9444
commit 831a1abac7

View File

@ -95,12 +95,12 @@ const gridOptions: VxeGridProps = {
/** /**
* 用于界面显示选中的数量 * 用于界面显示选中的数量
*/ */
const checkedLength = ref(0); const checkedNum = ref(0);
/** /**
* 更新选中的数量 * 更新选中的数量
*/ */
function updateCheckedLength() { function updateCheckedNumber() {
checkedLength.value = getCheckedKeys().length; checkedNum.value = getCheckedKeys().length;
} }
const [BasicTable, tableApi] = useVbenVxeGrid({ const [BasicTable, tableApi] = useVbenVxeGrid({
@ -110,7 +110,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
checkboxChange: (params) => { checkboxChange: (params) => {
// //
if (!association.value) { if (!association.value) {
updateCheckedLength(); updateCheckedNumber();
return; return;
} }
// //
@ -119,7 +119,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
const record = params.row; const record = params.row;
// //
rowAndChildrenChecked(record, checked); rowAndChildrenChecked(record, checked);
updateCheckedLength(); updateCheckedNumber();
}, },
// //
checkboxAll: (params) => { checkboxAll: (params) => {
@ -127,7 +127,7 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
records.forEach((item) => { records.forEach((item) => {
rowAndChildrenChecked(item, params.checked); rowAndChildrenChecked(item, params.checked);
}); });
updateCheckedLength(); updateCheckedNumber();
}, },
}, },
}); });
@ -208,6 +208,7 @@ onMounted(() => {
// data checkedKeysmenuswatch // data checkedKeysmenuswatch
const records = tableApi.grid.getData(); const records = tableApi.grid.getData();
setCheckedByKeys(records, allCheckedKeys, association.value); setCheckedByKeys(records, allCheckedKeys, association.value);
updateCheckedNumber();
}, },
); );
}); });
@ -223,7 +224,7 @@ async function handleAssociationChange() {
}); });
// //
await tableApi.grid.clearCheckboxRow(); await tableApi.grid.clearCheckboxRow();
updateCheckedLength(); updateCheckedNumber();
// //
await tableApi.grid.scrollTo(0, 0); await tableApi.grid.scrollTo(0, 0);
} }
@ -256,7 +257,7 @@ function handlePermissionChange(row: any) {
} }
} }
// //
updateCheckedLength(); updateCheckedNumber();
} }
/** /**
@ -341,7 +342,7 @@ defineExpose({
<div v-if="tableApi?.grid"> <div v-if="tableApi?.grid">
已选中 已选中
<span class="text-primary mx-1 font-semibold"> <span class="text-primary mx-1 font-semibold">
{{ checkedLength }} {{ checkedNum }}
</span> </span>
个节点 个节点
</div> </div>