<template>
	<view>
		<view class="myContainer redMi acceptTitle">挂起原因</view>
		<view class="myContainer myContentBox">
			<textarea placeholder="请输入挂起的原因" class="mytextarea" v-model="pendingReason"></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{
				dispatchId:'',
				pendingReason:'',
			}
		},
		onLoad(option) {
			let d = new Date();
			this.dispatchId = option.dispatchId;
			// if (this.id == undefined) {
			// 	uni.reLaunch({
			// 		url: 'eqPatrol'
			// 	});
			// 	return false;
			// }
			},
		methods:{
			submit(){
				if(this.pendingReason.trim()==''){
					uni.showToast({
						title: '请填写挂起的原因',
						icon: 'none',
						duration: 2000
					});
					return false;
				}
				var json_ = {
					dispatchId: this.dispatchId,
					pendingReason:this.pendingReason,
				}
				var _this = this;
				this.$http.request({
					url: '/apis/mes/dispatch/workHangUp',
					params: json_,
				}).then(res => {
					if (res.data.code == 0) {
						uni.showToast({
							title: '提交成功',
							icon: 'none',
							duration: 1000
						});
						uni.switchTab({
							url: "../main/main"
						});
						// 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>
