product.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. export default {
  2. state: {
  3. selectInfo: {} //选择商品信息 用页面pageType当key 查询对应模块选择的商品列表
  4. },
  5. getters: {
  6. getSelectInfo(state) {
  7. return state.selectInfo || {};
  8. }
  9. },
  10. actions: {
  11. //设置不同类别选中商品列表信息(老写法,在采购模块的花材列表使用)
  12. setSelectInfoByType({ commit }, { type, info }) {
  13. commit("SET_SELECTINFO_BY_TYPE", { type, info });
  14. },
  15. //清空不同类别选中商品列表信息(老写法,在采购模块的花材列表使用)
  16. resetSelectInfoByType({ commit }, type) {
  17. commit("SET_SELECTINFO_BY_TYPE", { type, info: [] });
  18. },
  19. //重要!!!!selectJobType区分不同业务,如开单、损耗、调拨,selectJobId用于区分相同业务下的不同主体,如调拨给不同门店,开店给不同的客户
  20. //保存已选花材列表(新写法)
  21. setSelectInfo({ commit }, { selectJobType, info,selectJobId }) {
  22. commit("SET_SELECTED_ITEM", { selectJobType, info,selectJobId });
  23. },
  24. //清空已选花材信息(新写法)
  25. reSetSelectInfo({ commit }, {selectJobType,selectJobId}) {
  26. commit("SET_SELECTED_ITEM", { selectJobType, info: [],selectJobId });
  27. }
  28. },
  29. mutations: {
  30. //老写法,在采购模块的花材列表使用
  31. ["SET_SELECTINFO_BY_TYPE"](state, { type, info }) {
  32. state.selectInfo = {...state.selectInfo,[type]: info};
  33. },
  34. //新写法
  35. SET_SELECTED_ITEM(state, { selectJobType, info,selectJobId }) {
  36. state.selectInfo = { ...state.selectInfo, [selectJobType+'_'+selectJobId]: info }
  37. }
  38. }
  39. };