zhengxin 5 лет назад
Родитель
Сommit
8c52f3c125

+ 20 - 18
ghs/src/admin/billing/index.vue

@@ -1,14 +1,18 @@
 <template>
 	<view class="billing_box_bg">
-		<view class="input-wrap">
-			<app-search-module placeholder="请输入关键词" @search="searchFn" />
-		</view>
 		<app-tabs
 			:tabs="tabs"
 			:currentTab="tabIndex"
 			@change="change"
 			itemWidth="50%"
 		/>
+		<view class="input-wrap">
+			<app-search-module
+				v-model="py"
+				placeholder="请输入关键词"
+				@search="searchFn"
+			/>
+		</view>
 		<view class="scroll-middle_bx">
 			<scroll-view
 				scroll-y
@@ -17,7 +21,7 @@
 				:scroll-top="scrollTop"
 			>
 				<div
-					v-for="(item, index) in productInfo"
+					v-for="(item, index) in filterProductInfo"
 					:key="index"
 					class="tab-bar-item"
 					:class="[classIndex == index ? 'active' : '']"
@@ -47,10 +51,10 @@
 				:scroll-into-view="scrollClassId"
 			>
 				<!--内容部分 start -->
-				<block v-if="!$util.isEmpty(productInfo)">
+				<block v-if="!$util.isEmpty(filterProductInfo)">
 					<view
 						class="item_list_bx"
-						v-for="(classItem, classIndex) in productInfo"
+						v-for="(classItem, classIndex) in filterProductInfo"
 						:key="classIndex"
 						:id="`class_${classItem.classId}`"
 					>
@@ -59,6 +63,7 @@
 						</view>
 						<template v-for="(productItem, productIndex) in classItem.child">
 							<Commondity
+								:id="`class_${classItem.classId}_${productItem.id}`"
 								:key="productIndex"
 								:info="productItem"
 								:bigCount="
@@ -81,7 +86,7 @@
 				<block v-else>
 					<app-wrapper-empty
 						title="暂无数据"
-						:is-empty="$util.isEmpty(productInfo)"
+						:is-empty="$util.isEmpty(filterProductInfo)"
 					/>
 				</block>
 				<!--内容部分 end -->
@@ -106,7 +111,7 @@
 				<view class="select-cmd_bx" v-if="customData">
 					<view class="kc"> 库存{{ customData.stock }} </view>
 					<view class="num_bx">
-						<input v-model="customData.bigCount" type="number" />扎
+						<input v-model="customData.bigCount" type="number" focus />扎
 						<input
 							v-model="customData.smallCount"
 							type="number"
@@ -248,12 +253,13 @@ export default {
 			}
 		},
 		confirmSelectEvent() {
-			uni.navigateTo({
-				url: "/admin/billing/affirm"
-			});
-			// if (this.selectList.length > 0) {
-			// 	this.showSubmitModel = true;
-			// }
+			if (this.selectList.length > 0) {
+				uni.navigateTo({
+					url: "/admin/billing/affirm"
+				});
+			} else {
+				this.$msg("请选择花材");
+			}
 		},
 		change(e) {
 			if (this.tabIndex == e.index) {
@@ -262,10 +268,6 @@ export default {
 				this.tabIndex = e.index;
 			}
 		},
-		searchFn() {
-			this.resetSelectInfoByType(this.pageType);
-			this.initData();
-		},
 		scrollTop() {}
 	}
 };

+ 11 - 6
ghs/src/components/app-flower-sel.vue

@@ -21,7 +21,7 @@
 						<view
 							v-for="(item, itemIndex) in list.data"
 							:key="itemIndex"
-							@click="switchAddress(item, itemIndex)"
+							@click="switchFlower(item, itemIndex)"
 							class="customer-item"
 						>
 							<view class="item-avatar">
@@ -105,6 +105,7 @@ export default {
 			// #endif
 
 			if (val) {
+				console.log(11111111);
 				this.initData();
 			}
 		}
@@ -112,11 +113,15 @@ export default {
 	methods: {
 		initData() {
 			let options = {
-				keyword: keyword,
+				keyword: this.keyword,
 				page: this.list.page,
 				pageSize: this.list.pageSize
 			};
-			return getPlatformFlowerListApi(options);
+			return getPlatformFlowerListApi(options)
+				.then(res => {
+					this.completes(res);
+				})
+				.catch(err => {});
 		},
 
 		// 搜索
@@ -129,7 +134,7 @@ export default {
 			this.$emit("update:show", false);
 			this.$emit("hide");
 		},
-		switchAddress(item, index) {
+		switchFlower(item, index) {
 			this.$emit("select", item);
 			this.hidePopup();
 		},
@@ -138,13 +143,13 @@ export default {
 		},
 		hasSelect(item) {
 			let has = false;
-			for (const selectItem of selectList) {
+			for (const selectItem of this.selectList) {
 				if (selectItem.id == item.id) {
 					has = true;
 					break;
 				}
 			}
-			return item;
+			return has;
 		}
 	}
 };

+ 1 - 0
ghs/src/components/module/app-search.vue

@@ -15,6 +15,7 @@
 					:placeholder="placeholder"
 					placeholder-class="placeholder"
 					@confirm="searchFn"
+					confirm-type="search"
 				/>
 			</div>
 		</div>

+ 47 - 11
ghs/src/mixins/product.js

@@ -1,5 +1,6 @@
 import { getProductDataApi } from "@/api/product/index";
 import { mapGetters, mapActions } from "vuex";
+import { copyObject } from "@/utils/util";
 export default {
 	data() {
 		return {
@@ -26,6 +27,31 @@ export default {
 	onUnload() {},
 	computed: {
 		...mapGetters(["getSelectInfo"]),
+		filterProductInfo() {
+			let list = copyObject(this.productInfo);
+			if (this.py) {
+				let commonList = list.find(ele => {
+					//在常用中过滤
+					return ele.classId == -2;
+				});
+				if (commonList) {
+					let commonChildList = [];
+					if (!this.$util.isEmpty(commonList.child)) {
+						commonList.child.forEach(ele => {
+							let hasName = ele.itemName && ele.itemName.indexOf(this.py) >= 0;
+							let elePy = (ele.py && ele.py.toLocaleUpperCase()) || "";
+							let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
+							if (hasName || hasPy) {
+								commonChildList.push(ele);
+							}
+						});
+					}
+					commonList.child = commonChildList;
+					list = [commonList];
+				}
+			}
+			return list;
+		},
 		/**
 		 * 当前页面选中的商品列表
 		 */
@@ -37,6 +63,7 @@ export default {
 			if (curClass) {
 				return `class_${curClass.classId}`;
 			}
+
 			return "";
 		},
 		//选择商品总价
@@ -57,6 +84,7 @@ export default {
 		},
 		//选择商品总数
 		allCount() {
+			console.log(444444, this.selectList);
 			return this.selectList.length;
 		},
 		/**
@@ -204,15 +232,16 @@ export default {
 				const element = list[index];
 				if (element.id == item.id && element.classId == item.classId) {
 					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) {
+					// 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];
@@ -270,7 +299,7 @@ export default {
 					if (element.bigCount > 0) {
 						list[index] = { ...element, bigCount: --element.bigCount };
 					} else if (element.smallCount > 0) {
-						list[index] = { ...element, smallCount: --element.smallCount };
+						list[index] = { ...element, smallCount: 0 };
 					}
 
 					if (this.isLimit) {
@@ -285,6 +314,9 @@ export default {
 							list[index].smallCount = Number(item.smallNum);
 						}
 					}
+					if (element.bigCount == 0 && element.smallCount == 0) {
+						list.splice(index, 1);
+					}
 
 					break;
 				}
@@ -373,6 +405,10 @@ export default {
 			} else {
 				this.classIndex = cur;
 			}
-		}
+		},
+		/**
+		 * 搜索对应花材
+		 */
+		searchFn() {}
 	}
 };