add fiel
This commit is contained in:
@@ -283,7 +283,6 @@ const getTermList = async () => {
|
||||
termList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取批次列表失败', err)
|
||||
termList.value = []
|
||||
}
|
||||
}
|
||||
@@ -298,7 +297,6 @@ const getClassListData = async () => {
|
||||
classList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
@@ -316,7 +314,6 @@ const getGenderDict = async () => {
|
||||
genderList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取性别字典失败', err)
|
||||
genderList.value = []
|
||||
}
|
||||
}
|
||||
@@ -334,7 +331,6 @@ const getEducationDict = async () => {
|
||||
educationList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取生源字典失败', err)
|
||||
educationList.value = []
|
||||
}
|
||||
}
|
||||
@@ -352,7 +348,6 @@ const getMajorLevelDict = async () => {
|
||||
majorLevelList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取层次字典失败', err)
|
||||
majorLevelList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,6 @@ const getTermList = async () => {
|
||||
termList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取批次列表失败', err)
|
||||
termList.value = []
|
||||
}
|
||||
}
|
||||
@@ -273,7 +272,6 @@ const getDeptListData = async () => {
|
||||
deptList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学院列表失败', err)
|
||||
deptList.value = []
|
||||
}
|
||||
}
|
||||
@@ -288,7 +286,6 @@ const getClassListData = async () => {
|
||||
classList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +114,26 @@
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
class="ml10 mr20"
|
||||
class="ml10"
|
||||
style="float: right;"
|
||||
@queryTable="getDataList">
|
||||
<TableColumnControl
|
||||
ref="columnControlRef"
|
||||
:columns="tableColumns"
|
||||
v-model="visibleColumns"
|
||||
trigger-type="default"
|
||||
trigger-circle
|
||||
@change="handleColumnChange"
|
||||
@order-change="handleColumnOrderChange"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-tooltip class="item" effect="dark" content="列设置" placement="top">
|
||||
<el-button circle style="margin-left: 0;">
|
||||
<el-icon><Menu /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</TableColumnControl>
|
||||
</right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
@@ -133,124 +150,61 @@
|
||||
<el-icon><List /></el-icon>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="deptName" label="学院" show-overflow-tooltip align="center" min-width="150">
|
||||
<template #header>
|
||||
<el-icon><OfficeBuilding /></el-icon>
|
||||
<span style="margin-left: 4px">学院</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="majorName" label="专业" show-overflow-tooltip align="center" min-width="150">
|
||||
<template #header>
|
||||
<el-icon><Reading /></el-icon>
|
||||
<span style="margin-left: 4px">专业</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="teacherName" label="班主任" show-overflow-tooltip align="center" width="100">
|
||||
<template #header>
|
||||
<el-icon><UserFilled /></el-icon>
|
||||
<span style="margin-left: 4px">班主任</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="grade" label="入学年份" show-overflow-tooltip align="center" width="100">
|
||||
<template #header>
|
||||
<el-icon><Calendar /></el-icon>
|
||||
<span style="margin-left: 4px">入学年份</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="gradeCurr" label="年级" show-overflow-tooltip align="center" width="80">
|
||||
<template #header>
|
||||
<el-icon><Sort /></el-icon>
|
||||
<span style="margin-left: 4px">年级</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.gradeCurr !== undefined && scope.row.gradeCurr !== null" size="small" type="primary" effect="plain">
|
||||
{{ scope.row.gradeCurr }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="classNo" label="班级" show-overflow-tooltip align="center" width="120">
|
||||
<template #header>
|
||||
<el-icon><Grid /></el-icon>
|
||||
<span style="margin-left: 4px">班级</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="stuNo" label="学号" show-overflow-tooltip align="center" width="120">
|
||||
<template #header>
|
||||
<el-icon><CreditCard /></el-icon>
|
||||
<span style="margin-left: 4px">学号</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="realName" label="姓名" show-overflow-tooltip align="center" width="100">
|
||||
<template #header>
|
||||
<el-icon><Avatar /></el-icon>
|
||||
<span style="margin-left: 4px">姓名</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="gender" label="性别" show-overflow-tooltip align="center" width="80">
|
||||
<template #header>
|
||||
<el-icon><User /></el-icon>
|
||||
<span style="margin-left: 4px">性别</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<GenderTag :sex="scope.row.gender" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="education" label="生源" show-overflow-tooltip align="center" width="100">
|
||||
<template #header>
|
||||
<el-icon><School /></el-icon>
|
||||
<span style="margin-left: 4px">生源</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.education" size="small" type="info" effect="plain">
|
||||
{{ formatEducation(scope.row.education) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="majorLevel" label="层次" show-overflow-tooltip align="center" width="100">
|
||||
<template #header>
|
||||
<el-icon><Trophy /></el-icon>
|
||||
<span style="margin-left: 4px">层次</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.majorLevel" size="small" type="warning" effect="plain">
|
||||
{{ formatMajorLevel(scope.row.majorLevel) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="phone" label="联系电话" show-overflow-tooltip align="center" width="120">
|
||||
<template #header>
|
||||
<el-icon><Phone /></el-icon>
|
||||
<span style="margin-left: 4px">联系电话</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="money" label="金额" show-overflow-tooltip align="center" width="100">
|
||||
<template #header>
|
||||
<el-icon><Money /></el-icon>
|
||||
<span style="margin-left: 4px">金额</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.money !== undefined && scope.row.money !== null" size="small" type="success" effect="plain">
|
||||
¥{{ scope.row.money }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="checkStatus" label="审核状态" show-overflow-tooltip align="center" width="100">
|
||||
<template #header>
|
||||
<el-icon><CircleCheck /></el-icon>
|
||||
<span style="margin-left: 4px">审核状态</span>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<StatusTag
|
||||
:value="scope.row.checkStatus"
|
||||
:options="checkStatusList"
|
||||
:type-map="{ '0': { type: 'warning', effect: 'light' }, '1': { type: 'success', effect: 'light' } }"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template v-for="col in sortedTableColumns" :key="col.prop || col.label">
|
||||
<el-table-column
|
||||
v-if="checkColumnVisible(col.prop || '') && col.prop !== '操作'"
|
||||
:prop="col.prop"
|
||||
:label="col.label"
|
||||
show-overflow-tooltip
|
||||
align="center"
|
||||
:min-width="col.minWidth"
|
||||
:width="col.width">
|
||||
<template #header>
|
||||
<el-icon><component :is="columnConfigMap[col.prop]?.icon || Calendar" /></el-icon>
|
||||
<span style="margin-left: 4px">{{ col.label }}</span>
|
||||
</template>
|
||||
<!-- 年级列特殊模板 -->
|
||||
<template v-if="col.prop === 'gradeCurr'" #default="scope">
|
||||
<el-tag v-if="scope.row.gradeCurr !== undefined && scope.row.gradeCurr !== null" size="small" type="primary" effect="plain">
|
||||
{{ scope.row.gradeCurr }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 性别列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'gender'" #default="scope">
|
||||
<GenderTag :sex="scope.row.gender" />
|
||||
</template>
|
||||
<!-- 生源列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'education'" #default="scope">
|
||||
<el-tag v-if="scope.row.education" size="small" type="info" effect="plain">
|
||||
{{ formatEducation(scope.row.education) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 层次列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'majorLevel'" #default="scope">
|
||||
<el-tag v-if="scope.row.majorLevel" size="small" type="warning" effect="plain">
|
||||
{{ formatMajorLevel(scope.row.majorLevel) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 金额列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'money'" #default="scope">
|
||||
<el-tag v-if="scope.row.money !== undefined && scope.row.money !== null" size="small" type="success" effect="plain">
|
||||
¥{{ scope.row.money }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<!-- 审核状态列特殊模板 -->
|
||||
<template v-else-if="col.prop === 'checkStatus'" #default="scope">
|
||||
<StatusTag
|
||||
:value="scope.row.checkStatus"
|
||||
:options="checkStatusList"
|
||||
:type-map="{ '0': { type: 'warning', effect: 'light' }, '1': { type: 'success', effect: 'light' } }"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template #header>
|
||||
<el-icon><Setting /></el-icon>
|
||||
@@ -288,7 +242,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="TuitionFreeStu">
|
||||
import { reactive, ref, onMounted, defineAsyncComponent } from 'vue'
|
||||
import { reactive, ref, onMounted, defineAsyncComponent, computed, nextTick } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, exportExcel, delObj, getDetail } from "/@/api/stuwork/tuitionfreestu";
|
||||
import { getDeptList } from "/@/api/basic/basicclass";
|
||||
@@ -298,10 +253,11 @@ import { queryAllSchoolYear } from "/@/api/basic/basicyear";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import request from '/@/utils/request'
|
||||
import axios from 'axios'
|
||||
import TableColumnControl from '/@/components/TableColumnControl/index.vue'
|
||||
import {
|
||||
User, School, Trophy, Phone, Money, CircleCheck, List,
|
||||
OfficeBuilding, Reading, UserFilled, Calendar, Sort, Grid,
|
||||
CreditCard, Avatar, Setting
|
||||
CreditCard, Avatar, Setting, Menu
|
||||
} from '@element-plus/icons-vue'
|
||||
|
||||
// 引入组件
|
||||
@@ -309,7 +265,9 @@ const GenderTag = defineAsyncComponent(() => import('/@/components/GenderTag/ind
|
||||
const StatusTag = defineAsyncComponent(() => import('/@/components/StatusTag/index.vue'))
|
||||
|
||||
// 定义变量内容
|
||||
const route = useRoute()
|
||||
const searchFormRef = ref()
|
||||
const columnControlRef = ref<any>()
|
||||
const formDialogRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const exportLoading = ref(false)
|
||||
@@ -325,6 +283,146 @@ const checkStatusList = ref<any[]>([
|
||||
{ label: '审核通过', value: '1' }
|
||||
])
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
{ prop: 'deptName', label: '学院', minWidth: 150 },
|
||||
{ prop: 'majorName', label: '专业', minWidth: 150 },
|
||||
{ prop: 'teacherName', label: '班主任', width: 100 },
|
||||
{ prop: 'grade', label: '入学年份', width: 100 },
|
||||
{ prop: 'gradeCurr', label: '年级', width: 80 },
|
||||
{ prop: 'classNo', label: '班级', width: 120 },
|
||||
{ prop: 'stuNo', label: '学号', width: 120 },
|
||||
{ prop: 'realName', label: '姓名', width: 100 },
|
||||
{ prop: 'gender', label: '性别', width: 80 },
|
||||
{ prop: 'education', label: '生源', width: 100 },
|
||||
{ prop: 'majorLevel', label: '层次', width: 100 },
|
||||
{ prop: 'phone', label: '联系电话', width: 120 },
|
||||
{ prop: 'money', label: '金额', width: 100 },
|
||||
{ prop: 'checkStatus', label: '审核状态', width: 100 }
|
||||
]
|
||||
|
||||
// 列配置映射(用于图标)
|
||||
const columnConfigMap: Record<string, { icon: any }> = {
|
||||
deptName: { icon: OfficeBuilding },
|
||||
majorName: { icon: Reading },
|
||||
teacherName: { icon: UserFilled },
|
||||
grade: { icon: Calendar },
|
||||
gradeCurr: { icon: Sort },
|
||||
classNo: { icon: Grid },
|
||||
stuNo: { icon: CreditCard },
|
||||
realName: { icon: Avatar },
|
||||
gender: { icon: User },
|
||||
education: { icon: School },
|
||||
majorLevel: { icon: Trophy },
|
||||
phone: { icon: Phone },
|
||||
money: { icon: Money },
|
||||
checkStatus: { icon: CircleCheck }
|
||||
}
|
||||
|
||||
// 当前显示的列
|
||||
const visibleColumns = ref<string[]>([])
|
||||
// 列排序顺序
|
||||
const columnOrder = ref<string[]>([])
|
||||
|
||||
// 立即从 localStorage 加载配置
|
||||
const loadSavedConfig = () => {
|
||||
const routePath = route.path.replace(/^\//, '').replace(/\//g, '-')
|
||||
const storageKey = `table-columns-${routePath}`
|
||||
const saved = localStorage.getItem(storageKey)
|
||||
if (saved) {
|
||||
try {
|
||||
const savedColumns = JSON.parse(saved)
|
||||
const validColumns = tableColumns.map(col => col.prop || col.label)
|
||||
const filteredSaved = savedColumns.filter((col: string) => validColumns.includes(col))
|
||||
visibleColumns.value = filteredSaved.length > 0 ? filteredSaved : validColumns
|
||||
} catch (e) {
|
||||
visibleColumns.value = tableColumns.map(col => col.prop || col.label)
|
||||
}
|
||||
} else {
|
||||
visibleColumns.value = tableColumns.map(col => col.prop || col.label)
|
||||
}
|
||||
|
||||
const orderKey = `${storageKey}-order`
|
||||
const savedOrder = localStorage.getItem(orderKey)
|
||||
if (savedOrder) {
|
||||
try {
|
||||
const parsedOrder = JSON.parse(savedOrder)
|
||||
const validColumns = tableColumns.map(col => col.prop || col.label)
|
||||
columnOrder.value = parsedOrder.filter((key: string) => validColumns.includes(key))
|
||||
validColumns.forEach(key => {
|
||||
if (!columnOrder.value.includes(key)) {
|
||||
columnOrder.value.push(key)
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
columnOrder.value = tableColumns.map(col => col.prop || col.label)
|
||||
}
|
||||
} else {
|
||||
columnOrder.value = tableColumns.map(col => col.prop || col.label)
|
||||
}
|
||||
}
|
||||
|
||||
loadSavedConfig()
|
||||
|
||||
// 排序后的表格列
|
||||
const sortedTableColumns = computed(() => {
|
||||
const columns = tableColumns.filter(col => {
|
||||
const key = col.prop || col.label
|
||||
return visibleColumns.value.includes(key)
|
||||
})
|
||||
|
||||
if (columnOrder.value.length > 0) {
|
||||
const orderedColumns: typeof tableColumns = []
|
||||
const unorderedColumns: typeof tableColumns = []
|
||||
|
||||
columnOrder.value.forEach(key => {
|
||||
const col = columns.find(c => (c.prop || c.label) === key)
|
||||
if (col) {
|
||||
orderedColumns.push(col)
|
||||
}
|
||||
})
|
||||
|
||||
columns.forEach(col => {
|
||||
const key = col.prop || col.label
|
||||
if (!columnOrder.value.includes(key)) {
|
||||
unorderedColumns.push(col)
|
||||
}
|
||||
})
|
||||
|
||||
return [...orderedColumns, ...unorderedColumns]
|
||||
}
|
||||
|
||||
return columns
|
||||
})
|
||||
|
||||
// 列显示控制函数
|
||||
const checkColumnVisible = (prop: string): boolean => {
|
||||
if (visibleColumns.value.length === 0) {
|
||||
return true
|
||||
}
|
||||
return visibleColumns.value.includes(prop)
|
||||
}
|
||||
|
||||
// 监听列变化
|
||||
const handleColumnChange = (columns: string[]) => {
|
||||
visibleColumns.value = columns
|
||||
const routePath = route.path.replace(/^\//, '').replace(/\//g, '-')
|
||||
const storageKey = `table-columns-${routePath}`
|
||||
const selectableColumns = columns.filter(col => {
|
||||
const column = tableColumns.find(c => (c.prop || c.label) === col)
|
||||
return column && !column.alwaysShow && !column.fixed
|
||||
})
|
||||
localStorage.setItem(storageKey, JSON.stringify(selectableColumns))
|
||||
}
|
||||
|
||||
// 监听列排序变化
|
||||
const handleColumnOrderChange = (order: string[]) => {
|
||||
columnOrder.value = order
|
||||
const routePath = route.path.replace(/^\//, '').replace(/\//g, '-')
|
||||
const storageKey = `table-columns-${routePath}-order`
|
||||
localStorage.setItem(storageKey, JSON.stringify(order))
|
||||
}
|
||||
|
||||
// 表格样式
|
||||
const tableStyle = {
|
||||
cellStyle: { padding: '8px 0' },
|
||||
@@ -468,7 +566,6 @@ const getTermList = async () => {
|
||||
termList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取批次列表失败', err)
|
||||
termList.value = []
|
||||
}
|
||||
}
|
||||
@@ -483,7 +580,6 @@ const getDeptListData = async () => {
|
||||
deptList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取学院列表失败', err)
|
||||
deptList.value = []
|
||||
}
|
||||
}
|
||||
@@ -498,7 +594,6 @@ const getClassListData = async () => {
|
||||
classList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
@@ -513,7 +608,6 @@ const getGradeList = async () => {
|
||||
gradeList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取入学年份列表失败', err)
|
||||
gradeList.value = []
|
||||
}
|
||||
}
|
||||
@@ -531,7 +625,6 @@ const getGenderDict = async () => {
|
||||
genderList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取性别字典失败', err)
|
||||
genderList.value = []
|
||||
}
|
||||
}
|
||||
@@ -549,7 +642,6 @@ const getEducationDict = async () => {
|
||||
educationList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取生源字典失败', err)
|
||||
educationList.value = []
|
||||
}
|
||||
}
|
||||
@@ -567,7 +659,6 @@ const getMajorLevelDict = async () => {
|
||||
majorLevelList.value = []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取层次字典失败', err)
|
||||
majorLevelList.value = []
|
||||
}
|
||||
}
|
||||
@@ -581,6 +672,11 @@ onMounted(() => {
|
||||
getGenderDict()
|
||||
getEducationDict()
|
||||
getMajorLevelDict()
|
||||
nextTick(() => {
|
||||
if (visibleColumns.value.length === 0) {
|
||||
loadSavedConfig()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user