mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -1,306 +0,0 @@
|
||||
import { computed, ref } from "vue";
|
||||
import {
|
||||
type ButtonsCallBackParams,
|
||||
type FieldValues,
|
||||
type PageInfo,
|
||||
type PlusColumn,
|
||||
useTable
|
||||
} from "plus-pro-components";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { api } from "@/api/sysAdminUser";
|
||||
|
||||
const isAdd = ref(false);
|
||||
|
||||
// ========= search form =========
|
||||
|
||||
// 查询表单对象
|
||||
export const searchFormData = ref({
|
||||
id: "",
|
||||
username: "",
|
||||
password: "",
|
||||
nickname: "",
|
||||
email: "",
|
||||
avatar: "",
|
||||
status: "",
|
||||
regType: "",
|
||||
addTime: "",
|
||||
updateTime: "",
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
|
||||
// 查询表单字段定义
|
||||
export const searchFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "用户名",
|
||||
prop: "username"
|
||||
},
|
||||
{
|
||||
label: "密码",
|
||||
prop: "password"
|
||||
},
|
||||
{
|
||||
label: "用户名",
|
||||
prop: "nickname"
|
||||
},
|
||||
{
|
||||
label: "邮箱",
|
||||
prop: "email"
|
||||
},
|
||||
{
|
||||
label: "头像",
|
||||
prop: "avatar"
|
||||
},
|
||||
{
|
||||
label: "状态,1:启用,2:禁用",
|
||||
prop: "status"
|
||||
},
|
||||
{
|
||||
label: "注册类型",
|
||||
prop: "regType"
|
||||
},
|
||||
{
|
||||
label: "addTime",
|
||||
prop: "addTime"
|
||||
},
|
||||
{
|
||||
label: "updateTime",
|
||||
prop: "updateTime"
|
||||
}
|
||||
];
|
||||
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
export const {
|
||||
tableData,
|
||||
total,
|
||||
pageInfo,
|
||||
buttons: actionButtons
|
||||
} = useTable<any[]>();
|
||||
// 默认每页条数,默认10
|
||||
pageInfo.value.pageSize = 10;
|
||||
|
||||
// 表格字段定义
|
||||
export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "用户名",
|
||||
prop: "username"
|
||||
},
|
||||
{
|
||||
label: "密码",
|
||||
prop: "password"
|
||||
},
|
||||
{
|
||||
label: "用户名",
|
||||
prop: "nickname"
|
||||
},
|
||||
{
|
||||
label: "邮箱",
|
||||
prop: "email"
|
||||
},
|
||||
{
|
||||
label: "头像",
|
||||
prop: "avatar"
|
||||
},
|
||||
{
|
||||
label: "状态,1:启用,2:禁用",
|
||||
prop: "status"
|
||||
},
|
||||
{
|
||||
label: "注册类型",
|
||||
prop: "regType"
|
||||
},
|
||||
{
|
||||
label: "addTime",
|
||||
prop: "addTime"
|
||||
},
|
||||
{
|
||||
label: "updateTime",
|
||||
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 {
|
||||
username: "",
|
||||
password: "",
|
||||
nickname: "",
|
||||
email: "",
|
||||
avatar: "",
|
||||
status: "",
|
||||
regType: "",
|
||||
addTime: "",
|
||||
updateTime: ""
|
||||
};
|
||||
};
|
||||
export const editFormData = ref<FieldValues>(editFormDataGen());
|
||||
export const editFormRules = {
|
||||
id: [{ required: true, message: "请输入id" }],
|
||||
username: [{ required: true, message: "请输入用户名" }],
|
||||
password: [{ required: true, message: "请输入密码" }],
|
||||
nickname: [{ required: true, message: "请输入用户名" }],
|
||||
email: [{ required: true, message: "请输入邮箱" }],
|
||||
avatar: [{ required: true, message: "请输入头像" }],
|
||||
status: [{ required: true, message: "请输入状态,1:启用,2:禁用" }],
|
||||
regType: [{ required: true, message: "请输入注册类型" }],
|
||||
addTime: [{ required: true, message: "请输入addTime" }],
|
||||
updateTime: [{ required: true, message: "请输入updateTime" }]
|
||||
};
|
||||
|
||||
// 表单内容
|
||||
export const editFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "id",
|
||||
prop: "id",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "用户名",
|
||||
prop: "username",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "密码",
|
||||
prop: "password",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "用户名",
|
||||
prop: "nickname",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "邮箱",
|
||||
prop: "email",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "头像",
|
||||
prop: "avatar",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "状态,1:启用,2:禁用",
|
||||
prop: "status",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "注册类型",
|
||||
prop: "regType",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "addTime",
|
||||
prop: "addTime",
|
||||
valueType: "copy"
|
||||
},
|
||||
{
|
||||
label: "updateTime",
|
||||
prop: "updateTime",
|
||||
valueType: "copy"
|
||||
}
|
||||
];
|
||||
|
||||
// ========= 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();
|
@@ -1,63 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
actionButtons,
|
||||
dlgShow,
|
||||
dlgTitle,
|
||||
editFormColumns,
|
||||
editFormData,
|
||||
editFormRules,
|
||||
handleAdd,
|
||||
handlePaginationChange,
|
||||
handleSave,
|
||||
handleSearch,
|
||||
pageInfo,
|
||||
searchFormColumns,
|
||||
searchFormData,
|
||||
tableColumns,
|
||||
tableData,
|
||||
total
|
||||
} from "./index";
|
||||
</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'
|
||||
}"
|
||||
@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>
|
@@ -66,10 +66,7 @@ export function useDocList() {
|
||||
},
|
||||
{
|
||||
label: "描述",
|
||||
prop: "description",
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
prop: "description"
|
||||
},
|
||||
{
|
||||
label: "发布状态",
|
||||
@@ -98,12 +95,22 @@ export function useDocList() {
|
||||
}
|
||||
},
|
||||
{
|
||||
width: 160,
|
||||
width: 100,
|
||||
label: "添加人",
|
||||
prop: "addBy.showName"
|
||||
},
|
||||
{
|
||||
width: 100,
|
||||
label: "修改人",
|
||||
prop: "updateBy.showName"
|
||||
},
|
||||
{
|
||||
width: 120,
|
||||
label: "添加时间",
|
||||
prop: "addTime"
|
||||
},
|
||||
{
|
||||
width: 160,
|
||||
width: 120,
|
||||
label: "修改时间",
|
||||
prop: "updateTime"
|
||||
}
|
||||
|
@@ -46,6 +46,7 @@ const {
|
||||
v-show="tabsData.length > 0"
|
||||
:columns="tableColumns"
|
||||
:table-data="tableRows"
|
||||
showOverflowTooltip
|
||||
:action-bar="{
|
||||
buttons: actionButtons,
|
||||
confirmType: 'popconfirm',
|
||||
|
@@ -1,53 +1,59 @@
|
||||
import { ref } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import type { PlusColumn, FieldValues } from "plus-pro-components";
|
||||
import { api } from "@/api/docSetting";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
export const state = ref<FieldValues>({
|
||||
tornaServerAddr: "",
|
||||
openProdUrl: "",
|
||||
openSandboxUrl: ""
|
||||
});
|
||||
|
||||
export const rules = {};
|
||||
|
||||
export const columns: PlusColumn[] = [
|
||||
{
|
||||
label: "Torna地址",
|
||||
prop: "tornaServerAddr",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
placeholder: "Torna地址,到端口号,如:https://torna.xxx.com:7700"
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "开放平台线上环境地址",
|
||||
prop: "openProdUrl",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
placeholder: "开放平台线上环境地址,如:https://open.xxx.com/api"
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "开放平台沙箱环境地址",
|
||||
prop: "openSandboxUrl",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
placeholder: "开放平台沙箱环境地址, 如:https://open-sandbox.xxx.com/api"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export const handleSubmit = (values: FieldValues) => {
|
||||
api.save(values).then(() => {
|
||||
ElMessage.success("保存成功");
|
||||
export function useDocSetting() {
|
||||
const state = ref<FieldValues>({
|
||||
tornaServerAddr: "",
|
||||
openProdUrl: "",
|
||||
openSandboxUrl: ""
|
||||
});
|
||||
};
|
||||
|
||||
const loadSetting = () => {
|
||||
api.get().then(resp => {
|
||||
state.value = resp.data;
|
||||
const rules = {};
|
||||
|
||||
const columns: PlusColumn[] = [
|
||||
{
|
||||
label: "Torna地址",
|
||||
prop: "tornaServerAddr",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
placeholder: "Torna地址,到端口号,如:https://torna.xxx.com:7700"
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "开放平台线上环境地址",
|
||||
prop: "openProdUrl",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
placeholder: "开放平台线上环境地址,如:https://open.xxx.com/api"
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "开放平台沙箱环境地址",
|
||||
prop: "openSandboxUrl",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
placeholder: "开放平台沙箱环境地址, 如:https://open-sandbox.xxx.com/api"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const handleSubmit = (values: FieldValues) => {
|
||||
api.save(values).then(() => {
|
||||
ElMessage.success("保存成功");
|
||||
});
|
||||
};
|
||||
|
||||
const loadSetting = () => {
|
||||
api.get().then(resp => {
|
||||
state.value = resp.data;
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadSetting();
|
||||
});
|
||||
};
|
||||
|
||||
loadSetting();
|
||||
return { state, rules, columns, handleSubmit };
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { state, rules, columns, handleSubmit } from "./index";
|
||||
import { useDocSetting } from "./index";
|
||||
const { state, rules, columns, handleSubmit } = useDocSetting();
|
||||
defineOptions({
|
||||
name: "DocSetting"
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ref } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import {
|
||||
type ButtonsCallBackParams,
|
||||
type FieldValues,
|
||||
@@ -11,281 +11,320 @@ 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";
|
||||
export function useIsvList() {
|
||||
const isAdd = ref(false);
|
||||
|
||||
const isAdd = ref(false);
|
||||
// ========= search form =========
|
||||
|
||||
// ========= search form =========
|
||||
// 查询表单对象
|
||||
const searchFormData = ref({
|
||||
appId: "",
|
||||
status: "",
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
|
||||
// 查询表单对象
|
||||
export const searchFormData = ref({
|
||||
appId: "",
|
||||
status: "",
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
// 查询表单字段定义
|
||||
const searchFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "AppID",
|
||||
prop: "appId"
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
valueType: "select",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: StatusEnum.ENABLE,
|
||||
color: "green"
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: StatusEnum.DISABLE,
|
||||
color: "red"
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// 查询表单字段定义
|
||||
export const searchFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "AppID",
|
||||
prop: "appId"
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
valueType: "select",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: StatusEnum.ENABLE,
|
||||
color: "green"
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: StatusEnum.DISABLE,
|
||||
color: "red"
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
const {
|
||||
tableData,
|
||||
total,
|
||||
pageInfo,
|
||||
buttons: actionButtons
|
||||
} = useTable<any[]>();
|
||||
// 默认每页条数,默认10
|
||||
pageInfo.value.pageSize = 10;
|
||||
|
||||
// 表格字段定义
|
||||
const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "AppID",
|
||||
prop: "appId",
|
||||
width: 250
|
||||
},
|
||||
{
|
||||
label: "秘钥",
|
||||
prop: "keys",
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
label: "所属分组",
|
||||
prop: "groupNames",
|
||||
width: 120,
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
export const {
|
||||
tableData,
|
||||
total,
|
||||
pageInfo,
|
||||
buttons: actionButtons
|
||||
} = useTable<any[]>();
|
||||
// 默认每页条数,默认10
|
||||
pageInfo.value.pageSize = 10;
|
||||
|
||||
// 表格字段定义
|
||||
export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "AppID",
|
||||
prop: "appId",
|
||||
width: 250
|
||||
},
|
||||
{
|
||||
label: "秘钥",
|
||||
prop: "keys",
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
label: "所属分组",
|
||||
prop: "groupNames",
|
||||
width: 200,
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
width: 80,
|
||||
valueType: "select",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: StatusEnum.ENABLE,
|
||||
color: "green"
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: StatusEnum.DISABLE,
|
||||
color: "red"
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
width: 80,
|
||||
valueType: "select",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: StatusEnum.ENABLE,
|
||||
color: "green"
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: StatusEnum.DISABLE,
|
||||
color: "red"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "添加时间",
|
||||
prop: "addTime",
|
||||
width: 160
|
||||
},
|
||||
{
|
||||
label: "修改时间",
|
||||
prop: "updateTime",
|
||||
width: 160
|
||||
}
|
||||
];
|
||||
// 表格按钮定义
|
||||
actionButtons.value = [
|
||||
{
|
||||
// 修改
|
||||
text: "修改",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
isAdd.value = false;
|
||||
editFormData.value = Object.assign({}, params.row);
|
||||
dlgTitle.value = "修改";
|
||||
dlgShow.value = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "设置秘钥",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
{
|
||||
width: 100,
|
||||
label: "添加人",
|
||||
prop: "addBy.showName"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
settingKeys(params.row);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "设置分组",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
{
|
||||
width: 100,
|
||||
label: "修改人",
|
||||
prop: "updateBy.showName"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
settingGroup(params.row);
|
||||
{
|
||||
width: 120,
|
||||
label: "添加时间",
|
||||
prop: "addTime",
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
},
|
||||
{
|
||||
width: 120,
|
||||
label: "修改时间",
|
||||
prop: "updateTime",
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// 启用/禁用
|
||||
text: row => (row.status === StatusEnum.ENABLE ? "禁用" : "启用"),
|
||||
confirm: {
|
||||
message: data => {
|
||||
const opt = data.row.status === StatusEnum.ENABLE ? "禁用" : "启用";
|
||||
return `确定${opt}吗?`;
|
||||
];
|
||||
// 表格按钮定义
|
||||
actionButtons.value = [
|
||||
{
|
||||
// 修改
|
||||
text: "修改",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
options: { draggable: false }
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
isAdd.value = false;
|
||||
editFormData.value = Object.assign({}, params.row);
|
||||
dlgTitle.value = "修改";
|
||||
dlgShow.value = true;
|
||||
}
|
||||
},
|
||||
onConfirm(params: ButtonsCallBackParams) {
|
||||
const data = {
|
||||
id: params.row.id,
|
||||
status:
|
||||
params.row.status === StatusEnum.ENABLE
|
||||
? StatusEnum.DISABLE
|
||||
: StatusEnum.ENABLE
|
||||
};
|
||||
api.updateStatus(data).then(() => {
|
||||
ElMessage.success("修改成功");
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
{
|
||||
text: "设置秘钥",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
settingKeys(params.row);
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "设置分组",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
settingGroup(params.row);
|
||||
}
|
||||
},
|
||||
{
|
||||
// 启用/禁用
|
||||
text: row => (row.status === StatusEnum.ENABLE ? "禁用" : "启用"),
|
||||
confirm: {
|
||||
message: data => {
|
||||
const opt = data.row.status === StatusEnum.ENABLE ? "禁用" : "启用";
|
||||
return `确定${opt}吗?`;
|
||||
},
|
||||
options: { draggable: false }
|
||||
},
|
||||
onConfirm(params: ButtonsCallBackParams) {
|
||||
const data = {
|
||||
id: params.row.id,
|
||||
status:
|
||||
params.row.status === StatusEnum.ENABLE
|
||||
? StatusEnum.DISABLE
|
||||
: StatusEnum.ENABLE
|
||||
};
|
||||
api.updateStatus(data).then(() => {
|
||||
ElMessage.success("修改成功");
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
];
|
||||
|
||||
// ========= dialog form =========
|
||||
// ========= dialog form =========
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgShow = ref(false);
|
||||
export const dlgTitle = ref("");
|
||||
// 表单值
|
||||
const editFormDataGen = () => {
|
||||
return {
|
||||
id: 0,
|
||||
status: StatusEnum.ENABLE,
|
||||
keyFormat: KeyFormatEnum.PKCS8,
|
||||
remark: ""
|
||||
// 弹窗显示
|
||||
const dlgShow = ref(false);
|
||||
const dlgTitle = ref("");
|
||||
// 表单值
|
||||
const editFormDataGen = () => {
|
||||
return {
|
||||
id: 0,
|
||||
status: StatusEnum.ENABLE,
|
||||
keyFormat: KeyFormatEnum.PKCS8,
|
||||
remark: ""
|
||||
};
|
||||
};
|
||||
};
|
||||
export const editFormData = ref<FieldValues>(editFormDataGen());
|
||||
export const editFormRules = {};
|
||||
const editFormData = ref<FieldValues>(editFormDataGen());
|
||||
const editFormRules = {};
|
||||
|
||||
// 表单内容
|
||||
export const editFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "AppID",
|
||||
prop: "appId",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
disabled: true,
|
||||
placeholder: "自动生成"
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
valueType: "radio",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: StatusEnum.ENABLE
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: StatusEnum.DISABLE
|
||||
// 表单内容
|
||||
const editFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "AppID",
|
||||
prop: "appId",
|
||||
valueType: "copy",
|
||||
fieldProps: {
|
||||
disabled: true,
|
||||
placeholder: "自动生成"
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
valueType: "radio",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: StatusEnum.ENABLE
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: StatusEnum.DISABLE
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
valueType: "textarea",
|
||||
fieldProps: {
|
||||
maxlength: 300,
|
||||
showWordLimit: true,
|
||||
autosize: { minRows: 2, maxRows: 4 }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
valueType: "textarea",
|
||||
fieldProps: {
|
||||
maxlength: 300,
|
||||
showWordLimit: true,
|
||||
autosize: { minRows: 2, maxRows: 4 }
|
||||
}
|
||||
}
|
||||
];
|
||||
];
|
||||
|
||||
// ========= event =========
|
||||
// ========= event =========
|
||||
|
||||
// 添加按钮事件
|
||||
export const handleAdd = () => {
|
||||
isAdd.value = true;
|
||||
editFormData.value = editFormDataGen();
|
||||
dlgTitle.value = "新增";
|
||||
dlgShow.value = true;
|
||||
};
|
||||
// 添加按钮事件
|
||||
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.success("保存成功");
|
||||
dlgShow.value = false;
|
||||
// 保存按钮事件,校验成功后触发
|
||||
const handleSave = () => {
|
||||
const postData = editFormData.value;
|
||||
const pms = isAdd.value ? api.add(postData) : api.update(postData);
|
||||
pms.then(() => {
|
||||
ElMessage.success("保存成功");
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
||||
// 点击查询按钮
|
||||
const handleSearch = () => {
|
||||
pageInfo.value.page = 1;
|
||||
search();
|
||||
};
|
||||
|
||||
// 分页事件
|
||||
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);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 页面加载
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
||||
// 点击查询按钮
|
||||
export const handleSearch = () => {
|
||||
pageInfo.value.page = 1;
|
||||
search();
|
||||
};
|
||||
|
||||
// 分页事件
|
||||
export const handlePaginationChange = (_pageInfo: PageInfo): void => {
|
||||
pageInfo.value = _pageInfo;
|
||||
search();
|
||||
};
|
||||
|
||||
// 查询
|
||||
export 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();
|
||||
return {
|
||||
search,
|
||||
actionButtons,
|
||||
dlgShow,
|
||||
dlgTitle,
|
||||
editFormColumns,
|
||||
editFormData,
|
||||
editFormRules,
|
||||
handleAdd,
|
||||
handlePaginationChange,
|
||||
handleSave,
|
||||
handleSearch,
|
||||
pageInfo,
|
||||
searchFormColumns,
|
||||
searchFormData,
|
||||
tableColumns,
|
||||
tableData,
|
||||
total
|
||||
};
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
import { useIsvList } from "./index";
|
||||
const {
|
||||
actionButtons,
|
||||
dlgShow,
|
||||
dlgTitle,
|
||||
@@ -16,7 +17,7 @@ import {
|
||||
tableColumns,
|
||||
tableData,
|
||||
total
|
||||
} from "./index";
|
||||
} = useIsvList();
|
||||
import {
|
||||
dlgKeysShow,
|
||||
showKeysFormColumns,
|
||||
@@ -67,6 +68,7 @@ defineOptions({
|
||||
pageSizeList: [10, 20, 50, 100],
|
||||
align: 'right'
|
||||
}"
|
||||
showOverflowTooltip
|
||||
@paginationChange="handlePaginationChange"
|
||||
>
|
||||
<template #title>
|
||||
|
@@ -5,7 +5,9 @@ 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";
|
||||
import { useIsvList } from "@/views/isv/list/index";
|
||||
|
||||
const { search } = useIsvList();
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgGroupSetting = ref(false);
|
||||
|
@@ -3,7 +3,9 @@ import type { PlusFormGroupRow } from "plus-pro-components";
|
||||
import { api } from "@/api/isvList";
|
||||
import { KeyFormatEnum } from "@/model/enums";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { search } from "./index";
|
||||
import { useIsvList } from "./index";
|
||||
|
||||
const { search } = useIsvList();
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgKeysSetting = ref(false);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ref } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import {
|
||||
type ButtonsCallBackParams,
|
||||
type PlusColumn,
|
||||
@@ -8,149 +8,173 @@ import { ElMessage } from "element-plus";
|
||||
import { api } from "@/api/permGroup";
|
||||
import { searchTable } from "@/views/isv/perm/permGroupApi";
|
||||
|
||||
const isAdd = ref(false);
|
||||
export function usePermGroup() {
|
||||
const isAdd = ref(false);
|
||||
|
||||
// ========= search form =========
|
||||
// ========= search form =========
|
||||
|
||||
// 查询表单对象
|
||||
export const searchFormData = ref({
|
||||
groupName: ""
|
||||
});
|
||||
|
||||
// 查询表单字段定义
|
||||
export const searchFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组描述",
|
||||
prop: "groupName"
|
||||
}
|
||||
];
|
||||
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
export const { tableData, buttons: actionButtons } = useTable<any[]>();
|
||||
|
||||
export const selectedGroupId = ref(0);
|
||||
|
||||
// 表格字段定义
|
||||
export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组名称",
|
||||
prop: "groupName"
|
||||
}
|
||||
];
|
||||
// 表格按钮定义
|
||||
actionButtons.value = [
|
||||
{
|
||||
// 修改
|
||||
text: "修改",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
params.e.stopPropagation();
|
||||
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) {
|
||||
params.e.stopPropagation();
|
||||
api.del(params.row).then(() => {
|
||||
ElMessage({
|
||||
message: "删除成功",
|
||||
type: "success"
|
||||
});
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// ========= dialog form =========
|
||||
|
||||
// 弹窗显示
|
||||
export const dlgShow = ref(false);
|
||||
export const dlgTitle = ref("");
|
||||
// 表单值
|
||||
const editFormDataGen = () => {
|
||||
return {
|
||||
// 查询表单对象
|
||||
const searchFormData = ref({
|
||||
groupName: ""
|
||||
});
|
||||
|
||||
// 查询表单字段定义
|
||||
const searchFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组描述",
|
||||
prop: "groupName"
|
||||
}
|
||||
];
|
||||
|
||||
// ========= table =========
|
||||
|
||||
// 表格对象
|
||||
const { tableData, buttons: actionButtons } = useTable<any[]>();
|
||||
|
||||
const selectedGroupId = ref(0);
|
||||
|
||||
// 表格字段定义
|
||||
const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组名称",
|
||||
prop: "groupName"
|
||||
}
|
||||
];
|
||||
// 表格按钮定义
|
||||
actionButtons.value = [
|
||||
{
|
||||
// 修改
|
||||
text: "修改",
|
||||
code: "edit",
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
params.e.stopPropagation();
|
||||
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) {
|
||||
params.e.stopPropagation();
|
||||
api.del(params.row).then(() => {
|
||||
ElMessage({
|
||||
message: "删除成功",
|
||||
type: "success"
|
||||
});
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// ========= dialog form =========
|
||||
|
||||
// 弹窗显示
|
||||
const dlgShow = ref(false);
|
||||
const dlgTitle = ref("");
|
||||
// 表单值
|
||||
const editFormDataGen = () => {
|
||||
return {
|
||||
groupName: ""
|
||||
};
|
||||
};
|
||||
const editFormData = ref<any>(editFormDataGen());
|
||||
const editFormRules = {
|
||||
groupName: [{ required: true, message: "请输入分组名称" }]
|
||||
};
|
||||
};
|
||||
export const editFormData = ref<any>(editFormDataGen());
|
||||
export const editFormRules = {
|
||||
groupName: [{ required: true, message: "请输入分组名称" }]
|
||||
};
|
||||
|
||||
// 表单内容
|
||||
export const editFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组名称",
|
||||
prop: "groupName",
|
||||
valueType: "input"
|
||||
}
|
||||
];
|
||||
// 表单内容
|
||||
const editFormColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "分组名称",
|
||||
prop: "groupName",
|
||||
valueType: "input"
|
||||
}
|
||||
];
|
||||
|
||||
// ========= event =========
|
||||
// ========= event =========
|
||||
|
||||
// 点击行
|
||||
export const handleRowClick = row => {
|
||||
const groupId = row.id;
|
||||
selectedGroupId.value = groupId;
|
||||
searchTable(groupId);
|
||||
};
|
||||
// 点击行
|
||||
const handleRowClick = row => {
|
||||
const groupId = row.id;
|
||||
selectedGroupId.value = groupId;
|
||||
searchTable(groupId);
|
||||
};
|
||||
|
||||
// 添加按钮事件
|
||||
export const handleAdd = () => {
|
||||
isAdd.value = true;
|
||||
editFormData.value = editFormDataGen();
|
||||
dlgTitle.value = "新增";
|
||||
dlgShow.value = true;
|
||||
};
|
||||
// 添加按钮事件
|
||||
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.success("保存成功");
|
||||
dlgShow.value = false;
|
||||
// 保存按钮事件,校验成功后触发
|
||||
const handleSave = () => {
|
||||
const postData = editFormData.value;
|
||||
const pms = isAdd.value ? api.add(postData) : api.update(postData);
|
||||
pms.then(() => {
|
||||
ElMessage.success("保存成功");
|
||||
dlgShow.value = false;
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
||||
// 点击查询按钮
|
||||
const handleSearch = () => {
|
||||
search();
|
||||
};
|
||||
|
||||
// 查询
|
||||
const search = async () => {
|
||||
try {
|
||||
const { data } = await doSearch();
|
||||
tableData.value = data;
|
||||
} catch (error) {}
|
||||
};
|
||||
// 请求接口
|
||||
const doSearch = async () => {
|
||||
// 查询参数
|
||||
const data = searchFormData.value;
|
||||
return api.listAll(data);
|
||||
};
|
||||
|
||||
// 页面加载
|
||||
search();
|
||||
|
||||
onMounted(() => {
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
||||
// 点击查询按钮
|
||||
export const handleSearch = () => {
|
||||
search();
|
||||
};
|
||||
|
||||
// 查询
|
||||
const search = async () => {
|
||||
try {
|
||||
const { data } = await doSearch();
|
||||
tableData.value = data;
|
||||
} catch (error) {}
|
||||
};
|
||||
// 请求接口
|
||||
const doSearch = async () => {
|
||||
// 查询参数
|
||||
const data = searchFormData.value;
|
||||
return api.listAll(data);
|
||||
};
|
||||
|
||||
// 页面加载
|
||||
search();
|
||||
return {
|
||||
actionButtons,
|
||||
dlgShow,
|
||||
dlgTitle,
|
||||
editFormColumns,
|
||||
editFormData,
|
||||
editFormRules,
|
||||
handleAdd,
|
||||
handleRowClick,
|
||||
handleSave,
|
||||
handleSearch,
|
||||
searchFormColumns,
|
||||
searchFormData,
|
||||
selectedGroupId,
|
||||
tableColumns,
|
||||
tableData
|
||||
};
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
import { usePermGroup } from "./permGroup";
|
||||
const {
|
||||
actionButtons,
|
||||
dlgShow,
|
||||
dlgTitle,
|
||||
@@ -15,7 +16,7 @@ import {
|
||||
selectedGroupId,
|
||||
tableColumns,
|
||||
tableData
|
||||
} from "./permGroup";
|
||||
} = usePermGroup();
|
||||
import PermGroupApi from "./permGroupApi.vue";
|
||||
defineOptions({
|
||||
name: "IsvPermPermGroup"
|
||||
|
@@ -39,6 +39,7 @@ defineOptions({
|
||||
pageSizeList: [10, 20, 50, 100],
|
||||
align: 'right'
|
||||
}"
|
||||
showOverflowTooltip
|
||||
@paginationChange="handlePaginationChange"
|
||||
>
|
||||
<template #title>
|
||||
|
@@ -1,99 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { hasAuth, getAuths } from "@/router/utils";
|
||||
|
||||
defineOptions({
|
||||
name: "PermissionButtonRouter"
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p class="mb-2">当前拥有的code列表:{{ getAuths() }}</p>
|
||||
|
||||
<el-card shadow="never" class="mb-2">
|
||||
<template #header>
|
||||
<div class="card-header">组件方式判断权限</div>
|
||||
</template>
|
||||
<el-space wrap>
|
||||
<Auth value="permission:btn:add">
|
||||
<el-button plain type="warning">
|
||||
拥有code:'permission:btn:add' 权限可见
|
||||
</el-button>
|
||||
</Auth>
|
||||
<Auth :value="['permission:btn:edit']">
|
||||
<el-button plain type="primary">
|
||||
拥有code:['permission:btn:edit'] 权限可见
|
||||
</el-button>
|
||||
</Auth>
|
||||
<Auth
|
||||
:value="[
|
||||
'permission:btn:add',
|
||||
'permission:btn:edit',
|
||||
'permission:btn:delete'
|
||||
]"
|
||||
>
|
||||
<el-button plain type="danger">
|
||||
拥有code:['permission:btn:add', 'permission:btn:edit',
|
||||
'permission:btn:delete'] 权限可见
|
||||
</el-button>
|
||||
</Auth>
|
||||
</el-space>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mb-2">
|
||||
<template #header>
|
||||
<div class="card-header">函数方式判断权限</div>
|
||||
</template>
|
||||
<el-space wrap>
|
||||
<el-button v-if="hasAuth('permission:btn:add')" plain type="warning">
|
||||
拥有code:'permission:btn:add' 权限可见
|
||||
</el-button>
|
||||
<el-button v-if="hasAuth(['permission:btn:edit'])" plain type="primary">
|
||||
拥有code:['permission:btn:edit'] 权限可见
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="
|
||||
hasAuth([
|
||||
'permission:btn:add',
|
||||
'permission:btn:edit',
|
||||
'permission:btn:delete'
|
||||
])
|
||||
"
|
||||
plain
|
||||
type="danger"
|
||||
>
|
||||
拥有code:['permission:btn:add', 'permission:btn:edit',
|
||||
'permission:btn:delete'] 权限可见
|
||||
</el-button>
|
||||
</el-space>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
指令方式判断权限(该方式不能动态修改权限)
|
||||
</div>
|
||||
</template>
|
||||
<el-space wrap>
|
||||
<el-button v-auth="'permission:btn:add'" plain type="warning">
|
||||
拥有code:'permission:btn:add' 权限可见
|
||||
</el-button>
|
||||
<el-button v-auth="['permission:btn:edit']" plain type="primary">
|
||||
拥有code:['permission:btn:edit'] 权限可见
|
||||
</el-button>
|
||||
<el-button
|
||||
v-auth="[
|
||||
'permission:btn:add',
|
||||
'permission:btn:edit',
|
||||
'permission:btn:delete'
|
||||
]"
|
||||
plain
|
||||
type="danger"
|
||||
>
|
||||
拥有code:['permission:btn:add', 'permission:btn:edit',
|
||||
'permission:btn:delete'] 权限可见
|
||||
</el-button>
|
||||
</el-space>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
@@ -1,109 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { hasPerms } from "@/utils/auth";
|
||||
import { useUserStoreHook } from "@/store/modules/user";
|
||||
|
||||
const { permissions } = useUserStoreHook();
|
||||
|
||||
defineOptions({
|
||||
name: "PermissionButtonLogin"
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p class="mb-2">当前拥有的code列表:{{ permissions }}</p>
|
||||
<p v-show="permissions?.[0] === '*:*:*'" class="mb-2">
|
||||
*:*:* 代表拥有全部按钮级别权限
|
||||
</p>
|
||||
|
||||
<el-card shadow="never" class="mb-2">
|
||||
<template #header>
|
||||
<div class="card-header">组件方式判断权限</div>
|
||||
</template>
|
||||
<el-space wrap>
|
||||
<Perms value="permission:btn:add">
|
||||
<el-button plain type="warning">
|
||||
拥有code:'permission:btn:add' 权限可见
|
||||
</el-button>
|
||||
</Perms>
|
||||
<Perms :value="['permission:btn:edit']">
|
||||
<el-button plain type="primary">
|
||||
拥有code:['permission:btn:edit'] 权限可见
|
||||
</el-button>
|
||||
</Perms>
|
||||
<Perms
|
||||
:value="[
|
||||
'permission:btn:add',
|
||||
'permission:btn:edit',
|
||||
'permission:btn:delete'
|
||||
]"
|
||||
>
|
||||
<el-button plain type="danger">
|
||||
拥有code:['permission:btn:add', 'permission:btn:edit',
|
||||
'permission:btn:delete'] 权限可见
|
||||
</el-button>
|
||||
</Perms>
|
||||
</el-space>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mb-2">
|
||||
<template #header>
|
||||
<div class="card-header">函数方式判断权限</div>
|
||||
</template>
|
||||
<el-space wrap>
|
||||
<el-button v-if="hasPerms('permission:btn:add')" plain type="warning">
|
||||
拥有code:'permission:btn:add' 权限可见
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="hasPerms(['permission:btn:edit'])"
|
||||
plain
|
||||
type="primary"
|
||||
>
|
||||
拥有code:['permission:btn:edit'] 权限可见
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="
|
||||
hasPerms([
|
||||
'permission:btn:add',
|
||||
'permission:btn:edit',
|
||||
'permission:btn:delete'
|
||||
])
|
||||
"
|
||||
plain
|
||||
type="danger"
|
||||
>
|
||||
拥有code:['permission:btn:add', 'permission:btn:edit',
|
||||
'permission:btn:delete'] 权限可见
|
||||
</el-button>
|
||||
</el-space>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
指令方式判断权限(该方式不能动态修改权限)
|
||||
</div>
|
||||
</template>
|
||||
<el-space wrap>
|
||||
<el-button v-perms="'permission:btn:add'" plain type="warning">
|
||||
拥有code:'permission:btn:add' 权限可见
|
||||
</el-button>
|
||||
<el-button v-perms="['permission:btn:edit']" plain type="primary">
|
||||
拥有code:['permission:btn:edit'] 权限可见
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="[
|
||||
'permission:btn:add',
|
||||
'permission:btn:edit',
|
||||
'permission:btn:delete'
|
||||
]"
|
||||
plain
|
||||
type="danger"
|
||||
>
|
||||
拥有code:['permission:btn:add', 'permission:btn:edit',
|
||||
'permission:btn:delete'] 权限可见
|
||||
</el-button>
|
||||
</el-space>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
@@ -1,66 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { initRouter } from "@/router/utils";
|
||||
import { storageLocal } from "@pureadmin/utils";
|
||||
import { type CSSProperties, ref, computed } from "vue";
|
||||
import { useUserStoreHook } from "@/store/modules/user";
|
||||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||
|
||||
defineOptions({
|
||||
name: "PermissionPage"
|
||||
});
|
||||
|
||||
const elStyle = computed((): CSSProperties => {
|
||||
return {
|
||||
width: "85vw",
|
||||
justifyContent: "start"
|
||||
};
|
||||
});
|
||||
|
||||
const username = ref(useUserStoreHook()?.username);
|
||||
|
||||
const options = [
|
||||
{
|
||||
value: "admin",
|
||||
label: "管理员角色"
|
||||
},
|
||||
{
|
||||
value: "common",
|
||||
label: "普通角色"
|
||||
}
|
||||
];
|
||||
|
||||
function onChange() {
|
||||
useUserStoreHook()
|
||||
.loginByUsername({ username: username.value, password: "admin123" })
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
storageLocal().removeItem("async-routes");
|
||||
usePermissionStoreHook().clearAllCachePage();
|
||||
initRouter();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p class="mb-2">
|
||||
模拟后台根据不同角色返回对应路由,观察左侧菜单变化(管理员角色可查看系统管理菜单、普通角色不可查看系统管理菜单)
|
||||
</p>
|
||||
<el-card shadow="never" :style="elStyle">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>当前角色:{{ username }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-select v-model="username" class="!w-[160px]" @change="onChange">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
@@ -66,18 +66,12 @@ export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "所属应用",
|
||||
prop: "application",
|
||||
minWidth: 150,
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
minWidth: 150
|
||||
},
|
||||
{
|
||||
label: "接口名称",
|
||||
prop: "apiName",
|
||||
minWidth: 200,
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
label: "版本号",
|
||||
@@ -87,17 +81,11 @@ export const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
label: "接口描述",
|
||||
prop: "description",
|
||||
minWidth: 100,
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
minWidth: 100
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
tableColumnProps: {
|
||||
showOverflowTooltip: true
|
||||
}
|
||||
prop: "remark"
|
||||
},
|
||||
{
|
||||
label: "需要授权",
|
||||
@@ -187,14 +175,14 @@ export const tableColumns: PlusColumn[] = [
|
||||
]
|
||||
},
|
||||
{
|
||||
width: 120,
|
||||
label: "添加时间",
|
||||
prop: "addTime",
|
||||
width: 160
|
||||
prop: "addTime"
|
||||
},
|
||||
{
|
||||
width: 120,
|
||||
label: "修改时间",
|
||||
prop: "updateTime",
|
||||
width: 160
|
||||
prop: "updateTime"
|
||||
}
|
||||
];
|
||||
// 表格按钮权限
|
||||
|
@@ -44,6 +44,7 @@ defineOptions({
|
||||
pageSizeList: [10, 20, 50, 100],
|
||||
align: 'right'
|
||||
}"
|
||||
showOverflowTooltip
|
||||
adaptive
|
||||
@paginationChange="handlePaginationChange"
|
||||
>
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import dayjs from "dayjs";
|
||||
import editForm from "../form.vue";
|
||||
import { handleTree } from "@/utils/tree";
|
||||
import { message } from "@/utils/message";
|
||||
@@ -44,10 +43,9 @@ export function useDept() {
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
minWidth: 200,
|
||||
prop: "createTime",
|
||||
formatter: ({ createTime }) =>
|
||||
dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
width: 120,
|
||||
prop: "addTime",
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import dayjs from "dayjs";
|
||||
import editForm from "../form.vue";
|
||||
import { handleTree } from "@/utils/tree";
|
||||
import { message } from "@/utils/message";
|
||||
@@ -90,10 +89,9 @@ export function useRole(treeRef: Ref) {
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
prop: "createTime",
|
||||
minWidth: 160,
|
||||
formatter: ({ createTime }) =>
|
||||
dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
prop: "addTime",
|
||||
width: 120,
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import "./reset.css";
|
||||
import dayjs from "dayjs";
|
||||
import roleForm from "../form/role.vue";
|
||||
import editForm from "../form/index.vue";
|
||||
import { zxcvbn } from "@zxcvbn-ts/core";
|
||||
@@ -157,10 +156,9 @@ export function useUser(tableRef: Ref, treeRef: Ref) {
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
minWidth: 90,
|
||||
prop: "createTime",
|
||||
formatter: ({ createTime }) =>
|
||||
dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
width: 120,
|
||||
prop: "addTime",
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
|
Reference in New Issue
Block a user