Browse Source

Merge branch 'http_test' into pern

qinzhipeng_v 5 years ago
parent
commit
3a545629e4

+ 23 - 0
src/utils/mesDebounce.js

@@ -0,0 +1,23 @@
+import {
+  Message
+} from 'element-ui'
+
+let messageInstance = null
+const overrideMessage = (options) => {
+  if (messageInstance) {
+    messageInstance.close()
+  }
+  messageInstance = Message(options)
+};
+['error', 'success', 'info', 'warning'].forEach(type => {
+  overrideMessage[type] = options => {
+    if (typeof options === 'string') {
+      options = {
+        message: options
+      }
+    }
+    options.type = type
+    return overrideMessage(options)
+  }
+})
+export const message = overrideMessage

+ 5 - 5
src/utils/request.js

@@ -1,9 +1,9 @@
 import axios from 'axios'
-import { Message } from 'element-ui'
 // import store from '@/store'
 // import { getToken } from '@/utils/auth'
 import { loginUrl } from '@/apiConfig/requestIP.js'
 import { Encrypt } from '@/utils/crypto-js.js'
+import { message } from '@/utils/mesDebounce'
 
 // create an axios instance
 const service = axios.create({
@@ -51,13 +51,13 @@ service.interceptors.response.use(
   response => {
     const res = response.data
     if (typeof res.code !== 'undefined' && res.code !== 200 && res.code !== 0) {
-      Message({
+      message({
         message: res.msg || 'Error',
         type: 'error',
         duration: 5 * 1000
       })
     } else if (typeof res.retCode !== 'undefined' && res.retCode !== 0) {
-      Message({
+      message({
         message: res.retMsg || 'Error',
         type: 'error',
         duration: 5 * 1000
@@ -108,7 +108,7 @@ service.interceptors.response.use(
         default:
           error.message = `未知错误${error.response.status}`
       }
-      Message({
+      message({
         message: error.message,
         type: 'warning',
         duration: 5 * 1000
@@ -118,7 +118,7 @@ service.interceptors.response.use(
       }
     } else {
       error.message = '网络请求超时,请检查网络信息!'
-      Message({
+      message({
         message: error.message,
         type: 'warning',
         duration: 5 * 1000

+ 41 - 10
src/views/Platform/presentation/DailyNewsAdded.vue

@@ -15,10 +15,9 @@
       <div class="backStyle" style="margin-top: 10px;">三. bug情况</div>
       <div style="border: 1px,solid #ccc;">
         <div style="color: #606266">1、bug统计</div>
-        <div style="display:flex;">
-          <div id="lineShow" style="flex:2; width: 400px;height:430px;" />
-          <div style="flex:1; width: 200px;height:400px;" />
-          <div id="barShow" style="flex:2; width: 400px;height:400px;" />
+        <div :class="{'space-between' : xaxisTotal < 7} ">
+          <div id="lineShow" :class="{'backTop' : xaxisTotal < 7,'backLeft' : xaxisTotal > 6}" />
+          <div id="barShow" :class="{'backTop' : xaxisTotal < 7, 'backLeft' : xaxisTotal > 6}" />
         </div>
         <div style="color: #606266; margin: 1% 0;">2、bug说明</div>
         <el-row>
@@ -26,7 +25,6 @@
         </el-row>
       </div>
     </el-form>
-
   </div>
 </template>
 
@@ -76,6 +74,7 @@ export default {
       statusMap: [],
       statusList: [],
       dailys: '',
+      xaxisTotal: 0,
       setHeight: 500
     }
   },
@@ -83,7 +82,14 @@ export default {
     this.getRouterData()
   },
   mounted() {
-
+    const myChart = echarts.init(document.getElementById('lineShow'))
+    const myChartA = echarts.init(document.getElementById('barShow'))
+    window.addEventListener('resize', () => {
+      if (myChart) {
+        myChart.resize()
+        myChartA.resize()
+      }
+    })
   },
   methods: {
     getRouterData() {
@@ -97,6 +103,11 @@ export default {
         this.statusMap = res.data.statusMap
         this.statusList = res.data.statusList
         this.numList = res.data.bugMap
+        if (this.dateList.length >= 6 || this.statusList.length >= 6) {
+          this.xaxisTotal = 7
+        } else {
+          this.xaxisTotal = 1
+        }
         for (var ele of this.numList) {
           this.bugName.push(ele.name)
         }
@@ -106,24 +117,27 @@ export default {
             color: ['#2F54EB', '#13C2C2', '#F78B16', '#9254DE'],
             tooltip: { trigger: 'axis' },
             legend: { top: 30, data: this.bugName },
-            grid: { left: '5%', right: '10%', bottom: '12%', containLabel: true },
+            grid: { left: '5%', right: '5%', bottom: '12%', containLabel: true },
             xAxis: { type: 'category', boundaryGap: true, data: this.dateList, axisLabel: { interval: 0, rotate: 30 }},
             yAxis: { type: 'value' },
             series: this.numList
           })
-        }, 500)
+          echarts.init(document.getElementById('lineShow')).resize()
+        }, 1000)
         setTimeout(item => {
           echarts.init(document.getElementById('barShow')).setOption({
             title: { text: 'bug状态汇总', x: 'center' },
             color: ['#2F54EB', '#13C2C2', '#F78B16', '#9254DE'],
             tooltip: { trigger: 'axis' },
             legend: { top: 30, data: this.statusMap },
+            grid: { left: '5%', right: '5%', bottom: '12%', containLabel: true },
             xAxis: [{ data: this.statusList, axisLabel: { interval: 0, rotate: 45 }}],
             yAxis: [{}],
             series: this.statusMap
           })
-        })
-      }, 500)
+          echarts.init(document.getElementById('barShow')).resize()
+        }, 500)
+      })
     },
     parentHandleclick(e, task, id) {
       if (e === 1) {
@@ -189,4 +203,21 @@ export default {
     border-radius: 4px;
     margin: 1% 0;
   }
+
+  .space-between {
+    display:flex;
+    align-items: center;
+    justify-content: space-between;
+  }
+
+  .backTop {
+    flex:1.5;
+    width: 400px;
+    height:400px;
+  }
+
+  .backLeft {
+    width: 100%;
+    height:400px;
+  }
 </style>

+ 38 - 6
src/views/Platform/presentation/testPresenyL.vue

@@ -10,10 +10,9 @@
       <div class="titleStyle" style="margin-top: 10px;">三. bug情况</div>
       <div style="border: 1px,solid #ccc;font-size:14px;color:#606266;padding-bottom: 20px;">
         <div style="margin: 1%;">1、bug统计</div>
-        <div style="display:flex;">
-          <div id="lineShow" style="flex:2;width: 400px;height:400px;" />
-          <div style="flex:1; width: 200px;height:400px;" />
-          <div id="barShow" style="flex:2; width: 400px;height:400px;" />
+        <div :class="{'space-between' : xaxisTotal < 7} ">
+          <div id="lineShow" :class="{'backTop' : xaxisTotal < 7,'backLeft' : xaxisTotal > 6}" />
+          <div id="barShow" :class="{'backTop' : xaxisTotal < 7, 'backLeft' : xaxisTotal > 6}" />
         </div>
         <div style="margin: 1%;">2、bug说明:</div>
         <div class="pre-line">{{ bugshow }}</div>
@@ -49,11 +48,20 @@ export default {
       statusMap: [],
       statusList: [],
       pro: '',
+      xaxisTotal: 0,
       name: ''
     }
   },
   mounted() {
     this.idGet()
+    const myChart = echarts.init(document.getElementById('lineShow'))
+    const myChartA = echarts.init(document.getElementById('barShow'))
+    window.addEventListener('resize', () => {
+      if (myChart) {
+        myChart.resize()
+        myChartA.resize()
+      }
+    })
   },
   methods: {
     idGet() {
@@ -71,26 +79,33 @@ export default {
         for (var ele of this.numList) {
           this.bugName.push(ele.name)
         }
+        if (this.dateList.length >= 6 || this.statusList.length >= 6) {
+          this.xaxisTotal = 7
+        } else {
+          this.xaxisTotal = 1
+        }
         this.$nextTick(() => {
           echarts.init(document.getElementById('lineShow')).setOption({
             title: { left: 'center', text: 'bug数量汇总' },
             tooltip: { trigger: 'axis' },
             legend: { top: 30, data: this.bugName },
-            grid: { left: '5%', right: '25%', bottom: '12%', containLabel: true },
+            grid: { left: '5%', right: '5%', bottom: '12%', containLabel: true },
             xAxis: { type: 'category', boundaryGap: true, data: this.dateList, axisLabel: { interval: 0, rotate: 30 }},
             yAxis: { type: 'value' },
             series: this.numList
           })
+          echarts.init(document.getElementById('lineShow')).resize()
           echarts.init(document.getElementById('barShow')).setOption({
             title: { text: 'bug状态汇总', x: 'center' },
             color: ['#003366', '#006699', '#4cabce', '#e5323e'],
             tooltip: { trigger: 'axis' },
             legend: { top: 30, data: this.statusMap },
-            grid: { left: '5%', right: '25%', bottom: '12%', containLabel: true },
+            grid: { left: '5%', right: '5%', bottom: '12%', containLabel: true },
             xAxis: [{ data: this.statusList, axisLabel: { interval: 0, rotate: 30 }}],
             yAxis: [{}],
             series: this.statusMap
           })
+          echarts.init(document.getElementById('barShow')).resize()
         })
       })
     }
@@ -110,6 +125,23 @@ export default {
     font-size: 17px;
     font-weight: bold;
   }
+
+  .space-between {
+    display:flex;
+    align-items: center;
+    justify-content: space-between;
+  }
+
+  .backTop {
+    flex:1.5;
+    width: 400px;
+    height:400px;
+  }
+
+  .backLeft {
+    width: 100%;
+    height:400px;
+  }
   #app .hideSidebar .sidebar-container {
     display: none;
   }