update announcement
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getAnnouncementList } from "~/oj/api"
|
import { getAnnouncementList, getAnnouncement } from "~/oj/api"
|
||||||
import Pagination from "~/shared/components/Pagination.vue"
|
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"
|
||||||
@@ -19,13 +19,19 @@ const columns: DataTableColumn<Announcement>[] = [
|
|||||||
key: "create_time",
|
key: "create_time",
|
||||||
title: "发布时间",
|
title: "发布时间",
|
||||||
render: (row) => parseTime(row.create_time),
|
render: (row) => parseTime(row.create_time),
|
||||||
width: 160,
|
width: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "last_update_time",
|
||||||
|
title: "更新时间",
|
||||||
|
render: (row) => parseTime(row.last_update_time),
|
||||||
|
width: 180,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "username",
|
key: "username",
|
||||||
title: "发布人",
|
title: "发布人",
|
||||||
render: (row) => row.created_by.username,
|
render: (row) => row.created_by.username,
|
||||||
width: 100,
|
width: 120,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
function rowProps(row: Announcement) {
|
function rowProps(row: Announcement) {
|
||||||
@@ -35,10 +41,11 @@ function rowProps(row: Announcement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showContent(announcement: Announcement) {
|
async function showContent(announcement: Announcement) {
|
||||||
|
const res = await getAnnouncement(announcement.id)
|
||||||
toggleShow(true)
|
toggleShow(true)
|
||||||
title.value = announcement.title
|
title.value = announcement.title
|
||||||
content.value = announcement.content
|
content.value = res.data.content
|
||||||
}
|
}
|
||||||
const announcements = ref<Announcement[]>([])
|
const announcements = ref<Announcement[]>([])
|
||||||
|
|
||||||
|
|||||||
@@ -168,3 +168,7 @@ export function updateProfile(data: { real_name: string; mood: string }) {
|
|||||||
export function getAnnouncementList(offset = 10, limit = 10) {
|
export function getAnnouncementList(offset = 10, limit = 10) {
|
||||||
return http.get("announcement", { params: { limit, offset } })
|
return http.get("announcement", { params: { limit, offset } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getAnnouncement(id: number) {
|
||||||
|
return http.get("announcement", { params: { id } })
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user