<template>
	<view>
		<view class="intro-box">活动申请已审批通过，确定关闭该活动吗？若关闭，请选填关闭原因!</view>
		<view class="textarea-wrap white-wrap">
			<textarea placeholder="请输入关闭理由" v-model="reason" maxlength="-1"></textarea>
		</view>
		<view class="btns-wrap flex">
			<button class="confirm-btn" @click="handleSubmit">提交</button>
			<button class="cancel-btn" @click="handleCancel">取消</button>
		</view>
	</view>
</template>

<script>
	import {apiCloseApply} from '@/api/businessTrip/index'
	export default {
		data() {
			return {
				reason: '',
				id:null,
				shouldCheck:false
			}
		},
		onLoad(options) {
			this.id=options.id
            this.shouldCheck = options.shouldCheck
		},

		methods: {
			async handleSubmit() {
				// if(!this.reason){
				// 	uni.showToast({
				// 		title:'请填写理由',
				// 		icon:"none"
				// 	})
				// 	return
				// }
				if(this.shouldCheck=='true'&&!this.reason){
					uni.showToast({
						title:'请填写理由',
						icon:"none"
					})
					return
				}
				const res=await apiCloseApply({
					BusinessApplyId:Number(this.id),
					CloseReason:this.reason
				})
				if(res.code===200){
					uni.showToast({
						title:"关闭成功",
						icon:'success'
					})
					uni.$emit('businessApproveListUpdate')
					setTimeout(()=>{
						this.handleCancel()
					},1000)
				}
			},
			
			handleCancel(){
				uni.navigateBack({
					delta:1
				})
			}
			
		},
	}
</script>

<style lang="scss">
	.intro-box{
		padding: 17px;
	}
	.textarea-wrap {
		padding: 17px;

		textarea {
			resize: none;
			display: block;
			box-sizing: border-box;
			width: 100%;
			height: 200px;
			border: none;
			font-size: 14px;
			/* no */
		}
	}

	.btns-wrap {
		justify-content: center;
		padding-top: 50px;
		padding-bottom: 50px;

		button {
			width: 90px;
			height: 28px;
			border-radius: 28px;
			border: none;
			margin: 0 10px;
			font-size: 14px;
			/* no */
			color: #fff;
			line-height: 28px;
		}

		.confirm-btn {
			background-color: #5890fb;
		}

		.cancel-btn {
			border: 1px solid #5890fb;
			color: #5890fb;
			background-color: #fff;
		}
	}
</style>
