<template>
    <div class="p-3">
        <div class="bg-fff flex1 ov-hd d-flex flex-cln">
            <div class="d-flex a-c pd-16 border-bottom">
                <div class="f-s-20 c-333 f-w-7 mr-10">详情</div>
                <el-button @click="router.go(-1)" type="primary" text>
                    <el-icon>
                        <Back />
                    </el-icon>
                    返回上一级
                </el-button>
            </div>
            <div class="flex1 over-auto">
                <div class="pd-16">
                    <div class="info-title mb-16">新闻基本信息</div>
                    <el-descriptions :column="2">
                        <el-descriptions-item label="标题:">{{ form?.title || '-' }}</el-descriptions-item>
                        <el-descriptions-item label="类型:">{{ selectDictLabel(news_type, form?.type) || '-' }}</el-descriptions-item>
                        <el-descriptions-item label="来源:">{{ form?.source || '-' }}</el-descriptions-item>
                        <el-descriptions-item label="链接地址:">
                            <a :href="form?.link || '#'" target="_blank">{{ form?.link || '-' }}</a>
                        </el-descriptions-item>
                    </el-descriptions>
                    <el-divider />
                    <el-descriptions :column="1">
                        <el-descriptions-item label="封面图:">
                            <el-image style="width: 100px; height: 100px" :src="form?.coverImg" :zoom-rate="1.2" :max-scale="7" :min-scale="0.2" :preview-src-list="[form?.coverImg]" fit="cover"></el-image>
                        </el-descriptions-item>
                        <el-descriptions-item label="内容:">
                            <div v-html="form?.content || '-'"></div>
                        </el-descriptions-item>
                    </el-descriptions>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup name="MedicineNews-detail" lang="ts">
import { getNewsInfo } from '@/api/dgtmedicine/news';

const { query }: any = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { news_type } = toRefs<any>(proxy?.useDict('news_type'));
const router = useRouter();

const form = ref<any>({});

const getDetail = async () => {
    proxy?.$modal.loading('加载中...');
    const res = await getNewsInfo(query?.id).finally(() => {
        proxy?.$modal.closeLoading();
    });
    if (!res || res.code !== 200) return;
    form.value = {
        ...res.data
    };
};

onMounted(() => {
    getDetail();
});
</script>
