<template>
  <BasicDrawer
    v-bind="$attrs"
    destroyOnClose
    @register="registerDrawer"
    :title="getTitle"
    :width="width"
  >
    <Description @register="registerDesc" :data="descData" />
  </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 { viewSchema } from './data';
  import { storageRecordDetail } from '/@/api/infra/storageRecordApi';

  const descData = ref({});
  const getTitle = '查看存储记录';
  const width = '45%';

  onBeforeMount(async () => {});
  const [registerDrawer] = useDrawerInner(async data => {
    const resData = await storageRecordDetail(data.record.id);
    resData.size = resData.size + ' kb';
    descData.value = {
      ...resData,
    };
  });
  const [registerDesc] = useDescription({
    schema: viewSchema,
    column: 1,
    size: 'middle',
    labelStyle: {
      width: '120px',
    },
  });
</script>
