<template>
	<view>
		<view class="width100 height100p" style="background-color: #eb6a53;" v-if="RateApplyDetail.status == 5">
			<view class="font18 fcorfff paddtop35 fotct">
				渠道审核中
			</view>
		</view>

		<view class="titlename width100 font18 fontwig6 fcor333">费率信息审核</view>
		<view class="width100 backcorfff">
			<view class="notes" v-for="(item,index) in RateApplyDetail.merRateApplyDetailList"  :key="index">
				<view class="fcor666 width25">{{item.rateTypeName}}</view>
				<view class="font14 fcor333 text2 width75 fotrt">{{item.ratePct}} (单位: 百分之一)</view>
			</view>
		</view>

		<view class="titlename width100 font18 fontwig6 fcor333"
			v-if="RateApplyDetail.status == 2 || RateApplyDetail.status == 4 || RateApplyDetail.status == 6">驳回信息</view>
		<textarea class="width100 backcorfff" v-model="rejectReason" v-if="RateApplyDetail.status == 2"
			style="padding: 15px;" placeholder="请填写审核驳回内容"></textarea>
		<textarea class="width100 backcorfff" :value="RateApplyDetail.rejectReason" disabled="true"
			v-if="RateApplyDetail.status == 4 || RateApplyDetail.status == 6" style="padding: 15px;"></textarea>
		<view class="alijusstart" v-if="RateApplyDetail.status == 2">
			<button class="btns mart40 backcor008" @click="approve()">通过</button>
			<button class="btns mart40 backcorlr" @click="reject()">驳回</button>
		</view>
	</view>
</template>

<script>
	import {
		reject,
		approve,
		getRateApplyDetail
	} from '../../../Utils/Api.js';
	export default {
		data() {
			return {
				auditNo: '', //审批编号
				rateApplyId: '', //审核对象id
				rejectReason: '', //驳回内容
				RateApplyDetail: '' //费率详情
			}
		},
		onLoad(options) {
			this.rateApplyId = options.id;
			this.auditNo = options.auditid;
			this.getRateApplyDetail();
		},
		methods: {
			//详情
			getRateApplyDetail() {
				let datas = {
					rateApplyId: this.rateApplyId
				}
				getRateApplyDetail(datas).then(res => {
					if (res.return_code == '000000') {
						this.RateApplyDetail = res.return_data.rateApply;
					}
				})
			},
			//通过审核
			approve() {
				uni.showModal({
					title: '通过审核',
					content: '是否通过当前审核',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '提交中'
							})
							let datas = {
								auditNo: this.auditNo
							}
							approve(datas).then(res => {
								uni.hideLoading();
								if (res.return_code == '000000') {
									uni.showToast({
										title: '提交成功',
										icon: "none",
										duration: 2000
									});
									uni.navigateBack();
								} else {
									uni.showToast({
										title: res.return_msg,
										icon: "none",
										duration: 2000
									});
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			//驳回审核
			reject() {
				if (!this.rejectReason) {
					uni.showToast({
						title: '请填写驳回理由',
						icon: "none",
						duration: 2000
					});
					return;
				}
				uni.showModal({
					title: '驳回审核',
					content: '是否驳回当前审核',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: '提交中'
							})
							let datas = {
								auditNo: this.auditNo,
								"rejectReason": this.rejectReason
							}
							reject(datas).then(res => {
								uni.hideLoading();
								if (res.return_code == '000000') {
									uni.showToast({
										title: '提交成功',
										icon: "none",
										duration: 2000
									});
									uni.navigateBack();
								} else {
									uni.showToast({
										title: res.return_msg,
										icon: "none",
										duration: 2000
									});
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}

	.titlename {
		align-items: center;
		padding: 30rpx 0 30rpx 20rpx;
		background-color: #ffffff;
		border-bottom: 1px solid #f6f6f6;
	}

	.notes {
		width: calc(100% - 40rpx);
		display: flex;
		align-items: center;
		padding: 30rpx 0 30rpx 20rpx;
		border-bottom: 1px solid #f6f6f6;
	}

	.btns {
		width: 40%;
		height: 50px;
		line-height: 50px;
		color: #FFFFFF;
		font-weight: bold;
	}
</style>