From 658c60998b5607f5573e7cf2b1473a89ed5d7693 Mon Sep 17 00:00:00 2001
From: yuetsh <517252939@qq.com>
Date: Tue, 21 Mar 2023 14:56:16 +0800
Subject: [PATCH] contest problem list.
---
src/admin/api.ts | 24 ++++++++++++++++++---
src/admin/contest/components/Actions.vue | 2 +-
src/admin/contest/problems.vue | 7 ------
src/admin/problem/components/Actions.vue | 27 +++++++++++++++++-------
src/admin/problem/list.vue | 18 ++++++++++++++--
src/routes.ts | 6 +++---
6 files changed, 60 insertions(+), 24 deletions(-)
delete mode 100644 src/admin/contest/problems.vue
diff --git a/src/admin/api.ts b/src/admin/api.ts
index a667840..c1a4833 100644
--- a/src/admin/api.ts
+++ b/src/admin/api.ts
@@ -1,9 +1,15 @@
import http from "utils/http"
import { Problem, User } from "~/utils/types"
-export async function getProblemList(offset = 0, limit = 10, keyword: string) {
- const res = await http.get("admin/problem", {
- params: { paging: true, offset, limit, keyword },
+export async function getProblemList(
+ offset = 0,
+ limit = 10,
+ keyword: string,
+ contestID?: string
+) {
+ const endpoint = !!contestID ? "admin/contest/problem" : "admin/problem"
+ const res = await http.get(endpoint, {
+ params: { paging: true, offset, limit, keyword, contest_id: contestID },
})
return {
results: res.data.results.map((result: Problem) => ({
@@ -22,14 +28,26 @@ export function deleteProblem(id: number) {
return http.delete("admin/problem", { params: { id } })
}
+export function deleteContestProblem(id: number) {
+ return http.delete("admin/contest/problem", { params: { id } })
+}
+
export function editProblem(problem: Problem) {
return http.put("admin/problem", problem)
}
+export function editContestProblem(problem: Problem) {
+ return http.put("admin/contest/problem", problem)
+}
+
export function getProblem(id: number) {
return http.get("admin/problem", { params: { id } })
}
+export function getContestProblem(id: number) {
+ return http.get("admin/contest/problem", { params: { id } })
+}
+
export function getUserList(offset = 0, limit = 10, keyword: string) {
return http.get("admin/user", {
params: { paging: true, offset, limit, keyword },
diff --git a/src/admin/contest/components/Actions.vue b/src/admin/contest/components/Actions.vue
index 3020fd4..48022dc 100644
--- a/src/admin/contest/components/Actions.vue
+++ b/src/admin/contest/components/Actions.vue
@@ -16,7 +16,7 @@ function goEdit() {
function goEditProblems() {
router.push({
- name: "admin contest problems",
+ name: "admin contest problem list",
params: { contestID: props.contest.id },
})
}
diff --git a/src/admin/contest/problems.vue b/src/admin/contest/problems.vue
deleted file mode 100644
index b2d548a..0000000
--- a/src/admin/contest/problems.vue
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- contest problem list
-
-
-
diff --git a/src/admin/problem/components/Actions.vue b/src/admin/problem/components/Actions.vue
index 1e6fbc6..6006b46 100644
--- a/src/admin/problem/components/Actions.vue
+++ b/src/admin/problem/components/Actions.vue
@@ -1,5 +1,5 @@
diff --git a/src/admin/problem/list.vue b/src/admin/problem/list.vue
index 0bb185a..6bad368 100644
--- a/src/admin/problem/list.vue
+++ b/src/admin/problem/list.vue
@@ -6,6 +6,11 @@ import { AdminProblemFiltered } from "~/utils/types"
import { parseTime } from "~/utils/functions"
import Actions from "./components/Actions.vue"
+interface Props {
+ contestID?: string
+}
+
+const props = defineProps()
const total = ref(0)
const problems = ref([])
const query = reactive({
@@ -40,13 +45,22 @@ const columns: DataTableColumn[] = [
title: "选项",
key: "actions",
width: 200,
- render: (row) => h(Actions, { problemID: row.id, onDeleted: listProblems }),
+ render: (row) =>
+ h(Actions, {
+ problemID: row.id,
+ onDeleted: listProblems,
+ }),
},
]
async function listProblems() {
const offset = (query.page - 1) * query.limit
- const res = await getProblemList(offset, query.limit, query.keyword)
+ const res = await getProblemList(
+ offset,
+ query.limit,
+ query.keyword,
+ props.contestID
+ )
total.value = res.total
problems.value = res.results
}
diff --git a/src/routes.ts b/src/routes.ts
index 182e783..7206eac 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -162,9 +162,9 @@ export const routes: RouteRecordRaw[] = [
props: true,
},
{
- path: "contest/:contestID/problems",
- name: "admin contest problems",
- component: () => import("admin/contest/detail.vue"),
+ path: "contest/:contestID/problem/list",
+ name: "admin contest problem list",
+ component: () => import("admin/problem/list.vue"),
props: true,
},
{