<template>
	<div>
		<common @asynCallBack="asynCallBack"></common>
		<top-header :pageTitle="pageTitle"></top-header>

		<div class="mui-content vongi-zctj">
			<div class="vongi-bagfff">
				<div class="vongi-xzdw-search">
					<input v-model="listForm.name" @keyup.enter="searchForm" type="search" placeholder="搜索姓名或编号">
					<span class="mui-icon mui-icon-search"></span>
				</div>
			</div>
			<div id="slider" class="mui-slider mui-fullscreen ">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a @click="reloadList('0')" :class="'mui-control-item '+(listForm.status=='0'?'mui-active':'')">
							未激活({{notActivation}}人)
						</a>
						<a @click="reloadList('1')" :class="'mui-control-item '+(listForm.status=='1'?'mui-active':'')">
							已激活({{activation}}人)
						</a>
					</div>
				</div>
				<div class="mui-slider-group">
					<div class="mui-slider-item mui-control-content">
						<div class="mui-scroll-wrapper">
							<div class="mui-scroll vongi-archives">
								<ul class="mui-table-view">
									<li v-for="(item,index) in recordList" class="mui-table-view-cell">
										<router-link :to="{name:'MasterCompanyRegisterStatisticsInfo',params:{detail:item}}" class="mui-navigate-right">
											<div class="mui-pull-left flew-items">
												<div class="mui-media-object"><img :src="item.faceImagUrl?item.faceImagUrl:require('$project/assets/img/default_face.png')"></div>
												{{item.personName}}
											</div>
											<span class="mui-pull-right" v-text="item.personRoleName"></span>
										</router-link>
									</li>
								</ul>
							</div>
						</div>
					</div>

				</div>
			</div>

		</div>

		<loading :visible="isLoading"></loading>
	</div>
</template>

<script>
	import * as API_Company from '@/apis/Master/company'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import isReachBottom from '$project/utils/isReachBottom'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterCompanyRegisterStatistics',
		components: {
			Common,
			Loading,
			TopHeader
		},
		data() {
			return {
				isLoading: false,

				pageTitle: '激活统计',

				listForm: {
					name: '',
					status: '0',
					pageIndex: '',
					pageSize: 20,
					totalPage: 1,
				},
				recordList: [],

				activation: 0,
				notActivation: 0
			}
		},
		created() {},
		methods: {
			//获取列表
			getList() {
				this.isLoading = true;
				API_Company.activationListData(this.listForm).then(response => {
					this.isLoading = false;

					this.activation = response.activation;
					this.notActivation = response.notActivation;

					if (response) {
						if (this.listForm.pageIndex == 1) {
							this.recordList = response.data;
							this.listForm.pageIndex = response.pageNumber;
							this.listForm.totalPage = response.totalPage;
						} else {
							this.recordList = [
								...this.recordList,
								...response.data
							];
						}
					}
					this.listForm.pageIndex++;

				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//重新加载列表
			reloadList(status) {
				this.listForm.status = status;
				this.listForm.pageIndex = 1;
				this.getList();
			},
			//搜索
			searchForm() {
				this.listForm.pageIndex = 1;
				this.getList();
			},
			//下拉事件
			handleScrool() {
				if (isReachBottom()) {
					console.log('到达底部')
					if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
						this.getList();
					} else {
						return;
					}
				}
			},
			asynCallBack() {},
		},
		mounted() {
			this.getList();
			//监控下拉加载事件
			var _this = this;
			window.addEventListener('scroll', _this.handleScrool);
		},
		destroyed() {
			//销毁监听事件
			var _this = this;
			window.removeEventListener('scroll', _this.handleScrool);
		},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
				person_data: 'person_data',
				person_popedom: 'person_popedom',
				menu_list: 'menu_list',
				common_menu_list: 'common_menu_list',
			})
		}
	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
