From b207bc0e68e15b509c7685470bcede3dcd108000 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Thu, 31 Oct 2024 14:53:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=B1=BB=E5=9E=8B=20CRUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/.env.development | 4 +- frontend/src/api/interface/index.ts | 6 +- .../api/system/dictionary/dictData/index.ts | 0 .../{dict => dictionary}/dictExample.ts | 2 +- .../api/system/dictionary/dictType/index.ts | 24 ++ .../api/system/{dict => dictionary}/index.ts | 2 +- .../{dict => dictionary}/interface/index.ts | 49 +++- frontend/src/api/user/login.ts | 12 +- .../ProTable/components/Pagination.vue | 8 +- frontend/src/enums/httpEnum.ts | 2 +- frontend/src/hooks/useTable.ts | 8 +- .../src/layouts/components/Footer/index.vue | 2 +- frontend/src/types/auto-imports.d.ts | 2 +- frontend/src/views/authority/role/index.vue | 2 +- frontend/src/views/home/components/table.vue | 6 +- frontend/src/views/home/index.vue | 2 +- .../views/plan/autoTest/components/table.vue | 6 +- frontend/src/views/plan/autoTest/index.vue | 4 +- .../singlePlanList/components/details.vue | 2 +- .../src/views/plan/singlePlanList/index.vue | 10 +- frontend/src/views/system/dict/index.vue | 231 ------------------ .../system/{dict => dictionary}/data.vue | 6 +- .../system/dictionary/dictData/index.vue | 0 .../dictType/components/typePopup.vue | 132 ++++++++++ .../system/dictionary/dictType/index.vue | 141 +++++++++++ frontend/tailwind.config.js | 2 +- 26 files changed, 386 insertions(+), 279 deletions(-) create mode 100644 frontend/src/api/system/dictionary/dictData/index.ts rename frontend/src/api/system/{dict => dictionary}/dictExample.ts (97%) create mode 100644 frontend/src/api/system/dictionary/dictType/index.ts rename frontend/src/api/system/{dict => dictionary}/index.ts (96%) rename frontend/src/api/system/{dict => dictionary}/interface/index.ts (58%) delete mode 100644 frontend/src/views/system/dict/index.vue rename frontend/src/views/system/{dict => dictionary}/data.vue (98%) create mode 100644 frontend/src/views/system/dictionary/dictData/index.vue create mode 100644 frontend/src/views/system/dictionary/dictType/components/typePopup.vue create mode 100644 frontend/src/views/system/dictionary/dictType/index.vue diff --git a/frontend/.env.development b/frontend/.env.development index 1aa3daa..d53b7f8 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -18,5 +18,5 @@ VITE_PWA=false VITE_API_URL=/api # 开发环境跨域代理,支持配置多个 -# VITE_PROXY=[["/api","http://192.168.1.125:18092/"]] -VITE_PROXY=[["/api","http://192.168.1.138:8080/"]] \ No newline at end of file + VITE_PROXY=[["/api","http://192.168.1.125:18092/"]] +#VITE_PROXY=[["/api","http://192.168.1.138:8080/"]] \ No newline at end of file diff --git a/frontend/src/api/interface/index.ts b/frontend/src/api/interface/index.ts index 36330cd..0a0fef8 100644 --- a/frontend/src/api/interface/index.ts +++ b/frontend/src/api/interface/index.ts @@ -30,9 +30,9 @@ export interface ReqPage { * 分页响应参数 */ export interface ResPage { - list: T[]; - pageNum: number; - pageSize: number; + records: T[]; + current: number; + size: number; total: number; } diff --git a/frontend/src/api/system/dictionary/dictData/index.ts b/frontend/src/api/system/dictionary/dictData/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/api/system/dict/dictExample.ts b/frontend/src/api/system/dictionary/dictExample.ts similarity index 97% rename from frontend/src/api/system/dict/dictExample.ts rename to frontend/src/api/system/dictionary/dictExample.ts index 852ab4f..16a4145 100644 --- a/frontend/src/api/system/dict/dictExample.ts +++ b/frontend/src/api/system/dictionary/dictExample.ts @@ -1,4 +1,4 @@ -import { type Dict } from "@/api/system/dict/interface"; +import { type Dict } from "@/api/system/dictionary/interface"; export const dictTypeList: Dict.ResDictType[] = [ { diff --git a/frontend/src/api/system/dictionary/dictType/index.ts b/frontend/src/api/system/dictionary/dictType/index.ts new file mode 100644 index 0000000..ccf7bda --- /dev/null +++ b/frontend/src/api/system/dictionary/dictType/index.ts @@ -0,0 +1,24 @@ +import http from '@/api' +import { type Dict } from '@/api/system/dictionary/interface' + +//获取字典类型 +export const getDictTypeList = (params: Dict.ReqDictTypeParams) => { + return http.post(`/dictType/list`, params) +} + +//添加字典类型 +export const addDictType = (params: Dict.ResDictType) => { + return http.post(`/dictType/add`, params) +} + +//编辑字典类型 +export const updateDictType = (params: Dict.ResDictType) => { + return http.post(`/dictType/update`, params) +} + +//删除字典类型 +export const deleteDictType = (params: string[]) => { + return http.post(`/dictType/delete`, params) +} + + diff --git a/frontend/src/api/system/dict/index.ts b/frontend/src/api/system/dictionary/index.ts similarity index 96% rename from frontend/src/api/system/dict/index.ts rename to frontend/src/api/system/dictionary/index.ts index 9e42def..1a98d7b 100644 --- a/frontend/src/api/system/dict/index.ts +++ b/frontend/src/api/system/dictionary/index.ts @@ -1,6 +1,6 @@ import http from "@/api"; import { ADMIN as rePrefix } from "@/api/config/serviceName"; -import { type Dict } from "@/api/system/dict/interface"; +import { type Dict } from "@/api/system/dictionary/interface"; //获取字典类型 export const getDictTypeList = (params: Dict.ReqDictTypeParams) => { diff --git a/frontend/src/api/system/dict/interface/index.ts b/frontend/src/api/system/dictionary/interface/index.ts similarity index 58% rename from frontend/src/api/system/dict/interface/index.ts rename to frontend/src/api/system/dictionary/interface/index.ts index ecc8d5a..db8b700 100644 --- a/frontend/src/api/system/dict/interface/index.ts +++ b/frontend/src/api/system/dictionary/interface/index.ts @@ -1,7 +1,25 @@ -import type { ReqPage } from "@/api/interface"; +import type { ReqPage, ResPage } from '@/api/interface' export namespace Dict { - + + /** + * 一个单表的CRUD需要申明一下几个对象 + * 1、表格分页查询对象,字段:查询字段?、页码、每页条数; + * 2、新增、修改、根据id查询返回的对象; + * 3、表格查询分页返回的对象; + */ + + /** + * 字典类型表格分页查询参数 + */ + export interface ReqDictTypeParams extends ReqPage{ + name?: string; // 名称 + code?: string; // 编码 + } + + /** + * 字典类型新增、修改、根据id查询返回的对象 + */ export interface ResDictType { id: string; // 字典类型表Id name: string; // 名称 @@ -17,10 +35,27 @@ export namespace Dict { updateTime?: string | null; // 更新时间 } - export interface ReqDictTypeParams extends ReqPage{ - + /** + * 字典类型表格查询分页返回的对象; + */ + export interface ResDictTypePage extends ResPage { + } + + + /** + * 字典数据表格分页查询参数 + */ + export interface ReqDictDataParams extends ReqPage{ + typeId: string; // 类型id 必填 + name?: string; // 名称 + code?: string; // 编码 + } + + /** + * 字典数据新增、修改、根据id查询返回的对象 + */ export interface ResDictData { id: string; // 字典数据表Id typeId: string; // 字典类型表Id @@ -37,7 +72,11 @@ export namespace Dict { updateTime?: string | null; // 更新时间 } - export interface ReqDictDataParams extends ReqPage{ + /** + * 字典数据表格查询分页返回的对象; + */ + export interface ResDictDataPage extends ResPage { } + } diff --git a/frontend/src/api/user/login.ts b/frontend/src/api/user/login.ts index 3583e5a..e363d15 100644 --- a/frontend/src/api/user/login.ts +++ b/frontend/src/api/user/login.ts @@ -7,20 +7,20 @@ import http from '@/api' */ // 用户登录 export const loginApi = (params: Login.ReqLoginForm) => { - // return http.post(`${rePrefix}/login`, params, { loading: false }) - return http.post(`/Register1`, params, { loading: false }) + return http.post(`${rePrefix}/login`, params, { loading: false }) + // return http.post(`/Register1`, params, { loading: false }) } // 获取菜单列表 export const getAuthMenuListApi = () => { - // return http.get(`${rePrefix}/menu/list`, {}, { loading: false }) - return http.post(`/Register2`, {}, { loading: false }) + return http.get(`${rePrefix}/menu/list`, {}, { loading: false }) + // return http.post(`/Register2`, {}, { loading: false }) } // 获取按钮权限 export const getAuthButtonListApi = () => { - // return http.get(`${rePrefix}/auth/buttons`, {}, { loading: false }) - return http.post(`/Register3`, {}, { loading: false }) + return http.get(`${rePrefix}/auth/buttons`, {}, { loading: false }) + // return http.post(`/Register3`, {}, { loading: false }) } // 用户退出登录 diff --git a/frontend/src/components/ProTable/components/Pagination.vue b/frontend/src/components/ProTable/components/Pagination.vue index 21efde0..3bd67fe 100644 --- a/frontend/src/components/ProTable/components/Pagination.vue +++ b/frontend/src/components/ProTable/components/Pagination.vue @@ -2,8 +2,8 @@ --> - +
{{ title }} { // 导出角色列表 //const downloadFile = async () => { -// ElMessageBox.confirm('确认导出角色数据?', '温馨提示', { type: 'warning' }).then(() => +// ElMessageBox.confirm('确认导出角色数据?', '温馨提示', { dictType: 'warning' }).then(() => // useDownload(exportRoleInfo, '角色列表', proTable.value?.searchParam), // ) //} diff --git a/frontend/src/views/home/components/table.vue b/frontend/src/views/home/components/table.vue index 9365d4f..5238608 100644 --- a/frontend/src/views/home/components/table.vue +++ b/frontend/src/views/home/components/table.vue @@ -101,21 +101,21 @@