疯狂的狮子li
2021-09-27 99dcbe0207eed69ed2613f3cd9a11d0529bd7265
update 封装通用下载方法简化下载使用
已修改16个文件
已删除1个文件
160 ■■■■ 文件已修改
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/main.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/plugins/download.js 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/utils/download.js 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/demo/demo/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/monitor/job/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/monitor/job/log.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/monitor/logininfor/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/monitor/operlog/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/config/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/dict/data.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/dict/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/oss/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/post/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/role/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/system/user/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-ui/src/views/tool/gen/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
@@ -573,7 +573,7 @@
#end
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/${moduleName}/${businessName}/export', this.queryParams);
        this.#[[$download]]#.excel('/${moduleName}/${businessName}/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/main.js
@@ -17,7 +17,6 @@
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { downLoadExcel } from "@/utils/download";
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
// åˆ†é¡µç»„ä»¶
import Pagination from "@/components/Pagination";
@@ -44,7 +43,6 @@
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.downLoadExcel = downLoadExcel
Vue.prototype.handleTree = handleTree
// å…¨å±€ç»„件挂载
ruoyi-ui/src/plugins/download.js
@@ -5,28 +5,51 @@
const baseURL = process.env.VUE_APP_BASE_API
export default {
  name(name, isDelete = true) {
    var url = baseURL + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete
  excel(url, params) {
    // get请求映射params参数
    if (params) {
      let urlparams = url + '?';
      for (const propName of Object.keys(params)) {
        const value = params[propName];
        var part = encodeURIComponent(propName) + "=";
        if (value !== null && typeof(value) !== "undefined") {
          if (typeof value === 'object') {
            for (const key of Object.keys(value)) {
              if (value[key] !== null && typeof (value[key]) !== 'undefined') {
                let params = propName + '[' + key + ']';
                let subPart = encodeURIComponent(params) + '=';
                urlparams += subPart + encodeURIComponent(value[key]) + '&';
              }
            }
          } else {
            urlparams += part + encodeURIComponent(value) + "&";
          }
        }
      }
      urlparams = urlparams.slice(0, -1);
      url = urlparams;
    }
    url = baseURL + url
    axios({
      method: 'get',
      url: url,
      responseType: 'blob',
      headers: { 'Authorization': 'Bearer ' + getToken() }
    }).then(res => {
      const blob = new Blob([res.data])
      const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
      this.saveAs(blob, decodeURI(res.headers['download-filename']))
    })
  },
  resource(resource) {
    var url = baseURL + "/common/download/resource?resource=" + encodeURI(resource);
  oss(ossId, name) {
    var url = baseURL + '/system/oss/download/' + ossId
    axios({
      method: 'get',
      url: url,
      responseType: 'blob',
      headers: { 'Authorization': 'Bearer ' + getToken() }
    }).then(res => {
      const blob = new Blob([res.data])
      this.saveAs(blob, decodeURI(res.headers['download-filename']))
      const blob = new Blob([res.data], { type: 'application/octet-stream' })
      this.saveAs(blob, name)
    })
  },
  zip(url, name) {
ruoyi-ui/src/utils/download.js
ÎļþÒÑɾ³ý
ruoyi-ui/src/views/demo/demo/index.vue
@@ -358,7 +358,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/demo/demo/export', this.queryParams);
      this.$download.excel('/demo/demo/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/monitor/job/index.vue
@@ -510,7 +510,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/monitor/job/export', this.queryParams);
      this.$download.excel('/monitor/job/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/monitor/job/log.vue
@@ -293,7 +293,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/monitor/jobLog/export', this.queryParams);
      this.$download.excel('/monitor/jobLog/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/monitor/logininfor/index.vue
@@ -216,7 +216,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/monitor/logininfor/export', this.queryParams);
      this.$download.excel('/monitor/logininfor/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/monitor/operlog/index.vue
@@ -303,7 +303,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/monitor/operlog/export', this.queryParams);
      this.$download.excel('/monitor/operlog/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/system/config/index.vue
@@ -334,7 +334,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/system/config/export', this.queryParams);
      this.$download.excel('/system/config/export', this.queryParams);
    },
    /** åˆ·æ–°ç¼“存按钮操作 */
    handleRefreshCache() {
ruoyi-ui/src/views/system/dict/data.vue
@@ -380,7 +380,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/system/dict/data/export', this.queryParams);
      this.$download.excel('/system/dict/data/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/system/dict/index.vue
@@ -338,7 +338,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/system/dict/type/export', this.queryParams);
      this.$download.excel('/system/dict/type/export', this.queryParams);
    },
    /** åˆ·æ–°ç¼“存按钮操作 */
    handleRefreshCache() {
ruoyi-ui/src/views/system/oss/index.vue
@@ -188,7 +188,6 @@
<script>
import { listOss, delOss, changePreviewListResource } from "@/api/system/oss";
import { downLoadOss } from "@/utils/download";
export default {
  name: "Oss",
@@ -325,7 +324,7 @@
    },
    /** ä¸‹è½½æŒ‰é’®æ“ä½œ */
    handleDownload(row) {
      downLoadOss(row.ossId)
      this.$download.oss(row.ossId)
    },
    /** åˆ é™¤æŒ‰é’®æ“ä½œ */
    handleDelete(row) {
ruoyi-ui/src/views/system/post/index.vue
@@ -305,7 +305,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/system/post/export', this.queryParams);
      this.$download.excel('/system/post/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/system/role/index.vue
@@ -613,7 +613,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/system/role/export', this.queryParams);
      this.$download.excel('/system/role/export', this.queryParams);
    }
  }
};
ruoyi-ui/src/views/system/user/index.vue
@@ -643,7 +643,7 @@
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.downLoadExcel('/system/user/export', this.queryParams);
      this.$download.excel('/system/user/export', this.queryParams);
    },
    /** å¯¼å…¥æŒ‰é’®æ“ä½œ */
    handleImport() {
@@ -652,7 +652,7 @@
    },
    /** ä¸‹è½½æ¨¡æ¿æ“ä½œ */
    importTemplate() {
      this.downLoadExcel('/system/user/importTemplate');
      this.$download.excel('/system/user/importTemplate');
    },
    // æ–‡ä»¶ä¸Šä¼ ä¸­å¤„理
    handleFileUploadProgress(event, file, fileList) {
ruoyi-ui/src/views/tool/gen/index.vue
@@ -180,7 +180,6 @@
<script>
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
import importTable from "./importTable";
import { downLoadZip } from "@/utils/download";
import hljs from "highlight.js/lib/highlight";
import "highlight.js/styles/github-gist.css";
hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));