feat: 表格增加参数控制是否展示跨页全选

This commit is contained in:
RubyLiu 2023-12-20 11:40:18 +08:00 committed by 刘瑞斌
parent e89b978c8d
commit 81b9f083e5
3 changed files with 9 additions and 1 deletions

View File

@ -22,7 +22,7 @@
<SelectALL
:total="selectTotal"
:current="selectCurrent"
:show-select-all="(attrs.showPagination as boolean)"
:show-select-all="(attrs.showPagination as boolean) && props.showSelectorAll"
:disabled="(attrs.data as []).length === 0"
@change="handleSelectAllChange"
/>
@ -255,6 +255,7 @@
expandedKeys?: string[];
rowClass?: string | any[] | Record<string, any> | ((record: TableData, rowIndex: number) => any);
spanAll?: boolean;
showSelectorAll?: boolean;
}>();
const emit = defineEmits<{
(e: 'batchAction', value: BatchActionParams, queryParams: BatchActionQueryParams): void;

View File

@ -79,6 +79,7 @@ export interface MsTableProps<T> {
selectedKeys: Set<string>; // 选中的key
excludeKeys: Set<string>; // 排除的key
selectorStatus: SelectAllEnum; // 选择器状态
showSelectorAll?: boolean; // 是否显示跨页全选选择器
/** end */
loading?: boolean; // 加载效果
bordered?: boolean; // 是否显示边框

View File

@ -54,6 +54,7 @@ export default function useTableProps<T>(
selectedKeys: new Set<string>(), // 选中的key
excludeKeys: new Set<string>(), // 排除的key
selectorStatus: SelectAllEnum.NONE, // 选择器状态
showSelectorAll: true, // 是否显示全选
/** end */
enableDrag: false, // 是否可拖拽
showSetting: false, // 是否展示列选择器
@ -380,6 +381,11 @@ export default function useTableProps<T>(
excludeKeys.delete(key);
}
}
if (selectedKeys.size === 0 && propsRes.value.selectorStatus === SelectAllEnum.CURRENT) {
propsRes.value.selectorStatus = SelectAllEnum.NONE;
} else if (selectedKeys.size > 0 && propsRes.value.selectorStatus === SelectAllEnum.NONE) {
propsRes.value.selectorStatus = SelectAllEnum.CURRENT;
}
propsRes.value.selectedKeys = selectedKeys;
propsRes.value.excludeKeys = excludeKeys;
},