({});
+
+// 修改编辑函数
+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 @@
@@ -29,10 +30,8 @@