viewDrawer.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <BasicDrawer
  3. v-bind="$attrs"
  4. destroyOnClose
  5. @register="registerDrawer"
  6. :title="getTitle"
  7. :width="width"
  8. >
  9. <Description @register="registerDesc" :data="descData" />
  10. </BasicDrawer>
  11. </template>
  12. <script lang="ts" setup>
  13. import { onBeforeMount, ref } from 'vue'; // onBeforeMount,
  14. import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  15. import { Description, useDescription } from '/@/components/Description';
  16. import { viewSchema } from './data';
  17. import { LogDetail } from '/@/api/monitor/LogApi';
  18. import { listDictModel } from '/@/api/common';
  19. import { formatDictValue } from '/@/utils';
  20. const descData = ref({});
  21. const getTitle = '查看系统日志';
  22. const width = '45%';
  23. const typeOptions = ref();
  24. onBeforeMount(async () => {
  25. typeOptions.value = await listDictModel({ dictCode: 'sys_login_log_type' });
  26. });
  27. const [registerDrawer] = useDrawerInner(async data => {
  28. console.log('::::::::::', data.record);
  29. const resData = await LogDetail(data.record.id);
  30. descData.value = {
  31. ...resData,
  32. type: formatDictValue(typeOptions.value, resData.type),
  33. };
  34. });
  35. const [registerDesc] = useDescription({
  36. schema: viewSchema,
  37. column: 2,
  38. size: 'middle',
  39. labelStyle: {
  40. width: '120px',
  41. },
  42. });
  43. </script>