From 21fb37c7162d5b47a14d6438870377c85fcc0b52 Mon Sep 17 00:00:00 2001
From: qingyiay <2386314947@qq.com>
Date: 星期六, 07 十月 2023 10:23:21 +0800
Subject: [PATCH] 修改装卸员页面 调整websocket逻辑

---
 pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue |   93 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 73 insertions(+), 20 deletions(-)

diff --git a/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue b/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue
index b3b9105..0381b1f 100644
--- a/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue
+++ b/pages/driver-page/driver-index/bill-of-lading-details/weighingDevice/weighingDevice.vue
@@ -204,16 +204,20 @@
 				:disabled="addAndSubtractCoalDisabled"
 				@click="addAndSubtractCoal"
 				class="jiajian"
-				v-if="outBuy"></u-button>
+				v-if="outBuy||!isSkinWeigh"></u-button>
 		</view>
-		<view class="four">
+		<view v-show="isConfirmWeighLoading"
+			style="color: #ff6363;width: auto;margin: 0 auto;">
+			瓒呭嚭姣涢噸,纾呮埧浜哄憳纭涓�,璇峰嬁绂诲紑姝ら〉闈�
+		</view>
+		<!-- <view class="four">
 			<u-button type="primary"
 				text="鍒锋柊"
 				@click.stop="RefreshHandle"
 				icon="reload"
 				throttle-time="800"
 				:loading="refreshLoading"></u-button>
-		</view>
+		</view> -->
 		<!-- 鏀剧┖寮圭獥 -->
 		<view class="evacuationModal">
 			<u-modal :show="evacuationModalShow"
@@ -229,7 +233,6 @@
 				title="寮傚父鍘熷洜"
 				:showCancelButton="true"
 				@confirm="abnormalConfirm"
-				@cancel="abnormalCancel"
 				confirmText="鎻愪氦">
 				<view class="slot-content">
 					<u--form labelPosition="top"
@@ -249,11 +252,17 @@
 				</view>
 			</u-modal>
 		</view>
+		<!-- 纭鍚庣О閲嶆彁绀哄脊绐� -->
+		<view class="">
+			<u-modal :show="confirmWeighVisiable"
+				title="鎻愮ず"
+				:content="confirmWeighContent"
+				@confirm="confirmWeighConfirm"></u-modal>
+		</view>
 	</view>
 </template>
 
 <script>
-	let socket = null;
 	import { webSocketUrl } from '@/api/request.js';
 	import { mapState, mapMutations } from 'vuex';
 	import combinedTitle from '@/components/combined-title/combined-title.vue';
@@ -277,6 +286,23 @@
 			this.changeWeigh('')
 			this.realTimeWeigh = 0
 		},
+		onShow() {
+			this.timer = setTimeout(() => {
+				if (!this.globalweigh) {
+					console.log('绉伴噸鏃惰嚜鍔ㄩ噸杩�');
+					this.socketTask.close();
+					this.changesocketTask(null);
+					this.changereconnectNum({ connectNum: 1, isWeigh: true })
+					this.$store.dispatch('websocketInit');
+				}
+			}, 3000)
+		},
+		onHide() {
+			clearTimeout(this.timer)
+		},
+		onUnload() {
+			clearTimeout(this.timer)
+		},
 		components: {
 			combinedTitle
 		},
@@ -296,7 +322,8 @@
 					coalContactClean: 0,
 					coalContactHair: 0,
 					coalContactSkin: 0,
-					isMerge: 0 //1鏄� 0涓嶆槸  榛樿0  鏄惁鍚堝崱
+					isMerge: '0', //1鏄� 0涓嶆槸  榛樿0  鏄惁鍚堝崱
+					isBackground: '0'
 				},
 				takeCoalId: null,
 				weighHouseCode: '',
@@ -360,7 +387,8 @@
 				mergeStateShow: false, //鍚堝崱寮圭獥
 				checkboxValue1: [],
 				isExceedOrigin: false, //鏄惁瓒呭嚭鍘熷彂姣涢噸
-				refreshLoading: false
+				refreshLoading: false,
+				timer: null
 			};
 		},
 		watch: {
@@ -373,7 +401,8 @@
 						.orderType ==
 						'杞嚭') {
 						if (this.weighList.skin == 0) {
-							this.isSkinWeigh = true
+							this.isSkinWeigh = true //绉扮毊娌℃湁杩斿洖瑁呭嵏
+							this.outBuy = false //绉扮毊娌℃湁杩斿洖瑁呭嵏
 							this.temporaryWeighObj.skin = newV;
 							let xx = new BigNumber(this.avgSkin)
 							let yy = new BigNumber(newV)
@@ -381,6 +410,7 @@
 								this.avgSkin !== 0
 						} else {
 							this.isSkinWeigh = false;
+							this.outBuy = true;
 							this.temporaryWeighObj.hair = newV;
 							this.temporaryWeighObj.clean = (this.temporaryWeighObj.hair - this.weighList.skin).toFixed(
 								2);
@@ -394,17 +424,20 @@
 						.orderType == '杞叆') {
 						if (this.weighList.hair == 0) {
 							this.isSkinWeigh = false;
+							this.outBuy = true;
 							this.temporaryWeighObj.hair = newV;
-							if (this.weighList.orderType == '澶栬喘') {
-								let xx = new BigNumber(newV)
-								let yy = new BigNumber(this.weighList.hairTwo)
-								if (xx.minus(yy) > 0.3) {
-									this.$u.toast('瓒呭嚭鍘熷彂淇℃伅姣涢噸,璇风瓑寰呯鐞嗕汉鍛樺鐞�')
-									this.isExceedOrigin = true
-								}
-							}
+							// if (this.weighList.orderType == '澶栬喘') {
+							// 	let xx = new BigNumber(newV)
+							// 	let yy = new BigNumber(this.weighList.hairTwo)
+							// 	if (xx.minus(yy) > 0.3) {
+							// 		this.$u.toast('瓒呭嚭鍘熷彂淇℃伅姣涢噸,璇风瓑寰呯鐞嗕汉鍛樺鐞�')
+							// 		this.isExceedOrigin = true
+							// 		this.saveWeigh()
+							// 	}
+							// }
 						} else {
-							this.isSkinWeigh = true;
+							this.isSkinWeigh = true; //绉扮毊娌℃湁杩斿洖瑁呭嵏
+							this.outBuy = false //绉扮毊娌℃湁杩斿洖瑁呭嵏
 							this.temporaryWeighObj.skin = newV;
 							let xx = new BigNumber(this.avgSkin)
 							let yy = new BigNumber(newV)
@@ -420,11 +453,16 @@
 						}
 					}
 				}
+			},
+			confirmWeighVisiable(v) {
+				if (v) {
+					uni.hideLoading()
+				}
 			}
 		},
 		computed: {
 			...mapState(['globalweigh', 'globalinfraredStatus', 'globalisconnect', 'globalisUploadimg', 'globalisLogin',
-				'is_open_socket'
+				'is_open_socket', 'socketTask', 'confirmWeighVisiable', 'confirmWeighContent'
 			]),
 			coalContactClean() {
 				let xx = BigNumber(this.weighData.coalContactHair)
@@ -455,7 +493,9 @@
 		},
 
 		methods: {
-			...mapMutations(['changeweighHouseCode', 'changeisLogin', 'changeWeigh']),
+			...mapMutations(['changeweighHouseCode', 'changeisLogin', 'changeWeigh', 'changeconfirmWeighVisiable',
+				'changesocketTask', 'changereconnectNum'
+			]),
 			RefreshHandle() {
 				if (this.globalisconnect) return this.$u.toast('宸茶繛鎺ワ紝鏃犻渶鍒锋柊')
 				this.refreshLoading = true
@@ -542,7 +582,6 @@
 			// 纭绉伴噸鎺ュ彛
 			saveWeigh() {
 				this.weighData.coalContactClean = this.coalContactClean;
-				console.log(this.weighData);
 				this.$reqPost('saveWeigh', this.weighData, 'json')
 					.then(res => {
 						console.log(res, '绉伴噸鎺ュ彛');
@@ -554,6 +593,10 @@
 								});
 								this.isConfirmWeighLoading = false;
 							}, 1000);
+						} else if (res.code === 3) {
+							uni.showLoading({
+								title: '纾呮埧浜哄憳纭涓�',
+							})
 						} else {
 							this.$u.toast(res.msg ? res.msg : '绉伴噸澶辫触锛岃绋嶅悗閲嶈瘯');
 							this.isConfirmWeighLoading = false
@@ -678,6 +721,16 @@
 					this.orderSurplusLess = true
 				}
 			},
+			confirmWeighConfirm() {
+				this.changeconfirmWeighVisiable(false)
+				this.isConfirmWeighLoading = false
+				setTimeout(() => {
+					this.$u.toast('鍗冲皢杩斿洖涓婁竴椤�'),
+						uni.navigateBack({
+							delta: 1
+						})
+				}, 800)
+			}
 		}
 	};
 </script>

--
Gitblit v1.9.1