Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 全选套餐中的所有配置文件反应时间慢 #3491

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@

const emits = defineEmits(['toggleOpen', 'update:selectedConfigs', 'change']);

const selectedConfigIds = computed(() => new Set(props.selectedConfigs.map((item) => item.id)));

const isAllSelected = computed(() => {
const res = props.configList.length > 0 && props.configList.every((item) => isConfigSelected(item.id));
return res;
return props.configList.every((item) => selectedConfigIds.value.has(item.id));
});

const isIndeterminate = computed(() => {
const res = props.configList.length > 0 && props.selectedConfigs.length > 0 && !isAllSelected.value;
return res;
const selectedCount = props.selectedConfigs.length;
const totalCount = props.configList.length;
return selectedCount > 0 && selectedCount < totalCount && !isAllSelected.value;
});

const isConfigSelected = (id: number) => props.selectedConfigs.findIndex((item) => item.id === id) > -1;
const isConfigSelected = (id: number) => selectedConfigIds.value.has(id);

const handleAllSelectionChange = (checked: boolean) => {
const configs = props.selectedConfigs.slice();
Expand Down
Loading