fix
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

This commit is contained in:
2026-05-20 09:32:08 -06:00
parent 9093ba56e6
commit 2850887ce3
3 changed files with 23 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import { addProblemForContest } from "admin/api"
interface Props { interface Props {
problemID: number problemID: number
contestID: string contestID: string
nextDisplayId?: string
} }
const props = defineProps<Props>() const props = defineProps<Props>()
const emit = defineEmits(["added"]) const emit = defineEmits(["added"])
@@ -39,7 +40,7 @@ async function addProblem() {
</template> </template>
<n-flex vertical> <n-flex vertical>
<span>请输入在这场比赛中的显示编号</span> <span>请输入在这场比赛中的显示编号</span>
<n-input autofocus v-model:value="displayID" /> <n-input autofocus v-model:value="displayID" :placeholder="props.nextDisplayId ?? ''" />
</n-flex> </n-flex>
</n-popconfirm> </n-popconfirm>
</template> </template>

View File

@@ -1,12 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getProblemList } from "admin/api" import { getProblemList } from "admin/api"
import Pagination from "shared/components/Pagination.vue" import Pagination from "shared/components/Pagination.vue"
import { AdminProblemFiltered } from "utils/types" import type { AdminProblemFiltered } from "utils/types"
import AddButton from "./AddButton.vue" import AddButton from "./AddButton.vue"
interface Props { interface Props {
show: boolean show: boolean
count: number count: number
nextDisplayId?: string
} }
const props = defineProps<Props>() const props = defineProps<Props>()
const emit = defineEmits<{ const emit = defineEmits<{
@@ -34,6 +35,7 @@ const columns: DataTableColumn<AdminProblemFiltered>[] = [
h(AddButton, { h(AddButton, {
problemID: row.id, problemID: row.id,
contestID: route.params.contestID as string, contestID: route.params.contestID as string,
nextDisplayId: props.nextDisplayId,
onAdded: () => emit("change"), onAdded: () => emit("change"),
}), }),
width: 60, width: 60,
@@ -53,7 +55,14 @@ watch(
}, },
) )
watch(() => [query.limit, query.page], getList) watch(() => [query.limit, query.page], getList)
watchDebounced(() => query.keyword, getList, { debounce: 500, maxWait: 1000 }) watchDebounced(
() => query.keyword,
() => {
query.page = 1
getList()
},
{ debounce: 500, maxWait: 1000 },
)
</script> </script>
<template> <template>
<n-modal <n-modal

View File

@@ -34,6 +34,15 @@ const { count, inc } = useCounter(0)
const total = ref(0) const total = ref(0)
const problems = ref<AdminProblemFiltered[]>([]) const problems = ref<AdminProblemFiltered[]>([])
const nextDisplayID = computed(() => {
if (!isContestProblemList.value || problems.value.length === 0) return ""
const ids = problems.value.map((p) => p._id)
if (ids.every((id) => /^\d+$/.test(id))) {
return String(Math.max(...ids.map((id) => parseInt(id))) + 1)
}
return ""
})
interface ProblemQuery { interface ProblemQuery {
keyword: string keyword: string
author: string author: string
@@ -184,7 +193,7 @@ watch(() => [query.page, query.limit, query.author], listProblems)
v-model:limit="query.limit" v-model:limit="query.limit"
v-model:page="query.page" v-model:page="query.page"
/> />
<Modal v-model:show="show" :count="count" @change="listProblems" /> <Modal v-model:show="show" :count="count" :next-display-id="nextDisplayID" @change="listProblems" />
</template> </template>
<style scoped> <style scoped>