<template>
    <div class="h-full">
        <div class="p-3 text-16 text-black text-center shrink-0 top-bar">
            <!-- <span class="back-bt">
                <span @click="onBack">
                    <doc-icon type="doc-left" />
                </span>
            </span> -->
            <span>慢病筛查记录</span>
        </div>
        <div class='card' v-for='item in list' :key="item.id">
            <div class="p-4">
                <div class='text-16 font-semibold mb-2 title'>{{ item.residentName }}</div>
                <div class="mb-2">
                    <span class="label">证件号码</span>
                    <span>{{ $idCardHide(item.idCard) }}</span>
                </div>
                <div class="mb-2">
                    <span class="label">筛查日期</span>
                    <span>{{ item.screenDate }}</span>
                </div>
                <div class="mb-2">
                    <span class="label">筛查机构</span>
                    <span>{{ item.screenUnitName }}</span>
                </div>
                <div class="bt-box flex pt-2 justify-end">
                    <van-button type="primary" size="small"
                        @click="toDetail(item)">详 情</van-button>
                </div>
            </div>
            <div class="divide"></div>
        </div>
    </div>
</template>

<script>
import { showNotify } from 'vant'
import { querScreenList } from '@/api/resident/screening.js'

export default {
    data() {
        return {
            list: []
        }
    },
    computed: {
        routeQuery() {
            return this.$route.query
        },
        idCard() {
            return this.routeQuery.idCard
        }
    },
    created() {
        if (!this.idCard) {
            showNotify({ type: 'warning', message: '未获取到用户信息'})
            return
        }
        this.init()
    },
    methods: {
        init() {
            querScreenList({ idCard: this.idCard }).then(res => {
                this.list = res.data || []
            })
        },
        toDetail(record) {
            if (!record) return
            const path = `/resident/screening/first/detail/${record.id}`
            this.$router.push({ path })
        }
    }
}
</script>

<style lang="less" scoped>
@import url('../../../utils/common.less');
.card {
    .label {
        display: inline-block;
        min-width: 5em;
        color: #8C8C8C;
    }
    .bt-box {
        border-top: 1px solid var(--van-border-color);
    }
    .divide {
        border-top: 6px solid #f5f5f5;
    }
    &:last-child {
        .divide { display: none; }
    }
}
</style>
