diff --git a/src/components/RePlusPage/src/utils/types.ts b/src/components/RePlusPage/src/utils/types.ts index ec1e4fa..b62dffb 100644 --- a/src/components/RePlusPage/src/utils/types.ts +++ b/src/components/RePlusPage/src/utils/types.ts @@ -41,7 +41,7 @@ interface PageColumn extends PlusColumn, TableColumn { >; } -interface PageColumnList extends TableColumns { +interface PageTableColumn extends TableColumns { prop?: string; _column: Partial< Mutable & @@ -115,7 +115,7 @@ interface RePlusPageProps { * pure table 的 columns, 并返回 * @param columns */ - listColumnsFormat?: (columns: PageColumnList[]) => PageColumnList[]; + listColumnsFormat?: (columns: PageTableColumn[]) => PageTableColumn[]; /** * plus pro descriptions 的 columns, 并返回 * @param columns @@ -165,4 +165,4 @@ interface RePlusPageProps { tableBarButtonsProps?: Partial; } -export type { ApiAuthProps, RePlusPageProps, PageColumn, PageColumnList }; +export type { ApiAuthProps, RePlusPageProps, PageColumn, PageTableColumn }; diff --git a/src/components/RePlusSearch/src/types.ts b/src/components/RePlusSearch/src/types.ts index e7712f7..f5139a5 100644 --- a/src/components/RePlusSearch/src/types.ts +++ b/src/components/RePlusSearch/src/types.ts @@ -2,7 +2,7 @@ import type { BaseApi } from "@/api/base"; import type { RecordType } from "plus-pro-components"; import type { PaginationProps } from "@pureadmin/table"; import type { ComputedRef, Ref } from "vue"; -import type { PageColumnList } from "@/components/RePlusPage"; +import type { PageTableColumn } from "@/components/RePlusPage"; import type { PageColumn } from "@/components/RePlusPage"; interface PlusSearchProps { @@ -11,7 +11,7 @@ interface PlusSearchProps { multiple?: boolean; localeName?: string; searchColumnsFormat?: (columns: PageColumn[]) => PageColumn[]; - listColumnsFormat?: (columns: PageColumnList[]) => PageColumnList[]; + listColumnsFormat?: (columns: PageTableColumn[]) => PageTableColumn[]; baseColumnsFormat?: ({ listColumns, detailColumns, diff --git a/src/views/account/utils/hook.tsx b/src/views/account/utils/hook.tsx index 6616401..02e0239 100644 --- a/src/views/account/utils/hook.tsx +++ b/src/views/account/utils/hook.tsx @@ -16,7 +16,7 @@ import croppingUpload from "@/components/RePictureUpload"; import { userLoginLogApi } from "@/api/user/logs"; import type { PaginationProps } from "@pureadmin/table"; import { - type PageColumnList, + type PageTableColumn, handleOperation, openFormDialog, renderBooleanTag @@ -203,7 +203,7 @@ export function useUserLoginLog() { layout: "prev, pager, next" }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "status": diff --git a/src/views/demo/book/index.vue b/src/views/demo/book/index.vue index 7273349..0d2520a 100644 --- a/src/views/demo/book/index.vue +++ b/src/views/demo/book/index.vue @@ -11,6 +11,7 @@ const { api, auth, addOrEditOptions, + listColumnsFormat, searchColumnsFormat, tableBarButtonsProps, operationButtonsProps @@ -24,6 +25,7 @@ const { locale-name="demoBook" :search-columns-format="searchColumnsFormat" :add-or-edit-options="addOrEditOptions" + :list-columns-format="listColumnsFormat" :tableBarButtonsProps="tableBarButtonsProps" :operationButtonsProps="operationButtonsProps" /> diff --git a/src/views/demo/book/utils/hook.tsx b/src/views/demo/book/utils/hook.tsx index a9f7bc0..d444451 100644 --- a/src/views/demo/book/utils/hook.tsx +++ b/src/views/demo/book/utils/hook.tsx @@ -1,9 +1,10 @@ import { bookApi } from "./api"; -import { getCurrentInstance, reactive, type Ref, shallowRef } from "vue"; +import { getCurrentInstance, h, reactive, type Ref, shallowRef } from "vue"; import { getDefaultAuths } from "@/router/utils"; import type { OperationProps, PageColumn, + PageTableColumn, RePlusPageProps } from "@/components/RePlusPage"; import { useRenderIcon } from "@/components/ReIcon/src/hooks"; @@ -12,6 +13,7 @@ import { handleOperation } from "@/components/RePlusPage"; import { useI18n } from "vue-i18n"; import Success from "@iconify-icons/ep/success-filled"; import { message } from "@/utils/message"; +import { ElTag } from "element-plus"; export function useDemoBook(tableRef: Ref) { // 权限判断,用于判断是否有该权限 @@ -162,11 +164,28 @@ export function useDemoBook(tableRef: Ref) { }); return columns; }; + /** + * 表格列操作 + * @param columns + */ + const listColumnsFormat = (columns: PageTableColumn[]) => { + columns.forEach(column => { + switch (column._column?.key) { + case "category": + column["cellRenderer"] = ({ row }) => { + return h(ElTag, { type: "success" }, () => row.category.label); + }; + break; + } + }); + return columns; + }; return { api, auth, addOrEditOptions, + listColumnsFormat, searchColumnsFormat, tableBarButtonsProps, operationButtonsProps diff --git a/src/views/system/config/user/utils/hook.tsx b/src/views/system/config/user/utils/hook.tsx index 450fd7d..3ffd1fe 100644 --- a/src/views/system/config/user/utils/hook.tsx +++ b/src/views/system/config/user/utils/hook.tsx @@ -4,7 +4,7 @@ import { getDefaultAuths, hasAuth } from "@/router/utils"; import { getCurrentInstance, reactive, type Ref, shallowRef } from "vue"; import { userConfigApi } from "@/api/system/config/user"; import { - type PageColumnList, + type PageTableColumn, handleOperation, type OperationProps, type RePlusPageProps @@ -40,7 +40,7 @@ export function useUserConfig(tableRef: Ref) { } }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "owner": diff --git a/src/views/system/dept/utils/hook.tsx b/src/views/system/dept/utils/hook.tsx index 13f99e1..027384a 100644 --- a/src/views/system/dept/utils/hook.tsx +++ b/src/views/system/dept/utils/hook.tsx @@ -7,7 +7,7 @@ import { useI18n } from "vue-i18n"; import { customRolePermissionOptions } from "@/views/system/hooks"; import { handleTree } from "@/utils/tree"; import { - type PageColumnList, + type PageTableColumn, handleOperation, openFormDialog, type OperationProps, @@ -26,7 +26,7 @@ export function useDept(tableRef: Ref) { ...getDefaultAuths(getCurrentInstance(), ["empower"]) }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "user_count": diff --git a/src/views/system/file/utils/hook.tsx b/src/views/system/file/utils/hook.tsx index 6653a89..3b0764e 100644 --- a/src/views/system/file/utils/hook.tsx +++ b/src/views/system/file/utils/hook.tsx @@ -3,7 +3,7 @@ import { systemUploadFileApi } from "@/api/system/file"; import { getDefaultAuths, hasAuth } from "@/router/utils"; import { getCurrentInstance, h, reactive, type Ref, shallowRef } from "vue"; import { - type PageColumnList, + type PageTableColumn, isUrl, openFormDialog, type OperationProps, @@ -88,7 +88,7 @@ export function useSystemUploadFile(tableRef: Ref) { } }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "access_url": diff --git a/src/views/system/logs/login/utils/hook.tsx b/src/views/system/logs/login/utils/hook.tsx index 96ef888..55460c7 100644 --- a/src/views/system/logs/login/utils/hook.tsx +++ b/src/views/system/logs/login/utils/hook.tsx @@ -5,7 +5,7 @@ import { getDefaultAuths, hasAuth } from "@/router/utils"; import { getCurrentInstance, reactive, shallowRef } from "vue"; import { usePublicHooks } from "@/views/system/hooks"; import { - type PageColumnList, + type PageTableColumn, type OperationProps, renderBooleanTag } from "@/components/RePlusPage"; @@ -24,7 +24,7 @@ export function useLoginLog() { const operationButtonsProps = shallowRef({ width: 140 }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "creator": diff --git a/src/views/system/logs/operation/utils/hook.tsx b/src/views/system/logs/operation/utils/hook.tsx index 0fa6eee..d9661a3 100644 --- a/src/views/system/logs/operation/utils/hook.tsx +++ b/src/views/system/logs/operation/utils/hook.tsx @@ -5,7 +5,7 @@ import { getDefaultAuths, hasAuth } from "@/router/utils"; import type { PageColumn, OperationProps, - PageColumnList + PageTableColumn } from "@/components/RePlusPage"; import VueJsonPretty from "vue-json-pretty"; import "vue-json-pretty/lib/styles.css"; @@ -20,7 +20,7 @@ export function useOperationLog() { const operationButtonsProps = shallowRef({ width: 140 }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "creator": diff --git a/src/views/system/notice/read/hook.tsx b/src/views/system/notice/read/hook.tsx index 4614254..7220d09 100644 --- a/src/views/system/notice/read/hook.tsx +++ b/src/views/system/notice/read/hook.tsx @@ -12,7 +12,7 @@ import { addDialog } from "@/components/ReDialog"; import { useRouter } from "vue-router"; import { getDefaultAuths, hasAuth } from "@/router/utils"; import { useI18n } from "vue-i18n"; -import type { PageColumnList, OperationProps } from "@/components/RePlusPage"; +import type { PageTableColumn, OperationProps } from "@/components/RePlusPage"; import { renderSwitch, usePublicHooks } from "@/components/RePlusPage"; import NoticeShowForm from "@/views/system/components/NoticeShow.vue"; @@ -53,7 +53,7 @@ export function useNoticeRead(tableRef: Ref) { } ] }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "notice_info": diff --git a/src/views/system/notice/utils/hook.tsx b/src/views/system/notice/utils/hook.tsx index e1c6366..6437a22 100644 --- a/src/views/system/notice/utils/hook.tsx +++ b/src/views/system/notice/utils/hook.tsx @@ -14,7 +14,7 @@ import { getDefaultAuths, hasAuth } from "@/router/utils"; import { useI18n } from "vue-i18n"; import { NoticeChoices } from "@/views/system/constants"; import type { - PageColumnList, + PageTableColumn, OperationProps, RePlusPageProps } from "@/components/RePlusPage"; @@ -67,7 +67,7 @@ export function useNotice(tableRef: Ref) { } ] }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "title": diff --git a/src/views/system/role/utils/hook.tsx b/src/views/system/role/utils/hook.tsx index 66b207d..fe20817 100644 --- a/src/views/system/role/utils/hook.tsx +++ b/src/views/system/role/utils/hook.tsx @@ -16,7 +16,7 @@ import { FieldChoices } from "@/views/system/constants"; import { cloneDeep, getKeyList } from "@pureadmin/utils"; import { modelLabelFieldApi } from "@/api/system/field"; import type { - PageColumnList, + PageTableColumn, OperationProps, RePlusPageProps } from "@/components/RePlusPage"; @@ -130,7 +130,7 @@ export function useRole() { } }); - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { return columns; }; diff --git a/src/views/system/user/utils/hook.tsx b/src/views/system/user/utils/hook.tsx index 516dfc4..bbcb150 100644 --- a/src/views/system/user/utils/hook.tsx +++ b/src/views/system/user/utils/hook.tsx @@ -38,7 +38,7 @@ import { renderSwitch, type RePlusPageProps, usePublicHooks, - type PageColumnList + type PageTableColumn } from "@/components/RePlusPage"; import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import Role from "@iconify-icons/ri/admin-line"; @@ -284,7 +284,7 @@ export function useUser(tableRef: Ref) { selectedNum.value = manySelectData.value.length ?? 0; }; - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "avatar": diff --git a/src/views/user/notice/utils/hook.tsx b/src/views/user/notice/utils/hook.tsx index 906f9e9..9d3b789 100644 --- a/src/views/user/notice/utils/hook.tsx +++ b/src/views/user/notice/utils/hook.tsx @@ -7,7 +7,7 @@ import { useI18n } from "vue-i18n"; import { useUserStoreHook } from "@/store/modules/user"; import { hasAuth } from "@/router/utils"; -import type { PageColumnList, OperationProps } from "@/components/RePlusPage"; +import type { PageTableColumn, OperationProps } from "@/components/RePlusPage"; import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import NoticeShowForm from "@/views/system/components/NoticeShow.vue"; @@ -101,7 +101,7 @@ export function useUserNotice(tableRef: Ref) { manySelectData.value = data; selectedNum.value = manySelectData.value.length ?? 0; }; - const listColumnsFormat = (columns: PageColumnList[]) => { + const listColumnsFormat = (columns: PageTableColumn[]) => { columns.forEach(column => { switch (column._column?.key) { case "title":