#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({ return request({
url: '/smarttalk/classReserv/getSelfReserv', url: '/smarttalk/classReserv/getSelfReserv',
method: 'get' method: 'get',
params
}) })
} }
export function deleteSmartReserv(id) { 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详细 // 查询classcourse详细
export function getClasscourse(id) { export function getClasscourse(id) {
return request({ return request({

View File

@ -1,25 +1,25 @@
<template> <template>
<el-container class="class-reserv-wrap"> <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" /> <el-segmented v-model="tabActive" block :options="tabOptions" size="large" />
</div> </div>-->
<div class="class-reserv-body"> <div class="class-reserv-body">
<reserv-item <template v-for="(item, index) in dataList" :key="index">
v-for="(item, index) in activeDataList" <reserv-item
v-show="tabActive === '进行中'" :style="{'background-color': index%2==0?'#f5f5f5':''}"
:key="index" :item="item"
:item="item" v-if="item.bookImg"
@open-edit="reservDialog.openDialog(item)" @open-edit="reservDialog.openDialog(item)"
@delete-reserv="deleteReserv(item)" @delete-reserv="deleteReserv(item)"
></reserv-item> ></reserv-item>
<reserv-item <reserv-item-apt
v-for="(item, index) in doneDataList" v-if="!item.bookImg"
v-show="tabActive === '已结束'" :style="{'background-color': index%2==0?'#f5f5f5':''}"
:key="index" :item="item"
:item="item" @open-edit="reservDialog.openDialog(item)"
@open-edit="reservDialog.openDialog(item)" @delete-reserv="deleteReserv(item)"
@delete-reserv="deleteReserv(item)" ></reserv-item-apt>
></reserv-item> </template>
</div> </div>
<reserv ref="reservDialog"></reserv> <reserv ref="reservDialog"></reserv>
</el-container> </el-container>
@ -28,44 +28,62 @@
<script setup> <script setup>
import { ref, onMounted, computed, watch } from 'vue' import { ref, onMounted, computed, watch } from 'vue'
import { getSelfReserv } from '@/api/classManage' import { getSelfReserv } from '@/api/classManage'
import { listClasscourseNew } from '@/api/teaching/classcourse' // api
import ReservItem from '@/views/classManage/reserv-item.vue' import ReservItem from '@/views/classManage/reserv-item.vue'
import Reserv from '@/views/prepare/container/reserv.vue' import Reserv from '@/views/prepare/container/reserv.vue'
import { useToolState } from '@/store/modules/tool' 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 reservDialog = ref(null)
const tabOptions = ref(['进行中', '已结束']) const tabOptions = ref(['进行中', '已结束'])
const tabActive = ref('进行中') const tabActive = ref('进行中')
const dataList = ref([]) const dataList = ref([])
const activeDataList = computed(() => { const toolStore = useToolState()
const userStore = useUserStore()
/*const activeDataList = computed(() => {
return dataList.value.filter((item) => { return dataList.value.filter((item) => {
return item.status !== '已结束' return item.status !== '已结束'
}) })
})*/
const props = defineProps({
curNode: {
type: Object,
default: () => {}
}
}) })
const deleteReserv = (item) => { const deleteReserv = (item) => {
dataList.value = dataList.value.filter((is) => { dataList.value = dataList.value.filter((is) => {
return is.id !== item.id return is.id !== item.id
}) })
} }
const doneDataList = computed(() => { /*const doneDataList = computed(() => {
return dataList.value.filter((item) => { return dataList.value.filter((item) => {
return item.status === '已结束' return item.status === '已结束'
}) })
}) })*/
// //
const getData = () => { 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 || [] const list = res.data || []
list.sort((a,b) => { if(a.status=='上课中') return -1; else return 0 }) list.sort((a,b) => { if(a.status=='上课中') return -1; else return 0 })
dataList.value = list dataList.value = list
}) })*/
} }
const toolStore = useToolState()
watch( watch(
() => [dataList,toolStore.isToolWin], () => [dataList,toolStore.isToolWin,props.curNode],
() => { () => {
console.log('====',toolStore)
setTimeout(()=>{ setTimeout(()=>{
getData() // getData() //
},300) },300)
@ -81,13 +99,14 @@ onMounted(() => {
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 15px 30px; //padding: 15px 10px;
.class-reserv-tabs { .class-reserv-tabs {
width: 30%; width: 30%;
text-align: left; text-align: left;
} }
.class-reserv-body { .class-reserv-body {
height: 100%; height: 100%;
font-size: 12px;
flex: 1; flex: 1;
overflow: auto; overflow: auto;
padding: 10px 0; 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> <template>
<div class="class-reserv-item"> <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-body">
<div class="class-reserv-item-title1"> {{ item.classDay }}&nbsp;{{ item.startTime }}
<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>
</div> </div>
<div class="class-reserv-item-tool"> <div style="flex: 1;max-width: 400px">
<el-button v-if="item.status !== '已结束'" :disabled="toolStore.isToolWin" type="primary" @click="startClassR(item)" <span v-for="(tag, index) in item.classItemList" :key="index">{{ index === 0 ? tag.name : '' + tag.name }}</span>
>{{item.status == '上课中'?'上课中':'上课'}}</el-button </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 === '未开始'" @click="openEdit">编辑</el-button>-->
<!-- <el-button v-if="item.status === '上课中'" type="info" @click="endClassR(item)" <el-button v-if="item.status === '上课中'" size="small" type="info" @click="endClassR(item)"
>下课</el-button >下课</el-button
>--> >
<el-button v-if="item.status!='上课中'" type="danger" @click="deleteReserv">删除</el-button>
</div> </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> </div>
</template> </template>
<script setup> <script setup>
@ -100,25 +93,24 @@ const endClassR = (item) => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.class-reserv-item { .class-reserv-item {
font-size: 13px;
display: flex; display: flex;
background-color: white; background-color: white;
border-radius: 10px; border-radius: 10px;
padding: 5px; padding: 5px;
margin-bottom: 10px; margin-bottom: 10px;
.class-reserv-item-img { .class-reserv-item-img {
width: 80px; width: 60px;
padding-left: 20px;
img { img {
width: 100%; width: 100%;
} }
} }
.class-reserv-item-body { .class-reserv-item-body {
flex: 1;
display: flex; display: flex;
flex-direction: column; align-items: center;
text-align: left; text-align: left;
padding-left: 30px; padding-left: 5px;
font-size: 14px; width: 120px;
.class-reserv-item-title1 { .class-reserv-item-title1 {
flex: 1; flex: 1;
label { label {

View File

@ -102,6 +102,10 @@ import { deleteSmarttalk, updateSmarttalk, getPrepareById } from '@/api/file'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import outLink from '@/utils/linkConfig' import outLink from '@/utils/linkConfig'
import { sessionStore } from '@/utils/store' 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 || {} const { ipcRenderer } = window.electron || {}
export default { export default {
@ -142,8 +146,87 @@ export default {
this.userInfo = useUserStore().user this.userInfo = useUserStore().user
}, },
methods: { 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) { 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) { editTalk(item) {
ElMessageBox.prompt('请输入新的标签', '添加标签', { ElMessageBox.prompt('请输入新的标签', '添加标签', {

View File

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