|
|
|
@ -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 { constantRouterMap } from "../../router";
|
|
|
|
|
import {constantRouterMap} from "../../router";
|
|
|
|
|
import {
|
|
|
|
|
getToken,
|
|
|
|
|
setToken,
|
|
|
|
@ -16,8 +16,8 @@ import {
|
|
|
|
|
removeCompanyName,
|
|
|
|
|
} from "../../utils/auth";
|
|
|
|
|
// import { $NOT_NETWORK } from '../../utils/errorCode'
|
|
|
|
|
import { Message } from "element-ui";
|
|
|
|
|
import {RECEIVE_LOCINVCODE, RECEIVE_LOCSUBINVCODE} from "../mutation-types";
|
|
|
|
|
import {Message} from "element-ui";
|
|
|
|
|
import {RECEIVE_LOCINVCODE, RECEIVE_LOCINVNAME, RECEIVE_LOCSUBINVCODE, RECEIVE_LOCSUBINVNAME} from "../mutation-types";
|
|
|
|
|
|
|
|
|
|
// initial state
|
|
|
|
|
const state = {
|
|
|
|
@ -28,10 +28,12 @@ const state = {
|
|
|
|
|
token: getToken(), // 登录token
|
|
|
|
|
authRules: [], // 权限列表
|
|
|
|
|
routers: constantRouterMap, // 路由列表
|
|
|
|
|
customerId:getCustomerId(),
|
|
|
|
|
companyName:getCompanyName(),
|
|
|
|
|
locInvCode:"",
|
|
|
|
|
locSubInvCode:""
|
|
|
|
|
customerId: getCustomerId(),
|
|
|
|
|
companyName: getCompanyName(),
|
|
|
|
|
locInvCode: "",
|
|
|
|
|
locSubInvCode: "",
|
|
|
|
|
locInvName: "",
|
|
|
|
|
locSubInvName: ""
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// getters
|
|
|
|
@ -43,23 +45,25 @@ const getters = {
|
|
|
|
|
token: state => state.token,
|
|
|
|
|
authRules: state => state.authRules,
|
|
|
|
|
routers: state => state.routers,
|
|
|
|
|
customerId:state => state.customerId,
|
|
|
|
|
companyName:state => state.companyName,
|
|
|
|
|
locInvCode:state => state.locInvCode,
|
|
|
|
|
locSubInvCode:state => state.locSubInvCode,
|
|
|
|
|
customerId: state => state.customerId,
|
|
|
|
|
companyName: state => state.companyName,
|
|
|
|
|
locInvCode: state => state.locInvCode,
|
|
|
|
|
locSubInvCode: state => state.locSubInvCode,
|
|
|
|
|
locInvName: state => state.locInvName,
|
|
|
|
|
locSubInvName: state => state.locSubInvName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
|
const actions = {
|
|
|
|
|
// 用户名登录
|
|
|
|
|
loginName({ commit }, userInfo) {
|
|
|
|
|
loginName({commit}, userInfo) {
|
|
|
|
|
const userName = userInfo.userName ? userInfo.userName.trim() : "";
|
|
|
|
|
const pwd = userInfo.pwd ? userInfo.pwd : "";
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
loginName(userName, pwd)
|
|
|
|
|
.then(response => {
|
|
|
|
|
console.log(response);
|
|
|
|
|
if (response.code!=20000) {
|
|
|
|
|
if (response.code != 20000) {
|
|
|
|
|
Message({
|
|
|
|
|
message: response.message,
|
|
|
|
|
type: "error",
|
|
|
|
@ -80,7 +84,7 @@ const actions = {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
userInfo({ commit }) {
|
|
|
|
|
userInfo({commit}) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
userInfo()
|
|
|
|
|
.then(response => {
|
|
|
|
@ -102,7 +106,7 @@ const actions = {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 登出
|
|
|
|
|
loginOut({ commit }) {
|
|
|
|
|
loginOut({commit}) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
logout()
|
|
|
|
|
.then(() => {
|
|
|
|
@ -120,7 +124,7 @@ const actions = {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 前端 登出
|
|
|
|
|
fedLogout({ commit }) {
|
|
|
|
|
fedLogout({commit}) {
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
commit(types.RECEIVE_ADMIN_ID, "");
|
|
|
|
|
commit(types.RECEIVE_ADMIN_TOKEN, "");
|
|
|
|
@ -136,8 +140,8 @@ const actions = {
|
|
|
|
|
* @param data
|
|
|
|
|
* @returns {Promise}
|
|
|
|
|
*/
|
|
|
|
|
filterRouter({ commit }, data) {
|
|
|
|
|
const { accessedRouters } = data;
|
|
|
|
|
filterRouter({commit}, data) {
|
|
|
|
|
const {accessedRouters} = data;
|
|
|
|
|
if (accessedRouters && accessedRouters.length > 0) {
|
|
|
|
|
commit(types.RECEIVE_ROUTERS, accessedRouters);
|
|
|
|
|
}
|
|
|
|
@ -201,6 +205,12 @@ const mutations = {
|
|
|
|
|
[types.RECEIVE_LOCSUBINVCODE](state, locSubInvCode) {
|
|
|
|
|
state.locSubInvCode = locSubInvCode;
|
|
|
|
|
},
|
|
|
|
|
[types.RECEIVE_LOCINVNAME](state, locInvName) {
|
|
|
|
|
state.locInvName = locInvName;
|
|
|
|
|
},
|
|
|
|
|
[types.RECEIVE_LOCSUBINVNAME](state, locSubInvName) {
|
|
|
|
|
state.locSubInvName = locSubInvName;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|