<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 { sysConstantDetail } from '/@/api/sys/sysConstantMenuApi';
  import { listDictModel } from '/@/api/common';
  import { formatDictValue } from '/@/utils';

  const descData = ref({});
  const getTitle = '查看常量菜单';
  const width = '45%';

  const disableOptions = ref();
  onBeforeMount(async () => {
    disableOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
  });
  const [registerDrawer] = useDrawerInner(async data => {
    console.log('::::::::::', data.record);
    const resData = await sysConstantDetail(data.record.id);
    descData.value = {
      ...resData,
      disable: formatDictValue(disableOptions.value, resData.disable),
    };
  });
  const [registerDesc] = useDescription({
    schema: viewSchema,
    column: 2,
    size: 'middle',
    labelStyle: {
      width: '120px',
    },
  });
</script>
