From 2511a6cc3212ec3ce2faccfa40943f6fd9fde5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Thu, 21 Nov 2024 15:02:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/api/file/img.js | 42 +++++++++ .../src/components/tinymce/tinymce.vue | 91 +++++++++++-------- .../newClassTaskAssign/myQuestion/index.vue | 1 + .../questionUpload/quesItem/index.vue | 81 ++--------------- .../searchQuestion/index.vue | 4 +- .../Details/classroomPresentation/index.vue | 8 +- 6 files changed, 113 insertions(+), 114 deletions(-) create mode 100644 src/renderer/src/api/file/img.js diff --git a/src/renderer/src/api/file/img.js b/src/renderer/src/api/file/img.js new file mode 100644 index 0000000..6d833e9 --- /dev/null +++ b/src/renderer/src/api/file/img.js @@ -0,0 +1,42 @@ +import request from '@/utils/request' + +// 新增图片存eos +export function saveUploadFile(data) { + return request({ + url: '/education/uploadfile/saveUploadFile', + method: 'post', + headers: { + 'Content-Type': 'multipart/form-data' + }, + data: data + }) +} + +// 新增批量图片存eos +export function saveUploadFiles(data) { + return request({ + url: '/education/uploadfile/saveUploadFiles', + method: 'post', + headers: { + 'Content-Type': 'multipart/form-data' + }, + data: data + }) +} + +// 修改basecomment +export function updateUploadFile(data) { + return request({ + url: '/education/uploadfile', + method: 'put', + data: data + }) +} + +// 删除basecomment +export function delUploadFile(id) { + return request({ + url: '/education/uploadfile/' + id, + method: 'delete' + }) +} \ No newline at end of file diff --git a/src/renderer/src/components/tinymce/tinymce.vue b/src/renderer/src/components/tinymce/tinymce.vue index 30b84ca..4c74536 100644 --- a/src/renderer/src/components/tinymce/tinymce.vue +++ b/src/renderer/src/components/tinymce/tinymce.vue @@ -46,7 +46,8 @@ import "tinymce/plugins/anchor"; //锚点 import { ref, reactive, defineProps, defineEmits, nextTick, onMounted, computed, watch } from 'vue' import { getStaticUrl } from '@/utils/tool' -//import { listUploadfile, getUploadFile, delUploadFile, addUploadFile, saveUploadFile } from "@/api/comm/uploadfile"; +import useUserStore from '@/store/modules/user' +import { saveUploadFile } from "@/api/file/img"; const emits = defineEmits(["update:modelValue", "setHtml"]); //这里我选择将数据定义在props里面,方便在不同的页面也可以配置出不同的编辑器,当然也可以直接在组件中直接定义 @@ -107,6 +108,8 @@ const props = defineProps({ default: () => ({ userId: 0, fileAlias: '单题上传' }), }, }); + +const userStore = useUserStore().user; const pasteImgName = ref(''); const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传的图片服务器地址 @@ -212,29 +215,31 @@ const init = reactive({ // 插入/编辑图片(普通) - 因此处上传可传图片和文件故仅参考, 实际以[images_upload_handler]这个为准 file_picker_callback: function(callback, value, meta) { + return; + //文件分类 - let filetype='.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4'; - let upURL = '/common/upload'; - //为不同插件指定文件类型及后端地址 - switch(meta.filetype){ - case 'image': - filetype='.jpg, .jpeg, .png, .gif'; - //upURL='upimg.php'; - break; - case 'media': - filetype='.mp3, .mp4'; - //upURL='upfile.php'; - break; - case 'file': - default: - } + // let filetype='.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4'; + // let upURL = '/common/upload'; + // //为不同插件指定文件类型及后端地址 + // switch(meta.filetype){ + // case 'image': + // filetype='.jpg, .jpeg, .png, .gif'; + // //upURL='upimg.php'; + // break; + // case 'media': + // filetype='.mp3, .mp4'; + // //upURL='upfile.php'; + // break; + // case 'file': + // default: + // } - // 模拟出一个input用于添加本地文件 - let input = document.createElement('input'); - input.setAttribute('type', 'file'); - input.setAttribute('accept', filetype); + // // 模拟出一个input用于添加本地文件 + // let input = document.createElement('input'); + // input.setAttribute('type', 'file'); + // input.setAttribute('accept', filetype); - // 暂时屏蔽 + // // 暂时屏蔽 // input.onchange = function() { // const file = this.files[0]; // const formData = new FormData(); @@ -250,7 +255,7 @@ const init = reactive({ // }); // }; - input.click(); + // input.click(); }, // 插入/编辑图片(上传) @@ -278,22 +283,25 @@ const init = reactive({ formData.append("entpcourseid", 0); formData.append("filetype", "image"); formData.append("suffix", "image"); - formData.append("status", '0'); - if(props.upFileParams?.hasOwnProperty('deptId')){ - formData.append("entpid", props.upFileParams.deptId); + formData.append("status", '1'); + if(userStore.deptId && userStore.deptId != null){ + formData.append("entpid", userStore.deptId); } - if(props.upFileParams?.hasOwnProperty('userId')){ - formData.append("userid", props.upFileParams.userId); + if(userStore.userId && userStore.userId != null){ + formData.append("userid", userStore.userId); } - if(props.upFileParams?.hasOwnProperty('edudegree')){ - let edudegree = props.upFileParams.edudegree.toString(); + if(userStore.edudegree && userStore.edudegree != null){ + let edudegree = userStore.edudegree.toString(); if(edudegree != '' && edudegree.indexOf('年级') == -1){ edudegree += '年级'; } formData.append("edudegree", edudegree); } - if(props.upFileParams?.hasOwnProperty('edusubject')){ - formData.append("edusubject", props.upFileParams.edusubject); + if(userStore.edusubject && userStore.edusubject != null){ + formData.append("edusubject", userStore.edusubject); + } + if(userStore.edustage && userStore.edustage != null){ + formData.append("edustage", userStore.edustage); } if(props.upFileParams?.hasOwnProperty('lessionId')){ formData.append("evalid", props.upFileParams.lessionId); @@ -301,19 +309,22 @@ const init = reactive({ if(props.upFileParams?.hasOwnProperty('fileAlias')){ formData.append("filegroup", props.upFileParams.fileAlias); } + loading.value = true; + console.log('formData->', formData); // 暂时屏蔽 - // saveUploadFile(formData) - // .then((res) => { - // loading.value = false; - // return resolve(res.fileurl); - // }) - // .catch((err) => { - // loading.value = false; - // return reject('err:' + err); - // }); + saveUploadFile(formData) + .then((res) => { + console.log('res->', res); + loading.value = false; + return resolve(res.fileurl); + }) + .catch((err) => { + loading.value = false; + return reject('err:' + err); + }); } ), diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue index 4661abe..9689f4f 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue @@ -94,6 +94,7 @@ \ No newline at end of file diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue index 03c24ee..629991f 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/questionUpload/quesItem/index.vue @@ -1733,6 +1733,7 @@ watch(() => props.bookobj.levelSecondId, (newVal, oldVal) => { // 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去) defineExpose({ updateForm, + resetForm, cropperFormItemCallBack, }) From 14bfef69032b6622091762d8f234649f090079ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com> Date: Thu, 21 Nov 2024 15:30:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E9=A2=98=E5=BA=93?= =?UTF-8?q?=EF=BC=9A=E9=A2=98=E7=9B=AE=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../newClassTaskAssign/myQuestion/index.vue | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue b/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue index d142d03..1c1ff42 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/myQuestion/index.vue @@ -93,14 +93,15 @@ - + props.bookobj.levelSecondId, (newVal, oldVal) => { }) + \ No newline at end of file