mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 16:37:18 +08:00
feat: 表格选择器添加默认回显
This commit is contained in:
parent
5e5169817c
commit
0b9fcaca4a
@ -1,13 +1,13 @@
|
|||||||
import { message } from "@/utils/message";
|
import { message } from "@/utils/message";
|
||||||
import { tableDataEdit } from "../../data";
|
import { tableDataEdit } from "../../data";
|
||||||
import { type Ref, ref, reactive } from "vue";
|
|
||||||
import type { PaginationProps } from "@pureadmin/table";
|
import type { PaginationProps } from "@pureadmin/table";
|
||||||
import { cloneDeep, isAllEmpty } from "@pureadmin/utils";
|
import { cloneDeep, isAllEmpty } from "@pureadmin/utils";
|
||||||
|
import { type Ref, ref, reactive, watch, nextTick } from "vue";
|
||||||
|
|
||||||
export function useColumns(selectRef: Ref, formRef: Ref, tableRef: Ref) {
|
export function useColumns(selectRef: Ref, formRef: Ref, tableRef: Ref) {
|
||||||
const tableData = ref(tableDataEdit);
|
const tableData = ref(tableDataEdit);
|
||||||
const cloneTableData = cloneDeep(tableData.value);
|
const cloneTableData = cloneDeep(tableData.value);
|
||||||
const selectValue = ref([]);
|
const selectValue = ref([1, 3, 4]);
|
||||||
const searchForm = reactive({
|
const searchForm = reactive({
|
||||||
sexValue: "",
|
sexValue: "",
|
||||||
searchDate: ""
|
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 {
|
return {
|
||||||
searchForm,
|
searchForm,
|
||||||
sexOptions,
|
sexOptions,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user