Просмотр исходного кода

Merge branch 'master' of http://git.huaml.com/zhh/front-end

fuwei 5 лет назад
Родитель
Сommit
6bb21c052a
2 измененных файлов с 26 добавлено и 10 удалено
  1. 19 7
      ghs/src/mixins/product.js
  2. 7 3
      ghs/src/store/modules/product.js

+ 19 - 7
ghs/src/mixins/product.js

@@ -3,10 +3,10 @@ import { mapGetters, mapActions } from "vuex";
 export default {
 	data() {
 		return {
-			pageType: "bill", //下单类别  用于区分不同功能的数据
+			pageType: "bill", //选择商品页面类别  用于区分不同功能的数据
 
 			productInfo: [], //商品信息
-			classIndex: 0, //商品类别小
+			classIndex: 0, //当前商品类别下
 			py: "", //拼音搜索条件
 			type: "", //库存预警时,固定为waring,其他情况不传或者传空
 			autoLoad: true //自动获取商品信息
@@ -26,7 +26,7 @@ export default {
 	computed: {
 		...mapGetters(["getSelectInfo"]),
 		/**
-		 * 选中的商品
+		 * 当前页面选中的商品列表
 		 */
 		selectList() {
 			return this.getSelectInfo[this.pageType] || [];
@@ -58,6 +58,9 @@ export default {
 		allCount() {
 			return this.selectList.length;
 		},
+		/**
+		 * 当前选中商品列表中是否有没有库存的商品
+		 */
 		hasNoStock() {
 			let has = false;
 			if (this.selectList) {
@@ -86,7 +89,10 @@ export default {
 	},
 	methods: {
 		...mapActions(["setSelectInfoByType", "resetSelectInfoByType"]),
-		async initData(extendInfo, clear) {
+		/**
+		 * 请求商品数据
+		 */
+		async initData(extendInfo) {
 			//extendInfo调用时的扩展参数  如  shopId
 			try {
 				let params = {
@@ -124,6 +130,9 @@ export default {
 		// 		});
 		// 	return info;
 		// },
+		/**
+		 * 获取当前选中商品总价
+		 */
 		getSelectItemPrice(item) {
 			let price = 0;
 			const { bigCount, smallCount, bigPrice, smallPrice } = item;
@@ -134,7 +143,7 @@ export default {
 			return price;
 		},
 		/**
-		 * 通过id获取当前选中的商品信息
+		 * 通过id获取当前选中的商品信息
 		 */
 		getSelectItemById(id, classId) {
 			let info = {
@@ -158,7 +167,7 @@ export default {
 			return info;
 		},
 		/**
-		 * 通过id获取当前选中的商品信息
+		 * 通过id获取当前选中的商品类别信息  左边菜单角标  当前选中该类别商品多少件
 		 */
 		getSelectClassById(classId) {
 			let info = {
@@ -295,7 +304,7 @@ export default {
 			// this.$forceUpdate();
 		},
 		// /**
-		//  * 减去商品
+		//  * 删除商品
 		//  */
 		// removeEvent(item) {
 		// 	const list = this.selectList;
@@ -341,6 +350,9 @@ export default {
 			this.setSelectInfoByType({ type: this.pageType, info: list });
 			// this.$forceUpdate();
 		},
+		/**
+		 * 切换左侧商品类别
+		 */
 		swichClass(e) {
 			let cur = e.currentTarget.dataset.current;
 			if (this.classIndex == cur) {

+ 7 - 3
ghs/src/store/modules/product.js

@@ -1,6 +1,6 @@
 export default {
 	state: {
-		selectInfo: {}
+		selectInfo: {} //选择商品信息  用页面pageType当key  查询对应模块选择的商品列表
 	},
 	getters: {
 		getSelectInfo(state) {
@@ -8,17 +8,21 @@ export default {
 		}
 	},
 	actions: {
+		/**
+		 * 设置不同类别选中商品列表信息
+		 */
 		setSelectInfoByType({ commit }, { type, info }) {
 			commit("SET_SELECTINFO_BY_TYPE", { type, info });
 		},
+		/**
+		 * 清空不同类别选中商品列表信息
+		 */
 		resetSelectInfoByType({ commit }, type) {
 			commit("SET_SELECTINFO_BY_TYPE", { type, info: [] });
 		}
 	},
 	mutations: {
 		["SET_SELECTINFO_BY_TYPE"](state, { type, info }) {
-			// state.selectInfo[type] = info;
-
 			state.selectInfo = {
 				...state.selectInfo,
 				[type]: info