模拟报志愿列表对接接口完成

This commit is contained in:
zhouwentao 2026-01-02 21:59:46 +08:00
parent c2ef1cad84
commit 7f27542057
4 changed files with 48 additions and 12 deletions

View File

@ -12,3 +12,14 @@
- Updated `src/pages/simulate.vue` to fetch and display data in Panel A using the new API.
- Implemented infinite scroll and filtering by probability.
- Mapped API response fields to the UI table.
### [Task 7] Update Major List API Response Structure
- **Time**: 2026-01-02
- **Goal**: Adapt to the updated API response structure and implement dynamic tab counting.
- **Scope**:
- `src/service/api/major.ts` (Update interface)
- `src/pages/simulate.vue` (Update logic)
- **Result**:
- Updated `UserMajorListResponse` to support `{ list: { items: [], probCount: {} } }` structure.
- Added 'stable' (较稳妥) tab to `simulate.vue`.
- Implemented dynamic update of tab counts using `probCount` from API response.

View File

@ -86,13 +86,13 @@ const volunteerTabs = [
{ key: '专科', label: '专科', count: 2, max: 64 },
]
const currentTab = ref<TabKey>('all')
const tabs = [
{ key: 'all', label: '全部', count: 157 },
{ key: 'hard', label: '难录取', count: 145 },
{ key: 'risky', label: '可冲击', count: 11 },
const currentTab = ref<TabKey>('stable')
const tabs = ref([
{ key: 'safe', label: '可保底', count: 1 },
]
{ key: 'stable', label: '较稳妥', count: 11 },
{ key: 'risky', label: '可冲击', count: 11 },
{ key: 'hard', label: '难录取', count: 145 },
])
const oldYears = ref(['2025','2024','2023'])
// Panel A
@ -153,6 +153,7 @@ async function loadMore(reset = false) {
let probability: string | undefined
if (currentTab.value === 'hard') probability = '难录取'
if (currentTab.value === 'risky') probability = '可冲击'
if (currentTab.value === 'stable') probability = '较稳妥'
if (currentTab.value === 'safe') probability = '可保底'
const res = await getUserMajorList({
@ -160,12 +161,21 @@ async function loadMore(reset = false) {
size: size.value,
probability
})
if (res && res.list) {
schools.value.push(...res.list)
console.warn(res)
if (res && res.list && res.list.items) {
schools.value.push(...res.list.items)
total.value = res.total
if (schools.value.length >= res.total || res.list.length < size.value) {
// Tabs
if (res.list.probCount) {
tabs.value.forEach(tab => {
if (tab.key && res.list.probCount[tab.key] !== undefined) {
tab.count = res.list.probCount[tab.key]
}
})
}
if (schools.value.length >= res.total || res.list.items.length < size.value) {
isFinished.value = true
} else {
page.value++

View File

@ -47,7 +47,10 @@ export interface MajorItem {
}
export interface UserMajorListResponse {
list: MajorItem[]
list: {
items: MajorItem[]
probCount: Record<string, number>
}
total: number
page: number
size: number

View File

@ -1,6 +1,6 @@
# Task Detail
## Session 2026-01-02
## Session 2026-01-02 (1)
- **Execution Reason**: User requested to encapsulate the "User Recommended Major List API" and integrate it into the `simulate.vue` page (Panel A).
- **Execution Process**:
@ -14,3 +14,15 @@
- Updated the template to bind correct fields from `MajorItem` (e.g., `schoolName`, `enrollProbability`, `historyMajorEnrollMap`).
4. Updated project documentation (`project_index.md`, `project_codebase.md`, `project_task.md`, `project_doing.md`).
- **Execution Result**: Successfully integrated the recommended major list API. Panel A in `simulate.vue` now displays real data structure (mapped from API) and supports loading more data.
## Session 2026-01-02 (2)
- **Execution Reason**: User updated the API response structure (`list` -> `list.items`) and requested dynamic tab counts from `list.probCount`.
- **Execution Process**:
1. Updated `src/service/api/major.ts`: Modified `UserMajorListResponse` to include nested `items` and `probCount`.
2. Updated `src/pages/simulate.vue`:
- Updated `tabs` definition to include 'stable' (较稳妥) and made it reactive.
- Updated `loadMore` function to access data from `res.list.items`.
- Added logic to update `tabs[].count` using `res.list.probCount`.
- Added 'stable' case to filter logic.
- **Execution Result**: The application now correctly handles the new API structure and dynamically updates the tab counts based on backend data.