create.vue
1.22 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
<script setup lang="ts" name="notification-create">
import { ref } from 'vue';
import FormContent from '@/views/operation/notification/components/form-content.vue';
import { Message } from '@arco-design/web-vue';
import { onBeforeRouteLeave, useRouter } from 'vue-router';
import useNotificationApi from '@/http/notification';
import { AttributeData } from '@/types/global';
const { create } = useNotificationApi;
const formValue = ref({
title: '',
type: 1,
content: '',
cover: '',
publish_type: 1,
publish_at: '',
publish_to: [],
publish_count: 0,
link_type: 'none',
link_id: 0,
link_name: '',
rich_content: '',
is_alert: 0,
}) as any;
const router = useRouter();
const onSubmit = (value: AttributeData) =>
create(formValue.value).then(() => {
Message.success(`添加通知:${value.title}`);
router.replace({ name: 'operation-notification' });
});
onBeforeRouteLeave((to, from) => {
if (from.meta.from === to.name) {
to.meta.reload = false;
}
});
</script>
<template>
<page-view has-bread has-card>
<form-content v-model="formValue" :submit="onSubmit" />
</page-view>
</template>
<style scoped lang="less"></style>