shish 4 lat temu
rodzic
commit
01e5feaa59

+ 2 - 0
ghsPad/src/admin/home/components/rightItemArea.vue

@@ -72,6 +72,8 @@ export default {
             this.shopListType = data
             this.categoryId = this.shopListType[0].id
             this.getShowList()
+
+            this.initData()
         },
         async getShowList(){
             let { data:{list} } =  await showList({})

+ 15 - 243
ghsPad/src/mixins/product.js

@@ -149,172 +149,24 @@ export default {
 			}
 		},
 		//请求商品数据
-		async initData(extendInfo) {
-			try {
-				let params = {type: this.type,customId:this.option.customId}
-				if (extendInfo) {
-					params = { ...params, ...extendInfo };
-				}
-				const { data } = await getProductDataApi(params);
-				this.globalClassItemList = '';
-
-				data.forEach(element => {
-					element.child && element.child.forEach(child => {
-						
-							//组合出一维数组给下面使用 shish 20210811
-							this.globalItemList[child.id] = child
-
-							child.classId = element.classId;
-							child.className = element.className;
-							child.userPrice = 0;
-						});
-				});
-				this.productInfoList = data;
-
-				let currentInfo = uni.getStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
-				if(!this.$util.isEmpty(currentInfo)){
-					currentInfo.forEach((currentItem,currentIndex,currentArray)=>{
-						let currentId = currentItem.id
-						if(this.globalItemList[currentId]){
-							currentArray[currentIndex].bigPrice = this.globalItemList[currentId].bigPrice
-							currentArray[currentIndex].smallPrice = this.globalItemList[currentId].smallPrice
-							//已经记住的花材,价格修改之后,被记住的价格也要同步修改
-							//不能放开会造成采购单已经填好的,也会变动 shish 20220114
-							// if(!this.$util.isEmpty(currentArray[currentIndex].userPrice)){
-							// 	currentArray[currentIndex].userPrice = this.globalItemList[currentId].bigPrice
-							// }
-						}
-					})
-					this.setSelectInfo({ selectJobType: this.selectJobType, info: currentInfo,selectJobId:this.selectJobId })
-				}
-
-				this.classIndex = 0;
-				this.scroll_into_view = 'class_0';
-				this.scrollPushList();
-			} catch (error) {} finally {
-				uni.hideLoading();
-			}
-		},
-		//滚动或切换分类 获取更多数据
-		scrollPushList(){
-
-			//涉及记住花材的代码和流程,请全项目搜索关键词remember_item
-			//将已选的花材按classId_productId键名组合
-			let selectListData = []
-			if(!this.$util.isEmpty(this.selectList)){
-				this.selectList.forEach((i)=>{
-					selectListData[i.id] = i
-				})
-			}
-
-			let list = copyObject(this.productInfoList);
-			let classList = [];
-			for (let i=0;i<list.length;i++){
-
-				//将已选的花材数量和价格组合到总列表里
-				if(!this.$util.isEmpty(list[i].child)){
-					let currentChildren = list[i].child
-					for(let x=0;x<currentChildren.length;x++){
-						let currentProduct = currentChildren[x]
-						let currentPId = currentProduct.id
-						let selectProduct = selectListData[currentPId] || []
-						if(!this.$util.isEmpty(selectProduct)){
-							list[i].child[x].bigCount = selectProduct.bigCount || 0
-							list[i].child[x].userPrice = selectProduct.userPrice || 0
-							list[i].child[x].smallCount = selectProduct.smallCount || 0
-						}else{
-							list[i].child[x].bigCount = 0
-							list[i].child[x].userPrice = 0
-							list[i].child[x].smallCount = 0
-						}
+		initData() {
+			console.log('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
+			let currentInfo = uni.getStorageSync('selectList_'+this.selectJobType+'_target_'+this.selectJobId)
+			if(!this.$util.isEmpty(currentInfo)){
+				currentInfo.forEach((currentItem,currentIndex,currentArray)=>{
+					let currentId = currentItem.id
+					if(this.globalItemList[currentId]){
+						currentArray[currentIndex].bigPrice = this.globalItemList[currentId].bigPrice
+						currentArray[currentIndex].smallPrice = this.globalItemList[currentId].smallPrice
+						//已经记住的花材,价格修改之后,被记住的价格也要同步修改
+						//不能放开会造成采购单已经填好的,也会变动 shish 20220114
+						// if(!this.$util.isEmpty(currentArray[currentIndex].userPrice)){
+						// 	currentArray[currentIndex].userPrice = this.globalItemList[currentId].bigPrice
+						// }
 					}
-				}
-
-				if(i<2){
-					classList.push({...list[i],isActive:true});
-				}else{
-					classList.push({...list[i],isActive:false});
-				}
-			}
-			this.globalClassItemList = classList
-		},
-		//搜索对应花材
-		searchFn() {
-			let list = this.globalItemList
-			if(this.$util.isEmpty(this.py)){
-				this.globalClassItemList = '';
-				this.classIndex = 0;
-				this.scroll_into_view = 'class_'+0;
-				this.scrollPushList();
-				return
-			}
-
-			//大于等于2个字符才开始搜索 shish 20210622
-			if(this.py.length <=1){
-				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
-			}
-			//涉及记住花材的代码和流程,请全项目搜索关键词remember_item
-			//将已选的花材按productId键名组合
-			let selectListData = []
-			if(!this.$util.isEmpty(this.selectList)){
-				this.selectList.forEach((i)=>{
-					selectListData[i.id] = i
 				})
+				this.setSelectInfo({ selectJobType: this.selectJobType, info: currentInfo,selectJobId:this.selectJobId })
 			}
-
-			let filterItemData = [];
-			list.forEach(currentItem => {
-
-				//组合已记忆已选择的花材
-				let currentPId = currentItem.id
-				let selectProduct = selectListData[currentPId] || []
-				if(!this.$util.isEmpty(selectProduct)){
-					currentItem.bigCount = selectProduct.bigCount || 0
-					currentItem.userPrice = selectProduct.userPrice || 0
-					currentItem.smallCount = selectProduct.smallCount || 0
-				}else{
-					currentItem.bigCount = 0
-					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]})
-							}
-						})
-					}
-				}
-
-			})
-
-			let searchList = this.$util.unique(filterItemData)
-			this.globalClassItemList = searchList;
-			this.classIndex = 0;
-			this.scroll_into_view = 'class_'+0;
 		},
 		//获取当前选中商品总价
 		getSelectItemPrice(item) {
@@ -397,8 +249,6 @@ export default {
 			this.pushToSave(list)
 
 			this.itemNumPriceRefresh()
-
-
 		},
 		//显示可以修改花材的弹框
 		showAddModelFn(info) {
@@ -491,84 +341,6 @@ export default {
 				}
 			}
 			this.globalClassItemList = upList
-		},
-		//切换左侧商品类别
-		swichClass(cur) {
-			this.isCut = true;
-			this.globalClassItemList[cur].isActive = true;
-			if(cur==this.globalClassItemList.length-1){
-				this.globalClassItemList[cur-1].isActive = true;
-			}
-			if(cur!=0&&cur!=this.globalClassItemList.length-1){
-				this.globalClassItemList[cur-1].isActive = true;
-				this.globalClassItemList[cur+1].isActive = true;
-				if(this.globalClassItemList[cur+1].child.length<5 && cur<this.globalClassItemList.length-3){
-					this.globalClassItemList[cur+2].isActive = true;
-				}
-			}
-			this.scroll_into_view = '';
-			this.$nextTick(()=>{
-				this.scroll_into_view = 'class_'+cur;
-				this.classIndex = cur;
-			})
-			//解决最后一个 ***来回*** 问题 (由于点击左侧导航,右侧锚点位置信息变化,此时滚动事件也随之滚动。)
-			uni.setStorageSync("resolve","last");
-			setTimeout(()=>{ uni.removeStorageSync("resolve") },400)
-		},
-		//滚动商品监听
-		scroll_detail(options){
-			if(this.isCut) {
-				this.isCut = false
-				return
-			}
-			//options为滚动信息,options.detail.scrollTop  值为相对于scroll-view。
-			if(!uni.getStorageSync("resolve")){
-				this.get_node_details(options);
-			};
-		},
-		//获取商品节点信息
-		get_node_details(options){
-			//获得实例
-			const query = uni.createSelectorQuery().in(this);
-			//获取多个节点方式
-			query.selectAll(".selectAll").boundingClientRect(data=>{
-				this.top_list = data.map(item=>{
-					return Math.ceil(item.top);
-				});
-				this.async_detail_msg(options);
-			}).exec();
-		},
-		async_detail_msg(options){
-			//options为滚动信息,options.detail.scrollTop  值为相对于scroll-view
-			let top_page = options.detail.scrollTop + this.top_list[0];
-			for(let i = 0;i < this.top_list.length; i++){
-				let node1 = this.top_list[i];
-				let node2 = this.top_list[i+1];
-				if(node2 && top_page >= node1 && top_page < node2){
-					this.classIndex = i;
-					this.globalClassItemList[this.classIndex].isActive = true;
-					this.globalClassItemList[this.classIndex+1].isActive = true;
-					if(this.globalClassItemList[this.classIndex+1].child.length<5){
-						this.globalClassItemList[this.classIndex+2].isActive = true;
-					}
-					break;
-				}else if(node2 && top_page === node2){
-					this.classIndex = i + 1;
-					this.globalClassItemList[this.classIndex].isActive = true;
-					this.globalClassItemList[this.classIndex+1].isActive = true;
-					if(this.globalClassItemList[this.classIndex+1].child.length<5){
-						this.globalClassItemList[this.classIndex+2].isActive = true;
-					}
-					break;
-				}
-			}
-		},
-		scroll_bottom(){
-			this.classIndex = this.globalClassItemList.length-1
-			this.globalClassItemList[this.classIndex].isActive = true;
-			if(!this.$util.isEmpty(this.globalClassItemList[this.classIndex+1]) && this.globalClassItemList[this.classIndex+1].child.length<5){
-				this.globalClassItemList[this.classIndex+2].isActive = true;
-			}
 		}
 	}
 }