<template>
	<view class="warp">
		<view class="topInfo">
			<view class="topInfo-item">
				<view class="flex info" v-if='list.billingMethod==2'>
					<view class="logo">
						<image src="../../../static/img/reject.png" mode="" v-if="list.priceStatusCar == '已驳回'"
							style="height: 40rpx;"></image><!-- 驳回 -->
						<image src="../../../static/img/tongguo.png" mode="" v-if="list.priceStatusCar == '已通过'"
							style="height: 40rpx;"></image><!-- 通过 -->
						<image src="../../../static/img/daishenhe.png" mode="" v-if="list.priceStatusCar == '审核中'"
							style="height: 40rpx;"></image><!-- 待审核 -->
					</view>
					<view class="infoText">{{list.priceStatusCar}}</view>
				</view>
				<view class="flex info" v-else>
					<view class="logo">
						<image src="../../../static/img/reject.png" mode="" v-if="list.priceStatus == '已驳回'"
							style="height: 40rpx;"></image><!-- 驳回 -->
						<image src="../../../static/img/tongguo.png" mode="" v-if="list.priceStatus == '已通过'"
							style="height: 40rpx;"></image><!-- 通过 -->
						<image src="../../../static/img/daishenhe.png" mode="" v-if="list.priceStatus == '审核中'"
							style="height: 40rpx;"></image><!-- 待审核 -->
					</view>
					<view class="infoText">{{list.priceStatus}}</view>
				</view>
				<view class="infoData">{{list.updateDate}}</view>
			</view>
		</view>
		<view class="transaction">
			<u-form :model="list" ref="list" class="uForm">
				<u-form-item label="运费类型" prop="contractNo" label-width="140">
					{{list.tranType}}运费
				</u-form-item>
				<u-form-item label="合同编号" prop="contractNo" label-width="140">
					<u-input v-model="list.contractNo" input-align="right" placeholder="" disabled />
				</u-form-item>
				<u-form-item label="任务编号" prop="processNo" label-width="140">
					<u-input v-model="list.processNo" input-align="right" placeholder="" disabled />
				</u-form-item>
				<u-form-item label="货名" prop="goodsName" label-width="140">
					<u-input v-model="list.goodsName" input-align="right" placeholder="" disabled />
				</u-form-item>
				<u-form-item label="发货地址" prop="sendDetailedAddress" label-width="140">
					<!-- <u-input v-model="list.sendDetailedAddress" input-align="right" placeholder="发货地址" disabled /> -->
					<view class="text_info">
						{{list.sendPrivate}}{{list.sendCity}}{{list.sendArea}}{{list.sendDetailedAddress}}
					</view>

				</u-form-item>
				<u-form-item label="收货地址" prop="receiveDetailedAddress" label-width="140">
					<!-- <u-input v-model="list.receiveDetailedAddress" input-align="right" placeholder="收货地址" disabled /> -->
					<view class="text_info">
						{{list.receivePrivate}}{{list.receiveCity}}{{list.receiveArea}}{{list.receiveDetailedAddress}}
					</view>

				</u-form-item>
				<u-form-item label="运费（元）" prop="tranPrice" label-width="250">
					<u-input v-if='list.billingMethod==1&&list.tranType=="汽运"' v-model="list.tranPriceIng" input-align="right"
						placeholder="请输入运费单价" />
					<u-input v-else-if='list.billingMethod!=1&&list.tranType=="汽运"' v-model="list.tranPriceIngCar" input-align="right" placeholder="请输入运费单价" />
					<u-input v-else v-model="list.tranPriceIng" input-align="right"
						placeholder="请输入运费单价" />
				</u-form-item>
			</u-form>
		</view>
		<u-modal v-model="show" :title-style="{fontSize: '18px',fontWeight:'500'}"
			:content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
			showCancelButton='false' :content="content" @confirm="passSubmit" @cancel="show = false"></u-modal>
		<u-button type="primary" class="submit" @click="show = true" v-if="list.priceStatus == '审核中'||isSHowBtn">通过
		</u-button>
	</view>
</template>

<script>
	import helper from '@/common/helper.js';
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				isSHowBtn: true,
				everyCheck: '',
				list: {
					priceStatus: "",
				},
				id: "",
				show: false,
				rejectInfo: "", //审核意见
				title: "提示",
				content: '是否通过该设置?'
			}
		},
		onBackPress(e) {
			if (this.everyCheck) {
				uni.navigateTo({
					url: "/pages/task/my_task"
				})
				return true;
			}
		},
		onLoad(options) {
			this.id = options.id
			this.everyCheck = uni.getStorageSync("everyTask")
			this.isSHowBtn = options.isShowbtn
			this.getList()
		},
		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		methods: {
			getList() {
				this.$api.doRequest('get', '/tranProcessInfo/getTranProcess', {
					id: this.id
				}).then(res => {
					this.list = res.data.data
				})
			},
			passSubmit() {
				var that = this
				if (!this.list.tranPriceIng && this.list.billingMethod == 1&&this.list.tranType=="汽运" || !this.list.tranPriceIngCar && this.list
					.billingMethod == 2&&this.list.tranType=="汽运"||!this.list.tranPriceIng &&this.list.tranType!="汽运") {
					this.$api.msg('运费单价不能为空')
					return
				}
				uni.showLoading({
					title: "审核中"
				})
				var tranProcessInfo = {}
				var url = ''
				tranProcessInfo.id = that.list.id
				tranProcessInfo.flag = "2"
				tranProcessInfo.billingMethod = that.list.billingMethod
				tranProcessInfo.reviewer = that.userInfo.userName
				tranProcessInfo.tranTypeKey = that.list.tranTypeKey
				if (that.list.billingMethod == 1&&that.list.tranType=="汽运"||that.list.tranType!="汽运") {
					tranProcessInfo.tranPriceIng = that.list.tranPriceIng
					url = '/tranProcessInfo/api/setUpTranPrice'
				} else {
					tranProcessInfo.tranPriceIngCar = that.list.tranPriceIngCar
					url = '/tranProcessInfo/api/setUpTranPriceCar'
				}
				that.$api.doRequest('post', url, tranProcessInfo)
					.then(res => {
						if (res.data.code == 200) {
							that.$api.msg('审核通过成功!')
							setTimeout(function() {
								if (that.everyCheck) {
									helper.setAudit(that.list)
								} else {
									uni.navigateBack()
								}
								uni.hideLoading()
							}, 1000);
						}
					})

			}
		}
	}
</script>

<style scoped lang="scss">
	.transaction {
		background-color: #FFFFFF;
		margin: 10rpx;
		padding-bottom: 10rpx;
		border-radius: 20rpx;
	}

	.uForm {
		padding: 0 40rpx;
	}

	.u-form-item {
		padding: 0;
	}

	.bottom-btn {
		width: 100%;
		position: fixed;
		bottom: 40rpx;
		display: flex;
		z-index: 2;
	}

	.topInfo {
		height: 210rpx;
		background: linear-gradient(270deg, #22C572 0%, #34DE8A 100%);
		padding: 30rpx;

		.topInfo-item {
			height: 150rpx;
			background-color: #FFFFFF;
			border-radius: 20rpx;
			padding: 40rpx;

			.logo {
				width: 40rpx;
				height: 40rpx;
				margin-top: 8rpx;
			}

			.infoText {
				font-size: 36rpx;
				font-weight: 600;
				margin-left: 20rpx;
			}

			.infoData {
				color: #878C9C;
				font-size: 26rpx;
				margin-top: 10rpx;
			}
		}
	}

	.submit {
		width: 98%;
		background: #22C572;
		border-radius: 40rpx;
		margin-top: 40rpx;
	}

	.rejectInfoCss {
		border: 1px solid #ccc;
		border-radius: 10rpx;
		background-color: #F9F9FA;
		// height: 100px;
		overflow-y: auto;
		margin: 30rpx;
	}

	.rejectText {
		text-align: center;
	}

	/deep/.u-input__textarea {
		height: 300rpx !important;
	}

	.text_info {
		display: flex;
		width: 100%;
		justify-content: flex-end;
	}
</style>
