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,4 +1,9 @@
|
||||
import { http } from "@/utils/http";
|
||||
import { createUrl, http } from "@/utils/http";
|
||||
|
||||
// 后端请求接口
|
||||
const apiUrl: any = createUrl({
|
||||
listMenu: "sys/userperm/listCurrentUserMenu"
|
||||
});
|
||||
|
||||
type Result = {
|
||||
success: boolean;
|
||||
@@ -6,5 +11,6 @@ type Result = {
|
||||
};
|
||||
|
||||
export const getAsyncRoutes = () => {
|
||||
return http.request<Result>("get", "/get-async-routes");
|
||||
return http.request<Result>("get", apiUrl.listMenu);
|
||||
// return http.request<Result>("get", "/get-async-routes");
|
||||
};
|
||||
|
23
sop-admin/sop-admin-frontend/src/utils/perm.ts
Normal file
23
sop-admin/sop-admin-frontend/src/utils/perm.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 按钮权限定义
|
||||
*/
|
||||
export const PermCode = {
|
||||
// 接口管理按钮权限
|
||||
api: {
|
||||
// 更新
|
||||
update: "api:table-btn:update",
|
||||
// 启用/禁用
|
||||
updateStatus: "api:table-btn:updateStatus"
|
||||
},
|
||||
// 文档列表按钮定义
|
||||
doc: {
|
||||
// 发布
|
||||
publish: "doc:table-btn:publish",
|
||||
// 下线
|
||||
offline: "doc:table-btn:offline",
|
||||
// 同步
|
||||
sync: "doc:table-btn:sync",
|
||||
// 同步所有接口
|
||||
syncAll: "doc:page-btn:sync"
|
||||
}
|
||||
};
|
@@ -1,12 +1,14 @@
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { api } from "@/api/doc";
|
||||
import { PermCode } from "@/utils/perm";
|
||||
import {
|
||||
type ButtonsCallBackParams,
|
||||
type PlusColumn,
|
||||
useTable
|
||||
} from "plus-pro-components";
|
||||
import { YesOrNoEnum } from "@/model/enums";
|
||||
import { hasPerms } from "@/utils/auth";
|
||||
|
||||
export function useDocList() {
|
||||
const tabsData = ref<Array<any>>([
|
||||
@@ -45,6 +47,8 @@ export function useDocList() {
|
||||
);
|
||||
};
|
||||
|
||||
// 按钮权限code
|
||||
const btnCode = PermCode.doc;
|
||||
// 表格字段定义
|
||||
const tableColumns: PlusColumn[] = [
|
||||
{
|
||||
@@ -129,7 +133,7 @@ export function useDocList() {
|
||||
search();
|
||||
});
|
||||
},
|
||||
show: (row: any) => row.isFolder === 1
|
||||
show: (row: any) => hasPerms(btnCode.publish) && row.isFolder === 1
|
||||
},
|
||||
{
|
||||
text: "下线",
|
||||
@@ -155,7 +159,7 @@ export function useDocList() {
|
||||
search();
|
||||
});
|
||||
},
|
||||
show: (row: any) => row.isFolder === 1
|
||||
show: (row: any) => hasPerms(btnCode.offline) && row.isFolder === 1
|
||||
},
|
||||
{
|
||||
text: row => (row.isPublish ? "下线" : "发布"),
|
||||
@@ -181,7 +185,10 @@ export function useDocList() {
|
||||
search();
|
||||
});
|
||||
},
|
||||
show: (row: any) => row.isFolder === 0
|
||||
show: (row: any) => {
|
||||
const perm = row.isPublish ? btnCode.offline : btnCode.publish;
|
||||
return hasPerms(perm) && row.isFolder === 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
text: "同步",
|
||||
@@ -210,7 +217,8 @@ export function useDocList() {
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
show: () => hasPerms(btnCode.sync)
|
||||
}
|
||||
];
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useDocList } from "./index";
|
||||
import { Search } from "@element-plus/icons-vue";
|
||||
import { hasPerms } from "@/utils/auth";
|
||||
defineOptions({
|
||||
name: "DocList"
|
||||
});
|
||||
@@ -65,7 +66,11 @@ const {
|
||||
</el-input>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<el-button type="primary" @click="handleSyncApi">
|
||||
<el-button
|
||||
v-if="hasPerms('doc:page-btn:sync')"
|
||||
type="primary"
|
||||
@click="handleSyncApi"
|
||||
>
|
||||
同步全部接口
|
||||
</el-button>
|
||||
</template>
|
||||
|
@@ -8,6 +8,8 @@ import {
|
||||
import { ElMessage } from "element-plus";
|
||||
import { RegSource, StatusEnum, YesOrNoEnum } from "@/model/enums";
|
||||
import { api } from "@/api/serveApi";
|
||||
import { hasPerms } from "@/utils/auth";
|
||||
import { PermCode } from "@/utils/perm";
|
||||
|
||||
const isAdd = ref(false);
|
||||
|
||||
@@ -195,6 +197,8 @@ export const tableColumns: PlusColumn[] = [
|
||||
width: 160
|
||||
}
|
||||
];
|
||||
// 表格按钮权限
|
||||
const btnCode = PermCode.api;
|
||||
// 表格按钮定义
|
||||
actionButtons.value = [
|
||||
{
|
||||
@@ -204,13 +208,13 @@ actionButtons.value = [
|
||||
props: {
|
||||
type: "primary"
|
||||
},
|
||||
show: computed(() => true),
|
||||
onClick(params: ButtonsCallBackParams) {
|
||||
isAdd.value = false;
|
||||
editFormData.value = Object.assign({}, params.row);
|
||||
dlgTitle.value = "修改接口";
|
||||
dlgShow.value = true;
|
||||
}
|
||||
},
|
||||
show: () => hasPerms(btnCode.update)
|
||||
},
|
||||
{
|
||||
// 启用/禁用
|
||||
@@ -235,7 +239,8 @@ actionButtons.value = [
|
||||
ElMessage.success("修改成功");
|
||||
search();
|
||||
});
|
||||
}
|
||||
},
|
||||
show: () => hasPerms(btnCode.updateStatus)
|
||||
}
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user