From 0eab6dcc163bec041d44bc27c9c89ef9c6ec988d Mon Sep 17 00:00:00 2001
From: yangan <yangan0921@163.com>
Date: 星期四, 26 九月 2024 17:17:39 +0800
Subject: [PATCH] feat:确认装卸bug提交

---
 pages/driver-page/drvier-my/certifiCate/certifiCate.vue |  268 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 211 insertions(+), 57 deletions(-)

diff --git a/pages/driver-page/drvier-my/certifiCate/certifiCate.vue b/pages/driver-page/drvier-my/certifiCate/certifiCate.vue
index 6678aad..662c301 100644
--- a/pages/driver-page/drvier-my/certifiCate/certifiCate.vue
+++ b/pages/driver-page/drvier-my/certifiCate/certifiCate.vue
@@ -8,16 +8,16 @@
 			v-if="certificateData.length===0"></u-empty>
 			<view class="tran-type">
 				<view ><u-button type="primary"
-						@click="editTranClick"
+						@click="editTranClick(-1)"
 						shape="circle"
-						plain>娣诲姞杩愯緭璇�</u-button></view>
+						plain>娣诲姞閫氳璇�</u-button></view>
 			</view>
 		<view class="main"
 			v-if="certificateData.length!==0">
 			<view class="information-block"
 				v-for="item in certificateData"
 				:key="item.id">
-				<view class="detail-block">
+				<view class="detail-block" @click="editTranClick(item.status,item)">
 					<view class="line detail-reason">
 						<u--image :showLoading="true"
 							:src="item.certificateImg != null ? BaseUrl + item.certificateImg : ''"
@@ -55,14 +55,14 @@
 					height="400px"></u--image>
 			</u-popup>
 		</view>
-		<!-- 娣诲姞鍓ф瘨杩愯緭璇� -->
+		<!-- 娣诲姞鍓ф瘨閫氳璇� -->
 		<view class="editDriverPopup-container">
 			<u-popup :show="editTranShow"
 				mode="bottom"
 				@close="editTranClose"
 				@open="editTranOpen"
 				:closeable="true">
-				<combined-title title="杩愯緭璇�"
+				<combined-title title="閫氳璇�"
 					style="margin-left:20rpx"></combined-title>
 				<view class="editDriverPopup-container-box">
 					<u--form labelPosition="left"
@@ -70,7 +70,7 @@
 						:rule="sportRules"
 						ref="sportRef">
 						<u-form-item labelWidth="20%"
-							label="杩愯緭璇佸彿"
+							label="閫氳璇佸彿"
 							prop="certificateNo"
 							required>
 							<u--input v-model="tranSportForm.certificateNo"
@@ -108,7 +108,7 @@
 								type="text"></u--input>
 						</u-form-item>
 						<u-form-item prop="certificateImg"
-							label="杩愯緭璇�"
+							label="閫氳璇�"
 							labelWidth="20%"
 							borderBottom
 							required
@@ -126,13 +126,13 @@
 							</u-upload>
 						</u-form-item>
 						<u-form-item prop="startTime"
-							label="杩愯緭璇佸紑濮嬫椂闂�"
+							label="閫氳璇佸紑濮嬫椂闂�"
 							labelWidth="20%"
 							borderBottom>
 							<uni-datetime-picker v-model="tranSportForm.startTime" type="datetime"  />
 						</u-form-item>
 						<u-form-item prop="expirationTime"
-							label="杩愯緭璇佽繃鏈熸椂闂�"
+							label="閫氳璇佽繃鏈熸椂闂�"
 							labelWidth="20%"
 							borderBottom>
 							<uni-datetime-picker v-model="tranSportForm.expirationTime" type="datetime" :start="minDate" />
@@ -196,6 +196,24 @@
 									border="none"
 									inputAlign="left"></u--input>
 							</u-form-item>
+							<u-form-item prop="certificateImg"
+								label="璧勮川璇佹槑"
+								labelWidth="20%"
+								borderBottom
+								required
+								@click="beforeRead">
+								<u-upload :fileList="item.fileList"
+									deletable
+									@afterRead="afterReads"
+									@delete="deletePics"
+									multiple
+									:name="index.toString()"
+									:maxCount="1"
+									width="250"
+									height="150"
+									:previewFullImage="true">
+								</u-upload>
+							</u-form-item>
 						</view>
 						
 						<u-form-item labelWidth="20%"
@@ -207,7 +225,7 @@
 						</u-form-item>
 					</u--form>
 					<view class="person-utils">
-						<u-button text="鎻愪氦鍓ф瘨杩愯緭璇�"
+						<u-button text="鎻愪氦鍓ф瘨閫氳璇�"
 							@click="updateRoad"
 							:disabled="upload"
 							type="primary"></u-button>
@@ -229,7 +247,8 @@
 				supercargoList:[{
 					driverName:"",
 					driverIdcard:"",
-					driverPhone:""
+					driverPhone:"",
+					fileList:[]
 				}],
 				userInfo: {},
 				scoreDetailList: [],
@@ -264,13 +283,13 @@
 					certificateNo: {
 						type: 'string',
 						required: true,
-						message: '璇峰~鍐欒繍杈撹瘉鍙�',
+						message: '璇峰~鍐欓�氳璇佸彿',
 						trigger: ['blur', 'change']
 					},
 					expirationTime: [{
 						type: 'string',
 						required: true,
-						message: '璇烽�夋嫨杩愯緭璇佽繃鏈熸椂闂�',
+						message: '璇烽�夋嫨閫氳璇佽繃鏈熸椂闂�',
 						trigger: ['blur', 'change']
 					},{
 						pattern: /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
@@ -279,7 +298,7 @@
 					startTime:[{
 						type: 'string',
 						required: true,
-						message: '璇烽�夋嫨杩愯緭璇佸紑濮嬫椂闂�',
+						message: '璇烽�夋嫨閫氳璇佸紑濮嬫椂闂�',
 						trigger: ['blur', 'change']
 					},{
 						pattern: /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
@@ -320,11 +339,6 @@
 			getData(){
 				this.$reqGet('getUserEntity').then(res => {
 					this.userInfo = res.data;
-					this.tranSportForm.carNo=this.userInfo.carNo
-					this.driverList[0]={
-					driverName:this.userInfo.name,
-					driverIdcard:this.userInfo.idCard
-				}
 					this.$reqGetId('getDriverListById', this.userInfo.userId).then(res => {
 						this.certificateData = res.data;
 					});
@@ -340,6 +354,10 @@
 				this.previewImageShow = false;
 			},
 			previewImageOpen() {},
+			deletePics(event) {
+				this.changeisUploadimg(true);
+				this.supercargoList[event.name].fileList.splice(event.index, 1);
+			},
 			// 鍒犻櫎
 			deletePic(event) {
 				this.changeisUploadimg(true);
@@ -372,8 +390,40 @@
 					}
 				});
 			},
-			editTranClick(){
-				this.editTranShow = true;
+			editTranClick(e,data){
+				if(e==-1){
+					this.editTranShow = true;
+					this.tranSportForm={
+						carNo:"",
+						productId:"",
+						customerId:""
+					}
+					 this.driverList=[]
+					 this.supercargoList=[]
+					 this.fileList9=[]
+					 this.tranSportForm.carNo=this.userInfo.carNo
+					 this.driverList[0]={
+					 	driverName:this.userInfo.name,
+					 	driverIdcard:this.userInfo.idCard
+					 }
+					if(data){
+						this.tranSportForm=Object.assign({},this.tranSportForm,data)
+						if((!this.tranSportForm.supercargoInfo==''||null)||(!this.tranSportForm.highlyToxicImg==''||null) ){
+							this.supercargoList =this.tranSportForm.supercargoInfo.split(",").map((item,index)=>{
+								return {driverName:item.split("|")[0],driverIdcard:item.split("|")[1],driverPhone:item.split("|")[2],fileList:[{url:`${BaseUrl}${this.tranSportForm.highlyToxicImg.split(',')[index]}`}]}
+							})
+						}
+						this.driverList=this.tranSportForm.driverName.split(",").map((item,index)=>{
+							return {driverName:item,driverIdcard:this.tranSportForm.driverIdcard.split(",")[index]}
+						})
+						if (this.fileList9.length == 0 && this.tranSportForm.certificateImg) {
+							this.fileList9.push({
+								url: `${BaseUrl}${this.tranSportForm.certificateImg}`
+							});
+						}
+					}
+				}
+				
 			},
 			editTranClose(){
 				this.editTranShow = false;
@@ -387,7 +437,7 @@
 						let idcardtext=/^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
 						if (this.fileList9.length==0) {
 							uni.showToast({
-								title: '璇烽�夋嫨杩愯緭璇侊紒',
+								title: '璇烽�夋嫨閫氳璇侊紒',
 								icon: 'error',
 								duration: 2000
 							});
@@ -455,6 +505,13 @@
 										duration: 2000
 									});
 									submit=false
+								}else if(item.fileList.length==0){
+									uni.showToast({
+										title: `璇蜂笂浼犺祫璐ㄨ瘉鏄庯紒`,
+										icon: 'error',
+										duration: 2000
+									});
+									submit=false
 								}
 							})
 						}
@@ -462,6 +519,7 @@
 							   let driverName=""
 							   let driverIdcard=""
 							   let supercargoInfo=''
+							   let highlyToxicImg=''
 							   driverName = this.driverList.map((item, index) => {
 							           return item.driverName;
 							         }).join(",");
@@ -471,42 +529,137 @@
 							   supercargoInfo = this.supercargoList.map((item, index) => {
 							   	 return item.driverName+ '|'+item.driverIdcard+"|"+item.driverPhone
 							      }).join(",");
-							   this.$reqPost('addJcroadtransport', {
-							   	userId:this.userInfo.userId,
-							   	...this.tranSportForm,
-							   	driverName:driverName,
-							   	driverIdcard:driverIdcard,
-							   	supercargoInfo:supercargoInfo
-							   }, 'json').then(res => {
-							   	if (res.code == 0) {
-							   		this.editTranShow = false;
-							   		this.$u.toast('鎻愪氦鎴愬姛');
-							   		this.tranSportForm={
-							   			carNo:"",
-							   			productId:"",
-							   			customerId:""
-							   		}
-							   		this.driverList=[{
-							   			driverName:"",
-							   			driverIdcard:""
-							   		}]
-							   		this.supercargoList=[{
-							   			driverName:"",
-							   			driverIdcard:"",
-							   			driverPhone:""
-							   		}]
-							   		this.fileList9=[]
-							   		this.getData();
-							   	} else {
-							   		uni.showToast({
-							   			title: res.msg,
-							   			icon: 'none',
-							   			duration: 2000
-							   		});
-							   	}
-							   })
+								highlyToxicImg= this.supercargoList.map((item, index) => {
+									return item.fileList[0].url.replace(BaseUrl,'')
+							      }).join(",")
+								  if(this.tranSportForm.id){
+									this.$reqPut('putJcroadtransport',{
+										id:this.tranSportForm.id,
+										certificateNo:this.tranSportForm.certificateNo,
+										carNo:this.tranSportForm.carNo,
+										certificateImg:this.tranSportForm.certificateImg,
+										customerName:this.tranSportForm.customerName,
+										productName:this.tranSportForm.productName,
+										startTime:this.tranSportForm.startTime,
+										expirationTime:this.tranSportForm.expirationTime,
+										status:0,
+										customerId:this.tranSportForm.customerId,
+										productId:this.tranSportForm.productId,
+										userId:this.userInfo.userId,
+										driverName:driverName,
+										driverIdcard:driverIdcard,
+										supercargoInfo:supercargoInfo,
+										highlyToxicImg:highlyToxicImg
+									}, 'json').then(res => {
+										if (res.code == 0) {
+											this.editTranShow = false;
+											this.$u.toast('鎻愪氦鎴愬姛');
+											this.tranSportForm={
+												carNo:"",
+												productId:"",
+												customerId:""
+											}
+											this.driverList=[{
+												driverName:"",
+												driverIdcard:""
+											}]
+											this.supercargoList=[{
+												driverName:"",
+												driverIdcard:"",
+												driverPhone:"",
+												fileList:[]
+											}]
+											this.fileList9=[]
+											this.getData();
+										} else {
+											uni.showToast({
+												title: res.msg,
+												icon: 'none',
+												duration: 2000
+											});
+										}
+									})
+								  }else{
+									this.$reqPost('addJcroadtransport', {
+										userId:this.userInfo.userId,
+										...this.tranSportForm,
+										driverName:driverName,
+										driverIdcard:driverIdcard,
+										supercargoInfo:supercargoInfo,
+										highlyToxicImg:highlyToxicImg
+									}, 'json').then(res => {
+										if (res.code == 0) {
+											this.editTranShow = false;
+											this.$u.toast('鎻愪氦鎴愬姛');
+											this.tranSportForm={
+												carNo:"",
+												productId:"",
+												customerId:""
+											}
+											this.driverList=[{
+												driverName:"",
+												driverIdcard:""
+											}]
+											this.supercargoList=[{
+												driverName:"",
+												driverIdcard:"",
+												driverPhone:"",
+												fileList:[]
+											}]
+											this.fileList9=[]
+											this.getData();
+										} else {
+											uni.showToast({
+												title: res.msg,
+												icon: 'none',
+												duration: 2000
+											});
+										}
+									})
+								  }
 						   }
 					})
+			},
+			async afterReads(event) {
+				// 褰撹缃� mutiple 涓� true 鏃�, file 涓烘暟缁勬牸寮忥紝鍚﹀垯涓哄璞℃牸寮�
+				let lists = [].concat(event.file);
+				let fileListLen = this.supercargoList[event.name].fileList.length;
+				lists.map(item => {
+					this.supercargoList[event.name].fileList.push({
+						...item,
+						status: 'uploading',
+						message: '涓婁紶涓�'
+					});
+				});
+				for (let i = 0; i < lists.length; i++) {
+					const result = await this.uploadFilePromises(lists[i].url, event.name);
+					let item = this.supercargoList[event.name].fileList[fileListLen];
+					this.supercargoList[event.name].fileList.splice(
+						fileListLen,
+						1,
+						Object.assign(item, {
+							status: 'success',
+							message: '涓婁紶鎴愬姛',
+							url: result
+						})
+					);
+					fileListLen++;
+				}
+			},
+			uploadFilePromises(url, num) {
+				return new Promise((resolve, reject) => {
+					let a = uni.uploadFile({
+						url: BaseUrl + '/admin/sys-file/uploadUnToken',
+						filePath: url,
+						name: 'file',
+						// formData: {
+						// 	user: 'test'
+						// },
+						success: res => {
+								resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
+						}
+					});
+				});
 			},
 			async afterRead(event) {
 				// 褰撹缃� mutiple 涓� true 鏃�, file 涓烘暟缁勬牸寮忥紝鍚﹀垯涓哄璞℃牸寮�
@@ -566,7 +719,8 @@
 				this.supercargoList.push({
 					driverName:"",
 					driverIdcard:"",
-					driverPhone:""
+					driverPhone:"",
+					fileList:[]
 				})
 			},
 			addDriver(){

--
Gitblit v1.9.1