瀏覽代碼

Merge branch 'develop3.0-tmd' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0-tmd

OnePsycho 4 年之前
父節點
當前提交
a37bf55abf
共有 2 個文件被更改,包括 138 次插入158 次删除
  1. 9 3
      TEAMModelOS/ClientApp/src/common/NewUploadFile.vue
  2. 129 155
      TEAMModelOS/ClientApp/src/view/teachcontent/index.vue

+ 9 - 3
TEAMModelOS/ClientApp/src/common/NewUploadFile.vue

@@ -175,17 +175,20 @@ export default {
                             cancelText: '否',
                             content: `<p>是否将<strong style='color:red;'>${file.name}</strong>转成HTEX文件?</p>`,
                             onOk: () => {
+                                this.$emit('parsing')
+                                let delBlob = res.blob
                                 this.$api.teachContent.ParseDoc({
                                     file: res.url,
                                     scope: this.routerScope
                                 }).then(
                                     parseRes => {
-                                        this.containerClient.deleteBlob(res.blob)
+                                        this.containerClient.deleteBlob(delBlob)
                                         res.blob = `/res/${res.name}/index.json`
                                         res.extension = 'HTEX'
                                         res.name = res.name.replace('pptx', 'HTEX').replace('PPTX', 'HTEX')
                                         res.type = 'res'
-                                        this.$emit('successData', res)
+                                        this.$emit('successData', res.blob)
+                                        this.$emit('parseComplete')
                                         this.$Message.success('解析成功')
                                     },
                                     parseErr => {
@@ -199,6 +202,7 @@ export default {
                         })
                     } else if (extension == 'HTEX') {
                         let delBlob = res.blob
+                        this.$emit('parsing')
                         res.blob = `/res/${res.name}/index.json`
                         this.$emit('successData', res)
                         this.$api.teachContent.ParseDoc({
@@ -212,7 +216,9 @@ export default {
                                 this.$Message.error('上传失败')
                                 this.containerClient.deleteBlob(delBlob)
                             }
-                        )
+                        ).finally(() => {
+                            this.$emit('parseComplete')
+                        })
                     }
                 },
                 err => {

+ 129 - 155
TEAMModelOS/ClientApp/src/view/teachcontent/index.vue

@@ -12,6 +12,7 @@
                         <Icon type="ios-alert-outline" color="#1cc0f3" size="20" v-if="index == 0" style="position:absolute;top:-16px;margin-left:5px;" />
                     </Tooltip>
                 </div>
+                <!-- Blob空间计算 -->
                 <div :class="($access.can('admin.*|content-school-upd') || routerScope == 'private') ? 'space-box animated fadeIn fast' : 'space-box animated fadeOut fast'">
                     <div class="percent-box">
                         <span class="percent-item-span storage-full" :style="{ width: '100%' }" v-if="sizeInfo.total > storageSpace"></span>
@@ -158,8 +159,8 @@
             </div>
         </div>
         <!--上传文件-->
-        <Modal v-model="uploadStatus" @on-cancel="cancelUpd()" @on-ok="confirmUpd()" ok-text="确认上传" cancel-text="取消上传" :title="$t('teachContent.btnUpload')" class="upload-modal dark-iview-modal" width="660" :mask-closable="false">
-            <NewUploadFile ref="uploadFile" @successData="getFileUrl" @deleteFile="cancelUpdFile" :sasString="sasString" :urlString="urlString" :path="folder" :containerName="containerName" :quality="1"></NewUploadFile>
+        <Modal v-model="uploadStatus" ref="uploadModal" @on-cancel="cancelUpd()" @on-ok="confirmUpd()" :loading="modalLoading" :ok-text="modalLoading ? '解析中':'确认上传'" cancel-text="取消上传" :title="$t('teachContent.btnUpload')" class="upload-modal dark-iview-modal" width="660" :mask-closable="false">
+            <NewUploadFile ref="uploadFile" @successData="getFileUrl" @deleteFile="cancelUpdFile" @parsing="parseFile" @parseComplete="parseComplete" :sasString="sasString" :urlString="urlString" :path="folder" :containerName="containerName" :quality="1"></NewUploadFile>
         </Modal>
         <!--文件预览-->
         <div v-if="previewStatus" class="image-viewer">
@@ -193,6 +194,7 @@ export default {
     },
     data() {
         return {
+            modalLoading: false,
             containerClient: undefined,
             waterfallWidth: 1000,
             isLoading: false,
@@ -240,6 +242,14 @@ export default {
         }
     },
     methods: {
+        parseComplete() {
+            this.modalLoading = false
+            this.$refs['uploadModal'].buttonLoading = false
+        },
+        parseFile() {
+            this.modalLoading = true
+            this.$refs['uploadModal'].buttonLoading = true
+        },
         cancelUpdFile(file) {
             for (let index in this.preUpdFiles) {
                 if (this.preUpdFiles[index].blob == file.blob) {
@@ -274,6 +284,7 @@ export default {
         },
         //确认上传
         async confirmUpd() {
+            console.log(this.$refs['uploadModal'])
             this.$refs['uploadFile'].uploadedList = []
             for (let file of this.preUpdFiles) {
                 if (!this.fileList[file.type]) {
@@ -511,76 +522,30 @@ export default {
         //批量删除
         delFileBatch() {
             console.log(this.selections)
-            if (this.selections.length > 0) {
-                let names = this.selections.map((item) => {
-                    return item.name
-                })
-                let blobs = this.selections.map((item) => {
-                    return item.blob.substring(1)
-                })
-                this.$Modal.confirm({
-                    title: this.$t('teachContent.props1'),
-                    content: "<p class='dialog-p'>" + names.join(', ') + '</p>',
-                    onOk: () => {
-                        if (this.activeType == 'res') {
-                            //批量删除HTEX需要循环删除每个文件夹下面的文件
-                            this.selections.forEach((item, index) => {
-                                this.$api.uploadFile.deletePrefix({
-                                    cntr: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
-                                    prefix: `res/${item.name.replace('.HTEX', '')}`
-                                }).then(
-                                    res => {
-                                        let files = this.selections.map((item) => {
-                                            return item.blob
-                                        })
-                                        for (let i = 0; i < this.fileList[this.activeType].length; i++) {
-                                            let index = files.indexOf(this.fileList[this.activeType][i].blob)
-                                            if (index != -1) {
-                                                this.sizeInfo[this.activeType] -= this.fileList[this.activeType][i].size
-                                                this.sizeInfo.total -= this.fileList[this.activeType][i].size
-                                                this.fileList[this.activeType].splice(i, 1)
-                                                i--
-                                            }
-                                        }
-                                        let fs = []
-                                        fs = this.fileList[this.activeType] ? this.fileList[this.activeType] : []
-                                        this.fileListShow = this._.cloneDeep(fs)
-                                        this.$Message.success('删除成功!')
-                                    },
-                                    err => {
-                                        this.$Message.error('删除失败!')
-                                    }
-                                ).finally(() => {
-                                    this.isLoading = false
-                                })
-                            })
-                        } else {
-                            this.$api.uploadFile.deleteBlobs({
+            if (this.selections.length == 0) {
+                if (this.showType) {
+                    this.$Message.warning('请在列表模式使用批量删除!')
+                } else {
+                    this.$Message.warning('请先选择需要删除的文件!')
+                }
+                return
+            }
+
+            let names = this.selections.map((item) => { return item.name })
+            let blobs = this.selections.map((item) => { return item.blob.substring(1) })
+            this.$Modal.confirm({
+                title: this.$t('teachContent.props1'),
+                content: "<p class='dialog-p'>" + names.join(', ') + '</p>',
+                onOk: () => {
+                    if (this.activeType == 'res') {
+                        //批量删除HTEX需要循环删除每个文件夹下面的文件
+                        this.selections.forEach((item, index) => {
+                            this.$api.uploadFile.deletePrefix({
                                 cntr: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
-                                urls: blobs
+                                prefix: `res/${item.name.replace('.HTEX', '')}`
                             }).then(
                                 res => {
-                                    if (this.activeType == 'image') {
-                                        let thums = blobs.map((item) => {
-                                            return item.replace('/image/', '/thum/')
-                                        })
-                                        this.$api.uploadFile.deleteBlobs({
-                                            cntr: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
-                                            urls: thums
-                                        })
-                                    } else if (this.activeType == 'video') {
-                                        let thums = blobs.map((item) => {
-                                            let n = item.replace('/video/', '/thum/')
-                                            return n.slice(0, n.lastIndexOf('.')) + '.png'
-                                        })
-                                        this.$api.uploadFile.deleteBlobs({
-                                            cntr: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
-                                            urls: thums
-                                        })
-                                    }
-                                    let files = this.selections.map((item) => {
-                                        return item.blob
-                                    })
+                                    let files = this.selections.map((item) => { return item.blob })
                                     for (let i = 0; i < this.fileList[this.activeType].length; i++) {
                                         let index = files.indexOf(this.fileList[this.activeType][i].blob)
                                         if (index != -1) {
@@ -590,63 +555,98 @@ export default {
                                             i--
                                         }
                                     }
-                                    let fs = []
-                                    fs = this.fileList[this.activeType] ? this.fileList[this.activeType] : []
+                                    let fs = this.fileList[this.activeType] ? this.fileList[this.activeType] : []
                                     this.fileListShow = this._.cloneDeep(fs)
+                                    this.$Message.success('删除成功!')
                                 },
-                            )
-                        }
-                        // this.isLoading = true
-                        // let files = this.selections.map((item) => {
-                        //     return item.blob
-                        // })
-                        // this.containerClient.deleteBlobBatch(files).then(
-                        //     res => {
-                        //         this.$Message.success('删除成功')
-                        //         //删除缩略图或封面
-                        //         if (this.activeType == 'image') {
-                        //             let thums = files.map((item) => {
-                        //                 return item.replace('/image/', /thum/)
-                        //             })
-                        //             this.containerClient.deleteBlobBatch(thums)
-                        //         } else if (this.activeType == 'video') {
-                        //             let thums = files.map((item) => {
-                        //                 let n = item.replace('/video/', /thum/)
-                        //                 return n.slice(0, n.lastIndexOf('.')) + '.png'
-                        //             })
-                        //             this.containerClient.deleteBlobBatch(thums)
-                        //         }
-                        //         for (let i = 0; i < this.fileList[this.activeType].length; i++) {
-                        //             let index = files.indexOf(this.fileList[this.activeType][i].blob)
-                        //             if (index != -1) {
-                        //                 this.sizeInfo[this.activeType] -= this.fileList[this.activeType][i].size
-                        //                 this.sizeInfo.total -= this.fileList[this.activeType][i].size
-                        //                 this.fileList[this.activeType].splice(i, 1)
-                        //                 i--
-                        //             }
-                        //         }
-                        //         let fs = []
-                        //         fs = this.fileList[this.activeType] ? this.fileList[this.activeType] : []
-                        //         this.fileListShow = this._.cloneDeep(fs)
-                        //     },
-                        //     err => {
-                        //         console.log(err)
-                        //         this.$Message.error('删除失败')
-                        //     }
-                        // ).finally(() => {
-                        //     setTimeout(() => {
-                        //         this.isLoading = false
-                        //     })
-                        // })
+                                err => {
+                                    this.$Message.error('删除失败!')
+                                }
+                            ).finally(() => {
+                                this.isLoading = false
+                            })
+                        })
+                    } else {
+                        this.$api.uploadFile.deleteBlobs({
+                            cntr: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
+                            urls: blobs
+                        }).then(
+                            res => {
+                                let thums = []
+                                if (this.activeType == 'image') {
+                                    thums = blobs.map((item) => { return item.replace('/image/', '/thum/') })
+                                } else if (this.activeType == 'video') {
+                                    thums = blobs.map((item) => {
+                                        let n = item.replace('/video/', '/thum/')
+                                        return n.slice(0, n.lastIndexOf('.')) + '.png'
+                                    })
+                                }
+                                if (thums.length) {
+                                    this.$api.uploadFile.deleteBlobs({
+                                        cntr: this.routerScope == 'school' ? this.$store.state.userInfo.schoolCode : this.$store.state.userInfo.TEAMModelId,
+                                        urls: thums
+                                    })
+                                }
+
+                                let files = this.selections.map((item) => { return item.blob })
+                                for (let i = 0; i < this.fileList[this.activeType].length; i++) {
+                                    let index = files.indexOf(this.fileList[this.activeType][i].blob)
+                                    if (index != -1) {
+                                        this.sizeInfo[this.activeType] -= this.fileList[this.activeType][i].size
+                                        this.sizeInfo.total -= this.fileList[this.activeType][i].size
+                                        this.fileList[this.activeType].splice(i, 1)
+                                        i--
+                                    }
+                                }
+                                let fs = this.fileList[this.activeType] ? this.fileList[this.activeType] : []
+                                this.fileListShow = this._.cloneDeep(fs)
+                            },
+                        )
                     }
-                })
-            } else {
-                if (this.showType) {
-                    this.$Message.warning('请在列表模式使用批量删除!')
-                } else {
-                    this.$Message.warning('请先选择需要删除的文件!')
+                    // this.isLoading = true
+                    // let files = this.selections.map((item) => {
+                    //     return item.blob
+                    // })
+                    // this.containerClient.deleteBlobBatch(files).then(
+                    //     res => {
+                    //         this.$Message.success('删除成功')
+                    //         //删除缩略图或封面
+                    //         if (this.activeType == 'image') {
+                    //             let thums = files.map((item) => {
+                    //                 return item.replace('/image/', /thum/)
+                    //             })
+                    //             this.containerClient.deleteBlobBatch(thums)
+                    //         } else if (this.activeType == 'video') {
+                    //             let thums = files.map((item) => {
+                    //                 let n = item.replace('/video/', /thum/)
+                    //                 return n.slice(0, n.lastIndexOf('.')) + '.png'
+                    //             })
+                    //             this.containerClient.deleteBlobBatch(thums)
+                    //         }
+                    //         for (let i = 0; i < this.fileList[this.activeType].length; i++) {
+                    //             let index = files.indexOf(this.fileList[this.activeType][i].blob)
+                    //             if (index != -1) {
+                    //                 this.sizeInfo[this.activeType] -= this.fileList[this.activeType][i].size
+                    //                 this.sizeInfo.total -= this.fileList[this.activeType][i].size
+                    //                 this.fileList[this.activeType].splice(i, 1)
+                    //                 i--
+                    //             }
+                    //         }
+                    //         let fs = []
+                    //         fs = this.fileList[this.activeType] ? this.fileList[this.activeType] : []
+                    //         this.fileListShow = this._.cloneDeep(fs)
+                    //     },
+                    //     err => {
+                    //         console.log(err)
+                    //         this.$Message.error('删除失败')
+                    //     }
+                    // ).finally(() => {
+                    //     setTimeout(() => {
+                    //         this.isLoading = false
+                    //     })
+                    // })
                 }
-            }
+            })
         },
         /**
          * 删除单个文件
@@ -698,9 +698,7 @@ export default {
                                 this.sizeInfo.total -= file.size
                                 this.fileListShow.splice(index, 1)
                                 for (let i in this.fileList[this.activeType]) {
-                                    if (this.fileList[this.activeType][i].url == file.url) {
-                                        this.fileList[this.activeType].splice(i, 1)
-                                    }
+                                    if (this.fileList[this.activeType][i].url == file.url) this.fileList[this.activeType].splice(i, 1)
                                 }
                                 this.$Message.success('删除成功!')
                             },
@@ -806,15 +804,6 @@ export default {
         // 处理教材文件夹的文件
         handleHTEXFile(fileList) {
             let parseRes = []
-            // let fileItem = {
-            //     url: url,
-            //     blob: '/' + path + "/" + file.name,
-            //     name: file.name,
-            //     size: res._response.request.body.size,
-            //     createTime: res.lastModified.getTime(),
-            //     extension: info.ex,
-            //     type: info.type
-            // }
             let names = []
             fileList.forEach((item, index) => {
                 let fileItem = {}
@@ -871,21 +860,11 @@ export default {
                                 res.blobList[i]['thum'] = res.blobList[i].url.replace(res.blobList[i].blob, n)
                             }
                         }
-                        //if (this.activeType == 'image' || this.activeType == 'video') {//分页查询用push
-                        //    if (this.fileList[this.activeType]) {
-                        //        this.fileList[this.activeType].push(...res.blobList)
-                        //    } else {
-                        //        this.fileList[this.activeType] = res.blobList
-                        //    }
-                        //    let baseLen = this.fileList[this.activeType].length - res.blobList.length
-                        //    this.handleFileRes(this.activeType, res.blobList, baseLen)
-                        //} else {//一次查询所有直接赋值
                         this.fileList[this.activeType] = res.blobList
                         this.fileListShow = this._.cloneDeep(this.fileList[this.activeType])
                         setTimeout(() => {
                             this.isLoading = false
                         }, 500)
-                        //}
                         this.searchBefore = this.fileList[this.activeType]
                         this.getFilesExtension()
                     },
@@ -897,9 +876,8 @@ export default {
                 )
             }
         },
-        //处理Blob返回结果 缩略图、封面
+        //处理Blob返回结果 缩略图、封面 现在是上传的时候生成缩略图和封面,就不用每次临时生成了)
         async handleFileRes(curAcType, blobList, baseLen) {
-            //let baseLen = this.fileList[curAcType] ? this.fileList[curAcType].length : 0
             for (let i in blobList) {
                 i = parseInt(i)
                 if (curAcType == 'image') {
@@ -968,11 +946,7 @@ export default {
                 }
             }
         },
-        handleTabClick(scope) {
-            this.routerScope = scope
-            this.activeType = 'res'
-            this.getSasStr()
-        },
+
         /**
          * 根据文件类型筛选
          * @param index
@@ -1038,13 +1012,14 @@ export default {
             handler: function (to, from) {
                 this.initData()
                 if (this.$route.name == 'schoolcontent') {
-                    this.handleTabClick(0)
+                    this.routerScope = 'school'
                     this.storageSpace = this.$GLOBAL.SCHOOL_SPACE
-
                 } else {
-                    this.handleTabClick(1)
+                    this.routerScope = 'private'
                     this.storageSpace = this.$GLOBAL.PRIVATE_SPACE
                 }
+                this.activeType = 'res'
+                this.getSasStr()
             },
             immediate: true
         }
@@ -1058,7 +1033,6 @@ export default {
 .content-file-filter .ivu-input {
     background: none;
     border-radius: 16px;
-    /*height:24px;*/
     color: white;
 }