From 1788c804bc23fc7828d24152162e87faee56f3f4 Mon Sep 17 00:00:00 2001 From: qianbao Date: Sun, 2 Apr 2023 02:18:19 +0800 Subject: [PATCH] 上传添加导入添加loading --- config/dev.env.js | 4 +--- src/views/bigscreenDesigner/designer/index.vue | 81 ++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/config/dev.env.js b/config/dev.env.js index 9f9cb23..06bbc83 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -1,10 +1,8 @@ 'use strict' const merge = require('webpack-merge') const prodEnv = require('./prod.env') -const isDev = false; +const isDev = true; const ipAddresses = isDev?"weberp.xlyprint.cn":"127.0.0.1:8080"; - //window.location.host; - module.exports = merge(prodEnv, { NODE_ENV: '"development"', BASE_API: '"http://'+ipAddresses+'/xlyReport"', diff --git a/src/views/bigscreenDesigner/designer/index.vue b/src/views/bigscreenDesigner/designer/index.vue index 5cd8dd0..c9e6618 100644 --- a/src/views/bigscreenDesigner/designer/index.vue +++ b/src/views/bigscreenDesigner/designer/index.vue @@ -131,6 +131,7 @@ :headers="headers" accept=".zip" :on-success="handleUpload" + :before-upload="beforeUpload" :on-error="handleError" :show-file-list="false" :limit="1" @@ -140,34 +141,42 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -301,7 +310,6 @@ import { insertDashboard, detailDashboard, - importDashboard, exportDashboard, } from "@/api/bigscreen"; import { widgetTools, getToolByCode } from "./tools/index"; @@ -319,7 +327,6 @@ import { debounce } from '@/utils/debounce'; // 引入防抖函数 import loadingViewerVue from 'loading-view-vue' import Vue from "vue"; Vue.use(loadingViewerVue,{mode:"5"}); - export default { name: "Login", components: { @@ -331,7 +338,7 @@ export default { }, data() { return { - uploadUrl:process.env.BASE_API +"/reportDashboard/import/" +this.$route.query.reportCode, + uploadUrl :"http://"+window.location.host+"/xlyReport/reportDashboard/import/" +this.$route.query.reportCode, grade: false, layerWidget: [], widgetTools: widgetTools, // 左侧工具栏的组件图标,将js变量加入到当前作用域 @@ -717,11 +724,11 @@ export default { // 导出 async exportDashboard(val) { const fileName = this.$route.query.reportCode + ".zip"; - const param = { reportCode: this.$route.query.reportCode, showDataSet: val, }; + this.$showLoading(); exportDashboard(param).then((res) => { const that = this; const type = res.type; @@ -734,8 +741,8 @@ export default { }; return; } - const blob = new Blob([res], { type: "application/octet-stream" }); + this.$hideLoading(); if (window.navigator.msSaveOrOpenBlob) { //msSaveOrOpenBlob方法返回bool值 navigator.msSaveBlob(blob, fileName); //本地保存 @@ -748,12 +755,17 @@ export default { } }); }, + //上传之前 + beforeUpload(){ + this.$showLoading(); + }, // 上传成功的回调 handleUpload(response, file, fileList) { //清除el-upload组件中的文件 this.$refs.upload.clearFiles(); //刷新大屏页面 this.initEchartData(); + this.$hideLoading(); if (response.code == "200") { this.$message({ message: "导入成功!", @@ -767,6 +779,7 @@ export default { } }, handleError(err) { + this.$hideLoading(); this.$message({ message: "上传失败!", type: "error", @@ -941,6 +954,8 @@ export default { this.widgetOptions = this.deepClone(this.widgets[obj.index]["options"]); }, widgetsClick(index) { + console.log("222222",process); + console.log("222222",window.location.host,reurl); const draggableArr = this.$refs.widgets; //判断是否按住了shift键盘 if(this.shiftEnt){ -- libgit2 0.22.2