Commit bffa24d0 authored by renjintao's avatar renjintao

resource/cart

parent 55bde781
......@@ -20,7 +20,7 @@
</Col>
<Col span="7">
<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>
</Col>
</Row>
......
import createVuexAlong from 'vuex-along'
import Api from '@/plugins/request'
export const state=()=>({
counter:0,
dictionary: new Map(),//所有字典项
userMap:[],//所有用户缓存;
userInfo:{
userId:0,
userName:""
}
export const state = () => ({
counter: 0,
dictionary: new Map(), //所有字典项
userMap: [], //所有用户缓存;
userInfo: {
userId: 0,
userName: ""
},
cart:[],
count: 0,
})
export const getters={
export const getters = {
dictionaryByKey: (state) => (key) => {
let result = [];
let items = state.dictionary.get(key);
......@@ -19,7 +21,7 @@ export const getters={
}
return result;
},
getUser:state=>key=>{
getUser: state => key => {
// try{
// if(state.userMap.has(key)){
// return state.userMap.get(key);
......@@ -27,41 +29,59 @@ export const getters={
// }catch(e){
// console.log(e);
// }
let user=state.userMap.filter(u=>{return u.id==key});
if(user.length>0){
let user = state.userMap.filter(u => {
return u.id == key
});
if (user.length > 0) {
return user[0]
}else{
} else {
return null;
}
}
}
export const mutations={
increment(state){
state.counter++
},
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
// sessionStorage.setItem("userInfo", JSON.stringify(userInfo));
// sessionStorage.setItem("token", userInfo.token);
},
addUser(state,user){
state.userMap.push(user);
},
setDictionary(state, dictionary) {
state.dictionary = dictionary;
},
export const mutations = {
increment(state) {
state.counter++
},
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
// sessionStorage.setItem("userInfo", JSON.stringify(userInfo));
// sessionStorage.setItem("token", userInfo.token);
},
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;
}
}
export const actions={
async loadUser({commit},key){
let { result } = await this.$api.get(`${systemUrl}/user/getuser`,{id:key});
console.warn("result",result)
commit("addUser",result);
export const actions = {
async loadUser({
commit
}, key) {
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 { result } = await Api.get(url);
let {
result
} = await Api.get(url);
var map = new Map();
......@@ -74,20 +94,20 @@ export const actions={
}
}
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