<template>
	<view style=" background-color: #FFF2CC;">
		<!-- 建议信息 -->
		<view class="suggestHead">
		    <text>建议号</text>
		    <text class="suggestHeadDetail">{{suggestion.id}}</text>
		</view>
		<view class="suggestHead">
		    <text>建议人UID</text>
		    <text class="suggestHeadId">{{suggestion.fromUid}}</text>
		</view>
		<view class="suggestHead">
		    <text>处理人UID</text>
		    <text class="suggestHeadId">{{suggestion.processorUid}}</text>
		</view>
		<view class="suggestHead">
		    <text>建议日期</text>
		    <text class="suggestHeadDetail">{{suggestion.fistDatetime}}</text>
		</view>
		<!-- 建议标题 -->
		<view class="suggestTitle">
		    <text class="suggestTitleText">建议标题</text>
		    <text class="suggestTitleDetail">{{suggestion.adviseTitle}}</text>
		</view>
		<!-- 建议内容 -->
		<view class="suggestTitle">
		    <text class="suggestTitleText">建议内容</text>
		    <text class="suggestTitleDetail">{{suggestion.adviseDetail}}</text>
		</view>
		<!-- 结案日期 -->
		<view class="handleDate">
		    <text>结案日期</text>
		    <text class="handleDateDetail">{{suggestion.closetime}}</text>
		</view>
		<!-- 处理状态 -->
		<view class="handleStatus">
		    <text>状态</text>
		    <text class="handleStatusDetail">{{suggestion.status}}</text>
		</view>
		<!-- 处理结果 -->
		<view class="handleResult">
		    <view class="handleResultTitle">处理结果</view>
		    <!-- 未处理 -->
		    <view>
		        <textarea v-model="result"  class="handleDetail" maxlength="512" placeholder="不超过512个字"></textarea>
		    </view>
		   
		</view>
		<!-- 底部按钮 -->
		<view class="handleEnd">
		    <text class="handleClosed" @click="toHandle">结案</text>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
					suggestion: {},
					result: ""
			};
		},
		onLoad(opt){
			this.suggestion = JSON.parse(opt.item);
			if(this.suggestion.processorUid==null){
				this.suggestion.processorUid = " ";
			}
		},
		methods:{
			toHandle(){
				var head = '^[ ]+$';
				var re = new RegExp(head);
				if (re.test(this.result)) {
					 uni.showModal({
						 title: '',
						 content: '结果不能为空'
					 })
				} 
				else if(this.result==null || this.result==""){
					uni.showModal({
					    title: '',
					    content: '结果不能为空'
					})
				}
				else{
				uni.request({
					url: `${uni.$http.baseUrl}/education/my-suggestion/handleAdvise`,
					data: {
							"id": this.suggestion.id,
							"result": this.result
						},
					header: {
						token: uni.getStorageSync('token')
					},
					method: 'POST',
					success: res => {
						uni.navigateBack({
						     delta: 2,
						})
					}
				})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
/* 设置页面背景 */
page{
    padding: 20rpx;
    height: 100%;
    background-color: #FFF2CC;
}

/* 顶部的建议信息 */
.suggestHead{
    margin-top: 20rpx;
}
/* 顶部建议信息详情、结案日期详情、状态处理详情 */
.suggestHeadDetail,
.suggestHeadId,
.handleDateDetail,
.handleStatusDetail{
    margin-left: 20rpx;
    font-weight: bold;
}
.suggestHeadId{
    color: #00B0F0;
    text-decoration: underline;
}

/* 建议详情 */
.suggestTitle{
    margin-top: 30rpx;
    display: flex;
    flex-direction: column;
}
/* 标题 */
.suggestTitleText{
    text-align: center;
    font-weight: bold;
    margin-bottom: 10rpx;
}
/* 内容 */
.suggestTitleDetail{
    width: 94%;    
}

/* 结案日期 */
.handleDate{
    margin-top: 40rpx;
}

/* 处理状态 */
.handleStatus{
    margin-top: 40rpx;
}
.handleStatusDetail{
    color: red;
}

/* 处理结果 */
.handleResult{
    display: flex;
    flex-direction: column;
}
.handleResultTitle{
    text-align: center;
    margin: 20rpx 0;
    font-weight: bold;
}

/* 处理结果详情 */
.handleDetail{
    padding: 10rpx;
    background-color: #fff;
    border: 1rpx solid gray;
    border-radius: 20rpx;
    width: 93%;
	margin: auto;
    //margin-bottom: 40rpx;
}
.handleResultDetail{
    min-height: 200rpx;
    padding: 10rpx;
    background-color: #fff;
    border-radius: 20rpx;
    width: 93%;
    margin-bottom: 40rpx;
}

/* 结案 */
.handleEnd{
    display: flex;
    justify-content: center;
    margin-bottom: 40rpx;
}
.handleClosed{
    background-color: #8FAADC;
    font-size: 40rpx;
    padding: 10rpx 30rpx;
    border-radius: 40rpx;
    color: white;
}
</style>
