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

人员显示bug处理

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