Files
ojnext/src/admin/announcement/components/Actions.vue
2024-07-05 09:10:23 +08:00

40 lines
921 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script lang="ts" setup>
import { deleteAnnouncement } from "~/admin/api"
interface Props {
announcementID: number
}
const props = defineProps<Props>()
const emit = defineEmits(["deleted"])
const router = useRouter()
const message = useMessage()
function goEdit() {
router.push({
name: "admin announcement edit",
params: { announcementID: props.announcementID },
})
}
async function handleDelete() {
await deleteAnnouncement(props.announcementID)
message.success("删除成功")
emit("deleted")
}
</script>
<template>
<n-flex>
<n-button size="small" type="success" secondary @click="goEdit">
编辑
</n-button>
<n-popconfirm @positive-click="handleDelete">
<template #trigger>
<n-button size="small" type="error" secondary>删除</n-button>
</template>
确定删除这条公告吗
</n-popconfirm>
</n-flex>
</template>
<style scoped></style>