Skip to content

Commit

Permalink
perf: 将 PageColumnList 修改为 PageTableColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
nineaiyu committed Nov 18, 2024
1 parent c412ad6 commit e5688c0
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/components/RePlusPage/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface PageColumn extends PlusColumn, TableColumn {
>;
}

interface PageColumnList extends TableColumns {
interface PageTableColumn extends TableColumns {
prop?: string;
_column: Partial<
Mutable<SearchFieldsResult["data"][0]> &
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -165,4 +165,4 @@ interface RePlusPageProps {
tableBarButtonsProps?: Partial<OperationProps>;
}

export type { ApiAuthProps, RePlusPageProps, PageColumn, PageColumnList };
export type { ApiAuthProps, RePlusPageProps, PageColumn, PageTableColumn };
4 changes: 2 additions & 2 deletions src/components/RePlusSearch/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/views/account/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
2 changes: 2 additions & 0 deletions src/views/demo/book/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
api,
auth,
addOrEditOptions,
listColumnsFormat,
searchColumnsFormat,
tableBarButtonsProps,
operationButtonsProps
Expand All @@ -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"
/>
Expand Down
21 changes: 20 additions & 1 deletion src/views/demo/book/utils/hook.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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) {
// 权限判断,用于判断是否有该权限
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/config/user/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/dept/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/file/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/logs/login/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -24,7 +24,7 @@ export function useLoginLog() {
const operationButtonsProps = shallowRef<OperationProps>({
width: 140
});
const listColumnsFormat = (columns: PageColumnList[]) => {
const listColumnsFormat = (columns: PageTableColumn[]) => {
columns.forEach(column => {
switch (column._column?.key) {
case "creator":
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/logs/operation/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -20,7 +20,7 @@ export function useOperationLog() {
const operationButtonsProps = shallowRef<OperationProps>({
width: 140
});
const listColumnsFormat = (columns: PageColumnList[]) => {
const listColumnsFormat = (columns: PageTableColumn[]) => {
columns.forEach(column => {
switch (column._column?.key) {
case "creator":
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/notice/read/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/notice/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions src/views/system/role/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -130,7 +130,7 @@ export function useRole() {
}
});

const listColumnsFormat = (columns: PageColumnList[]) => {
const listColumnsFormat = (columns: PageTableColumn[]) => {
return columns;
};

Expand Down
4 changes: 2 additions & 2 deletions src/views/system/user/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions src/views/user/notice/utils/hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit e5688c0

Please sign in to comment.