From 5c8951e28e9f2fbdbe730ddf264eeba313647ea9 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期四, 13 七月 2023 16:32:53 +0800
Subject: [PATCH] #

---
 pages/AGV/AGVPakinOn.vue |  168 ++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 121 insertions(+), 47 deletions(-)

diff --git a/pages/AGV/AGVPakinOn.vue b/pages/AGV/AGVPakinOn.vue
index ebbd3db..753ae47 100644
--- a/pages/AGV/AGVPakinOn.vue
+++ b/pages/AGV/AGVPakinOn.vue
@@ -52,12 +52,6 @@
 						</view>
 					</view>
 					<view class="list-left-item">
-						<view class="desc">閲嶉噺锛�</view>
-						<view class="left-item">
-							<uni-tag :text="item.weight" type="warning"></uni-tag>
-						</view>
-					</view>
-					<view class="list-left-item">
 						<view class="desc">鏁伴噺锛�</view>
 						<view class="left-item">{{item.anfme}}</view>
 					</view>
@@ -71,6 +65,7 @@
 		<!-- 搴曢儴鎿嶄綔鎸夐挳 -->
 		<view class="buttom">
 			<button size="mini" @click="reset('warn')">閲嶇疆</button>
+			<button size="mini" type="primary" @click="agvStart('warn')">鍚姩鍏ュ簱</button>
 			<button size="mini" type="primary" @click="combConfirm('warn')">缁勬墭</button>
 		</view>
 		<!-- 寮圭獥 -->
@@ -87,13 +82,9 @@
 								style="background-color: #f7f7f7;padding: 0;color: #d5d5d5;">
 						</view>
 					</view>
-					<!-- <view class="popup-item">
+					<view class="popup-item">
 						<view class="popup-item-left">鎵瑰彿:</view>
 						<view class="popup-item-right"><input type="text" v-model="batch"></view>
-					</view> -->
-					<view class="popup-item">
-						<view class="popup-item-left">閲嶉噺:</view>
-						<view class="popup-item-right"><input type="text" v-model="weight"></view>
 					</view>
 					<view class="popup-item">
 						<view class="popup-item-left">鏁伴噺:</view>
@@ -126,7 +117,7 @@
 		<view>
 			<uni-popup ref="combConfirm" type="dialog">
 				<uni-popup-dialog :type="msgType" cancelText="鍙栨秷" confirmText="纭" :title="title" :content="content"
-					@confirm="comb" @close="combClose"></uni-popup-dialog>
+					@confirm="comb(1)" @close="combClose"></uni-popup-dialog>
 			</uni-popup>
 		</view>
 		<!-- 纭閲嶇疆 -->
@@ -134,6 +125,13 @@
 			<uni-popup ref="resetConfirm" type="dialog">
 				<uni-popup-dialog :type="msgType" cancelText="鍙栨秷" confirmText="纭" :title="title" :content="content"
 					@confirm="resetConfirm" @close="resetClose"></uni-popup-dialog>
+			</uni-popup>
+		</view>
+		<!-- 鍚姩鍏ュ簱 -->
+		<view>
+			<uni-popup ref="agvStartConfirm" type="dialog">
+				<uni-popup-dialog :type="msgType" cancelText="鍙栨秷" confirmText="纭" :title="title" :content="content"
+					@confirm="agvStartConfirm" @close="resetClose"></uni-popup-dialog>
 			</uni-popup>
 		</view>
 	</view>
@@ -163,6 +161,8 @@
 				matFocus: false,
 				matData: '',
 				removeNum: 0,
+				devNo: [],
+				flag: 0
 			}
 		},
 		onLoad() {
@@ -178,27 +178,40 @@
 				this.$refs.message.open()
 			},
 			stationCodeInput() {
-				
+				setTimeout(() => {
+					var len = this.stationCode.length
+					if (len != 15) {
+						this.stationCode = ''
+						this.stationCodeFocus = true
+						uni.showToast({
+							title: '鏆傚瓨鐮佹湁璇閲嶈瘯',
+							icon: "none",
+							position: 'top'
+						});
+						return;
+					}
+					this.focuss()
+				}, 200)
 			},
-			// barcode input 浜嬩欢
+			// 绗﹀悎鏉′欢鐨勮烦杞埌涓嬩竴鏍忕洰
 			barcodeInput() {
 				// 涓嶈缃畾鏃跺櫒 浼氬嚭鐜版壂鍏ョ殑瀛楃涓蹭笉鍏�
 				setTimeout(() => {
 					var len = this.barcode.length
-					if (len != 8) {
+					if (len != 10) {
+						this.barcode = ''
+						this.barcodeFocus = true
 						uni.showToast({
 							title: '鎵樼洏鐮佹湁璇閲嶈瘯',
 							icon: "none",
 							position: 'top'
 						});
-						this.stationCodeFocuss()
 						return;
 					}
 					this.stationCodeFocuss()
-					// this.focuss()
 				}, 200)
 			},
-			// 鎵樼洏鐮佹湁璇噸缃�
+			// 鏆傚瓨浣嶆湁璇噸缃�
 			stationCodeFocuss() {
 				let that = this;
 				that.barcodeFocus = false;
@@ -384,7 +397,7 @@
 			combClose() {
 				this.$refs.combConfirm.close()
 			},
-			comb() {
+			comb(e) {
 				uni.vibrateShort();
 				let that = this;
 				if (that.barcode === '') {
@@ -418,12 +431,96 @@
 					success(result) {
 						var res = result.data
 						if (res.code === 200) {
+							that.flag = 1
+							if (e == 1) {
+								that.resst();
+								that.messageText = "缁勬墭鎴愬姛"
+								that.messageToggle('success')
+								const innerAudioContext = uni.createInnerAudioContext();
+								innerAudioContext.src = '/static/music/pakinOk.mp3';
+								innerAudioContext.play()
+							}
+						} else if (res.code == 403) {
+							that.messageText = res.msg
+							that.messageToggle('error')
+							setTimeout(() => {
+								uni.reLaunch({
+									url: '../login/login'
+								});
+							}, 1000);
+							that.flag = 0
+						} else {
+							that.messageText = res.msg
+							that.messageToggle('error')
+							that.flag = 0
+						}
+					}
+				});
+			},
+			reset(type) {
+				this.msgType = type
+				this.title = '璀﹀憡'
+				this.content = '鏄惁閲嶇疆!'
+				this.$refs.resetConfirm.open()
+			},
+			// 纭閲嶇疆
+			resetConfirm() {
+				this.dataList = []
+				this.barcode = ''
+				this.stationCode = ''
+				this.messageText = "閲嶇疆瀹屾垚"
+				this.messageToggle('success')
+			},
+			// 鍙栨秷閲嶇疆
+			resetClose() {
+
+			},
+			// 娓呯┖
+			resst() {
+				this.dataList = []
+				this.barcode = ''
+				this.stationCode = ''
+				this.barcodeFocus = true
+			},
+			// 鍚姩鍏ュ簱
+			agvStart(type) {
+				this.msgType = type
+				this.title = '璀﹀憡'
+				this.content = '鏄惁鐜板湪鍚姩鍏ュ簱!'
+				this.$refs.agvStartConfirm.open()
+			},
+			agvStartConfirm() {
+				uni.showLoading()
+				this.devNo = []
+				this.devNo.push(this.stationCode)
+				this.comb(2)
+				setTimeout(()=>{
+					if (this.flag != 1) {
+						uni.hideLoading()
+						return
+					} 
+					this.start()
+					uni.hideLoading()
+				},500)
+				
+			},
+ 			start() {
+				let that = this
+				uni.request({
+					url: that.baseUrl + '/agvMobile/pakin/auth',
+					data: JSON.stringify({
+						devNo: that.devNo
+					}),
+					method: 'POST',
+					header: {
+						'token': uni.getStorageSync('token')
+					},
+					success(result) {
+						var res = result.data
+						if (res.code === 200) {
 							that.resst();
-							that.messageText = "缁勬墭鎴愬姛"
+							that.messageText = "鍚姩鎴愬姛"
 							that.messageToggle('success')
-							const innerAudioContext = uni.createInnerAudioContext();
-							innerAudioContext.src = '/static/music/pakinOk.mp3';
-							innerAudioContext.play()
 						} else if (res.code == 403) {
 							that.messageText = res.msg
 							that.messageToggle('error')
@@ -439,30 +536,7 @@
 					}
 				});
 			},
-			reset(type) {
-				this.msgType = type
-				this.title = '璀﹀憡'
-				this.content = '鏄惁閲嶇疆!'
-				this.$refs.resetConfirm.open()
-			},
-			// 纭閲嶇疆
-			resetConfirm() {
-				this.dataList = []
-				this.stationCode = ''
-				this.messageText = "閲嶇疆瀹屾垚"
-				this.messageToggle('success')
-			},
-			// 鍙栨秷閲嶇疆
-			resetClose() {
-
-			},
-			// 娓呯┖
-			resst() {
-				this.dataList = []
-				this.barcode = ''
-				this.stationCode = ''
-				this.barcodeFocuss()
-			},
+			
 		}
 	}
 </script>

--
Gitblit v1.9.1