update announcement

This commit is contained in:
2024-06-12 10:31:08 +08:00
parent cc89920553
commit e379c0bb6d
2 changed files with 16 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { getAnnouncementList } from "~/oj/api"
import { getAnnouncementList, getAnnouncement } from "~/oj/api"
import Pagination from "~/shared/components/Pagination.vue"
import { parseTime } from "~/utils/functions"
import { Announcement } from "~/utils/types"
@@ -19,13 +19,19 @@ const columns: DataTableColumn<Announcement>[] = [
key: "create_time",
title: "发布时间",
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",
title: "发布人",
render: (row) => row.created_by.username,
width: 100,
width: 120,
},
]
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)
title.value = announcement.title
content.value = announcement.content
content.value = res.data.content
}
const announcements = ref<Announcement[]>([])

View File

@@ -168,3 +168,7 @@ export function updateProfile(data: { real_name: string; mood: string }) {
export function getAnnouncementList(offset = 10, limit = 10) {
return http.get("announcement", { params: { limit, offset } })
}
export function getAnnouncement(id: number) {
return http.get("announcement", { params: { id } })
}