修改打包报错问题
This commit is contained in:
413
src/views/stuwork/classroombase/index.vue
Normal file
413
src/views/stuwork/classroombase/index.vue
Normal file
@@ -0,0 +1,413 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<!-- 搜索表单 -->
|
||||
<el-row v-show="showSearch">
|
||||
<el-form :model="searchForm" ref="searchFormRef" :inline="true" @keyup.enter="handleSearch">
|
||||
<el-form-item label="学院" prop="deptName">
|
||||
<el-select
|
||||
v-model="searchForm.deptName"
|
||||
placeholder="请选择学院"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in deptList"
|
||||
:key="item.deptCode"
|
||||
:label="item.deptName"
|
||||
:value="item.deptName">
|
||||
</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="classStatus">
|
||||
<el-select
|
||||
v-model="searchForm.classStatus"
|
||||
placeholder="请选择班级状态"
|
||||
clearable
|
||||
style="width: 200px">
|
||||
<el-option
|
||||
v-for="item in classStatusList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="教室位置" prop="position">
|
||||
<el-input
|
||||
v-model="searchForm.position"
|
||||
placeholder="请输入教室位置"
|
||||
clearable
|
||||
style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" plain icon="Search" @click="handleSearch">查询</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button
|
||||
icon="Download"
|
||||
type="success"
|
||||
class="ml10"
|
||||
@click="handleExport">
|
||||
导出
|
||||
</el-button>
|
||||
<el-button
|
||||
icon="Refresh"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="handleSync">
|
||||
同步教室安排
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
class="ml10 mr20"
|
||||
style="float: right;"
|
||||
@queryTable="getDataList">
|
||||
</right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
|
||||
<!-- 表格 -->
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
v-loading="state.loading"
|
||||
border
|
||||
row-key="id"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="buildingNo" label="楼号" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="deptName" label="学院" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="classStatus" label="班级状态" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ formatClassStatus(scope.row.classStatus) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="position" label="教室位置" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="stuNum" label="人数" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="teacherRealName" label="班主任" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="platformType" label="讲台类型" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ formatDict(scope.row.platformType, platformTypeList) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="tyType" label="投影类型" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ formatDict(scope.row.tyType, tyTypeList) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="tvType" label="电视机" show-overflow-tooltip align="center">
|
||||
<template #default="scope">
|
||||
<span>{{ formatDict(scope.row.tvType, tvTypeList) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="chairCnt" label="方凳数量" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="tableCnt" label="课桌数量" show-overflow-tooltip align="center" />
|
||||
<el-table-column prop="password" label="锁密码" show-overflow-tooltip align="center" />
|
||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
icon="Setting"
|
||||
text
|
||||
type="primary"
|
||||
@click="handleArrange(scope.row)">
|
||||
教室安排
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-bind="state.pagination" />
|
||||
</div>
|
||||
|
||||
<!-- 教室安排表单弹窗 -->
|
||||
<arrange-dialog ref="arrangeDialogRef" @refresh="getDataList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="ClassroomBase">
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, exportData, syncClassroomArrangement } from "/@/api/stuwork/classroombase";
|
||||
import { getDeptListByLevelTwo } from "/@/api/basic/basicdept";
|
||||
import { queryAllClass } from "/@/api/basic/basicclass";
|
||||
import { getDicts } from "/@/api/admin/dict";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import ArrangeDialog from './arrange.vue'
|
||||
|
||||
// 定义变量内容
|
||||
const searchFormRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const deptList = ref<any[]>([])
|
||||
const classList = ref<any[]>([])
|
||||
const classStatusList = ref<any[]>([])
|
||||
const platformTypeList = ref<any[]>([])
|
||||
const tyTypeList = ref<any[]>([])
|
||||
const tvTypeList = ref<any[]>([])
|
||||
const arrangeDialogRef = ref()
|
||||
|
||||
// 班级状态列表
|
||||
const classStatusListData = [
|
||||
{ label: '在校', value: '0' },
|
||||
{ label: '顶岗', value: '1' },
|
||||
{ label: '更岗', value: '2' },
|
||||
{ label: '离校', value: '3' }
|
||||
]
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive({
|
||||
deptName: '',
|
||||
classCode: '',
|
||||
classStatus: '',
|
||||
position: ''
|
||||
})
|
||||
|
||||
// 配置 useTable
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: searchForm,
|
||||
pageList: async (queryParams: any) => {
|
||||
try {
|
||||
const response = await fetchList(queryParams)
|
||||
// 处理 ipage 数据结构
|
||||
if (response && response.data) {
|
||||
if (response.data.ipage) {
|
||||
// 如果 ipage 是包含 records 和 total 的对象
|
||||
if (Array.isArray(response.data.ipage)) {
|
||||
// ipage 是数组
|
||||
return {
|
||||
...response,
|
||||
data: {
|
||||
records: response.data.ipage || [],
|
||||
total: response.data.total || response.data.ipage.length || 0
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// ipage 是对象,包含 records 和 total
|
||||
return {
|
||||
...response,
|
||||
data: {
|
||||
records: response.data.ipage.records || [],
|
||||
total: response.data.ipage.total || 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果没有 ipage,尝试直接使用 data
|
||||
return {
|
||||
...response,
|
||||
data: {
|
||||
records: response.data.records || response.data || [],
|
||||
total: response.data.total || 0
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果 response 结构不对,返回空数据
|
||||
return {
|
||||
...response,
|
||||
data: {
|
||||
records: [],
|
||||
total: 0
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
// 确保即使出错也返回正确的数据结构
|
||||
console.error('获取数据失败', err)
|
||||
throw err
|
||||
}
|
||||
},
|
||||
props: {
|
||||
item: 'records',
|
||||
totalCount: 'total'
|
||||
},
|
||||
createdIsNeed: true
|
||||
})
|
||||
|
||||
// table hook
|
||||
const {
|
||||
getDataList,
|
||||
currentChangeHandle,
|
||||
sizeChangeHandle,
|
||||
tableStyle
|
||||
} = useTable(state)
|
||||
|
||||
// 格式化班级状态
|
||||
const formatClassStatus = (value: string) => {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '-'
|
||||
}
|
||||
const dictItem = classStatusList.value.find(item => item.value == value)
|
||||
return dictItem ? dictItem.label : value
|
||||
}
|
||||
|
||||
// 格式化字典
|
||||
const formatDict = (value: string, dictList: any[]) => {
|
||||
if (!value) return '-'
|
||||
const item = dictList.find((item: any) => item.value === value)
|
||||
return item ? item.label : value
|
||||
}
|
||||
|
||||
// 查询
|
||||
const handleSearch = () => {
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 重置
|
||||
const handleReset = () => {
|
||||
searchFormRef.value?.resetFields()
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
const res = await exportData(searchForm)
|
||||
// 创建下载链接
|
||||
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const elink = document.createElement('a')
|
||||
elink.style.display = 'none'
|
||||
elink.href = url
|
||||
elink.setAttribute('download', `教室安排及公物管理_${new Date().getTime()}.xlsx`)
|
||||
document.body.appendChild(elink)
|
||||
elink.click()
|
||||
URL.revokeObjectURL(elink.href)
|
||||
document.body.removeChild(elink)
|
||||
useMessage().success('导出成功')
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '导出失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 同步教室安排
|
||||
const handleSync = async () => {
|
||||
const { confirm } = useMessageBox()
|
||||
try {
|
||||
await confirm('确定要同步教室安排吗?')
|
||||
await syncClassroomArrangement()
|
||||
useMessage().success('同步成功')
|
||||
getDataList()
|
||||
} catch (err: any) {
|
||||
if (err !== 'cancel') {
|
||||
useMessage().error(err.msg || '同步失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 教室安排
|
||||
const handleArrange = (row: any) => {
|
||||
arrangeDialogRef.value?.openDialog(row)
|
||||
}
|
||||
|
||||
// 获取系部列表
|
||||
const getDeptListData = async () => {
|
||||
try {
|
||||
const res = await getDeptListByLevelTwo()
|
||||
if (res.data) {
|
||||
deptList.value = Array.isArray(res.data) ? res.data : []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取系部列表失败', err)
|
||||
deptList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取班级列表
|
||||
const getClassListData = async () => {
|
||||
try {
|
||||
const res = await queryAllClass()
|
||||
if (res.data) {
|
||||
classList.value = Array.isArray(res.data) ? res.data : []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取班级列表失败', err)
|
||||
classList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取讲台类型字典
|
||||
const getPlatformTypeDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('platform_type')
|
||||
if (res.data) {
|
||||
platformTypeList.value = Array.isArray(res.data) ? res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
})) : []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取讲台类型字典失败', err)
|
||||
platformTypeList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取投影类型字典
|
||||
const getTyTypeDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('ty_type')
|
||||
if (res.data) {
|
||||
tyTypeList.value = Array.isArray(res.data) ? res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
})) : []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取投影类型字典失败', err)
|
||||
tyTypeList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 获取电视机类型字典
|
||||
const getTvTypeDict = async () => {
|
||||
try {
|
||||
const res = await getDicts('tv_type')
|
||||
if (res.data) {
|
||||
tvTypeList.value = Array.isArray(res.data) ? res.data.map((item: any) => ({
|
||||
label: item.label || item.dictLabel || item.name,
|
||||
value: item.value || item.dictValue || item.code
|
||||
})) : []
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取电视机类型字典失败', err)
|
||||
tvTypeList.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
classStatusList.value = classStatusListData
|
||||
getDeptListData()
|
||||
getClassListData()
|
||||
getPlatformTypeDict()
|
||||
getTyTypeDict()
|
||||
getTvTypeDict()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user