解决所有bug 优化table内容

This commit is contained in:
2026-01-21 18:43:39 +08:00
parent 9984200814
commit 7f0280ec8a
80 changed files with 5202 additions and 744 deletions

View File

@@ -19,6 +19,21 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="班级" prop="classCode">
<el-select
v-model="searchForm.classCode"
placeholder="请选择班级"
clearable
filterable
style="width: 200px">
<el-option
v-for="item in classList"
:key="item.classCode"
:label="item.classNo"
:value="item.classCode">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="月份" prop="month">
<el-date-picker
v-model="searchForm.month"
@@ -56,10 +71,41 @@
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@sort-change="sortChangeHandle">
<el-table-column type="index" label="序号" width="60" align="center" />
<el-table-column prop="totalScore" label="总分" show-overflow-tooltip align="center" />
<el-table-column prop="rank" label="排名" show-overflow-tooltip align="center" />
<el-table-column prop="classNo" label="班级" show-overflow-tooltip />
<el-table-column type="index" label="序号" width="60" align="center">
<template #header>
<el-icon><List /></el-icon>
</template>
</el-table-column>
<el-table-column prop="totalScore" label="总分" show-overflow-tooltip align="center">
<template #header>
<el-icon><DataAnalysis /></el-icon>
<span style="margin-left: 4px">总分</span>
</template>
<template #default="scope">
<el-tag v-if="scope.row.totalScore !== undefined && scope.row.totalScore !== null" size="small" type="success" effect="plain">
{{ scope.row.totalScore }}
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="rank" label="排名" show-overflow-tooltip align="center">
<template #header>
<el-icon><Trophy /></el-icon>
<span style="margin-left: 4px">排名</span>
</template>
<template #default="scope">
<el-tag v-if="scope.row.rank" size="small" :type="scope.row.rank <= 3 ? 'warning' : 'info'" effect="plain">
{{ scope.row.rank }}
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="classNo" label="班级" show-overflow-tooltip>
<template #header>
<el-icon><Grid /></el-icon>
<span style="margin-left: 4px">班级</span>
</template>
</el-table-column>
<!-- 动态日期列 -->
<el-table-column
v-for="day in dayColumns"
@@ -68,8 +114,17 @@
:label="`${day}日`"
show-overflow-tooltip
align="center"
width="80" />
width="80">
<template #header>
<el-icon><Calendar /></el-icon>
<span style="margin-left: 4px">{{ day }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="150" align="center" fixed="right">
<template #header>
<el-icon><Setting /></el-icon>
<span style="margin-left: 4px">操作</span>
</template>
<template #default="scope">
<el-button
icon="Plus"
@@ -152,6 +207,8 @@ import { BasicTableProps, useTable } from "/@/hooks/table";
import { fetchList } from "/@/api/stuwork/classhygienedailyanalysis";
import { useMessage } from "/@/hooks/message";
import { getBuildingList } from '/@/api/stuwork/dormbuilding'
import { getClassListByRole } from '/@/api/basic/basicclass'
import { List, DataAnalysis, Trophy, Grid, Calendar, Setting } from '@element-plus/icons-vue'
// 定义变量内容
const searchFormRef = ref()
@@ -159,6 +216,7 @@ const scoreFormRef = ref()
// 搜索变量
const showSearch = ref(true)
const buildingList = ref<any[]>([])
const classList = ref<any[]>([])
const scoreDialogVisible = ref(false)
const scoreDialogTitle = ref('加分')
const isAddScore = ref(true) // true: 加分, false: 减分
@@ -175,6 +233,7 @@ const scoreForm = reactive({
// 搜索表单
const searchForm = reactive({
buildingNo: '',
classCode: '',
month: ''
})
@@ -202,6 +261,9 @@ const state: BasicTableProps = reactive<BasicTableProps>({
if (searchForm.month) {
params.month = Array.isArray(searchForm.month) ? searchForm.month : [searchForm.month]
}
if (searchForm.classCode) {
params.classCode = searchForm.classCode
}
const res = await fetchList(params)
@@ -289,6 +351,7 @@ const handleSearch = () => {
const handleReset = () => {
searchFormRef.value?.resetFields()
searchForm.buildingNo = ''
searchForm.classCode = ''
searchForm.month = ''
getDataList()
}
@@ -364,8 +427,30 @@ const getBuildingListData = async () => {
}
}
// 获取班级列表
const getClassListData = async () => {
try {
const res = await getClassListByRole({})
if (res.data) {
if (Array.isArray(res.data.records)) {
classList.value = res.data.records
} else if (Array.isArray(res.data)) {
classList.value = res.data
} else {
classList.value = []
}
} else {
classList.value = []
}
} catch (err) {
console.error('获取班级列表失败', err)
classList.value = []
}
}
// 初始化
onMounted(() => {
getBuildingListData()
getClassListData()
})
</script>