Parcourir la source

文件修订生成多条阅读记录

lidie il y a 1 an
Parent
commit
a9a80d25db
1 fichiers modifiés avec 40 ajouts et 27 suppressions
  1. 40 27
      src/views/component/fileTraining/index.vue

+ 40 - 27
src/views/component/fileTraining/index.vue

@@ -207,6 +207,8 @@ export default {
                 if (newVal !== temp) {
                     this.leftData = temp
                 }
+                // this.fileShow(this.leftData[0])
+
                 newVal.forEach(val => {
                     this.fileShow(val)
                 })
@@ -339,12 +341,17 @@ export default {
         },
 
         toggleActive (activity, index) {
+            if (this.activeIndex === index) { return }
             this.activeIndex = index
             this.digData = activity
+            this.fileShow(activity)
+            if (this.browseTime >= 30) {
+                this.upFunc(this.tmpId, this.browseTime)
+            }
+
             clearInterval(this.clearTimeSet)
             this.browseTime = 0
             this.curFileName = activity.FILE_NAME_
-            this.fileShow(activity)// 展示内容改变
             this.checkNum(activity)// 阅读量
             // this.$forceUpdate()// 触发监听器
         },
@@ -419,7 +426,6 @@ export default {
             this.innerVisible = val
         },
         updateFile () {
-            // console.log('下载文件', this.optionFile)
             const a = document.createElement('a')
             a.href = this.optionFile.url
             a.download = this.optionFile.data.fileName
@@ -428,31 +434,38 @@ export default {
             a.remove()
         },
         fileShow (val) {
-            // console.log('qwqwqw', this.idChange('1166703356459089920'))
-            this.dialogVisible = this.visible
-            this.title = `文件:《${val.FILE_NAME_}》`
-            this.idChange(val.id).then(res => {
-                this.tmpId = res
-            })
-            this.upFunc = val.func
-            const data = {
-                ext: val.fileInfos.EXT_,
-                fileName: val.fileInfos.FILE_NAME_,
-                id: val.fileInfos.ID_,
-                index: 0,
-                totalBytes: val.fileInfos.TOTAL_BYTES_
-            }
-            // 1、获取文件数据 及下载流接口
-            this.optionFile.url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + data.id
-            this.optionFile.editUrl = BASE_API() + SYSTEM_URL() + '/file/editCallback?fileName=' + data.fileName + '&fileType=' + data.ext + '&type="fileTraining"&id=' + data.id
-            this.optionFile.title = data.fileName // 文件名称
-            this.optionFile.fileType = data.ext // 类型
-            this.optionFile.data = data // 记录编制的位置,需要替换。
-            this.optionFile.data.index = data.index
-            // 使用 v-if 实现组件刷新功能
-            this.refresh = false
-            this.$nextTick(() => {
-                this.refresh = true
+            return new Promise((resolve, reject) => {
+                try {
+                    this.dialogVisible = true
+                    this.title = `文件:《${val.FILE_NAME_}》`
+                    this.idChange(val.id).then(res => {
+                        this.tmpId = res
+                        if (val.func) { this.upFunc = val.func }
+                        const data = {
+                            ext: val.fileInfos.EXT_,
+                            fileName: val.fileInfos.FILE_NAME_,
+                            id: val.fileInfos.ID_,
+                            index: 0,
+                            totalBytes: val.fileInfos.TOTAL_BYTES_
+                        }
+
+                        this.optionFile.url = `${BASE_API()}${SYSTEM_URL()}/file/download?attachmentId=${data.id}`
+                        this.optionFile.editUrl = `${BASE_API()}${SYSTEM_URL()}/file/editCallback?fileName=${data.fileName}&fileType=${data.ext}&type=fileTraining&id=${data.id}`
+                        this.optionFile.title = data.fileName // 文件名称
+                        this.optionFile.fileType = data.ext // 类型
+                        this.optionFile.data = data // 记录编制的位置,需要替换。
+                        this.optionFile.data.index = data.index
+
+                        // 使用 v-if 实现组件刷新功能
+                        this.refresh = false
+                        this.$nextTick(() => {
+                            this.refresh = true
+                            resolve() // 异步操作完成后 resolve
+                        })
+                    })
+                } catch (error) {
+                    reject(error)
+                }
             })
         },
         // 排序函数