From c28020b703bc595a26e42c650250f2d97e3f8bf0 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Fri, 18 Aug 2023 15:58:10 +0800 Subject: [PATCH] update --- .../wwwroot/components/list/index.js | 34 +++++++++++++++ .../wwwroot/router/base-data.js | 2 +- .../wwwroot/views/base-data/role.js | 19 +------- .../wwwroot/views/base-data/user.js | 43 +++++-------------- .../wwwroot/views/settle/_check.js | 41 ++++++++++-------- 5 files changed, 71 insertions(+), 68 deletions(-) diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js index 56fa4244..b6c7a003 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js @@ -812,6 +812,39 @@ export default { } return postData; } + const action = async (method, confirMmessage = "确认操作吗?", successMessage = "操作成功", reload = true) => { + try { + await ElMessageBox.confirm(confirMmessage, "提示", { + type: "warning", + }); + tableLoading.value = true; + let result = null; + if (method.constructor.name == "AsyncFunction") { + result = await method(); + } else { + result = method(); + } + if (!result.errors) { + await ElMessage({ + type: "info", + message: successMessage, + }); + if (reload) { + pageModel.pageIndex = 1; + await load(); + } + } + } catch (error) { + if (error === "cancel") { + ElMessage({ + type: "info", + message: "操作取消", + }); + } + } finally { + tableLoading.value = false; + } + }; onMounted(async () => { if (route.meta.children?.length) { for (const item of route.meta.children) { @@ -833,6 +866,7 @@ export default { }); return { load, + action, config, queryModel, buildQuery, diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js index 9113a338..bf68968d 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/base-data.js @@ -11,7 +11,7 @@ export default [ createButton("create", "title=新建&isTop=true"), createButton("update", "title=编辑"), createButton("delete", "title=删除&disabled=o=>o.userName==='admin'"), - createButton("%s/reset-password", "title=重置密码&method=PUT"), + createButton("reset-password", "title=重置密码&method=PUT"), ], }, { diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/role.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/role.js index dc0ca43c..38225c35 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/role.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/role.js @@ -1,17 +1,2 @@ -import AppList from "../../components/list/index.js"; -import html from "html"; -import useConfig from "../../models/base-data/role.js"; - -export default { - components: { AppList }, - template: html``, - setup() { - // 变量定义 - const config = useConfig(); - // 函数定义 - const onCommand = (item, rows) => { - console.log(item.path, item, rows); - }; - return { config, onCommand }; - }, -}; +import useList from "../_list.js"; +export default useList("base-data/role"); diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/user.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/user.js index 38c44650..f7a38935 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/user.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/user.js @@ -2,45 +2,24 @@ import AppList from "../../components/list/index.js"; import html from "html"; import useConfig from "../../models/base-data/user.js"; import request from "../../request/index.js"; -import { format } from "../../utils/index.js"; -import { ElMessage, ElMessageBox } from "element-plus"; +import { ref } from "vue"; export default { components: { AppList }, - template: html``, + template: html``, setup() { + const appListRef = ref(null); const config = useConfig(); const onCommand = async (item, rows) => { - console.log(item.path, item, rows); - if (item.path === "%s/reset-password") { - const url = format(item.path, rows[0].id); - await request(`base/user/${url}`, null, { method: item.meta.method }); - try { - await ElMessageBox.confirm(format("是否重置用户%s密码", rows[0].userName), "提示", { - type: "warning", - }); - await ElMessage({ - type: "info", - message: "密码已经成功重置为123456", - }); - const url = `${config.baseUrl}/${item.path}`; - await request( - url, - rows.map((o) => o.id), - { method: "POST" } - ); - console.log(context); - await load(); - } catch (error) { - if (error === "cancel") { - ElMessage({ - type: "info", - message: "操作取消", - }); - } - } + if (item.path === "reset-password") { + const url = `base/user/${rows[0].id}/${item.path}`; + await appListRef.value.action( + async () => await request(url, null, { method: item.meta.method }), + `是否重置用户${rows[0].userName}密码`, + `${rows[0].userName}密码已经重置为123456` + ); } }; - return { config, onCommand }; + return { appListRef, config, onCommand }; }, }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js index 31caae39..ca438ee3 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/_check.js @@ -50,7 +50,7 @@ export default { -
+
新建 @@ -60,27 +60,25 @@ export default { - +
-
- - - 新建 - 导入 - 删除 +
+ + + + + + + + + + - - - - - - -
- + @@ -139,10 +137,11 @@ export default { .el-dialog__body { height: calc(100% - 120px); } + /* .re-open .el-scrollbar, .re-open .el-scrollbar__view { height: calc(100% - 120px); - } + } */ `, props: ["modelValue", "data", "isBusiness"], emit: ["update:modelValue"], @@ -361,6 +360,9 @@ export default { if (valid) { adjList.value.unshift(adjModel.value); addDialogVisible.value = false; + nextTick(() => { + scrollRef.value.update(); + }); } } catch (error) { console.log(error); @@ -406,6 +408,9 @@ export default { if (!result.errors) { adjList.value = result.data; importDialogVisible.value = false; + nextTick(() => { + scrollRef.value.update(); + }); } } } catch (error) { @@ -431,7 +436,7 @@ export default { console.log(e); } } else { - setupRef += 1; + setupRef.value += 1; } }; const submitReOpen = async () => {};