模拟报志愿列表对接接口完成
This commit is contained in:
parent
c2ef1cad84
commit
7f27542057
|
|
@ -12,3 +12,14 @@
|
||||||
- Updated `src/pages/simulate.vue` to fetch and display data in Panel A using the new API.
|
- Updated `src/pages/simulate.vue` to fetch and display data in Panel A using the new API.
|
||||||
- Implemented infinite scroll and filtering by probability.
|
- Implemented infinite scroll and filtering by probability.
|
||||||
- Mapped API response fields to the UI table.
|
- 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.
|
||||||
|
|
|
||||||
|
|
@ -86,13 +86,13 @@ const volunteerTabs = [
|
||||||
{ key: '专科', label: '专科', count: 2, max: 64 },
|
{ key: '专科', label: '专科', count: 2, max: 64 },
|
||||||
]
|
]
|
||||||
|
|
||||||
const currentTab = ref<TabKey>('all')
|
const currentTab = ref<TabKey>('stable')
|
||||||
const tabs = [
|
const tabs = ref([
|
||||||
{ key: 'all', label: '全部', count: 157 },
|
|
||||||
{ key: 'hard', label: '难录取', count: 145 },
|
|
||||||
{ key: 'risky', label: '可冲击', count: 11 },
|
|
||||||
{ key: 'safe', label: '可保底', count: 1 },
|
{ 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'])
|
const oldYears = ref(['2025','2024','2023'])
|
||||||
|
|
||||||
// Panel A 列表数据
|
// Panel A 列表数据
|
||||||
|
|
@ -153,6 +153,7 @@ async function loadMore(reset = false) {
|
||||||
let probability: string | undefined
|
let probability: string | undefined
|
||||||
if (currentTab.value === 'hard') probability = '难录取'
|
if (currentTab.value === 'hard') probability = '难录取'
|
||||||
if (currentTab.value === 'risky') probability = '可冲击'
|
if (currentTab.value === 'risky') probability = '可冲击'
|
||||||
|
if (currentTab.value === 'stable') probability = '较稳妥'
|
||||||
if (currentTab.value === 'safe') probability = '可保底'
|
if (currentTab.value === 'safe') probability = '可保底'
|
||||||
|
|
||||||
const res = await getUserMajorList({
|
const res = await getUserMajorList({
|
||||||
|
|
@ -160,12 +161,21 @@ async function loadMore(reset = false) {
|
||||||
size: size.value,
|
size: size.value,
|
||||||
probability
|
probability
|
||||||
})
|
})
|
||||||
|
console.warn(res)
|
||||||
if (res && res.list) {
|
if (res && res.list && res.list.items) {
|
||||||
schools.value.push(...res.list)
|
schools.value.push(...res.list.items)
|
||||||
total.value = res.total
|
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
|
isFinished.value = true
|
||||||
} else {
|
} else {
|
||||||
page.value++
|
page.value++
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,10 @@ export interface MajorItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserMajorListResponse {
|
export interface UserMajorListResponse {
|
||||||
list: MajorItem[]
|
list: {
|
||||||
|
items: MajorItem[]
|
||||||
|
probCount: Record<string, number>
|
||||||
|
}
|
||||||
total: number
|
total: number
|
||||||
page: number
|
page: number
|
||||||
size: number
|
size: number
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Task Detail
|
# 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 Reason**: User requested to encapsulate the "User Recommended Major List API" and integrate it into the `simulate.vue` page (Panel A).
|
||||||
- **Execution Process**:
|
- **Execution Process**:
|
||||||
|
|
@ -14,3 +14,15 @@
|
||||||
- Updated the template to bind correct fields from `MajorItem` (e.g., `schoolName`, `enrollProbability`, `historyMajorEnrollMap`).
|
- 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`).
|
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.
|
- **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.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue