11<template >
2+ <div v-if =" groupMode.active" style =" display :flex ; align-items :center ; justify-content :space-between ; margin-bottom : 8px ;" >
3+ <div style =" display :flex ; align-items :center ; gap : 8px ;" >
4+ <el-button type =" primary" link @click =" exitGroup" >返回</el-button >
5+ <span >{{ groupMode.title }}</span >
6+ </div >
7+ </div >
28 <el-table :data =" tableData.list" v-loading =" loading" height =" 97%" style =" width : 100% "
39 :cell-style =" { textAlign: 'left' }" :header-cell-style =" { textAlign: 'left' }"
410 table-layout =" auto" >
511 <!-- <el-table-column prop="class_id" label="ID" width="80" /> -->
6- <el-table-column prop =" title" label =" 标题" width =" 280" />
12+ <el-table-column prop =" title" label =" 标题" width =" 280" >
13+ <template #default =" scope " >
14+ <div style =" display :flex ; align-items :center ; gap : 8px ;" >
15+ <span >{{ scope.row.title }}</span >
16+ <el-tag v-if =" scope.row.is_group" type =" info" size =" small" >分组</el-tag >
17+ <span v-if =" scope.row.is_group" >共{{ scope.row.course_num || 0 }}本</span >
18+ <el-button v-if =" scope.row.is_group" type =" primary" link @click.stop =" enterGroup(scope.row)" >进入</el-button >
19+ </div >
20+ </template >
21+ </el-table-column >
722 <el-table-column prop =" icon" label =" 封面" width =" 80" >
823 <template #default =" scope " >
9- <el-image
10- :src =" scope.row.icon"
24+ <el-image
25+ v-if =" scope.row.icon"
26+ :src =" scope.row.icon"
1127 :preview-teleported =" true"
12- :preview-src-list =" [scope.row.icon]"
28+ :preview-src-list =" [scope.row.icon]"
1329 style =" width : 32px ;"
14- >
15- </ el-image >
30+ / >
31+ <span v-else >-</ span >
1632 </template >
1733 </el-table-column >
1834 <el-table-column prop =" intro" label =" 简介" width =" 280" />
2137
2238 <el-table-column prop =" publish_num" label =" 已更新" width =" 100" >
2339 <template #default =" scope " >
24- <span >{{ scope.row.publish_num }}/{{scope.row.course_num}}</span >
40+ <span v-if =" !scope.row.is_group" >{{ scope.row.publish_num || 0 }}/{{ scope.row.course_num || 0 }}</span >
41+ <span v-else >-</span >
2542 </template >
2643 </el-table-column >
2744 <el-table-column prop =" progress" label =" 已学%" width =" 80" />
2845 <el-table-column fixed =" right" label =" 操作" width =" 240" >
2946 <template #default =" scope " >
30- <el-button icon =" list" size =" small" type =" primary" link @click =" gotoArticleList(scope.row)" >章节列表
31- </el-button >
32- <el-button icon =" view" size =" small" type =" primary" link @click =" handleProd(scope.row.enid)" >详情
33- </el-button >
34- <el-button icon =" download" size =" small" type =" primary" link @click =" openDownloadDialog(scope.row)" >下载
35- </el-button >
47+ <template v-if =" ! scope .row .is_group " >
48+ <el-button icon =" list" size =" small" type =" primary" link @click =" gotoArticleList(scope.row)" >章节列表
49+ </el-button >
50+ <el-button icon =" view" size =" small" type =" primary" link @click =" handleProd(scope.row.enid)" >详情
51+ </el-button >
52+ <el-button icon =" download" size =" small" type =" primary" link @click =" openDownloadDialog(scope.row)" >下载
53+ </el-button >
54+ </template >
3655
3756 </template >
3857 </el-table-column >
3958 </el-table >
4059
41- <pagination :total =" total" @pageChange =" handleChangePage" ></pagination >
60+ <pagination :key = " paginationKey " : total =" total" @pageChange =" handleChangePage" ></pagination >
4261 <course-info v-if =" dialogVisible" :enid = " prodEnid" :dialog-visible =" dialogVisible" @close =" closeDialog" ></course-info >
4362 <download-dialog
4463 v-if =" dialogDownloadVisible"
5473<script lang="ts" setup>
5574import { ref , reactive , onMounted } from ' vue'
5675import { ElTable , ElMessage } from ' element-plus'
57- import {CourseList , CourseCategory , SetDir } from ' ../../wailsjs/go/backend/App'
76+ import {CourseList , CourseCategory , CourseGroupList , SetDir } from ' ../../wailsjs/go/backend/App'
5877import { services } from ' ../../wailsjs/go/models'
5978import { userStore } from ' ../stores/user' ;
6079import { settingStore } from ' ../stores/setting' ;
@@ -71,10 +90,17 @@ const { pushLogin, pushCourseDetail, pushSetting } = useAppRouter()
7190const loading = ref (true )
7291const page = ref (1 )
7392const total = ref (0 )
93+ const outerTotal = ref (0 )
7494const pageSize = ref (15 )
95+ const paginationKey = ref (0 )
7596const dialogVisible = ref (false )
7697const prodEnid = ref (" " )
7798
99+ const groupMode = reactive ({
100+ active: false ,
101+ groupId: 0 ,
102+ title: ' ' ,
103+ })
78104
79105const dialogDownloadVisible = ref (false )
80106const downloadType = ref (1 )
@@ -93,7 +119,8 @@ onMounted(() => {
93119 CourseCategory ().then (result => {
94120 result .forEach ((item , key ) => {
95121 if (item .category == " bauhinia" ) {
96- total .value = item .count
122+ outerTotal .value = item .count
123+ if (! groupMode .active ) total .value = item .count
97124 }
98125 })
99126 }).catch ((error ) => {
@@ -115,10 +142,15 @@ const handleChangePage = (item: any) => {
115142
116143
117144const getTableData = async () => {
118- await CourseList (" bauhinia" , " study" , page .value , pageSize .value ).then ((table ) => {
145+ loading .value = true
146+ const fetcher = groupMode .active
147+ ? CourseGroupList (" bauhinia" , " study" , groupMode .groupId , page .value , pageSize .value )
148+ : CourseList (" bauhinia" , " study" , page .value , pageSize .value )
149+
150+ await fetcher .then ((table ) => {
119151 loading .value = false
120152 Object .assign (tableData , table )
121- // console.log(tableData)
153+ total . value = groupMode . active ? ( table . total || 0 ) : outerTotal . value
122154 }).catch ((error ) => {
123155 loading .value = false
124156 ElMessage ({
@@ -143,6 +175,27 @@ const gotoArticleList = (row: any) => {
143175 })
144176}
145177
178+ const enterGroup = (row : any ) => {
179+ const groupId = Number (row ?.group_id || 0 )
180+ if (! groupId ) return
181+ groupMode .active = true
182+ groupMode .groupId = groupId
183+ groupMode .title = String (row ?.title || ' ' )
184+ page .value = 1
185+ paginationKey .value += 1
186+ getTableData ()
187+ }
188+
189+ const exitGroup = () => {
190+ groupMode .active = false
191+ groupMode .groupId = 0
192+ groupMode .title = ' '
193+ page .value = 1
194+ total .value = outerTotal .value
195+ paginationKey .value += 1
196+ getTableData ()
197+ }
198+
146199const openDialog = () => {
147200 dialogVisible .value = true
148201}
@@ -201,4 +254,4 @@ const closeDownloadDialog = () => {
201254 /* height: auto; */
202255 text-align : center ;
203256}
204- </style >
257+ </style >
0 commit comments