<template>
	<view class="wrap">
		<view class='content1'>
			<view class='row'>
				<view class="left">鲅鱼圈库</view>
				<!-- <view class="right">鲅鱼圈库</view> -->
			</view>
			<view class='row '>
				<textarea placeholder="请输入仓库信息" class="textarea" maxlength="2000" v-model="textareaValue"></textarea>
				<view class="textarea-bottom">{{textareaValue?textareaValue.length:'0'}}/2000字</view>
			</view>
			<view class='row content-item'>
				<!-- <u-checkbox activeColor="#19be6b" v-model="value" @change="checkBoxChange">显示在易粮易运收购信息中</u-checkbox> -->
				显示在易粮易运收购信息中
				<view class="right">
					<u-switch v-model="checked" active-color="#22C572" inactive-color="#eee" size='40' @change="checkBoxChange" disabled="disabled"></u-switch>
				</view>
			</view>
		</view>
		<view v-if='show' class="shade">
			<view class="wrap">
				<view class="alert-top">
					<view class="title">
						{{title}}
					</view>
					<u-icon name="close" class="close" color="#8890B1" @click="close()"></u-icon>
				</view>
				<view class="u-textarea-style">
					<view class="right-bottom">
						{{auditMind.length}}/100个字
					</view>
					<u-input class="" v-model='auditMind' placeholder="请在此输入审核意见" type="textarea" height="414"
						maxlength="100" />
				</view>
				<view @click='close()' class="cancel">取消</view>
				<view @click='passSubmit()' class="confirm">确定</view>
			</view>
		</view>
		<u-toast ref="uToast" />
		<view style='padding:10px;' class='flex bottom-btn'>
			<!-- getRoles("acquisitionQuality.initial") -->
			<u-button v-if='isSHowBtn' @click='reject' type="error" class="btn1" hover-class='none'>驳回</u-button>
			<u-button v-if='isSHowBtn' @click='pass' type="success" class="btn2">通过</u-button>
		</view>
		<u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
			:content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='登录提示'
			showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex';

	export default {
		components: {

		},
		data() {
			return {
				isSHowBtn: true,
				isShowAlert: false,
				content: '当前登入信息验证失败，是否重新登录？',
				textareaValue: '',
				value: '',
				show:false,
				title:"",
				auditMind:"", //审核意见
			    checked: false,
			}
		},

		onLoad() {

		},
		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		onShow() {
			this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
				console.log("checkSession", res)
				if (res.data.data == "INVALID") {
					this.isShowAlert = true;
					// uni.showModal({
					// 	title: '登录提示',
					// 	content: '当前登入信息验证失败，是否重新登录？',
					// 	showCancel: true,
					// 	confirmText: '登录',
					// 	success: (e) => {
					// 		if (e.confirm) {
					// 			uni.navigateTo({
					// 				url: '/pages/public/login'
					// 			})
					// 		}
					// 	},
					// 	fail: () => {},
					// 	complete: () => {}
					// })
				}
			})
			console.log("hasLogin", this.hasLogin)
		},
		methods: {
			pass(){
				this.title = "审核意见（通过）"
				this.show = true
			},
			reject(){
				this.title = "驳回原因（驳回）"
				this.show = true
			},
			close(){
				this.show = false
			},
			passSubmit(item){
				if(this.title == "审核意见（通过）"){
					this.$api.doRequest('post', '/workflow/api/handle', {
						taskId: item.taskId,
						approved: true,
						auditMind: this.auditMind ? this.auditMind : "34",
						needReapply:true
					}).then(res => {
						if (res.data.code == 200) {
					      this.$api.msg('通过成功')
						}
					})
					
				}else if(this.title == "驳回原因（驳回）"){
					if(!this.auditMind){
						this.$api.msg('驳回原因不能为空！')
						return
					}
					this.$api.doRequest('post', '/workflow/api/handle', {
						taskId: item.taskId,
						approved: false,
						auditMind: this.auditMind ? this.auditMind : "34",
						needReapply:true
					}).then(res => {
						if (res.data.code == 200) {
					      this.$api.msg('驳回成功')
						}
					})
				}
			},
			
			
			/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			navTo(url) {
				if (!this.hasLogin) {
					url = '/pages/public/login';
				}
				uni.navigateTo({
					url
				})
			},
			alertBtn() {
				uni.navigateTo({
					url: '/pages/public/login'
				})
			},
			cancelClick() {
				this.isShowAlert = false
			},
			checkBoxChange(e) {
				console.log(e)
			}
		}
	}
</script>
<style lang='scss' scoped>
	page {
		background: #F5F6FA;
	}

	.wrap {
		background: #fff;
		margin: 10px;
		border-radius: 10px;
		padding: 40rpx 30rpx;

	}
	.content-item{
		margin-top: 50rpx;
		font-size: 28rpx;
	}

	.row {
		display: flex;
		justify-content: space-between;
		position: relative;
		/* border-bottom: 1px solid #EEEEEE; */
		.right,
		input {
			font-size: 28rpx;
			// color: #333333;
		}
		.left{
			font-size: 34rpx;
			color: #333333;
			font-weight: 600;
		}
	}

	.textarea {
		background: #F9F9FA;
		font-size: 26rpx;
		text-align: left;
		width: 100%;
		height: 60px;
		padding: 32rpx;
		border-radius: 10rpx;
		margin-top: 40rpx;
		height: 50vh;
		padding-bottom: 20rpx;
		color: #AFB3BF ;
	}

	.textarea-bottom {
		position: absolute;
		bottom: 20rpx;
		right: 20rpx;
		color: #606266;
	}
	.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;
			padding: 20rpx;
	
			.alert-top {
				padding: 33rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				position: relative;
			}
	
			.title {
				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;
		}
	}
	
	/deep/.u-input__textarea {
		height: 300rpx !important;
	}
</style>
