<template>
	<view class="page">
		<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 :class="[current_num==3?'current':'']" @click="changecurrent(3)">验收评价</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">{{repairInfo.startTime}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">实际完工时间</view>
					<view class="list_item_content content_right">{{repairInfo.endTime}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">故障类型</view>
					<view class="list_item_content content_right">{{repairInfo.typeName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">设备停机时长</view>
					<view class="list_item_content content_right">{{repairInfo.offHour?repairInfo.offHour+'小时':'-'}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">使用情况</view>
					<view class="list_item_content content_right">{{repairInfo.usageName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">维修工时</view>
					<view class="list_item_content content_right">{{repairInfo.manHour?repairInfo.manHour+'小时':'-'}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">维修费用</view>
					<view class="list_item_content content_right">{{repairInfo.cost?repairInfo.cost+'元':'-'}}</view>
				</view>
			</view>
			<view class="myContainer myContentBox">
				<view class="top_container">故障原因</view>
				<view class="resultContent">{{repairInfo.cause}}</view>
			</view>
			<view class="myCon myContentBox">
				<view class="top_container">维修方案</view>
				<view class="resultContent">{{repairInfo.solution}}</view>
				<view class="img-wrap" v-for="(items,index) in repairRecordImage" :key='index'>
					<view class="img-box">
						<img :src="config.imgURL+'/'+items.filePath" />
					</view>
				</view>
			</view>
		</view>
		<view v-else-if="current_num==2">			
			<view v-for="(item,index) in listCards" :key="index" class="example-box difBox">
				<dev-block :title="item.title" :titleNumber="item.titleNumber" :contentList="item.contentList"></dev-block>
				<view class="myContentBox uni-flex uni-row diffDetails">
					<view class="flex-item">单价：{{item.price||'-'}}元</view>
					<view class="flex-item">总价：{{item.total||'-'}}元</view>
					<view class="flex-item">数量：{{item.amount||'-'}}个</view>
				</view>
			</view>
		</view>	
		<view v-else-if="current_num==3">
			<view class="myContainer myContentBox">
				<view class="list_item" style="padding: 20upx 0px">
					<view class="list_item_name" style="padding-top: 28upx; color:#333;">{{checkInfo.resultName||'-'}}</view>
					<view class="list_item_content content_right">
						<view>验收人：{{checkInfo.createName||'-'}}</view>
						<view>验收时间：{{checkInfo.update_time||'-'}}</view>
					</view>
				</view>
			</view>
			<view class="myContainer myContentBox">
				<view class="top_container">验收评价</view>
				<view class="star_content">
					<view class="star_name">完成效率</view>
					<view class="star">
						<uni-rate :value="checkInfo.xl_grade||'-'" active-color="#3382FF" :disabled="true" color="#C1C1C1"></uni-rate>
					</view>
				</view>
				<view class="star_content">
					<view class="star_name">完成质量</view>
					<view class="star">
						<uni-rate :value="checkInfo.qa_grade||'-'" active-color="#3382FF" :disabled="true" color="#C1C1C1"></uni-rate>
					</view>
				</view>
				<view class="star_content">
					<view class="star_name">工作态度</view>
					<view class="star">
						<uni-rate :value="checkInfo.td_grade||'-'" active-color="#3382FF" :disabled="true" color="#C1C1C1" ></uni-rate>
					</view>
				</view>
			</view>
			<view class="myContainer myContentBox">
				<view class="top_container">验收意见</view>
				<view class="resultContent">{{checkInfo.content||'-'}}</view>
			</view>
		</view>
		<view class="goHome" @click='goMain()'  >
		 	<img src="../../static/img/gohome.png">
		</view>
	</view>
</template>

<script>
	import uniRate from "@/components/uni-rate/uni-rate.vue"
	import devBlock from '@/components/xinsoft-dev-block/xinsoft-dev-block.vue'
	import {
		config
	} from '../../request/js/config.js'
	export default{
		components: {
			devBlock,uniRate
		},
		data(){
			return {
				config:config,
				current_num:1,
				id:'',
				repairInfo:{},
				repairRecordImage:[],
				listCards: [],
				checkInfo:{}
			}
		},
		onLoad(option) {
			this.id=option.id;
			if(this.id==undefined){
				uni.reLaunch({
				    url: 'eqRepair'
				});
				return false;
			}
		    var _this = this;
		    this.$http.request({
				 url: '/apis/repairEvent/getRecordDetail',
				 params: {
				   recordId:_this.id
				 },
		   }).then(res=>{
			if(res.data.code == 0){
				this.repairInfo = res.data.recordInfo;
				this.repairRecordImage = res.data.repairRecordImage;
				this.listCards = this.formaterData(res.data.mapList);
				if( res.data.checkInfo.length>0){
					this.checkInfo = res.data.checkInfo[0];
				}
			}else{
				uni.showToast({
					title: '获取信息失败',
					duration: 	1000,
					icon:"none"
				});
			}
		   }).catch(err=>{
			   console.log(err)
		   });
			
		},
		methods:{
			changecurrent(num){
				this.current_num=num;
			},
			formaterData(data){
				var resData = [];
				data.forEach((vals,index)=>{
					var combineJSON = {
						id: vals.id,
						title: vals.name,
						titleNumber:'['+vals.code+']',
						contentList: [
							{
								id:1,
								isDouble:true,
								labelName:'规格型号',
								labelContent:vals.type
							},						
							{
								id:2,
								isDouble:true,
								labelName:'库位',
								labelContent:vals.facilityLocation
							}
						],
						amount:vals.amount,
						price:vals.price,
						total:vals.total
					}
					resData.push(combineJSON);
				});
				return resData;
			},
		}
	}
</script>
<style scoped>
	.difBox .dev-block{
		border-radius: 12upx 12upx 0px 0px ;
		box-shadow:none;
	}
	.diffDetails{
		height: 80upx;
		margin:-24upx 24upx 24upx 24upx;
		font-size: 28upx;
		color:#333;
		border-top: 1px solid #EDEDED;
		border-radius: 0px 0px 12upx 12upx;
		overflow: hidden;
	}
	.flex-item {
		width: 33.3%;
		text-align: center;
		line-height: 80upx;
	}
</style>