From 57f6ba007700bbbdde332d46bd27fe9046089f66 Mon Sep 17 00:00:00 2001 From: yuanjunjie Date: Thu, 25 Jul 2024 11:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf<=E5=90=8E=E7=AB=AF>:=20?= =?UTF-8?q?=E5=A4=87=E5=BF=98=E5=BD=95=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 21 +++ nest-admin/servers/src/app.module.ts | 5 + .../servers/src/common/enums/common.enum.ts | 7 + .../servers/src/common/utils/req-query.ts | 18 ++ .../category/dto/memorandum-category.dto.ts | 56 ++++++ .../memorandum-category.controller.ts | 54 ++++++ .../category/memorandum-category.entity.ts | 20 +++ .../category/memorandum-category.module.ts | 13 ++ .../category/memorandum-category.service.ts | 165 ++++++++++++++++++ .../memorandum/memorandum.controller.ts | 12 ++ .../memorandum/memorandum.entity.ts | 25 +++ .../memorandum/memorandum.module.ts | 13 ++ .../memorandum/memorandum.service.ts | 15 ++ .../src/api/website/memorandum-category.ts | 27 +++ .../api/website/model/memorandum-category.ts | 28 +++ .../category/CreateOrEditModal.vue | 10 +- .../category/category.data.ts | 7 +- .../memorandum-management/category/index.vue | 33 ++-- .../memorandum/memorandum.data.ts | 3 +- 19 files changed, 503 insertions(+), 29 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 nest-admin/servers/src/common/utils/req-query.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/category/dto/memorandum-category.dto.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/category/memorandum-category.controller.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/category/memorandum-category.entity.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/category/memorandum-category.module.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/category/memorandum-category.service.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.controller.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.entity.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.module.ts create mode 100644 nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.service.ts create mode 100644 vue-vben-admin/src/api/website/memorandum-category.ts create mode 100644 vue-vben-admin/src/api/website/model/memorandum-category.ts diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4986d97 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "type": "node", + "request": "launch", + "name": "启动程序", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\nest-admin\\servers\\src\\website\\memorandum-management\\category\\memorandum-category.service.ts", + "outFiles": [ + "${workspaceFolder}/**/*.js" + ] + } + ] +} \ No newline at end of file diff --git a/nest-admin/servers/src/app.module.ts b/nest-admin/servers/src/app.module.ts index c4ef0a9..7bea85e 100644 --- a/nest-admin/servers/src/app.module.ts +++ b/nest-admin/servers/src/app.module.ts @@ -19,6 +19,9 @@ import { RoleModule } from './system/role/role.module' import { PermModule } from './system/perm/perm.module' import { OssModule } from './system/oss/oss.module' +import { MemorandumCategoryModule } from './website/memorandum-management/category/memorandum-category.module' +import { MemorandumModule } from './website/memorandum-management/memorandum/memorandum.module' + @Module({ imports: [ // 配置模块 @@ -95,6 +98,8 @@ import { OssModule } from './system/oss/oss.module' PermModule, OssModule, // 业务功能模块 + MemorandumCategoryModule, + // MemorandumModule ], // app module 守卫,两个守卫分别依赖 UserService、PermService, 而 UserService、PermService 没有设置全局模块, // 所以这俩 守卫 不能再 main.ts 设置全局守卫 diff --git a/nest-admin/servers/src/common/enums/common.enum.ts b/nest-admin/servers/src/common/enums/common.enum.ts index 2f0b5db..8c7ad35 100644 --- a/nest-admin/servers/src/common/enums/common.enum.ts +++ b/nest-admin/servers/src/common/enums/common.enum.ts @@ -20,6 +20,13 @@ export enum StatusValue { NORMAL = 1 } +export enum StatusValue2 { + /** 否 */ + NO = 0, + /** 是 */ + YES = 1 +} + export enum MenuType { /** 菜单 */ MENU = 1, diff --git a/nest-admin/servers/src/common/utils/req-query.ts b/nest-admin/servers/src/common/utils/req-query.ts new file mode 100644 index 0000000..431d8ad --- /dev/null +++ b/nest-admin/servers/src/common/utils/req-query.ts @@ -0,0 +1,18 @@ +import { ApiProperty } from '@nestjs/swagger' + +export class ReqQuery { + @ApiProperty({ description: '创建人' }) + createdBy?: string + + @ApiProperty({ description: '更新人' }) + updatedBy?: string + + @ApiProperty({ description: '更新时间' }) + updatedAt?: Date + + @ApiProperty({ description: '删除人' }) + deletedBy?: string + + @ApiProperty({ description: '删除时间' }) + deletedAt?: Date +} diff --git a/nest-admin/servers/src/website/memorandum-management/category/dto/memorandum-category.dto.ts b/nest-admin/servers/src/website/memorandum-management/category/dto/memorandum-category.dto.ts new file mode 100644 index 0000000..268012c --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/category/dto/memorandum-category.dto.ts @@ -0,0 +1,56 @@ +import { ApiProperty } from '@nestjs/swagger' +import { IsString, Length, IsOptional, IsNotEmpty } from 'class-validator' +import { ReqListQuery } from 'src/common/utils/req-list-query' +import { ReqQuery } from 'src/common/utils/req-query' + +export class AddMemorandumCategoryDto extends ReqQuery { + @ApiProperty({ description: '名称' }) + @IsString({ message: 'name 类型错误, 正确类型 string' }) + @IsNotEmpty({ message: 'name 不能为空' }) + @Length(0, 20, { message: 'name 字符长度在 0~20' }) + name: string + + @ApiProperty({ description: '角色备注', required: false }) + @IsString({ message: 'description 类型错误, 正确类型 string' }) + @Length(0, 200, { message: 'description 字符长度在 0~200' }) + @IsOptional() + description?: string +} + +export class UpdateMemorandumCategoryDto extends AddMemorandumCategoryDto { + @ApiProperty({ description: 'id' }) + @IsString({ message: 'id 类型错误,正确类型 number' }) + @IsNotEmpty({ message: 'id 不能为空' }) + id: string +} + +export class DeleteMemorandumCategoryDto extends ReqQuery { + @ApiProperty({ description: 'id' }) + @IsString({ message: 'id 类型错误,正确类型 number' }) + @IsNotEmpty({ message: 'id 不能为空' }) + id: string +} + +export class FindPageDto extends ReqListQuery { + + @ApiProperty({ description: '昵称模糊搜索', required: false }) + name?: string + + @ApiProperty({ description: '开始时间', required: false }) + startDate?: Date + + @ApiProperty({ description: '开始时间', required: false }) + endDate?: Date +} + +export class FindListDto { + + @ApiProperty({ description: '昵称模糊搜索', required: false }) + name?: string + + @ApiProperty({ description: '开始时间', required: false }) + startDate?: Date + + @ApiProperty({ description: '开始时间', required: false }) + endDate?: Date +} diff --git a/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.controller.ts b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.controller.ts new file mode 100644 index 0000000..b60c7d6 --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.controller.ts @@ -0,0 +1,54 @@ +import { Controller, Get, Post, UseInterceptors, Query, Body, Delete, Put } from '@nestjs/common' +import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger' +import { ResultData } from 'src/common/utils/result' +import { UpdateInterceptor } from 'src/common/guards/update.interceptor' +import { ApiResult } from 'src/common/decorators/api-result.decorator' + +import { AddMemorandumCategoryDto, DeleteMemorandumCategoryDto, FindListDto, FindPageDto, UpdateMemorandumCategoryDto } from './dto/memorandum-category.dto' +import { MemorandumCategoryEntity } from './memorandum-category.entity' +import { MemorandumCategoryService } from './memorandum-category.service' + +@ApiTags('备忘录类型') +@ApiBearerAuth() +@Controller('memorandum-category') +export class MemorandumCategoryController { + constructor(private readonly service: MemorandumCategoryService) {} + + @Post() + @ApiOperation({ summary: '新增' }) + @ApiResult() + @UseInterceptors(UpdateInterceptor) + async create(@Body() dto: AddMemorandumCategoryDto): Promise { + return await this.service.add(dto) + } + + @Delete() + @ApiOperation({ summary: '删除' }) + @ApiResult() + @UseInterceptors(UpdateInterceptor) + async delete(@Body() dto: DeleteMemorandumCategoryDto): Promise { + return await this.service.delete(dto) + } + + @Put() + @ApiOperation({ summary: '更新' }) + @ApiResult() + @UseInterceptors(UpdateInterceptor) + async update(@Body() dto: UpdateMemorandumCategoryDto): Promise { + return await this.service.update(dto) + } + + @Get('getPage') + @ApiOperation({ summary: '查询分页数据列表' }) + @ApiResult(MemorandumCategoryEntity, true, true) + async getPage(@Query() dto: FindPageDto): Promise { + return await this.service.getPage(dto) + } + + @Get('getList') + @ApiOperation({ summary: '查询不分页数据列表' }) + @ApiResult(MemorandumCategoryEntity, true, true) + async getList(@Query() dto: FindListDto): Promise { + return await this.service.getList(dto) + } +} diff --git a/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.entity.ts b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.entity.ts new file mode 100644 index 0000000..af8bc4d --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.entity.ts @@ -0,0 +1,20 @@ +import { Column, Entity, JoinTable, ManyToMany } from 'typeorm' +import { ApiProperty } from '@nestjs/swagger' +import { CommonEntity } from '../../../entities/common.entity' +import { MemorandumEntity } from '../memorandum/memorandum.entity' + +@Entity('website_memorandum_category') +export class MemorandumCategoryEntity extends CommonEntity{ + + @ApiProperty({ type: String, description: '名称' }) + @Column({ type: 'varchar', length: 32, comment: '名称' }) + public name: string + + @ApiProperty({ description: '描述' }) + @Column({ type: 'varchar', length: 200, default: '', comment: '描述' }) + public description: string + + // @ManyToMany(() => MemorandumEntity, i=> i.categories) + // @JoinTable() + // memorandums: MemorandumEntity[]; +} diff --git a/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.module.ts b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.module.ts new file mode 100644 index 0000000..952728b --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.module.ts @@ -0,0 +1,13 @@ +import { Module } from "@nestjs/common" +import { TypeOrmModule } from "@nestjs/typeorm" +import { MemorandumCategoryController } from './memorandum-category.controller' +import { MemorandumCategoryEntity } from './memorandum-category.entity' +import { MemorandumCategoryService } from "./memorandum-category.service" + +@Module({ + imports: [TypeOrmModule.forFeature([MemorandumCategoryEntity])], + providers: [MemorandumCategoryService], + controllers: [MemorandumCategoryController] +}) + +export class MemorandumCategoryModule {} diff --git a/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.service.ts b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.service.ts new file mode 100644 index 0000000..0ea5601 --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/category/memorandum-category.service.ts @@ -0,0 +1,165 @@ +import { Injectable } from '@nestjs/common' +import { InjectEntityManager, InjectRepository } from '@nestjs/typeorm' +import { Between, EntityManager, Like, Not, Repository } from 'typeorm' +import { MemorandumCategoryEntity } from './memorandum-category.entity' +import { + AddMemorandumCategoryDto, + DeleteMemorandumCategoryDto, + FindListDto, + FindPageDto, + UpdateMemorandumCategoryDto, +} from './dto/memorandum-category.dto' +import { ResultData } from 'src/common/utils/result' +import { AppHttpCode } from 'src/common/enums/code.enum' +import { plainToInstance } from 'class-transformer' + +@Injectable() +export class MemorandumCategoryService { + constructor( + @InjectRepository(MemorandumCategoryEntity) + private readonly repository: Repository, + @InjectEntityManager() + private readonly manager: EntityManager, + ) {} + + /** + * # 添加一条新的数据 + * @param data 保存的数据 + */ + async add(data: AddMemorandumCategoryDto): Promise { + try { + const existing = await this.getDetail(null, data.name) + if (existing) { + return ResultData.fail(AppHttpCode.SERVICE_ERROR, '名称已存在,请调整后重新提交!') + } + + const __data__ = plainToInstance(MemorandumCategoryEntity, data) + const result = await this.manager.transaction(async (transactionalEntityManager) => { + return await transactionalEntityManager.save(__data__) + }) + + if (!result) { + return ResultData.fail(AppHttpCode.SERVICE_ERROR, '创建失败, 请稍后重试') + } + + return ResultData.ok(result) + } catch (error) { + return ResultData.fail(AppHttpCode.SERVICE_ERROR, '发生错误, 请稍后重试') + } + } + + /** + * # 根据ID删除一条数据 + * @param dto + */ + async delete(dto: DeleteMemorandumCategoryDto) { + try { + const existing = await this.getDetail(dto.id) + if (!existing) return ResultData.fail(AppHttpCode.ROLE_NOT_FOUND, '当前分类不存在或已被删除') + + // todo 该分类存在备忘录数据, 则不允许被删除 + // let len = 0; + // if (len > 0) + // return ResultData.fail(AppHttpCode.ROLE_NOT_DEL, '当前分类还有绑定的备忘录,需要解除关联后删除') + + const { affected } = await this.manager.transaction(async (transactionalEntityManager) => { + const __data__ = plainToInstance(MemorandumCategoryEntity, { + ...dto, + isDeleted: true, + }) + return await transactionalEntityManager.update( + MemorandumCategoryEntity, + __data__.id, + __data__, + ) + }) + if (!affected) return ResultData.fail(AppHttpCode.SERVICE_ERROR, '删除失败, 请稍后重试') + + return ResultData.ok(affected) + } catch (error) { + return ResultData.fail(AppHttpCode.SERVICE_ERROR, '发生错误, 请稍后重试') + } + } + + /** + * # 修改一条数据 + * @param data 修改的数据实体 + */ + async update(data: UpdateMemorandumCategoryDto): Promise { + try { + const existing = await this.getDetail(data.id) + if (!existing) return ResultData.fail(AppHttpCode.ROLE_NOT_FOUND, '当前分类不存在或已被删除') + if (data.name && (await this.getDetail(data.id, data.name, true))) + return ResultData.fail(AppHttpCode.USER_CREATE_EXISTING, '名称已存在,请调整后重新提交!') + + const { affected } = await this.manager.transaction(async (transactionalEntityManager) => { + const __data__ = plainToInstance(MemorandumCategoryEntity, data) + return await transactionalEntityManager.update( + MemorandumCategoryEntity, + __data__.id, + __data__, + ) + }) + if (!affected) return ResultData.fail(AppHttpCode.SERVICE_ERROR, '更新失败, 请稍后重试') + + return ResultData.ok(affected) + } catch (error) { + return ResultData.fail(AppHttpCode.SERVICE_ERROR, '发生错误, 请稍后重试') + } + } + + /** + * 查询分页数据列表 + */ + async getPage(dto: FindPageDto): Promise { + const { page, size, name } = dto + const where: any = { + ...(name ? { account: Like(`%${name}%`) } : null), + isDeleted: false, + } + if (dto.startDate && dto.endDate) { + where.createdAt = Between(dto.startDate, dto.endDate) + } + const [list, total] = await this.repository.findAndCount({ + order: { createdAt: 'DESC' }, + skip: size * (page - 1), + take: size, + where, + }) + return ResultData.ok({ list, total }) + } + + /** + * 查询不分页数据列表 + */ + async getList(dto: FindListDto): Promise { + const { name } = dto + const where: any = { + ...(name ? { account: Like(`%${name}%`) } : null), + isDeleted: false, + } + if (dto.startDate && dto.endDate) { + where.createdAt = Between(dto.startDate, dto.endDate) + } + const list = await this.repository.find({ + order: { createdAt: 'DESC' }, + where, + }) + return ResultData.ok({ list, total: list.length }) + } + + /** + * ## 获取详情对象 + * @param id ID + * @param name 名称 + * @param exclude 是否排除当前id + */ + async getDetail(id: string = null, name: string = null, exclude = false): Promise { + let obj = { + name: name || null, + isDeleted: false, + id: exclude ? Not(id || null) : (id || null), + } + return await this.repository.findOne({ where: obj }) + } +} diff --git a/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.controller.ts b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.controller.ts new file mode 100644 index 0000000..c52fd8b --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.controller.ts @@ -0,0 +1,12 @@ +import { Controller, Get, Post, UploadedFile, UseInterceptors, Query, HttpCode, Body, Req } from '@nestjs/common' +import { FileInterceptor } from '@nestjs/platform-express' +import { ApiTags, ApiOperation, ApiConsumes, ApiBody, ApiBearerAuth } from '@nestjs/swagger' +import { MemorandumService } from './memorandum.service' + +@ApiTags('备忘录类型') +@ApiBearerAuth() +@Controller('memorandum') +export class MemorandumController { + constructor(private readonly service: MemorandumService) {} + +} diff --git a/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.entity.ts b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.entity.ts new file mode 100644 index 0000000..cc5c910 --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.entity.ts @@ -0,0 +1,25 @@ +import { Column, Entity, JoinTable, ManyToMany } from 'typeorm' +import { ApiProperty } from '@nestjs/swagger' +import { CommonEntity } from 'src/entities/common.entity' +import { $enum } from 'ts-enum-util' +import { StatusValue2 } from 'src/common/enums/common.enum' +import { MemorandumCategoryEntity } from '../category/memorandum-category.entity' + +@Entity('website_memorandum_category') +export class MemorandumEntity extends CommonEntity { + @ApiProperty({ type: String, description: '标题' }) + @Column({ type: 'varchar', default: '', length: 100, comment: '标题' }) + public name: string + + @ApiProperty({ type: String, description: '置顶: 1-是: 0-否', enum: $enum(StatusValue2).getValues() }) + @Column({ type: 'tinyint', default: StatusValue2.NO, comment: '置顶: 1-是: 0-否' }) + public stickyPost: StatusValue2 + + @ApiProperty({ description: '内容' }) + @Column({ type: 'text', comment: '内容' }) + public content: string + + // @ManyToMany(() => MemorandumCategoryEntity, i=> i.memorandums) + // @JoinTable() + // categories: MemorandumCategoryEntity[]; +} diff --git a/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.module.ts b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.module.ts new file mode 100644 index 0000000..e10e992 --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.module.ts @@ -0,0 +1,13 @@ +import { Module } from "@nestjs/common" +import { TypeOrmModule } from "@nestjs/typeorm" +import { MemorandumController } from './memorandum.controller' +import { MemorandumEntity } from './memorandum.entity' +import { MemorandumService } from "./memorandum.service" + +@Module({ + imports: [TypeOrmModule.forFeature([MemorandumEntity])], + providers: [MemorandumService], + controllers: [MemorandumController] +}) + +export class MemorandumModule {} diff --git a/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.service.ts b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.service.ts new file mode 100644 index 0000000..e99073a --- /dev/null +++ b/nest-admin/servers/src/website/memorandum-management/memorandum/memorandum.service.ts @@ -0,0 +1,15 @@ +import { Injectable } from '@nestjs/common' +import { InjectRepository } from '@nestjs/typeorm' +import { Repository } from 'typeorm' +import { MemorandumEntity } from './memorandum.entity' + +@Injectable() +export class MemorandumService { + + constructor( + @InjectRepository(MemorandumEntity) + private readonly repository: Repository, + ) {} + + +} diff --git a/vue-vben-admin/src/api/website/memorandum-category.ts b/vue-vben-admin/src/api/website/memorandum-category.ts new file mode 100644 index 0000000..64e6aeb --- /dev/null +++ b/vue-vben-admin/src/api/website/memorandum-category.ts @@ -0,0 +1,27 @@ +import { defHttp } from '@/utils/http/axios'; +import { + AddMemorandumCategoryDto, + DeleteMemorandumCategoryDto, + FindListDto, + FindPageDto, + UpdateMemorandumCategoryDto, +} from './model/memorandum-category'; + +enum Api { + MemorandumCategory = '/memorandum-category', +} + +export const add = (params: AddMemorandumCategoryDto) => + defHttp.post({ url: Api.MemorandumCategory, params }); + +export const del = (params: DeleteMemorandumCategoryDto) => + defHttp.delete({ url: Api.MemorandumCategory, params }); + +export const update = (params: UpdateMemorandumCategoryDto) => + defHttp.put({ url: Api.MemorandumCategory, params }); + +export const getPage = (params: FindPageDto) => + defHttp.get({ url: Api.MemorandumCategory + '/getPage', params }); + +export const getList = (params: FindListDto) => + defHttp.get({ url: Api.MemorandumCategory + '/getList', params }); diff --git a/vue-vben-admin/src/api/website/model/memorandum-category.ts b/vue-vben-admin/src/api/website/model/memorandum-category.ts new file mode 100644 index 0000000..5850f87 --- /dev/null +++ b/vue-vben-admin/src/api/website/model/memorandum-category.ts @@ -0,0 +1,28 @@ +import { BasicPageParams } from '@/api/model/baseModel'; + +export interface MemorandumCategoryEntity { + name: string; + description: string; + [key: string]: any; +} + +export interface AddMemorandumCategoryDto { + name: string; + description?: string; +} + +export interface UpdateMemorandumCategoryDto extends AddMemorandumCategoryDto { + id: string; +} + +export interface DeleteMemorandumCategoryDto { + id: string; +} + +export interface FindListDto { + name?: string; + startDate?: Date; + endDate?: Date; +} + +export type FindPageDto = BasicPageParams & FindListDto; diff --git a/vue-vben-admin/src/views/website/memorandum-management/category/CreateOrEditModal.vue b/vue-vben-admin/src/views/website/memorandum-management/category/CreateOrEditModal.vue index 3d7f226..41784ec 100644 --- a/vue-vben-admin/src/views/website/memorandum-management/category/CreateOrEditModal.vue +++ b/vue-vben-admin/src/views/website/memorandum-management/category/CreateOrEditModal.vue @@ -19,7 +19,7 @@ import { BasicModal, useModalInner } from '@/components/Modal'; import { BasicForm, useForm } from '@/components/Form'; import { basicFormSchema } from './category.data'; - import { createUser, updateUser } from '@/api/demo/system'; + import { add, update } from '@/api/website/memorandum-category'; import { useMessage } from '@/hooks/web/useMessage'; const { createMessage } = useMessage(); @@ -29,7 +29,7 @@ const isUpdate = ref(true); const rowId = ref(''); - const [registerForm, { setFieldsValue, validate, clearValidate, updateSchema }] = useForm({ + const [registerForm, { setFieldsValue, validate, clearValidate }] = useForm({ name: 'memorandum-management-category-modal-form', labelWidth: '80px', baseColProps: { span: 12 }, @@ -63,14 +63,14 @@ try { const values = await validate(); setModalProps({ confirmLoading: true }); - let params = { + let params: any = { ...values, id: unref(isUpdate) ? rowId.value : undefined } if (unref(isUpdate)) { - await updateUser(params) + await update(params) createMessage.success('更新成功') } else { - await createUser(params) + await add(params) createMessage.success('新增成功') } diff --git a/vue-vben-admin/src/views/website/memorandum-management/category/category.data.ts b/vue-vben-admin/src/views/website/memorandum-management/category/category.data.ts index d0321e5..ab03b38 100644 --- a/vue-vben-admin/src/views/website/memorandum-management/category/category.data.ts +++ b/vue-vben-admin/src/views/website/memorandum-management/category/category.data.ts @@ -8,7 +8,7 @@ export const columns: BasicColumn[] = [ }, { title: '描述', - dataIndex: 'remark', + dataIndex: 'description', }, { title: '创建时间', @@ -46,11 +46,12 @@ export const basicFormSchema: FormSchema[] = [ required: true, componentProps: { showCount: true, + maxlength: 20, } }, { - label: '备注', - field: 'remark', + label: '描述', + field: 'description', component: 'InputTextArea', componentProps: { showCount: true, diff --git a/vue-vben-admin/src/views/website/memorandum-management/category/index.vue b/vue-vben-admin/src/views/website/memorandum-management/category/index.vue index 024d9c3..e6866a8 100644 --- a/vue-vben-admin/src/views/website/memorandum-management/category/index.vue +++ b/vue-vben-admin/src/views/website/memorandum-management/category/index.vue @@ -2,7 +2,12 @@