feat(admin): 新增题库模块并优化比赛管理功能
新增题库模块,包含题目管理页面和Excel导入导出功能 优化比赛管理功能,包括分组管理、硬件绑定和题目配置 重构比赛添加流程,增加重置功能和数据校验 添加Excel工具函数,支持读取和导出Excel文件 更新依赖,添加xlsx库支持
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { NGrid, NGridItem, NInput } from 'naive-ui'
|
||||
import { ref, watch } from 'vue'
|
||||
import { NButton, NGrid, NGridItem, NInput, NUpload } from 'naive-ui'
|
||||
import { useHardwareBinding, useHardwareExcel, useQuickGenerate } from './useHardwareBinding'
|
||||
|
||||
const props = defineProps<{
|
||||
config?: {
|
||||
@ -9,64 +9,52 @@ const props = defineProps<{
|
||||
}
|
||||
}>()
|
||||
|
||||
interface HardwareGroup {
|
||||
groupId: string
|
||||
pens: Array<{ label: string, sn: string, online: boolean }>
|
||||
}
|
||||
const { hardwareGroups, validate, reset } = useHardwareBinding(props)
|
||||
const { handleDownloadTemplate, handleUpload } = useHardwareExcel(props, hardwareGroups)
|
||||
const { quickGenerate } = useQuickGenerate(props, hardwareGroups)
|
||||
|
||||
const hardwareGroups = ref<HardwareGroup[]>([])
|
||||
|
||||
function generateHardwareGroups() {
|
||||
if (!props.config)
|
||||
return
|
||||
|
||||
const { groupCount, teamCount } = props.config
|
||||
if (!groupCount || groupCount <= 0)
|
||||
return
|
||||
|
||||
const totalGroups = groupCount
|
||||
const newGroups: HardwareGroup[] = []
|
||||
|
||||
for (let i = 1; i <= totalGroups; i++) {
|
||||
const idStr = String(i).padStart(2, '0')
|
||||
const currentTeamCount = teamCount
|
||||
|
||||
const pens = []
|
||||
for (let j = 1; j <= currentTeamCount; j++) {
|
||||
pens.push({
|
||||
label: `T${j}`,
|
||||
sn: '',
|
||||
online: false, // 模拟初始状态
|
||||
})
|
||||
}
|
||||
|
||||
newGroups.push({
|
||||
groupId: idStr,
|
||||
pens,
|
||||
})
|
||||
}
|
||||
hardwareGroups.value = newGroups
|
||||
}
|
||||
|
||||
watch(() => props.config, generateHardwareGroups, { deep: true, immediate: true })
|
||||
|
||||
function validate() {
|
||||
// 暂时不需要强制校验硬件绑定,允许跳过
|
||||
return true
|
||||
}
|
||||
|
||||
defineExpose({ validate })
|
||||
defineExpose({ validate, reset })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full">
|
||||
<div class="mb-8">
|
||||
<h2 class="mb-2 text-3xl text-gray-800 font-bold">
|
||||
点阵笔硬件绑定
|
||||
</h2>
|
||||
<p class="text-gray-400">
|
||||
请将点阵笔序列号 (SN) 绑定至对应队伍。建议使用扫码枪快速录入。
|
||||
</p>
|
||||
<div class="mb-8 flex items-center justify-between">
|
||||
<div>
|
||||
<h2 class="mb-2 text-3xl text-gray-800 font-bold">
|
||||
点阵笔硬件绑定
|
||||
</h2>
|
||||
<p class="text-gray-400">
|
||||
请将点阵笔序列号 (SN) 绑定至对应队伍。建议使用扫码枪快速录入。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-4">
|
||||
<NButton secondary type="primary" @click="handleDownloadTemplate">
|
||||
<template #icon>
|
||||
<icon-ic-baseline-download class="text-icon" />
|
||||
</template>
|
||||
下载模板
|
||||
</NButton>
|
||||
<NUpload :show-file-list="false" :custom-request="handleUpload" accept=".xlsx, .xls">
|
||||
<NButton type="primary" color="#1a202c">
|
||||
<template #icon>
|
||||
<icon-ic-baseline-upload class="text-icon" />
|
||||
</template>
|
||||
导入配置
|
||||
</NButton>
|
||||
</NUpload>
|
||||
<NButton secondary type="success" @click="quickGenerate('order')">
|
||||
<template #icon>
|
||||
<icon-ic-baseline-settings-backup-restore class="text-icon" />
|
||||
</template>
|
||||
快速顺序生成
|
||||
</NButton>
|
||||
<NButton type="info" @click="quickGenerate('random')">
|
||||
<template #icon>
|
||||
<icon-ic-baseline-settings-backup-restore class="text-icon" />
|
||||
</template>
|
||||
快速随机生成
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 状态提示栏 -->
|
||||
@ -85,7 +73,7 @@ defineExpose({ validate })
|
||||
<!-- 硬件状态卡片 -->
|
||||
<NGrid :x-gap="24" :y-gap="24" cols="1 m:2 l:3" responsive="screen">
|
||||
<NGridItem v-for="(group, idx) in hardwareGroups" :key="idx">
|
||||
<div class="border border-gray-100 rounded-2xl bg-[#F8FAFC] p-6">
|
||||
<div class="border border-gray-100 rounded-2xl bg-[#F8FAFC] p-4">
|
||||
<div class="mb-4 text-gray-800 font-bold">
|
||||
硬件绑定: 第 {{ idx + 1 }} 分组
|
||||
</div>
|
||||
@ -102,7 +90,8 @@ defineExpose({ validate })
|
||||
/>
|
||||
</div>
|
||||
<!-- 扫描图标 -->
|
||||
<div class="i-carbon-qr-code text-gray-300" />
|
||||
<!-- <div class="i-carbon-qr-code text-gray-300" /> -->
|
||||
<icon-ic-baseline-edit class="text-xl text-blue-500" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user