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

		<NullList :remark="'强防护，不恐慌，信科学，不传谣'" v-if="!recordList.length"></NullList>
		<div class="mui-content">
			<ul class="mui-table-view vongi-yqsb-list">
				<li v-for="(item,index) in recordList" class="mui-table-view-cell">
					<router-link :to="{name:'MasterHealthReportInfo',query:{id:item.id}}">
						<div class="mui-media-body">
							{{item.content}}
						</div>
						<span class="vongi-wordcard" v-if="item.img">
							<div class="fyy-upphoto flew">
								<div v-for="(iten,inden) in item.img.split(',')" class="mui-col-xs-3">
									<img :src="iten" />
								</div>
							</div>
						</span>
						<p class="flew-sp"><span class="color55f868" v-text="item.statusN"></span><span v-text="item.createTime"></span></p>
					</router-link>
				</li>
			</ul>
		</div>
		<div class="fyy-footer">
			<div class="bindfyy-btn" @click="goToForm"><button type="submit" class="mui-btn mui-btn-primary ">疫情上报</button></div>
		</div>

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

<script>
	import * as API_Health from '@/apis/Master/health'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import isReachBottom from '$project/utils/isReachBottom'
	import TopHeader from '$project/components/TopHeader.vue'
	import NullList from '$project/components/NullList.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterHealthReportList',
		components: {
			Common,
			Loading,
			TopHeader,
			NullList
		},
		data() {
			return {
				pageTitle: '疫情上报记录',

				isLoading: false,

				listForm: {
					pageIndex: 1,
					pageSize: 20,
					totalPage: 1,
				},
				recordList: [],
			}
		},
		created() {},
		methods: {
			//获取列表
			getList() {
				this.isLoading = true;
				API_Health.getReportList(this.listForm).then(response => {
					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++;
					this.isLoading = false;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//下拉事件
			handleScrool() {
				if (isReachBottom()) {
					console.log('到达底部')
					if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
						this.getList();
					} else {
						return;
					}
				}
			},
			//填写页面
			goToForm() {
				this.$router.push({
					name: 'MasterHealthReport'
				})
			},
			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',
			})
		}
	}
</script>

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