import { h, resolveComponent } from 'vue'

export default {
	props: {
		currentPage: {
			type: Number,
			required: true
		},
		pageSize: {
			type: Number,
			required: true
		}
	},
	render() {
		return h (
			resolveComponent("el-table-column"),
			{
				index:this.index,
				...this.$attrs
			},
			this.$slots
		)
	},
	methods: {
		index(index) {
			if (this.$attrs.type === "index") {
				if(this.currentPage && this.pageSize){
					return (this.currentPage - 1) * this.pageSize + index + 1;
				}else{
					let page = this.$parent.$parent.currentPage
					let pageSize = this.$parent.$parent.pageSize
					return (page - 1) * pageSize + index + 1
				}
			}
			return index
		}
	}
}
