<template>
	<view>
		<uni-list>
			<uni-list-item v-for="(item, index) in listData" :key="index" @click="goDetail(item)" clickable >
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">工作项：</view>
						<view class="column-right">{{item.progressName}}->{{item.nodeName}}</view>
					</view>
					<view class="row">
						<view class="column-left">实际开始时间：</view>
						<view class="column-right">{{item.actualStartDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">实际结束时间：</view>
						<view class="column-right">{{item.actualFinishDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">进度：</view>
						<view class="column-right progress-box">
						<progress :percent="item.completePercent" show-info stroke-width="3" /> 	 
						</view>
					</view>
					 
					<view class="row">
						<view class="column-left">状态：</view>
						<view class="column-right">{{item.stateName}}</view>
					</view>
					 
				</view>
			</uni-list-item>
		</uni-list>
		 <view style="bottom: 15px;right:10px;position: fixed;z-index: 50;">
		 	<router-link :to="'/pages/template/ProgressReportAdd/ProgressReportAdd?progressId=' + progressId +'&progressName=' + progressName +'&progressNodeId=' + progressNodeId +'&progressNodeName=' + progressNodeName" style="text-decoration: none;" title="进度报告添加">
		 		<uni-icons type="plus-filled" size="80" color="#5678FE"></uni-icons>
		 	</router-link>
		 </view>
	</view>
</template>

<script>
	import {
		GetpmProgressReportDTOs
	} from "@/common/api/ProgressApi.js";
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	 
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				listData: [],
				searchvalue:'',
				last_id: '',
				progressId:0,
				progressName:'',
				progressNodeId:0,
				progressNodeName:'',
				
				reload: false,
				status: 'more',

				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多'
				}
			};
		},
		onLoad() {
			console.info("当前登录状态:" + this.$store.state.isLogin);
			//console.info(this);
			this.$util.persistLogin(this);
		},
		onPullDownRefresh() {
			this.reload = true;
			this.last_id = '';

			this.getList();
		},
		onReachBottom() {
			this.status = 'more';
			this.getList();
		},
		created: function() {
			this.getList();
		},
		methods: {

			getList() {
				let that = this;
				let progressNodeId = that.$util.getQuery("progressNodeId");	
				let userCode=that.$util.getState(that, 'userCode');
				GetpmProgressReportDTOs(progressNodeId).then((res) => {
					console.info(res);
					that.listData=[];
					res.forEach(function(item, index, array) {
						that.$set(that.listData, index, item);
						if(index==0){
							that.progressId=item.progressId;
							that.progressName=item.progressName;
							that.progressNodeId=item.progressNodeId;
							that.progressNodeName=item.nodeName;
						}
					});
					console.info(that.listData);
				});
			},
			goDetail: function(item) {
				console.info('检查godetail', item);
				
				uni.navigateTo({
					url: '/pages/template/GetpmProgressReportDTO/GetpmProgressReportDTO?&id=' + item.id
				});
			},
            search(res) { //回车搜索
            	this.searchvalue = res.value; //赋值
            	
            	this.getList(); //调用搜索方法
            },
            input(res) {
            	this.searchVal = res.value
            },
            cancel(res) {
            	console.info('点击取消，输入值为：' + res.value);
            	
            }
		}
	};
</script>

<style scoped>
	
</style>
