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/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/components/dict/label.vue b/src/components/dict/label.vue new file mode 100644 index 0000000..8d3a2d9 --- /dev/null +++ b/src/components/dict/label.vue @@ -0,0 +1,54 @@ + + + diff --git a/src/pages.json b/src/pages.json index 9a762b5..37a4746 100644 --- a/src/pages.json +++ b/src/pages.json @@ -2,7 +2,8 @@ "easycom": { "autoscan": true, "custom": { - "^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue" + "^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue", + "^dict-(.*)": "@/components/dict/$1.vue" } }, @@ -55,12 +56,6 @@ "navigationBarTitleText": "系统配置" } }, - { - "path": "pages/work/config/edit", - "style": { - "navigationBarTitleText": "新增修改配置页面" - } - }, { "path": "pages/work/notice/index", "style": { 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 @@ - - diff --git a/src/pages/work/config/index.vue b/src/pages/work/config/index.vue index 33bd7cd..fc0da07 100644 --- a/src/pages/work/config/index.vue +++ b/src/pages/work/config/index.vue @@ -12,8 +12,10 @@ placeholder="请输入关键字" /> - 查询 - 重置 + + 查询 + + 重置 @@ -57,9 +59,7 @@ @@ -69,10 +69,55 @@ - - 添加 + + 添加 刷新缓存 + + + + + + + + + + + 取消 + + 确定 + + + + @@ -80,7 +125,8 @@ import ConfigAPI, { ConfigPageVO, ConfigForm, ConfigPageQuery } from "@/api/system/config"; import { DropMenuItemExpose } from "wot-design-uni/components/wd-drop-menu-item/types"; import { LoadMoreState } from "wot-design-uni/components/wd-loadmore/types"; -import { debounce } from "@/utils/commonUtil"; +import { FormInstance } from "wot-design-uni/components/wd-form/types"; +import { debounce } from "@/utils"; const state = ref("loading"); // 加载状态 loading, finished:, error const total = ref(0); const queryParams = reactive({ @@ -90,6 +136,10 @@ const queryParams = reactive({ }); // 系统配置表格数据 const pageData = ref([]); +const formRef = ref(); + +const loading = ref(false); + /** * 搜索栏 */ @@ -98,17 +148,57 @@ const dropMenu = ref(); /** * 搜索 */ -function search() { +function handleQuery() { pageData.value = []; dropMenu.value?.close(); queryParams.pageNum = 1; - handleQuery(); + loadmore(); +} + +const showEditPopup = ref(false); +const form = ref({}); + +// 修改编辑函数 +function handleEdit(id: number) { + ConfigAPI.getFormData(id).then((data) => { + Object.assign(form.value, data); + // 显示弹窗 + showEditPopup.value = true; + }); +} + +// 提交表单 +async function submitForm() { + loading.value = true; + try { + if (formRef.value) { + formRef.value!.validate().then(async ({ valid, errors }) => { + if (valid) { + if (form.value.id) { + await ConfigAPI.update(form.value.id, form.value); + uni.showToast({ title: "更新成功", icon: "success" }); + } else { + await ConfigAPI.add(form.value); + uni.showToast({ title: "添加成功", icon: "success" }); + } + showEditPopup.value = false; + handleQuery(); // 刷新列表 + } else { + uni.showToast({ title: "请检查表单", icon: "error" }); + loading.value = false; + } + }); + } + } catch (error) { + uni.showToast({ title: "操作失败", icon: "error" }); + loading.value = false; + } } /** * 重置搜索条件 */ -function reset() { +function handleReset() { queryParams.pageNum = 1; queryParams.keywords = ""; pageData.value = []; @@ -125,9 +215,9 @@ onReachBottom(() => { }); /** - * 查询 + * 加载更多 */ -function handleQuery() { +function loadmore() { state.value = "loading"; ConfigAPI.getPage(queryParams) .then((data) => { @@ -146,10 +236,13 @@ function handleQuery() { /** * 添加 */ -function add() { - uni.navigateTo({ - url: "/pages/work/config/edit", - }); +function handleOpenDialog() { + form.id = undefined; + form.configName = ""; + form.configKey = ""; + form.configValue = ""; + form.remark = ""; + showEditPopup.value = true; } /** @@ -165,16 +258,6 @@ const refreshCache = debounce(() => { }); }, 1000); -/** - * 编辑 - */ -function handleEdit(item: ConfigPageVO) { - // 直接传递整个 item 对象 - uni.navigateTo({ - url: "/pages/work/config/edit?item=" + encodeURIComponent(JSON.stringify(item)), - }); -} - /** * 删除 */ @@ -204,7 +287,7 @@ function handleAction(item: ConfigPageVO) { success: ({ tapIndex }) => { switch (actions[tapIndex]) { case "编辑": - handleEdit(item); + handleEdit(item.id || 0); break; case "删除": handleDelete(item); diff --git a/src/pages/work/log/index.vue b/src/pages/work/log/index.vue index dd6117e..de5127e 100644 --- a/src/pages/work/log/index.vue +++ b/src/pages/work/log/index.vue @@ -17,9 +17,11 @@ allow-same-day @confirm="handleConfirm" /> - - 查询 - 重置 + + + 查询 + + 重置 @@ -90,7 +92,7 @@ function handleConfirm({ value }: Ref) { * 搜索栏 */ const dropMenu = ref(); -function search() { +function handleSearch() { pageData.value = []; dropMenu.value?.close(); handleQuery(); @@ -99,7 +101,7 @@ function search() { /** * 重置搜索条件 */ -function reset() { +function handleReset() { queryParams.pageNum = 1; queryParams.keywords = ""; queryParams.createTime = ["", ""]; diff --git a/src/pages/work/notice/detail.vue b/src/pages/work/notice/detail.vue index d225baf..c9c9538 100644 --- a/src/pages/work/notice/detail.vue +++ b/src/pages/work/notice/detail.vue @@ -8,18 +8,11 @@
- 发布人:{{ noticeDetail.publisherName }} - - 发布时间:{{ formatDate(noticeDetail.publishTime ?? "") }} -
-
- - 优先级: - - {{ getLevelText(noticeDetail.level) }} - - + 优先级: +
+
发布人:{{ noticeDetail.publisherName }}
+
发布时间:{{ noticeDetail.publishTime }}
@@ -29,10 +22,8 @@