Commit 2d161fd2 authored by 周远喜's avatar 周远喜

人员显示bug处理

parent 31aeeb36
......@@ -24,7 +24,6 @@ export default {
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
await store.dispatch("loadUsers");//加载缓存的用户
},
created() {
// 处理路由 得到每一级的路由设置
......
......@@ -194,6 +194,7 @@ export default {
props: {},
async fetch({ store, params }) {
await store.dispatch('loadDictionary') // 加载数据字典
// await store.dispatch("loadUsers");//加载缓存的用户
},
created() {
this.currentUserId=this.$store.state.userInfo.userId
......
<template>
<div class="container">
<iview/>
<iview />
</div>
</template>
<script>
import iview from './crm/statistical/index.vue'
import iview from "./crm/statistical/index.vue";
export default {
components: {
iview
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
await store.dispatch("loadUsers"); //加载缓存的用户
}
}
};
</script>
\ No newline at end of file
import createVuexAlong from 'vuex-along'
import Api from '@/plugins/request'
export const state=()=>({
counter:0,
dictionary: new Map(),//所有字典项
userMap:new Map(),//所有用户缓存;
userInfo:{
userId:0,
userName:""
},
cart:[],
count: 0,
countAps:0,//aps排产
countAi:0,//智能排产
countAll:0,//整机排产
countRun:0,//流水排产
export const state = () => ({
counter: 0,
dictionary: new Map(), //所有字典项
userMap: new Map(), //所有用户缓存;
userInfo: {
userId: 0,
userName: ""
},
cart: [],
count: 0,
countAps: 0, //aps排产
countAi: 0, //智能排产
countAll: 0, //整机排产
countRun: 0, //流水排产
})
export const getters={
export const getters = {
dictionaryByKey: (state) => (key) => {
let result = [];
let items = state.dictionary.get(key);
......@@ -25,69 +25,83 @@ export const getters={
}
return result;
},
getUser:(state)=>key=>{
getUser: (state) => key => {
// debugger
if(state.userMap&&state.userMap.get){
if (state.userMap && state.userMap.get) {
return state.userMap.get(key);
}
}
}
export const mutations={
increment(state){
state.counter++
},
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
// sessionStorage.setItem("userInfo", JSON.stringify(userInfo));
// sessionStorage.setItem("token", userInfo.token);
},
setUsers(state,users){
state.userMap=users;
},
addUser(state,user){
state.userMap.push(user);
},
setDictionary(state, dictionary) {
state.dictionary = dictionary;
},
setCart(state, cart) {
state.cart = cart;
},
setCartCount(state, count) {
state.count = count;
},
setCountAps(state, count) {//设置aps排产数量
state.countAps = count;
},
setCountAi(state, count) {//设置智能排产数量
state.countAi = count;
},
setCountAll(state, count) {//设置整机排产数量
state.countAll = count;
},
setCountRun(state, count) {//设置流水排产数量
state.countRun = count;
}
export const mutations = {
increment(state) {
state.counter++
},
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
// sessionStorage.setItem("userInfo", JSON.stringify(userInfo));
// sessionStorage.setItem("token", userInfo.token);
},
setUsers(state, users) {
state.userMap = users;
},
addUser(state, user) {
state.userMap.push(user);
},
setDictionary(state, dictionary) {
state.dictionary = dictionary;
},
setCart(state, cart) {
state.cart = cart;
},
setCartCount(state, count) {
state.count = count;
},
setCountAps(state, count) { //设置aps排产数量
state.countAps = count;
},
setCountAi(state, count) { //设置智能排产数量
state.countAi = count;
},
setCountAll(state, count) { //设置整机排产数量
state.countAll = count;
},
setCountRun(state, count) { //设置流水排产数量
state.countRun = count;
}
}
export const actions={
async loadUser({commit},key){
let { result } = await Api.get(`${systemUrl}/user/getuser`,{id:key});
console.warn("result",result)
commit("addUser",result);
export const actions = {
async loadUser({
commit
}, key) {
let {
result
} = await Api.get(`${systemUrl}/user/getuser`, {
id: key
});
console.warn("result", result)
commit("addUser", result);
},
async loadUsers({commit}){
let { result } = await Api.get(`${systemUrl}/user/getuserlist`);
var map=new Map();
result.map(u=>{
map.set(u.id,u);
async loadUsers({
commit
}) {
let {
result
} = await Api.get(`${systemUrl}/user/getuserlist`);
var map = new Map();
result.map(u => {
map.set(u.id, u);
});
commit("setUsers",map)
commit("setUsers", map)
},
async loadDictionary({ commit }) {
async loadDictionary({
commit
}) {
let url = `${systemUrl}/Dictionary/GetAll`
let { result } = await Api.get(url);
let {
result
} = await Api.get(url);
var map = new Map();
......@@ -97,23 +111,30 @@ export const actions={
}
}
commit("setDictionary", map);
let r = await Api.get(`${systemUrl}/user/getuserlist`);
var umap = new Map();
r.result.map(u => {
umap.set(u.id, u);
});
commit("setUsers", umap)
}
}
export const plugins= [
createVuexAlong({
// 设置保存的集合名字,避免同站点下的多项目数据冲突
name: "hyhmes",
local: {
list: ["hyhmes"],
// 过滤模块 ma 数据, 将其他的存入 localStorage
isFilter: true,
},
session: {
// 保存模块 ma 中的 a1 到 sessionStorage
list: ["hyhmes.session"],
},
}),
]
//设置 strict 为不严格模式,即可在actions中修改state
export const strict=false;
\ No newline at end of file
export const plugins = [
createVuexAlong({
// 设置保存的集合名字,避免同站点下的多项目数据冲突
name: "hyhmes",
local: {
list: ["hyhmes"],
// 过滤模块 ma 数据, 将其他的存入 localStorage
isFilter: true,
},
session: {
// 保存模块 ma 中的 a1 到 sessionStorage
list: ["hyhmes.session"],
},
}),
]
//设置 strict 为不严格模式,即可在actions中修改state
export const strict = false;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment