<template>
	<view class="container">
		<view class="details">
			<view class="detail_msg">
				<view class="info-item status">
					<text class="label">考核状态： </text>
					<text v-if="item.reply_flag =='0'" class="infoSpan" style="color: red;" >未回复</text><!-- statusred -->
					<text v-if="item.reply_flag =='1'" class="infoSpan" style="color: #ff9000;">已回复</text>
					<text v-if="item.reply_flag =='2'" class="infoSpan" style="color: green;">已办结</text>
				</view>
				<!-- <view class="info-item">  
					<text class="label">检查人： </text>
					<text class="infoSpan">{{item.userName}}</text>
				</view> -->
				<view class="info-item">
					<text class="label">考核项目： </text>
					<text class="infoSpan">{{ item.repair_option_name }}</text>
				</view> 
				<view v-if="item.repair_option_sub_name" class="info-item">
					<text class="label">考核小项： </text>
					<text class="infoSpan">{{ item.repair_option_sub_name }}</text>
				</view> 
				
				<view class="info-item">
					<text class="label">考核位置： </text>
					<text class="infoSpan">{{item.repair_place+" "+(item.repair_floor||'')+""+(item.repair_room_no?"-"+item.repair_room_no+'':'')}}</text>
				</view>
				<view v-if="item.fault_detail" class="info-item">
					<text class="label">考核描述： </text>	
					<text class="infoSpan">{{item.fault_detail}}</text>
				</view>
				
				<view v-if="item.fault_proposal" class="info-item">
					<text class="label">考核建议： </text>	
					<text class="infoSpan">{{item.fault_proposal}}</text>
				</view>
				<view  class="info-item">
					<text class="label">考核评价： </text>	
					<text class="infoSpan">{{item.fault_evaluate}}</text>
				</view>
				<view class="info-item">
					<text class="label">考核分数： </text>
					<text class="infoSpan">{{item.check_fraction+"分"}}</text>
				</view>
				<view class="info-item">
					<text class="label">考核时间： </text>	
					<text class="infoSpan">{{item.repair_time}}</text>
				</view>
				<view class="img-box" >
					<image v-for="(itemImg,imgIndex) in item.pictures" :key="imgIndex" :src="formatImgUrl(itemImg)" mode="" @click="vbPicture(new Array(formatImgUrl(itemImg)))"></image>
				</view>
			</view> 
		</view>
		<view class="details" v-if="item.reply_flag!='0'" v-for="(reply,replyIndex) in item.replyList" :key="replyIndex">
			<view class="detail_msg" >
				<view class="info-item">
					<text class="label">回复内容： </text>	
					<text class="infoSpan">{{reply.reply_content}}</text>
				</view>
				<view  class="info-item" >
					<text class="label">回复时间： </text>	
					<text class="infoSpan">{{ formatDate(reply.reply_date,'dateTime')}}</text>
				</view>
				<view class="img-box" >
					<image v-for="(itemImg,imgIndex) in reply.replyPictures" :key="imgIndex" :src="formatImgUrl(itemImg)" mode="" @click="vbPicture(new Array(formatImgUrl(itemImg)))"></image>
				</view>
			</view>
		</view>
		<!-- <view style="clear: both;"></view>
		<view class="occupied"></view> -->
		<!-- <view class="footer-btn" v-if="role=='1' && first_status=='0'">
			<view class="btn">取消</view>
		</view> -->
		<!-- <view class="footer-btn footer-btn-two" v-if="item.statusCode == '10'">
			<view class="btn btn-col" @click="submit(2)">拒绝</view>
			<view class="btn btn-col1" @click="submit(1)">接受</view>
		</view> -->
	</view>
</template>

<script>
	import {
		getFaultRepairInfoById
	} from '@/common/api.js';
	import {
		callbackRequest,
		getStorage,
		alertTip,
		formatDate,
		sureAlterTip,vbPicture,
		formatImgUrl
	} from '@/common/util.js';
	export default {
		data() {
			return {
				vbPicture:vbPicture,
				formatImgUrl:formatImgUrl,
				userInfo:'',
				formatDate:formatDate,
				item: {},
				id:0,
				userId: getStorage('userInfo').id,
			}
		},
		onLoad(option) {
			this.userInfo = getStorage('userInfo');
			this.id = option.id||0;
			this.getFaultRepairInfoById();
		},
		methods: {
			getFaultRepairInfoById(){
				let params =  {
						method: getFaultRepairInfoById,
						data: {
							userId:this.userId,
							id:this.id
						}
					};
				callbackRequest(params).then(res => {
					res = res.data;
					if (res.returnCode == 1) {
						this.item = res.returnData;
					} else {
						alertTip(res.returnMsg);
					}
				});
			},
			submit(type){
				if (type != 1 && type != 2 ){ 
					return
				}
				// 1 同意 2 拒绝
				let params = {
					"method": doHitch,
					"data":{
						userId: this.userInfo.id,
						type: type,
						id: this.item.id
					}
				};
				console.log("params:",params);
				callbackRequest(params).then(res => {
					res = res.data;
					console.log("return:", res);
					alertTip(res.returnMsg);
					if ( res.returnCode === "1"){
						// 跳回列表页
						uni.navigateTo({
							url:'/pages/repair-record/repair-record'
						})
					}
				})
			}
				
		}
	}
</script>

<style lang="scss">
	@import '@/static/css/common.scss';
	.container {
		min-height:100vh;
		background: #f8f8f8;
		font-size: 28upx;
		.details{
			// height: 550upx;
			background: white;
			margin: 15upx;
			border-radius: 15upx;
			padding-bottom:15rpx;
			.detail_header {
				border-bottom: #f8f8f8 5upx solid;
				height: 90upx;
				line-height: 90upx;
				margin: 15upx;
				border-radius: 10upx;
				.blueSign {
					height: 28upx;
					width: 5upx;
					background: #00c277;
					display: inline-block;
					margin-left: 20upx;
				}
				.font-tilte {
					font-weight:bold;
					margin-left: 20upx;
				}
			}
			.detail_msg {
				margin-left: 20upx;
				border-radius: 10upx;
				.info-item{
					border-bottom:1px solid #f8f8f8;
					padding:20upx 10upx;
					line-height: 50upx;
					.label{
						display:inline-block;
						width:150upx;
						font-size:28upx;
						color:#333;
						font-weight:bold;
					}
				}
				.status {
					.infoSpan{
						color: #00c277;
					}
					.infoSpan2{
						color: red;
					}
				}
				.img-box {
					// background: #fff;
					image{
						width: 200upx;
						height: 200upx;
						margin:20upx 20upx 0 0;
					}
				}
			}
		}
	}
</style>
