<template>
	<view>
		<view class="myContainer redMi acceptTitle">关闭原因</view>
		<view class="myContainer myContentBox">
			<textarea placeholder="请输入关闭巡检的原因" class="mytextarea" v-model="content"></textarea>
		</view>
		
		<view class="fixMargin"></view>
		<view class="fixBottom">
			<button type="primary"  style="width: 100%;" @click="submit">提交</button>
		</view>
		<view class="goHome" @click='goMain()'>
			<img src="../../static/img/gohome.png">
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				id:'',
				content:'',
				flag:''
			}
		},
		onLoad(option) {
			let d = new Date();
			this.id = option.id;
			this.flag = option.flag;
			// if (this.id == undefined) {
			// 	uni.reLaunch({
			// 		url: 'eqPatrol'
			// 	});
			// 	return false;
			// }
			},
		methods:{
			submit(){
				if(this.content.trim()==''){
					uni.showToast({
						title: '请填写关闭巡检的原因',
						icon: 'none',
						duration: 2000
					});
					return false;
				}
				var json_ = {
					id: this.id,
					closeReason:this.content,
				}
				var _this = this;
				this.$http.request({
					url: '/apis/patrolRecord/closeRecord',
					params: json_,
				}).then(res => {
					if (res.data.code == 0) {
						uni.showToast({
							title: '提交成功',
							icon: 'none',
							duration: 1000
						});
						uni.navigateTo({
							url: "patrolDetail?id="+_this.id
						});
						// setTimeout(function(){
						// 	_this.$eventHub.$emit('changestate',{id:_this.id,state:"已验收"});
						// 	uni.navigateBack({
						// 		delta: 2
						// 	});
						// },1000)
						
					}else{
						uni.showToast({
							title: '提交失败，请稍后重试',
							icon: 'none',
							duration: 2000
						});
					}
				}).catch(err => {});
			}
		}
	}
</script>

<style scoped>
	
	.mytextarea{
		padding: 20upx;
		font-size: 26upx;
	}
	
</style>
