<template>
    <xc-table :local-data="props.data"
              :default-expand-all="props.defaultExpandAll"
              :final-height="getWindowSize.h / 1.2">
        <el-table-column type="expand">
            <template #default="{row}">
                <JsonViewer :value="row.mapMessage"
                            copyable
                            :expandDepth="3"/>
            </template>
        </el-table-column>
        <el-table-column prop="inpatientNo" label="住院号" width="120"/>
        <el-table-column prop="admissTimes" label="次数" width="40"/>
        <el-table-column prop="name" label="姓名" width="220"/>
        <el-table-column prop="gradingScale" label="病历评级"/>
        <el-table-column prop="age" label="年龄"/>
        <el-table-column prop="clinicDiagStr" label="门（急）诊诊断"/>
        <el-table-column prop="admissDiag" label="入院诊断"/>
        <el-table-column prop="admissDate" label="入院时间" width="220"/>
        <el-table-column prop="deptName" label="入院科室" width="220"/>
        <el-table-column prop="zkListName" label="转科"/>
        <el-table-column prop="typing" label="病历分型"/>
        <el-table-column prop="deptDirectorName" label="主任医生"/>
        <el-table-column prop="consultPhysicianName" label="主治医生"/>
        <el-table-column prop="tubeBedDoctorName" label="管床医生" width="220"/>
        <el-table-column prop="mapMessage" label="详情" show-overflow-tooltip>
            <template #header>
                <el-button @click="exportExcel">导出Excel</el-button>
            </template>
            <template #default="{row}">
                {{ mapToStr(row) }}
            </template>
        </el-table-column>
    </xc-table>
</template>

<script setup name='RuleSift'>
import XcTable from "@/components/xiao-chan/xc-table/XcTable.vue";
import {getWindowSize} from "@/utils/window-size";
import {mapToStr} from "./rule-store";
import {Export} from "@/utils/ExportExcel";

const props = defineProps({
    data: Array,
    defaultExpandAll: {
        type: Boolean,
        default: false
    }
})

const exportExcel = () => {
    const title = {
        inpatientNo: '住院号',
        admissTimes: '次数',
        name: '姓名',
        gradingScale: '病历评级',
        age: "年龄",
        clinicDiagStr: '门（急）诊诊断',
        admissDiag: '入院诊断',
        admissDate: '入院时间',
        deptName: '入院科室',
        zkListName: '转科',
        typing: '病历分型',
        deptDirectorName: '主任医生',
        consultPhysicianName: '主治医生',
        tubeBedDoctorName: '管床医生',
        message: '详情',
    }
    Export(props.data, title, "质控数据")
}

onMounted(() => {
    console.log(props.data)
})

</script>

<style scoped lang="scss">

</style>
