<template>
	<view class='page'>
		<view class="top_container" style="padding-right: 30upx;clear: both;overflow: auto;">
			<view class="report_status">
				<text class="magtext">{{data_result.repairEvent.reventStatusName}}</text>
				<text class="magtext">(编号:{{data_result.repairEvent.workOrderNo||''}})</text>
			</view>
			<!-- <view class="report_status2">(编号:{{data_result.repairEvent.workOrderNo||''}})</view> -->
			<view v-if="data_result.repairEvent.reventStatusId=='56'">  <!-- 待处理 -->
				<view class="btn"   @click="toRepair()">维修处理</view>
				<view class="btn"   @click="toTurnTo()">维修转派</view>
			</view>
			<view v-else-if="data_result.repairEvent.reventStatusId=='57'">  <!-- 待验收 -->
				<view class="btn"  @click="toEvaluate">验收评价</view>
			</view>
		</view>
		<view class="detail_name_container">
			<view :class="[current_num==1?'current':'']" @click="changecurrent(1)">故障信息</view>
			<view :class="[current_num==2?'current':'']" @click="changecurrent(2)">维修记录</view>
		</view>
		<view v-if="current_num==1">
			<view class="myContainer myContentBox">
				<view class="top_container">设备信息</view>
				<view class="list_item">
					<view class="list_item_name">设备编号</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.deviceSerialno}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">设备名称</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.deviceName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">设备类别</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.deviceTypeName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">规格型号</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.deviceModel}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">安装地点</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.deciceSite}}</view>
				</view>
			</view>
			<view class="myContainer myContentBox">
				<view class="top_container">报修信息</view>
				<view class="list_item">
					<view class="list_item_name">任务等级</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.reventLevelName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">报修人</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.createUserName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">报修时间</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.createTime}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name" style="width: 180upx;">要求完成时间</view>
					<view class="list_item_content content_right">{{data_result.repairEvent.planTime}}</view>
				</view>
			</view>
			<view class="myCon myContentBox">
				<view class="top_container">详细描述</view>
				<view class="resultContent">{{data_result.repairEvent.reventConent}}</view>
				<view class="img-wrap" v-for="(items,index) in data_result.repairEventImage" :key='index'>
					<view class="img-box">
						<img :src="config.imgURL+items.filePath" />
					</view>
				</view>
			</view>
			<view class="myContainer myContentBox">
				<view class="top_container">人员信息</view>
				<view class="list_item">
					<view class="list_item_name">责任人</view>
					<view class="list_item_content content_right" v-if="data_result.repairEvent.engineerUserName">{{data_result.repairEvent.engineerUserName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">抄送人</view>
					<view class="list_item_content content_right" >
						<view v-for="(items,index) in data_result.ccIdList" :key='index' style="display: inline;">
							<view v-if="index!=0" style="display: inline;">,{{items.name}}</view>
							<view v-else style="display: inline;">{{items.name}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else-if="current_num==2">
			<view  class="myContainer myContentBox" v-for="(items,index) in data_result.records" :key='index'  @click="edit(index,items)">
				<view class="top_container detail_list_top">
					<view class="report_status" style="float: left;line-height: 50upx;">{{items.typeName}}</view>
					<view class="report_status3" :class="'report_status3_'+items.usageId">{{items.usageName}}</view>
					<view class="report_status" style="clear: both;">停机时间:{{items.offTime}}</view>
					<view class="edit" v-if="items.statusId=='146'">编辑</view>  <!-- 暂存 -->
					<view class="edit" v-else>维修详情</view>
				</view>
				<view style="clear: both;">
					<view class="multi_list_item">
						<view class="list_item list_item-">
							<view class="list_item_name">维修工时:</view>
							<view class="list_item_content" v-if="items.manHour">{{items.manHour}}小时</view>
						</view>
						<view class="list_item list_item-">
							<view class="list_item_name">报修费用:</view>
							<view class="list_item_content" v-if="items.cost">{{items.cost}}元</view>
						</view>
					</view>
					<view class="list_item" >
						<view class="list_item_name" >维修时间:</view>
						<view class="list_item_content" v-if="items.startTime">{{setTime1(items.startTime)}}~{{setTime1(items.endTime)}}</view>
					</view>
					<view class="list_item ">
						<view class="list_item_name">故障原因:</view>
						<view class="list_item_content">{{items.cause}}</view>
					</view>
					<view class="list_item ">
						<view class="list_item_name">维修方案:</view>
						<view class="list_item_content">{{items.solution}}</view>
					</view>
					<view class="multi_list_item" style="border-top: 1px solid #EDEDED;">
						<view class="list_item list_item-">
							<view class="list_item_name">维修人:</view>
							<view class="list_item_content">{{items.heldPersonName}}</view>
						</view>
						<view class="list_item list_item-">
							<view class="list_item_name">验收结果:</view>
							<view class="list_item_content list_item_content_no" v-if="items.statusId==116">{{items.statusName}}</view> <!-- 不通过 -->
							<view class="list_item_content " v-else>{{items.statusName}}</view>
						</view>
					</view>
				</view>
			</view>
		</view >
		<view class="goHome" @click='goMain()'>
			<img src="../../static/img/gohome.png">
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		config
	} from '../../request/js/config.js'
	export default{
		data(){
			return {
				config:config,
				current_num:1,
				id:'',
				data_result:{
					repairEvent:{},
					details:[]
					}
			}
		},
		onLoad(option) {
			  this.id=option.id;
			if(this.id==undefined){
				uni.reLaunch({
				    url: 'eqRepair'
				});
				return false;
			}
			this.setpartList([]);
			this.setrepairRecordList({});
			   var _this = this;
			   this.$http.request({
			     url: '/apis/repairEvent/getDetail',
			     params: {
			       eventId:option.id
			     },
			   }).then(res=>{
			   	if(res.data.code == 0){
					this.data_result=res.data;
			   	}else{
					this.data_result={}
				}
			   }).catch(err=>{
				  uni.showToast({
				  	title: '获取信息失败',
				  	duration: 	1000,
				  	icon:"none"
				  });
			   });
			
		},
		methods:{
			...mapMutations(['setpartList','setrepairRecordList']),
			setTime1(time) {
				if(time==''||!time){
					return '';
				}else{
					var t = time.split('-');
					return t[0] + '/' + t[1] + '/' + t[2].substring(0, 8)
				}
				
			
			},
			//点击维修处理
			toRepair(){
				uni.navigateTo({
				    url: "repairStep1?id="+this.id
				});
			},
			//维修转派
			toTurnTo(){
				uni.navigateTo({
				    url: "repairTurnTo?id="+this.id+"&flag=wxzp"
				});
			},
			changecurrent(num){
				this.current_num=num;
			},
			//验收评价
			toEvaluate(){
				uni.navigateTo({
				    url: "acceptEvaluation?id="+this.id
				});
				
			},
			//编辑
			edit(index,items){
				if(items.statusId==146){//编辑
					uni.navigateTo({
						url: "repairStep1?id="+this.id+"&recordId="+this.data_result.records[index].id
					});
				}else{//查看详情
					uni.navigateTo({
					    url: "maintenanceDetails?id="+this.data_result.records[index].id
					});
				}
							  
			},
		},
		onBackPress(options) { //取消默认的返回事件.
			uni.navigateTo({
				url: "eqRepair"
			});
			return true;
		}
	}
</script>

<style scoped>
	
	.detail_list_top{
		border-bottom: 1px solid #EDEDED;
		box-shadow: none;
		padding-right: 30upx;
	}
	.report_status{
		line-height: 40upx;
		word-break: break-all;
		font-size: 28upx;
	}
	.report_status .magtext{margin-right: 5px;}
	
	.report_status_{
		float: left;
		margin-right: 20upx;
	}
	.report_status2{
		float: left;
		line-height: 40upx;
		color: #666666;
	}
	.report_status3{
		float: left;
		padding:16upx 20upx;
		font-size: 20upx;
		line-height: 20upx;
		border-radius: 30upx;
		margin-left: 20upx;
		margin-bottom: 8upx;
	}
	/* 正常运行 */
	.report_status3_106{
		background-color: #EBF5FF;
		color: #3382FF;
		
	}
	/* 带病运行 停机待修 停用报废*/
	.report_status3_107,.report_status3_108,.report_status3_109{
	background-color: #FFEBEB;
	color: #FF0000;
	}
	
	.btn{
		width: 160upx;
		height:68upx;
		text-align: center;
		line-height: 68upx;
		border-radius: 10upx;
		background-color: #3382FF;
		color: #fff;
		font-size: 28upx;
		float: left;
		margin-right: 30upx;
		margin-top: 30upx;
	}
	
	.edit{
		position: absolute;
		font-size: 28upx;
		color: #3382FF;
		right: 30upx;
		top: 50upx;
		
	}
	.multi_list_item{
		position: relative;
		overflow: auto;
	}
	.list_item-{
		width: 50%;
		float: left;
	}
	
	.list_item- .list_item_name{
		width: 120upx !important;
		white-space: nowrap;
	}
	
	.list_item_content_no{
		color: #FF9C00;
	}
</style>
