add tag for announcement
This commit is contained in:
@@ -16,10 +16,16 @@ const [ready, toggleReady] = useToggle()
|
|||||||
const announcement = reactive<AnnouncementEdit>({
|
const announcement = reactive<AnnouncementEdit>({
|
||||||
id: 0,
|
id: 0,
|
||||||
title: "",
|
title: "",
|
||||||
|
tag: "",
|
||||||
content: "",
|
content: "",
|
||||||
visible: false,
|
visible: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const tags: SelectOption[] = [
|
||||||
|
{ label: "空白", value: "" },
|
||||||
|
{ label: "更新", value: "更新" },
|
||||||
|
]
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
if (!props.announcementID) {
|
if (!props.announcementID) {
|
||||||
toggleReady(true)
|
toggleReady(true)
|
||||||
@@ -69,6 +75,9 @@ onMounted(init)
|
|||||||
<n-form-item label="标题">
|
<n-form-item label="标题">
|
||||||
<n-input class="contestTitle" v-model:value="announcement.title" />
|
<n-input class="contestTitle" v-model:value="announcement.title" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
<n-form-item label="标签">
|
||||||
|
<n-select class="select" v-model:value="announcement.tag" :options="tags" />
|
||||||
|
</n-form-item>
|
||||||
<n-form-item label="可见">
|
<n-form-item label="可见">
|
||||||
<n-switch v-model:value="announcement.visible" />
|
<n-switch v-model:value="announcement.visible" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
@@ -88,6 +97,10 @@ onMounted(init)
|
|||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.select {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
.contestTitle {
|
.contestTitle {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const announcements = ref<Announcement[]>([])
|
|||||||
const columns: DataTableColumn<Announcement>[] = [
|
const columns: DataTableColumn<Announcement>[] = [
|
||||||
{ title: "ID", key: "id", width: 60 },
|
{ title: "ID", key: "id", width: 60 },
|
||||||
{ title: "标题", key: "title", minWidth: 300 },
|
{ title: "标题", key: "title", minWidth: 300 },
|
||||||
|
{ title: "标签", key: "tag", width: 120 },
|
||||||
{
|
{
|
||||||
title: "创建时间",
|
title: "创建时间",
|
||||||
key: "create_time",
|
key: "create_time",
|
||||||
@@ -59,6 +60,7 @@ async function toggleVisible(announcement: Announcement) {
|
|||||||
editAnnouncement({
|
editAnnouncement({
|
||||||
id: announcement.id,
|
id: announcement.id,
|
||||||
title: announcement.title,
|
title: announcement.title,
|
||||||
|
tag: announcement.tag,
|
||||||
content: announcement.content,
|
content: announcement.content,
|
||||||
visible: announcement.visible,
|
visible: announcement.visible,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Pagination from "~/shared/components/Pagination.vue"
|
|||||||
import { parseTime } from "~/utils/functions"
|
import { parseTime } from "~/utils/functions"
|
||||||
import { Announcement } from "~/utils/types"
|
import { Announcement } from "~/utils/types"
|
||||||
import { isDesktop } from "~/shared/composables/breakpoints"
|
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||||
|
import { NTag } from "naive-ui"
|
||||||
|
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const content = ref("")
|
const content = ref("")
|
||||||
@@ -15,6 +16,11 @@ const query = reactive({
|
|||||||
})
|
})
|
||||||
const columns: DataTableColumn<Announcement>[] = [
|
const columns: DataTableColumn<Announcement>[] = [
|
||||||
{ key: "title", title: "公告标题", minWidth: 300 },
|
{ key: "title", title: "公告标题", minWidth: 300 },
|
||||||
|
{
|
||||||
|
key: "tag",
|
||||||
|
title: "标签",
|
||||||
|
render: (row) => h(NTag, row.tag || "公告"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "create_time",
|
key: "create_time",
|
||||||
title: "发布时间",
|
title: "发布时间",
|
||||||
|
|||||||
@@ -331,19 +331,16 @@ export interface Server {
|
|||||||
is_disabled: boolean
|
is_disabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Announcement {
|
|
||||||
id: number
|
|
||||||
created_by: SampleUser
|
|
||||||
title: string
|
|
||||||
content: string
|
|
||||||
create_time: Date
|
|
||||||
last_update_time: Date
|
|
||||||
visible: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AnnouncementEdit {
|
export interface AnnouncementEdit {
|
||||||
id: number
|
id: number
|
||||||
title: string
|
title: string
|
||||||
|
tag: string
|
||||||
content: string
|
content: string
|
||||||
visible: boolean
|
visible: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Announcement extends AnnouncementEdit {
|
||||||
|
created_by: SampleUser
|
||||||
|
create_time: Date
|
||||||
|
last_update_time: Date
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user