From 346c01add76f64b396594ac7be7d97f9f6dbf813 Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期一, 11 十一月 2024 16:48:26 +0800 Subject: [PATCH] bug修改 --- src/views/onlineEducation/courseManage/courseChapters/index.vue | 64 ++++++++++++++++++++++++++----- 1 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/views/onlineEducation/courseManage/courseChapters/index.vue b/src/views/onlineEducation/courseManage/courseChapters/index.vue index 1ce31f6..a5a54d8 100644 --- a/src/views/onlineEducation/courseManage/courseChapters/index.vue +++ b/src/views/onlineEducation/courseManage/courseChapters/index.vue @@ -1,8 +1,8 @@ <template> <div class="app-container"> - <div style="margin-bottom: 10px"> - <el-button type="success" plain @click="openDialog('addFirst',{courseId: data.courseId})">章添加</el-button> - + <div style="margin-bottom: 10px;display:flex;justify-content: space-between;align-items: center"> + <el-button type="success" plain @click="openDialog('addFirst',{courseId: data.courseId})" :disabled="disabled">章添加</el-button> + <el-button type="primary" plain @click="back">返回</el-button> </div> <!-- 表格数据 --> <el-table v-loading="loading" :data="dataList" :border="true" row-key="id" :tree-props="{ children: 'chapterPeriods' }"> @@ -10,14 +10,15 @@ <el-table-column label="章节名称" > <template #default="scope"> <span>{{scope.row.name}}</span> + <span v-if="scope.row.chapterId" style="font-size: 14px;margin-left: 5px">【{{scope.row.resource.resourceType === 1 ? '视频:':scope.row.resource.resourceType === 2 ? '音频:':'文档:'}}{{scope.row.resource.name}}】| {{scope.row.timeFormat}}</span> </template> </el-table-column> <el-table-column label="排序" prop="sort" align="center" width="80" /> <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250" > <template #default="scope"> - <el-button type="success" plain @click="openDialog('add',scope.row)" v-if="!scope.row.chapterId">节添加</el-button> - <el-button type="primary" plain @click="openDialog('edit',scope.row)">编辑</el-button> - <el-button type="danger" plain @click="handleDelete(scope.row)">删除</el-button> + <el-button type="success" plain @click="openDialog('add',scope.row)" v-if="!scope.row.chapterId" :disabled="disabled">节添加</el-button> + <el-button type="primary" plain @click="openDialog('edit',scope.row)" :disabled="disabled">编辑</el-button> + <el-button type="danger" plain @click="handleDelete(scope.row)" :disabled="disabled">删除</el-button> </template> </el-table-column> </el-table> @@ -32,11 +33,13 @@ import {delArea, getArea} from "@/api/backManage/area"; import {getDictList} from "@/api/backManage/evaluate"; import {delMonitor} from "@/api/sysUsers"; -import {useRoute} from 'vue-router' +import {useRoute,useRouter} from 'vue-router' import {delClassification, getClassification} from "@/api/onlineEducation/courseClass"; import {delChapter, delPeriod, getChapters} from "@/api/onlineEducation/chapters"; +import Cookies from "js-cookie"; const { proxy } = getCurrentInstance(); const route = useRoute() +const router = useRouter(); const loading = ref(false); const areaRef = ref(); const cityList = ref([]) @@ -51,11 +54,16 @@ }); const { queryParams, total, dataList } = toRefs(data); - +const backValue = ref() +const disabled = ref(false) //页面加载 onMounted(() => { - - data.courseId = route.query.courseId + backValue.value = JSON.parse(route.query.val) + const userInfo = JSON.parse(Cookies.get('userInfo')) + if((backValue.value.state === 2 || backValue.value.state === 1 ) && userInfo.userType == 1){ + disabled.value = true; + } + data.courseId = backValue.value.id console.log("rou",data.courseId) getList(); }); @@ -66,12 +74,37 @@ } const res = await getChapters(param); if(res.code === 200){ - dataList.value = res.data + dataList.value = res.data.map(item => { + return { + ...item, + chapterPeriods: item.chapterPeriods.map(r => { + return { + ...r, + timeFormat: r.resource.resourceType === 1 || r.resource.resourceType === 2 ? secondsToTime(r.resource.resourceLength) : r.resource.docPage + '页' + } + }) + + } + }) }else{ ElMessage.warning(res.message) } loading.value = false; console.log('dataList.value',dataList.value) +} +const secondsToTime = (seconds) => { + const hours = Math.floor(seconds / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + const secs = seconds % 60; + + return [ + hours, + hours > 0 ? pad(minutes) : minutes, + pad(secs) + ].join(':'); +} +const pad = (number) => { + return (number < 10 ? '0' : '') + number; } const openDialog = (type, value) => { @@ -119,6 +152,15 @@ }) } +const back = () => { + + const obj = { + pageNum: backValue.value.pageNum, + pageSize: backValue.value.pageSize, + } + const v = JSON.stringify(obj) + router.push({ path: "/courseManage/course", query: { val: v } }); +} </script> -- Gitblit v1.9.2