<template>
    <z-paging ref="paging" v-model="list" @query="handleQuery">
        <template #top>
            <mx-nav-bar title="心理健康测评结果"/>
        </template>
        <view class="py-30">
            <uv-cell v-for="row in list" :key="row.examineeId" is-link class="bg-white"
                     :title="row.endTime" label="测评时间" value="查看报告" @click="goReport(row)"/>
        </view>
    </z-paging>
</template>

<script setup>
import {ref} from 'vue';
import MxConst from "@/common/MxConst";
import {getMentalHealthHistories} from "@/api/webApi/mental-health";
import {useTransfer} from "@/hooks/useTransfer";

const list = ref([])
const paging = ref(null)
const {transferTo} = useTransfer()

const handleQuery = (pageNum, pageSize) => {
    getMentalHealthHistories({pageNum, pageSize})
        .then(res => paging.value.completeByTotal(res.rows, res.total))
        .catch(e => paging.value.complete(false))
}

const goReport = (row) => {
    const next = {testType: MxConst.enum.mentalHealthTestType, examineeId: row.examineeId}
    transferTo('/pagesOther/pages/test-center/mental-health/report', next)
}
</script>

<style>

</style>
