完善前台

This commit is contained in:
LiuQAQQWQ 2025-12-02 11:21:42 +08:00
parent 29849c7a24
commit 43ccbf165c
2 changed files with 119 additions and 6 deletions

71
pc/api/enrollment.ts Normal file
View File

@ -0,0 +1,71 @@
/**
* @description
* @return { Promise }
*/
export function getStudentBaseInfo() {
// 模拟后端数据
return new Promise((resolve) => {
setTimeout(() => {
resolve({
data: {
name: '张三',
gender: 'male',
idCard: '110101201001011234',
phone: '13800138000',
address: '北京市海淀区XX街道XX小区',
emergencyContact: '李四',
emergencyPhone: '13900139000'
}
})
}, 500) // 模拟网络延迟
})
// 真实接口(后端恢复后启用)
// return $request.get({ url: '/enrollment/studentInfo', params })
}
/**
* @description "保存信息"
* @param {Object} params -
* @return { Promise }
*/
export function updateStudentBaseInfo(params: any) {
// 模拟后端数据
return new Promise((resolve) => {
setTimeout(() => {
resolve({
data: {
success: true,
message: '信息保存成功'
}
})
}, 500)
})
// 真实接口(后端恢复后启用)
// return $request.post({ url: '/enrollment/studentInfo', params })
}
/**
* @description
* @return { Promise }
*/
export function getEnrollmentProcessStatus() {
// 模拟后端数据
return new Promise((resolve) => {
setTimeout(() => {
resolve({
data: {
label: '审核完毕',
type: 'success',
steps: [
{ completed: true, time: '2025-05-01 10:30:00' },
{ completed: true, time: '2025-05-01 10:30:00' },
{ completed: false, time: '' },
{ completed: false, time: '' }
]
}
})
}, 500)
})
// 真实接口(后端恢复后启用)
// return $request.get({ url: '/enrollment/processStatus' })
}

View File

@ -136,9 +136,8 @@
</div>
</div>
<div class="mt-6">
<el-button type="primary" block>保存信息</el-button>
<el-button type="default" block class="mt-2"
>提交审核</el-button
<el-button type="primary" block @click="handleSave"
>保存信息</el-button
>
</div>
</el-card>
@ -147,6 +146,11 @@
<script lang="ts" setup>
import { reactive } from 'vue'
import { ElButton } from 'element-plus'
import {
getStudentBaseInfo,
updateStudentBaseInfo,
getEnrollmentProcessStatus
} from '@/api/enrollment'
definePageMeta({
module: 'personal',
@ -179,15 +183,53 @@ const statusConfig = reactive<{
progress: number
steps: { completed: boolean; time: string }[]
}>({
label: '报名',
label: '报名',
type: 'info',
progress: 25,
get progress() {
const completedCount = this.steps.filter(
(step: { completed: any }) => step.completed
).length
return (completedCount / this.steps.length) * 100
},
steps: [
{ completed: true, time: '2024-03-15' },
{ completed: false, time: '' },
{ completed: false, time: '' },
{ completed: false, time: '' },
{ completed: false, time: '' }
]
})
const handleSave = async () => {
try {
// APIstudentData.baseInfo
const res = await updateStudentBaseInfo(studentData.baseInfo)
//
if (res.data.success) {
ElMessage.success(res.data.message || '信息保存成功')
} else {
ElMessage.warning(res.data.message || '保存失败,请检查数据')
}
} catch (error) {
//
ElMessage.error('保存失败,请稍后重试')
console.error('更新信息失败:', error)
}
}
onMounted(async () => {
try {
// 1.
const studentInfoRes = await getStudentBaseInfo()
Object.assign(studentData.baseInfo, studentInfoRes.data)
// 2.
const statusRes = await getEnrollmentProcessStatus()
// statusConfig
Object.assign(statusConfig, statusRes.data)
} catch (error) {
//
ElMessage.error('数据加载失败,请稍后重试')
console.error('获取初始数据失败:', error)
}
})
</script>
<style lang="scss" scoped></style>