<template>
  <BasicDrawer v-bind="$attrs" @register="registerDescDrawer" title="系统通知公告详情" width="30%">
    <Description @register="registerDesc" :data="noticed" />
  </BasicDrawer>
</template>
<script lang="ts" setup>
  import { onBeforeMount, ref } from 'vue'; // onBeforeMount,
  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import { Description, useDescription } from '/@/components/Description';
  import { descFormSchema } from './data';

  import { sysNoticeDetail } from '/@/api/sys/sysNoticeApi';
  import { listDictModel } from '/@/api/common';
  import { formatDictValue } from '/@/utils';

  const noticed = ref({});
  const sysNoticeTypeOptions = ref([]);
  onBeforeMount(async () => {
    sysNoticeTypeOptions.value = await listDictModel({ dictCode: 'sys_notice_type' });
  });
  const [registerDescDrawer] = useDrawerInner(async data => {
    console.log('::::::::::', data.record);
    const resData = await sysNoticeDetail(data.record.noticeId);
    noticed.value = {
      ...resData,
      noticeType: formatDictValue(sysNoticeTypeOptions.value, resData.noticeType),
    };
  });
  const [registerDesc] = useDescription({
    schema: descFormSchema,
    column: 1,
    labelStyle: {
      width: '120px',
    },
  });
</script>
