forked from liweijie/education
298 lines
10 KiB
Vue
298 lines
10 KiB
Vue
<template>
|
||
<div class="app-container teaching-task-page">
|
||
<!-- ==================== 页面标题 ==================== -->
|
||
<div class="page-title">教学任务列表</div>
|
||
|
||
<!-- ==================== 1. 查询条件区域 ==================== -->
|
||
<el-card shadow="never" class="search-card">
|
||
<el-form :model="searchForm" label-width="80px" class="search-form">
|
||
<el-row :gutter="24">
|
||
<el-col :xs="24" :sm="12" :md="8">
|
||
<el-form-item label="任务名称">
|
||
<el-input
|
||
v-model="searchForm.rwmc"
|
||
placeholder="请输入任务名称"
|
||
clearable
|
||
@keyup.enter.native="handleQuery"
|
||
/>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :xs="24" :sm="12" :md="8">
|
||
<el-form-item label="年度">
|
||
<el-select
|
||
v-model="searchForm.nd"
|
||
placeholder="请选择年度"
|
||
clearable
|
||
filterable
|
||
style="width: 100%"
|
||
>
|
||
<el-option v-for="y in yearOptions" :key="y" :label="y" :value="y" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :xs="24" :sm="12" :md="8">
|
||
<el-form-item label="状态">
|
||
<el-select
|
||
v-model="searchForm.zt"
|
||
placeholder="请选择状态"
|
||
clearable
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="opt in statusOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
<div class="search-actions">
|
||
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
||
</div>
|
||
</el-form>
|
||
</el-card>
|
||
|
||
<!-- ==================== 2. 数据表格 ==================== -->
|
||
<el-card shadow="never" class="table-card">
|
||
<el-table v-loading="loading" :data="tableData" border stripe>
|
||
<template slot="empty">
|
||
<span>无数据!</span>
|
||
</template>
|
||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||
<el-table-column prop="bh" label="编号" width="100" align="center" show-overflow-tooltip />
|
||
<el-table-column prop="rwmc" label="任务名称" width="250" align="center" show-overflow-tooltip />
|
||
<el-table-column prop="nd" label="年度" width="150" align="center" />
|
||
<el-table-column label="状态" width="100" align="center">
|
||
<template slot-scope="{ row }">
|
||
<el-tag :type="row.zt === '已发布' ? 'success' : 'info'" size="small">
|
||
{{ row.zt || '-' }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="fbsj" label="发布时间" width="200" align="center" :formatter="fmtDateTime" />
|
||
<el-table-column prop="jssj" label="结束时间" width="200" align="center" :formatter="fmtDateTime" />
|
||
<el-table-column prop="cjsj" label="创建时间" width="200" align="center" :formatter="fmtDateTime" />
|
||
<el-table-column prop="jcxqscsj" label="教材需求生成时间" width="200" align="center" :formatter="fmtDateTime" />
|
||
<el-table-column label="操作" align="center" fixed="right">
|
||
<template slot-scope="{ row }">
|
||
<el-button type="text" size="small" @click="handleDetail(row)">详情</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
|
||
<el-pagination
|
||
:current-page="pageNum"
|
||
:page-size="pageSize"
|
||
:total="total"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
class="pagination"
|
||
@current-change="handlePageChange"
|
||
@size-change="handleSizeChange"
|
||
/>
|
||
</el-card>
|
||
|
||
<!-- ==================== 3. 详情对话框 ==================== -->
|
||
<el-dialog
|
||
:visible="detailVisible"
|
||
title="教学任务详情"
|
||
width="620px"
|
||
:close-on-click-modal="false"
|
||
@update:visible="val => detailVisible = val"
|
||
>
|
||
<el-descriptions v-if="detailData.bh" :column="2" border>
|
||
<el-descriptions-item label="编号">{{ detailData.bh || '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="任务名称">{{ detailData.rwmc || '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="年度">{{ fmtVal(detailData.nd) }}</el-descriptions-item>
|
||
<el-descriptions-item label="状态">{{ detailData.zt || '-' }}</el-descriptions-item>
|
||
<el-descriptions-item label="发布时间">{{ fmtVal(detailData.fbsj) }}</el-descriptions-item>
|
||
<el-descriptions-item label="结束时间">{{ fmtVal(detailData.jssj) }}</el-descriptions-item>
|
||
<el-descriptions-item label="创建时间">{{ fmtVal(detailData.cjsj) }}</el-descriptions-item>
|
||
<el-descriptions-item label="教材需求生成时间">{{ fmtVal(detailData.jcxqscsj) }}</el-descriptions-item>
|
||
</el-descriptions>
|
||
<div v-else v-loading="detailLoading" class="detail-empty">加载中...</div>
|
||
<div slot="footer">
|
||
<el-button @click="detailVisible = false">关闭</el-button>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
/**
|
||
* 教学任务列表(只读查询页)
|
||
* 对应菜单:teachBusiness/teachingTask(原「分组课列表」页,下载类功能后端无接口已移除)
|
||
* 仅提供 分页查询 list + 详情 get?bh=,不做增删改发(避免与教学任务计划管理页重复操作同一实体)
|
||
* 增删改发统一在 src/views/teachOffice/taskPlan/index.vue(教学任务计划管理)完成
|
||
*/
|
||
import { listTeachingTask, getTeachingTask } from '@/api/teachBusiness/teachingTask'
|
||
import { listAllSemester } from '@/api/teachBusiness/semester'
|
||
|
||
export default {
|
||
name: 'TeachingTask',
|
||
data() {
|
||
return {
|
||
// ==================== 1. 查询条件 ====================
|
||
searchForm: {
|
||
rwmc: '',
|
||
nd: undefined,
|
||
zt: ''
|
||
},
|
||
yearOptions: [],
|
||
statusOptions: [
|
||
{ label: '未发布', value: '未发布' },
|
||
{ label: '已发布', value: '已发布' }
|
||
],
|
||
|
||
// ==================== 2. 表格数据 ====================
|
||
loading: false,
|
||
tableData: [],
|
||
pageNum: 1,
|
||
pageSize: 10,
|
||
total: 0,
|
||
|
||
// ==================== 3. 详情 ====================
|
||
detailVisible: false,
|
||
detailLoading: false,
|
||
detailData: {}
|
||
}
|
||
},
|
||
created() {
|
||
this.loadYearOptions().then(() => this.fetchList())
|
||
},
|
||
methods: {
|
||
/* ---------- 年度下拉(数据来自 /semester/all,禁止硬编码) ---------- */
|
||
loadYearOptions() {
|
||
return listAllSemester().then(response => {
|
||
const list = response.data || []
|
||
const map = {}
|
||
list.forEach(item => {
|
||
if (item.nd !== null && item.nd !== undefined && item.nd !== '') map[item.nd] = item
|
||
})
|
||
const arr = Object.keys(map).sort((a, b) => String(b).localeCompare(String(a)))
|
||
this.yearOptions = arr
|
||
// 默认年度:优先当前学期(dqxq=true),否则取最新年度
|
||
const current = list.find(item => item.dqxq === true)
|
||
const defaultNd = (current && current.nd) || arr[0]
|
||
if (!this.searchForm.nd) this.searchForm.nd = defaultNd
|
||
return arr
|
||
}).catch(() => {
|
||
this.yearOptions = []
|
||
return []
|
||
})
|
||
},
|
||
|
||
/* ---------- 通用格式化 ---------- */
|
||
fmtDateTime(row, column, cellValue) {
|
||
if (cellValue === null || cellValue === undefined || cellValue === '') return '-'
|
||
return String(cellValue).replace('T', ' ').slice(0, 16)
|
||
},
|
||
fmtVal(val) {
|
||
if (val === null || val === undefined || val === '') return '-'
|
||
return String(val).replace('T', ' ').slice(0, 16)
|
||
},
|
||
|
||
/* ---------- 列表加载 ---------- */
|
||
fetchList() {
|
||
this.loading = true
|
||
const params = { pageNum: this.pageNum, pageSize: this.pageSize }
|
||
if (this.searchForm.rwmc && this.searchForm.rwmc.trim()) params.rwmc = this.searchForm.rwmc.trim()
|
||
if (this.searchForm.nd !== undefined && this.searchForm.nd !== null && this.searchForm.nd !== '') {
|
||
params.nd = this.searchForm.nd
|
||
}
|
||
if (this.searchForm.zt && this.searchForm.zt.trim()) params.zt = this.searchForm.zt.trim()
|
||
listTeachingTask(params).then(res => {
|
||
const data = (res && res.data) || {}
|
||
this.tableData = data.records || []
|
||
this.total = data.total || 0
|
||
this.loading = false
|
||
}).catch(() => {
|
||
this.tableData = []
|
||
this.total = 0
|
||
this.loading = false
|
||
})
|
||
},
|
||
|
||
handleQuery() {
|
||
this.pageNum = 1
|
||
this.fetchList()
|
||
},
|
||
|
||
handlePageChange(page) {
|
||
this.pageNum = page
|
||
this.fetchList()
|
||
},
|
||
|
||
handleSizeChange(size) {
|
||
this.pageSize = size
|
||
this.pageNum = 1
|
||
this.fetchList()
|
||
},
|
||
|
||
/* ---------- 详情(只读,走真实 get?bh= 接口) ---------- */
|
||
handleDetail(row) {
|
||
this.detailVisible = true
|
||
this.detailLoading = true
|
||
this.detailData = {}
|
||
getTeachingTask(row.bh).then(res => {
|
||
this.detailData = (res && res.data) || {}
|
||
this.detailLoading = false
|
||
}).catch(() => {
|
||
this.detailLoading = false
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.app-container {
|
||
padding: 20px;
|
||
}
|
||
|
||
.teaching-task-page {
|
||
.page-title {
|
||
text-align: center;
|
||
font-size: 20px;
|
||
font-weight: 600;
|
||
color: #303133;
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
// ==================== 1. 查询条件区域 ====================
|
||
.search-card {
|
||
margin-bottom: 16px;
|
||
|
||
.search-form {
|
||
.search-actions {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
padding-top: 12px;
|
||
border-top: 1px solid #ebeef5;
|
||
}
|
||
}
|
||
}
|
||
|
||
// ==================== 2. 数据表格 ====================
|
||
.table-card {
|
||
.pagination {
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
margin-top: 12px;
|
||
}
|
||
}
|
||
|
||
// ==================== 3. 详情 ====================
|
||
.detail-empty {
|
||
min-height: 120px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
color: #909399;
|
||
}
|
||
}
|
||
|
||
</style>
|