<template>
	<view class="consultItem">
		<view class="top_row">
			<view class="flex">
				<view class="tag"> {{ item.complainDO.userType==1?'投诉驾校':'投诉教练'}}</view>
				<view class="tag">{{ item.complainType }}</view>
			</view>
			<view class="status">{{dealStatus[item.complainDO.dealStatus]}}</view>
		</view>
		<view class="target">
			<view class="row">
				<view class="leftLab">
					<view class="icon">
						<image src="@/static/images/car/ic_jiaxiao.png" mode=""></image>
					</view>
					<view class="lab">驾校名称</view>
				</view>
				<view class="name towRowText">{{ item.complainDO.schoolName }}</view>
			</view>
			<view class="row" v-if="item.complainDO.coachName">
				<view class="leftLab">
					<view class="icon">
						<image src="@/static/images/index/edit.png" mode=""></image>
					</view>
					<view class="lab">教练名称</view>
				</view>
				<view class="name">{{ item.complainDO.coachName }}</view>
			</view>
		</view>
		<view class="content">
			<view class="lab">问题描述</view>
			<view class="text">{{ item.complainDO.content }}</view>
		</view>
		<view class="content" v-if="item.complainReplayDOS&&item.complainReplayDOS.length">
			<view class="lab">回复内容</view>
			<view class="text" v-for="(item2,index2) in item.complainReplayDOS" :key="index2">{{ item2.replyContent }}</view>
		</view>
		<view class="border_bottom">
			<view class="dateBox">
				<view class="date">创建时间：{{ $u.date(item.createTime, 'yyyy-mm-dd')}}</view>
				<view class="date" v-if="item.complainDO.dealStatus==2&&item.complainReplayDOS.length">处理时间：{{ $u.date(item.complainReplayDOS[0].updateTime, 'yyyy-mm-dd')}} </view>
			</view>
			<view class="close_btn" @click="closeFn(item.complainDO.id)"  v-if="item.complainDO.dealStatus==1">关闭</view>
		</view>
	</view>
</template>

<script>
	import { consultationClosed } from '@/config/api.js'
	export default {
		props: ['item'],
		data() {
			return {
				dealStatus: ['','未处理', '已处理', '已关闭' ],//处理状态：1、未处理，2、已处理，3、已关闭
			}
		},
		methods: {
			closeFn(id) {
				uni.showModal({
					content:'确定要关闭吗？',
					success: async (res)=> {
						if (res.confirm) {
							const result = await consultationClosed({id: this.item.complainDO.id})
							this.$u.toast('关闭成功')
							this.item.complainDO.dealStatus = 3
							this.$emit('closeFn')
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.consultItem {
		width: 100%;
		.target {
			border-bottom: 2rpx dashed #E8E9EC;
		}
		.row {
			display: flex;
			align-items: flex-start;
			padding: 24rpx 0;
		  .leftLab {
			  display: flex;
			  align-items: center;
		    .icon {
		      width: 30rpx;
			  height: 30rpx;
		    }
		
		    .lab {
				// margin-left: 10rpx;
				font-size: 28rpx;
				color: #ADADAD;
				white-space: nowrap;
		    }
		  }
		
		  .name {
			font-size: 28rpx;
			color: #333;
			width: 0;
			flex: 1;
			padding-left: 15rpx;
		  }
		}
	  .top_row {
		  display: flex;
		  width: 100%;
		  height: 116rpx;
		  border-bottom: 2rpx dashed #E8E9EC;
		  justify-content: space-between;
		  align-items: center;
	    .tag {
			width: 176rpx;
			height: 60rpx;
			background: rgba(38,144,12,0.1);
			border-radius: 8rpx;
			text-align: center;
			line-height: 60rpx;
			font-size: 28rpx;
			color: #0D9269;
			margin-right: 24rpx;
	    }
	
	    .status {
			font-size: 28rpx;
			color: $themC;
	    }
	  }
	
	  .content {
		  padding: 24rpx 0 20rpx 0;
		  font-size: 28rpx;
	    .lab {
			color: #ADADAD;
			margin-bottom: 4rpx;
	    }
	
	    .text {
	
	    }
	  }
	
	  .border_bottom {
		  border-top: 2rpx dashed #E8E9EC;
		  display: flex;
		  align-items: center;
		  justify-content: space-between;
		  padding: 30rpx 0 16rpx 0;
	    .dateBox {
	      .date {
			font-size: 28rpx;
			color: #ADADAD;
			margin-bottom: 16rpx;
	      }
	    }
	
	    .close_btn {
			width: 140rpx;
			height: 60rpx;
			background: #FFFFFF;
			border-radius: 8rpx;
			border: 2rpx solid #E8E9EC;
			text-align: center;
			line-height: 60rpx;
			color: #ADADAD;
			font-size: 28rpx;
	    }
	  }
	}
</style>