From ee0e507e473289586013023c25aeb0bb6f72ed73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8A=A0=E8=84=9A=E6=9C=AC=E4=BA=BA?= <742374184@qq.com> Date: Fri, 28 Jul 2023 11:39:35 +0800 Subject: [PATCH] =?UTF-8?q?Table=E7=BB=84=E4=BB=B6columns=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B3=9B=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/src/hooks/useTableContext.ts | 2 +- src/components/Table/src/types/table.ts | 10 +++++----- src/views/list/basicList/columns.ts | 13 +++++++++++-- src/views/list/basicList/index.vue | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/Table/src/hooks/useTableContext.ts b/src/components/Table/src/hooks/useTableContext.ts index e975ac3..f9d8dee 100644 --- a/src/components/Table/src/hooks/useTableContext.ts +++ b/src/components/Table/src/hooks/useTableContext.ts @@ -4,7 +4,7 @@ import { provide, inject, ComputedRef } from 'vue'; const key = Symbol('s-table'); -type Instance = TableActionType & { +type Instance = TableActionType<{}> & { wrapRef: Ref>; getBindValues: ComputedRef; }; diff --git a/src/components/Table/src/types/table.ts b/src/components/Table/src/types/table.ts index edbb48f..6a9ee72 100644 --- a/src/components/Table/src/types/table.ts +++ b/src/components/Table/src/types/table.ts @@ -1,6 +1,6 @@ import type { TableBaseColumn } from 'naive-ui/lib/data-table/src/interface'; import { ComponentType } from './componentType'; -export interface BasicColumn extends TableBaseColumn { +export interface BasicColumn extends TableBaseColumn { //编辑表格 edit?: boolean; editRow?: boolean; @@ -13,16 +13,16 @@ export interface BasicColumn extends TableBaseColumn { // 权限编码控制是否显示 auth?: string[]; // 业务控制是否显示 - ifShow?: boolean | ((column: BasicColumn) => boolean); + ifShow?: boolean | ((column: BasicColumn) => boolean); // 控制是否支持拖拽,默认支持 draggable?: boolean; } -export interface TableActionType { +export interface TableActionType { reload: (opt) => Promise; emit?: any; - getColumns: (opt?) => BasicColumn[]; - setColumns: (columns: BasicColumn[] | string[]) => void; + getColumns: (opt?) => BasicColumn[]; + setColumns: (columns: BasicColumn[] | string[]) => void; } export interface BasicTableProps { diff --git a/src/views/list/basicList/columns.ts b/src/views/list/basicList/columns.ts index a4fe697..910b839 100644 --- a/src/views/list/basicList/columns.ts +++ b/src/views/list/basicList/columns.ts @@ -1,7 +1,16 @@ import { h } from 'vue'; import { NAvatar } from 'naive-ui'; - -export const columns = [ +import { BasicColumn } from '@/components/Table'; +export interface ListData { + id: string; + name: string; + avatar: string; + address: string; + beginTime: string; + endTime: string; + date: string; +} +export const columns: BasicColumn[] = [ { title: 'id', key: 'id', diff --git a/src/views/list/basicList/index.vue b/src/views/list/basicList/index.vue index af63d90..7b9db60 100644 --- a/src/views/list/basicList/index.vue +++ b/src/views/list/basicList/index.vue @@ -9,7 +9,7 @@