Ferat
This commit is contained in:
@@ -53,9 +53,9 @@
|
||||
<el-table-column prop="headImg" label="头像" width="120" align="center">
|
||||
<template #default="scope">
|
||||
<el-image
|
||||
v-if="scope.row.headImg"
|
||||
:src="scope.row.headImg"
|
||||
:preview-src-list="[scope.row.headImg]"
|
||||
v-if="scope.row.headImg || scope.row.imageUrl || scope.row.qrCode"
|
||||
:src="scope.row.headImg || scope.row.imageUrl || scope.row.qrCode"
|
||||
:preview-src-list="[scope.row.headImg || scope.row.imageUrl || scope.row.qrCode]"
|
||||
fit="cover"
|
||||
style="width: 80px; height: 100px; cursor: pointer;"
|
||||
lazy>
|
||||
@@ -96,10 +96,44 @@ const searchForm = reactive({
|
||||
classCode: ''
|
||||
})
|
||||
|
||||
// 配置 useTable
|
||||
// 配置 useTable - 接口返回的数据结构是 { classes: [], students: [] }
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: searchForm,
|
||||
pageList: fetchList,
|
||||
pageList: async (queryParams: any) => {
|
||||
const res = await fetchList(queryParams)
|
||||
// 接口返回的数据结构是 { classes: [], students: [] }
|
||||
// 需要将 students 数组转换为表格数据,并关联班级信息
|
||||
if (res.data && res.data.students) {
|
||||
const students = res.data.students || []
|
||||
const classes = res.data.classes || []
|
||||
const classMap = new Map()
|
||||
classes.forEach((cls: any) => {
|
||||
classMap.set(cls.classCode, cls)
|
||||
})
|
||||
|
||||
// 将学生数据与班级信息合并
|
||||
const dataList = students.map((stu: any) => {
|
||||
const classInfo = classMap.get(stu.classCode)
|
||||
return {
|
||||
...stu,
|
||||
className: classInfo ? classInfo.classNo : stu.className || '',
|
||||
classNo: classInfo ? classInfo.classNo : ''
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
...res,
|
||||
data: {
|
||||
records: dataList,
|
||||
total: dataList.length,
|
||||
current: 1,
|
||||
size: dataList.length,
|
||||
pages: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
},
|
||||
props: {
|
||||
item: 'records',
|
||||
totalCount: 'total'
|
||||
|
||||
Reference in New Issue
Block a user