quanyawei
2023-11-24 27750338586d541f8ba0623200c7281187148141
fix:导出修改
2 files modified
34 ■■■■ changed files
src/mixins/downLoadNotice.js 27 ●●●● patch | view | raw | blame | history
src/views/toCarryOutLegislativeReforms/reform/index.vue 7 ●●●● patch | view | raw | blame | history
src/mixins/downLoadNotice.js
@@ -2,7 +2,8 @@
export const mixins = {
  data: function () {
    return {
      notify: {} // 用来维护下载文件进度弹框对象
      notify: {}, // 用来维护下载文件进度弹框对象
      downLoading: false
    }
  },
  computed: {
@@ -21,8 +22,13 @@
          if (domList.find(i => i.className === item.path)) {
            // 如果页面已经有该进度对象的弹框,则更新它的进度progress
            if (item.progress) {
              domList.find(i => i.className === item.path).innerHTML =
                item.progress + '%'
              // if (this.downLoadingNumber >= 90) {
              //   this.downLoadingNumber = 99
              // } else {
              //   this.downLoadingNumber += 1
              // }
              domList.find(i => i.className === item.path).innerHTML = ''
              // this.downLoadingNumber + '%'
            }
            if (item.progress === null) {
              // 此处容错处理,如果后端传输文件流报错,删除当前进度对象
@@ -33,19 +39,25 @@
              })
            }
          } else {
            if (!this.downLoading) {
            // 如果页面中没有该进度对象所对应的弹框,页面新建弹框,并在notify中加入该弹框对象,属性名为该进度对象的path(上文可知path是唯一的),属性值为$notify(element ui中的通知组件)弹框对象
            this.notify[item.path] = this.$notify.success({
              // title: 'info',
              dangerouslyUseHTMLString: true,
              customClass: 'progress-notify',
              message: `<p style="width: 100px;">正在下载<span class="${item.path}" style="float: right">${item.progress}%</span></p>`, // 显示下载百分比,类名为进度对象的path(便于后面更新进度百分比)
              duration: 0
                message: `<div style="width: 100px;">正在下载<span class="${item.path}" style="float: right"></span></div>`, // 显示下载百分比,类名为进度对象的path(便于后面更新进度百分比)
                duration: 5000,
                onClose: () => {
                  this.downLoading = true
                }
            })
            }
          }
          if (item.progress == 100) {
            // 如果下载进度到了100%,关闭该弹框,并删除notify中维护的弹框对象
            this.notify[item.path].close()
            this.downLoading = false
            // delete this.notify[item.path] 上面的close()事件是异步的,这里直接删除会报错,利用setTimeout,将该操作加入异步队列
            setTimeout(() => {
              delete this.notify[item.path]
@@ -56,5 +68,10 @@
      },
      deep: true
    }
  },
  methods: {
    onClose() {
      console.log('关闭')
    }
  }
}
src/views/toCarryOutLegislativeReforms/reform/index.vue
@@ -433,7 +433,12 @@
        link.click()
        // 下载完成进行释放
        url.revokeObjectURL(link.href)
        this.$message.success('下载完成!')
        this.$message({
          showClose: true,
          duration: 0,
          message: '下载完成!',
          type: 'success'
        })
        this.loading = false
      }
    },