viewDrawer.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div>
  3. <BasicDrawer
  4. v-bind="$attrs"
  5. destroyOnClose
  6. @register="registerDrawer"
  7. :title="getTitle"
  8. :width="width"
  9. >
  10. <Description @register="registerDesc" :data="descData" />
  11. </BasicDrawer>
  12. <Button
  13. v-auth="['storage:config:add']"
  14. type="primary"
  15. @click="handleCreate"
  16. preIcon="icon-plus|iconfont"
  17. >
  18. 新增
  19. </Button>
  20. <FormModal @register="registerModal" @success="handleSuccess" />
  21. </div>
  22. </template>
  23. <script lang="ts" setup>
  24. import { onBeforeMount, ref } from 'vue'; // onBeforeMount,
  25. import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  26. import { Description, useDescription } from '/@/components/Description';
  27. import { viewSchema } from './data';
  28. import { archivesPatrolWardDetail } from '/@/api/biz/visit/checkApi';
  29. import { listDictModel } from '/@/api/common';
  30. import FormModal from './formModal.vue';
  31. import { formatDictValue } from '/@/utils';
  32. import { useModal } from '/@/components/Modal';
  33. const descData = ref({});
  34. const getTitle = '查看查房记录';
  35. const width = '45%';
  36. const [registerModal, { openModal }] = useModal();
  37. const typeOptions = ref();
  38. onBeforeMount(async () => {
  39. typeOptions.value = await listDictModel({ dictCode: 'sys_login_log_type' });
  40. });
  41. // 新增按钮事件
  42. function handleCreate() {
  43. openModal(true, {
  44. isUpdate: false,
  45. });
  46. }
  47. const [registerDrawer] = useDrawerInner(async data => {
  48. console.log('::::::::::', data.record);
  49. const resData = await archivesPatrolWardDetail(data.record.id);
  50. descData.value = {
  51. ...resData,
  52. type: formatDictValue(typeOptions.value, resData.type),
  53. };
  54. });
  55. const [registerDesc] = useDescription({
  56. schema: viewSchema,
  57. column: 1,
  58. size: 'middle',
  59. labelStyle: {
  60. width: '120px',
  61. },
  62. });
  63. // 弹窗回调事件
  64. async function handleSuccess({ isUpdate, values }) {
  65. console.log(isUpdate);
  66. console.log(values);
  67. }
  68. </script>