feat: 合并pure pr

This commit is contained in:
橙子
2024-11-02 16:17:48 +08:00
8 changed files with 506 additions and 8 deletions

View File

@@ -19,7 +19,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
public async Task SeedAsync(DataSeedContext context) 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()); await _repository.InsertManyAsync(GetSeedData());
} }
@@ -37,7 +37,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
OrderNum = 100 OrderNum = 100
}; };
entities.Add(system); entities.Add(system);
//系统监控 //系统监控
MenuAggregateRoot monitoring = new MenuAggregateRoot(_guidGenerator.Create()) MenuAggregateRoot monitoring = new MenuAggregateRoot(_guidGenerator.Create())
{ {
@@ -64,7 +64,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
}; };
entities.Add(online); entities.Add(online);
//Yi框架 //Yi框架
MenuAggregateRoot guide = new MenuAggregateRoot(_guidGenerator.Create()) MenuAggregateRoot guide = new MenuAggregateRoot(_guidGenerator.Create())
{ {
@@ -77,7 +77,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
Component = null Component = null
}; };
entities.Add(guide); entities.Add(guide);
//用户管理 //用户管理
MenuAggregateRoot user = new MenuAggregateRoot(_guidGenerator.Create()) MenuAggregateRoot user = new MenuAggregateRoot(_guidGenerator.Create())
{ {
@@ -141,7 +141,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
entities.Add(userRemove); entities.Add(userRemove);
MenuAggregateRoot userResetPwd = new MenuAggregateRoot(_guidGenerator.Create()) MenuAggregateRoot userResetPwd = new MenuAggregateRoot(_guidGenerator.Create())
{ {
MenuName = "重置密码", MenuName = "重置密码",
@@ -408,7 +408,7 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
IsDeleted = false IsDeleted = false
}; };
entities.Add(postRemove); entities.Add(postRemove);
//操作日志 //操作日志
MenuAggregateRoot operationLog = new MenuAggregateRoot(_guidGenerator.Create()) MenuAggregateRoot operationLog = new MenuAggregateRoot(_guidGenerator.Create())
@@ -491,10 +491,78 @@ namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
OrderNum = 100, OrderNum = 100,
ParentId = loginLog.Id, ParentId = loginLog.Id,
IsDeleted = false, IsDeleted = false,
}; };
entities.Add(loginLogRemove); 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 => entities.ForEach(m =>
{ {

View File

@@ -0,0 +1,27 @@
import { http } from "@/utils/http";
import type { Result, ResultPage } from "@/api/result";
/** 获取系统管理-参数配置列表 */
export const getConfigList = (data?: object) => {
return http.request<ResultPage>("get", "/config", { data });
};
/** 查询参数详细 */
export const getConfig = id => {
return http.request<Result>("get", `/config/${id}`, {});
};
/** 新增参数 */
export const addConfig = data => {
return http.request<Result>("post", `/config`, { data });
};
/** 修改参数 */
export const updateConfig = (id, data) => {
return http.request<Result>("put", `/config/${id}`, { data });
};
/** 删除参数 */
export const delConfig = id => {
return http.request<Result>("delete", `/config`, { params: { id } });
};

View File

@@ -0,0 +1,67 @@
<script setup lang="ts">
import { ref } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";
import { usePublicHooks } from "../hooks";
const props = withDefaults(defineProps<FormProps>(), {
formInline: () => ({
id: "",
configName: "",
configValue: "",
configKey: "",
configType: "",
remark: ""
})
});
const ruleFormRef = ref();
const { switchStyle } = usePublicHooks();
const newFormInline = ref(props.formInline);
function getRef() {
return ruleFormRef.value;
}
defineExpose({ getRef });
</script>
<template>
<el-form
ref="ruleFormRef"
:model="newFormInline"
:rules="formRules"
label-width="82px">
<el-row :gutter="30">
<re-col :value="12" :xs="24" :sm="24">
<el-form-item label="参数名称" prop="configName">
<el-input v-model="newFormInline.configName" clearable placeholder="请输入参数名称" />
</el-form-item>
</re-col>
<re-col :value="12" :xs="24" :sm="24">
<el-form-item label="参数键名" prop="configKey">
<el-input v-model="newFormInline.configKey" clearable placeholder="请输入参数键名" />
</el-form-item>
</re-col>
<re-col :value="12" :xs="24" :sm="24">
<el-form-item label="参数键值" prop="configValue">
<el-input v-model="newFormInline.configValue" clearable placeholder="请输入参数键值" />
</el-form-item>
</re-col>
<re-col :value="12" :xs="24" :sm="24">
<el-form-item label="系统内置">
<el-switch v-model="newFormInline.configType" inline-prompt :active-value="true" :inactive-value="false"
active-text="" inactive-text="" :style="switchStyle" />
</el-form-item>
</re-col>
<re-col>
<el-form-item label="备注" prop="remark">
<el-input v-model="newFormInline.remark" placeholder="请输入备注信息" type="textarea" />
</el-form-item>
</re-col>
</el-row>
</el-form>
</template>

View File

@@ -0,0 +1,117 @@
<script setup lang="ts">
import { ref } from "vue";
import { useConfig } from "./utils/hook";
import { PureTableBar } from "@/components/RePureTableBar";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import Delete from "@iconify-icons/ep/delete";
import EditPen from "@iconify-icons/ep/edit-pen";
import Refresh from "@iconify-icons/ep/refresh";
import AddFill from "@iconify-icons/ri/add-circle-line";
defineOptions({
name: "SystemConfig"
});
const formRef = ref();
const tableRef = ref();
const {
form,
loading,
columns,
dataList,
onSearch,
resetForm,
openDialog,
handleDelete,
pagination,
rowStyle,
handleSelectionChange
} = useConfig();
</script>
<template>
<div class="main">
<el-form ref="formRef" :inline="true"
:model="form"
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
<el-form-item label="参数名称:" prop="name">
<el-input v-model="form.configName" placeholder="请输入参数名称" clearable class="!w-[180px]" />
</el-form-item>
<el-form-item label="参数键名:" prop="key">
<el-input v-model="form.configKey" placeholder="请输入参数名称" clearable class="!w-[180px]" />
</el-form-item>
<el-form-item label="是否内置:" prop="state">
<el-select v-model="form.configType" placeholder="" clearable class="!w-[180px]">
<el-option label="是" :value="true" />
<el-option label="否" :value="false" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="useRenderIcon('ri:search-line')" :loading="loading" @click="onSearch">
搜索
</el-button>
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
重置
</el-button>
</el-form-item>
</el-form>
<PureTableBar title="参数设置" :columns="columns" :tableRef="tableRef?.getTableRef()" @refresh="onSearch" >
<template #buttons>
<el-button type="primary" :icon="useRenderIcon(AddFill)" @click="openDialog()">
新增参数
</el-button>
</template>
<template v-slot="{ size, dynamicColumns }">
<pure-table
ref="tableRef"
row-key="id"
align-whole="center"
table-layout="auto"
:loading="loading"
:size="size"
adaptive
:adaptiveConfig="{ offsetBottom: 108 }"
:data="dataList"
:columns="dynamicColumns"
:pagination="{ ...pagination, size }"
:header-cell-style="{
background: 'var(--el-fill-color-light)',
color: 'var(--el-text-color-primary)'
}"
@selection-change="handleSelectionChange">
<template #operation="{ row }">
<el-button class="reset-margin" link type="primary" :size="size" :icon="useRenderIcon(EditPen)"
@click="openDialog('修改', row)">
修改
</el-button>
<el-popconfirm :title="`是否确认删除 ? 参数: ${row.configName}`" @confirm="handleDelete(row)">
<template #reference>
<el-button class="reset-margin" link type="primary" :size="size" :icon="useRenderIcon(Delete)">
删除
</el-button>
</template>
</el-popconfirm>
</template>
</pure-table>
</template>
</PureTableBar>
</div>
</template>
<style lang="scss" scoped>
:deep(.el-dropdown-menu__item i) {
margin: 0;
}
.main-content {
margin: 24px 24px 0 !important;
}
.search-form {
:deep(.el-form-item) {
margin-bottom: 12px;
}
}
</style>

View File

@@ -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<PaginationProps>({
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
};
}

View File

@@ -0,0 +1,13 @@
import { reactive } from "vue";
import type { FormRules } from "element-plus";
/** 自定义表单规则校验 */
export const formRules = reactive(<FormRules>{
configName: [
{ required: true, message: "参数名称为必填项", trigger: "blur" }
],
configKey: [{ required: true, message: "参数键名为必填项", trigger: "blur" }],
configValue: [
{ required: true, message: "参数键值为必填项", trigger: "blur" }
]
});

View File

@@ -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 };

View File

@@ -108,7 +108,7 @@ defineExpose({ getRef });
<el-input <el-input
v-model="newFormInline.routerName" v-model="newFormInline.routerName"
clearable clearable
placeholder="请输入菜单名称" placeholder="请输入路由名称"
class="w-full" class="w-full"
/> />
</el-form-item> </el-form-item>