From 73db2a202a818a2ee5a2376689d9a4027047aa48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E7=A6=8F?= Date: Fri, 1 Nov 2024 21:58:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Pure=20Config=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 400cf6c1..83569d02 100644 --- a/.gitignore +++ b/.gitignore @@ -274,3 +274,6 @@ database_backup /Yi.Abp.Net8/src/Yi.Abp.Web/logs/ /Yi.Abp.Net8/src/Yi.Abp.Web/yi-abp-dev.db +/Yi.RuoYi.Vue3/pnpm-lock.yaml +/.gitignore +/.gitignore From 7a916fc78ed512bf262574df59b1b39e8cf49952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E7=A6=8F?= Date: Fri, 1 Nov 2024 21:59:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Pure=20Config=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 + .../DataSeeds/MenuPureDataSeed.cs | 82 +++++++- Yi.Pure.Vue3/public/platform-config.json | 2 +- Yi.Pure.Vue3/src/api/system/config.ts | 27 +++ Yi.Pure.Vue3/src/views/system/config/form.vue | 67 ++++++ .../src/views/system/config/index.vue | 117 +++++++++++ .../src/views/system/config/utils/hook.tsx | 192 ++++++++++++++++++ .../src/views/system/config/utils/rule.ts | 13 ++ .../src/views/system/config/utils/types.ts | 14 ++ Yi.Pure.Vue3/src/views/system/menu/form.vue | 2 +- 10 files changed, 509 insertions(+), 9 deletions(-) create mode 100644 Yi.Pure.Vue3/src/api/system/config.ts create mode 100644 Yi.Pure.Vue3/src/views/system/config/form.vue create mode 100644 Yi.Pure.Vue3/src/views/system/config/index.vue create mode 100644 Yi.Pure.Vue3/src/views/system/config/utils/hook.tsx create mode 100644 Yi.Pure.Vue3/src/views/system/config/utils/rule.ts create mode 100644 Yi.Pure.Vue3/src/views/system/config/utils/types.ts diff --git a/.gitignore b/.gitignore index 83569d02..fee29282 100644 --- a/.gitignore +++ b/.gitignore @@ -277,3 +277,5 @@ database_backup /Yi.RuoYi.Vue3/pnpm-lock.yaml /.gitignore /.gitignore +/Yi.Abp.Net8/src/Yi.Abp.Web/yi-abp-dev.db111 +/.gitignore diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/MenuPureDataSeed.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/MenuPureDataSeed.cs index 75bd258f..3eaf7d68 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/MenuPureDataSeed.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.SqlSugarCore/DataSeeds/MenuPureDataSeed.cs @@ -19,7 +19,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds public async Task SeedAsync(DataSeedContext context) { - if (!await _repository.IsAnyAsync(x => x.MenuName == "系统管理"&&x.MenuSource==MenuSourceEnum.Pure)) + if (!await _repository.IsAnyAsync(x => x.MenuName == "系统管理" && x.MenuSource == MenuSourceEnum.Pure)) { await _repository.InsertManyAsync(GetSeedData()); } @@ -37,7 +37,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds OrderNum = 100 }; entities.Add(system); - + //系统监控 MenuAggregateRoot monitoring = new MenuAggregateRoot(_guidGenerator.Create()) { @@ -64,7 +64,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds }; entities.Add(online); - + //Yi框架 MenuAggregateRoot guide = new MenuAggregateRoot(_guidGenerator.Create()) { @@ -77,7 +77,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds Component = null }; entities.Add(guide); - + //用户管理 MenuAggregateRoot user = new MenuAggregateRoot(_guidGenerator.Create()) { @@ -141,7 +141,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds entities.Add(userRemove); - MenuAggregateRoot userResetPwd = new MenuAggregateRoot(_guidGenerator.Create()) + MenuAggregateRoot userResetPwd = new MenuAggregateRoot(_guidGenerator.Create()) { MenuName = "重置密码", @@ -408,7 +408,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds IsDeleted = false }; entities.Add(postRemove); - + //操作日志 MenuAggregateRoot operationLog = new MenuAggregateRoot(_guidGenerator.Create()) @@ -491,10 +491,78 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds OrderNum = 100, ParentId = loginLog.Id, IsDeleted = false, - + }; entities.Add(loginLogRemove); + //参数设置 + MenuAggregateRoot config = new MenuAggregateRoot(_guidGenerator.Create()) + { + + MenuName = "参数设置", + PermissionCode = "system:config:list", + MenuType = MenuTypeEnum.Menu, + Router = "config", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "/system/config/index", + MenuIcon = "ri:edit-box-line", + OrderNum = 94, + ParentId = system.Id, + IsDeleted = false + }; + entities.Add(config); + + MenuAggregateRoot configQuery = new MenuAggregateRoot(_guidGenerator.Create()) + { + + MenuName = "参数查询", + PermissionCode = "system:config:query", + MenuType = MenuTypeEnum.Component, + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + entities.Add(configQuery); + + MenuAggregateRoot configAdd = new MenuAggregateRoot(_guidGenerator.Create()) + { + + MenuName = "参数新增", + PermissionCode = "system:config:add", + MenuType = MenuTypeEnum.Component, + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + entities.Add(configAdd); + + MenuAggregateRoot configEdit = new MenuAggregateRoot(_guidGenerator.Create()) + { + + MenuName = "参数修改", + PermissionCode = "system:config:edit", + MenuType = MenuTypeEnum.Component, + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + entities.Add(configEdit); + + MenuAggregateRoot configRemove = new MenuAggregateRoot(_guidGenerator.Create()) + { + + MenuName = "参数删除", + PermissionCode = "system:config:remove", + MenuType = MenuTypeEnum.Component, + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + entities.Add(configRemove); + + //默认值 entities.ForEach(m => { diff --git a/Yi.Pure.Vue3/public/platform-config.json b/Yi.Pure.Vue3/public/platform-config.json index 085249b1..9ec42266 100644 --- a/Yi.Pure.Vue3/public/platform-config.json +++ b/Yi.Pure.Vue3/public/platform-config.json @@ -1,6 +1,6 @@ { "Version": "5.8.0", - "Title": "Yi-PureAdmin", + "Title": "智泊云科技管理系统", "FixedHeader": true, "HiddenSideBar": false, "MultiTagsCache": false, diff --git a/Yi.Pure.Vue3/src/api/system/config.ts b/Yi.Pure.Vue3/src/api/system/config.ts new file mode 100644 index 00000000..65c0597d --- /dev/null +++ b/Yi.Pure.Vue3/src/api/system/config.ts @@ -0,0 +1,27 @@ +import { http } from "@/utils/http"; +import type { Result, ResultPage } from "@/api/result"; + +/** 获取系统管理-参数配置列表 */ +export const getConfigList = (data?: object) => { + return http.request("get", "/config", { data }); +}; + +/** 查询参数详细 */ +export const getConfig = id => { + return http.request("get", `/config/${id}`, {}); +}; + +/** 新增参数 */ +export const addConfig = data => { + return http.request("post", `/config`, { data }); +}; + +/** 修改参数 */ +export const updateConfig = (id, data) => { + return http.request("put", `/config/${id}`, { data }); +}; + +/** 删除参数 */ +export const delConfig = id => { + return http.request("delete", `/config`, { params: { id } }); +}; diff --git a/Yi.Pure.Vue3/src/views/system/config/form.vue b/Yi.Pure.Vue3/src/views/system/config/form.vue new file mode 100644 index 00000000..7ffe926d --- /dev/null +++ b/Yi.Pure.Vue3/src/views/system/config/form.vue @@ -0,0 +1,67 @@ + + + diff --git a/Yi.Pure.Vue3/src/views/system/config/index.vue b/Yi.Pure.Vue3/src/views/system/config/index.vue new file mode 100644 index 00000000..d5aa3898 --- /dev/null +++ b/Yi.Pure.Vue3/src/views/system/config/index.vue @@ -0,0 +1,117 @@ + + + + + diff --git a/Yi.Pure.Vue3/src/views/system/config/utils/hook.tsx b/Yi.Pure.Vue3/src/views/system/config/utils/hook.tsx new file mode 100644 index 00000000..817ee937 --- /dev/null +++ b/Yi.Pure.Vue3/src/views/system/config/utils/hook.tsx @@ -0,0 +1,192 @@ +import editForm from "../form.vue"; +import { handleTree } from "@/utils/tree"; +import { message } from "@/utils/message"; +import { usePublicHooks } from "../../hooks"; +import { addDialog } from "@/components/ReDialog"; +import { reactive, ref, onMounted, h, toRaw } from "vue"; +import type { FormItemProps } from "../utils/types"; +import type { PaginationProps } from "@pureadmin/table"; +import { cloneDeep, isAllEmpty, deviceDetection } from "@pureadmin/utils"; +import { addConfig, delConfig, getConfig, getConfigList, updateConfig } from "@/api/system/config"; +import { getPlatformConfig } from "@/config/index"; + +export function useConfig() { + const form = reactive({ + configName: "", + configKey:"", + configType:"", + }); + + const pagination = reactive({ + total: 0, + pageSize: 10, + currentPage: 1, + background: true + }); + + /** 高亮当前权限选中行 */ + function rowStyle({ row: { id } }) { + return { + cursor: "pointer", + background: id === curRow.value?.id ? "var(--el-fill-color-light)" : "" + }; + } + + const curRow = ref(); + const formRef = ref(); + const dataList = ref([]); + const loading = ref(true); + const { tagStyle } = usePublicHooks(); + + const columns: TableColumnList = [ + { + label: "参数主键", + prop: "id", + width: 180, + align: "left" + }, + { + label: "参数名称", + prop: "configName", + width: 180, + align: "left" + }, + { + label: "参数键名", + prop: "configKey", + width: 180, + align: "left" + }, + { + label: "参数键值", + prop: "configValue", + width: 180, + align: "left" + }, + { + label: "系统内置", + prop: "configType", + width: 180, + align: "left" + }, + { + label: "备注", + prop: "remark", + minWidth: 120, + align: "left" + }, + { + label: "创建时间", + prop: "creationTime", + width: 180, + align: "left" + }, + { + label: "操作", + fixed: "right", + width: 210, + slot: "operation" + } + ]; + + function handleSelectionChange(val) { + console.log("handleSelectionChange", val); + } + + function resetForm(formEl) { + if (!formEl) return; + formEl.resetFields(); + onSearch(); + } + + async function onSearch() { + loading.value = true; + const { data } = await getConfigList(toRaw(form)); + dataList.value = data.items; + pagination.total = data.totalCount; + loading.value = false; + } + + + async function openDialog(title = "新增", row?: FormItemProps) { + let data: any = null; + if (title == "修改") { + const response = await getConfig(row?.id); + data = response.data; + } + addDialog({ + title: `${title}参数`, + props: { + formInline: { + configName:data?.configName?? "", + configKey:data?.configKey?? "", + configValue:data?.configValue?? "", + configTYpe:data?.configType?? "", + remark:data?.remark?? "", + } + }, + width: "40%", + draggable: true, + fullscreen: deviceDetection(), + fullscreenIcon: true, + closeOnClickModal: false, + contentRenderer: () => h(editForm, { ref: formRef }), + beforeSure: (done, { options }) => { + const FormRef = formRef.value.getRef(); + const curData = options.props.formInline as FormItemProps; + function chores() { + message(`您 ${title} 了参数名称为 ${curData.configName} 的这条数据`, { + type: "success" + }); + done(); // 关闭弹框 + onSearch(); // 刷新表格数据 + } + FormRef.validate(async valid => { + if (valid) { + // 表单规则校验通过 + if (title === "新增") { + // 实际开发先调用新增接口,再进行下面操作 + console.log('新增参数'); + await addConfig(curData); + chores(); + } else { + // 实际开发先调用修改接口,再进行下面操作 + curData.id = row.id + curData.creationTime = row.creationTime + await updateConfig(row.id, curData); + chores(); + } + } + }); + } + }); + } + + async function handleDelete(row) { + await delConfig([row.id]); + message(`您删除了参数名称为 ${row.configName} 的这条数据`, { type: "success" }); + onSearch(); + } + + onMounted(() => { + onSearch(); + }); + + return { + form, + loading, + columns, + dataList, + /** 搜索 */ + onSearch, + /** 重置 */ + resetForm, + /** 新增、修改部门 */ + openDialog, + /** 删除部门 */ + handleDelete, + pagination, + handleSelectionChange, + rowStyle + }; +} diff --git a/Yi.Pure.Vue3/src/views/system/config/utils/rule.ts b/Yi.Pure.Vue3/src/views/system/config/utils/rule.ts new file mode 100644 index 00000000..a8d4a13a --- /dev/null +++ b/Yi.Pure.Vue3/src/views/system/config/utils/rule.ts @@ -0,0 +1,13 @@ +import { reactive } from "vue"; +import type { FormRules } from "element-plus"; + +/** 自定义表单规则校验 */ +export const formRules = reactive({ + configName: [ + { required: true, message: "参数名称为必填项", trigger: "blur" } + ], + configKey: [{ required: true, message: "参数键名为必填项", trigger: "blur" }], + configValue: [ + { required: true, message: "参数键值为必填项", trigger: "blur" } + ] +}); diff --git a/Yi.Pure.Vue3/src/views/system/config/utils/types.ts b/Yi.Pure.Vue3/src/views/system/config/utils/types.ts new file mode 100644 index 00000000..ebc7a3ac --- /dev/null +++ b/Yi.Pure.Vue3/src/views/system/config/utils/types.ts @@ -0,0 +1,14 @@ +interface FormItemProps { + id: string; + configName: string; + configValue: string; + configKey: string; + configType: string; + remark: string; + creationTime:string; +} +interface FormProps { + formInline: FormItemProps; +} + +export type { FormItemProps, FormProps }; diff --git a/Yi.Pure.Vue3/src/views/system/menu/form.vue b/Yi.Pure.Vue3/src/views/system/menu/form.vue index cad2f4f3..f472485c 100644 --- a/Yi.Pure.Vue3/src/views/system/menu/form.vue +++ b/Yi.Pure.Vue3/src/views/system/menu/form.vue @@ -108,7 +108,7 @@ defineExpose({ getRef });