chore(Table->setting): fix CheckboxGroup onchange event fn type

This commit is contained in:
invalid w 2023-10-31 16:51:41 +08:00
parent e497721e9b
commit 50eac7f353
1 changed files with 7 additions and 4 deletions

View File

@ -111,7 +111,10 @@
computed, computed,
} from 'vue'; } from 'vue';
import { Tooltip, Popover, Checkbox, Divider } from 'ant-design-vue'; import { Tooltip, Popover, Checkbox, Divider } from 'ant-design-vue';
import type { CheckboxChangeEvent } from 'ant-design-vue/lib/checkbox/interface'; import type {
CheckboxChangeEvent,
CheckboxValueType,
} from 'ant-design-vue/lib/checkbox/interface';
import { SettingOutlined, DragOutlined } from '@ant-design/icons-vue'; import { SettingOutlined, DragOutlined } from '@ant-design/icons-vue';
import Icon from '@/components/Icon/Icon.vue'; import Icon from '@/components/Icon/Icon.vue';
import { ScrollContainer } from '/@/components/Container'; import { ScrollContainer } from '/@/components/Container';
@ -278,17 +281,17 @@
}); });
// Trigger when check/uncheck a column // Trigger when check/uncheck a column
function onChange(checkedList: string[]) { function onChange(checkedList: CheckboxValueType[]) {
const len = plainSortOptions.value.length; const len = plainSortOptions.value.length;
state.checkAll = checkedList.length === len; state.checkAll = checkedList.length === len;
const sortList = unref(plainSortOptions).map((item) => item.value); const sortList = unref(plainSortOptions).map((item) => item.value);
checkedList.sort((prev, next) => { checkedList.sort((prev, next) => {
return sortList.indexOf(prev) - sortList.indexOf(next); return sortList.indexOf(String(prev)) - sortList.indexOf(String(next));
}); });
unref(plainSortOptions).forEach((item) => { unref(plainSortOptions).forEach((item) => {
(item as BasicColumn).defaultHidden = !checkedList.includes(item.value); (item as BasicColumn).defaultHidden = !checkedList.includes(item.value);
}); });
setColumns(checkedList); setColumns(checkedList as string[]);
} }
let sortable: Sortable; let sortable: Sortable;