<template>
	<view class="page">
		<view class="item_line" >
		</view>
		<view class="item item_line item_textarea" >
			<view class="itemname redMi">原因分析</view>
			<textarea class="textarea" placeholder="请输入原因分析" v-model="msg"  ></textarea>
		</view>
		<view class="item item_line item_textarea" >
			<view class="itemname redMi">解决方案</view>
			<textarea class="textarea" placeholder="请输入解决方案" v-model="solution"  ></textarea>
		</view>
		<view class="fixMargin"></view>
		<view class="goHome" @click='goMain("taskInfo")'>
			<img src="../../static/img/gohome.png">
		</view>
		<view class="fixBottom">
			<view class="uni-flex uni-row">
				<view style="-webkit-flex:1;flex: 1;">
					<button type="primary"  style="width: 100%;"  @click="submit()">确认提交</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				msg:'',
				solution:'',
			}
		},
		onLoad(option) {
			var _this = this;
			this.id = option.id||'';
		},
		methods: {
			submit(){
				var _this = this;
				if(!(this.msg)){
					uni.showToast({
							title: '请填写原因分析',
							duration: 2000,
							icon:"none"
						});
					return false;
				}
				if(!(this.solution)){
					uni.showToast({
							title: '请填写解决方案',
							duration: 2000,
							icon:"none"
						});
					return false;
				}
				
				//处理
				this.$http.request({
				  url: '/apis/taskMain/dealSave',
				  params:{
					  taskid:this.id,
					  solution:this.solution,
					  reason:this.msg
				  }
				}).then(res=>{
					if(res.data.code == 0){
						uni.showToast({
							title: '操作成功',
							duration: 	1000,
							icon:"none"
						});
						setTimeout( function(){
							uni.navigateTo({
								url: "taskDetail?id="+_this.id
							});
						},1000)
					}else{
						uni.showToast({
							title: res.data.msg,
							duration: 	2000,
							icon:"none"
						});
					}
				}).catch(err=>{
					uni.showToast({
						title: '操作失败',
						duration: 	2000,
						icon:"none"
					});
				});
			}
		}
	}
</script>

