<template>
	<view class="letter-content">
		<view class="letter-header">
			<text>放款通知</text>
		</view>
		
		<view class="mat15 bank">
			<text>{{letterValue.bank}}</text>
		</view>
		
		<view class="letter-main mat15">
			<text>
				我公司同意贵行为该公司放款。
			</text>
					
			<view>
				<view class="mat15">
					<text>客户名称：{{letterValue.name}}</text>
				</view>
				<view class="mat15">
					<text>放款额度(万元)：{{letterValue.loanMoney}} (大写：{{letterValue.guaranteeMoney}})</text>
				</view>
				<view class="mat15">
					<text>担保期限：{{letterValue.loanTern}}</text>
				</view>
			</view>
			
			<view class="mat15">
				我公司同意贵行为<text class="letter-key">{{letterValue.name}}</text>放款人民币<text class="letter-key">{{letterValue.loanMoney}}</text>万元整(大写：<text class="letter-key">{{letterValue.guaranteeMoney}}</text>)。
			</view>
			
			<view class="mat40 letter-footer">
				<view class="mat15">
					<text>大庆市工商业融资担保有限公司</text>
				</view>
				<view class="mat15">
					<text>法定代表人：</text>
				</view>
				<view class="mat15">
					<text>或授权代理人：</text>
				</view>
				<view class="mat15">
					<text>&emsp;&emsp;年&emsp;&emsp;&emsp;月&emsp;&emsp;&emsp;日</text>
				</view>
			</view>
		</view>
					
		<uni-forms v-show="operationType !== 2" :value="letterValue" ref="letterValue" validate-trigger="bind" err-show-type="toast">
			<uni-forms-item name="name" :label="operationType === 1 ? '审核' : '放款确认'">
				<uni-easyinput :disabled="operationType == 2" type="textarea" v-model="letterValue.auditOpinion" placeholder="请输入审核意见"></uni-easyinput>
			</uni-forms-item>
		</uni-forms>
		<!-- v-show="operationType == 1" -->
		<view class="foot-btn btn-rig pad-bt margin-top">
			<button  v-show="operationType == 3" class="mini-btn round def-btn mar-lr" type="primary" size="mini" @tap="sumbitOpinion('提交',2)">提交</button>
			<button  v-show="operationType == 3" class="mini-btn round refuse-btn mar-lr" type="primary" size="mini" @tap="sumbitOpinion('驳回',4)">驳回</button> 
			<button plain class="mini-btn round plain-btn" type="primary" size="mini" @tap="back()">返回</button>			
		</view>
		
		<timeline></timeline>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fileList: [],
				operationType: '',
				letterValue: {},
			};
		},
		onLoad(option) {
			// 判断来自待处理否
			if(uni.getStorageSync('decideIndex')){ // 仅有一个确认
				let data = JSON.parse(uni.getStorageSync('decideIndex'))
				this.loanNoticeDetail(data)
				this.operationType = 3
				uni.removeStorageSync('decideIndex')
			}else if(uni.getStorageSync('copyData')){
				let data =JSON.parse(uni.getStorageSync('copyData')),that = this
				this.operationType = 2
				if(uni.getStorageSync('notCopy','查看')){
					this.loanNoticeDetail(data)
				}else{
					this.letterValue = {
						name:data.clientName,
						passingTime:data.passingTime,
						loanMoney:data.loanMoney,
						loanTern:data.loanTern,
						bank:data.bank,
						guaranteeMoney:that.core.fMoney3(data.loanMoney)
					}					
				}
			}else{
				this.fileList = option.fileList
				this.operationType = option.operationType
				this.letterValue = JSON.parse(option.letterValue)
			}
			
		},
		methods: {
			// 详情
			loanNoticeDetail(data){
				this.$http.get('/api-guarantee/dg-loan-notice/loanNoticeDetail',{id:data.detailId}).then(res=>{
					let that = this,data = res.data.data
					this.letterValue = {
						businessId: data.businessId,//业务id
						bank: data.bank,//银行
						name: data.name,//客户名称
						passingTime: data.passingTime,//贷审会日期
						loanMoney: data.loanMoney,//担保金额
						guaranteeMoney: that.core.fMoney3(data.loanMoney),//担保金额转格式
						file: '',//会议纪要
						loanTern: data.loanTern,//担保期限
						auditOpinion: '',//审核意见
						roleId: ''//角色id
					}
				})
			},
			//放大图片
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			
			// 提交审核意见
			sumbitOpinion(text,type){
				let _this = this
				uni.showModal({
				    title: '提示',
				    content: `确定要${text}该审核意见吗？`,
				    success: function (res) {
				        if (res.confirm) {
							if(type == 4 && _this.letterValue.auditOpinion == ''){
								return uni.showToast({title: '请先填写审核意见！',icon:'none'})
							}						
							_this.$http.post('/api-guarantee/dg-loan-notice/updateLoanNotice',{
								auditOpinion: _this.letterValue.auditOpinion,
								businessId: _this.letterValue.businessId,
								status: type
							}).then(res => {
								uni.showToast({title: `${text}成功`,icon:'none'})
								_this.back()
							}).catch(()=>{

							})				       
				        } else if (res.cancel) {}
				    }
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.letter-content{
	padding: 40rpx 40rpx;
	.letter-header{
		text-align: center;
		font-size: 32rpx;
		font-weight: 500;
		padding-bottom: 40rpx;
		border-bottom: 2rpx solid #e5e5e5;
	}
	.bank{
		font-weight: 700;
	}
	.letter-main{
		letter-spacing: 4rpx;
		text-indent: 60rpx;
	}
	.letter-key{
		font-weight: bold;
		margin: 0 10px;
	}
	.letter-footer{
		text-align: right;
		margin-right: 20rpx;
	}
}
</style>
