Commit bffa24d0 authored by renjintao's avatar renjintao

resource/cart

parent 55bde781
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</Col> </Col>
<Col span="7"> <Col span="7">
<FormItem label="领料人" style="width:100%" prop="customerId"> <FormItem label="领料人" style="width:100%" prop="customerId">
<UserSelect ref="userSelected" v-model="resource.customerId" :type="1" /> <UserSelect ref="userSelected" v-model="resource.customerId" :type="0" />
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
......
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:[],//所有用户缓存; userMap: [], //所有用户缓存;
userInfo:{ userInfo: {
userId:0, userId: 0,
userName:"" userName: ""
} },
cart:[],
count: 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);
...@@ -19,7 +21,7 @@ export const getters={ ...@@ -19,7 +21,7 @@ export const getters={
} }
return result; return result;
}, },
getUser:state=>key=>{ getUser: state => key => {
// try{ // try{
// if(state.userMap.has(key)){ // if(state.userMap.has(key)){
// return state.userMap.get(key); // return state.userMap.get(key);
...@@ -27,41 +29,59 @@ export const getters={ ...@@ -27,41 +29,59 @@ export const getters={
// }catch(e){ // }catch(e){
// console.log(e); // console.log(e);
// } // }
let user=state.userMap.filter(u=>{return u.id==key}); let user = state.userMap.filter(u => {
if(user.length>0){ return u.id == key
});
if (user.length > 0) {
return user[0] return user[0]
}else{ } else {
return null; return null;
} }
} }
} }
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);
}, },
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) {
state.cart = cart;
},
setCartCount(state, count) {
state.count = count;
}
} }
export const actions={ export const actions = {
async loadUser({commit},key){ async loadUser({
commit
let { result } = await this.$api.get(`${systemUrl}/user/getuser`,{id:key}); }, key) {
console.warn("result",result)
commit("addUser",result); let {
result
} = await this.$api.get(`${systemUrl}/user/getuser`, {
id: key
});
console.warn("result", result)
commit("addUser", result);
}, },
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();
...@@ -74,20 +94,20 @@ export const actions={ ...@@ -74,20 +94,20 @@ export const actions={
} }
} }
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