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

拼音搜索相关,没看出个大概,先这样

shizhongqi 10 месяцев назад
Родитель
Сommit
6829632ccd
3 измененных файлов с 60 добавлено и 61 удалено
  1. 1 1
      hdApp/src/admin/home/order.vue
  2. 15 15
      mallApp/src/mixins/cgProduct.js
  3. 44 45
      mallApp/src/mixins/product.js

+ 1 - 1
hdApp/src/admin/home/order.vue

@@ -161,7 +161,7 @@
 
         <!-- 操作按钮 -->
         <view class="filter-actions">
-          <button class="filter-action-btn clear-btn middle" @click="clearFilters">清空</button>
+          <button class="filter-action-btn clear-btn middle" @click="clearFilters">重置</button>
           <button class="filter-action-btn confirm-btn middle blue" @click="confirmFilters">确定</button>
         </view>
       </view>

+ 15 - 15
mallApp/src/mixins/cgProduct.js

@@ -898,21 +898,21 @@ export default {
 					return
 				}
 				//红色粉色紫色绿色白色花材太多,搜索时会卡住,所以设置输入第三个字母时才搜索
-				if(this.py.toLocaleLowerCase().indexOf('fs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('hs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('zs') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('ls') == 0 && this.py.length <= 2){
-					return
-				}
-				if(this.py.toLocaleLowerCase().indexOf('bs') == 0 && this.py.length <= 2){
-					return
-				}
+				// if(this.py.toLocaleLowerCase().indexOf('fs') == 0 && this.py.length <= 2){
+				// 	return
+				// }
+				// if(this.py.toLocaleLowerCase().indexOf('hs') == 0 && this.py.length <= 2){
+				// 	return
+				// }
+				// if(this.py.toLocaleLowerCase().indexOf('zs') == 0 && this.py.length <= 2){
+				// 	return
+				// }
+				// if(this.py.toLocaleLowerCase().indexOf('ls') == 0 && this.py.length <= 2){
+				// 	return
+				// }
+				// if(this.py.toLocaleLowerCase().indexOf('bs') == 0 && this.py.length <= 2){
+				// 	return
+				// }
 				clearInterval(this.timeFun)
 				let commonChildList = [];
 				list.forEach(ele => {

+ 44 - 45
mallApp/src/mixins/product.js

@@ -199,8 +199,7 @@ export default {
 		},
 		//滚动或切换分类 获取更多数据
 		scrollPushList(){
-
-			//涉及记住花材的代码和流程,请全项目搜索关键词remember_item
+			//涉及记住花材的代码和流程,请全项目搜索关键词 remember_item
 			//将已选的花材按classId_productId键名组合
 			let selectListData = []
 			if(!this.$util.isEmpty(this.selectList)){
@@ -242,7 +241,7 @@ export default {
 		},
 		//搜索对应花材
 		searchFn() {
-			let list = this.globalItemList
+			const list = this.globalItemList
 			if(this.$util.isEmpty(this.py)){
 				this.globalClassItemList = '';
 				this.classIndex = 0;
@@ -256,25 +255,25 @@ export default {
 				return
 			}
 			//红色粉色花材太多,搜索时会卡住,所以设置输入第三个字母时才搜索
-			if(this.py.indexOf('fs') == 0 && this.py.length <= 2){
-				return
-			}
-			if(this.py.indexOf('hs') == 0 && this.py.length <= 2){
-				return
-			}
-			if(this.py.indexOf('zs') == 0 && this.py.length <= 2){
-				return
-			}
-			if(this.py.indexOf('ls') == 0 && this.py.length <= 2){
-				return
-			}
-			if(this.py.indexOf('bs') == 0 && this.py.length <= 2){
-				return
-			}
-			if(this.py.indexOf('yj') == 0 && this.py.length <= 2){
-				return
-			}
-			//涉及记住花材的代码和流程,请全项目搜索关键词remember_item
+			// if(this.py.indexOf('fs') == 0 && this.py.length <= 2){
+			// 	return
+			// }
+			// if(this.py.indexOf('hs') == 0 && this.py.length <= 2){
+			// 	return
+			// }
+			// if(this.py.indexOf('zs') == 0 && this.py.length <= 2){
+			// 	return
+			// }
+			// if(this.py.indexOf('ls') == 0 && this.py.length <= 2){
+			// 	return
+			// }
+			// if(this.py.indexOf('bs') == 0 && this.py.length <= 2){
+			// 	return
+			// }
+			// if(this.py.indexOf('yj') == 0 && this.py.length <= 2){
+			// 	return
+			// }
+			//涉及记住花材的代码和流程,请全项目搜索关键词 remember_item
 			//将已选的花材按productId键名组合
 			let selectListData = []
 			if(!this.$util.isEmpty(this.selectList)){
@@ -283,13 +282,16 @@ export default {
 				})
 			}
 
-			let filterItemData = [];
-			list.forEach(currentItem => {
-
+			const queryUpper = this.py.toLocaleUpperCase()
+			const groupsMap = {}
+			const items = Object.values(list || {})
+			for (let idx = 0; idx < items.length; idx++) {
+				const currentItem = items[idx]
+				if(!currentItem){ continue }
 				//组合已记忆已选择的花材
-				let currentPId = currentItem.id
-				let selectProduct = selectListData[currentPId] || []
-				if(!this.$util.isEmpty(selectProduct)){
+				const currentPId = currentItem.id
+				const selectProduct = selectListData[currentPId] || null
+				if(selectProduct){
 					currentItem.bigCount = selectProduct.bigCount || 0
 					currentItem.userPrice = selectProduct.userPrice || 0
 					currentItem.smallCount = selectProduct.smallCount || 0
@@ -298,25 +300,22 @@ export default {
 					currentItem.userPrice = 0
 					currentItem.smallCount = 0
 				}
-				let elePy = (currentItem.py && currentItem.py.toLocaleUpperCase()) || "";
-				let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
-				if (hasPy) {
-					if(this.$util.isEmpty(filterItemData)){
-						filterItemData = [{classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]}]
-					}else{
-						filterItemData.forEach(res => {
-							if(res.classId==currentItem.classId){
-								res.child.push(currentItem)
-							}else{
-								filterItemData.push({classId: currentItem.classId, className: currentItem.className,isActive:true,child:[currentItem]})
-							}
-						})
+
+				// 预计算并复用 py 大写
+				if(currentItem._pyUpper === undefined){
+					currentItem._pyUpper = (currentItem.py && currentItem.py.toLocaleUpperCase()) || ""
+				}
+				const hasPy = currentItem._pyUpper.indexOf(queryUpper) >= 0
+				if(hasPy){
+					const cid = currentItem.classId
+					if(!groupsMap[cid]){
+						groupsMap[cid] = {classId: cid, className: currentItem.className, isActive: true, child: []}
 					}
+					groupsMap[cid].child.push(currentItem)
 				}
+			}
 
-			})
-
-			let searchList = this.$util.unique(filterItemData)
+			const searchList = Object.values(groupsMap)
 			this.globalClassItemList = searchList;
 			this.classIndex = 0;
 			this.scroll_into_view = 'class_'+0;
@@ -489,7 +488,7 @@ export default {
 			this.customData = {};
 		},
 		itemNumPriceRefresh(){
-			//涉及记住花材的代码和流程,请全项目搜索关键词remember_item
+			//涉及记住花材的代码和流程,请全项目搜索关键词 remember_item
 			//将已选的花材按classId_productId键名组合
 			let selectListData = []
 			if(!this.$util.isEmpty(this.selectList)){