school-file-portal/src/views/TextBook/index.vue

376 lines
12 KiB
Vue
Raw Normal View History

2024-06-12 07:47:55 +00:00
<template>
<div class="container">
<div class="bread-container">
<el-breadcrumb separator=">">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>同步教材</el-breadcrumb-item>
</el-breadcrumb>
</div>
2024-07-16 01:47:16 +00:00
<el-collapse v-model="activeNames">
2024-07-22 02:34:23 +00:00
<el-collapse-item title="" name="1" style="position: relative;">
<template #title>
<div style="position: absolute;right: 30px;font-size: 16px;">{{ activeNames == '1' ? '收起' : '展开' }}</div>
</template>
2024-07-16 01:47:16 +00:00
<el-form label-width="auto" style="padding-left: 20px;">
2024-07-24 02:48:01 +00:00
<el-form-item v-if="textbook2List && textbook2List.length > 0" label="学段">
2024-07-16 01:47:16 +00:00
<el-radio-group v-model="radio2" @change="handle2Change">
<el-radio-button v-for="item in textbook2List" :label="item.catalogName" :value="item.catalogId"
:key="item.catalogId" />
</el-radio-group>
</el-form-item>
2024-07-24 02:48:01 +00:00
<el-form-item v-if="textbook3List && textbook3List.length > 0" label="年级">
2024-07-16 01:47:16 +00:00
<el-radio-group v-model="radio3" @change="handle3Change">
<el-radio-button v-for="item in textbook3List" :label="item.catalogName" :value="item.catalogId"
:key="item.catalogId" />
</el-radio-group>
</el-form-item>
2024-07-24 02:48:01 +00:00
<el-form-item v-if="textbook4List && textbook4List.length > 0" label="学科">
2024-07-16 01:47:16 +00:00
<el-radio-group v-model="radio4" @change="handle4Change">
<el-radio-button v-for="item in textbook4List" :label="item.catalogName" :value="item.catalogId"
:key="item.catalogId" />
</el-radio-group>
</el-form-item>
2024-07-24 02:48:01 +00:00
<el-form-item v-if="textbook5List && textbook5List.length > 0" label="版本">
2024-07-16 01:47:16 +00:00
<el-radio-group v-model="radio5" @change="handle5Change">
<el-radio-button v-for="item in textbook5List" :label="item.catalogName" :value="item.catalogId"
:key="item.catalogId" />
</el-radio-group>
</el-form-item>
2024-07-24 02:48:01 +00:00
<el-form-item v-if="textbook6List && textbook6List.length > 0" label="教材">
2024-07-16 01:47:16 +00:00
<el-radio-group v-model="radio6" @change="handle6Change">
<el-radio-button v-for="item in textbook6List" :label="item.catalogName" :value="item.catalogId"
:key="item.catalogId" />
</el-radio-group>
</el-form-item>
<el-form-item label="类型">
<el-radio-group v-model="queryParams.type">
<el-radio-button label="全部" value=""></el-radio-button>
<el-radio-button label="课件" value="1"></el-radio-button>
<el-radio-button label="精品课堂" value="2"></el-radio-button>
<el-radio-button label="作业" value="3"></el-radio-button>
<el-radio-button label="试卷" value="4"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="格式">
<el-radio-group v-model="queryParams.formatSuffix">
<el-radio-button label="全部" value=""></el-radio-button>
<el-radio-button label="PPT" value="1"></el-radio-button>
<el-radio-button label="WORD" value="2"></el-radio-button>
<el-radio-button label="PDF" value="3"></el-radio-button>
<el-radio-button label="图片" value="4"></el-radio-button>
<el-radio-button label="音频" value="5"></el-radio-button>
<el-radio-button label="视频" value="6"></el-radio-button>
<el-radio-button label="其它" value="7"></el-radio-button>
</el-radio-group>
</el-form-item>
</el-form>
</el-collapse-item>
</el-collapse>
2024-06-12 07:47:55 +00:00
2024-06-18 00:44:06 +00:00
<el-row :gutter="10" style="margin-top: 10px">
2024-06-12 07:47:55 +00:00
<el-col :span="6">
<el-card>
<template #header>
<div class="card--left-header">
<span class="title">目录</span>
</div>
</template>
2024-06-20 09:08:05 +00:00
<el-table @row-click="handleRowClick" :data="textbook7List" row-key="id" border default-expand-all
:show-header="false">
<el-table-column prop="label" label="label" />
2024-06-12 07:47:55 +00:00
</el-table>
</el-card>
</el-col>
<el-col :span="18">
<el-card>
<div class="card-right-header">
2024-06-18 00:44:06 +00:00
<!-- 排序组件 -->
<JzSort v-model="sortResult" :sortData="sortData" />
2024-07-02 01:32:49 +00:00
<div class="header-search">
<el-input v-model="queryParams.fileName" style="width: 300px" placeholder="请输入关键词" clearable
@clear="handleClear" />
<el-button type="primary" :icon="Search" @click="handleQuery" />
</div>
2024-06-12 07:47:55 +00:00
</div>
<div class="book-grid">
2024-06-24 07:20:12 +00:00
<el-card v-for="item in tableData" :key="item" @click="goto(item)">
2024-06-12 07:47:55 +00:00
<div class="book-content">
2024-07-24 02:48:01 +00:00
<img v-if="item?.fileSuffix.includes('doc')" src="@/assets/images/word.png" alt="" />
<img v-else-if="item?.fileSuffix.includes('xls')" src="@/assets/images/excel.png" alt="" />
<img v-else-if="item?.fileSuffix.includes('pdf')" src="@/assets/images/pdf.png" alt="" />
<img v-else-if="item?.fileSuffix.includes('txt')" src="@/assets/images/txt.png" alt="" />
2024-07-02 01:32:49 +00:00
<img v-else src="@/assets/images/book.png" alt="" />
2024-06-12 07:47:55 +00:00
</div>
<template #footer>
2024-07-24 02:48:01 +00:00
<div class="book-title">{{ item?.fileName }}</div>
2024-06-12 07:47:55 +00:00
<div class="book-des">
2024-07-24 02:48:01 +00:00
<div class="book-teacher"><span>{{ item?.createBy }}</span>&nbsp;|&nbsp;<span>{{ item?.createDept
2024-06-20 09:08:05 +00:00
}}</span></div>
2024-06-12 07:47:55 +00:00
<div class="book-view">
2024-06-24 07:20:12 +00:00
<span style="margin-right: 5px;">
2024-06-12 07:47:55 +00:00
<el-icon>
<View />
</el-icon>
</span>
2024-07-24 02:48:01 +00:00
<span>{{ item?.downloadNum }}</span>
2024-06-12 07:47:55 +00:00
</div>
</div>
</template>
</el-card>
</div>
2024-07-24 02:55:47 +00:00
<pagination v-show="total > 0" :total="total" :page-sizes="[6, 10, 20, 30, 50]"
v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getTextbookListData" />
2024-06-12 07:47:55 +00:00
</el-card>
</el-col>
</el-row>
</div>
</template>
<script setup>
2024-06-20 09:08:05 +00:00
import { ref, onMounted, watchEffect, watch } from 'vue';
2024-06-24 07:20:12 +00:00
import { useRouter } from 'vue-router'
2024-07-02 01:32:49 +00:00
import { View, Search } from '@element-plus/icons-vue'
2024-06-20 09:08:05 +00:00
import { getTextbookAPI, getTextbookTreeAPI, getTextbookList } from '@/apis/textbook'
import JzSort from '@/components/JzSort/index.vue'
2024-07-24 02:48:01 +00:00
import pagination from '@/components/Pagination/index.vue';
// 排序初始化数据
const sortData = [
{ label: '上传时间', key: 'createTime' },
{ label: '浏览量', key: 'previewNum' },
{ label: '下载量', key: 'downloadNum' }
];
const sortResult = ref({}); // 排序结果
2024-06-20 09:08:05 +00:00
2024-06-24 07:20:12 +00:00
const router = useRouter()
2024-06-20 09:08:05 +00:00
const queryParams = ref({
catalogId: undefined,
2024-07-02 01:32:49 +00:00
fileName: '',
2024-06-24 07:20:12 +00:00
type: undefined,
2024-07-02 01:32:49 +00:00
formatSuffix: undefined,
2024-06-20 09:08:05 +00:00
pageNum: 1,
2024-06-24 07:20:12 +00:00
pageSize: 6,
orderByColumn: '',
isAsc: ''
2024-06-20 09:08:05 +00:00
})
const tableData = ref([])
const total = ref(0)
2024-07-16 01:47:16 +00:00
const activeNames = ref(['1'])
2024-06-20 09:08:05 +00:00
const radio2 = ref()
const radio3 = ref()
const radio4 = ref()
const radio5 = ref()
const radio6 = ref()
// 1主目录2学段3年级4学科5版本6教材7目录
const textbookList = ref([])
const textbook2List = ref([])
const textbook3List = ref([])
const textbook4List = ref([])
const textbook5List = ref([])
const textbook6List = ref([])
const textbook7List = ref([])
const getTextbookData = async () => {
const res = await getTextbookAPI()
textbookList.value = res.data
2024-07-24 02:48:01 +00:00
// 学段
2024-06-20 09:08:05 +00:00
textbook2List.value = filterListByType(2)
2024-07-24 02:48:01 +00:00
radio2.value = textbook2List.value[0].catalogId
// 年级
textbook3List.value = filterListByParentId(radio2.value)
radio3.value = textbook3List.value[0].catalogId
// 学科
textbook4List.value = filterListByParentId(radio3.value)
radio4.value = textbook4List.value[0].catalogId
// 版本
textbook5List.value = filterListByParentId(radio4.value)
radio5.value = textbook5List.value[0].catalogId
// 教材
textbook6List.value = filterListByParentId(radio5.value)
radio6.value = textbook6List.value[0].catalogId
// 目录
const treeData = await getTextbookTreeAPI({ parentId: radio6.value })
textbook7List.value = treeData.data
queryParams.value.catalogId = radio6.value
2024-06-20 09:08:05 +00:00
}
const handle2Change = (val) => {
2024-07-24 02:48:01 +00:00
radio3.value = null
2024-06-20 09:08:05 +00:00
textbook4List.value = []
2024-07-24 02:48:01 +00:00
radio4.value = null
2024-06-20 09:08:05 +00:00
textbook5List.value = []
2024-07-24 02:48:01 +00:00
radio5.value = null
2024-06-20 09:08:05 +00:00
textbook6List.value = []
2024-07-24 02:48:01 +00:00
radio6.value = null
2024-06-20 09:08:05 +00:00
textbook7List.value = []
2024-07-24 02:48:01 +00:00
textbook3List.value = filterListByParentId(val)
2024-06-20 09:08:05 +00:00
queryParams.value.catalogId = val
}
const handle3Change = (val) => {
2024-07-24 02:48:01 +00:00
radio4.value = null
2024-06-20 09:08:05 +00:00
textbook5List.value = []
2024-07-24 02:48:01 +00:00
radio5.value = null
2024-06-20 09:08:05 +00:00
textbook6List.value = []
2024-07-24 02:48:01 +00:00
radio6.value = null
2024-06-20 09:08:05 +00:00
textbook7List.value = []
2024-07-24 02:48:01 +00:00
textbook4List.value = filterListByParentId(val)
2024-06-20 09:08:05 +00:00
queryParams.value.catalogId = val
}
const handle4Change = (val) => {
2024-07-24 02:48:01 +00:00
radio5.value = null
2024-06-20 09:08:05 +00:00
textbook6List.value = []
2024-07-24 02:48:01 +00:00
radio6.value = null
2024-06-20 09:08:05 +00:00
textbook7List.value = []
2024-07-24 02:48:01 +00:00
textbook5List.value = filterListByParentId(val)
2024-06-20 09:08:05 +00:00
queryParams.value.catalogId = val
}
const handle5Change = (val) => {
2024-07-24 02:48:01 +00:00
radio6.value = null
2024-06-20 09:08:05 +00:00
textbook7List.value = []
2024-07-24 02:48:01 +00:00
textbook6List.value = filterListByParentId(val)
2024-06-20 09:08:05 +00:00
queryParams.value.catalogId = val
}
const handle6Change = async (val) => {
const res = await getTextbookTreeAPI({ parentId: val })
textbook7List.value = res.data
queryParams.value.catalogId = val
}
const filterListByType = (type) => {
return textbookList.value.filter(item => item.type == type)
}
const filterListByParentId = (parentId) => {
return textbookList.value.filter(item => item.parentId == parentId)
}
2024-06-18 00:44:06 +00:00
2024-06-20 09:08:05 +00:00
const getTextbookListData = async () => {
const res = await getTextbookList(queryParams.value)
tableData.value = res.rows
total.value = res.total
}
const handleRowClick = (val) => {
queryParams.value.catalogId = val.id
}
2024-06-24 07:20:12 +00:00
watchEffect(() => {
queryParams.value.orderByColumn = sortResult.value.key
queryParams.value.isAsc = sortResult.value.order
2024-07-24 02:48:01 +00:00
})
2024-06-24 07:20:12 +00:00
2024-07-24 02:48:01 +00:00
watch(queryParams, (newVal, oldVal) => {
2024-06-24 07:20:12 +00:00
getTextbookListData()
2024-07-24 02:48:01 +00:00
}, { deep: true })
2024-06-24 07:20:12 +00:00
const goto = (item) => {
router.push({ path: 'textBookDetail', query: { id: item.id } })
}
2024-07-02 01:32:49 +00:00
const handleQuery = () => {
if (!queryParams.value.fileName) {
ElMessage.error('请输入查询关键字!')
return
}
2024-07-24 02:48:01 +00:00
getTextbookListData()
2024-07-02 01:32:49 +00:00
}
const handleClear = () => {
queryParams.value.fileName = ''
2024-07-24 02:48:01 +00:00
getTextbookListData()
2024-07-02 01:32:49 +00:00
}
2024-06-20 09:08:05 +00:00
onMounted(() => {
getTextbookData()
})
2024-06-12 07:47:55 +00:00
</script>
<style lang="scss" scoped>
.container {
.bread-container {
padding: 25px 0;
:deep(.el-breadcrumb__inner) {
color: #fff;
font-size: 16px;
}
:deep(.el-breadcrumb__separator) {
color: #fff;
}
}
2024-07-16 01:47:16 +00:00
.el-collapse {
2024-06-12 07:47:55 +00:00
margin-top: 20px;
}
.card--left-header {
.title {
font-size: 20px;
}
}
.card-right-header {
2024-07-02 01:32:49 +00:00
display: flex;
justify-content: space-between;
padding-bottom: 10px;
border-bottom: 1px solid #919DA3;
2024-06-12 07:47:55 +00:00
}
.book-grid {
margin-top: 10px;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
2024-07-02 01:32:49 +00:00
gap: 10px;
2024-06-12 07:47:55 +00:00
.book-content {
2024-07-02 01:32:49 +00:00
img {
2024-06-24 07:20:12 +00:00
border-radius: 10px;
width: 100%;
2024-07-02 01:32:49 +00:00
height: 240px;
2024-06-20 09:08:05 +00:00
}
2024-06-12 07:47:55 +00:00
}
.book-title {
font-size: 16px;
font-weight: bold;
}
2024-06-18 02:37:00 +00:00
.book-des {
2024-06-12 07:47:55 +00:00
display: flex;
justify-content: space-between;
2024-06-18 02:37:00 +00:00
color: #919DA3;
2024-06-12 07:47:55 +00:00
padding: 5px 0;
}
2024-06-18 02:37:00 +00:00
}
2024-06-12 07:47:55 +00:00
2024-06-18 02:37:00 +00:00
.book-page {
margin-top: 20px;
display: flex;
justify-content: end
2024-06-12 07:47:55 +00:00
}
}
2024-06-18 00:44:06 +00:00
</style>