二期:预约开发

This commit is contained in:
朱浩 2024-08-09 17:20:55 +08:00
parent ae500c94ce
commit c2876ff983
9 changed files with 81 additions and 34 deletions

View File

@ -20,7 +20,7 @@ export function shareStorePlugin({store}) {
function stateSync(store) { function stateSync(store) {
const storeName = store.$id const storeName = store.$id
const jsonStr = JSON.stringify(store.$state) const jsonStr = JSON.stringify(store.$state)
// console.log('state-change', jsonStr, storeName) console.log('state-change', jsonStr, storeName)
// 通知主线程更新 // 通知主线程更新
ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr) ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
} }

View File

@ -24,10 +24,11 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted, computed } from 'vue' import { ref, onMounted, computed, watch } from 'vue'
import { getSelfReserv } from '@/api/classManage' import { getSelfReserv } from '@/api/classManage'
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'
const reservDialog = ref(null) const reservDialog = ref(null)
const tabOptions = ref(['进行中', '已结束']) const tabOptions = ref(['进行中', '已结束'])
const tabActive = ref('进行中') const tabActive = ref('进行中')
@ -48,6 +49,15 @@ const doneDataList = computed(() => {
return item.status === '已结束' return item.status === '已结束'
}) })
}) })
const toolStore = useToolState()
watch(
() => toolStore.isToolWin,
(newD, oldD) => {
getSelfReserv().then((res) => {
dataList.value = [...res.data]
})
}
)
onMounted(() => { onMounted(() => {
getSelfReserv().then((res) => { getSelfReserv().then((res) => {
dataList.value = res.data dataList.value = res.data

View File

@ -24,16 +24,20 @@
>上课</el-button >上课</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 === '上课中'" type="info" @click="endClassR(item)"
>下课</el-button >下课</el-button
> >-->
<el-button type="danger" @click="deleteReserv">删除</el-button> <el-button type="danger" @click="deleteReserv">删除</el-button>
</div> </div>
</div> </div>
</template> </template>
<script setup> <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 { deleteSmartReserv, startClass, endClass } from '@/api/classManage'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { listEntpcourse } from '@/api/teaching/classwork'
const emit = defineEmits(['openEdit', 'deleteReserv']) const emit = defineEmits(['openEdit', 'deleteReserv'])
const props = defineProps({ const props = defineProps({
item: { item: {
@ -59,15 +63,26 @@ const deleteReserv = () => {
const startClassR = (item) => { const startClassR = (item) => {
startClass(item.id).then((res) => { startClass(item.id).then((res) => {
if (res.data === true) { if (res.data === true) {
ElMessage({
message: '上课成功',
type: 'success'
})
item.status = '上课中' item.status = '上课中'
openLesson()
}
})
}
const toolStore = useToolState()
// -
const openLesson = () => {
if (toolStore.isToolWin) return ElMessage.error('您当前已开始上课,请勿重复操作')
startClass(props.item.id)
listEntpcourse({
evalid: props.item.ex2,
edituserid: useUserStore().user.userId,
pageSize: 500
}).then(res=>{
if (res.rows[0].id) {
createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + res.rows[0].id + "&reservId=" + props.item.id })
} }
}) })
} }
const endClassR = (item) => { const endClassR = (item) => {
endClass(item.id).then((res) => { endClass(item.id).then((res) => {
if (res.data === true) { if (res.data === true) {

View File

@ -81,6 +81,7 @@ import { ref, defineExpose, onMounted, reactive, computed, watch } from 'vue'
import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage' import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
const emit = defineEmits(['addSuccess'])
const props = defineProps({ const props = defineProps({
bookId: { bookId: {
type: Number, type: Number,
@ -232,6 +233,7 @@ const addClassReserv = (formData) => {
type: 'success', type: 'success',
message: '预约成功!' message: '预约成功!'
}) })
emit('addSuccess')
} else { } else {
ElMessage({ ElMessage({
type: 'error', type: 'error',

View File

@ -3,8 +3,9 @@
<ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" /> <ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" />
<div class="page-right"> <div class="page-right">
<div class="header-top flex"> <div class="header-top flex">
<div class="textbook-img" @click="navtoPdf"> <div class="textbook-img">
<el-image style="width: 80px; height: 110px" :src="curBookImg" /> <el-image style="width: 80px; height: 110px" :src="curBookImg" @click="navtoPdf"/>
<el-progress v-if="downloadNum>0 && downloadNum < 100" style="position:absolute;left: 0;z-index: 999;" type="circle" :percentage="downloadNum" />
</div> </div>
<div class="top-item"> <div class="top-item">
<el-button class="btn" @click="handleOutLink('standard')">课标研读</el-button> <el-button class="btn" @click="handleOutLink('standard')">课标研读</el-button>
@ -12,7 +13,7 @@
<el-button class="btn" @click="handleOutLink('gk')">高考研读</el-button> <el-button class="btn" @click="handleOutLink('gk')">高考研读</el-button>
<el-button class="btn" @click="handleOutLink('aiModel')">教学大模型</el-button> <el-button class="btn" @click="handleOutLink('aiModel')">教学大模型</el-button>
</div> </div>
<el-button type="primary" class="to-class-btn" @click="openLesson"> <el-button :type="!curClassReserv.id?'info' : 'primary'" :disabled="!curClassReserv.id" class="to-class-btn" @click="openLesson">
<label><i class="iconfont icon-lingdang"></i>上课</label> <label><i class="iconfont icon-lingdang"></i>上课</label>
<label>{{ curClassReserv.classDay }} {{ getWeekday1(curClassReserv.classDay) }}</label> <label>{{ curClassReserv.classDay }} {{ getWeekday1(curClassReserv.classDay) }}</label>
<label>{{ curClassReserv.startTime }}-{{ curClassReserv.endTime }}</label> <label>{{ curClassReserv.startTime }}-{{ curClassReserv.endTime }}</label>
@ -104,7 +105,7 @@
@on-close="closeHomework" @on-close="closeHomework"
/> />
</div> </div>
<reserv ref="reservDialog" :current-node="currentNode" :book-id="uploadData.textbookId"></reserv> <reserv ref="reservDialog" @add-success="initReserv" :current-node="currentNode" :book-id="uploadData.textbookId"></reserv>
</template> </template>
<script setup> <script setup>
import { Check } from '@element-plus/icons-vue' import { Check } from '@element-plus/icons-vue'
@ -131,7 +132,8 @@ import outLink from '@/utils/linkConfig'
import { createWindow } from '@/utils/tool' import { createWindow } from '@/utils/tool'
import { uniqBy, cloneDeep } from 'lodash' import { uniqBy, cloneDeep } from 'lodash'
import { delClasswork, addEntpcourse } from '@/api/teaching/classwork' import { delClasswork, addEntpcourse } from '@/api/teaching/classwork'
import { getSelfReserv } from '@/api/classManage' import { getSelfReserv, startClass } from '@/api/classManage'
const toolStore = useToolState()
const fs = require('fs') const fs = require('fs')
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
@ -161,6 +163,7 @@ export default {
currentWorkList: [], currentWorkList: [],
curBookPath: '', curBookPath: '',
curClassReserv: {}, curClassReserv: {},
downloadNum: 0,
lastAsyncAllTime: '', lastAsyncAllTime: '',
uploadData: { uploadData: {
textbookId: null, textbookId: null,
@ -202,24 +205,33 @@ export default {
this.callback(param) this.callback(param)
}) })
this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime') this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime')
this.initReserv()
}, },
mounted() { mounted() {
getSelfReserv().then((res) => { this.$watch(()=>toolStore.isToolWin,(newD, oldD)=>{
let list = res.data.filter((item) => { setTimeout(this.initReserv, 500)
return item.status !== '已结束'
})
if (list.length > 0) {
this.curClassReserv = list[list.length - 1]
}
}) })
}, },
activated() { activated() {
if (this.uploadData.textbookId !== null) { if (this.uploadData.textbookId !== null) {
this.asyncAllFile() this.asyncAllFile()
this.initHomeWork() this.initHomeWork()
this.initReserv()
} }
}, },
methods: { methods: {
initReserv() {
getSelfReserv().then((res) => {
let list = res.data.filter((item) => {
return item.status !== '已结束'
})
if (list.length > 0) {
this.curClassReserv = list[list.length - 1]
}else {
this.curClassReserv = {}
}
})
},
getBookPathFromServer() { getBookPathFromServer() {
let fileName = this.curBookPath let fileName = this.curBookPath
if (!fileName) return if (!fileName) return
@ -255,8 +267,7 @@ export default {
}) })
}, },
progDownFile(e, num) { progDownFile(e, num) {
console.log(num) this.downloadNum = num
//TODO
}, },
createFile() { createFile() {
creatPPT(this.currentNode.label + '.pptx', this.uploadData).then((res) => { creatPPT(this.currentNode.label + '.pptx', this.uploadData).then((res) => {
@ -559,7 +570,6 @@ export default {
// PDF- // PDF-
async navtoPdf() { async navtoPdf() {
const toolStore = useToolState()
if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作') if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
let path = await this.getBookPathFromServer() let path = await this.getBookPathFromServer()
createWindow('open-PDF', { createWindow('open-PDF', {
@ -570,7 +580,8 @@ export default {
openLesson() { openLesson() {
const toolStore = useToolState() const toolStore = useToolState()
if (toolStore.isToolWin) return this.$message.error('您当前已开始上课,请勿重复操作') if (toolStore.isToolWin) return this.$message.error('您当前已开始上课,请勿重复操作')
createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + this.entpcourseid }) startClass(this.curClassReserv.id)
createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + this.entpcourseid + "&reservId=" + this.curClassReserv.id })
} }
} }
} }
@ -645,9 +656,14 @@ export default {
overflow: hidden; overflow: hidden;
margin-right: 20px; margin-right: 20px;
z-index: 1; z-index: 1;
position: relative;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
} }
:deep(.el-progress-circle) {
width: 90px!important;
background-color: white;
}
} }
.top-item { .top-item {

View File

@ -30,13 +30,16 @@
<script setup> <script setup>
// electron // electron
import { onMounted, ref, reactive, watchEffect } from 'vue' import { onMounted, ref, reactive, watchEffect } from 'vue'
import { useRoute } from 'vue-router';
import logo from '@root/resources/icon.png' // logo import logo from '@root/resources/icon.png' // logo
import boardVue from './components/board.vue' // - import boardVue from './components/board.vue' // -
import sideVue from './components/side.vue' // - import sideVue from './components/side.vue' // -
import vDrag from './directive/drag' // - import vDrag from './directive/drag' // -
import vIgnore from './directive/ignore' // -穿 import vIgnore from './directive/ignore' // -穿
import { endClass } from '@/api/classManage'
import { useToolState } from '@/store/modules/tool' import { useToolState } from '@/store/modules/tool'
import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' // import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' //
const route = useRoute();
const tabActive = ref('select') // const tabActive = ref('select') //
const isFold = ref(false) // const isFold = ref(false) //
const isDrag = ref(false) // const isDrag = ref(false) //
@ -111,6 +114,7 @@ const sideChange = o => {
break break
case 'over': // case 'over': //
toolStore.isToolWin = false toolStore.isToolWin = false
endClass(route.query.reservId)
ipcMsgSend('tool-sphere:close') ipcMsgSend('tool-sphere:close')
break break
} }