专业批次筛选

This commit is contained in:
zhouwentao 2026-01-24 16:44:35 +08:00
parent 5d9bc3ba5a
commit da16f9fdca
2 changed files with 91 additions and 17 deletions

View File

@ -4,7 +4,7 @@ import { onMounted, ref, watch } from 'vue'
import { getUserMajorList, type MajorItem } from '~/service/api/major'
// --- ---
type TabKey = 'all' | 'hard' | 'risky' | 'safe' | 'stable' | '本科' | '专科'
type TabKey = 'all' | 'hard' | 'risky' | 'safe' | 'stable' | '本科' | '专科' | '985/211/双一流' | '公办本科' | '民办本科'
type PanelType = 'market' | 'my-volunteers'
interface VolunteerTab {
@ -90,14 +90,40 @@ const myVolunteers = ref<VolunteerSchool[]>([
{ id: '2025121427', name: '志愿2025121427', code: "1001", tags: ['手动'], probability: "80.5%", statusLabel: '保', calcScore: 450, diffScore: 250, majorName: '计算机科学与技术', requirements: '物化生', tuition: '', majorCode:'2003', planCount: 10, history: { '2025': {count: 10,minScore: 1,diff: 4,method: 'q'} } }
])
// Tab
const volunteerCurrentTab = ref<TabKey>('本科')
const volunteerTabs = [
{ key: '本科', label: '本科', count: 1, max: 64 },
{ key: '专科', label: '专科', count: 2, max: 64 },
] as VolunteerTab[]
const currentTab = ref<TabKey>('stable')
const tabs = [
//============= Panel A
// Tab
const currentBatchTab = ref<TabKey>('本科')
const batchTabs = [
{ key: '本科提前', label: '本科提前批', count: 0 },
{ key: '本科', label: '本科批', count: 0 },
{ key: '高职高专', label: '高职批', count: 0 },
] as VolunteerTab[]
// Tab
const currentBatch2Tab = ref<TabKey>('公办本科')
const batch2Tabs = [
{ key: '双一流', label: '985/211/双一流', count: 0 },
{ key: '公办本科', label: '公办本科', count: 0 },
{ key: '民办本科', label: '民办本科', count: 0 },
] as VolunteerTab[]
// Tab
const currentProbTab = ref<TabKey>('all')
const probTabs = [
{ key: 'all', label: '全部', count: 0 },
{ key: 'safe', label: '可保底', count: 1 },
{ key: 'stable', label: '较稳妥', count: 11 },
{ key: 'risky', label: '可冲击', count: 11 },
@ -106,7 +132,6 @@ const tabs = [
const oldYears = ref(['2025','2024','2023'])
// Panel A
const schools = ref<MajorItem[]>([])
const page = ref(1)
const size = ref(10)
@ -126,6 +151,8 @@ const selectedMajorCodes = ref<string[]>([]) // 存储已选的专业Code
const showSaveConfirm = ref(false) //
const isSaving = ref(false) // Loading
//============= Panel A
// --- ---
function getProbabilityLabel(prob: number): string {
if (prob >= 93) return '保'
@ -162,15 +189,17 @@ async function loadMore(reset = false) {
try {
// Tab API
let probability: string | undefined
if (currentTab.value === 'hard') probability = '难录取'
if (currentTab.value === 'risky') probability = '可冲击'
if (currentTab.value === 'stable') probability = '较稳妥'
if (currentTab.value === 'safe') probability = '可保底'
if (currentProbTab.value === 'hard') probability = '难录取'
if (currentProbTab.value === 'risky') probability = '可冲击'
if (currentProbTab.value === 'stable') probability = '较稳妥'
if (currentProbTab.value === 'safe') probability = '可保底'
const res = await getUserMajorList({
page: page.value,
size: size.value,
probability
probability,
batch: currentBatchTab.value,
batch2: currentBatch2Tab.value,
})
console.warn(res)
if (res && res.list && res.list.items) {
@ -179,8 +208,10 @@ async function loadMore(reset = false) {
// Tabs
if (res.list.probCount) {
tabs.forEach(tab => {
if (tab.key && res.list.probCount[tab.key] !== undefined) {
probTabs.forEach(tab => {
if (tab.key && tab.key == 'all'){
tab.count = total.value
}else if (tab.key && res.list.probCount[tab.key] !== undefined) {
tab.count = res.list.probCount[tab.key]
}
})
@ -203,10 +234,20 @@ async function loadMore(reset = false) {
}
// Tab
watch(currentTab, () => {
watch(currentBatchTab, () => {
loadMore(true)
})
watch(currentBatch2Tab, () => {
loadMore(true)
})
watch(currentProbTab, () => {
loadMore(true)
})
function handleScroll() {
if (!scrollContainer.value)
return
@ -525,7 +566,7 @@ function deletePlan(planId: string) {
========================================================== -->
<div v-show="activePanel === 'market'" class="h-full flex flex-col">
<!-- 顶部筛选栏 (保持不变) -->
<div class="mb-8 mt-8 rounded-lg bg-white p-6 shadow">
<div class="mt-8 rounded-t-lg bg-white p-6 border-b border-slate-200">
<div class="grid grid-cols-1 select-none gap-6 lg:grid-cols-6">
<!-- Top Toolbar -->
<div class="lg:col-span-4">
@ -533,19 +574,51 @@ function deletePlan(planId: string) {
</div>
</div>
</div>
<div class="flex flex-shrink-0 space-x-2 justify-between mb-8">
<div class="flex flex-shrink-0 space-x-2">
<button
v-for="tab in batchTabs" :key="tab.key"
class="border-x border-t border-transparent rounded-b-md px-6 py-2 text-sm font-medium transition-colors duration-200"
:class="[
currentBatchTab === tab.key
? 'bg-blue-500 text-white border-blue-500'
: 'bg-white text-slate-600 hover:text-blue-500 border-slate-200',
]" @click="currentBatchTab = tab.key"
>
{{ tab.label }}
</button>
</div>
<div class="flex flex-shrink-0 space-x-2" v-show="currentBatchTab == '本科'">
<button
v-for="tab in batch2Tabs" :key="tab.key"
class="border-x border-t border-transparent rounded-b-md px-6 py-2 text-sm font-medium transition-colors duration-200"
:class="[
currentBatch2Tab === tab.key
? 'bg-blue-500 text-white border-blue-500'
: 'bg-white text-slate-600 hover:text-blue-500 border-slate-200',
]" @click="currentBatch2Tab = tab.key"
>
{{ tab.label }}
</button>
</div>
</div>
<div class="flex flex-shrink-0 space-x-2">
<button
v-for="tab in tabs" :key="tab.key"
v-for="tab in probTabs" :key="tab.key"
class="border-x border-t border-transparent rounded-t-md px-6 py-2 text-sm font-medium transition-colors duration-200"
:class="[
currentTab === tab.key
currentProbTab === tab.key
? 'bg-blue-500 text-white border-blue-500'
: 'bg-white text-slate-600 hover:text-blue-500 border-slate-200',
]" @click="currentTab = tab.key"
]" @click="currentProbTab = tab.key"
>
{{ tab.label }} <span class="ml-1 opacity-90">{{ tab.count }}</span>
</button>
</div>
<!-- 表格容器限制高度 + 滚动监听 -->
<!-- 关键点h-[calc(100vh-150px)] 用于限制高度overflow-auto 用于滚动 -->

View File

@ -4,6 +4,7 @@ export interface UserMajorListRequest {
page?: number
size?: number
batch?: string
batch2?: string
probability?: string
}