<template>
	<view class="page">
		<view class="top_container" style="padding-right: 30upx;clear: both;overflow: auto;" v-show="num==2">
			<view class="btn"   @click="sendMsg()">回复</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">{{info.createByName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">部门</view>
					<view class="list_item_content content_right">{{info.deptName}}</view>
				</view>
				<view class="list_item">
					<view class="list_item_name">时间</view>
					<view class="list_item_content content_right">{{changeTime(info)}}</view>
				</view>
			</view>
			<!-- <view class="myContainer myContentBox">
				<view class="list_item" style="padding: 20upx 0px">
					<view class="list_item_name" style="color:#333;">
						<view>工作周报</view>
						<view>{{changeTime(info)}}</view>
					</view>
					<view class="list_item_content content_right">
						<view>姓名：{{info.createByName||'-'}}</view>
						<view>部门：{{info.deptName||'-'}}</view>
					</view>
				</view>
			</view> -->
			<view class="myContainer acceptTitle">本周完成工作</view>
			<view class="myContainer myContentBox">
				<view class="resultContent">{{info.comContent||''}}</view>
			</view>
			<view class="myContainer acceptTitle">本周工作总结</view>
			<view class="myContainer myContentBox">
				<view class="resultContent">{{info.contentSum||''}}</view>
			</view>
			<view class="myContainer acceptTitle">下周工作计划</view>
			<view class="myContainer myContentBox">
				<view class="resultContent">{{info.contentPlan||''}}</view>
			</view>
			<view class="myContainer acceptTitle">备注</view>
			<view class="myContainer myContentBox">
				<view class="resultContent">{{info.description||''}}</view>
			</view>
			<view class="myContainer myContentBox">
				<view class="item item_line">
					<view class="itemname" style="color: #000;">本周计划详情</view>
					<view class="itemtext" style="padding-bottom: 0px;">
						<button type="primary" size="mini" @click="toSeven">点击查看</button>
					</view>
				</view>
			</view>
			<view v-if="initFileList.length>0">
				<view class="myContainer acceptTitle">图片</view>
				<view class="myCon myContentBox">
					<view class="resultContent" style="height: 26upx; padding: 0px;"></view>
					<view class="img-wrap" v-for="(items,index) in initFileList" :key='index'>
						<view class="img-box">
							<img :src="config.imgURL+'/'+items.filePath" />
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else-if="current_num==2">
			<view class="myCon myContentBox" v-if="approvalList.length>0">
				<uni-steps :options="approvalList" :active="approvalList.length" direction="column" />
			</view>
		</view> 
		<view class="goHome" @click='goMain("weekInfo")'>
			<img src="../../static/img/gohome.png">
		</view>
	</view>
</template>

<script>
	import {
		config
	} from '../../request/js/config.js'
	import uniSteps from '@/components/uni-steps/uni-steps.vue'
	export default{
		components: {
			uniSteps
		},
		data(){
			return {
				current_num:1,
				config:config,
				info:{},
				initFileList:[],
				id:'',
				approvalList:[],
				num:''
			}
		},
		onLoad(option) {
			this.id=option.id;
			this.num = option.num;
			if(this.id==undefined){
				uni.reLaunch({
				    url: 'week'
				});
				return false;
			}
		    var _this = this;
		    this.$http.request({
				 url: '/apis/weekReport/detail',
				 method:'GET',
				 params: {
				   id:_this.id
				 },
		   }).then(res=>{
			if(res.data.code == 0){
				this.info = res.data.weekReport;
				this.initFileList = res.data.initFileList;
				if(res.data.commentList && res.data.commentList.length>0){
					res.data.commentList.forEach(function(val,index){
						var myjson = {
							title: val.createByName+':'+val.comment,
							desc: val.createTime?('时间：'+val.createTime):'时间：'
						}
						// if(val.isDealed){
						// 	_this.active = index;
						// }
						_this.approvalList.push(myjson);
					});
				}
			}else{
				uni.showToast({
					title: '获取信息失败',
					duration: 	1000,
					icon:"none"
				});
			}
		   }).catch(err=>{
			   console.log(err)
		   });
			
		},
		methods:{
			changeTime(info){
				var st = [];
				var en = [];
				if(info.startTime){
					st = info.startTime.split(" ");
				}
				if(info.endTime){
					en = info.endTime.split(" ");
				}
				var time1 = st[0]||'-';
				var time2 = en[0]||'-';
				return time1+'~'+time2;
			},
			toSeven(){
				var _this = this;
				uni.navigateTo({
				    url: "weekDetailSeven?id="+_this.id
				});
			},
			changecurrent(num){
				this.current_num=num;
			},
			sendMsg(){
				uni.redirectTo({
				    url: "sendMsg?id="+this.id
				});
			},
		}
	}
</script>
<style scoped>
	.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;
		float:right
	}
</style>