hfxc226 há 2 anos atrás
pai
commit
8084dd191a
2 ficheiros alterados com 25 adições e 4 exclusões
  1. 21 0
      src/views/sb/measure/MeasureSbInfo.vue
  2. 4 4
      vue.config.js

+ 21 - 0
src/views/sb/measure/MeasureSbInfo.vue

@@ -513,6 +513,9 @@ export default {
         this.queryParam.nextCheckDateEnd = this.dateRange[1]
         this.queryParam.nextCheckDateStart = this.queryParam.nextCheckDateStart ? this.queryParam.nextCheckDateStart.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
         this.queryParam.nextCheckDateEnd = this.queryParam.nextCheckDateEnd ? this.queryParam.nextCheckDateEnd.format(this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
+      } else {
+        this.$message.error('请选择有效日期范围')
+        return
       }
       if (this.dateRangeCheck != null) {
         this.queryParam.checkDateStart = this.dateRangeCheck[0]
@@ -577,9 +580,27 @@ export default {
         ...this.queryParam
       }
       exportSbInfoMeasureTwo(parameter).then(file => {
+        console.log(file)
+        if (file.data.type === 'application/json') {
+          this.handleResponseError(file.data)
+          return
+        }
         this.BaseTool.UPLOAD.downLoadExportExcel(file)
       })
     },
+    handleResponseError (data) {
+      const _this = this
+      const fileReader = new FileReader()
+      fileReader.onload = function () {
+        try {
+          const jsonData = JSON.parse(fileReader.result)
+          _this.$message.error(jsonData.message)
+        } catch (err) {
+          console.log('返回文件流,正确的')
+        }
+      }
+      fileReader.readAsText(data)
+    },
     setTree (record = {}) {
       fetchSbTypeTree().then(res => {
         this.treeData = res.data

+ 4 - 4
vue.config.js

@@ -28,12 +28,12 @@ const assetsCDN = {
 }
 
 // webpack build externals
-const prodExternals = {
+/* const prodExternals = {
   vue: 'Vue',
   'vue-router': 'VueRouter',
   vuex: 'Vuex',
   axios: 'axios'
-}
+} */
 
 // vue.config.js
 const vueConfig = {
@@ -43,9 +43,9 @@ const vueConfig = {
       // Ignore all locale files of moment.js
       new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
 
-    ],
+    ]
     // if prod is on, add externals
-    externals: isProd() ? prodExternals : {}
+    // externals: isProd() ? prodExternals : {}
   },
 
   chainWebpack: (config) => {