<template>
    <page-layer>
        <template #header>
            <el-button type="primary" icon="Download" @click="exportData" style="margin-left: 2px">导出</el-button>
        </template>
        <template #main>
            <xc-table :data="returnData" localPaging :height="105">
                <el-table-column type="index" label="序号" align="center"></el-table-column>
                <template v-for="col in returnData.tableDisplays">
                    <el-table-column v-if="col.sortable" :prop="col.prop" :label="col.label" :width="col.width"
                        :align="col.align" sortable show-overflow-tooltip>
                    </el-table-column>
                    <el-table-column v-else :prop="col.prop" :label="col.label" :width="col.width" :align="col.align"
                        show-overflow-tooltip>
                    </el-table-column>
                </template>
            </xc-table>
        </template>
    </page-layer>
</template>
<script setup name="ReportPatientPage">
import PageLayer from '@/layout/PageLayer.vue'
import { ref } from '@vue/reactivity'
import { clone } from '@/utils/clone'
import { selectReportPortalMenu, exportReportPortalData } from '@/api/reports/high-report'
import XcTable from "@/components/xiao-chan/xc-table/XcTable"

const props = defineProps({
    reportPatient: {
        type: Object,
        default: {}
    }
})

// 报表基本信息
const reportPatient = ref({})
// 查询信息
const paramPatient = ref({})

reportPatient.value = props.reportPatient.row
paramPatient.value = props.reportPatient.params

nextTick(() => {
    query()
})
const returnData = ref({
    currentPage: 1,
    pageSize: 30,
    total: 0,
    data: []
});

const queryTerm = clone(paramPatient.value)
const query = async () => {
    selectReportPortalMenu(queryTerm)
        .then((res) => {
            returnData.value.tableDisplays = res.tableDisplays
            returnData.value.data = res.dataList
            returnData.value.total = returnData.value.data.length
        });
};
const exportData = () => {
    if (returnData.value.data.length <= 0) {
        ElMessage({
            message: '没有可以导出的数据！',
            type: 'warning',
            duration: 2500,
            showClose: true,
        })
    }
    // 导出excel表格标题
    queryTerm.exportName = reportPatient.value.reportName;
    exportReportPortalData(queryTerm)
}
</script>