From 722736f9a56cf64b615e37ed1722dd430ad90d2d Mon Sep 17 00:00:00 2001
From: whycq <123456>
Date: 星期三, 26 十月 2022 08:48:31 +0800
Subject: [PATCH] #

---
 pages/basics/pakin.vue |  103 +++++++++++++++++++++++++--------------------------
 1 files changed, 51 insertions(+), 52 deletions(-)

diff --git a/pages/basics/pakin.vue b/pages/basics/pakin.vue
index b1fb132..c79978c 100644
--- a/pages/basics/pakin.vue
+++ b/pages/basics/pakin.vue
@@ -87,7 +87,8 @@
 		
 		<!-- 寮圭獥 -->
 		<!-- 淇敼鏁伴噺 -->
-		<uni-popup ref="revise" background-color="#fff" @change="change">
+		
+		<uni-popup ref="revise" background-color="#fff">
 			<view class="revise-box">
 				<view class="revise-box-top">
 					<view class="color-block-blue"></view>
@@ -98,7 +99,7 @@
 				</view>
 				<view class="changeBox">
 					<view class="num-box">
-						<uni-number-box v-model="counts" :min="0" :max="99999" color="#747474" />
+						<uni-number-box :value="count" :max="999999999" color="#747474" @change="changeValue" />
 					</view> 
 				</view>
 				<view class="revise-box-buttom">
@@ -126,6 +127,7 @@
 				matList:[],
 				result: '',
 				enableQty:'',
+				count:'',
 				counts:'',
 				minCount:0,
 				maxCount:'',
@@ -210,12 +212,6 @@
 			},
 			remove(item,index) {
 				this.matList.splice(index,1)
-				
-				// for (var i = 0; i < this.matList.length; i++) {
-				// 	if (this.matList[i].checked == true) {
-				// 		this.matList.splice(i,1)
-				// 	}
-				// }
 				this.checkList();
 				uni.vibrateShort();
 			},
@@ -278,7 +274,7 @@
 					},
 					success: function(res) {
 					    // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�   鍚戝彟澶栦竴涓〉闈紶閫掑�肩殑
-					    res.eventChannel.emit('acceptDataFromOpenerPage', {baseIP:that.baseIP, basePORT:that.basePORT })
+					    res.eventChannel.emit('matData', {baseIP:that.baseIP, basePORT:that.basePORT })
 					},
 					
 				});
@@ -305,7 +301,8 @@
 								events: {
 								    // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹�
 								    matList: function(data) {
-										that.matList.push(data.data)
+										that.checkMat(data.data)
+										// that.matList.push(data.data)
 									},
 								},
 								success: function(res) {
@@ -319,7 +316,24 @@
 				});
 				
 			},
-		
+			// 娣诲姞鍟嗗搧
+			addMat(mat) {
+				this.matList.unshift(mat)
+			},
+			checkMat(mat) {
+				var len = this.matList.length
+				var add = true
+				for (var i = 0; i < len; i++) {
+					if (mat.matNo === this.matList[i].matNo) {
+						this.matList[i].count += mat.count 
+						this.$forceUpdate() // 寮哄埗鍒锋柊
+						add = false
+					}
+				}
+				if (add) {
+					this.matList.unshift(mat)
+				}
+			},
 			change(e) {
 				console.log('褰撳墠妯″紡锛�' + e.type + ',鐘舵�侊細' + e.show);
 			},
@@ -329,58 +343,43 @@
 				this.$refs.goodsSearch.open(type)
 			},
 			checkbox: function (e) {
-				var items = this.matList,
-					values = e.detail.value;
-				for (var i = 0, lenI = items.length; i < lenI; ++i) {
-					const item = items[i]
-					item.id = item.id + ''
-					if(values.indexOf(item.id) >= 0){
-						this.$set(item,'checked',true)
-					}else{
-						this.$set(item,'checked',false)
-					}
-				}
-				if (values.length == items.length) {
-					this.check = true
-					this.checkText = "鍙栨秷鍏ㄩ��"
-				} else {
-					this.check = false
-					this.checkText = "鍏ㄩ��"
-				}
-				uni.vibrateShort();
+				// var items = this.matList,
+				// 	values = e.detail.value;
+				// for (var i = 0, lenI = items.length; i < lenI; ++i) {
+				// 	const item = items[i]
+				// 	item.id = item.id + ''
+				// 	if(values.indexOf(item.id) >= 0){
+				// 		this.$set(item,'checked',true)
+				// 	}else{
+				// 		this.$set(item,'checked',false)
+				// 	}
+				// }
+				// if (values.length == items.length) {
+				// 	this.check = true
+				// 	this.checkText = "鍙栨秷鍏ㄩ��"
+				// } else {
+				// 	this.check = false
+				// 	this.checkText = "鍏ㄩ��"
+				// }
+				// uni.vibrateShort();
 			},
 			revise(index) {
-				
 				this.rowNum = index
-				
+				this.count = this.matList[this.rowNum].count
 				this.$refs.revise.open()
 				
-				
-				// this.matList[this.rowNum].count = this.count
-				// this.eject()
-				// var maxCount = this.item.maxCount
-				// if (maxCount == undefined ) {
-				// 	this.matList[index]["maxCount"] = item.enableQty
-				// } 
-				// this.enableQty = item.enableQty
-				// this.count = this.minCount
-				// this.maxCount = item.maxCount
-				
+			},
+			changeCount(e) {
 				
 			},
-			eject() {
-				// this.type = type
-				// open 鏂规硶浼犲叆鍙傛暟 绛夊悓鍦� uni-popup 缁勪欢涓婄粦瀹� type灞炴��
-				this.$refs.revise.open()
+			changeValue(value) {
+				this.count = value
 			},
-			
 			// 纭缁勬墭鏁伴噺
 			confirm() {
-				this.matList[this.rowNum].count = this.counts
-				this.matList = this.matList
-				console.log(this.counts)
-				console.log(this.matList[this.rowNum].count)
+				this.matList[this.rowNum].count = this.count
 				this.$refs.revise.close()
+				this.$forceUpdate() // 寮哄埗鍒锋柊
 			},
 			// 鍒楄〃鍙嶉��
 			reChecked() { 

--
Gitblit v1.9.1