#876 教学实践,上课时检查未结束课程逻辑

This commit is contained in:
朱浩 2024-10-10 17:42:48 +08:00
parent 4b2f2aa73a
commit e253a6c9dc
7 changed files with 293 additions and 63 deletions

View File

@ -147,10 +147,11 @@ export function updateSmartClassReserv(data) {
})
}
//查询课程预约
export function getSelfReserv() {
export function getSelfReserv(params) {
return request({
url: '/smarttalk/classReserv/getSelfReserv',
method: 'get'
method: 'get',
params
})
}
export function deleteSmartReserv(id) {

View File

@ -9,6 +9,14 @@ export function listClasscourse(query) {
})
}
export function listClasscourseNew(query) {
return request({
url: '/education/classcourse/new/list',
method: 'get',
params: query
})
}
// 查询classcourse详细
export function getClasscourse(id) {
return request({

View File

@ -1,25 +1,25 @@
<template>
<el-container class="class-reserv-wrap">
<div class="class-reserv-tabs">
<!-- <div class="class-reserv-tabs">
<el-segmented v-model="tabActive" block :options="tabOptions" size="large" />
</div>
</div>-->
<div class="class-reserv-body">
<reserv-item
v-for="(item, index) in activeDataList"
v-show="tabActive === '进行中'"
:key="index"
:item="item"
@open-edit="reservDialog.openDialog(item)"
@delete-reserv="deleteReserv(item)"
></reserv-item>
<reserv-item
v-for="(item, index) in doneDataList"
v-show="tabActive === '已结束'"
:key="index"
:item="item"
@open-edit="reservDialog.openDialog(item)"
@delete-reserv="deleteReserv(item)"
></reserv-item>
<template v-for="(item, index) in dataList" :key="index">
<reserv-item
:style="{'background-color': index%2==0?'#f5f5f5':''}"
:item="item"
v-if="item.bookImg"
@open-edit="reservDialog.openDialog(item)"
@delete-reserv="deleteReserv(item)"
></reserv-item>
<reserv-item-apt
v-if="!item.bookImg"
:style="{'background-color': index%2==0?'#f5f5f5':''}"
:item="item"
@open-edit="reservDialog.openDialog(item)"
@delete-reserv="deleteReserv(item)"
></reserv-item-apt>
</template>
</div>
<reserv ref="reservDialog"></reserv>
</el-container>
@ -28,44 +28,62 @@
<script setup>
import { ref, onMounted, computed, watch } from 'vue'
import { getSelfReserv } from '@/api/classManage'
import { listClasscourseNew } from '@/api/teaching/classcourse' // api
import ReservItem from '@/views/classManage/reserv-item.vue'
import Reserv from '@/views/prepare/container/reserv.vue'
import { useToolState } from '@/store/modules/tool'
import { sessionStore } from '@/utils/tool'
import useUserStore from '@/store/modules/user'
import ReservItemApt from '@/views/classManage/reserv-item-apt.vue'
const reservDialog = ref(null)
const tabOptions = ref(['进行中', '已结束'])
const tabActive = ref('进行中')
const dataList = ref([])
const activeDataList = computed(() => {
const toolStore = useToolState()
const userStore = useUserStore()
/*const activeDataList = computed(() => {
return dataList.value.filter((item) => {
return item.status !== '已结束'
})
})*/
const props = defineProps({
curNode: {
type: Object,
default: () => {}
}
})
const deleteReserv = (item) => {
dataList.value = dataList.value.filter((is) => {
return is.id !== item.id
})
}
const doneDataList = computed(() => {
/*const doneDataList = computed(() => {
return dataList.value.filter((item) => {
return item.status === '已结束'
})
})
})*/
//
const getData = () => {
getSelfReserv().then((res) => {
Promise.all([listClasscourseNew({teacherid: userStore.id,evalid: props.curNode.id,pageSize:1000}), getSelfReserv({ex2:props.curNode.id})]).then(([res1,res2])=>{
let list = res2.data || []
let list2 = res1.rows || []
// list.sort((a,b) => { if(a.status=='') return -1; else return 0 })
list = list.concat(list2)
list.sort((a,b) => { return new Date(b.createTime) - new Date(a.createTime) })
dataList.value = list
})
/*getSelfReserv().then((res) => {
const list = res.data || []
list.sort((a,b) => { if(a.status=='上课中') return -1; else return 0 })
dataList.value = list
})
})*/
}
const toolStore = useToolState()
watch(
() => [dataList,toolStore.isToolWin],
() => [dataList,toolStore.isToolWin,props.curNode],
() => {
console.log('====',toolStore)
setTimeout(()=>{
getData() //
},300)
@ -81,13 +99,14 @@ onMounted(() => {
height: 100%;
display: flex;
flex-direction: column;
padding: 15px 30px;
//padding: 15px 10px;
.class-reserv-tabs {
width: 30%;
text-align: left;
}
.class-reserv-body {
height: 100%;
font-size: 12px;
flex: 1;
overflow: auto;
padding: 10px 0;

View File

@ -0,0 +1,127 @@
<template>
<div class="class-reserv-item">
<div class="class-reserv-item-body">
{{ item.openDate }}&nbsp;{{ item.openTime }}
</div>
<div style="flex: 1;max-width: 400px">
<span>{{item.caption}}</span>
</div>
<div class="class-reserv-item-tool" style="width: 200px;max-width: 300px">
<el-tag v-if="item.status === 'close'" style="margin-right: 5px" type="success">已结束</el-tag>
<el-tag v-if="item.status === 'open'" style="margin-right: 5px" type="danger">上课中</el-tag>
<el-button v-if="item.status === 'open'" :disabled="toolStore.isToolWin" size="small" type="primary" @click="startClassR(item)"
>继续上课</el-button
>
<!-- <el-button v-if="item.status === '未开始'" @click="openEdit">编辑</el-button>-->
<el-button v-if="item.status === 'open'" size="small" type="info" @click="endClassR(item)"
>下课</el-button
>
</div>
<div class="class-reserv-item-tool" style="width: 50px;">
<!-- <el-button v-if="item.status!='open'" size="small" type="danger" @click="deleteReserv">删除</el-button>-->
<el-tag>APT</el-tag>
</div>
<div style="min-width: 150px;"><span> 浏览25955 点赞26605</span></div>
</div>
</template>
<script setup>
import { useToolState } from '@/store/modules/tool'
import useUserStore from '@/store/modules/user'
import { createWindow } from '@/utils/tool'
import { deleteSmartReserv, startClass, endClass } from '@/api/classManage'
import { ElMessage } from 'element-plus'
import { listEntpcourse } from '@/api/teaching/classwork'
const emit = defineEmits(['openEdit', 'deleteReserv'])
const props = defineProps({
item: {
type: Object,
default: () => {}
}
})
const basePath = import.meta.env.VITE_APP_BUILD_BASE_PATH
const toolStore = useToolState() // -tool
const openEdit = () => {
emit('openEdit', props.item)
}
const deleteReserv = () => {
deleteSmartReserv([props.item.id]).then((res) => {
if (res.data === true) {
ElMessage({
message: '删除成功',
type: 'success'
})
emit('deleteReserv', props.item)
}
})
}
const startClassR = (item) => {
// startClass(item.id).then((res) => {
// if (res.data === true) {
// item.status = ''
// openLesson()
// }
// })
// item.status = ''
openLesson()
}
const endClassR = (item) => {
/*endClass(item.id).then((res) => {
if (res.data === true) {
ElMessage({
message: '下课成功',
type: 'success'
})
item.status = '已结束'
}
})*/
}
// const toolStore = useToolState()
let wins = null;
// -
const openLesson = () => {
// startClass(props.item.id)
/*listEntpcourse({
evalid: props.item.ex2,
edituserid: useUserStore().user.userId,
pageSize: 500
}).then(async res=>{
if (res.rows[0].id) {
wins = await createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res.rows[0].id + "&reservId=" + props.item.id })
}
})*/
}
</script>
<style scoped lang="scss">
.class-reserv-item {
display: flex;
background-color: white;
border-radius: 10px;
padding: 5px;
margin-bottom: 10px;
.class-reserv-item-img {
width: 60px;
img {
width: 100%;
}
}
.class-reserv-item-body {
display: flex;
align-items: center;
text-align: left;
padding-left: 5px;
width: 120px;
.class-reserv-item-title1 {
flex: 1;
label {
font-size: 20px;
font-weight: bold;
}
}
}
.class-reserv-item-tool {
margin-left: 15px;
display: flex;
align-items: center;
}
}
</style>

View File

@ -1,34 +1,27 @@
<template>
<div class="class-reserv-item">
<div class="class-reserv-item-img">
<img :src="basePath + item.bookImg" alt="封面" />
</div>
<div class="class-reserv-item-body">
<div class="class-reserv-item-title1">
<label>{{ item.className }}</label>
<el-tag style="margin-left: 5px" type="primary"> {{ item.classType }}</el-tag>
<el-tag style="margin-left: 5px" type="primary"> {{ item.classSubject }}</el-tag>
</div>
<div class="class-reserv-item-title2">
{{ item.classDay }}&nbsp;{{ item.startTime }} ~ {{ item.classDay }}&nbsp;{{ item.endTime }}
{{ item.createUserName }}老师
</div>
<div class="class-reserv-item-title3">
<span v-for="(tag, index) in item.classItemList" :key="index" style="margin-left: 5px">
{{ index === 0 ? tag.name : '、' + tag.name }}</span
>
</div>
{{ item.classDay }}&nbsp;{{ item.startTime }}
</div>
<div class="class-reserv-item-tool">
<el-button v-if="item.status !== '已结束'" :disabled="toolStore.isToolWin" type="primary" @click="startClassR(item)"
>{{item.status == '上课中'?'上课中':'上课'}}</el-button
<div style="flex: 1;max-width: 400px">
<span v-for="(tag, index) in item.classItemList" :key="index">{{ index === 0 ? tag.name : '' + tag.name }}</span>
</div>
<div class="class-reserv-item-tool" style="width: 200px;max-width: 300px">
<el-tag v-if="item.status === '已结束'" style="margin-right: 5px" type="success">已结束</el-tag>
<el-tag v-if="item.status === '上课中'" style="margin-right: 5px" type="danger">上课中</el-tag>
<el-button v-if="item.status === '上课中'" :disabled="toolStore.isToolWin" size="small" type="primary" @click="startClassR(item)"
>继续上课</el-button
>
<el-button v-if="item.status === '未开始'" @click="openEdit">编辑</el-button>
<!-- <el-button v-if="item.status === '上课中'" type="info" @click="endClassR(item)"
<!-- <el-button v-if="item.status === '未开始'" @click="openEdit">编辑</el-button>-->
<el-button v-if="item.status === '上课中'" size="small" type="info" @click="endClassR(item)"
>下课</el-button
>-->
<el-button v-if="item.status!='上课中'" type="danger" @click="deleteReserv">删除</el-button>
>
</div>
<div class="class-reserv-item-tool" style="width: 50px;">
<!-- <el-button v-if="item.status!='上课中'" size="small" type="danger" @click="deleteReserv">删除</el-button>-->
<el-tag type="success">PPT</el-tag>
</div>
<div style="min-width: 150px;"></div>
</div>
</template>
<script setup>
@ -100,25 +93,24 @@ const endClassR = (item) => {
</script>
<style scoped lang="scss">
.class-reserv-item {
font-size: 13px;
display: flex;
background-color: white;
border-radius: 10px;
padding: 5px;
margin-bottom: 10px;
.class-reserv-item-img {
width: 80px;
padding-left: 20px;
width: 60px;
img {
width: 100%;
}
}
.class-reserv-item-body {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
text-align: left;
padding-left: 30px;
font-size: 14px;
padding-left: 5px;
width: 120px;
.class-reserv-item-title1 {
flex: 1;
label {

View File

@ -102,6 +102,10 @@ import { deleteSmarttalk, updateSmarttalk, getPrepareById } from '@/api/file'
import useUserStore from '@/store/modules/user'
import outLink from '@/utils/linkConfig'
import { sessionStore } from '@/utils/store'
import { listClasscourseNew } from '@/api/teaching/classcourse'
import { endClass, getSelfReserv } from '@/api/classManage'
import { listEntpcourse } from '@/api/teaching/classwork'
import { createWindow } from '@/utils/tool'
const { ipcRenderer } = window.electron || {}
export default {
@ -142,8 +146,87 @@ export default {
this.userInfo = useUserStore().user
},
methods: {
getOpenCourse() {
return Promise.all([listClasscourseNew({teacherid: this.userInfo.userId,status:"open",evalid: this.curNode.id,pageSize:1000}), getSelfReserv({ex2:this.curNode.id})]).then(([res1,res2])=>{
let list2 = res1.rows || []
let list = res2.data || []
let one = list.find(item1 => {
if (item1.status === "上课中") {
return true
}
})
if (one) {
return one
}
if (list2.length>0) {
one = list2[0]
}
return one
})
},
clickStartClass(item) {
this.$emit('on-start-class', item)
this.getOpenCourse().then(res=>{
if(!res){
this.$emit('on-start-class', item)
}else{
ElMessageBox.alert('<strong>上次课程尚未结束,是否继续上课?</strong>', '', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: '下课  ',
cancelButtonText: '继续上课',
showCancelButton: true,
showClose: false,
closeOnClickModal: true,
distinguishCancelAndClose: true,
dangerouslyUseHTMLString: true,
cancelButtonClass: "el-button--primary",
confirmButtonClass: "el-button--danger",
center: true,
beforeClose: (action, instance, done) => {
if (action === 'confirm'){
//
if (res.bookImg) {
//PPT
endClass(res.id).then((res1) => {
if (res1.data === true) {
ElMessage({
message: '下课成功',
type: 'success'
})
res.status = '已结束'
done()
}
})
}else {
//APT
}
}
if (action === 'cancel'){
//
if (res.bookImg) {
//PPT
listEntpcourse({
evalid: res.ex2,
edituserid: useUserStore().user.userId,
pageSize: 500
}).then(async res1=>{
if (res1.rows[0].id) {
createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res1.rows[0].id + "&reservId=" + res.id })
done()
}
})
}else {
//APT
}
}
if (action === 'close') {
done()
}
},
})
}
})
// this.$emit('on-start-class', item)
},
editTalk(item) {
ElMessageBox.prompt('请输入新的标签', '添加标签', {

View File

@ -28,7 +28,7 @@
</div>
</el-tab-pane>
<el-tab-pane label="教学实录" name="教学实录" class="prepare-center-jxsl">
<class-reserv></class-reserv>
<class-reserv v-if="activeAptTab==='教学实录'" :curNode="currentNode"></class-reserv>
</el-tab-pane>
</el-tabs>
</div>
@ -654,7 +654,7 @@ export default {
fullPath: fullPath,
cookieData: { ...configObj.data }
})
},
},
//
delhomework(item) {
this.isLoading = true