Commit 7edeaf19 authored by 周远喜's avatar 周远喜

数据字典修改,返回数据字典对象集合

parent 3ff578c0
...@@ -3,7 +3,7 @@ import Api from '@/plugins/request' ...@@ -3,7 +3,7 @@ import Api from '@/plugins/request'
// import Mock from 'mockjs' // import Mock from 'mockjs'
export const state = () => ({ export const state = () => ({
counter: 0, counter: 0,
dictionary: new Map(), //所有字典项 dictionary: [], //所有字典项
userMap: new Map(), //所有用户缓存; userMap: new Map(), //所有用户缓存;
userNameMap: new Map(), //所有用户名称缓存; userNameMap: new Map(), //所有用户名称缓存;
departmentsMap: new Map(), //部门缓存; departmentsMap: new Map(), //部门缓存;
...@@ -25,10 +25,11 @@ export const getters = { ...@@ -25,10 +25,11 @@ export const getters = {
dictionaryByKey: (state) => (key) => { dictionaryByKey: (state) => (key) => {
let result = []; let result = [];
if (state && state.dictionary) { if (state && state.dictionary) {
let items = state.dictionary.get(key); let items = state.dictionary.filter(u=>{
if (items) { return u.code===key
// console.info("items",items) });
return items; if (items.length>0) {
return items[0].items;
} }
} }
...@@ -36,12 +37,11 @@ export const getters = { ...@@ -36,12 +37,11 @@ export const getters = {
}, },
dictionaryByCode: (state) => (key, code) => { dictionaryByCode: (state) => (key, code) => {
let result = null; let result = null;
let items = state.dictionary.get(key); let items = state.dictionary.filter(u=>{
if (items) { return u.code===key
// console.info("items",items) });
return items.filter(u => { if (items.length>0) {
return u.code == code return items[0];
})[0];
} }
return result; return result;
}, },
...@@ -167,18 +167,12 @@ export const actions = { ...@@ -167,18 +167,12 @@ export const actions = {
async loadDictionary({ async loadDictionary({
commit commit
}) { }) {
let url = `${systemUrl}/Dictionary/GetAll` let url = `${systemUrl}/Dictionary/getallanditems`
let { let {
result result
} = await Api.get(url); } = await Api.get(url);
var map = new Map();
commit("setDictionary", result);
for (const key in result) {
if (result.hasOwnProperty(key)) {
map.set(key, result[key])
}
}
commit("setDictionary", map);
let r = await Api.get(`${systemUrl}/user/getuserlist`); let r = await Api.get(`${systemUrl}/user/getuserlist`);
var umap = new Map(); var umap = new Map();
......
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