<template>
	<view class="container">
		<u-form ref="uForm">
			<view class="form_item">
				<view class="title">申请信息</view>
				<u-form-item label-width='260' label="业务编号" :borderBottom="false">
					<u-input v-model="tradeList.billNo" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="名头" :borderBottom="false">
					<u-input v-model="tradeList.renown" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="仓库名称" :borderBottom="false">
					<u-input v-model="tradeList.warehouseName" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="仓位号" :borderBottom="false">
					<u-input v-model="tradeList.warehouseNo" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="仓库地址" :borderBottom="false">
					<u-input v-model="tradeList.warehouseAddress" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="货名" :borderBottom="false">
					<u-input v-model="tradeList.goodsName" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="品级" :borderBottom="false">
					<u-input v-model="tradeList.grade" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="现有储量（吨）" :borderBottom="false">
					<u-input v-model="tradeList.nowWeight" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="可用储量（吨）" :borderBottom="false">
					<u-input v-model="tradeList.useWeight" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="本单重量（吨)" :borderBottom="false">
					<u-input v-model="tradeList.weight" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="单价（元/吨）" :borderBottom="false">
					<u-input v-model="tradeList.unitPrice" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="总价值（元）" :borderBottom="false">
					<u-input v-model="tradeList.totalValue" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="申请比例（%）" :borderBottom="false">
					<u-input v-model="tradeList.applicationProportion" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="申请金额（元）" :borderBottom="false">
					<u-input v-model="tradeList.interest" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
			</view>
			<view class="form_item">
				<view class="title">附件</view>
				<upload class="upload" ref="upload" :action="action" :max-size="maxSize" :max-count="0"
					:file-list="imgUrl" :size-type="['compressed']" @on-success="getImgUrl" :deletable="false"
					:showProgress="false" @on-uploaded="isAdd = true" :before-upload="filterFileType"
					@on-progress="onProgress"></upload>
			</view>
			<view class="form_item">
				<view class="title">外审部门</view>
				<u-form-item label-width='260' label="银行" :borderBottom="false">
					<u-input v-model="tradeList.bank" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
				<u-form-item label-width='260' label="第三方" :borderBottom="false">
					<u-input v-model="tradeList.three" input-align="right" placeholder="暂无" disabled />
				</u-form-item>
			</view>
			<view class="form_item" v-if="tradeList.status == '待还款'">
				<view class="title">发放信息</view>
				<u-form-item label-width='260' label="合同编号">
					<u-input v-model="tradeList.contractNo" input-align="right" disabled placeholder="请输入合同编号" />
				</u-form-item>
				<u-form-item label-width='260' label="发放金额(元)">
					<u-input v-model="tradeList.paymentAmount" input-align="right" type="digit" disabled placeholder="请输入发放金额" />
				</u-form-item>
				<view v-for="(item,index) in count">
					<view class="row">
						<view class="left ">
							<u-input v-model="item.modifyExpense" placeholder="输入费用名称,1-8个字" disabled/>
						</view>
						<view class="right">
							<u-input v-model="item.expenses"  input-align="right" placeholder="暂无" type="digit" disabled/>
							</u-input><span class="yuan">元</span>
						</view>
					</view>
				</view>
				<view class="flex count">
					<view class=" flex count_item"><span>合计应还：</span><span class="number">￥{{tradeList.amountDue}}</span>
					</view>
				</view>
			</view>
		</u-form>
		<view class="form_item flex">
			<view class="auditInfo flex" @click="auditInfo">
				<view class="title1">审核记录</view>
				<view class="img">
					<image src="../../../static/img/myimg/gengduo1@3x.png"
						style="width: 16rpx; height: 30rpx;top: 20rpx;margin-right: 0rpx;"></image>
				</view>
			</view>
		</view>
		<view style='padding:10px;' class='flex bottom-btn'>
			<u-button @click='reject' type="error" class="btn1" hover-class='none'>返回</u-button>
		</view>
	</view>
</template>

<script>
	import upload from '@/components/upload.vue';
	export default {
		components: {
			upload
		},
		data() {
			return {
				id: "",
				action: this.$uploadUrl,
				maxSize: 50 * 1024 * 1024, //限制文件大小 50M
				btnLoading: false, //防止重复点击
				imgUrl: [],
				tradeList: {},
				isShowAlert: false,
				count: [],
			}
		},
		onLoad(options) {
			this.id = options.id
			this.getList()
		},
		methods: {
			getList() {
				var that = this
				that.$api.doRequest('get', '/tradeWarehouseReceiptAppl/getTrageInfo', {
					id: that.id
				}).then(res => {
					that.tradeList = res.data.data
					if(that.tradeList.modifyExpense1){
						that.count.push({
							modifyExpense:that.tradeList.modifyExpense1,
							expenses:that.tradeList.applicationAmount
						})
					}
					if(that.tradeList.modifyExpense2){
						that.count.push({
							modifyExpense:that.tradeList.modifyExpense2,
							expenses:that.tradeList.supervisionFee
						})
					}
					if(that.tradeList.modifyExpense3){
						that.count.push({
							modifyExpense:that.tradeList.modifyExpense3,
							expenses:that.tradeList.insurancePremium
						})
					}
					if(that.tradeList.modifyExpense4){
						that.count.push({
							modifyExpense:that.tradeList.modifyExpense4,
							expenses:that.tradeList.otherFee
						})
					}
					//通过图片id找到地址
					that.$api.doRequest('get', '/appendix/query/getFileList', {
						appendixIds: that.tradeList.appendix
					}).then(res => {
						for (let i = 0; i < res.data.data.length; i++) {
							that.imgUrl.push({
								url: res.data.data[i].appendixPath
							})
						}
					}).catch(res => {
						if (res.errmsg) {
							uni.showToast({
								title: res.errmsg,
								icon: 'none',
								duration: 2000
							})
						}
					});
				})
			},
			reject(){
			   uni.navigateBack()
			},
			auditInfo() {
				uni.navigateTo({
					url: '/pages/task/audit_info?id=' + this.tradeList.id + "&workflowId=" + this.tradeList
						.workflowId
				})
			},
			filterFileType(index, lists) {
				if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif' &&
					lists[index].fileType != 'jpeg') {
					lists.splice(index, 1);
					// 当前文件不支持
					uni.showModal({
						title: '暂不支持当前图片类型',
						showCancel: false
					});
				} else {
					this.isAdd = false;
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.container {
		padding: 6rpx 12rpx 140rpx 12rpx;
	}

	.title {
		font-size: 34rpx;
		font-weight: 600;
		margin-top: 20rpx;
		line-height: 90rpx;
		border-bottom: 2rpx solid #EEEEEE;
	}

	.form_item {
		background: #fff;
		margin: 10px;
		border-radius: 10px;
		padding: 10rpx 30rpx;
		// width: 100%;
	}

	.u-form-item {
		padding: 12rpx 0 !important;
	}

	.auditInfo {
		width: 100%;

		.title1 {
			width: 99%;
			font-size: 34rpx;
			font-weight: 600;
			// margin-top: 20rpx;
			line-height: 70rpx;
		}
	}

	.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;
		}
	}

	.shade {
		position: fixed;
		top: 0;
		left: 0;
		height: 100%;
		width: 100%;
		background: rgba(0, 0, 0, 0.4);
		z-index: 3;

		.wrap {
			position: absolute;
			left: 0;
			top: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			background: #fff;
			width: calc(100% - 198rpx);
			height: 700rpx;
			border-radius: 20rpx;

			.alert-top {
				padding: 33rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				position: relative;
			}

			.titleAudit {
				font-size: 32rpx;
				font-weight: 600;
				color: #333333;
			}

			.close {
				position: absolute;
				right: 33rpx;
			}
		}
	}

	.cancel,
	.confirm {
		position: absolute;
		display: inline-block;
		width: 50%;
		text-align: center;
		bottom: 0;
		padding: 10px;
		border-top: 1px solid #eee;
		font-size: 34rpx;
	}

	.cancel {
		left: 0;
		border-right: 1px solid #eee;
		color: #AFB3BF;
	}

	.confirm {
		right: 0;
		color: #22C572;
	}

	.u-textarea-style {
		margin: 20rpx;
		background: #F9F9FA;
		border-radius: 10px;
		border: 1px solid #EEEEEE;
		padding: 10rpx 20rpx;
		position: relative;

		.right-bottom {
			position: absolute;
			right: 20rpx;
			bottom: 20rpx;
			color: #AFB3BF;
		}
	}

	.row {
		display: flex;
		justify-content: space-between;
		border-bottom: 1px solid #eee;

		.right {
			display: flex;

			// .uni-input-input{
			// width: 30%;
			// font-size: 28rpx;
			//     }
			.del {
				width: 46rpx;
				height: 46rpx;
				border-radius: 25rpx;
				background-color: #F1F4FB;
				text-align: center;
				line-height: 46rpx;
				font-weight: 600;
				margin-top: 8rpx;
			}

			.yuan {
				line-height: 70rpx;
				// margin: 0 16rpx;
				margin-left: 16rpx;
			}
		}

	}

	.count {
		width: 100%;
		margin: 20rpx 0;
		justify-content: flex-end;
		.count_item {
			// width: 70%;
			font-size: 30rpx;
			line-height: 70rpx;

			.number {
				font-size: 32rpx;
				font-weight: 600;
				margin-left: 20rpx;
			}
		}
	}

	/deep/.u-list-item {
		margin: 20rpx 4rpx !important;
	}
</style>
