This commit is contained in:
六如
2024-10-20 23:28:17 +08:00
parent 0cbadbeda8
commit c84a05b522
36 changed files with 985 additions and 164 deletions

View File

@@ -35,6 +35,14 @@ const apiRouters = [
title: "ISV列表",
roles: ["admin"]
}
},
{
path: "/isv/perm/permGroup",
name: "PermGroup",
meta: {
title: "分组管理",
roles: ["admin"]
}
}
]
},

View File

@@ -17,7 +17,7 @@
"Stretch": false,
"SidebarStatus": true,
"EpThemeColor": "#409EFF",
"ShowLogo": true,
"ShowLogo": false,
"ShowModel": "smart",
"MenuArrowIconNoTransition": false,
"CachingAsyncRoutes": false,

View File

@@ -10,7 +10,9 @@ const apiUrl: any = createUrl({
getKeys: "/isv/getKeys",
updateStatus: "/isv/updateStatus",
createKeys: "/isv/createKeys",
updateKeys: "/isv/updateKeys"
updateKeys: "/isv/updateKeys",
listGroup: "perm/isv/group/listIsvCode",
updateGroup: "perm/isv/group/setting"
});
/*
@@ -84,5 +86,30 @@ export const api: any = {
*/
updateKeys(data: object): Promise<Result<KeyStore>> {
return http.post<Result<any>, any>(apiUrl.updateKeys, { data });
},
/**
* 修改秘钥
* @param data 表单内容
*/
listGroup(isvId: Number): Promise<Result<string>> {
const data = {
isvId: isvId
};
return http.get<Result<string>, any>(apiUrl.listGroup, { params: data });
},
/**
* 设置分组
* @param isvId isvId
* @param groupCodes groupCodes
*/
updateGroup(
isvId: Number,
groupCodes: Array<string>
): Promise<Result<KeyStore>> {
const data = {
isvId: isvId,
groupCodeList: groupCodes
};
return http.post<Result<any>, any>(apiUrl.updateGroup, { data });
}
};

View File

@@ -0,0 +1,51 @@
import { createUrl, http } from "@/utils/http";
import type { PageResult, Result } from "@/model";
// 后端请求接口
const apiUrl: any = createUrl({
page: "/perm/group/page",
add: "/perm/group/add",
update: "/perm/group/update",
del: "/perm/group/delete",
listAll: "/perm/group/listAll"
});
/**
* 接口管理
*/
export const api: any = {
/**
* 分页查询
* @param params 查询参数
*/
page(params: object): Promise<PageResult> {
return http.get<PageResult, any>(apiUrl.page, { params });
},
/**
* 查询全部
*/
listAll(): Promise<Result<any>> {
return http.get<Result<any>, any>(apiUrl.listAll, {});
},
/**
* 新增
* @param data 表单内容
*/
add(data: object) {
return http.post<Result<any>, any>(apiUrl.add, { data });
},
/**
* 修改
* @param data 表单内容
*/
update(data: object) {
return http.post<Result<any>, any>(apiUrl.update, { data });
},
/**
* 删除
* @param data 表单内容
*/
del(data: object) {
return http.post<Result<any>, any>(apiUrl.del, { data });
}
};

View File

@@ -10,6 +10,7 @@ import { ElMessage } from "element-plus";
import { KeyFormatEnum, StatusEnum } from "@/model/enums";
import { api } from "@/api/isvList";
import { settingKeys } from "@/views/isv/list/isvKeys";
import { settingGroup } from "@/views/isv/list/isvGroup";
const isAdd = ref(false);
@@ -73,9 +74,12 @@ export const tableColumns: PlusColumn[] = [
width: 80
},
{
label: "角色",
prop: "roleNames",
width: 200
label: "所属分组",
prop: "groupNames",
width: 200,
tableColumnProps: {
showOverflowTooltip: true
}
},
{
label: "状态",
@@ -97,7 +101,10 @@ export const tableColumns: PlusColumn[] = [
},
{
label: "备注",
prop: "remark"
prop: "remark",
tableColumnProps: {
showOverflowTooltip: true
}
},
{
label: "添加时间",
@@ -136,6 +143,16 @@ actionButtons.value = [
settingKeys(params.row);
}
},
{
text: "设置分组",
code: "edit",
props: {
type: "primary"
},
onClick(params: ButtonsCallBackParams) {
settingGroup(params.row);
}
},
{
// 启用/禁用
text: row => (row.status === StatusEnum.ENABLE ? "禁用" : "启用"),
@@ -195,29 +212,6 @@ export const editFormColumns: PlusColumn[] = [
placeholder: "自动生成"
}
},
// {
// label: "秘钥格式",
// prop: "keyFormat",
// valueType: "radio",
// options: [
// {
// label: "PKCS8(Java适用)",
// value: KeyFormatEnum.PKCS8
// },
// {
// label: "PKCS1(非Java适用)",
// value: KeyFormatEnum.PKCS1
// }
// ]
// },
// {
// label: "角色",
// prop: "roleCodes",
// valueType: "checkbox",
// // options推荐写法
// // 3. 用 computed 返回 ref 的 value
// options: computed(() => roleList.value)
// },
{
label: "状态",
prop: "status",

View File

@@ -34,6 +34,12 @@ import {
settingKeysFormData,
settingKeysFormRules
} from "@/views/isv/list/isvKeys";
import {
dlgGroupSetting,
groupColumns,
handleUpdateGroup,
settingGroupFormData
} from "@/views/isv/list/isvGroup";
</script>
<template>
<el-card shadow="never">
@@ -50,7 +56,7 @@ import {
<PlusTable
:columns="tableColumns"
:table-data="tableData"
:action-bar="{ buttons: actionButtons, width: 190 }"
:action-bar="{ buttons: actionButtons, width: 230, showNumber: 4 }"
:pagination="{
total,
modelValue: pageInfo,
@@ -129,5 +135,17 @@ import {
</el-button>
</template>
</PlusDialogForm>
<!-- 设置分组 -->
<PlusDialogForm
v-model:visible="dlgGroupSetting"
v-model="settingGroupFormData"
:dialog="{ title: '设置分组' }"
:form="{
columns: groupColumns,
labelPosition: 'top'
}"
:hasErrorTip="false"
@confirm="handleUpdateGroup"
/>
</el-card>
</template>

View File

@@ -1,12 +1,71 @@
// options推荐写法
// 1. 定义一个 `ref`数组
import { type Ref, ref } from "vue";
import { type OptionsRow } from "plus-pro-components";
import { computed, type Ref, ref } from "vue";
import { type OptionsRow, type PlusColumn } from "plus-pro-components";
import { api } from "@/api/isvList";
import { api as groupApi } from "@/api/permGroup";
import { ElMessage } from "element-plus";
import { search } from "@/views/isv/list/index";
// 弹窗显示
export const dlgGroupSetting = ref(false);
export const settingGroupFormData = ref<any>({
isvId: 0,
groupCodeList: []
});
const groupList: Ref<OptionsRow[]> = ref([]);
// 2. 异步函数获取到值赋值到 `ref`
const loadGroup = async () => {
//
console.log(groupList);
const loadGroup = () => {
groupApi.listAll().then(resp => {
const rows = resp.data;
/*
options.value = [
{ label: '未解决', value: '0', color: 'red' },
{ label: '已解决', value: '1', color: 'blue' }
]
*/
groupList.value = rows.map(row => {
return {
label: row.groupName,
value: row.groupCode
};
});
});
};
loadGroup();
export const groupColumns: PlusColumn[] = [
{
label: "分组",
width: 120,
prop: "groupCodeList",
valueType: "checkbox",
// options推荐写法
// 3. 用 computed 返回 ref 的 value
options: computed(() => groupList.value)
}
];
export const settingGroup = (row: any) => {
api.listGroup(row.id).then(resp => {
settingGroupFormData.value = {
isvId: row.id,
groupCodeList: resp.data
};
dlgGroupSetting.value = true;
});
};
export const handleUpdateGroup = () => {
const data = settingGroupFormData.value;
api.updateGroup(data.isvId, data.groupCodeList).then(() => {
ElMessage({
message: "保存成功",
type: "success"
});
dlgGroupSetting.value = false;
search();
});
};

View File

@@ -0,0 +1,196 @@
import { computed, ref } from "vue";
import {
type ButtonsCallBackParams,
type PageInfo,
type PlusColumn,
useTable
} from "plus-pro-components";
import { ElMessage } from "element-plus";
import { api } from "@/api/permGroup";
const isAdd = ref(false);
// ========= search form =========
// 查询表单对象
export const searchFormData = ref({
groupCode: "",
groupName: "",
pageIndex: 1,
pageSize: 10
});
// 查询表单字段定义
export const searchFormColumns: PlusColumn[] = [
{
label: "分组代码",
prop: "groupCode"
},
{
label: "角色描述",
prop: "groupName"
}
];
// ========= table =========
// 表格对象
export const {
tableData,
total,
pageInfo,
buttons: actionButtons
} = useTable<any[]>();
// 默认每页条数,默认10
pageInfo.value.pageSize = 10;
// 表格字段定义
export const tableColumns: PlusColumn[] = [
{
label: "分组代码",
prop: "groupCode"
},
{
label: "角色描述",
prop: "groupName"
},
{
width: 160,
label: "添加时间",
prop: "addTime"
},
{
width: 160,
label: "修改时间",
prop: "updateTime"
}
];
// 表格按钮定义
actionButtons.value = [
{
// 修改
text: "修改",
code: "edit",
props: {
type: "primary"
},
show: computed(() => true),
onClick(params: ButtonsCallBackParams) {
isAdd.value = false;
editFormData.value = Object.assign({}, params.row);
dlgTitle.value = "修改";
dlgShow.value = true;
}
},
{
// 删除
text: "删除",
code: "delete",
props: {
type: "danger"
},
confirm: {
options: { draggable: false }
},
onConfirm(params: ButtonsCallBackParams) {
api.del(params).then(() => {
ElMessage({
message: "删除成功",
type: "success"
});
dlgShow.value = false;
search();
});
}
}
];
// ========= dialog form =========
// 弹窗显示
export const dlgShow = ref(false);
export const dlgTitle = ref("");
// 表单值
const editFormDataGen = () => {
return {
groupCode: "",
groupName: ""
};
};
export const editFormData = ref<any>(editFormDataGen());
export const editFormRules = {
groupCode: [{ required: true, message: "请输入角色代码" }],
groupName: [{ required: true, message: "请输入角色描述" }]
};
// 表单内容
export const editFormColumns: PlusColumn[] = [
{
label: "分组代码",
prop: "groupCode",
valueType: "input"
},
{
label: "角色描述",
prop: "groupName",
valueType: "input"
}
];
// ========= event =========
// 添加按钮事件
export const handleAdd = () => {
isAdd.value = true;
editFormData.value = editFormDataGen();
dlgTitle.value = "新增";
dlgShow.value = true;
};
// 保存按钮事件,校验成功后触发
export const handleSave = () => {
const postData = editFormData.value;
const pms = isAdd.value ? api.add(postData) : api.update(postData);
pms.then(() => {
ElMessage({
message: "保存成功",
type: "success"
});
dlgShow.value = false;
search();
});
};
// 点击查询按钮
export const handleSearch = () => {
pageInfo.value.page = 1;
search();
};
// 分页事件
export const handlePaginationChange = (_pageInfo: PageInfo): void => {
pageInfo.value = _pageInfo;
search();
};
// 查询
const search = async () => {
try {
const { data } = await doSearch();
tableData.value = data.list;
total.value = data.total;
} catch (error) {}
};
// 请求接口
const doSearch = async () => {
// 查询参数
const data = searchFormData.value;
// 添加分页参数
data.pageIndex = pageInfo.value.page;
data.pageSize = pageInfo.value.pageSize;
return api.page(data);
};
// 页面加载
search();

View File

@@ -0,0 +1,64 @@
<script setup lang="ts">
import {
actionButtons,
dlgShow,
dlgTitle,
editFormColumns,
editFormData,
editFormRules,
handleAdd,
handlePaginationChange,
handleSave,
handleSearch,
pageInfo,
searchFormColumns,
searchFormData,
tableColumns,
tableData,
total
} from "./permGroup";
</script>
<template>
<el-card shadow="never">
<template #header>
<PlusSearch
v-model="searchFormData"
:columns="searchFormColumns"
:show-number="2"
label-position="right"
:has-reset="false"
@search="handleSearch"
/>
</template>
<PlusTable
:columns="tableColumns"
:table-data="tableData"
:action-bar="{ buttons: actionButtons, width: 120 }"
:pagination="{
total,
modelValue: pageInfo,
pageSizeList: [10, 20, 50, 100],
align: 'right'
}"
adaptive
@paginationChange="handlePaginationChange"
>
<template #title>
<el-button type="primary" @click="handleAdd">新增</el-button>
</template>
</PlusTable>
<PlusDialogForm
v-model:visible="dlgShow"
v-model="editFormData"
:dialog="{ title: dlgTitle }"
:form="{
columns: editFormColumns,
rules: editFormRules,
labelWidth: '100px',
labelPosition: 'right'
}"
:hasErrorTip="false"
@confirm="handleSave"
/>
</el-card>
</template>