diff --git a/src/pages.json b/src/pages.json index 9a762b5..aed4ed3 100644 --- a/src/pages.json +++ b/src/pages.json @@ -55,12 +55,6 @@ "navigationBarTitleText": "系统配置" } }, - { - "path": "pages/work/config/edit", - "style": { - "navigationBarTitleText": "新增修改配置页面" - } - }, { "path": "pages/work/notice/index", "style": { diff --git a/src/pages/work/config/edit.vue b/src/pages/work/config/edit.vue deleted file mode 100644 index 470b030..0000000 --- a/src/pages/work/config/edit.vue +++ /dev/null @@ -1,217 +0,0 @@ - - - - diff --git a/src/pages/work/config/index.vue b/src/pages/work/config/index.vue index 33bd7cd..9e40770 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,9 @@ const queryParams = reactive({ }); // 系统配置表格数据 const pageData = ref([]); +const formRef = ref(); + +const loading = ref(false); /** * 搜索栏 */ @@ -98,17 +147,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 +214,9 @@ onReachBottom(() => { }); /** - * 查询 + * 加载更多 */ -function handleQuery() { +function loadmore() { state.value = "loading"; ConfigAPI.getPage(queryParams) .then((data) => { @@ -146,10 +235,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 +257,6 @@ const refreshCache = debounce(() => { }); }, 1000); -/** - * 编辑 - */ -function handleEdit(item: ConfigPageVO) { - // 直接传递整个 item 对象 - uni.navigateTo({ - url: "/pages/work/config/edit?item=" + encodeURIComponent(JSON.stringify(item)), - }); -} - /** * 删除 */ @@ -204,7 +286,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/notice/detail.vue b/src/pages/work/notice/detail.vue index d225baf..f3d8f49 100644 --- a/src/pages/work/notice/detail.vue +++ b/src/pages/work/notice/detail.vue @@ -8,18 +8,19 @@
- 发布人:{{ noticeDetail.publisherName }} - - 发布时间:{{ formatDate(noticeDetail.publishTime ?? "") }} -
-
- + 优先级: - + {{ getLevelText(noticeDetail.level) }}
+
+ 发布人:{{ noticeDetail.publisherName }} +
+
+ 发布时间:{{ noticeDetail.publishTime }} +
@@ -29,10 +30,8 @@