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

  const descData = ref({});
  const getTitle = '查看调度任务';
  const width = '45%';

  const typeOptions = ref();
  const typeStatus = ref();
  onBeforeMount(async () => {
    typeOptions.value = await listDictModel({ dictCode: 'sys_create_type' });
    typeStatus.value = await listDictModel({ dictCode: 'sys_common_result' });
  });
  const [registerDrawer] = useDrawerInner(async data => {
    const resData = data.record;
    // const resData = await smsChannelDetail(data.record.id);
    descData.value = {
      ...resData,
      jobGroup: formatDictValue(typeOptions.value, resData.jobGroup),
      status: formatDictValue(typeStatus.value, resData.status == 'true' ? '0' : '1'),
    };
  });
  const [registerDesc] = useDescription({
    schema: viewSchema,
    column: 2,
    size: 'middle',
    labelStyle: {
      width: '140px',
    },
  });
</script>
