From b6eaf843294b8a438dad42efda2be6bd24d2e926 Mon Sep 17 00:00:00 2001
From: 付延余 <f-yanyu@outlook.com>
Date: 星期四, 16 三月 2023 19:56:16 +0800
Subject: [PATCH] 客户,货代订单转发数量的判断

---
 pages/public-page/forward/forward.vue |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/pages/public-page/forward/forward.vue b/pages/public-page/forward/forward.vue
index 52e564a..a8f43a6 100644
--- a/pages/public-page/forward/forward.vue
+++ b/pages/public-page/forward/forward.vue
@@ -48,15 +48,21 @@
 export default {
 	onLoad(params) {
 		console.log('杞彂鐨勬彁鐓ゅ崟id', params.orderPlanId, params.carNum);
+		if (params.carNumSurplus1 || params.carNumSurplusHuodai) {
+			if (params.carNumSurplus1 != 0) {
+				this.forwardSurplus = params.carNumSurplus1;
+			} else if (params.carNumSurplusHuodai != 0) {
+				this.forwardSurplus = params.carNumSurplusHuodai;
+			}
+		}
 		this.forwardForm.orderPlanId = params.orderPlanId;
-		this.carNumTatal = params.carNum;
 	},
 	data() {
 		return {
+			forwardSurplus: 0,
 			paramsName: {},
 			huoDaiData: [],
 			fleetData: [],
-			carNumTatal: null,
 			name: '',
 			forwardForm: {
 				orderPlanId: null,
@@ -107,7 +113,7 @@
 		checkboxChange(value) {
 			console.log('澶嶉�夋鍙樺寲', value);
 			if (value.length != 0) {
-				this.forwardForm.nums = this.carNumTatal;
+				this.forwardForm.nums = this.forwardSurplus;
 			} else {
 				this.forwardForm.nums = null;
 			}
@@ -156,14 +162,20 @@
 		},
 		// 鎻愪氦
 		submitForm() {
-			this.$reqPost('forward', this.forwardForm, 'params').then(res => {
-				if (res.code == 0) {
-					this.$u.toast('鎻愪氦鎴愬姛');
-					setTimeout(() => {
-						uni.navigateBack({ delta: 1 });
-					}, 1000);
-				}
-			});
+			if (isNaN(Number(this.forwardForm.nums)) || Number(this.forwardForm.nums) <= 0) {
+				this.$u.toast('璇疯緭鍏ュ悎娉曟暟瀛�');
+			} else if (Number(this.forwardForm.nums) > Number(this.forwardSurplus)) {
+				this.$u.toast('瓒呰繃鏈�澶ц鍗曞墿浣欓噺');
+			} else {
+				this.$reqPost('forward', this.forwardForm, 'params').then(res => {
+					if (res.code == 0) {
+						this.$u.toast('鎻愪氦鎴愬姛');
+						setTimeout(() => {
+							uni.navigateBack({ delta: 1 });
+						}, 1000);
+					}
+				});
+			}
 		},
 		tabClick(item) {
 			console.log('tab鐐瑰嚮', item);

--
Gitblit v1.9.1