From d5a6b28258858c9359ee81a235030100f25e6a4c Mon Sep 17 00:00:00 2001
From: whycq <whycq>
Date: 星期二, 15 二月 2022 15:47:27 +0800
Subject: [PATCH] ###

---
 pages/basics/comb.vue |  132 ++++++++++++++++++++++++++++++++------------
 1 files changed, 96 insertions(+), 36 deletions(-)

diff --git a/pages/basics/comb.vue b/pages/basics/comb.vue
index 3c32ef4..9d4d295 100644
--- a/pages/basics/comb.vue
+++ b/pages/basics/comb.vue
@@ -3,7 +3,7 @@
 		<form>
 			<view class="cu-form-group margin-top">
 				<view class="title">鎵樼洏鐮�</view>
-				<input v-model="code" placeholder="鎵爜 / 杈撳叆" name="input" @input="findCode" focus>
+				<input v-model="code" placeholder="鎵爜 / 杈撳叆" name="input" @input="findCode()" focus>
 				<button v-model="matBtn" class="cu-btn bg-yellow" @click="toggle('right')"><text>+鎻愬彇</text></button>
 				
 			</view>
@@ -11,20 +11,20 @@
 		<view class="margin-top">
 			<uni-table border stripe emptyText="鏆傛棤鏇村鏁版嵁">
 				<uni-tr>
-					<uni-th>鏁伴噺</uni-th>
-					<uni-th>浜у搧浠e彿</uni-th>
-					<uni-th>浜у搧鍚嶇О</uni-th>
+					<uni-th width="50">鏁伴噺</uni-th>
+					<uni-th width="100">浜у搧ID</uni-th>
+					<uni-th width="100">浜у搧鍚嶇О</uni-th>
 				</uni-tr>
-				<uni-tr>
-					<uni-td>1121</uni-td>
-					<uni-td>1121</uni-td>
-					<uni-td>1121</uni-td>
+				<uni-tr v-for="(item, index) in matData" :key="index" @input="tabRender()">
+					<uni-td>{{item.count}}</uni-td>
+					<uni-td>{{item.matNo}}</uni-td>
+					<uni-td>{{item.matName}}</uni-td>
 				</uni-tr>
 			</uni-table>
 			
 		</view>
 		<view>
-			<button class="cu-btn bg-yellow pda-btn">缁勬墭</button>
+			<button class="cu-btn bg-yellow pda-btn" @click="comb()">缁勬墭</button>
 			<button class="cu-btn bg-grey pda-btn" @click="reset">閲嶇疆</button>
 		</view>
 		<view>
@@ -36,7 +36,7 @@
 						</view>
 						<view class="cu-form-group margin-top">
 							<text class="title">浜у搧ID</text>
-							<input type="text" v-model="matNo" placeholder="鎵爜 / 杈撳叆" name="input" autocomplete="off" focus @input="find">
+							<input type="text" v-model="matNo" placeholder="鎵爜 / 杈撳叆" name="input" autocomplete="off" focus @input="find()">
 						</view>
 						<view class="cu-form-group margin-top">
 							<text class="title">浜у搧鍚嶇О</text>
@@ -55,13 +55,14 @@
 							<uni-number-box @change="countDom" v-model="count" />
 						</view>
 						<button class="cu-btn bg-yellow pda-btn2" @click="confirm">鎻愬彇</button>
-						<view>
-							<!-- 鎻愮ず淇℃伅寮圭獥 -->
-							<uni-popup ref="message" type="message">
-								<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
-							</uni-popup>
-						</view>
+						
 				</view>
+			</uni-popup>
+		</view>
+		<view>
+			<!-- 鎻愮ず淇℃伅寮圭獥 -->
+			<uni-popup ref="message" type="message">
+				<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
 			</uni-popup>
 		</view>
 	</view>
@@ -89,12 +90,11 @@
 			}
 		},
 		methods: {
-			reset:function() {
+			reset() {
 				let that =this;
 				that.code = '';
-			},
-			idid(){
-				alert(1)
+				that.matData=[];
+				
 			},
 			toggle(type) {
 				this.type = type
@@ -104,7 +104,7 @@
 			countDom(value) {
 				
 			},
-			findCode(){ // 鎵樼洏鐮� 瓒呰繃8浣�
+			findCode(){ //  鏌ヨ鎵樼洏鐮� 瓒呰繃8浣�
 				let that = this;
 				if(that.code.length === 8){
 					that.toggle('right')
@@ -113,25 +113,26 @@
 			// 鏍规嵁浜у搧浠e彿鏌ヨ浜у搧璇︽儏
 			find(){
 				let that = this
-				// if(isEmpty(that.matNo)){
-				// 	return;
-				// } isEmpty 鏈畾涔�
 				let thatId = that.matNo
 				if(that.matNo.length===0){
 					return;
 				}
+				console.log('http://'+ that.baseUrl + ':8082/xgmwms' + "/matCode/auth")
 				uni.request({
-					url:that.baseUrl+"/matCode/auth",
+					url: that.baseUrl + "/matCode/auth",
+					
 					header:{
 						'content-type':'application/x-www-form-urlencoded',
-						'token':localStorage.getItem('token'),	
-					},
+						'token':uni.getStorageSync('token')
+						},
 					data:{
 						id:thatId
 					},
 					method:'POST',
 					success:function(res){
+						console.log(res)
 						let data = res.data.data
+						
 						if(res.data.code === 200){
 							if(data != null){
 								that.matName = data.matName
@@ -155,20 +156,18 @@
 					matName:that.matName,
 					count:that.count
 				}
-				
-				that.addTbaleData(data)
+				that.addTableData(data)
 				
 			},
-			addTbaleData(data){
+			// 娣诲姞琛ㄦ牸鏁版嵁
+			addTableData(data){
 				if(data.matName===''){
 					this.messageToggle('error')
 					return
 				}
 				
 				this.$refs.popup.close()
-				for(var i=0;i<this.matData.length;i++){
-					console.log(data)
-					console.log(this.data)
+				for(var i=0;i<this.matData.length;i++){	
 					if(data.matNo === this.matData[i].matNo){
 						this.matData[i].count = Number(this.matData[i].count) + Number(data.count);
 							this.toPush  = false;
@@ -178,15 +177,76 @@
 					this.matData.push(data)
 				}
 				this.messageToggle('success')
-				
+				this.messageText = '鎻愬彇鎴愬姛'
+				this.matName=''
+				this.matNo=''
+				this.specs=''
+				this.count='0'
+				this.tabRender()
 			},
 			
 			messageToggle(type) {
 				this.msgType = type
-				this.messageText = `鎻愬彇澶辫触`
+				this.messageText = '鎻愬彇澶辫触'
 				this.$refs.message.open()
 			},
-			
+			// 琛ㄦ牸娓叉煋
+			tabRender(){
+				
+			},
+			// 缁勬墭
+			comb(){
+				let that = this
+				let barcode = that.code
+				if(barcode.length === 0){
+					console.log(1)
+					that.messageToggle('error')
+					that.messageText = '鎵樼洏鏉$爜涓虹┖'
+					return;
+				}
+				if(barcode.length !== 8){
+					that.messageToggle('error')
+					that.messageText = '鏉$爜蹇呴』涓�8浣�'
+					return;
+				}
+				if (that.matData.length === 0) {
+				    that.messageToggle('error')
+				    that.messageText = '璇锋彁鍙栦骇鍝�'
+				    return;
+				}
+				uni.request({
+					
+					url: that.baseUrl + "/mobile/comb/auth",
+					header:{
+						// #ifdef H5
+						'token':uni.getStorageSync('token')
+						// #endif
+						
+						// #ifdef APP-PLUS
+						'token': uni.getStorageSync('token')
+						// Authorization:uni.getStorageSync('token')
+						// #endif
+						},
+					data:{
+						barcode:barcode,
+						combMats:that.matData
+					},
+					method:'POST',
+					success:function(res){
+						console.log(res)
+						if(res.data.code===200){
+							that.reset()
+							that.messageToggle('success')
+							that.messageText = '缁勬墭鎴愬姛'
+						}else if(res.data.data===403){
+							
+						}else {
+							
+						}
+					}
+				})
+				
+			}
 		}
 	}
 </script>

--
Gitblit v1.9.1