Ver código fonte

02/03 11:25

学生导出加这在
261568008@qq.com 5 anos atrás
pai
commit
960e852f11
3 arquivos alterados com 42 adições e 19 exclusões
  1. 20 0
      src/utils/loading.js
  2. 19 19
      src/utils/request.js
  3. 3 0
      src/views/studentManager/studentList.vue

+ 20 - 0
src/utils/loading.js

@@ -0,0 +1,20 @@
+import { Loading } from 'element-ui'
+let loading        //定义loading变量
+
+function startLoading () {    //使用Element loading-start 方法
+  loading = Loading.service({
+    lock: true,
+    fullscreen: true,
+    text: '加载中……',
+    background: 'rgba(0, 0, 0, 0.7)'
+  })
+}
+function endLoading () {
+  //使用Element loading-close 方法
+  loading.close();
+}
+
+export default {
+    startLoading,
+    endLoading
+}

+ 19 - 19
src/utils/request.js

@@ -3,9 +3,9 @@ import axios from 'axios'
 import { Message } from 'element-ui'
 import store from '@/store'
 import { getToken } from '@/utils/auth'
-import { Loading } from 'element-ui'
-import router from '@/router/index'
-// import '@/main'
+// import { Loading } from 'element-ui'
+import load from '@/utils/loading'
+import router from '@/router/index' 
 import Vue from 'vue'
 const showMessage = Symbol('showMessage')
 class DonMessage {
@@ -39,27 +39,27 @@ Vue.prototype.$message = new DonMessage()
 
 let vue = new Vue()
 
-let loading        //定义loading变量
-
-function startLoading () {    //使用Element loading-start 方法
-  loading = Loading.service({
-    lock: true,
-    fullscreen: true,
-    text: '加载中……',
-    background: 'rgba(0, 0, 0, 0.7)'
-  })
-}
-function endLoading () {
-  //使用Element loading-close 方法
-  loading.close();
-}
+// let loading        //定义loading变量
+
+// function startLoading () {    //使用Element loading-start 方法
+//   loading = Loading.service({
+//     lock: true,
+//     fullscreen: true,
+//     text: '加载中……',
+//     background: 'rgba(0, 0, 0, 0.7)'
+//   })
+// }
+// function endLoading () {
+//   //使用Element loading-close 方法
+//   loading.close();
+// }
 //那么 showFullScreenLoading() tryHideFullScreenLoading() 要干的事儿就是将同一时刻的请求合并。
 //声明一个变量 needLoadingRequestCount,每次调用showFullScreenLoading方法 needLoadingRequestCount + 1。
 //调用tryHideFullScreenLoading()方法,needLoadingRequestCount - 1。needLoadingRequestCount为 0 时,结束 loading。
 let needLoadingRequestCount = 0
 function showFullScreenLoading () {
   if (needLoadingRequestCount === 0) {
-    startLoading()
+    load.startLoading()
   }
   needLoadingRequestCount++
 
@@ -69,7 +69,7 @@ function tryHideFullScreenLoading () {
   if (needLoadingRequestCount <= 0) return
   needLoadingRequestCount--
   if (needLoadingRequestCount === 0) {
-    endLoading();
+    load.endLoading();
 
   }
 

+ 3 - 0
src/views/studentManager/studentList.vue

@@ -242,6 +242,7 @@ import store from '@/store'
 import axios from 'axios'
 import qs from 'qs'
 import { getToken } from '@/utils/auth'
+import load from '@/utils/loading'
 export default {
   name: 'studentList',
   components: { pagination },
@@ -376,6 +377,7 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
+        load.startLoading()
         axios(options).then(res => {
           let blob = new Blob([res.data], {
             // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
@@ -391,6 +393,7 @@ export default {
           link.setAttribute("download", fname)
           document.body.appendChild(link)
           link.click()
+           load.endLoading();
         })
       }).catch(() => { })