ppt导入-解析过程中增加关闭功能
This commit is contained in:
parent
6f3ffc45cf
commit
3032e2fb3a
|
@ -288,14 +288,17 @@ const createAIPPT = () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const isPgDialogClose = ref(false) // 弹窗-进度条-是否关闭
|
||||||
const pgDialog = ref({ // 弹窗-进度条
|
const pgDialog = ref({ // 弹窗-进度条
|
||||||
visible: false,
|
visible: false,
|
||||||
title: 'PPT解析中...',
|
title: 'PPT解析中...',
|
||||||
width: 300,
|
width: 300,
|
||||||
showClose: false,
|
showClose: true,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
beforeClose: done => {}, // 阻止-弹窗事件
|
beforeClose: done => { // 弹窗关闭前回调
|
||||||
|
isPgDialogClose.value = true
|
||||||
|
done()
|
||||||
|
},
|
||||||
pg: { // 进度条-参数
|
pg: { // 进度条-参数
|
||||||
percentage: 0, // 百分比
|
percentage: 0, // 百分比
|
||||||
color: [
|
color: [
|
||||||
|
@ -316,20 +319,26 @@ const openFilePicker = () =>{
|
||||||
|
|
||||||
const handleFileChange = ()=> {
|
const handleFileChange = ()=> {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
|
fileInput.value.value = ''
|
||||||
if (file) {
|
if (file) {
|
||||||
console.log(file);
|
|
||||||
createAIPPTByFile(file)
|
createAIPPTByFile(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ppt文件转PPT线上数据
|
// ppt文件转PPT线上数据
|
||||||
const createAIPPTByFile = async (file)=> {
|
const createAIPPTByFile = async (file)=> {
|
||||||
|
isPgDialogClose.value = false // 默认没有关闭
|
||||||
pgDialog.value.visible = true
|
pgDialog.value.visible = true
|
||||||
pgDialog.value.pg.percentage = 0
|
pgDialog.value.pg.percentage = 0
|
||||||
|
const closePgDialog = () => {
|
||||||
|
pgDialog.value.pg.percentage = 0
|
||||||
|
pgDialog.value.visible = false
|
||||||
|
}
|
||||||
pptMedia = {} // 清空媒体数据
|
pptMedia = {} // 清空媒体数据
|
||||||
const resPptJson = await PPTXFileToJson(file).catch(() => {
|
const resPptJson = await PPTXFileToJson(file).catch(() => {
|
||||||
ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!')
|
ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!')
|
||||||
pgDialog.value.visible = false
|
pgDialog.value.visible = false
|
||||||
})
|
})
|
||||||
|
if(isPgDialogClose.value) return closePgDialog() // 弹窗关闭了,终止进行
|
||||||
const { def, slides, ...content } = resPptJson
|
const { def, slides, ...content } = resPptJson
|
||||||
// 生成缩略图
|
// 生成缩略图
|
||||||
const thumbnails = await slidesToImg(slides, content.width)
|
const thumbnails = await slidesToImg(slides, content.width)
|
||||||
|
@ -337,13 +346,13 @@ const createAIPPTByFile = async (file)=> {
|
||||||
let completed = 0
|
let completed = 0
|
||||||
const total = slides.length
|
const total = slides.length
|
||||||
for( let o of slides ) {
|
for( let o of slides ) {
|
||||||
|
if(isPgDialogClose.value) return closePgDialog() // 弹窗关闭了,终止进行
|
||||||
completed++
|
completed++
|
||||||
await toRousrceUrl(o)
|
await toRousrceUrl(o)
|
||||||
// 设置进度条
|
// 设置进度条
|
||||||
pgDialog.value.pg.percentage = Math.floor(completed / total * 100)
|
pgDialog.value.pg.percentage = Math.floor(completed / total * 100)
|
||||||
}
|
}
|
||||||
pgDialog.value.pg.percentage = 0
|
closePgDialog() // 关闭进度条弹窗
|
||||||
pgDialog.value.visible = false
|
|
||||||
listEntpcourse({
|
listEntpcourse({
|
||||||
evalid: currentNode.value.id,
|
evalid: currentNode.value.id,
|
||||||
edituserid: userStore.userId,
|
edituserid: userStore.userId,
|
||||||
|
|
|
@ -274,13 +274,17 @@ export default {
|
||||||
treelogRef:null,
|
treelogRef:null,
|
||||||
// 获取当前章节对应的课程信息 Entpcourse
|
// 获取当前章节对应的课程信息 Entpcourse
|
||||||
entp: null,
|
entp: null,
|
||||||
|
isPgDialogClose: false, // 关闭进度条弹窗
|
||||||
pgDialog: { // 弹窗-进度条
|
pgDialog: { // 弹窗-进度条
|
||||||
visible: false,
|
visible: false,
|
||||||
title: 'PPT解析中...',
|
title: 'PPT解析中...',
|
||||||
width: 300,
|
width: 300,
|
||||||
showClose: false,
|
showClose: true,
|
||||||
draggable: true,
|
draggable: true,
|
||||||
beforeClose: done => {}, // 阻止-弹窗事件
|
beforeClose: done => { // 弹窗关闭前回调
|
||||||
|
this.isPgDialogClose = true
|
||||||
|
done()
|
||||||
|
},
|
||||||
pg: { // 进度条-参数
|
pg: { // 进度条-参数
|
||||||
percentage: 0, // 百分比
|
percentage: 0, // 百分比
|
||||||
color: [
|
color: [
|
||||||
|
@ -612,6 +616,7 @@ export default {
|
||||||
},
|
},
|
||||||
handleFileChange(){
|
handleFileChange(){
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
|
this.$refs.fileInput.value = ''
|
||||||
if (file) {
|
if (file) {
|
||||||
console.log(file);
|
console.log(file);
|
||||||
console.log('文件名:', file.name);
|
console.log('文件名:', file.name);
|
||||||
|
@ -687,14 +692,20 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async createAIPPTByFile(file,fileShowName) {
|
async createAIPPTByFile(file,fileShowName) {
|
||||||
|
this.isPgDialogClose = false // 默认不关闭
|
||||||
this.pgDialog.visible = true
|
this.pgDialog.visible = true
|
||||||
this.pgDialog.pg.percentage = 0
|
this.pgDialog.pg.percentage = 0
|
||||||
|
const closePgDialog = () => {
|
||||||
|
this.pgDialog.pg.percentage = 0
|
||||||
|
this.pgDialog.visible = false
|
||||||
|
}
|
||||||
this.pptMedia = {} // 清空媒体数据
|
this.pptMedia = {} // 清空媒体数据
|
||||||
const resPptJson = await PPTXFileToJson(file).catch(() => {
|
const resPptJson = await PPTXFileToJson(file).catch(() => {
|
||||||
ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!')
|
ElMessageBox.alert('PPT文件转换失败!请点击素材右侧...下载文件后打开另存为PPTX文件格式再进行导入!')
|
||||||
this.pgDialog.visible = false
|
this.pgDialog.visible = false
|
||||||
})
|
})
|
||||||
if (!resPptJson) return
|
if (!resPptJson) return
|
||||||
|
if(this.isPgDialogClose) return closePgDialog() // 弹窗关闭了,终止进行
|
||||||
const { def, slides, ...content } = resPptJson
|
const { def, slides, ...content } = resPptJson
|
||||||
// 生成缩略图
|
// 生成缩略图
|
||||||
const thumbnails = await slidesToImg(slides, content.width)
|
const thumbnails = await slidesToImg(slides, content.width)
|
||||||
|
@ -702,13 +713,13 @@ export default {
|
||||||
let completed = 0
|
let completed = 0
|
||||||
const total = slides.length
|
const total = slides.length
|
||||||
for( let o of slides ) {
|
for( let o of slides ) {
|
||||||
|
if(this.isPgDialogClose) return closePgDialog() // 弹窗关闭了,终止进行
|
||||||
completed++
|
completed++
|
||||||
await this.toRousrceUrl(o)
|
await this.toRousrceUrl(o)
|
||||||
// 设置进度条
|
// 设置进度条
|
||||||
this.pgDialog.pg.percentage = Math.floor(completed / total * 100)
|
this.pgDialog.pg.percentage = Math.floor(completed / total * 100)
|
||||||
}
|
}
|
||||||
this.pgDialog.pg.percentage = 0
|
closePgDialog() // 关闭进度条弹窗
|
||||||
this.pgDialog.visible = false
|
|
||||||
listEntpcourse({
|
listEntpcourse({
|
||||||
evalid: this.currentNode.id,
|
evalid: this.currentNode.id,
|
||||||
edituserid: this.userStore.userId,
|
edituserid: this.userStore.userId,
|
||||||
|
|
Loading…
Reference in New Issue