mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	perf: pure-table表格高级用法添加保留已选中的CheckBox选项demo
				
					
				
			This commit is contained in:
		
							parent
							
								
									87da9b881c
								
							
						
					
					
						commit
						ee73c88d36
					
				@ -6,11 +6,18 @@ import type { PaginationProps, LoadingConfig, Align } from "@pureadmin/table";
 | 
				
			|||||||
export function useColumns() {
 | 
					export function useColumns() {
 | 
				
			||||||
  const dataList = ref([]);
 | 
					  const dataList = ref([]);
 | 
				
			||||||
  const loading = ref(true);
 | 
					  const loading = ref(true);
 | 
				
			||||||
 | 
					  const select = ref("no");
 | 
				
			||||||
  const hideVal = ref("nohide");
 | 
					  const hideVal = ref("nohide");
 | 
				
			||||||
  const tableSize = ref("default");
 | 
					  const tableSize = ref("default");
 | 
				
			||||||
  const paginationSmall = ref(false);
 | 
					  const paginationSmall = ref(false);
 | 
				
			||||||
  const paginationAlign = ref("right");
 | 
					  const paginationAlign = ref("right");
 | 
				
			||||||
  const columns: TableColumnList = [
 | 
					  const columns: TableColumnList = [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      type: "selection",
 | 
				
			||||||
 | 
					      align: "left",
 | 
				
			||||||
 | 
					      reserveSelection: true,
 | 
				
			||||||
 | 
					      hide: () => (select.value === "no" ? true : false)
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      label: "日期",
 | 
					      label: "日期",
 | 
				
			||||||
      prop: "date",
 | 
					      prop: "date",
 | 
				
			||||||
@ -83,7 +90,9 @@ export function useColumns() {
 | 
				
			|||||||
      Array.from({ length: 6 }).forEach(() => {
 | 
					      Array.from({ length: 6 }).forEach(() => {
 | 
				
			||||||
        newList.push(clone(tableData, true));
 | 
					        newList.push(clone(tableData, true));
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      dataList.value = newList.flat(Infinity);
 | 
					      newList.flat(Infinity).forEach((item, index) => {
 | 
				
			||||||
 | 
					        dataList.value.push({ id: index, ...item });
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
      pagination.total = dataList.value.length;
 | 
					      pagination.total = dataList.value.length;
 | 
				
			||||||
      loading.value = false;
 | 
					      loading.value = false;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@ -93,6 +102,7 @@ export function useColumns() {
 | 
				
			|||||||
    loading,
 | 
					    loading,
 | 
				
			||||||
    columns,
 | 
					    columns,
 | 
				
			||||||
    dataList,
 | 
					    dataList,
 | 
				
			||||||
 | 
					    select,
 | 
				
			||||||
    hideVal,
 | 
					    hideVal,
 | 
				
			||||||
    tableSize,
 | 
					    tableSize,
 | 
				
			||||||
    pagination,
 | 
					    pagination,
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,7 @@ const {
 | 
				
			|||||||
  loading,
 | 
					  loading,
 | 
				
			||||||
  columns,
 | 
					  columns,
 | 
				
			||||||
  dataList,
 | 
					  dataList,
 | 
				
			||||||
 | 
					  select,
 | 
				
			||||||
  hideVal,
 | 
					  hideVal,
 | 
				
			||||||
  tableSize,
 | 
					  tableSize,
 | 
				
			||||||
  pagination,
 | 
					  pagination,
 | 
				
			||||||
@ -20,6 +21,12 @@ const {
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div>
 | 
					  <div>
 | 
				
			||||||
    <el-space class="float-right mb-4">
 | 
					    <el-space class="float-right mb-4">
 | 
				
			||||||
 | 
					      <p class="text-sm">多选:</p>
 | 
				
			||||||
 | 
					      <el-radio-group v-model="select" size="small">
 | 
				
			||||||
 | 
					        <el-radio-button label="yes">是</el-radio-button>
 | 
				
			||||||
 | 
					        <el-radio-button label="no">否</el-radio-button>
 | 
				
			||||||
 | 
					      </el-radio-group>
 | 
				
			||||||
 | 
					      <el-divider direction="vertical" />
 | 
				
			||||||
      <p class="text-sm">动态列:</p>
 | 
					      <p class="text-sm">动态列:</p>
 | 
				
			||||||
      <el-radio-group v-model="hideVal" size="small">
 | 
					      <el-radio-group v-model="hideVal" size="small">
 | 
				
			||||||
        <el-radio-button label="nohide">不隐藏</el-radio-button>
 | 
					        <el-radio-button label="nohide">不隐藏</el-radio-button>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user