From 9cb5cd3735f58bd62c3ad0d20b89646801bc05bf Mon Sep 17 00:00:00 2001
From: yangan <yangan0921@163.com>
Date: 星期三, 10 一月 2024 17:20:26 +0800
Subject: [PATCH] 验质页面增加单价

---
 pages/public-page/selectSpecifications/selectSpecifications.vue |  243 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 229 insertions(+), 14 deletions(-)

diff --git a/pages/public-page/selectSpecifications/selectSpecifications.vue b/pages/public-page/selectSpecifications/selectSpecifications.vue
index 1ce2331..f211140 100644
--- a/pages/public-page/selectSpecifications/selectSpecifications.vue
+++ b/pages/public-page/selectSpecifications/selectSpecifications.vue
@@ -1,11 +1,15 @@
 <template>
 	<view class="main">
 		<u--form labelPosition="top"
-			labelWidth="20%"
+			labelWidth="30%"
 			:borderBottom="false"
+			:rules="rules"
+			:errorType="'border-bottom'" 
 			:model="dataForm"
 			ref="uForm">
-			<u-form-item label="涓�绾у搧绫�"
+			<u-form-item 
+			borderBottom=true
+			label="涓�绾у搧绫�"
 				prop="firstClass"
 				:borderBottom="false">
 				<u-cell-group>
@@ -17,7 +21,9 @@
 							size="30"></u-icon></u-cell>
 				</u-cell-group>
 			</u-form-item>
-			<u-form-item label="浜岀骇鍝佸悕"
+			<u-form-item
+			borderBottom=true
+			label="浜岀骇鍝佸悕"
 				prop="secondClass"
 				:borderBottom="false">
 				<u-cell-group>
@@ -29,12 +35,41 @@
 							size="30"></u-icon></u-cell>
 				</u-cell-group>
 			</u-form-item>
-			<u-form-item label="瑙勬牸"
+			<u-form-item 
+			label="瑙勬牸"
 				prop="specifications"
 				borderBottom>
 				<u-input v-model="dataForm.specifications"
 					placeholder="璇疯緭鍏ヨ鏍�"
 					border="bottom"
+					@input="$u.debounce(specInputHandle, 500)"></u-input>
+			</u-form-item>
+			<!-- 鏂板涓嶅悎鏍肩О閲� -->
+			<u-form-item label="涓嶅悎鏍奸噸閲�"
+				prop="unqualifiedWeight"
+				borderBottom>
+				<u-input v-model="dataForm.unqualifiedWeight"
+					placeholder="璇疯緭鍏ラ噸閲�"
+					type="digit"
+					border="bottom"
+					@change="v=>checkNum(v,'unqualifiedWeight')"
+					@input="$u.debounce(specInputHandle, 500)"></u-input>
+			</u-form-item>
+			<!-- <u-form-item label="涓嶅悎鏍煎垽瀹�" prop="unqualifiedType">
+				<u-radio-group  size='32' v-model="dataForm.unqualifiedType">
+				<u-radio  :label-size="25" :name="'1'"  :label="'瓒呭昂鎵g綒'" :disabled="disabled">闀垮害鎵g綒</u-radio>
+				<u-radio  :label-size="25" :name="'2'" :label="'鍘氬害鎵g綒'" :disabled="disabled">鍘氬害鎵g綒</u-radio>
+				<u-radio  :label-size="25" :name="'3'" :label="'瀵嗛棴鍣�'" :disabled="disabled">瀵嗛棴鍣�</u-radio>
+				</u-radio-group>
+			</u-form-item> -->
+			<u-form-item label="鍗曚环"
+				prop="penaltyUnitPrice"
+				borderBottom>
+				<u-input v-model="dataForm.penaltyUnitPrice"
+					placeholder="璇疯緭鍏ヤ笉鍚堟牸鍗曚环"
+					type="digit"
+					border="bottom"
+					@change="v=>checkNum(v,'penaltyUnitPrice')"
 					@input="$u.debounce(specInputHandle, 500)"></u-input>
 			</u-form-item>
 		</u--form>
@@ -82,10 +117,14 @@
 				dataForm: {
 					firstClass: "",
 					secondClass: "",
-					specifications: ""
+					specifications: "",
+					unqualifiedWeight:'',
+					// unqualifiedType:'',
+					penaltyUnitPrice:''
 				},
 				index: '',
 				takeCoalId: "",
+				params:{},
 				// 涓�绾у搧绫绘搷浣滆彍鍗�
 				firstClassActionsList: [],
 				firstClassShow: false,
@@ -98,6 +137,41 @@
 				// 鍒ゆ柇鏄慨鏀瑰搧鍚嶄笌瑙勬牸杩樻槸涓嶅悎鏍煎搧鍚�
 				productName: false,
 				unqualified: false,
+				rules: {
+				'firstClass': {
+					type: 'string',
+					required: true,
+					message: '璇烽�夋嫨鍊�',
+					trigger: ['blur', 'change']
+				},
+				'secondClass': {
+					type: 'string',
+					required: true,
+					message: '璇烽�夋嫨鍊�',
+					trigger: ['blur', 'change']
+				},
+				'specifications': {
+					type: 'string',
+					required: true,
+					message: '璇烽�夋嫨鍊�',
+					trigger: ['blur', 'change']
+				},
+				'unqualifiedWeight': {
+					required: true,
+					message: '璇烽�夋嫨鍊�',
+					trigger: ['blur', 'change']
+				},
+				// 'unqualifiedType':{
+				// 	required: true,
+				// 	message: '璇烽�夋嫨鍊�',
+				// 	trigger: ['blur', 'change']
+				// },
+				'penaltyUnitPrice':{
+					required: true,
+					message: '璇烽�夋嫨鍊�',
+					trigger: ['blur', 'change']
+				}
+			},
 				// 
 				showWeighCopyStorge: []
 			}
@@ -105,17 +179,26 @@
 		computed: {
 			...mapState(["globalShowWeigh"]),
 		},
+		onReady() {
+		//濡傛灉闇�瑕佸吋瀹瑰井淇″皬绋嬪簭锛屽苟涓旀牎楠岃鍒欎腑鍚湁鏂规硶绛夛紝鍙兘閫氳繃setRules鏂规硶璁剧疆瑙勫垯銆�
+    	this.$refs.uForm.setRules(this.rules)
+   		 },
 		onLoad(params) {
 			this.index = params.index || ""
 			this.takeCoalId = params.takeCoalId || ''
-			this.getFirstCategoryName()
+			this.getFirstCategoryName(params)
+			this.params = params;
 			this.productName = params.productName === "true" || false
 			this.unqualified = params.unqualified === "true" || false
-			this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorge')))
+			this.showWeighCopyStorge = JSON.parse(JSON.stringify(uni.getStorageSync('showWeighCopyStorgeOther')))
+			console.log(params,'paramsparamsparams');
+			if(params.type == 'edit'){
+				this.init(params)
+			}
 		},
 		methods: {
 			...mapMutations(['changeglobalShowWeigh']),
-			getFirstCategoryName() {
+			getFirstCategoryName(params) {
 				uni.showLoading({
 					title: "鍔犺浇涓�"
 				})
@@ -128,12 +211,23 @@
 								name: v &&  v.firstCategoryName
 							}
 						})
-						this.dataForm.firstClass = this.firstClassActionsList[0].firstCategoryName;
+						if(params.type !== 'edit')	this.dataForm.firstClass = this.firstClassActionsList[0].firstCategoryName
 					} else {
 						uni.hideLoading()
 						this.$u.toast('鍔犺浇澶辫触')
 					}
 				})
+			},
+			init(params){
+			 let arr =  this.showWeighCopyStorge[params.index];
+			 console.log(this.showWeighCopyStorge,'arr')
+			 let {firstClass,secondClass,specifications} = arr.tempArr[params.indexTo];
+			 Object.assign(this.dataForm,{firstClass,secondClass,specifications});
+			 this.dataForm.unqualifiedWeight = this.showWeighCopyStorge[params.index].unqualifiedWeights.split(',')[params.indexTo];
+			 //涓嶅悎鏍肩被鍒ゅ畾
+			//  this.dataForm.unqualifiedType = this.showWeighCopyStorge[params.index].unqualifiedType.split(',')[params.indexTo];
+			 //鍗曚环
+			this.dataForm.penaltyUnitPrice = this.showWeighCopyStorge[params.index].penaltyUnitPrice.split(',')[params.indexTo];
 			},
 			//涓�绾у搧绫昏彍鍗�
 			firstClassSelect() {
@@ -199,25 +293,146 @@
 				this.haveSelectd = false
 			},
 			formHandle() {
-				console.log(this.globalShowWeigh,'this.globalShowWeigh')
-				this.showWeighCopyStorge = this.globalShowWeigh
-				if (this.productName) {
+				console.log(this.globalShowWeigh,	this.$refs.uForm,'this.globalShowWeigh');
+				this.$refs.uForm.validate().then(res => {
+						// uni.$u.toast('鏍¢獙閫氳繃')
+					
+						this.showWeighCopyStorge = this.globalShowWeigh;
+						console.log(this.showWeighCopyStorge,this.index,'this.showWeighCopyStorge[this.index]');
+				if(this.params.type == 'edit'){
+					if (this.productName) {
 					this.showWeighCopyStorge[this.index].modifyProductName = this.dataForm.secondClass + '/' + this
 						.dataForm.specifications
 					this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass
 					this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications
 				}
 				if (this.unqualified) {
-					this.showWeighCopyStorge[this.index].unqualifiedBreed = this.dataForm.secondClass + '/' + this.dataForm
-						.specifications
+					let str = this.dataForm.secondClass + '/' + this.dataForm
+						.specifications;
+				 	let tempArr = 	this.showWeighCopyStorge[this.index].unqualifiedBreed.split(",")
+					 let tempWeightArr = 	this.showWeighCopyStorge[this.index].unqualifiedWeights.split(",")
+					 let noPinArr =this.showWeighCopyStorge[this.index].unqualifiedType.split(",")
+					 let noPriceArr = this.showWeighCopyStorge[this.index].penaltyUnitPrice.split(",");
+				    tempArr[this.params.indexTo] = str;
+					tempWeightArr[this.params.indexTo] = this.dataForm.unqualifiedWeight;
+					// noPinArr[this.params.indexTo] = this.dataForm.unqualifiedType;
+					noPriceArr[this.params.indexTo] = this.dataForm.penaltyUnitPrice;
+					this.showWeighCopyStorge[this.index].unqualifiedBreed = tempArr.join(',');
+					this.showWeighCopyStorge[this.index].unqualifiedWeights = tempWeightArr.join(',');
+					this.showWeighCopyStorge[this.index].unqualifiedType = noPinArr.join(',');
+					this.showWeighCopyStorge[this.index].penaltyUnitPrice = noPriceArr.join(',');
+					this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass
+					this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications
+					//濡傛灉杩欎釜  tempArr涓嶄负 绌�
+					if(this.showWeighCopyStorge[this.index].tempArr){
+					this.showWeighCopyStorge[this.index].tempArr[this.params.indexTo].firstClass = this.dataForm.firstClass;
+					this.showWeighCopyStorge[this.index].tempArr[this.params.indexTo].secondClass = this.dataForm.secondClass;
+					this.showWeighCopyStorge[this.index].tempArr[this.params.indexTo].specifications = this.dataForm.specifications;
+					}else{
+
+						
+					}
+					
+				}
+				}else{
+					if (this.productName) {
+					this.showWeighCopyStorge[this.index].modifyProductName = this.dataForm.secondClass + '/' + this
+						.dataForm.specifications
 					this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass
 					this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications
 				}
+				if (this.unqualified) {
+					let str = this.dataForm.secondClass + '/' + this.dataForm
+						.specifications;
+				    let tempArr;
+					if(	this.showWeighCopyStorge[this.index].unqualifiedBreed){
+						tempArr = 	this.showWeighCopyStorge[this.index].unqualifiedBreed.split(",").filter(Boolean);
+					}else{
+						tempArr =  []
+					}
+				
+					let tempWeightArr;
+					if(this.showWeighCopyStorge[this.index].unqualifiedWeights){
+						tempWeightArr = 	this.showWeighCopyStorge[this.index].unqualifiedWeights.split(",").filter(Boolean)
+					}else{
+						tempWeightArr =  [];
+					}
+					// 娣诲姞涓嶅悎鏍煎搧绫诲垽瀹�
+				    // let noPin;
+					// if(this.showWeighCopyStorge[this.index].unqualifiedType){
+					// 	noPin = this.showWeighCopyStorge[this.index].unqualifiedType.split(",").filter(Boolean)
+					// }else{
+					// 	noPin = []
+					// }
+					//娣诲姞涓嶅悎鏍煎崟浠�
+					let noPrice;
+					if(this.showWeighCopyStorge[this.index].penaltyUnitPrice){
+						noPrice = this.showWeighCopyStorge[this.index].penaltyUnitPrice.split(",").filter(Boolean)
+					}else{
+						noPrice = []
+					}
+
+					tempWeightArr.push(this.dataForm.unqualifiedWeight);
+					tempArr.push(str);
+					// noPin.push(this.dataForm.unqualifiedType)
+					noPrice.push(this.dataForm.penaltyUnitPrice)
+					this.showWeighCopyStorge[this.index].unqualifiedBreed = tempArr.join(',')
+					this.showWeighCopyStorge[this.index].unqualifiedWeights = tempWeightArr.join(',')
+					// this.showWeighCopyStorge[this.index].unqualifiedType = noPin.join(',') 
+					this.showWeighCopyStorge[this.index].penaltyUnitPrice = noPrice.join(',') 
+
+					this.showWeighCopyStorge[this.index].breed = this.dataForm.secondClass
+					this.showWeighCopyStorge[this.index].spec = this.dataForm.specifications
+
+
+					this.showWeighCopyStorge[this.index].firstClass = this.dataForm.firstClass;
+				    this.showWeighCopyStorge[this.index].secondClass = this.dataForm.secondClass;
+				    this.showWeighCopyStorge[this.index].specifications = this.dataForm.specifications;
+
+					if(!this.showWeighCopyStorge[this.index].tempArr){
+						this.showWeighCopyStorge[this.index].tempArr = [];
+					}
+						this.showWeighCopyStorge[this.index].tempArr.push({
+							firstClass: this.dataForm.firstClass,
+							secondClass:this.dataForm.secondClass,
+							specifications:this.dataForm.specifications
+						})
+					
+				
+				}
+
+				}
+				
+			
+				
 				this.changeglobalShowWeigh(this.showWeighCopyStorge)
 				uni.setStorageSync('showWeighCopyStorgeOther', this.globalShowWeigh)
 				uni.navigateBack({
 					url: `/pages/driver-page/driver-index/bill-of-lading-details/weighDetail/weighDetail?dataForm=${JSON.stringify(this.dataForm)}&orderPlanId=${this.takeCoalId}&index=${this.index}&havedSubmit=${true}`
 				})
+				uni.$emit("handClick",{data:this.dataForm,tempArr:this.showWeighCopyStorge[this.index].tempArr,index:this.index});
+					}).catch(errors => {
+						console.log(errors,'errors')
+						uni.$u.toast('鏍¢獙澶辫触')
+					})
+	
+			},
+			checkNum(value,name){
+				if (
+					value &&
+					value.indexOf(".") < 0 &&
+					value != ""
+					) {
+						value = parseFloat(value);
+						value = value + ""; // 鍙樺洖涓哄瓧绗︿覆
+					}else{
+						value =  value.replace(/^(-)*(\d+)\.(\d\d).*$/,"$1$2.$3");
+						
+					} // 濡傛灉娌℃湁灏忔暟鐐癸紝棣栦綅涓嶈兘涓虹被浼间簬 01銆�02鐨勫��
+					this.$nextTick(()=>{
+							this.dataForm[name]  = value.replace(/[^\d.]/g, "");
+						});
+				
 			}
 		}
 	}

--
Gitblit v1.9.1