From bbed835ffe81dae2c2ec2beefa7f2da87c6ef3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=A8?= <666> Date: Thu, 12 Dec 2024 10:52:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9ppt=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B4=BB=E5=8A=A8=E7=9A=84bug=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/AixPPTist/src/api/index.ts | 60 ++++++++----------- .../src/AixPPTist/src/store/slides.ts | 44 ++++++++++++-- .../ElementStylePanel/Active/index.vue | 29 +++++++-- 3 files changed, 86 insertions(+), 47 deletions(-) diff --git a/src/renderer/src/AixPPTist/src/api/index.ts b/src/renderer/src/AixPPTist/src/api/index.ts index 057dcf3..aa255d2 100644 --- a/src/renderer/src/AixPPTist/src/api/index.ts +++ b/src/renderer/src/AixPPTist/src/api/index.ts @@ -3,22 +3,22 @@ * @author zdg * @date 2024-11-26 */ -import { toRaw, nextTick } from 'vue' +import { toRaw } from 'vue' import type { Result } from './types' // 接口类型 import msgUtils from '@/plugins/modal' // 消息工具 import * as API_entpcoursefile from '@/api/education/entpcoursefile' // 相关api import * as API_smarttalk from '@/api/file' // 相关api -import * as Api_server from '@/api/apiService' // 相关api -import * as CreateHomework from '@/views/tool/createHomework' // 统计相关 import * as useStore from '../store' // pptist-状态管理 import { sessionStore } from '@/utils/store' // electron-store 状态管理 import useUserStore from '@/store/modules/user' // 外部-用户信息 -import { toPng, toJpeg } from 'html-to-image' // 引入html-to-image库 -// import * as commUtils from '@/utils/comm.js' -import { createWindow } from '@/utils/tool' -import { useToolState } from '@/store/modules/tool' +import * as Api_server from '@/api/apiService' // 相关api +import * as commUtils from '@/utils/comm.js' const slidesStore = useStore.useSlidesStore() const userStore = useUserStore() + +import { getClassWorkList,getStudentClassWorkData } from '@/views/tool/createHomework' +import {createWindow} from '@/utils/tool' +import { useToolState } from '@/store/modules/tool' const toolStore = useToolState() /** 工具类 */ export class Utils { @@ -147,8 +147,6 @@ export class PPTApi { // 更新幻灯片 static updateSlide(data: object): Promise { return new Promise(async (resolve, reject) => { - const thumUrl = await this.getSlideThumUrl() - data.base64Code = thumUrl // 更新缩略图 const res: Result = await API_entpcoursefile.updateEntpcoursefileNew(data) console.log(data,'data'); console.log(res,'dresata'); @@ -193,40 +191,30 @@ export class PPTApi { else msgUtils.msgError(res.msg || '更新失败');return false }) } - // thumbnail-slide thumbnail - static getSlideThumUrl(): Promise { - return nextTick().then(async() => { - const slideIndex = slidesStore.slideIndex - const elements = document.querySelectorAll('.thumbnail-slide') - if (elements.length && slideIndex >= 0) { - const element = elements[slideIndex] - return await toPng(element) - } - return null - }) - } // 图片|音频|视频 转换为在线地址 - static toRousrceUrl =async (file: File|any) => { - const formData = new FormData() - formData.append('file', file) - const res = await Api_server.Other.uploadFile(formData) - if (res && res.code == 200){ - const url = res?.url - url &&(o.src = url) - return url - } - } + static toRousrceUrl =async (o:any) => { + const formData = new FormData() + formData.append('file', o) + const res = await Api_server.Other.uploadFile(formData) + if (res && res.code == 200){ + const url = res?.url + url &&(o.src = url) + return url + } + +} } export class Homework{ // 作业弹窗 static async showHomework(id: any) { - let result = await CreateHomework.getClassWorkList(id) - result = await CreateHomework.getStudentClassWorkData() - localStorage.setItem('teachClassWorkItem', JSON.stringify(result[0])); - toolStore.isTaskWin=true; // 设置打开批改窗口 - createWindow('open-taskwin',{url:'/teachClassTask'}); + let result = await getClassWorkList(id) +   result = await getStudentClassWorkData() +   localStorage.setItem('teachClassWorkItem', JSON.stringify(result[0])); +   toolStore.isTaskWin=true; // 设置打开批改窗口 + //   emit('closeActive') +   createWindow('open-taskwin',{url:'/teachClassTask'}); } } export default PPTApi \ No newline at end of file diff --git a/src/renderer/src/AixPPTist/src/store/slides.ts b/src/renderer/src/AixPPTist/src/store/slides.ts index 78e9d02..79f1e66 100644 --- a/src/renderer/src/AixPPTist/src/store/slides.ts +++ b/src/renderer/src/AixPPTist/src/store/slides.ts @@ -5,9 +5,12 @@ import type { Slide, SlideTheme, PPTElement, PPTAnimation } from '../types/slide import { slides } from '../mocks/slides' import { theme } from '../mocks/theme' import { layouts } from '../mocks/layout' +import { sessionStore } from '@/utils/store' // electron-store 状态管理 +import useUserStore from '@/store/modules/user' // 外部-用户信息 +import * as API_entpcoursefile from '@/api/education/entpcoursefile' // 相关api import PPTApi from '../api/store' - +const userStore = useUserStore() interface RemovePropData { id: string propName: string | string[] @@ -142,16 +145,46 @@ export const useSlidesStore = defineStore('slides', { setWorkItem(list: Object[]) { this.workItem = list }, + addWorkItem(data: any) { + const id = data?.parentid + if (!id) return + this.workItem.splice(this.slideIndex, 0, data) + }, addSlide(slide: Slide | Slide[]) { + const resource = sessionStore.get('curr.resource')||{} + const enpt = sessionStore.get('curr.entp')||{} + const {id, ...content} = slide + const params = { + parentid: resource.id, + activityContent:null, + entpid: userStore.user.deptId, + entpcourseid: enpt.id, + ppttype: 'file', + title: '', + fileurl: '', + filetype: 'slide', + datacontent: JSON.stringify(content), + filekey: '', + filetag: '', + fileidx: 0, + dflag: 0, + status: '', + edituserid: userStore.id, + } const slides = Array.isArray(slide) ? slide : [slide] for (const slide of slides) { if (slide.sectionTag) delete slide.sectionTag } - - const addIndex = this.slideIndex + 1 - this.slides.splice(addIndex, 0, ...slides) - this.slideIndex = addIndex + API_entpcoursefile.addEntpcoursefileReturnId(params).then((rid:number) => { + if(!!rid){ + params.id = rid + this.addWorkItem(params) + const addIndex = this.slideIndex + 1 + this.slides.splice(addIndex, 0, ...slides) + this.slideIndex = addIndex + } + }) }, updateSlide(props: Partial, slideId?: string) { @@ -188,6 +221,7 @@ export const useSlidesStore = defineStore('slides', { const isDel = await PPTApi.delSlide(deletedId) if (isDel) { // 后端删除成功,更新页面数据 + this.workItem.splice(index, 1) deleteSlidesIndex.push(index) slides.splice(index, 1) } diff --git a/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue b/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue index bc658cf..b1fb593 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/Toolbar/ElementStylePanel/Active/index.vue @@ -36,8 +36,8 @@
{{item.worktype}} - -
{{item.evaltitle}}
+ +
{{item.uniquekey}}
删除
@@ -62,7 +62,7 @@ > - +