useDrawer.vue
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<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>