From 1f8cda13b9d67e1708340758d17aa82207ac0cb0 Mon Sep 17 00:00:00 2001 From: Theo <971366405@qq.com> Date: Sun, 24 Nov 2024 15:46:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=92=8C=E5=AD=97=E5=85=B8=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增字典和字典展示功能 --- package.json | 1 + src/api/system/dict.ts | 180 ++++++++++++++++++++++++++++++ src/components/dict/DictLabel.vue | 54 +++++++++ src/components/dict/index.vue | 126 +++++++++++++++++++++ src/pages/login/index.vue | 5 +- src/pages/work/config/index.vue | 1 + src/pages/work/notice/detail.vue | 16 +-- src/pages/work/notice/index.vue | 2 +- src/store/modules/dict.ts | 38 +++++++ src/utils/cache.ts | 18 +++ src/utils/request.ts | 2 +- vite.config.ts | 4 + 12 files changed, 431 insertions(+), 16 deletions(-) create mode 100644 src/api/system/dict.ts create mode 100644 src/components/dict/DictLabel.vue create mode 100644 src/components/dict/index.vue create mode 100644 src/store/modules/dict.ts diff --git a/package.json b/package.json index d7d11b6..fce1528 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "@dcloudio/uni-quickapp-webview": "3.0.0-4020420240722002", "@qiun/uni-ucharts": "2.5.0-20230101", "pinia": "^2.2.2", + "unplugin-vue-components": "^0.27.4", "vue": "^3.4.21", "wot-design-uni": "^1.3.11" }, diff --git a/src/api/system/dict.ts b/src/api/system/dict.ts new file mode 100644 index 0000000..157b0a9 --- /dev/null +++ b/src/api/system/dict.ts @@ -0,0 +1,180 @@ +import request from "@/utils/request"; + +const DICT_BASE_URL = "/api/v1/dict"; + +const DictAPI = { + /** + * 获取字典分页列表 + * + * @param queryParams 查询参数 + * @returns 字典分页结果 + */ + getPage(queryParams: DictPageQuery) { + return request({ + url: `${DICT_BASE_URL}/page`, + method: "GET", + data: queryParams, + }); + }, + + /** + * 获取字典表单数据 + * + * @param id 字典ID + * @returns 字典表单数据 + */ + getFormData(id: number) { + return request({ + url: `${DICT_BASE_URL}/${id}/form`, + method: "GET", + }); + }, + + /** + * 新增字典 + * + * @param data 字典表单数据 + */ + add(data: DictForm) { + return request({ + url: `${DICT_BASE_URL}`, + method: "POST", + data: data, + }); + }, + + /** + * 修改字典 + * + * @param id 字典ID + * @param data 字典表单数据 + */ + update(id: number, data: DictForm) { + return request({ + url: `${DICT_BASE_URL}/${id}`, + method: "PUT", + data: data, + }); + }, + + /** + * 删除字典 + * + * @param ids 字典ID,多个以英文逗号(,)分隔 + */ + deleteByIds(ids: string) { + return request({ + url: `${DICT_BASE_URL}/${ids}`, + method: "delete", + }); + }, + + /** + * 获取字典列表 + * + * @returns 字典列表 + */ + getList() { + return request({ + url: `${DICT_BASE_URL}/list`, + method: "GET", + }); + }, +}; + +export default DictAPI; + +/** + * 字典查询参数 + */ +export interface DictPageQuery extends PageQuery { + /** + * 关键字(字典名称/编码) + */ + keywords?: string; + + /** + * 字典状态(1:启用,0:禁用) + */ + status?: number; +} + +/** + * 字典分页对象 + */ +export interface DictPageVO { + /** + * 字典ID + */ + id: number; + /** + * 字典名称 + */ + name: string; + /** + * 字典编码 + */ + dictCode: string; + /** + * 字典状态(1:启用,0:禁用) + */ + status: number; +} + +/** + * 字典 + */ +export interface DictForm { + /** + * 字典ID + */ + id?: number; + /** + * 字典名称 + */ + name?: string; + /** + * 字典编码 + */ + dictCode?: string; + /** + * 字典状态(1-启用,0-禁用) + */ + status?: number; + /** + * 备注 + */ + remark?: string; +} + +/** + * 字典数据项分页VO + * + * @description 字典数据分页对象 + */ +export interface DictVO { + /** 字典名称 */ + name: string; + + /** 字典编码 */ + dictCode: string; + + /** 字典数据集合 */ + dictDataList: DictData[]; +} + +/** + * 字典数据 + * + * @description 字典数据 + */ +export interface DictData { + /** 字典数据值 */ + value: string; + + /** 字典数据标签 */ + label: string; + + /** 标签类型 */ + tagType: string; +} diff --git a/src/components/dict/DictLabel.vue b/src/components/dict/DictLabel.vue new file mode 100644 index 0000000..8d3a2d9 --- /dev/null +++ b/src/components/dict/DictLabel.vue @@ -0,0 +1,54 @@ + + + diff --git a/src/components/dict/index.vue b/src/components/dict/index.vue new file mode 100644 index 0000000..d33b34d --- /dev/null +++ b/src/components/dict/index.vue @@ -0,0 +1,126 @@ + + + diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 25791a6..c2cc2d4 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -35,7 +35,7 @@