<template>
	 <view class="wrapper">
		<view>
		    <view>
		        <view class="suggestHead">
		            <text>建议号</text>
		            <text class="suggestHeadDetail">{{suggestion.id}}</text>
		        </view>
		        <view class="suggestHead">
		            <text>建议人UID</text>
		            <text class="suggestHeadDetailID">{{suggestion.fromUid}}</text>
		        </view>
		        <view class="suggestHead">
		            <text>处理人UID</text>
		            <text class="suggestHeadDetailID">{{suggestion.processorUid}}</text>
		        </view>
		        <view class="suggestHead">
		            <text>建议日期</text>
		            <text class="suggestHeadDetail">{{suggestion.fistDatetime}}</text>
		        </view>
		    </view>
		   
		    <view>
		        <view class="suggestTitle">
		            <text>建议标题</text>
		            <text class="suggestTitleDetail">{{suggestion.adviseTitle}}</text>
		        </view>
		        <view class="suggestContent">
		            <text>建议内容</text>
		            <text class="suggestContentDetail">{{suggestion.adviseDetail}}</text>
		        </view>
		    </view>
		  
		    <view>
		        <view class="handleResult">
		            <text>处理结果</text>
		            <text class="handleResultDetail">{{suggestion.result}}</text>
		        </view>
		        <view class="handleDate">
		            <text>结案日期</text>
		            <text class="DateDetail">{{suggestion.closetime}}</text>
		        </view>
		        <view class="handleStatus">
		            <text>状态</text>
		            <text style="width: 50px;" class="handleStatusDetail">{{suggestion.status}}</text>
										
					<text class="handleBtn" @click="toHandleSuggest">处理</text>
		        </view>
		    </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				suggestion: {}
			};
		},
		onLoad(opt){
			this.suggestion = JSON.parse(decodeURIComponent(opt.item));
			
			if(this.suggestion.result==null){
				this.suggestion.result=" ";
			}
			if(this.suggestion.closetime==null){
				this.suggestion.closetime = " ";
			}
			if(this.suggestion.processorUid==null){
				this.suggestion.processorUid = " ";
			}
		},
		methods:{
			toHandleSuggest(){
				if(this.suggestion.status=="已处理"){
							
					uni.showModal({
					    title: '',
					    content: '该建议已被处理'
					})					
				}
				else{
					uni.request({
						url: `${uni.$http.baseUrl}/education/my-suggestion/handlingAdvise`,
						data: {
								"id": this.suggestion.id
						},
						header: {
							token: uni.getStorageSync('token')
						},
						method: 'POST',
						success: res => {
							this.suggestion.status = "处理中"
							let suggestion = JSON.stringify(this.suggestion)
							uni.navigateTo({
								url: '/subpkg/manager/suggestion/manager_suggestion_handle?item=' + suggestion
							})
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
page {
	height: 100%;
	background-color: #FFF2CC;
}

.wrapper {
	padding: 20rpx;
}

/* 建议号、建议人、建议日期 */
.suggestHead {
    display: flex;
    margin-top: 10rpx;
    padding: 10rpx;
}

.suggestHeadDetail,
.suggestHeadDetailID {
    margin-left: 20rpx;
    font-weight: bold;
}

/* 建议人和处理人ID */
.suggestHeadDetailID {
    color: #00B0F0;
    text-decoration: underline;
}

/* 建议标题 */
.suggestTitle,
.suggestContent {
    margin-top: 40rpx;
    display: flex;
}

/* 建议标题内容 */
.suggestTitleDetail {
    display: block;
    width: 70%;
    height: 120rpx;
    margin-left: 20rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

/* 建议内容 */
.suggestContentDetail {
    display: block;
    width: 70%;
    height: 200rpx;
    margin-left: 20rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
}

/* 处理结果 */
.handleResult {
    margin-top: 60rpx;
    display: flex;
}

/* 处理结果详情 */
.handleResultDetail {
    display: block;
    width: 70%;
    height: 80rpx;
    margin-left: 20rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* 结案日期、处理状态 */
.handleDate,
.handleStatus {
    display: flex;
    margin-top: 40rpx;
}

/* 结案日期详情、状态详情 */
.DateDetail,
.handleStatusDetail {
    margin-left: 20rpx;
    font-weight: bold;
}

/* 状态详情颜色 */
.handleStatusDetail {
    color: red;
}

/* 开始处理按钮 */
.handleStart {
    position: absolute;
    bottom: 160rpx;
    width: 200rpx;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 0;
}

.handleBtn {
   // padding: 10rpx 20rpx;
	width: 50px;
	padding-left: 15px;
    border-radius: 30rpx;
    background-color: #8FAADC;
    color: white;
	margin-left: 20px;
}
</style>
