diff --git a/src/views/pure-table/high/table-select/multiple/columns.tsx b/src/views/pure-table/high/table-select/multiple/columns.tsx index 1c0296b94..e398d13d4 100644 --- a/src/views/pure-table/high/table-select/multiple/columns.tsx +++ b/src/views/pure-table/high/table-select/multiple/columns.tsx @@ -1,13 +1,13 @@ import { message } from "@/utils/message"; import { tableDataEdit } from "../../data"; -import { type Ref, ref, reactive } from "vue"; import type { PaginationProps } from "@pureadmin/table"; import { cloneDeep, isAllEmpty } from "@pureadmin/utils"; +import { type Ref, ref, reactive, watch, nextTick } from "vue"; export function useColumns(selectRef: Ref, formRef: Ref, tableRef: Ref) { const tableData = ref(tableDataEdit); const cloneTableData = cloneDeep(tableData.value); - const selectValue = ref([]); + const selectValue = ref([1, 3, 4]); const searchForm = reactive({ sexValue: "", searchDate: "" @@ -110,6 +110,21 @@ export function useColumns(selectRef: Ref, formRef: Ref, tableRef: Ref) { }); }; + watch( + selectValue, + async () => { + await nextTick(); + const { toggleRowSelection } = tableRef.value.getTableRef(); + selectValue.value.forEach(val => { + tableData.value.forEach(row => { + // 默认回显 + row.id === val ? toggleRowSelection(row) : undefined; + }); + }); + }, + { immediate: true } + ); + return { searchForm, sexOptions,