权限调整

master
zhangdi 3 months ago
parent 87bc6dcacc
commit c16329ea5a
  1. 3
      src/page/index/index.vue
  2. 235
      src/page/login/authorization.vue
  3. 753
      src/views/system/menu.vue

@ -89,8 +89,9 @@
// //
openMenu(item = {}) { openMenu(item = {}) {
console.log("itemitemitemopenMenu", this.userInfo) console.log("itemitemitemopenMenu", this.userInfo)
let roleIds = this.userInfo.roleList.map(item => item.id);
this.$store.dispatch("GetMenu", item.id).then(data => { this.$store.dispatch("GetMenu", {roleId:roleIds.join(',')}).then(data => {
console.log("每次刷新调用", data); console.log("每次刷新调用", data);
if (data.length !== 0) { if (data.length !== 0) {
this.$router.$avueRouter.formatRoutes(data, true); this.$router.$avueRouter.formatRoutes(data, true);

@ -8,9 +8,9 @@ import { mapGetters } from "vuex";
export default { export default {
name: "authorization", name: "authorization",
computed: { computed: {
...mapGetters(["tagWel", "userInfo"]) ...mapGetters(["tagWel", "userInfo"]),
}, },
data() { data() {
return {}; return {};
}, },
@ -20,10 +20,231 @@ computed: {
methods: { methods: {
getUserinfo() { getUserinfo() {
let data = this.$route.query.data; let data = this.$route.query.data;
// let data1 = {
// success: true,
// message: "",
// code: 200,
// result: {
// userId: "LiuXu",
// name: "",
// department: "//IT/",
// mainDepartment: "82",
// mainErDepartment: "20",
// leaderInDept: ",",
// gender: "",
// phone: "17853572157",
// mail: null,
// roleList: [
// {
// id: 1,
// code: "admin",
// name: "",
// },
// {
// id: 11,
// code: "trainAdmin",
// name: "",
// },
// {
// id: 19,
// code: "dispatcherAdmin",
// name: "",
// },
// {
// id: 41,
// code: "sidelineDriver",
// name: "",
// },
// {
// id: 62,
// code: "dutyAdmin",
// name: "",
// },
// {
// id: 119,
// code: "carDispatcherAdmin",
// name: "",
// },
// {
// id: 180,
// code: "birthdayAdmin",
// name: "",
// },
// {
// id: 215,
// code: "TeaAdmin",
// name: "",
// },
// {
// id: 217,
// code: "AddressAdmin",
// name: "",
// },
// {
// id: 220,
// code: "comprehensiveAdmin",
// name: "",
// },
// {
// id: 223,
// code: "deptStockAdmin",
// name: "",
// },
// ],
// roleNames:
// ",,,,,,,,,,",
// checked: false,
// manageNum: "1",
// deptId: null,
// deptList: [
// {
// id: "12",
// name: "",
// parentid: "1",
// order: 2147484447,
// oaId: 1000242,
// userList: null,
// children: [],
// },
// {
// id: "18",
// name: "",
// parentid: "1",
// order: 2147484322,
// oaId: 1000243,
// userList: null,
// children: [],
// },
// {
// id: "17",
// name: "",
// parentid: "1",
// order: 2147484197,
// oaId: 1000244,
// userList: null,
// children: [],
// },
// {
// id: "22",
// name: "",
// parentid: "1",
// order: 2147484134,
// oaId: 1000246,
// userList: null,
// children: [],
// },
// {
// id: "23",
// name: "",
// parentid: "1",
// order: 2147484103,
// oaId: 1000247,
// userList: null,
// children: [],
// },
// {
// id: "21",
// name: "",
// parentid: "1",
// order: 2147484087,
// oaId: 1000245,
// userList: null,
// children: [],
// },
// {
// id: "15",
// name: "",
// parentid: "1",
// order: 2147484072,
// oaId: 1000400,
// userList: null,
// children: [],
// },
// {
// id: "19",
// name: "",
// parentid: "1",
// order: 2147484009,
// oaId: 1000404,
// userList: null,
// children: [],
// },
// {
// id: "14",
// name: "",
// parentid: "1",
// order: 2147483947,
// oaId: 1000301,
// userList: null,
// children: [],
// },
// {
// id: "2",
// name: "",
// parentid: "1",
// order: 2147483884,
// oaId: 1000334,
// userList: null,
// children: [],
// },
// {
// id: "16",
// name: "",
// parentid: "1",
// order: 2147483822,
// oaId: 1000362,
// userList: null,
// children: [],
// },
// {
// id: "24",
// name: "",
// parentid: "1",
// order: 2147483697,
// oaId: 1000409,
// userList: null,
// children: [],
// },
// {
// id: "20",
// name: "",
// parentid: "1",
// order: 2147483634,
// oaId: 1000564,
// userList: null,
// children: [],
// },
// {
// id: "10",
// name: "",
// parentid: "1",
// order: 2147483572,
// oaId: 1000891,
// userList: null,
// children: [],
// },
// {
// id: "60",
// name: "",
// parentid: "1",
// order: 99996000,
// oaId: null,
// userList: null,
// children: [],
// },
// ],
// postName: "",
// virPostName: "",
// apprStatus: null,
// isCanAbnormal: true,
// userSort: 1000,
// isDel: false,
// mainErDepartmentName: "",
// },
// timestamp: 1768984070128,
// };
getUserinfo(this.$route.query.data).then((res) => { getUserinfo(this.$route.query.data).then((res) => {
this.$store.dispatch("user/setUserInfo", res); this.$store.dispatch("user/setUserInfo", res);
// console.log("", res.data.result);
const loading = this.$loading({ const loading = this.$loading({
lock: true, lock: true,
text: "登录中,请稍后。。。", text: "登录中,请稍后。。。",
@ -32,9 +253,9 @@ computed: {
this.$store this.$store
.dispatch("AuthLoginByUsername", res.data.result) .dispatch("AuthLoginByUsername", res.data.result)
.then(() => { .then(() => {
console.log("登录成功", res.data.result); console.log("登录成功", res.data.result);
console.log("获取用户信息", this.tagWel.value); console.log("获取用户信息", this.tagWel.value);
// this.$router.push({path: this.tagWel.value}); this.$router.push({path: this.tagWel.value});
loading.close(); loading.close();
}) })
.catch(() => { .catch(() => {

@ -1,31 +1,35 @@
<template> <template>
<basic-container> <basic-container>
<avue-crud :option="option" <avue-crud
:table-loading="loading" :option="option"
:data="data" :table-loading="loading"
ref="crud" :data="data"
v-model="form" ref="crud"
:permission="permissionList" v-model="form"
:before-open="beforeOpen" :permission="permissionList"
:before-close="beforeClose" :before-open="beforeOpen"
@row-del="rowDel" :before-close="beforeClose"
@row-update="rowUpdate" @row-del="rowDel"
@row-save="rowSave" @row-update="rowUpdate"
@search-change="searchChange" @row-save="rowSave"
@search-reset="searchReset" @search-change="searchChange"
@selection-change="selectionChange" @search-reset="searchReset"
@current-change="currentChange" @selection-change="selectionChange"
@size-change="sizeChange" @current-change="currentChange"
@refresh-change="refreshChange" @size-change="sizeChange"
@on-load="onLoad" @refresh-change="refreshChange"
@tree-load="treeLoad"> @on-load="onLoad"
@tree-load="treeLoad"
>
<template slot="menuLeft"> <template slot="menuLeft">
<el-button type="danger" <el-button
size="small" type="danger"
icon="el-icon-delete" size="small"
v-if="permission.menu_delete" icon="el-icon-delete"
plain v-if="permission.menu_delete"
@click="handleDelete"> plain
@click="handleDelete"
>
</el-button> </el-button>
</template> </template>
<template slot-scope="scope" slot="menu"> <template slot-scope="scope" slot="menu">
@ -33,15 +37,14 @@
type="text" type="text"
icon="el-icon-circle-plus-outline" icon="el-icon-circle-plus-outline"
size="small" size="small"
@click.stop="handleAdd(scope.row,scope.index)" @click.stop="handleAdd(scope.row, scope.index)"
v-if="userInfo.role_name.includes('admin') && scope.row.category === 1" v-if="scope.row.category === 1"
>新增子项 >新增子项
</el-button> </el-button>
</template> </template>
<template slot-scope="{row}" <template slot-scope="{ row }" slot="source">
slot="source"> <div style="text-align: center">
<div style="text-align:center"> <i :class="row.source" />
<i :class="row.source"/>
</div> </div>
</template> </template>
</avue-crud> </avue-crud>
@ -49,376 +52,382 @@
</template> </template>
<script> <script>
import {getLazyList, remove, update, add, getMenu} from "@/api/system/menu"; import { getLazyList, remove, update, add, getMenu } from "@/api/system/menu";
import {mapGetters} from "vuex"; import { mapGetters } from "vuex";
import iconList from "@/config/iconList"; import iconList from "@/config/iconList";
import func from "@/util/func"; import func from "@/util/func";
import {getMenuTree} from "@/api/system/menu"; import { getMenuTree } from "@/api/system/menu";
export default { export default {
data() { data() {
return { return {
form: {}, form: {},
query: {}, query: {},
loading: true, loading: true,
selectionList: [], selectionList: [],
parentId: 0, parentId: 0,
page: { page: {
pageSize: 10, pageSize: 10,
currentPage: 1, currentPage: 1,
total: 0, total: 0,
}, },
option: { option: {
height: "auto", height: "auto",
lazy: true, lazy: true,
tip: false, tip: false,
simplePage: true, simplePage: true,
searchShow: true, searchShow: true,
searchMenuSpan: 6, searchMenuSpan: 6,
dialogWidth: "60%", dialogWidth: "60%",
tree: true, tree: true,
border: true, border: true,
index: true, index: true,
selection: true, selection: true,
viewBtn: true, viewBtn: true,
menuWidth: 300, menuWidth: 300,
dialogClickModal: false, dialogClickModal: false,
column: [ column: [
{ {
label: "菜单名称", label: "菜单名称",
prop: "name", prop: "name",
search: true, search: true,
rules: [ rules: [
{ {
required: true, required: true,
message: "请输入菜单名称", message: "请输入菜单名称",
trigger: "blur" trigger: "blur",
}
]
},
{
label: "路由地址",
prop: "path",
rules: [
{
required: true,
message: "请输入路由地址",
trigger: "blur"
}
]
},
{
label: "上级菜单",
prop: "parentId",
type: "tree",
dicData: [],
hide: true,
addDisabled: false,
props: {
label: "title"
}, },
rules: [ ],
{ },
required: false, {
message: "请选择上级菜单", label: "路由地址",
trigger: "click" prop: "path",
} rules: [
] {
}, required: true,
{ message: "请输入路由地址",
label: "菜单图标", trigger: "blur",
prop: "source", },
type: "icon", ],
slot: true, },
iconList: iconList, {
rules: [ label: "上级菜单",
{ prop: "parentId",
required: true, type: "tree",
message: "请输入菜单图标", dicData: [],
trigger: "click" hide: true,
} addDisabled: false,
] props: {
}, label: "title",
{
label: "菜单编号",
prop: "code",
search: true,
rules: [
{
required: true,
message: "请输入菜单编号",
trigger: "blur"
}
]
},
{
label: "菜单类型",
prop: "category",
type: "radio",
dicData: [
{
label: "菜单",
value: 1
},
{
label: "按钮",
value: 2
}
],
hide: true,
rules: [
{
required: true,
message: "请选择菜单类型",
trigger: "blur"
}
]
},
{
label: "菜单别名",
prop: "alias",
search: true,
rules: [
{
required: true,
message: "请输入菜单别名",
trigger: "blur"
}
]
},
{
label: "新窗口",
prop: "isOpen",
type: "radio",
disabled: false,
display: false,
dicData: [
{
label: "否",
value: 1
},
{
label: "是",
value: 2
}
],
value: 1,
rules: [
{
required: true,
message: "请选择新窗口打开",
trigger: "blur"
}
]
},
{
label: "菜单排序",
prop: "sort",
type: "number",
rules: [
{
required: true,
message: "请输入菜单排序",
trigger: "blur"
}
]
}, },
{ rules: [
label: "菜单备注", {
prop: "remark", required: false,
type: "textarea", message: "请选择上级菜单",
span: 24, trigger: "click",
minRows: 2, },
hide: true ],
} },
] {
}, label: "菜单图标",
data: [] prop: "source",
}; type: "icon",
}, slot: true,
watch: { iconList: iconList,
'form.category'() { rules: [
const category = func.toInt(this.form.category); {
this.$refs.crud.option.column.filter(item => { required: true,
if (item.prop === "path") { message: "请输入菜单图标",
item.rules[0].required = category === 1; trigger: "click",
} },
if (item.prop === 'isOpen') { ],
item.disabled = category === 2; },
} {
}); label: "菜单编号",
prop: "code",
search: true,
rules: [
{
required: true,
message: "请输入菜单编号",
trigger: "blur",
},
],
},
{
label: "菜单类型",
prop: "category",
type: "radio",
dicData: [
{
label: "菜单",
value: 1,
},
{
label: "按钮",
value: 2,
},
],
hide: true,
rules: [
{
required: true,
message: "请选择菜单类型",
trigger: "blur",
},
],
},
{
label: "菜单别名",
prop: "alias",
search: true,
rules: [
{
required: true,
message: "请输入菜单别名",
trigger: "blur",
},
],
},
{
label: "新窗口",
prop: "isOpen",
type: "radio",
disabled: false,
display: false,
dicData: [
{
label: "否",
value: 1,
},
{
label: "是",
value: 2,
},
],
value: 1,
rules: [
{
required: true,
message: "请选择新窗口打开",
trigger: "blur",
},
],
},
{
label: "菜单排序",
prop: "sort",
type: "number",
rules: [
{
required: true,
message: "请输入菜单排序",
trigger: "blur",
},
],
},
{
label: "菜单备注",
prop: "remark",
type: "textarea",
span: 24,
minRows: 2,
hide: true,
},
],
}, },
data: [],
};
},
watch: {
"form.category"() {
const category = func.toInt(this.form.category);
this.$refs.crud.option.column.filter((item) => {
if (item.prop === "path") {
item.rules[0].required = category === 1;
}
if (item.prop === "isOpen") {
item.disabled = category === 2;
}
});
}, },
computed: { },
...mapGetters(["userInfo", "permission"]), computed: {
permissionList() { ...mapGetters(["userInfo", "permission"]),
return { permissionList() {
addBtn: this.vaildData(this.permission.menu_add, false), return {
viewBtn: this.vaildData(this.permission.menu_view, false), addBtn: this.vaildData(this.permission.menu_add, false),
delBtn: this.vaildData(this.permission.menu_delete, false), viewBtn: this.vaildData(this.permission.menu_view, false),
editBtn: this.vaildData(this.permission.menu_edit, false) delBtn: this.vaildData(this.permission.menu_delete, false),
}; editBtn: this.vaildData(this.permission.menu_edit, false),
}, };
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(",");
}
}, },
methods: { ids() {
initData() { let ids = [];
getMenuTree().then(res => { this.selectionList.forEach((ele) => {
const column = this.findObject(this.option.column, "parentId"); ids.push(ele.id);
column.dicData = res.data.result; });
}); return ids.join(",");
}, },
handleAdd(row) { },
this.parentId = row.id; methods: {
initData() {
getMenuTree().then((res) => {
const column = this.findObject(this.option.column, "parentId"); const column = this.findObject(this.option.column, "parentId");
column.value = row.id; column.dicData = res.data.result;
column.addDisabled = true; });
this.$refs.crud.rowAdd(); },
}, handleAdd(row) {
rowSave(row, done, loading) { this.parentId = row.id;
add(row).then((res) => { const column = this.findObject(this.option.column, "parentId");
column.value = row.id;
column.addDisabled = true;
this.$refs.crud.rowAdd();
},
rowSave(row, done, loading) {
add(row).then(
(res) => {
// //
const data = res.data.result; const data = res.data.result;
row.id = data.id; row.id = data.id;
this.$message({ this.$message({
type: "success", type: "success",
message: "操作成功!" message: "操作成功!",
}); });
// //
done(row); done(row);
}, error => { },
(error) => {
window.console.log(error); window.console.log(error);
loading(); loading();
}); }
}, );
rowUpdate(row, index, done, loading) { },
update(row).then(() => { rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.$message({ this.$message({
type: "success", type: "success",
message: "操作成功!" message: "操作成功!",
}); });
// //
done(row); done(row);
}, error => { },
(error) => {
window.console.log(error); window.console.log(error);
loading(); loading();
});
},
rowDel(row, index, done) {
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.$message({
type: "success",
message: "操作成功!"
});
//
done(row);
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning("请选择至少一条数据");
return;
} }
this.$confirm("确定将选择数据删除?", { );
confirmButtonText: "确定", },
cancelButtonText: "取消", rowDel(row, index, done) {
type: "warning" this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
return remove(row.id);
}) })
.then(() => { .then(() => {
return remove(this.ids); this.$message({
}) type: "success",
.then(() => { message: "操作成功!",
//
this.data = [];
this.parentId = 0;
this.$refs.crud.refreshTable();
this.$refs.crud.toggleSelection();
//
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
}); });
}, //
searchReset() { done(row);
this.query = {}; });
this.parentId = 0; },
this.onLoad(this.page); handleDelete() {
}, if (this.selectionList.length === 0) {
searchChange(params, done) { this.$message.warning("请选择至少一条数据");
this.query = params; return;
this.parentId = ''; }
this.page.currentPage = 1; this.$confirm("确定将选择数据删除?", {
this.onLoad(this.page, params); confirmButtonText: "确定",
done(); cancelButtonText: "取消",
}, type: "warning",
selectionChange(list) { })
this.selectionList = list; .then(() => {
}, return remove(this.ids);
selectionClear() { })
this.selectionList = []; .then(() => {
this.$refs.crud.toggleSelection(); //
}, this.data = [];
beforeOpen(done, type) { this.parentId = 0;
if (["add", "edit"].includes(type)) { this.$refs.crud.refreshTable();
this.initData(); this.$refs.crud.toggleSelection();
} //
if (["edit", "view"].includes(type)) { this.onLoad(this.page);
getMenu(this.form.id).then(res => { this.$message({
this.form = res.data.data; type: "success",
message: "操作成功!",
}); });
}
done();
},
beforeClose(done) {
this.parentId = "";
const column = this.findObject(this.option.column, "parentId");
column.value = "";
column.addDisabled = false;
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
this.data = res.data.result;
this.loading = false;
this.selectionClear();
}); });
}, },
treeLoad(tree, treeNode, resolve) { searchReset() {
const parentId = tree.id; this.query = {};
getLazyList(parentId).then(res => { this.parentId = 0;
this.onLoad(this.page);
resolve(res.data.result); },
searchChange(params, done) {
this.query = params;
this.parentId = "";
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
beforeOpen(done, type) {
if (["add", "edit"].includes(type)) {
this.initData();
}
if (["edit", "view"].includes(type)) {
getMenu(this.form.id).then((res) => {
this.form = res.data.data;
}); });
} }
} done();
}; },
beforeClose(done) {
this.parentId = "";
const column = this.findObject(this.option.column, "parentId");
column.value = "";
column.addDisabled = false;
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getLazyList(this.parentId, Object.assign(params, this.query)).then(
(res) => {
this.data = res.data.result;
this.loading = false;
this.selectionClear();
}
);
},
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
getLazyList(parentId).then((res) => {
resolve(res.data.result);
});
},
},
};
</script> </script>
<style> <style></style>
</style>

Loading…
Cancel
Save