mirror of
https://github.com/chillzhuang/Saber.git
synced 2024-11-22 18:39:32 +08:00
feat notice permission
This commit is contained in:
parent
61f880780b
commit
f9ea716287
@ -1,5 +1,5 @@
|
|||||||
import request from '@/router/axios';
|
import request from '@/router/axios';
|
||||||
import {baseUrl} from '@/config/env';
|
import { baseUrl } from '@/config/env';
|
||||||
|
|
||||||
export const loginByUsername = (account, password, type) => request({
|
export const loginByUsername = (account, password, type) => request({
|
||||||
url: 'api/blade-auth/token',
|
url: 'api/blade-auth/token',
|
||||||
@ -9,11 +9,16 @@ export const loginByUsername = (account, password, type) => request({
|
|||||||
password,
|
password,
|
||||||
type
|
type
|
||||||
},
|
},
|
||||||
meta:{
|
meta: {
|
||||||
isSerialize:true,
|
isSerialize: true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const getButtons = () => request({
|
||||||
|
url: 'api/blade-system/menu/buttons',
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
|
||||||
export const getUserInfo = () => request({
|
export const getUserInfo = () => request({
|
||||||
url: baseUrl + '/user/getUserInfo',
|
url: baseUrl + '/user/getUserInfo',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
|
@ -3,7 +3,7 @@ import { setStore, getStore } from '@/util/store'
|
|||||||
import { isURL } from '@/util/validate'
|
import { isURL } from '@/util/validate'
|
||||||
import { deepClone } from '@/util/util'
|
import { deepClone } from '@/util/util'
|
||||||
import webiste from '@/config/website'
|
import webiste from '@/config/website'
|
||||||
import { loginByUsername, getUserInfo, getMenu, getTopMenu, logout, refeshToken } from '@/api/user'
|
import { loginByUsername, getUserInfo, getMenu, getTopMenu, logout, refeshToken, getButtons } from '@/api/user'
|
||||||
|
|
||||||
|
|
||||||
function addPath(ele, first) {
|
function addPath(ele, first) {
|
||||||
@ -29,7 +29,7 @@ function addPath(ele, first) {
|
|||||||
const user = {
|
const user = {
|
||||||
state: {
|
state: {
|
||||||
userInfo: getStore({ name: 'userInfo' }) || [],
|
userInfo: getStore({ name: 'userInfo' }) || [],
|
||||||
permission: {},
|
permission: getStore({ name: 'permission' }) || {},
|
||||||
roles: [],
|
roles: [],
|
||||||
menu: getStore({ name: 'menu' }) || [],
|
menu: getStore({ name: 'menu' }) || [],
|
||||||
menuAll: [],
|
menuAll: [],
|
||||||
@ -37,7 +37,7 @@ const user = {
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
//根据用户名登录
|
//根据用户名登录
|
||||||
LoginByUsername({ commit }, userInfo) {
|
LoginByUsername({ commit, dispatch }, userInfo) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
loginByUsername(userInfo.username, userInfo.password, userInfo.type).then(res => {
|
loginByUsername(userInfo.username, userInfo.password, userInfo.type).then(res => {
|
||||||
const data = res.data.data;
|
const data = res.data.data;
|
||||||
@ -45,6 +45,16 @@ const user = {
|
|||||||
commit('SET_USERIFNO', data);
|
commit('SET_USERIFNO', data);
|
||||||
commit('DEL_ALL_TAG');
|
commit('DEL_ALL_TAG');
|
||||||
commit('CLEAR_LOCK');
|
commit('CLEAR_LOCK');
|
||||||
|
dispatch('GetButtons');
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
GetButtons({ commit }) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
getButtons().then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
commit('SET_PERMISSION', data);
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -66,7 +76,6 @@ const user = {
|
|||||||
getUserInfo().then((res) => {
|
getUserInfo().then((res) => {
|
||||||
const data = res.data.data;
|
const data = res.data.data;
|
||||||
commit('SET_ROLES', data.roles);
|
commit('SET_ROLES', data.roles);
|
||||||
commit('SET_PERMISSION', data.permission)
|
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
reject(err);
|
reject(err);
|
||||||
@ -157,10 +166,27 @@ const user = {
|
|||||||
state.roles = roles;
|
state.roles = roles;
|
||||||
},
|
},
|
||||||
SET_PERMISSION: (state, permission) => {
|
SET_PERMISSION: (state, permission) => {
|
||||||
|
let result = [];
|
||||||
|
function getCode(list) {
|
||||||
|
list.forEach(ele => {
|
||||||
|
if (typeof (ele) === 'object') {
|
||||||
|
const chiildren = ele.children;
|
||||||
|
const code = ele.code;
|
||||||
|
if (chiildren) {
|
||||||
|
getCode(chiildren)
|
||||||
|
} else {
|
||||||
|
result.push(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
getCode(permission);
|
||||||
state.permission = {};
|
state.permission = {};
|
||||||
permission.forEach(ele => {
|
result.forEach(ele => {
|
||||||
state.permission[ele] = true;
|
state.permission[ele] = true;
|
||||||
});
|
});
|
||||||
|
setStore({ name: 'permission', content: state.permission, type: 'session' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
:page="page"
|
:page="page"
|
||||||
@row-del="rowDel"
|
@row-del="rowDel"
|
||||||
v-model="form"
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
@row-update="rowUpdate"
|
@row-update="rowUpdate"
|
||||||
@row-save="rowSave"
|
@row-save="rowSave"
|
||||||
:before-open="beforeOpen"
|
:before-open="beforeOpen"
|
||||||
@ -17,6 +18,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
plain
|
plain
|
||||||
|
v-if="permission.notice_delete"
|
||||||
@click="handleDelete">删 除</el-button>
|
@click="handleDelete">删 除</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template slot-scope="{row}"
|
<template slot-scope="{row}"
|
||||||
@ -29,6 +31,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getList, remove, update, add, getNotice } from "@/api/dept/notice";
|
import { getList, remove, update, add, getNotice } from "@/api/dept/notice";
|
||||||
|
import { mapGetters } from "vuex";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -84,6 +87,15 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters(["permission"]),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.permission.notice_add,
|
||||||
|
viewBtn: this.permission.notice_view,
|
||||||
|
delBtn: this.permission.notice_delete,
|
||||||
|
editBtn: this.permission.notice_edit
|
||||||
|
};
|
||||||
|
},
|
||||||
ids() {
|
ids() {
|
||||||
let ids = [];
|
let ids = [];
|
||||||
this.selectionList.forEach(ele => {
|
this.selectionList.forEach(ele => {
|
||||||
|
Loading…
Reference in New Issue
Block a user