shish 5 лет назад
Родитель
Сommit
6720f6e457
2 измененных файлов с 16 добавлено и 74 удалено
  1. 7 37
      ghsApp/src/mixins/product.js
  2. 9 37
      hdApp/src/mixins/product.js

+ 7 - 37
ghsApp/src/mixins/product.js

@@ -37,41 +37,6 @@ export default {
 	onUnload() {},
 	computed: {
 		...mapGetters(["getSelectInfo"]),
-		filterProductInfoxxxxx() {
-			let list = copyObject(this.productInfo);
-			if (this.py) {
-				let commonChildList = [];
-				list.forEach(ele => {
-					//过滤常用
-					if(ele.classId != -2){
-						if (!this.$util.isEmpty(ele.child)) {
-							ele.child.forEach(obj => {
-								let hasName = obj.itemName && obj.itemName.indexOf(this.py) >= 0;
-								let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
-								let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
-								if (hasName || hasPy) {
-									if(this.$util.isEmpty(commonChildList)){
-										commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,child:[obj]}];
-									}else{
-										commonChildList.forEach(res => {
-											if(res.classId==ele.classId){
-												res.child.push(obj)
-											}else{
-												commonChildList.push({classId: ele.classId, className: ele.className,child:[obj]});
-											}
-										})
-									}
-								}
-							});
-						}
-
-					}
-				});
-				list = this.$util.unique(commonChildList)
-				this.suitClassIndex = 0;
-			}
-			return list;
-		},
 		/**
 		 * 当前页面选中的商品列表
 		 */
@@ -619,6 +584,10 @@ export default {
 		searchFn() {
 			let list = copyObject(this.productInfo);
 			if(!this.$util.isEmpty(this.py)){
+				//大于等于2个字符才开始搜索 shish 20210622
+				if(this.py.length <=1){
+					return
+				}
 				clearInterval(this.timeFun)
 				let commonChildList = [];
 				list.forEach(ele => {
@@ -626,9 +595,10 @@ export default {
 					if(ele.classId != -2){
 						if (!this.$util.isEmpty(ele.child)) {
 							ele.child.forEach(obj => {
-								let hasName = obj.itemName && obj.itemName.indexOf(this.py) >= 0;
+								//开头要匹配 shish 20210622
+								let hasName = obj.itemName && obj.itemName.indexOf(this.py) == 0;
 								let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
-								let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
+								let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) == 0;
 								if (hasName || hasPy) {
 									if(this.$util.isEmpty(commonChildList)){
 										commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,child:[obj]}];

+ 9 - 37
hdApp/src/mixins/product.js

@@ -58,41 +58,6 @@ export default {
 	onUnload() {},
 	computed: {
 		...mapGetters(["getSelectInfo"]),
-		filterProductInfoxxxx() {
-			let list = copyObject(this.productInfo);
-			if (this.py) {
-				let commonChildList = [];
-				list.forEach(ele => {
-					//过滤常用
-					if(ele.classId != -2){
-						if (!this.$util.isEmpty(ele.child)) {
-							ele.child.forEach(obj => {
-								let hasName = obj.itemName && obj.itemName.indexOf(this.py) >= 0;
-								let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
-								let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
-								if (hasName || hasPy) {
-									if(this.$util.isEmpty(commonChildList)){
-										commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,child:[obj]}];
-									}else{
-										commonChildList.forEach(res => {
-											if(res.classId==ele.classId){
-												res.child.push(obj)
-											}else{
-												commonChildList.push({classId: ele.classId, className: ele.className,child:[obj]});
-											}
-										})
-									}
-								}
-							});
-						}
-
-					}
-				});
-				list = this.$util.unique(commonChildList)
-				this.suitClassIndex = 0;
-			}
-			return list;
-		},
 		/**
 			* 搜索、初始化数据
 			* */
@@ -1028,6 +993,12 @@ export default {
 		searchFn() {
 			let list = copyObject(this.productInfo);
 			if(!this.$util.isEmpty(this.py)){
+
+				//大于等于2个字符才开始搜索 shish 20210622
+				if(this.py.length <=1){
+					return
+				}
+
 				clearInterval(this.timeFun)
 				let commonChildList = [];
 				list.forEach(ele => {
@@ -1035,9 +1006,10 @@ export default {
 					if(ele.classId != -2){
 						if (!this.$util.isEmpty(ele.child)) {
 							ele.child.forEach(obj => {
-								let hasName = obj.itemName && obj.itemName.indexOf(this.py) >= 0;
+								//开头要匹配 shish 20210622
+								let hasName = obj.itemName && obj.itemName.indexOf(this.py) == 0;
 								let elePy = (obj.py && obj.py.toLocaleUpperCase()) || "";
-								let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) >= 0;
+								let hasPy = elePy.indexOf(this.py.toLocaleUpperCase()) == 0;
 								if (hasName || hasPy) {
 									if(this.$util.isEmpty(commonChildList)){
 										commonChildList = [...commonChildList,{classId: ele.classId, className: ele.className,child:[obj]}];