Merge pull request 'zhuhao_dev' (#114) from zhuhao_dev into main

Reviewed-on: #114
This commit is contained in:
朱浩 2024-08-09 17:27:14 +08:00
commit 74275ac327
14 changed files with 450 additions and 34 deletions

View File

@ -24,8 +24,8 @@ export default defineConfig({
server: {
proxy: {
'/dev-api': {
target: 'http://27.128.240.72:7865',
// target: 'http://192.168.2.52:7863',
// target: 'http://27.128.240.72:7865',
target: 'http://192.168.2.52:7863',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '')
}

View File

@ -250,7 +250,9 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
onDownloadStarted: async ({ id, item, webContents }) => {
// Do something with the download id
},
onDownloadProgress: async ({ id, item, percentCompleted }) => {},
onDownloadProgress: async ({ id, item, percentCompleted }) => {
e.reply('download-file-default-prog' + fileName, percentCompleted)
},
onDownloadCompleted: async ({ id, item }) => {
console.log('完成')
e.reply('download-file-default' + fileName, true)

View File

@ -243,4 +243,4 @@ function handleAll() {
}
}
})
}
}

View File

@ -130,3 +130,46 @@ export function addStudentmainByNameArray(data) {
data: data
})
}
//新增课程预约
export function addSmartClassReserv(data) {
return request({
url: '/smarttalk/classReserv/addSmartClassReserv',
method: 'post',
data: data
})
}
//修改课程预约
export function updateSmartClassReserv(data) {
return request({
url: '/smarttalk/classReserv/updateSmartClassReserv',
method: 'post',
data: data
})
}
//查询课程预约
export function getSelfReserv() {
return request({
url: '/smarttalk/classReserv/getSelfReserv',
method: 'get'
})
}
export function deleteSmartReserv(id) {
return request({
url: '/smarttalk/classReserv/' + id,
method: 'delete'
})
}
export function startClass(id) {
return request({
url: '/smarttalk/classReserv/startClass',
method: 'get',
params: {id}
})
}
export function endClass(id) {
return request({
url: '/smarttalk/classReserv/endClass',
method: 'get',
params: {id}
})
}

View File

@ -35,6 +35,7 @@
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="changePage('/profile')">个人中心</el-dropdown-item>
<el-dropdown-item @click="changePage('/classReserv')">课程预约</el-dropdown-item>
<el-dropdown-item @click="changePage('/class')">班级中心</el-dropdown-item>
<el-dropdown-item divided command="logout">
<span>退出登录</span>

View File

@ -20,7 +20,7 @@ export function shareStorePlugin({store}) {
function stateSync(store) {
const storeName = store.$id
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)
}
@ -37,7 +37,7 @@ function stateChange(store) {
// 更新状态
store.$patch(stateJson)
// 您可以通过将其 $state 属性设置为新对象来替换 Store 的整个状态
// store.$state = stateJson
// store.$state = stateJson
}
})
}
}

View File

@ -45,6 +45,12 @@ export const constantRoutes = [
name: 'profile',
meta: {title: '个人中心'}
},
{
path: '/classReserv',
component: () => import('@/views/classManage/classReserv.vue'),
name: 'classReserv',
meta: {title: '课程预约'}
},
{
path: '/class',
component: () => import('@/views/classManage/index.vue'),

View File

@ -12,4 +12,4 @@ export const useToolState = defineStore('tool', {
}),
actions: {
}
})
})

View File

@ -19,7 +19,7 @@ const isDev = isNode?process.env.NODE_ENV !== 'production':''
export const ipcMain = Remote?.ipcMain || {}
/**
* 获取静态资源开发和生产环境
* @param {*} url
* @param {*} url
* @param {*} type 类型 app 应用内 user (用户目录 selfFile 自定义文件路径)
* @returns
*/
@ -67,9 +67,9 @@ export function ipcMsgInvoke(key, ...args) {
/**
* @description 封装ipcRenderer事件监听
* @param {*} fn on once handle invoke
* @param {*} key
* @param {*} key
* @param {Function} cb 回调函数
* @returns
* @returns
*/
export function ipcHandle(fn,key, cb) {
return ipcRenderer[fn](key, cb)

View File

@ -0,0 +1,85 @@
<template>
<el-container class="class-reserv-wrap">
<div class="class-reserv-tabs">
<el-segmented v-model="tabActive" block :options="tabOptions" size="large" />
</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"
></reserv-item>
</div>
<reserv ref="reservDialog"></reserv>
</el-container>
</template>
<script setup>
import { ref, onMounted, computed, watch } from 'vue'
import { getSelfReserv } from '@/api/classManage'
import ReservItem from '@/views/classManage/reserv-item.vue'
import Reserv from '@/views/prepare/container/reserv.vue'
import { useToolState } from '@/store/modules/tool'
const reservDialog = ref(null)
const tabOptions = ref(['进行中', '已结束'])
const tabActive = ref('进行中')
const dataList = ref([])
const activeDataList = computed(() => {
return dataList.value.filter((item) => {
return item.status !== '已结束'
})
})
const deleteReserv = (item) => {
dataList.value = dataList.value.filter((is) => {
return is.id !== item.id
})
}
const doneDataList = computed(() => {
return dataList.value.filter((item) => {
return item.status === '已结束'
})
})
const toolStore = useToolState()
watch(
() => toolStore.isToolWin,
(newD, oldD) => {
getSelfReserv().then((res) => {
dataList.value = [...res.data]
})
}
)
onMounted(() => {
getSelfReserv().then((res) => {
dataList.value = res.data
})
})
</script>
<style scoped lang="scss">
.class-reserv-wrap {
height: 100%;
display: flex;
flex-direction: column;
padding: 15px 30px;
.class-reserv-tabs {
width: 30%;
text-align: left;
}
.class-reserv-body {
height: 100%;
flex: 1;
overflow: auto;
padding: 10px 0;
}
}
</style>

View File

@ -0,0 +1,133 @@
<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>
</div>
<div class="class-reserv-item-tool">
<el-button v-if="item.status !== '已结束'" 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
>-->
<el-button type="danger" @click="deleteReserv">删除</el-button>
</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 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()
}
})
}
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) => {
endClass(item.id).then((res) => {
if (res.data === true) {
ElMessage({
message: '下课成功',
type: 'success'
})
item.status = '已结束'
}
})
}
</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: 80px;
padding-left: 20px;
img {
width: 100%;
}
}
.class-reserv-item-body {
flex: 1;
display: flex;
flex-direction: column;
text-align: left;
padding-left: 30px;
font-size: 14px;
.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

@ -77,20 +77,42 @@
</el-dialog>
</template>
<script setup>
import { ref, defineExpose, onMounted, reactive, computed } from 'vue'
import { listClassmain } from '@/api/classManage'
import { ref, defineExpose, onMounted, reactive, computed, watch } from 'vue'
import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
import useUserStore from '@/store/modules/user'
import { ElMessage } from 'element-plus'
const emit = defineEmits(['addSuccess'])
const props = defineProps({
bookId: {
type: Number,
default: 0
},
currentNode: {
type: Object,
default: () => {
return {}
}
}
})
const ruleFormDialog = ref(null)
const nowType = ref('add')
const userStore = useUserStore().user
const centerDialogVisible = ref(false)
const form = reactive({
name: '',
type: '常规课',
day: '',
time: '',
time: [],
resource: [],
classRoom: ''
})
const updateForm = ref({})
watch(
() => props.currentNode,
(newValue, oldValue) => {
form.name = newValue.label
}
)
const ruleForm = reactive({
name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }],
day: [{ required: true, message: '请选择上课日期', trigger: 'change' }],
@ -121,17 +143,29 @@ const locationOptions = [
const locationMessage = computed(() => {
return locationOptions.find((item) => item.value === form.type).message
})
const openDialog = () => {
const openDialog = (data) => {
if (data) {
updateForm.value = data
nowType.value = 'update'
form.name = data.className
form.type = data.classType
form.day = data.classDay
form.time = [data.startTime, data.endTime]
form.resource = data.classList.split(',').map((item) => parseInt(item))
form.classRoom = data.classRoom
}
centerDialogVisible.value = true
}
const closeDialog = () => {
ruleFormDialog.value.resetFields()
centerDialogVisible.value = false
form.name = props.currentNode.label
}
const classList = ref([])
onMounted(() => {
listClassmain({ classuserid: userStore.userId, pageSize: 100, status: 'open' }).then(
(response) => {
console.log(response)
classList.value = [...response.rows]
}
)
@ -141,10 +175,73 @@ const submitForm = async () => {
if (!formEl) return
await formEl.validate((valid) => {
if (valid) {
if (nowType.value === 'update') {
updateClassReserv(form)
} else {
addClassReserv(form)
}
centerDialogVisible.value = false
}
})
}
const updateClassReserv = (formData) => {
let ids = formData.resource.join(',')
let param = {
className: formData.name,
classType: formData.type,
classDay: formData.day,
startTime: formData.time[0],
endTime: formData.time[1],
classList: ids,
classRoom: formData.classRoom,
id: updateForm.value.id
}
updateSmartClassReserv(param).then((res) => {
if (res.data === true) {
closeDialog()
ElMessage({
type: 'success',
message: '修改预约成功!'
})
Object.assign(updateForm.value, param)
} else {
ElMessage({
type: 'error',
message: res.message
})
}
})
}
const addClassReserv = (formData) => {
let ids = formData.resource.join(',')
let param = {
className: formData.name,
classType: formData.type,
classDay: formData.day,
startTime: formData.time[0],
endTime: formData.time[1],
classList: ids,
classRoom: formData.classRoom,
classSubject: props.currentNode.edusubject,
ex1: props.bookId,
ex2: props.currentNode.id
}
addSmartClassReserv(param).then((res) => {
if (res.data === true) {
closeDialog()
ElMessage({
type: 'success',
message: '预约成功!'
})
emit('addSuccess')
} else {
ElMessage({
type: 'error',
message: res.message
})
}
})
}
defineExpose({
openDialog,
closeDialog

View File

@ -3,8 +3,9 @@
<ChooseTextbook @change-book="nodeClick" @node-click="nodeClick" />
<div class="page-right">
<div class="header-top flex">
<div class="textbook-img" @click="navtoPdf">
<el-image style="width: 80px; height: 110px" :src="curBookImg" />
<div class="textbook-img">
<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 class="top-item">
<el-button class="btn" @click="handleOutLink('standard')">课标研读</el-button>
@ -12,9 +13,11 @@
<el-button class="btn" @click="handleOutLink('gk')">高考研读</el-button>
<el-button class="btn" @click="handleOutLink('aiModel')">教学大模型</el-button>
</div>
<el-button type="primary" class="to-class-btn" @click="openLesson">
<i class="iconfont icon-lingdang"></i>上课</el-button
>
<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>{{ curClassReserv.classDay }} {{ getWeekday1(curClassReserv.classDay) }}</label>
<label>{{ curClassReserv.startTime }}-{{ curClassReserv.endTime }}</label>
</el-button>
<div class="top-zoom-style"></div>
</div>
<div class="prepare-body-header">
@ -60,7 +63,7 @@
<uploadDialog v-model="isDialogOpen" @submit-file="submitFile" />
<SetHomework v-model="setDialog" :entpcourseid="entpcourseid" :row="row" @on-close="closeHomework" />
</div>
<reserv ref="reservDialog"></reserv>
<reserv ref="reservDialog" @add-success="initReserv" :current-node="currentNode" :book-id="uploadData.textbookId"></reserv>
</template>
<script setup>
import { Check } from '@element-plus/icons-vue'
@ -87,7 +90,9 @@ import outLink from '@/utils/linkConfig'
import { createWindow } from '@/utils/tool'
import { uniqBy, cloneDeep } from 'lodash'
import { delClasswork, addEntpcourse } from '@/api/teaching/classwork'
const fs = require('fs');
import { getSelfReserv, startClass } from '@/api/classManage'
const toolStore = useToolState()
const fs = require('fs')
const { ipcRenderer } = window.electron || {}
export default {
@ -114,6 +119,8 @@ export default {
currentNode: {},
currentFileList: [],
curBookPath: '',
curClassReserv: {},
downloadNum: 0,
lastAsyncAllTime: '',
uploadData: {
textbookId: null,
@ -155,15 +162,33 @@ export default {
this.callback(param)
})
this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime')
this.initReserv()
},
mounted() {
this.$watch(()=>toolStore.isToolWin,(newD, oldD)=>{
setTimeout(this.initReserv, 500)
})
},
mounted() { },
activated() {
if (this.uploadData.textbookId !== null) {
this.asyncAllFile()
this.initHomeWork()
this.initReserv()
}
},
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() {
let fileName = this.curBookPath
if (!fileName) return
@ -180,22 +205,27 @@ export default {
url: filePath,
fileName: fileName
})
ipcRenderer.removeListener('download-file-default-prog' + fileName, this.progDownFile)
ipcRenderer.on('download-file-default-prog' + fileName, this.progDownFile)
ipcRenderer.once('download-file-default' + fileName, (e, isSuccess) => {
if (isSuccess === true) {
resolve(appRootFilePath + fileName)
}else {
} else {
ElMessage({
type: 'info',
message: `下载教材失败!`
})
}
})
}else {
} else {
resolve(appRootFilePath + fileName)
}
})
})
},
progDownFile(e, num) {
this.downloadNum = num
},
createFile() {
creatPPT(this.currentNode.label + '.pptx', this.uploadData).then((res) => {
this.currentFileList.unshift(res.resData)
@ -469,6 +499,11 @@ export default {
this.currentFileList = cloneDeep(ary)
})
},
getWeekday1(date) {
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
const weekday = new Date(date).getDay()
return weekdays[weekday]
},
//
openSet(row) {
this.row = row
@ -492,18 +527,18 @@ export default {
// PDF-
async navtoPdf() {
const toolStore = useToolState()
if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
let path = await this.getBookPathFromServer()
path=path.replace(/^.*[\\\/]/, '');
// console.log(this.uploadData.textbookId)
createWindow('open-PDF', { url: '/classBegins/index?textbookId='+this.uploadData.textbookId+'&path='+ path })
createWindow('open-PDF', {
url: '/classBegins/index?textbookId=' + this.uploadData.textbookId + '&path=' + path
})
},
// -
openLesson() {
const toolStore = useToolState()
if (toolStore.isToolWin) return this.$message.error('您当前已开始上课,请勿重复操作')
createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + this.entpcourseid +'&label=' + this.currentNode.label })
startClass(this.curClassReserv.id)
createWindow('tool-sphere', { url: '/tool/sphere?entpcourseid=' + this.entpcourseid +'&label=' + this.currentNode.label+ "&reservId=" + this.curClassReserv.id })
}
}
}
@ -578,9 +613,14 @@ export default {
overflow: hidden;
margin-right: 20px;
z-index: 1;
position: relative;
&:hover {
cursor: pointer;
}
:deep(.el-progress-circle) {
width: 90px!important;
background-color: white;
}
}
.top-item {
@ -617,7 +657,13 @@ export default {
margin-left: 25px;
font-size: 18px;
z-index: 1;
& label:hover {
cursor: pointer !important;
}
& > :deep(span) {
flex-direction: column !important;
font-size: 12px;
}
.icon-lingdang {
margin-right: 5px;
color: #ffffff;

View File

@ -35,7 +35,8 @@
<script setup>
// electron
import { onMounted, ref, reactive, watchEffect } from 'vue'
import { useRoute } from 'vue-router';
import { endClass } from '@/api/classManage'
import logo from '@root/resources/icon.png' // logo
import boardVue from './components/board.vue' // -
import sideVue from './components/side.vue' // -
@ -44,6 +45,7 @@ import vDrag from './directive/drag' // 自定义指令-拖拽
import vIgnore from './directive/ignore' // -穿
import { useToolState } from '@/store/modules/tool' // -
import { ipcMsgSend, ipcHandle, ipcMain, ipcMsgInvoke } from '@/utils/tool' //
const route = useRoute();
const tabActive = ref('select') //
const isFold = ref(false) //
const isDrag = ref(false) //
@ -118,6 +120,7 @@ const sideChange = o => {
break
case 'over': //
toolStore.isToolWin = false
endClass(route.query.reservId)
ipcMsgSend('tool-sphere:close')
break
}
@ -125,7 +128,7 @@ const sideChange = o => {
// === ===
watchEffect(() => {
// , : -
// , : -
const show = !toolStore.isPdfWin && toolStore.showBoardAll
if (show != isShow.value) isShow.value = show
})
@ -177,4 +180,4 @@ watchEffect(() => {
}
}
}
</style>
</style>