<template>
	<view class="content">
		<!-- <view class="example-body" v-if="listCards&&listCards.length>0">
			<view v-for="(item,index) in listCards" :key="index" class="example-box" style="position: relative;flex: 1;" >
				<dev-block :title="item.title" :titleNumber="item.titleNumber" :note="item.note" :extra="item.extra" :tagType="item.tagType"
				 :contentList="item.contentList" @click="toDetail(item)" ></dev-block>
			</view>
			<uni-load-more  :status="loading_status"></uni-load-more>
			<view class="goHome" @click='goMain()'>
				<img src="../../static/img/gohome.png">
			</view>
		</view> -->
		<view class="example-body">
			<no-record ></no-record>
		</view>
	</view>
</template>

<script>
import noRecord from '@/components/xinsoft-no-record/xinsoft-no-record';
import devBlock from '@/components/xinsoft-dev-block/xinsoft-dev-block.vue'
import uniIcons from '@/components/uni-icons/uni-icons.vue'
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
// import jweixin from '@/jweixin-module/index.js';
export default {
	components: {
		noRecord,devBlock,uniIcons,uniLoadMore
	},
	data() {
		return {
		pageno:1,//当前第几页
		pagesize:5,//每页加载数据条数
		contractType: 1,
		employeeId: '',
		filterResult: {

		},
		listCards: [],
		dataList: [],
		loading_status: 'more',//more（loading前）、loading（loading中）、noMore（没有更多了）
		}
	},
	onShow(){
		var _this=this;
		this.$eventHub.$on('changestate', function (data) {
			var datajson=data;
			if(datajson.id){
				for(var i=0;i<_this.listCards.length;i++){
					if(_this.listCards[i].id==datajson.id){
						 var str=_this.listCards[i].title;
						_this.listCards[i].title=str.split('-')[0]+"-"+datajson.state;
					}
				}
			}
			_this.$eventHub.$off('changestate');
		});	
	},
	onLoad() {
		var _this = this;
		uni.getStorage({
			key: 'userInfo',
			success: function (res) {
				_this.employeeId = res.data.employeeId
			}
		});
		var userInfo =  uni.getStorageSync('userInfo');
		if(userInfo!=''&&userInfo!=undefined){

			this.dataList=userInfo;
		}
		this.getLaborContract({});
	},
	//滚动到底部加载下一页
	onReachBottom(obj){
		if(this.loading_status=='noMore'){
			return false;
		}
		this.pageno++;
		this.getLaborContract();
	},
	//下拉刷新
	onPullDownRefresh(){
		this.listCards=[];
		this.pageno=1;
		this.loading_status="more";
		this.getLaborContract();
		  
	},
	mounted() {

	},
	created() {
		
	},
	methods: {	
		getLaborContract(n) {
			if(n==1){
				this.pageno=1
				this.listCards=[]
			}
			this.loading_status="loading";
			// var filterRes = {};
			this.filterResult.pageno = this.pageno;
			this.filterResult.pagesize = this.pagesize;
			this.filterResult.contractType = this.contractType;
			this.filterResult.employeeId = this.employeeId;
			this.$http.request({
				url: '/apis/contractInfo/pageList',
				paramsBody: this.filterResult,
				})
				.then(res => {
					uni.stopPullDownRefresh();
					if(!res.data.data){
					this.loading_status="noMore";
					}else if(res.data.data.datas.length<this.pagesize){
						this.loading_status="noMore";
					}else{
						this.loading_status="more";
					}
					
					if (res.data.code == 0) {
						this.listCards = this.listCards.concat(this.formaterData(res.data.data.datas));
					}
				}).catch(err => {
					this.loading_status="noMore";
				});
			},
	
		formaterData(data) {
			var resData = [];
			data.forEach((vals, index) => {
				var combineJSON = {
					id: vals.id,
					title: "合同编号"+":"+vals.contractCode,
					// titleNumber: vals.processName?"工序名称"+":"+vals.processName:' ',
					contentList: [{
							id: 1,
							isDouble: false,
							labelName: '签订单位',
							labelContent: vals.signingDeptName
						},
						{
							id: 2,
							isDouble: false,
							labelName: '签订日期',
							labelContent: vals.signingDate?vals.signingDate.substr(0,10):''
						},
						{
							id: 3,
							isDouble: false,
							labelName: '终止日期',
							labelContent: vals.stopDate?vals.stopDate.substr(0,10):''
						},
						{
							id: 4,
							isDouble: false,
							labelName: '合同年限（年）',
							labelContent: vals.contractTerm?vals.contractTerm:''
						}
					],
					note:'查看详情',
					name: vals.employeeName,
					// alreadyCount:vals.alreadyCount,
					// planCount:vals.planCount,
					// isOutsource: vals.isOutsource
				}
				resData.push(combineJSON);
			});
			return resData;
		},
		toDetail(item) {
				uni.removeStorageSync('trainingContract');
				uni.navigateTo({
				    url: 'trainingContractDetail?id='+item.id+"&name="+item.name
				});
		}
	},
	
	
	onBackPress(options) { //取消默认的返回事件.
		uni.switchTab({
			url: "../main/main"
		});
		return true;
	}
}
</script>

<style scoped>
	uni-input {
	    position: relative;
	    top: 4px;
		color: rgb(102, 102, 102);
	    display: block;
	    font-size: 13px;
	    line-height: 1.4em;
	    height: 1.4em;
	    min-height: 1.4em;
	    overflow: hidden;
	}
	.content{
		position: relative;
	}
	.filter_container {
		position: fixed;
		width: 50%;
		top: var(--window-top);
		background-color: #fff;
		height: 40px;
		z-index: 2;
		padding-top: 7px;
		box-sizing: border-box;
	}
	>>>.doubleList:nth-of-type(1) {
			width: 60%;
		}
	
		>>>.doubleList:nth-of-type(2) {
			width: 40%;
		}
	
		>>>.doubleList:nth-of-type(3) {
			width: 60%;
		}
		>>>.doubleList:nth-of-type(4) {
			width: 40%;
		}
		>>>.dev-label{
			white-space: nowrap;
		}
	>>>.select-tab-fixed-top{
		right: 0;
		width: 50%;
		z-index: 2;
		top:var(--window-top);
		white-space: nowrap
	}
	>>>.popup-layer{
		position: fixed;
		top: var(--window-top);
		margin-top: 40px;
	}
	>>>.filter-content-detail{
	/* 	position: relative;
		height: 90px;
		overflow: scroll; */
	}
		.search_container {
			position: relative;
			padding-left: 30px;
			box-sizing: border-box;
			color: #bdbdbd;
			margin: auto;
			width: 80%;
			height: 26px;
			background-color: #F6F6F6;
			border-radius: 26px;
			font-size: 14px;
			line-height: 26px;
		}
	.search_icon{
		position: absolute;
		left: 5px;
		top: 3px;
	}
		.fliter_content {
			position: absolute;
			right: 15px;
			left: 85px;
			height: 100%;
			z-index: 2;
		}
		.arrowright{
			position: absolute;
			right: 30upx;
			bottom: 30upx;
			font-size: 40upx !important;
		}
		>>>.dev-block__content{
			padding-right: 36upx;
		}
		>>>.dev-block__header-title-text{
			overflow: auto;
			white-space: pre-wrap !important;
			
		}
	
	
	
	/* >>>.select-tab >>>.select-tab-item[data-v-fe683d44],
	>>>.select-tab-fixed-top >>>.select-tab-item[data-v-fe683d44] {
	    width: 100% !important;
	} */
	.arrowright{
		position: absolute;
		right: 30upx;
		bottom: 30upx;
		font-size: 40upx !important;
	}
	>>>.dev-block__content{
		padding-right: 36upx;
	}
	>>>.popup-layer{
		position: fixed;
		top: var(--window-top);
		margin-top: 40px;
	}
</style>


