<template>
	<view class="wrap">
		<view>
			<view style='margin-left:10px;'>任务详情</view>
			<view class="content">
				<view class="row">
					<view class="left">任务编号</view>
					<view>{{detailData.processNo}}</view>
				</view>
				<view class="row">
					<view class="left">货名</view>
					<view>{{detailData.goodsName}}</view>
				</view>
				<view class="row">
					<view class="left">重量</view>
					<view>{{detailData.weight}}</view>
				</view>
				<view class="row">
					<view class="left">发货地址</view>
					<view>{{detailData.sendPrivate}}{{detailData.sendCity}}{{detailData.sendArea}}</view>
				</view>
				<view class="row">
					<view class="left">发货人</view>
					<view>{{detailData.sender}}</view>
				</view>
				<view class="row">
					<view class="left">发货人电话</view>
					<view>{{detailData.senderPhone}}</view>
				</view>
				<view class="row">
					<view class="left">收货地址</view>
					<view>{{detailData.receivePrivate}}{{detailData.receiveCity}}{{detailData.receiveArea}}</view>
				</view>
				<view class="row">
					<view class="left">收货人</view>
					<view>{{detailData.receiver}}</view>
				</view>
				<view class="row">
					<view class="left">收货人电话</view>
					<view>{{detailData.receiverPhone}}</view>
				</view>
				<view class="row">
					<view class="left">发货日期</view>
					<view>{{detailData.deliveryDateStart}}</view>
				</view>
				<view class="row">
					<view class="left">最晚到货日期</view>
					<view>{{detailData.deliveryDateEnd}}</view>
				</view>
				<view class="row">
					<view class="left">合同编号</view>
					<view>{{detailData.contractNo}}</view>
				</view>
				<view class="row">
					<view class="left">运输方式</view>
					<view>{{detailData.tranType}}</view>
				</view>
			</view>
		</view>
		
		<view>
			<view v-if='detailData.tranType=="火运"' style='margin-left:10px;'>联络员及车次</view>
			<view v-if='detailData.tranType=="火运"' class="content">
				<view class="row">
					<view class="left">姓名</view>
					<view>{{detailData.driver}}</view>
				</view>
				<view class="row">
					<view class="left">电话</view>
					<view>{{detailData.driverPhone}}</view>
				</view>
				<view class="row">
					<view class="left">发车日期</view>
					<view>
						<view @click='show1=true'>{{detailData.sendDateStart}}</view>
						<u-picker v-model="show1" mode="time" @confirm='dateChange($event)' :params="params">
						</u-picker>
					</view>
				</view>
				<view class="row">
					<view class="left">预计到站日期</view>
					<view> 
						<view>{{detailData.receiveDateEnd}}</view>
					</view>
				</view>
				<view class="row">
					<view class="left">车型</view>
					<view> 
						<view>{{detailData.carModel}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<view v-if='detailData.tranType=="船运"' class="content">
			<view class="row">
				<view class="left">姓名</view>
				<view>{{detailData.driver}}</view>
			</view>
			<view class="row">
				<view class="left">电话</view>
				<view>{{detailData.driverPhone}}</view>
			</view>
			<view class="row">
				<view class="left">发船日期</view>
				<view>
					<view @click='show1=true'>{{detailData.sendDateStart}}</view>
					<u-picker v-model="show1" mode="time" @confirm='dateChange($event)' :params="params">
					</u-picker>
				</view>
			</view>
			<view class="row">
				<view class="left">预计到港日期</view>
				<view> 
					<view>{{detailData.receiveDateEnd}}</view>
				</view>
			</view>
			<view class="row">
				<view class="left">船名</view>
				<view> 
					<view>{{detailData.shipName}}</view>
				</view>
			</view>
			<view class="row">
				<view class="left">航次</view>
				<view> 
					<view>{{detailData.shipNo}}</view>
				</view>
			</view>
			<view class="row">
				<view class="left">类型</view>
				<view> 
					<view>{{detailData.shipType}}</view>
				</view>
			</view>
			<view v-if="detailData.shipType == '集装箱'" class="row">
				<view class="left">数量</view>
				<view> 
					<view>{{detailData.boxNumber}}</view>
				</view>
			</view>
		</view>
		<view v-if='detailData.tranType=="火运"'>
			<view style='margin-left:10px;'>装车详情</view>
			<view v-for='(item,index) in freightspace' class="content">
				<view class="row">
					<view class="left">车厢号-{{index+1}}</view>
					<view>{{item.boxNo}}</view>
				</view>
				<view class="row">
					<view class="left">装车净重</view>
					<view v-if="item.status == '已装车' || item.status == '已送达'">{{item.loadNetWeight}}</view>
					<view style='text-align:right;' v-else>
						<input  v-model='item.loadNetWeight' class="right-bottom"
					placeholder="输入毛重"></input>
					</view>
				</view>
				<view class="row">
					<view class="left">磅单</view>
					<view v-if="item.status == '已装车' || item.status == '已送达'" v-for="(items,count) in item.imgUrl">
						<view class="pound_list1">
							<image v-if="items.url"  @click='shadeshow(item.loadPoundImg)' style='width:100px;height:100px;margin: 0rpx;' :src="items.url" mode=""></image>
						     <view v-else>暂无图片</view>
						</view>
						
					</view>
					<view v-else class="pound_list">
						<!-- <image v-if="item.loadPoundImg"  @click='shadeshow(item.loadPoundImg)' style='width:100px;height:100px;' :src="item.loadPoundImg" mode=""></image> -->
						<upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="9" :file-list="item.imgUrl"
							:size-type="['compressed']" :imgIndex='index' @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
							@on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
					</view>
				</view>
				<view class="row">
					<view class="left">装车日期</view>
					<view>
						<view v-if="item.status == '已装车' || item.status == '已送达'">{{item.loadingDate}}</view>
						<view v-else @click='train(index)'>{{item.loadingDate?item.loadingDate:'请选择日期'}}</view>
						<u-picker v-model="item.show2" mode="time" @cancel='datecancel()' @confirm='dateChange1($event,item)' :params="params">
						</u-picker>
					</view>
				</view>
				<view style='text-align:right;' v-if="item.status == '已装车' || item.status == '已送达'">{{item.status}}</view>
				<u-button v-else @click='submit(index,2)' type="success">保存</u-button>
			</view>
		</view>
		<view v-if='detailData.tranType=="汽运"'>
			<view style='margin-left:10px;'>装车详情</view>
			<view v-for='(item,index) in freightspace' class="content">
				<view class="row">
					<view class="left">司机-{{index+1}}</view>
					<view>{{item.status}}</view>
				</view>
				<view class="row">
					<view class="left">姓名</view>
					<view>{{item.driver}}</view>
				</view>
				<view class="row">
					<view class="left">司机电话</view>
					<view>{{item.driverPhone}}</view>
				</view>
				<view class="row">
					<view class="left">车牌号</view>
					<view>{{item.carNo}}</view>
				</view>
				<view class="row">
					<view class="left">装车净重</view>
					<view v-if="item.status == '已装车' || item.status == '已送达'">{{item.loadNetWeight}}</view>
					<view style='text-align:right;' v-else>
						<input  v-model='item.loadNetWeight' class="right-bottom"
					placeholder="输入毛重"></input>
					</view>
				</view>
				<view class="row">
					<view class="left">装车日期</view>
					<view>
						<view v-if="item.status == '已装车' || item.status == '已送达'">{{item.sendDateStart}}</view>
						<view v-else @click='train(index)'>{{item.sendDateStart?item.sendDateStart:'请选择日期'}}</view>
						<u-picker v-model="item.show2" mode="time" @cancel='datecancel()' @confirm='dateChange2($event,index)' :params="params">
						</u-picker>
					</view>
				</view>
				<view class="row">
					<view class="left">磅单</view>
					<view v-if="item.loadPoundImg">
						<image style='width:100px;height:100px;' @click='shadeshow(item.loadPoundImg)' :src="item.loadPoundImg" mode=""></image>
					</view>
					<view v-else class="pound_list">
						<upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="9" :file-list="item.imgUrl"
							:size-type="['compressed']" :imgIndex='index' @on-success="getImgUrl" @on-error="onError" @on-remove="onRemove"
							@on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
					</view>
				</view>
				<view class="row">
					<view class="left">箱号</view>
					<view>{{item.caseNo}}</view>
				</view>
				<view class="row">
					<view class="left">封号</view>
					<view>{{item.titleNo}}</view>
				</view>
				<view v-if="item.signStatus == '未签合同'">未签合同</view>
				<view v-if="item.signStatus == '已签合同'">已签合同</view>
				<u-button v-if="item.status != '已装车' && item.status != '已送达'" @click='submit(index,1)' type="success">保存</u-button>
			</view>
		</view>
		<view v-if='detailData.tranType=="船运"'>
			<view style='margin-left:10px;'>装船详情</view>
			<view v-for='(item,index) in freightspace' class="content">
				<view v-if="item.shipType == '集装箱'" class="row">
					<view class="left">集装箱-{{index+1}}</view>
					<view v-if="item.status == '未装车'">未装船</view>
					<view v-if="item.status == '已装车'">已装船</view>
					<view v-if="item.status == '已送达'">{{item.status}}</view>
				</view>
				<view v-if="item.shipType == '散船'" class="row">
					<view class="left">仓位号-{{index+1}}</view>
					<view v-if="item.status == '未装车'">未装船</view>
					<view v-if="item.status == '已装车'">已装船</view>
					<view v-if="item.status == '已送达'">{{item.status}}</view>
				</view>
				<view v-if="item.shipType == '集装箱'" class="row">
					<view class="left">箱号</view>
					<view style='text-align:right;'>
						<view  v-if="item.status == '已装车' || item.status == '已送达'">{{item.caseNo}}</view>
						<input v-else placeholder="请输入箱号" v-model='item.caseNo' type="text">
					</view>
				</view>
				<view v-if="item.shipType == '集装箱'" class="row">
					<view class="left">封号</view>
					<view style='text-align:right;'>
						<view  v-if="item.status == '已装车' || item.status == '已送达'">{{item.titleNo}}</view>
						<input v-else placeholder="请输入封号" v-model='item.titleNo' type="text">
					</view>
				</view>
				<view v-if="item.shipType == '散船'" class="row">
					<view class="left">仓位号</view>
					<view>
						<view>{{item.binNumber}}</view>
					</view>
				</view>
				<view v-if="item.shipType == '散船'" class="row">
					<view class="left">计划重量</view>
					<view>
						<view>{{item.positionWeight}}</view>
					</view>
				</view>
				<view class="row">
					<view class="left">装船净重</view>
					<view v-if="item.status == '已装车' || item.status == '已送达'">{{item.loadNetWeight}}</view>
					<view style='text-align:right;' v-else>
						<input  v-model='item.loadNetWeight' class="right-bottom"
					placeholder="输入毛重"></input>
					</view>
				</view>
				<view class="row">
					<view class="left">装船日期</view>
					<view>
						<view v-if="item.status == '已装车' || item.status == '已送达'">{{item.loadingDate}}</view>
						<view v-else @click='train(index)'>{{item.loadingDate?item.loadingDate:'请选择日期'}}</view>
						<u-picker v-model="item.show2" mode="time"  @cancel='datecancel()' @confirm='dateChange1($event,index)' :params="params">
						</u-picker>
					</view>
				</view>
				<view style='text-align:right;' v-if="item.status == '已装车'">未装船</view>
				<view style='text-align:right;' v-else-if="item.status == '已送达'">已装船</view>
				<u-button v-else @click='submit(index,3)' type="success">保存</u-button>
			</view>
			<view class="row">
				<view style='margin-left:10px;' class="left">运单</view>
				<view v-if="pictureTotal.length>0">
					<image  v-for='item in pictureTotal' @click='shadeshow(item)' style='width:100px;height:100px;margin:5px;' :src="item" mode=""></image>
				</view>
				<view >
					<upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="9" :file-list="imgUrl"
						:size-type="['compressed']"  @on-success="getImgUrl1" @on-error="onError" @on-remove="onRemove"
						@on-uploaded="isAdd = true" :before-upload="filterFileType" @on-progress="onProgress"></upload>
				</view>
			</view>
		</view>
		<view>合计吨：{{ total }}/{{ detailData.weight }}
			<text style='margin-left:10px;'
			class="noservice"
			v-show="detailData.receivingStatus == '执行中'">未完货</text>
			<text
			class="service"
			v-show="detailData.receivingStatus == '已完货'">{{ detailData.receivingStatus }}</text>
		</view>
		<view style='padding:10px;' class='flex bottom-btn'>
			<u-button  @click='pass' type="error" class="btn1" hover-class='none'>提交</u-button>
			<u-button  @click='finishedgoods' type="success" class="btn2">完货</u-button>
		</view>
		<view @click='imgShow=false' v-if="imgShow" class="shade">
			<image style='position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;' :src="url" mode=""></image>
		</view>
	</view>
</template>

<script>
	import upload from '@/components/upload.vue';
	import helper from '@/common/helper.js';
	export default {
		components: {
			upload
		},
		data() {
			return {
				id:'',
				show1: false,
				show2: false,
				currentPage: 1,
				pageSize: 10,
				show1:false,
				positionId: "",
				binNumber: "",
				maxSize: 50 * 1024 * 1024,
				status: '执行中',
				positionName: '',
				pictureTotal:[],
				statusList: [
					{name:'执行中',value:1},
					{name:'已完货',value:2},
					{name:'全部任务',value:3},
				],
				params: {
					year: true,
					month: true,
					day: true,
				},
				imgUrl:[],
				unloadPoundImg:'',
				action: this.$uploadUrl,
				freightspace:[
					{
						imgUrl:[],
					}
					
				],
				feedbackFlag:1,
				detailData:{},
				allWarehouse: [],
				showTime: '',
				index:0,
				imgShow:false,
				url:''
			}
		},
		onLoad(options) {
			this.id = options.id
		},
		onShow() {
			this.getList()
		},
		computed: {
		    total: function () {
		      var maxStorage = 0
			  if(this.detailData.tranCarInfoList){
				for (var i = 0; i < this.detailData.tranCarInfoList.length; i++) {
					maxStorage += Number(
					  this.detailData.tranCarInfoList[i].loadNetWeight
					)
				  } 
			  }
		      return maxStorage
		    },
		 },
		methods: {
			shadeshow(url){
				this.imgShow=true
				this.url=url
			},
			datecancel(){
				this.freightspace[this.index].show2=true
				this.$forceUpdate();
			},
			getImgUrl1(res1,res2,res3,res4){
				console.log(res1,res2,res3,res4)
				if (this.freightspace[0].loadPoundImg) {
					this.freightspace[0].loadPoundImg += ',' + res1
				} else {
					this.freightspace[0].loadPoundImg = res1
				}
			},
			submit(index,status){
				var that = this
				if(this.detailData.tranType=='火运'){
					if (!this.freightspace[index].loadNetWeight) {
						this.$api.msg('装车净重不能为空！')
						return
					}
					if (
						this.freightspace[index].loadNetWeight < 0 ||
						this.freightspace[index].loadNetWeight > 10000
					) {
						this.$api.msg('装车净重输入错误！')
						return
					}
					if (!this.freightspace[index].loadingDate) {
						this.$api.msg('装车日期不能为空！')
						return
					}
					var tranProcessInfo = {}
					tranProcessInfo.flag=0
					tranProcessInfo.id=that.freightspace[index].id
					tranProcessInfo.infoId = that.detailData.infoId
					tranProcessInfo.processId = that.detailData.id
					tranProcessInfo.driver = that.detailData.driver
					tranProcessInfo.driverPhone = that.detailData.driverPhone
					tranProcessInfo.tranCarNo = that.detailData.tranCarNo
					tranProcessInfo.carNo = that.detailData.carNo
					tranProcessInfo.loadNetWeight = that.freightspace[index].loadNetWeight
					tranProcessInfo.loadingDate = that.freightspace[index].loadingDate
					tranProcessInfo.loadPoundImg = that.freightspace[index].loadPoundImg
					tranProcessInfo.tranType = status
					tranProcessInfo.contractNo = that.detailData.contractNo
					that.$api.doRequest('post', '/tranCarInfo/api/feedbackTranCar', tranProcessInfo).then(res => {
						if (res.data.code == 200) {
							that.$api.msg('保存成功')
							that.detailData = {}
							that.freightspace = {}
							uni.navigateBack({})
						}
					})
							// }
						// }
					// })
				}else if(this.detailData.tranType=='船运'){
					if (this.freightspace[index].shipType == '集装箱'&&!this.freightspace[index].caseNo) {
						this.$api.msg('箱号不能为空！')
						return
					}
					if (
						this.freightspace[index].shipType == '集装箱'&&this.freightspace[index].caseNo.length > 15 ||
						this.freightspace[index].shipType == '集装箱'&&this.freightspace[index].caseNo.length < 1) {
						this.$api.msg('箱号输入错误！')
						return
					}
					if (this.freightspace[index].shipType == '集装箱'&&!this.freightspace[index].titleNo) {
						this.$api.msg('封号不能为空！')
						return
					}
					if (
						this.freightspace[index].shipType == '集装箱'&&this.freightspace[index].titleNo.length > 15 ||
						this.freightspace[index].shipType == '集装箱'&&this.freightspace[index].titleNo.length < 1
					) {
						this.$api.msg('封号输入错误！')
						return
					}
					if (!this.freightspace[index].loadNetWeight) {
						this.$api.msg('装船净重不能为空！')
						return
					}
					if (
						this.freightspace[index].loadNetWeight < 0 ||
						this.freightspace[index].loadNetWeight > 10000
					) {
						this.$api.msg('装船净重输入错误！')
						return
					}
					if (!this.freightspace[index].loadingDate) {
						this.$api.msg('装船日期不能为空！')
						return
					}
					var tranProcessInfo = {}
					tranProcessInfo.flag=0
					tranProcessInfo.id=that.freightspace[index].id
					tranProcessInfo.infoId = that.detailData.infoId
					tranProcessInfo.processId = that.detailData.id
					tranProcessInfo.driver = that.detailData.driver
					tranProcessInfo.driverPhone = that.detailData.driverPhone
					tranProcessInfo.tranCarNo = that.detailData.tranCarNo
					tranProcessInfo.caseNo = that.freightspace[index].caseNo
					tranProcessInfo.titleNo = that.freightspace[index].titleNo                    
					tranProcessInfo.loadNetWeight = that.freightspace[index].loadNetWeight
					tranProcessInfo.loadingDate = that.freightspace[index].loadingDate
					tranProcessInfo.loadPoundImg = that.freightspace[index].loadPoundImg
					tranProcessInfo.tranType = status
					tranProcessInfo.contractNo = that.detailData.contractNo
					that.$api.doRequest('post', '/tranCarInfo/api/feedbackTranCar', tranProcessInfo).then(res => {
						if (res.data.code == 200) {
							that.$api.msg('保存成功')
							that.detailData = {}
							that.freightspace = {}
							uni.navigateBack({})
						}
					})
				}else if(this.detailData.tranType=='汽运'){
					if (!this.freightspace[index].driver) {
						that.$api.msg('司机姓名不能为空！')
						return
					}
					if (!this.freightspace[index].driverPhone) {
						that.$api.msg('司机电话不能为空！')
						return
					}
					if (!this.freightspace[index].carNo) {
						that.$api.msg('车牌号不能为空！')	
						return
					}
					if (!this.freightspace[index].loadNetWeight) {
						that.$api.msg('装载净重不能为空！')
						return
					}
					var tranProcessInfo = {}
					tranProcessInfo.flag=0
					tranProcessInfo.id=that.freightspace[index].id
					tranProcessInfo.infoId = that.detailData.infoId
					tranProcessInfo.processId = that.detailData.id
					tranProcessInfo.driver = that.detailData.driver
					tranProcessInfo.driverPhone = that.detailData.driverPhone
					tranProcessInfo.tranCarNo = that.detailData.tranCarNo
					tranProcessInfo.carNo = that.freightspace[index].carNo
					tranProcessInfo.caseNo = that.freightspace[index].caseNo
					tranProcessInfo.titleNo = that.freightspace[index].titleNo                    
					tranProcessInfo.loadNetWeight = that.freightspace[index].loadNetWeight
					tranProcessInfo.sendDateStart = that.freightspace[index].sendDateStart
					tranProcessInfo.loadPoundImg = that.freightspace[index].loadPoundImg
					tranProcessInfo.tranType = status
					tranProcessInfo.contractNo = that.detailData.contractNo
					that.$api.doRequest('post', '/tranCarInfo/api/feedbackTranCar', tranProcessInfo).then(res => {
						if (res.data.code == 200) {
							that.$api.msg('保存成功')
							that.detailData = {}
							that.freightspace = {}
							uni.navigateBack({})
						}
					})
				}
			},
			finishedgoods(){
				var that = this
				if(this.detailData.tranType=='火运'){
					uni.showModal({
						content: "完货操作后，装车信息不可修改，是否确定完货？",
						success(res) {
							if (res.confirm) {
								uni.showLoading({title: '加载中'});
								that.tranCarInfoList = that.freightspace
								that.tranCarInfoList.driver = that.detailData.driver
								that.tranCarInfoList.driverPhone = that.detailData.driverPhone
								that.tranCarInfoList.tranCarNo = that.detailData.tranCarNo
								that.tranCarInfoList.carNo = that.detailData.carNo
								that.tranCarInfoList[0].sendDateStart = that.detailData.sendDateStart
								that.tranCarInfoList.loadNetWeight = that.detailData.loadNetWeight
								that.tranCarInfoList.tranType = that.tranType
								that.tranCarInfoList.loadPoundImg = that.detailData.loadPoundImg
								            // this.tranCarInfoList.boxNo = this.arr.toString()
								for (var i = 0; i < that.tranCarInfoList.length; i++) {
									that.tranCarInfoList[i].id = that.freightspace[i].id
									if (that.tranCarInfoList[i].temporaryDriverFlag != 0) {
											that.tranCarInfoList[i].temporaryDriverFlag = 1
											that.tranCarInfoList[i].tranType = that.tranType
									}
								}
								var tranProcessInfo = {}
								tranProcessInfo.id = that.detailData.id
								tranProcessInfo.infoId = that.detailData.infoId
								tranProcessInfo.processNo = that.detailData.processNo
								tranProcessInfo.tranPrice = that.detailData.tranPrice
								tranProcessInfo.tranCarInfoList = that.tranCarInfoList
								that.$api.doRequest('post', '/tranProcessInfo/api/editFeedbackStatus', tranProcessInfo).then(res => {
									if (res.data.code == 200) {
										uni.hideLoading()
										that.$api.msg('完货成功')
										that.detailData = {}
										that.freightspace = {}
										setTimeout(function() {
										         uni.navigateBack({})
										     }, 1000);
									}
								})
							}
						}
					})
				}else if(this.detailData.tranType=='船运'){
					uni.showModal({
						content: "完货操作后，装船信息不可修改，是否确定完货？",
						success(res) {
							if (res.confirm) {
								uni.showLoading({title: '加载中'});
								var tranProcessInfo = {}
								tranProcessInfo.id = that.detailData.id
								that.$api.doRequest('post', '/tranProcessInfo/api/editFeedbackStatus', tranProcessInfo).then(res => {
									if (res.data.code == 200) {
										uni.hideLoading()
										that.$api.msg('完货成功')
										that.detailData = {}
										that.freightspace = {}
										setTimeout(function() {
										         uni.navigateBack({})
										     }, 1000);
									}
								})
							}
						}
					})
				}else if(this.detailData.tranType=='汽运'){
					uni.showModal({
						content: "完货操作后，装车信息不可修改，是否确定完货？",
						success(res) {
							if (res.confirm) {
								uni.showLoading({title: '加载中'});
								var tranProcessInfo = {}
								tranProcessInfo.id = that.detailData.id
								that.$api.doRequest('post', '/tranProcessInfo/api/editFeedbackStatus', tranProcessInfo).then(res => {
									if (res.data.code == 200) {
										uni.hideLoading()
										that.$api.msg('完货成功')
										that.detailData = {}
										that.freightspace = {}
										uni.navigateBack({})
										setTimeout(function() {
										         uni.navigateBack({})
										     }, 1000);
									}
								})
							}
						}
					})
				}
			},
			pass(){
				
				var that = this
				if(this.detailData.tranType=='火运'){
					for(var i=0;i<this.freightspace.length;i++){
						if (!this.freightspace[i].loadNetWeight) {
							this.$api.msg('装车净重不能为空！')
							return
						}
						if (
							this.freightspace[i].loadNetWeight < 0 ||
							this.freightspace[i].loadNetWeight > 10000
						) {
							this.$api.msg('装车净重输入错误！')
							return
						}
						if (!this.freightspace[i].loadingDate) {
							this.$api.msg('装车日期不能为空！')
							return
						}
					}
					uni.showModal({
						content: "提交成功后提醒司机及时签订运输合同，确定提交装车信息？",
						success(res) {
							if (res.confirm) {
								uni.showLoading({title: '加载中'});
								that.tranCarInfoList = that.freightspace
								that.tranCarInfoList.driver = that.detailData.driver
								that.tranCarInfoList.driverPhone = that.detailData.driverPhone
								that.tranCarInfoList.tranCarNo = that.detailData.tranCarNo
								that.tranCarInfoList.carNo = that.detailData.carNo
								that.tranCarInfoList[0].sendDateStart = that.detailData.sendDateStart
								that.tranCarInfoList.loadNetWeight = that.detailData.loadNetWeight
								that.tranCarInfoList.tranType = that.tranType
								that.tranCarInfoList.loadPoundImg = that.detailData.loadPoundImg
								            // this.tranCarInfoList.boxNo = this.arr.toString()
								for (var i = 0; i < that.tranCarInfoList.length; i++) {
									that.tranCarInfoList[i].id = that.freightspace[i].id
									if (that.tranCarInfoList[i].temporaryDriverFlag != 0) {
											that.tranCarInfoList[i].temporaryDriverFlag = 1
											that.tranCarInfoList[i].tranType = that.tranType
									}
								}
								var tranProcessInfo = {}
								tranProcessInfo.id = that.detailData.id
								tranProcessInfo.infoId = that.detailData.infoId
								tranProcessInfo.processNo = that.detailData.processNo
								tranProcessInfo.tranPrice = that.detailData.tranPrice
								tranProcessInfo.tranCarInfoList = that.tranCarInfoList
								that.$api.doRequest('post', '/tranProcessInfo/api/insertTranCar', tranProcessInfo).then(res => {
									if (res.data.code == 200) {
										uni.hideLoading()
										that.$api.msg('提交成功')
										that.detailData = {}
										that.freightspace = {}
										setTimeout(function() {
										         uni.navigateBack({})
										     }, 1000);
									}
								})
							}
						}
					})
				}else if(this.detailData.tranType=='船运'){
					for(var i=0;i<this.freightspace.length;i++){
						if (this.freightspace[i].loadNetWeight&&this.freightspace[i].loadNetWeight < 0 ||this.freightspace[i].loadNetWeight&&this.freightspace[i].loadNetWeight > 10000) {
							this.$api.msg('装船净重输入错误！')
							return
						}
					}
					uni.showModal({
						content: "提交成功后装船信息不可修改，是否确定提交？",
						success(res) {
							if (res.confirm) {
								uni.showLoading({title: '加载中'});
								that.tranCarInfoList = that.freightspace
								that.tranCarInfoList[0].sendDateStart = that.detailData.sendDateStart
								for (var i = 0; i < that.tranCarInfoList.length; i++) {
									that.tranCarInfoList[i].id = that.freightspace[i].id
								}
								var tranProcessInfo = {}
								tranProcessInfo.id = that.detailData.id
								tranProcessInfo.infoId = that.detailData.infoId
								tranProcessInfo.processNo = that.detailData.processNo
								tranProcessInfo.tranCarInfoList = that.tranCarInfoList
								that.$api.doRequest('post', '/tranProcessInfo/api/insertTranCar', tranProcessInfo).then(res => {
									if (res.data.code == 200) {
										uni.hideLoading()
										that.$api.msg('提交成功')
										that.detailData = {}
										that.freightspace = {}
										setTimeout(function() {
										         uni.navigateBack({})
										     }, 1000);
									}else{
										uni.hideLoading()
										that.$api.msg('系统异常，请联系管理员')
									}
								})
							}
						}
					})
				}else if(this.detailData.tranType=='汽运'){
					uni.showModal({
						content: "提交成功后提醒司机及时签订运输合同，确定提交装车信息？",
						success(res) {
							if (res.confirm) {
								uni.showLoading({title: '加载中'});
								that.tranCarInfoList = that.freightspace
								that.tranCarInfoList.driver = that.detailData.driver
								that.tranCarInfoList.driverPhone = that.detailData.driverPhone
								that.tranCarInfoList.tranCarNo = that.detailData.tranCarNo
								that.tranCarInfoList.carNo = that.detailData.carNo
								that.tranCarInfoList.loadNetWeight = that.detailData.loadNetWeight
								that.tranCarInfoList.tranType = that.tranType
								that.tranCarInfoList.loadPoundImg = that.detailData.loadPoundImg
								            // this.tranCarInfoList.boxNo = this.arr.toString()
								for (var i = 0; i < that.tranCarInfoList.length; i++) {
									that.tranCarInfoList[i].id = that.freightspace[i].id
									if (that.tranCarInfoList[i].temporaryDriverFlag != 0) {
										that.tranCarInfoList[i].temporaryDriverFlag = 1
										that.tranCarInfoList[i].tranType = that.tranType
									}
								}
								var tranProcessInfo = {}
								tranProcessInfo.id = that.detailData.id
								tranProcessInfo.infoId = that.detailData.infoId
								tranProcessInfo.processNo = that.detailData.processNo
								tranProcessInfo.tranPrice = that.detailData.tranPrice
								tranProcessInfo.tranCarInfoList = that.tranCarInfoList
								that.$api.doRequest('post', '/tranProcessInfo/api/insertTranCar', tranProcessInfo).then(res => {
									if (res.data.code == 200) {
										uni.hideLoading()
										that.$api.msg('提交成功')
										that.detailData = {}
										that.freightspace = {}
										setTimeout(function() {
										         uni.navigateBack({})
										     }, 1000);
									}else{
										uni.hideLoading()
										that.$api.msg('系统异常，请联系管理员')
									}
								})
							}
						}
					})
				}
			},
			getList() {
				this.$api.doRequest('get', '/tranProcessInfo/getTranProcess', {
					id:this.id
				}).then(res => {
					if (res.data.code == 200) {
						this.detailData = res.data.data
						if(res.data.data.tranType=='火运'){
							if(res.data.data.tranCarInfoList.length>0){
								 if(res.data.data.tranCarInfoList[0].driver){
									this.detailData.driver = res.data.data.tranCarInfoList[0].driver
								}
								this.detailData.driverPhone =res.data.data.tranCarInfoList[0].driverPhone
								this.$set(this.detailData,'sendDateStart',res.data.data.tranCarInfoList[0].sendDateStart)
								this.detailData.receiveDateEnd =
								            res.data.data.tranCarInfoList[0].receiveDateEnd
								this.detailData.carModel = res.data.data.tranCarInfoList[0].carModel
								this.freightspace=res.data.data.tranCarInfoList
								for (var i = 0; i < res.data.data.tranCarInfoList.length; i++) {
									this.imgUrl = []
									res.data.data.tranCarInfoList[i].show2=false
									let imgs = res.data.data.tranCarInfoList[i].loadPoundImg.split(",")
									for(let j = 0 ; j < imgs.length ; j++){
										this.imgUrl.push({url:imgs[j]})
									}
									this.freightspace[i].imgUrl = this.imgUrl
								}
							}
						}else if(res.data.data.tranType=='汽运'){
							for (var i = 0; i < res.data.data.tranCarInfoList.length; i++) {
								res.data.data.tranCarInfoList[i].show2=false
							}
							this.freightspace=res.data.data.tranCarInfoList
							
						}else if(res.data.data.tranType=='船运'){
							if (res.data.data.tranCarInfoList.length > 0) {
								for (var i = 0; i < res.data.data.tranCarInfoList.length; i++) {
									res.data.data.tranCarInfoList[i].show2=false
								}
							            this.detailData.driver = res.data.data.tranCarInfoList[0].driver
							            this.detailData.driverPhone =
							              res.data.data.tranCarInfoList[0].driverPhone
							            this.$set(
							              this.detailData,
							              'sendDateStart',
							              res.data.data.tranCarInfoList[0].sendDateStart
							            )
							            this.detailData.receiveDateEnd =
							              res.data.data.tranCarInfoList[0].receiveDateEnd
							            this.detailData.shipName = res.data.data.tranCarInfoList[0].shipName
							            this.detailData.shipNo = res.data.data.tranCarInfoList[0].shipNo
							            this.detailData.shipType = res.data.data.tranCarInfoList[0].shipType
							            this.detailData.boxNumber = res.data.data.tranCarInfoList[0].boxNumber
							            //上传附件计数
							            if(this.detailData.tranCarInfoList[0].loadPoundImg){
							              this.pictureTotal =  this.detailData.tranCarInfoList[0].loadPoundImg.split(",")
							            }
							            this.freightspace = res.data.data.tranCarInfoList
							          }
							
						}
						
					}
				})
			},
			getImgUrl(res1,res2,res3,res4) {
				// debugger
				this.freightspace[res4].loadPoundImg=res1
				// this.detailData.addressUrl = res
				// console.log(res)
				// console.log('------------res-----------')
			},
			setImgUrl(val){
				// debugger
				for(let i = 0;i<freightspace.length;i++){
					
				}
			},
			filterFileType(index, lists) {
				if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
					lists.splice(index, 1);
					// 当前文件不支持
					uni.showModal({
						title: '暂不支持当前图片类型',
						showCancel: false
					});
				} else {
					this.isAdd = false;
				}
			},
			dateChange(e) {
				this.detailData.sendDateStart = e.year + "-" + e.month + "-" + e.day
			},
			train(index){
				console.log(index)
				
				this.freightspace[index].show2=true
				this.$forceUpdate();
				this.index=index
			},
			dateChange1(e){
				this.$set(this.freightspace[this.index],'loadingDate',e.year + "-" + e.month + "-" + e.day)
			},
			dateChange2(e){
				this.$set(this.freightspace[this.index],'sendDateStart',e.year + "-" + e.month + "-" + e.day)
			},
			statuschange(e) {
				this.status = this.statusList[e[0]].name
				this.getList()
			},
			goDetail(val) {
				uni.navigateTo({
					url: '/pages/erp/deliveryfeedback/details?data=' + JSON.stringify(val),
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	uni-page-body {
		overflow: hidden;
	}
	.content{
		margin:10px 0;
	}
	.wrap {
		margin: 10rpx;
		padding: 20rpx 20rpx 240rpx 20rpx;
	
		.top {
			display: flex;
			margin-bottom: 20rpx;
	
			.top-left {
				margin-right: 20rpx;
			}
		}
	}
	.bottom-btn {
			width: 100%;
			position: fixed;
			bottom:0;
			display: flex;
			z-index: 2;
			left: 0;
			background-color: #f8f8f8;
			flex-direction: column;
			.btn1,.btn2{
				width: 100%;
				margin-bottom: 26rpx;
				border-radius: 90rpx;
			}
			.btn1{
				background: white;
				color: #00C265;
			}
			}
	.content,
	.content1,
	.content2 {
		border-radius: 20rpx;
		background: white;
		padding: 20rpx;
	
		.title {
			font-size: 28rpx;
			font-weight: 600;
			color: #333333;
		}
	
		.row {
			display: flex;
			justify-content: space-between;
			// border-bottom: 1px solid #EEEEEE;
			padding: 21rpx 0;
	
			.right,
			input {
				font-size: 28rpx;
				color: #333333;
			}
		}
	
		.row-bottom {
	
			// border: 0;
			.right-bottom {
				width: 280rpx;
				text-align: right;
			}
		}
	}
	
	.content1 {
		margin-top: 20rpx;
	}
	
	.content2 {
		margin-top: 10px;
		// display: flex;
		align-items: center;
	
		.left {
			margin-right: 20px;
		}
	}
	
	.submit {
		width: 40%;
		background: #22C572;
		border-radius: 10rpx;
	}
	
	.edit-btn {
		background: #22C572;
		width: 100rpx;
		height: 50rpx;
		margin: 0;
		color: white;
	}
	
	.has-btn {
		align-items: center;
	}
	
	// .bottom-btn {
	//     padding: 30rpx;
	// 	background: #FFFFFF;
	// 	width: 92%;
	// 	position: fixed;
	// 	bottom: 0rpx;
	// 	display: flex;
	// 	z-index: 9999;
	// }
	.shade{
		background:#000;
		position:fixed;
		top:0;left:0;
	   width:100%;height:100%;
	   z-index:10000;
	}
	.pound_list{
		width: 452rpx;
		display: flex;
		justify-content: flex-end;
		text-align: right;
	}
</style>
