diff --git a/src/api/service/Api.ts b/src/api/service/Api.ts index 6ddb7d7..37a040a 100644 --- a/src/api/service/Api.ts +++ b/src/api/service/Api.ts @@ -258,6 +258,7 @@ export interface CreatePermissionDto { } export interface UpdatePermissionDto { + id: number; /** * 权限名称 * @example "权限名称" @@ -582,7 +583,7 @@ export interface GetPostsParams { size?: number; } -export interface GetCategorysParams { +export interface GetCategoriesParams { /** * 字段描述(Swagger用途) * @example "示例值" @@ -1230,7 +1231,7 @@ export namespace Post { export namespace Category { /** - * @description 新增分类 + * @description 添加分类 * @tags category * @name AddCategory * @request POST:/api/v1/categories @@ -1245,12 +1246,12 @@ export namespace Category { }; } /** - * @description 根据分页/过滤参数查询分类 + * @description 分页获取分类 * @tags category - * @name GetCategorys + * @name GetCategories * @request GET:/api/v1/categories */ - export namespace GetCategorys { + export namespace GetCategories { export type RequestParams = {}; export type RequestQuery = { /** @@ -1285,14 +1286,14 @@ export namespace Category { }; } /** - * @description 根据ID查询分类 + * @description 添加分类 * @tags category * @name GetCategory * @request GET:/api/v1/categories/{id} */ export namespace GetCategory { export type RequestParams = { - id: number; + id: string; }; export type RequestQuery = {}; export type RequestBody = never; @@ -1302,14 +1303,14 @@ export namespace Category { }; } /** - * @description 根据ID更新分类 + * @description 更新分类 * @tags category - * @name UpdateCategory + * @name SetCategory * @request PATCH:/api/v1/categories/{id} */ - export namespace UpdateCategory { + export namespace SetCategory { export type RequestParams = { - id: number; + id: string; }; export type RequestQuery = {}; export type RequestBody = UpdateCategoryDto; @@ -1317,14 +1318,14 @@ export namespace Category { export type ResponseBody = Response; } /** - * @description 根据ID删除分类 + * @description 删除分类 * @tags category * @name DelCategory * @request DELETE:/api/v1/categories/{id} */ export namespace DelCategory { export type RequestParams = { - id: number; + id: string; }; export type RequestQuery = {}; export type RequestBody = never; @@ -2132,7 +2133,7 @@ export class Api extends HttpClient extends HttpClient { + getCategories: (query: GetCategoriesParams, params: RequestParams = {}) => { return this.request< Response & { data: Category[]; @@ -2177,13 +2178,13 @@ export class Api extends HttpClient { + getCategory: (id: string, params: RequestParams = {}) => { return this.request< Response & { data: Category; @@ -2198,13 +2199,13 @@ export class Api extends HttpClient { + setCategory: (id: string, data: UpdateCategoryDto, params: RequestParams = {}) => { return this.request({ path: `/api/v1/categories/${id}`, method: "PATCH", @@ -2216,13 +2217,13 @@ export class Api extends HttpClient { + delCategory: (id: string, params: RequestParams = {}) => { return this.request({ path: `/api/v1/categories/${id}`, method: "DELETE", diff --git a/src/components/table/colume.tsx b/src/components/table/colume.tsx new file mode 100644 index 0000000..c9acda4 --- /dev/null +++ b/src/components/table/colume.tsx @@ -0,0 +1,38 @@ +import { dayjs } from "@/libs/dayjs"; +import { TableColumn } from "./use-interface"; + +const defineColumn = (column: T) => { + return column; +}; + +export const updateColumn = defineColumn({ + title: "更新者", + dataIndex: "createdAt", + width: 200, + render({ record }) { + return ( +
+ {record.updatedBy ?? "无"} + + {dayjs(record.updatedAt).format()} + +
+ ); + }, +}); + +export const createColumn = defineColumn({ + title: "创建者", + dataIndex: "createdAt", + width: 200, + render({ record }) { + return ( +
+ {record.createdBy ?? "无"} + + {dayjs(record.createdAt).format()} + +
+ ); + }, +}); diff --git a/src/components/table/index.ts b/src/components/table/index.ts index b4cf64b..8807de4 100644 --- a/src/components/table/index.ts +++ b/src/components/table/index.ts @@ -1,2 +1,4 @@ +export * from "./colume"; export * from "./table"; export * from "./use-table"; + diff --git a/src/components/table/use-table.tsx b/src/components/table/use-table.tsx index 556171f..04b9495 100644 --- a/src/components/table/use-table.tsx +++ b/src/components/table/use-table.tsx @@ -200,7 +200,11 @@ export const useTable = (optionsOrFn: UseTableOptions | (() => UseTableOptions)) } } } - const merged = merge({ modalProps: { titleAlign: "start", closable: false } }, options.create, options.modify); + const merged = merge( + { modalProps: { titleAlign: "start", closable: false }, model: { id: undefined } }, + options.create, + options.modify + ); options.modify = useFormModal(merged as any) as any; } else { options.modify = useFormModal(options.modify as any) as any; diff --git a/src/pages/post/category/index.vue b/src/pages/post/category/index.vue index 7342a9a..9d125fc 100644 --- a/src/pages/post/category/index.vue +++ b/src/pages/post/category/index.vue @@ -6,13 +6,12 @@