<template>
    <z-paging ref="paging" v-model="list" :default-page-size="20" @query="handleQuery">
        <template #top>
            <mx-nav-bar :title="prevData.title||prevData.paperType"/>
        </template>
        <view class="p-20 grid grid-cols-2 gap-20">
            <ie-paper-item v-for="i in list" :item="i"/>
        </view>
    </z-paging>
</template>

<script setup>
import {ref, computed} from 'vue'
import {useTransfer} from "@/hooks/useTransfer";
import _ from "lodash";
import {getPaperList} from "@/api/webApi/paper";
import IePaperItem from "@/pagesOther/pages/topic-center/paper-entry/components/ie-paper-item.vue";

const paging = ref(null)
const list = ref([])
const {prevData} = useTransfer()
const query = computed(() => _.pick(prevData.value, ['subjectId', 'paperType']))

const handleQuery = function (pageNum, pageSize) {
    getPaperList({...query.value, pageNum, pageSize})
        .then(res => {
            paging.value.completeByTotal(res.rows, res.total)
        })
        .catch(e => paging.value.complete(false))
}
</script>

<style lang="scss">

</style>
