diff --git a/src/main/file.js b/src/main/file.js index c671519..9cc20ea 100644 --- a/src/main/file.js +++ b/src/main/file.js @@ -201,7 +201,8 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { /*创建新的ppt文件*/ ipcMain.on('creat-file-default', (e, { name, uploadData, cookie }) => { createFolder('tempFile').then(() => { - let path = appTempFilePath + name + let path = appTempFilePath + name.replace(/[\\/:*?"<>|]/, '') + console.log(path) fs.writeFileSync(path, '', 'utf-8') let fileType = 'application/vnd.openxmlformats-officedocument.presentationml.presentation' let formData = new FormData() @@ -237,37 +238,41 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) { //下载文件 ipcMain.on('download-file-default', (e, { url, fileName }) => { - createFolder('selfFile').then(async () => { - const browserWindow = BrowserWindow.getFocusedWindow() - const id = await manager.download({ - window: browserWindow, - url: url, - saveAsFilename: fileName, - directory: appRootFilePath, - callbacks: { - onDownloadStarted: async ({ id, item, webContents }) => { - // Do something with the download id - }, - onDownloadProgress: async ({ id, item, percentCompleted }) => {}, - onDownloadCompleted: async ({ id, item }) => { - console.log('完成') - e.reply('download-file-default' + fileName, true) - }, - onDownloadCancelled: async () => { - console.log('取消') - e.reply('download-file-default' + fileName, false) - }, - onDownloadInterrupted: async () => { - console.log('中断') - e.reply('download-file-default' + fileName, false) - }, - onError: (err, data) => { - console.log(err.toString()) - e.reply('download-file-default' + fileName, false) + createFolder('selfFile') + .then(async () => { + const browserWindow = BrowserWindow.getFocusedWindow() + const id = await manager.download({ + window: browserWindow, + url: url, + saveAsFilename: fileName, + directory: appRootFilePath, + callbacks: { + onDownloadStarted: async ({ id, item, webContents }) => { + // Do something with the download id + }, + onDownloadProgress: async ({ id, item, percentCompleted }) => {}, + onDownloadCompleted: async ({ id, item }) => { + console.log('完成') + e.reply('download-file-default' + fileName, true) + }, + onDownloadCancelled: async () => { + console.log('取消') + e.reply('download-file-default' + fileName, false) + }, + onDownloadInterrupted: async () => { + console.log('中断') + e.reply('download-file-default' + fileName, false) + }, + onError: (err, data) => { + console.log(err.toString()) + e.reply('download-file-default' + fileName, false) + } } - } + }) + }) + .catch((error) => { + e.reply('download-file-default' + fileName, false) }) - }) }) /**另存为... diff --git a/src/renderer/src/views/prepare/container/reserv.vue b/src/renderer/src/views/prepare/container/reserv.vue index 1ab31db..4288303 100644 --- a/src/renderer/src/views/prepare/container/reserv.vue +++ b/src/renderer/src/views/prepare/container/reserv.vue @@ -4,60 +4,74 @@ class="reserv-dialog" title="预约课程" destroy-on-close + :before-close="closeDialog" width="600" style="text-align: left" > - - + + - + - +
{{ locationMessage }}
- - - + + + + + - - - - + + + + + - - - {{item.caption}}({{item.classstudentcount}})人 - + + + {{ item.caption }}({{ item.classstudentcount }})人 + + - +
@@ -66,17 +80,24 @@ import { ref, defineExpose, onMounted, reactive, computed } from 'vue' import { listClassmain } from '@/api/classManage' import useUserStore from '@/store/modules/user' +const ruleFormDialog = ref(null) const userStore = useUserStore().user const centerDialogVisible = ref(false) const form = reactive({ name: '', type: '常规课', - delivery: false, - day:'', - time:'', - resource: '', + day: '', + time: '', + resource: [], classRoom: '' }) +const ruleForm = reactive({ + name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }], + day: [{ required: true, message: '请选择上课日期', trigger: 'change' }], + time: [{ required: true, message: '请选择上课时间', trigger: 'change' }], + classRoom: [{ required: false, message: '请选择上课时间', trigger: 'change' }], + resource: [{ required: true, message: '请选择授课对象', trigger: 'change' }] +}) const locationOptions = [ { label: '常规课', @@ -85,9 +106,9 @@ const locationOptions = [ message: '现场公屏授课,学生无需长时间打开平板上。' }, { - label: '公开课', - value: '公开课', - disabled: true, + label: '互动课', + value: '互动课', + disabled: false, message: '现场公屏授课,学生需打开平开与老师进行互动,如点赞、互动作业。' }, { @@ -104,6 +125,7 @@ const openDialog = () => { centerDialogVisible.value = true } const closeDialog = () => { + ruleFormDialog.value.resetFields() centerDialogVisible.value = false } const classList = ref([]) @@ -114,6 +136,15 @@ onMounted(() => { } ) }) +const submitForm = async () => { + const formEl = ruleFormDialog.value + if (!formEl) return + await formEl.validate((valid) => { + if (valid) { + centerDialogVisible.value = false + } + }) +} defineExpose({ openDialog, closeDialog diff --git a/src/renderer/src/views/prepare/index.vue b/src/renderer/src/views/prepare/index.vue index 4f66edc..f3fafc1 100644 --- a/src/renderer/src/views/prepare/index.vue +++ b/src/renderer/src/views/prepare/index.vue @@ -13,7 +13,8 @@ 教学大模型 - 上课 + 上课
@@ -22,7 +23,13 @@ @@ -40,24 +47,60 @@ 作业反馈 布置作业 上传资料 - 新建课件 + 新建课件
- - - + + + + + + - + :choose="checkFileList" + :check-all="isCheckAll" + @click-delete="clickDelete" + @click-move="clickMove" + @cancel="checkFileList = []" + @click-choose="clickChoose" + > - + @@ -85,7 +128,7 @@ 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'); +const fs = require('fs') const { ipcRenderer } = window.electron || {} export default { @@ -111,6 +154,7 @@ export default { fileList: [], currentNode: {}, currentFileList: [], + currentWorkList: [], curBookPath: '', lastAsyncAllTime: '', uploadData: { @@ -154,7 +198,7 @@ export default { }) this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime') }, - mounted() { }, + mounted() {}, activated() { if (this.uploadData.textbookId !== null) { this.asyncAllFile() @@ -166,7 +210,7 @@ export default { let fileName = this.curBookPath if (!fileName) return fileName = fileName.replace('.txt', '.pdf') - return new Promise((resolve, reject)=>{ + return new Promise((resolve, reject) => { const userDataPath = Remote.app.getPath('userData') const appRootFilePath = userDataPath + '\\selfFile\\' let filePath = appRootFilePath + fileName @@ -181,14 +225,14 @@ export default { 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) } }) @@ -313,7 +357,6 @@ export default { }) }, async nodeClick(data) { - console.log(data) if (this.currentNode.id === data.node.id) return this.curBookImg = data.textBook.curBookImg this.curBookPath = data.textBook.curBookPath @@ -326,9 +369,9 @@ export default { this.uploadData.textbookId = data.textBook.curBookId this.initHomeWork() await this.asyncAllFile() - }, async initHomeWork() { + this.currentWorkList = [] if (this.timerId) { clearInterval(this.timerId) } @@ -337,11 +380,10 @@ export default { let { rows } = await this.getChapterId() if (rows.length > 0) { this.entpcourseid = rows[0].id - } - else{ - await this.createEntpcourse() - let { rows } = await this.getChapterId() - this.entpcourseid = rows[0].id + } else { + await this.createEntpcourse() + let { rows } = await this.getChapterId() + this.entpcourseid = rows[0].id } // 查询作业 @@ -350,27 +392,27 @@ export default { }, // 创建新的entpcourse createEntpcourse() { - var cform = {}; - cform.entpid = this.userStore.deptId; - cform.level = 1; - cform.parentid = 0; - cform.dictid = 0; - cform.evalid = this.currentNode.id; - cform.evalparentid = 0; - cform.edusubject = this.currentNode.edusubject; - cform.edudegree = this.currentNode.edudegree; - cform.edustage = this.currentNode.edustage; - cform.coursetype = '课标学科'; - cform.coursetitle = this.currentNode.itemtitle; - cform.coursedesc = ''; - cform.status = ''; - cform.dflag = 0; - cform.edituserid = this.userStore.userId; - cform.createblankfile = 'yes'; + var cform = {} + cform.entpid = this.userStore.deptId + cform.level = 1 + cform.parentid = 0 + cform.dictid = 0 + cform.evalid = this.currentNode.id + cform.evalparentid = 0 + cform.edusubject = this.currentNode.edusubject + cform.edudegree = this.currentNode.edudegree + cform.edustage = this.currentNode.edustage + cform.coursetype = '课标学科' + cform.coursetitle = this.currentNode.itemtitle + cform.coursedesc = '' + cform.status = '' + cform.dflag = 0 + cform.edituserid = this.userStore.userId + cform.createblankfile = 'yes' return addEntpcourse(cform) }, - openReserv(){ - // this.$refs['reservDialog'].openDialog() + openReserv() { + this.$refs['reservDialog'].openDialog() }, // 打开外部链接 handleOutLink(key) { @@ -462,9 +504,9 @@ export default { } } // 去重 - let ary = uniqBy([...this.currentFileList, ...list], 'id') + let ary = uniqBy([...list], 'id') // 深度克隆 - this.currentFileList = cloneDeep(ary) + this.currentWorkList = cloneDeep(ary) }) }, // 打开布置作业窗口 @@ -475,14 +517,16 @@ export default { // 删除作业 delhomework(item) { this.isLoading = true - delClasswork(item.id).then(async res => { - ElMessage.success('操作成功') - this.isLoading = false - await this.asyncAllFile() - this.getHomeWorkList() - }).catch(() => { - this.isLoading = false - }) + delClasswork(item.id) + .then(async (res) => { + ElMessage.success('操作成功') + this.isLoading = false + await this.asyncAllFile() + this.getHomeWorkList() + }) + .catch(() => { + this.isLoading = false + }) }, closeHomework() { this.setDialog = false