feat: 表格批量操作增加当前选中的数量

This commit is contained in:
RubyLiu 2023-09-25 10:47:17 +08:00 committed by 刘瑞斌
parent 766ef37320
commit fcebe7ceaf
3 changed files with 22 additions and 0 deletions

View File

@ -310,6 +310,7 @@
selectedIds: Array.from(selectedKeys),
excludeIds: Array.from(excludeKeys),
selectAll: selectorStatus === SelectAllEnum.ALL,
currentSelectCount: selectCurrent.value,
params: {
...(attrs.msPagination as MsPaginationI),
},

View File

@ -117,4 +117,5 @@ export interface BatchActionQueryParams {
selectedIds?: string[]; // 选中的id
selectAll: boolean; // 是否跨页全选
params?: TableQueryParams; // 查询参数
currentSelectCount: number; // 当前选中的数量
}

View File

@ -216,6 +216,25 @@ export default function useTableProps<T>(
propsRes.value.selectorStatus = SelectAllEnum.NONE;
};
// 获取当前表格的选中项数量
const getSelectedCount = () => {
const { selectorStatus, msPagination, excludeKeys, selectedKeys } = propsRes.value;
if (msPagination) {
if (selectorStatus === SelectAllEnum.ALL) {
// 如果是全选状态,返回总数减去排除的数量
return msPagination.total - excludeKeys.size;
}
// if (selectorStatus === SelectAllEnum.NONE) {
// 如果是全不选状态,返回选中的数量
return selectedKeys.size;
// }
// if (selectorStatus === SelectAllEnum.CURRENT) {
// // 如果是当前页状态,返回当前页减去排除的数量
// return msPagination.pageSize - excludeKeys.size;
// }
}
};
// 事件触发组
const propsEvent = ref({
// 排序触发
@ -318,5 +337,6 @@ export default function useTableProps<T>(
setLoadListParams,
setKeyword,
resetPagination,
getSelectedCount,
};
}