<template>
	<view>
		<view>
			<uni-search-bar :radius="100" @confirm="search" @input="input" @cancel="cancel"></uni-search-bar>
		</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 section-title">{{item.progressName}}</view>
					</view>
					<view class="row">
						<view class="column-left">工作项：</view>
						<view class="column-right">{{item.nodeName}}</view>
					</view>
					<view class="row">
						<view class="column-left">进度%：</view>
						<view class="column-right">{{item.completePercent}}%</view>
					</view>
					<view class="row">
						<view class="column-left">计划开始：</view>
						<view class="column-right">{{item.plannedStartDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">计划结束：</view>
						<view class="column-right">{{item.plannedFinishDate}}</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>
			</uni-list-item>
		</uni-list>
		
		<uni-load-more :status="status" :icon-size="16" :content-text="contentText" />


		<page-foot :isShow="true" :showIndex="0"></page-foot>
	</view>
</template>

<script>
	import {
		GetPmProgressDTOs
	} 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: '',
				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 projectCode = this.$util.getState(this,'projectCode');
                let searchValue=this.searchvalue;
				let userCode = this.$util.getState(this,'userCode');
				console.info('getList usercode',userCode);
				GetPmProgressDTOs(projectCode,userCode,searchValue).then((res) => {
					console.info('GetPmProgressDTOs',res);
					that.listData = [];
					res.forEach(function(item, index, array) {
						that.$set(that.listData, index, item);
					});
					console.info(that.listData);
				});
			},
			goDetail: function(item) {
				console.info('检查godetail', item);
				
				uni.navigateTo({
					url: '/pages/template/GetpmProgressReportDTOs/GetpmProgressReportDTOs?&progressNodeId=' + item.progressNodeId
				});
			},
			search(res) { //回车搜索
				this.searchvalue = res.value; //赋值

				this.getList(); //调用搜索方法
			},
			input(res) {
				this.searchVal = res.value
			},
			cancel(res) {
				console.info('点击取消，输入值为：' + res.value);

			},
			
		}
	};
</script>

<style scoped lang="scss">
	.uni-list-item{
		border-bottom: $BgColorBlue;
	} 
	
</style>