useDrawer.vue 1.63 KB
<template>
  <BasicDrawer
    v-bind="$attrs"
    @register="registerDrawer"
    :showFooter="false"
    :title="getTitle"
    width="800px"
  >
    <DetailChild :emitChildData="childData" />
  </BasicDrawer>
</template>
<script lang="ts">
  import { defineComponent, ref, computed, unref } from 'vue';
  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
  import DetailChild from './child/index.vue';
  import { notifyMyGetDetailApi } from '/@/api/stationnotification/stationnotifyApi';

  // import { useMessage } from '/@/hooks/web/useMessage';

  export default defineComponent({
    name: 'ConfigDrawer',
    components: { BasicDrawer, DetailChild },
    emits: ['success', 'register'],
    setup() {
      // const { createMessage } = useMessage();
      const isUpdate = ref(true);
      let childData: any = ref(null);
      const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
        setDrawerProps({ confirmLoading: false });
        isUpdate.value = !!data?.isUpdate;
        console.log(data.record);
        if (data.record) {
          // console.log(data.record.id);
          let getData = await notifyMyGetDetailApi(data.record.id);
          childData.value = getData;
          // createMessage.success()
        }
        //编辑
        if (unref(isUpdate)) {
        } else {
        }
      });

      const getTitle = computed(() => (!unref(isUpdate) ? '新增通知' : '查看通知'));
      const handleCancel = () => {
        closeDrawer();
      };

      return {
        childData,
        handleCancel,
        getTitle,
        registerDrawer,
      };
    },
  });
</script>