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

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

shish 5 лет назад
Родитель
Сommit
03e6becc1b

+ 16 - 47
ghsApp/src/admin/billing/priceChange.vue

@@ -5,45 +5,22 @@
                          @search="searchFn" />
                          @search="searchFn" />
     </view>
     </view>
     <view class="scroll-middle_bx">
     <view class="scroll-middle_bx">
-      <scroll-view scroll-y
-                   scroll-with-animation
-                   class="tab-view">
-        <div v-for="(item, index) in filterProductInfo"
-             :key="index"
-             class="tab-bar-item"
-             :class="[classIndex == index ? 'active' : '']"
-             :data-current="index"
-             @tap.stop="swichClass">
-          <text>{{ item.className || "" }}</text>
-        </div>
-      </scroll-view>
-      <scroll-view scroll-y
-                   class="right-box"
-                   :scroll-into-view="scrollClassId">
+      <scroll-view scroll-y class="right-box" :scroll-into-view="scrollClassId">
         <!--内容部分 start -->
         <!--内容部分 start -->
         <block v-if="!$util.isEmpty(filterProductInfo)">
         <block v-if="!$util.isEmpty(filterProductInfo)">
-          <view class="item_list_bx"
-                v-for="(classItem, classIndex) in filterProductInfo"
-                :key="classIndex"
-                :id="`class_${classItem.classId}`">
-            <view class="item_list_title">
-              {{ classItem.className }}
-            </view>
-            <template v-for="(productItem, productIndex) in classItem.child">
-              <Commondity :type="COMMODITY_TYPE.CHANGE"
-                          :key="productIndex"
-                          :info="productItem"
-                          :autoPrice="
-									productItem.priceLabel=='2'?getSelectItemById(productItem.id, classItem.classId).autoPrice:null
-								"
-                          @changePrice="changePriceEvent"
-                          @remove="removeChangePriceEvent"></Commondity>
-            </template>
-          </view>
+									<view style="padding: 30rpx">
+										<template v-for="(productItem, productIndex) in filterProductInfo">
+										<Commondity :type="COMMODITY_TYPE.CHANGE"
+																						:key="productIndex"
+																						:info="productItem"
+																						:autoPrice="productItem.priceLabel=='2'?getSelectItemById(productItem.id).autoPrice:null"
+																						@changePrice="changePriceEvent"
+																						@remove="removeChangePriceEvent"></Commondity>
+									</template>
+									</view>
         </block>
         </block>
         <block v-else>
         <block v-else>
-          <app-wrapper-empty title="暂无数据"
-                             :is-empty="$util.isEmpty(filterProductInfo)" />
+          <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(filterProductInfo)" />
         </block>
         </block>
         <!--内容部分 end -->
         <!--内容部分 end -->
       </scroll-view>
       </scroll-view>
@@ -58,7 +35,7 @@ import AppTabs from "@/components/plugin/tabs";
 import AppWrapperEmpty from "@/components/app-wrapper-empty";
 import AppWrapperEmpty from "@/components/app-wrapper-empty";
 import Commondity from "@/components/module/app-commodity";
 import Commondity from "@/components/module/app-commodity";
 import { COMMODITY_TYPE } from "@/utils/declare";
 import { COMMODITY_TYPE } from "@/utils/declare";
-import productMins from "@/mixins/product";
+import productMins from "@/mixins/productContrapose";
 import { autoPriceByIdApi, changePriceByIdApi } from '@/api/product/index'
 import { autoPriceByIdApi, changePriceByIdApi } from '@/api/product/index'
 
 
 export default {
 export default {
@@ -100,18 +77,10 @@ export default {
     async removeChangePriceEvent (item) {
     async removeChangePriceEvent (item) {
       try {
       try {
         if (item.priceLabel != '2') {
         if (item.priceLabel != '2') {
-          throw new Error(
-            '改价的商品才能清楚'
-          )
+          throw new Error('改价的商品才能清楚')
         }
         }
-        await autoPriceByIdApi({
-          productId: item.id
-        })
-        uni.showToast({
-          title: '自动调价成功',
-          icon: 'none',
-
-        });
+        await autoPriceByIdApi({productId: item.id})
+        uni.showToast({title: '自动调价成功',icon: 'none',});
         await this.initData()
         await this.initData()
       } catch (error) {
       } catch (error) {
       }
       }

+ 8 - 0
ghsApp/src/api/product/index.js

@@ -8,6 +8,14 @@ import https from "@/plugins/luch-request_0.0.7/request";
 export const getProductDataApi = data => {
 export const getProductDataApi = data => {
 	return https.get("/product/index", data);
 	return https.get("/product/index", data);
 };
 };
+/** *
+	* 获取所有分类(包括常用、全部)(暂不用)
+	* @parmas py 花材拼音
+	* @parmas type 库存预警时,固定为waring,其他情况不传或者传空
+	*/
+export const getAllProductDataApi = data => {
+	return https.get("/product/list", data);
+};
 
 
 /**
 /**
  * 自动调价
  * 自动调价

+ 384 - 0
ghsApp/src/mixins/productContrapose.js

@@ -0,0 +1,384 @@
+// import { getProductDataApi } from "@/api/product/index";
+import { getProductDataApi,getAllProductDataApi } from "@/api/product/index";
+import { mapGetters, mapActions } from "vuex";
+import { copyObject } from "@/utils/util";
+export default {
+	data() {
+		return {
+			pageType: "bill", //选择商品页面类别  用于区分不同功能的数据
+
+			productInfo: [], //商品信息
+			classIndex: 0, //当前商品类别下标
+			py: "", //拼音搜索条件
+			type: "", //库存预警时,固定为waring,其他情况不传或者传空
+			autoLoad: true, //自动获取商品信息
+			isLimit: true //选择数量不能大于库存限制
+		};
+	},
+	onLoad(options) {
+		const { pageType } = options;
+		if (pageType) {
+			this.pageType = pageType;
+		}
+
+		if (this.autoLoad) {
+			this.initData();
+		}
+	},
+	onUnload() {},
+	computed: {
+		...mapGetters(["getSelectInfo"]),
+		filterProductInfo() {
+			let list = copyObject(this.productInfo);
+			return list;
+		},
+		/**
+		 * 当前页面选中的商品列表
+		 */
+		selectList() {
+			console.log('this.getSelectInfo',this.getSelectInfo)
+			console.log('this.pageType',this.pageType)
+			console.log('this.getSelectInfo[this.pageType]',this.getSelectInfo[this.pageType])
+			return this.getSelectInfo[this.pageType] || [];
+		},
+		scrollClassId() {
+			const curClass = this.productInfo[this.classIndex];
+			if (curClass) {
+				return `class_${curClass.classId}`;
+			}
+
+			return "";
+		},
+		//选择商品总价
+		allPrice() {
+			let price = 0;
+
+			if (this.selectList) {
+				for (const item of this.selectList) {
+					const itemInfo = this.getSelectItemById(item.id, item.classId);
+					if (
+						itemInfo &&
+						!this.$util.isEmpty(itemInfo.bigPrice) &&
+						!this.$util.isEmpty(itemInfo.smallPrice)
+					) {
+						price += item.bigCount * Number(itemInfo.bigPrice);
+						price += item.smallCount * Number(itemInfo.smallPrice);
+					}
+				}
+			}
+
+			return Math.round(price * 100) / 100;
+		},
+		//选择商品总数
+		allCount() {
+			console.log(444444, this.selectList);
+			return this.selectList.length;
+		},
+		/**
+		 * 当前选中商品列表中是否有没有库存的商品
+		 */
+		hasNoStock() {
+			let has = false;
+			if (this.selectList) {
+				for (const item of this.selectList) {
+					const {
+						bigCount,
+						smallCount,
+						bigNum,
+						bigUnit,
+						smallNum,
+						smallUnit,
+						ratio
+					} = item;
+					const ratioNum = Number(ratio);
+					if (
+						Number(bigCount) * ratioNum + Number(smallCount) >
+						Number(bigNum) * ratioNum + Number(smallNum)
+					) {
+						has = true;
+						break;
+					}
+				}
+			}
+			return has;
+		}
+	},
+	methods: {
+		...mapActions(["setSelectInfoByType", "resetSelectInfoByType"]),
+		/**
+		 * 请求商品数据
+		 */
+		async initData(extendInfo) {
+			//extendInfo调用时的扩展参数  如  shopId
+			try {
+				let params = {
+					py: this.py,
+					type: this.type
+				};
+				if (extendInfo) {
+					params = { ...params, ...extendInfo };
+				}
+				// const { data } = await getProductDataApi(params);
+				const { data } = await getAllProductDataApi(params);
+				// data.forEach(element => {
+				// 	element.child && element.child.forEach(child => {
+				// 			child.classId = element.classId;
+				// 			child.className = element.className;
+				// 		});
+				// });
+				this.productInfo = data.list;
+				this.classIndex = 0;
+			} catch (error) {
+			} finally {
+				uni.hideLoading();
+			}
+		},
+		/**
+		 * 获取当前选中商品总价
+		 */
+		getSelectItemPrice(item) {
+			let price = 0;
+			const { bigCount, smallCount, bigPrice, smallPrice } = item;
+			let sum =
+				Number(bigCount) * Number(bigPrice) +
+				Number(smallCount) * Number(smallPrice);
+			price = Math.round(sum * 100) / 100;
+			return price;
+		},
+		/**
+		 * 通过id获取当前选中的商品信息
+		 */
+		getSelectItemById(id) {
+			let info = {
+				bigCount: 0, //扎数
+				smallCount: 0, //支数
+				autoPrice: 0 //调价价格
+			};
+			const item =
+				this.selectList && this.selectList.find(ele => {
+					return ele.id == id;
+				});
+			if (item) {
+				info = {
+					...item,
+					bigCount: Number(item.bigCount),
+					smallCount: Number(item.smallCount),
+					autoPrice: Number(item.autoPrice)
+				};
+			}
+			return info;
+		},
+		/**
+		 * 通过id获取当前选中的商品类别信息  左边菜单角标  当前选中该类别商品多少件
+		 */
+		getSelectClassById(classId) {
+			let info = {
+				bigCount: 0, //扎数
+				smallCount: 0 //支数
+			};
+
+			const productItem =
+				this.productInfo &&
+				this.productInfo.find(ele => {
+					return ele.classId == classId;
+				});
+			if (productItem && productItem.child) {
+				for (const item of productItem.child) {
+					for (const selectItem of this.selectList) {
+						if (item.id == selectItem.id && item.classId == selectItem.classId) {
+							info.bigCount += Number(selectItem.bigCount);
+							info.smallCount += Number(selectItem.smallCount);
+						}
+					}
+				}
+			}
+			return info;
+		},
+
+		/**
+		 * 添加商品
+		 */
+		addEvent(item) {
+			const list = this.selectList;
+			let has = false;
+			for (let index = 0; index < list.length; index++) {
+				const element = list[index];
+				if (element.id == item.id) {
+					has = true;
+					if (this.isLimit) {
+						if (element.bigCount < item.bigNum) {
+							list[index] = { ...element, bigCount: ++element.bigCount };
+						}
+						//  else if (element.smallCount < item.smallNum) {
+						// 	list[index] = { ...element, smallCount: ++element.smallCount };
+						// }
+					} else {
+						list[index] = { ...element, bigCount: ++element.bigCount };
+					}
+
+					if (this.isLimit) {
+						const { bigCount, smallCount } = list[index];
+						//超过库存时 设置为库存最大值
+						const ratio = Number(item.ratio);
+						if (
+							Number(bigCount) * ratio + Number(smallCount) >
+							Number(item.bigNum) * ratio + Number(item.smallNum)
+						) {
+							list[index].bigCount = Number(item.bigNum);
+							list[index].smallCount = Number(item.smallNum);
+							this.$msg("库存不足");
+						}
+					}
+
+					break;
+				}
+			}
+			if (!has) {
+				let info = {};
+
+				info =
+					this.productInfo && this.productInfo.find(element => {
+						return element.id == item.id;
+					});
+				let params = {
+					...info,
+					bigCount: 1, //扎数
+					smallCount: 0, //支数
+					autoPrice: 0 //调价价格
+				};
+				if (info.bigNum && info.bigNum > 0) {
+					list.push(params);
+				} else {
+					this.$msg("库存不足");
+				}
+			}
+
+			this.setSelectInfoByType({ type: this.pageType, info: list });
+		},
+		/**
+		 * 减去商品
+		 */
+		delEvent(item) {
+			const list = this.selectList;
+			let has = false;
+			for (let index = 0; index < list.length; index++) {
+				const element = list[index];
+				if (element.id == item.id && element.classId == item.classId) {
+					has = true;
+
+					if (element.bigCount > 0) {
+						list[index] = { ...element, bigCount: --element.bigCount };
+					} else if (element.smallCount > 0) {
+						list[index] = { ...element, smallCount: 0 };
+					}
+
+					if (this.isLimit) {
+						const { bigCount, smallCount } = list[index];
+						//超过库存时 设置为库存最大值
+						const ratio = Number(item.ratio);
+						if (
+							Number(bigCount) * ratio + Number(smallCount) >
+							Number(item.bigNum) * ratio + Number(item.smallNum)
+						) {
+							list[index].bigCount = Number(item.bigNum);
+							list[index].smallCount = Number(item.smallNum);
+						}
+					}
+					if (element.bigCount == 0 && element.smallCount == 0) {
+						list.splice(index, 1);
+					}
+
+					break;
+				}
+			}
+			if (!has) {
+				let info = { classId: item.classId, id: item.id };
+
+				const classInfo =
+					this.productInfo &&
+					this.productInfo.find(element => {
+						return element.classId == item.classId && element.child;
+					});
+				if (classInfo) {
+					info = classInfo.child.find(ele => {
+						return ele.id == item.id;
+					});
+				}
+				let params = {
+					...info,
+					bigCount: 1, //扎数
+					smallCount: 0, //支数
+					autoPrice: 0 //调价价格
+				};
+
+				list.push(params);
+			}
+			this.setSelectInfoByType({ type: this.pageType, info: list });
+			// this.$forceUpdate();
+		},
+		// /**
+		//  * 删除商品
+		//  */
+		// removeEvent(item) {
+		// 	const list = this.selectList;
+		// 	for (let index = list.length - 1; index >= 0; index--) {
+		// 		const element = list[index];
+		// 		if (element.id == item.id && element.classId == item.classId) {
+		// 			list.splice(index, 1);
+		// 			break;
+		// 		}
+		// 	}
+		// 	this.setSelectInfoByType({ type: this.pageType, info: list });
+		// 	// this.$forceUpdate();
+		// },
+		/**
+		 * 更新商品
+		 */
+		updateItemEvent(item) {
+			const list = this.selectList;
+			for (let index = 0; index < list.length; index++) {
+				const element = list[index];
+				if (element.id == item.id && element.classId == item.classId) {
+					const { bigCount, smallCount } = list[index];
+					//超过库存时 设置为库存最大值
+					const ratio = Number(item.ratio);
+					if (this.isLimit) {
+						if (
+							Number(bigCount) * ratio + Number(smallCount) >
+							Number(item.bigNum) * ratio + Number(item.smallNum)
+						) {
+							list[index].bigCount = Number(item.bigNum);
+							list[index].smallCount = Number(item.smallNum);
+						}
+					}
+
+					list[index] = {
+						...element,
+						bigCount: Number(item.bigCount),
+						smallCount: Number(item.smallCount)
+					};
+
+					break;
+				}
+			}
+
+			this.setSelectInfoByType({ type: this.pageType, info: list });
+			// this.$forceUpdate();
+		},
+		/**
+		 * 切换左侧商品类别
+		 */
+		swichClass(e) {
+			let cur = e.currentTarget.dataset.current;
+			if (this.classIndex == cur) {
+				return false;
+			} else {
+				this.classIndex = cur;
+			}
+		},
+		/**
+		 * 搜索对应花材
+		 */
+		searchFn() {}
+	}
+};

+ 3 - 24
ghsApp/src/pagesStorehouse/stockWarn/manage.vue

@@ -1,25 +1,9 @@
 <template>
 <template>
 	<view class="billing_box_bg">
 	<view class="billing_box_bg">
-		<app-tabs
-			:tabs="tabs"
-			:currentTab="tabIndex"
-			@change="change"
-			itemWidth="50%"
-		/>
+		<app-tabs :tabs="tabs" :currentTab="tabIndex" @change="change" itemWidth="50%"/>
 		<view class="input-wrap">
 		<view class="input-wrap">
-			<!-- <view
-				v-if=" == 1"
-				class="city-select text-line">
-				瑞经典<text class="iconfont iconsanjiao_xia"></text>
-			</view> -->
 			<view v-if="loginInfo.super" class="city-select text-line">
 			<view v-if="loginInfo.super" class="city-select text-line">
-				<DorpdownSelect
-					:menuObj.sync="menuObj"
-					:selectItemId.sync="shopId"
-					top="0"
-					@selectSussess="selectSussess"
-				>
-				</DorpdownSelect>
+				<DorpdownSelect :menuObj.sync="menuObj" :selectItemId.sync="shopId" top="0" @selectSussess="selectSussess"></DorpdownSelect>
 			</view>
 			</view>
 			<view class="search-bar">
 			<view class="search-bar">
 				<app-search-module
 				<app-search-module
@@ -56,12 +40,7 @@
 				<!--内容部分 start -->
 				<!--内容部分 start -->
 				<!--内容部分 start -->
 				<!--内容部分 start -->
 				<block v-if="!$util.isEmpty(filterProductInfo)">
 				<block v-if="!$util.isEmpty(filterProductInfo)">
-					<view
-						class="item_list_bx"
-						v-for="(classItem, classIndex) in filterProductInfo"
-						:key="classIndex"
-						:id="`class_${classItem.classId}`"
-					>
+					<view class="item_list_bx" v-for="(classItem, classIndex) in filterProductInfo" :key="classIndex" :id="`class_${classItem.classId}`">
 						<view class="item_list_title" v-if="!$util.isEmpty(classItem.child)"> {{ classItem.className }}</view>
 						<view class="item_list_title" v-if="!$util.isEmpty(classItem.child)"> {{ classItem.className }}</view>
 						<text v-else>当前库存充足</text>
 						<text v-else>当前库存充足</text>
 						<template v-for="(productItem, productIndex) in classItem.child">
 						<template v-for="(productItem, productIndex) in classItem.child">