<template>
	<div class="pagination-container">
    <el-pagination 
    	v-show="pageData.total>0" 
    	:current-page="pageData.page" 
    	:page-sizes="[10,20,30,50]" 
    	:page-size="pageData.limit" 
    	:total="pageData.total" 
    	background 
    	layout="total, sizes, prev, pager, next, jumper" 
    	@size-change="handleSizeChange" 
    	@current-change="handleCurrentChange"/>
    </div> 
</template>

<script>
	import {filterSearchData} from '@/api/common/pagination'
export default{
	name: 'PaginationIndex',
	/**
	 * pageData: 
	 * 	total
	 *  page
	 *  limit
	 *  keywords
	 *  listLoading
	 */
	props:{
		pageData:{
			type: Object,
			required: true,
		},
		requestUrl:{
			type: String,
			required: true,
		}
	},
	data(){
		return {
		}
	},
	methods: {
		filterSearch(){
			this.pageData.listLoading = true;
			filterSearchData(this.pageData,this.requestUrl).then(response=>{
				this.pageData.total =  response.data.total;
				this.$emit("retData",response.data.list);
				this.pageData.listLoading = false;
			});
		},
		handleSizeChange(val){ //改变分页尺寸大小
  		this.pageData.limit = val;
  		this.pageData.page = 1;
  		this.filterSearch();
  	},
  	handleCurrentChange(val){ //分页查询
  		this.pageData.page = val;
  		this.filterSearch();
  	},
		
	}
}
</script>

<style>

</style>