|
|
@ -1,6 +1,6 @@
|
|
|
|
import { userInfo, loginName, logout } from "../../api/auth/login";
|
|
|
|
import {userInfo, loginName, logout} from "../../api/auth/login";
|
|
|
|
import * as types from "../mutation-types";
|
|
|
|
import * as types from "../mutation-types";
|
|
|
|
import { constantRouterMap } from "../../router";
|
|
|
|
import {constantRouterMap} from "../../router";
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
getToken,
|
|
|
|
getToken,
|
|
|
|
setToken,
|
|
|
|
setToken,
|
|
|
@ -10,20 +10,22 @@ import {
|
|
|
|
removeAdminId
|
|
|
|
removeAdminId
|
|
|
|
} from "../../utils/auth";
|
|
|
|
} from "../../utils/auth";
|
|
|
|
// import { $NOT_NETWORK } from '../../utils/errorCode'
|
|
|
|
// import { $NOT_NETWORK } from '../../utils/errorCode'
|
|
|
|
import { Message } from "element-ui";
|
|
|
|
import {Message} from "element-ui";
|
|
|
|
import {RECEIVE_ADMIN_EMPLOY_NAME, RECEIVE_LOCINVCODE, RECEIVE_LOCSUBINVCODE} from "../mutation-types";
|
|
|
|
import {RECEIVE_ADMIN_EMPLOY_NAME} from "../mutation-types";
|
|
|
|
|
|
|
|
|
|
|
|
// initial state
|
|
|
|
// initial state
|
|
|
|
const state = {
|
|
|
|
const state = {
|
|
|
|
adminId: getAdminId(), // id
|
|
|
|
adminId: getAdminId(), // id
|
|
|
|
userName: "", // 昵称
|
|
|
|
userName: "", // 昵称
|
|
|
|
employeeName:null,
|
|
|
|
employeeName: null,
|
|
|
|
avatar: "", // 头像
|
|
|
|
avatar: "", // 头像
|
|
|
|
token: getToken(), // 登录token
|
|
|
|
token: getToken(), // 登录token
|
|
|
|
authRules: [], // 权限列表
|
|
|
|
authRules: [], // 权限列表
|
|
|
|
routers: constantRouterMap, // 路由列表
|
|
|
|
routers: constantRouterMap, // 路由列表
|
|
|
|
locInvCode:"",
|
|
|
|
locInvCode: "",
|
|
|
|
locSubInvCode:""
|
|
|
|
locSubInvCode: "",
|
|
|
|
|
|
|
|
locInvName: "",
|
|
|
|
|
|
|
|
locSubInvName: ""
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// getters
|
|
|
|
// getters
|
|
|
@ -35,21 +37,23 @@ const getters = {
|
|
|
|
token: state => state.token,
|
|
|
|
token: state => state.token,
|
|
|
|
authRules: state => state.authRules,
|
|
|
|
authRules: state => state.authRules,
|
|
|
|
routers: state => state.routers,
|
|
|
|
routers: state => state.routers,
|
|
|
|
locInvCode:state => state.locInvCode,
|
|
|
|
locInvCode: state => state.locInvCode,
|
|
|
|
locSubInvCode:state => state.locSubInvCode,
|
|
|
|
locSubInvCode: state => state.locSubInvCode,
|
|
|
|
|
|
|
|
locInvName: state => state.locInvName,
|
|
|
|
|
|
|
|
locSubInvName: state => state.locSubInvName,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
// actions
|
|
|
|
const actions = {
|
|
|
|
const actions = {
|
|
|
|
// 用户名登录
|
|
|
|
// 用户名登录
|
|
|
|
loginName({ commit }, userInfo) {
|
|
|
|
loginName({commit}, userInfo) {
|
|
|
|
const userName = userInfo.userName ? userInfo.userName.trim() : "";
|
|
|
|
const userName = userInfo.userName ? userInfo.userName.trim() : "";
|
|
|
|
const pwd = userInfo.pwd ? userInfo.pwd : "";
|
|
|
|
const pwd = userInfo.pwd ? userInfo.pwd : "";
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
loginName(userName, pwd)
|
|
|
|
loginName(userName, pwd)
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
|
console.log(response);
|
|
|
|
console.log(response);
|
|
|
|
if (response.code!=20000) {
|
|
|
|
if (response.code != 20000) {
|
|
|
|
Message({
|
|
|
|
Message({
|
|
|
|
message: response.message,
|
|
|
|
message: response.message,
|
|
|
|
type: "error",
|
|
|
|
type: "error",
|
|
|
@ -68,7 +72,7 @@ const actions = {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
userInfo({ commit }) {
|
|
|
|
userInfo({commit}) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
userInfo()
|
|
|
|
userInfo()
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
@ -77,6 +81,7 @@ const actions = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const data = response.data || {};
|
|
|
|
const data = response.data || {};
|
|
|
|
commit(types.RECEIVE_ADMIN_NAME, data.userName);
|
|
|
|
commit(types.RECEIVE_ADMIN_NAME, data.userName);
|
|
|
|
|
|
|
|
commit(types.RECEIVE_ADMIN_EMPLOY_NAME, data.employeeName);
|
|
|
|
commit(types.RECEIVE_ADMIN_AVATAR, data.avatar);
|
|
|
|
commit(types.RECEIVE_ADMIN_AVATAR, data.avatar);
|
|
|
|
commit(types.RECEIVE_ADMIN_AUTH_RULES, data.authRules);
|
|
|
|
commit(types.RECEIVE_ADMIN_AUTH_RULES, data.authRules);
|
|
|
|
|
|
|
|
|
|
|
@ -88,7 +93,7 @@ const actions = {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 登出
|
|
|
|
// 登出
|
|
|
|
loginOut({ commit }) {
|
|
|
|
loginOut({commit}) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
logout()
|
|
|
|
logout()
|
|
|
|
.then(() => {
|
|
|
|
.then(() => {
|
|
|
@ -97,6 +102,8 @@ const actions = {
|
|
|
|
commit(types.RECEIVE_ADMIN_AUTH_RULES, []);
|
|
|
|
commit(types.RECEIVE_ADMIN_AUTH_RULES, []);
|
|
|
|
commit(types.RECEIVE_LOCINVCODE, "");
|
|
|
|
commit(types.RECEIVE_LOCINVCODE, "");
|
|
|
|
commit(types.RECEIVE_LOCSUBINVCODE, "");
|
|
|
|
commit(types.RECEIVE_LOCSUBINVCODE, "");
|
|
|
|
|
|
|
|
commit(types.RECEIVE_LOCINVNAME, "");
|
|
|
|
|
|
|
|
commit(types.RECEIVE_LOCSUBINVNAME, "");
|
|
|
|
resolve();
|
|
|
|
resolve();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
.catch(error => {
|
|
|
@ -106,13 +113,15 @@ const actions = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 前端 登出
|
|
|
|
// 前端 登出
|
|
|
|
fedLogout({ commit }) {
|
|
|
|
fedLogout({commit}) {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
commit(types.RECEIVE_ADMIN_ID, "");
|
|
|
|
commit(types.RECEIVE_ADMIN_ID, "");
|
|
|
|
commit(types.RECEIVE_ADMIN_TOKEN, "");
|
|
|
|
commit(types.RECEIVE_ADMIN_TOKEN, "");
|
|
|
|
commit(types.RECEIVE_ADMIN_AUTH_RULES, []);
|
|
|
|
commit(types.RECEIVE_ADMIN_AUTH_RULES, []);
|
|
|
|
commit(types.RECEIVE_LOCINVCODE, "");
|
|
|
|
commit(types.RECEIVE_LOCINVCODE, "");
|
|
|
|
commit(types.RECEIVE_LOCSUBINVCODE, "");
|
|
|
|
commit(types.RECEIVE_LOCSUBINVCODE, "");
|
|
|
|
|
|
|
|
commit(types.RECEIVE_LOCINVNAME, "");
|
|
|
|
|
|
|
|
commit(types.RECEIVE_LOCSUBINVNAME, "");
|
|
|
|
resolve();
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -122,8 +131,8 @@ const actions = {
|
|
|
|
* @param data
|
|
|
|
* @param data
|
|
|
|
* @returns {Promise}
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
filterRouter({ commit }, data) {
|
|
|
|
filterRouter({commit}, data) {
|
|
|
|
const { accessedRouters } = data;
|
|
|
|
const {accessedRouters} = data;
|
|
|
|
if (accessedRouters && accessedRouters.length > 0) {
|
|
|
|
if (accessedRouters && accessedRouters.length > 0) {
|
|
|
|
commit(types.RECEIVE_ROUTERS, accessedRouters);
|
|
|
|
commit(types.RECEIVE_ROUTERS, accessedRouters);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -151,6 +160,9 @@ const mutations = {
|
|
|
|
[types.RECEIVE_ADMIN_NAME](state, userName) {
|
|
|
|
[types.RECEIVE_ADMIN_NAME](state, userName) {
|
|
|
|
state.userName = userName;
|
|
|
|
state.userName = userName;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[types.RECEIVE_ADMIN_EMPLOY_NAME](state, employeeName) {
|
|
|
|
|
|
|
|
state.employeeName = employeeName;
|
|
|
|
|
|
|
|
},
|
|
|
|
[types.RECEIVE_ADMIN_AVATAR](state, avatar) {
|
|
|
|
[types.RECEIVE_ADMIN_AVATAR](state, avatar) {
|
|
|
|
state.avatar = avatar;
|
|
|
|
state.avatar = avatar;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -167,6 +179,13 @@ const mutations = {
|
|
|
|
[types.RECEIVE_LOCSUBINVCODE](state, locSubInvCode) {
|
|
|
|
[types.RECEIVE_LOCSUBINVCODE](state, locSubInvCode) {
|
|
|
|
state.locSubInvCode = locSubInvCode;
|
|
|
|
state.locSubInvCode = locSubInvCode;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[types.RECEIVE_LOCINVNAME](state, locInvName) {
|
|
|
|
|
|
|
|
state.locInvName = locInvName;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
[types.RECEIVE_LOCSUBINVNAME](state, locSubInvName) {
|
|
|
|
|
|
|
|
state.locSubInvName = locSubInvName;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|