update contest visible.

This commit is contained in:
2023-12-19 19:32:58 +08:00
parent 47cf7aaa6b
commit 8f716a7ef1
5 changed files with 10 additions and 15 deletions

View File

@@ -130,7 +130,7 @@ export function createContest(contest: BlankContest) {
return http.post("admin/contest", contest)
}
export function editContest(contest: BlankContest) {
export function editContest(contest: Contest | BlankContest) {
return http.put("admin/contest", contest)
}

View File

@@ -2,7 +2,7 @@
import { NSwitch, NTag } from "naive-ui"
import Pagination from "~/shared/components/Pagination.vue"
import { Contest } from "~/utils/types"
import { getContestList } from "../api"
import { getContestList, editContest } from "../api"
import ContestType from "~/shared/components/ContestType.vue"
import ContestTitle from "~/shared/components/ContestTitle.vue"
import { CONTEST_STATUS } from "~/utils/constants"
@@ -16,7 +16,10 @@ const query = reactive({
keyword: "",
})
function toggleVisible(id: number) {}
function toggleVisible(contest: Contest) {
contest.visible = !contest.visible
editContest(contest)
}
const columns: DataTableColumn<Contest>[] = [
{ title: "ID", key: "id", width: 60 },
@@ -52,7 +55,7 @@ const columns: DataTableColumn<Contest>[] = [
value: row.visible,
size: "small",
rubberBand: false,
onUpdateValue: () => toggleVisible(row.id),
onUpdateValue: () => toggleVisible(row),
}),
},
{