Browse Source

用例合并

wenbobowen 4 years ago
parent
commit
68d2508f62

+ 16 - 0
src/apiConfig/requestIP.js

@@ -16,6 +16,22 @@ if (location.host.indexOf('localhost') < 0) {
   }
 }
 
+export function getEnv() {
+  let env = 'test'
+  if (location.host.indexOf('localhost') < 0) {
+    host = 'http://' + location.host
+    requestIp = host + '/zuul'
+    loginUrl = host + '/sso/login?jumpto=' + location.href
+    logoutUrl = host + '/sso/logout?jumpto=' + location.href
+    if (host.indexOf('zhihui-pre.intra.xiaojukeji.com') >= 0) {
+      env = 'pre'
+    } else if (host.indexOf('zhihui.xiaojukeji.com') >= 0) {
+      env = 'online'
+    }
+  }
+  return env
+}
+
 export let ws = '10.78.128.20:10234'
 if (location.host.match(/localhost/) || location.host.match(/zhihui-test/)) {
   ws = '10.78.128.20:10232'

+ 1 - 1
src/router/newRouter.js

@@ -197,7 +197,7 @@ const layout = [
         name: '测试用例',
         icon: 'test-case',
         cutOff: true,
-        component: () => import('@/views/Platform/useCasePage'),
+        component: () => import('@/views/useCase'),
         meta: { title: '测试用例' }
       },
       {

+ 0 - 3
src/views/Platform/useCasePage.vue

@@ -213,9 +213,6 @@ export default {
     this.im_File = document.getElementById('im_File')
     this.initWindow()
   },
-  activated() {
-    this.updateCaseListData()
-  },
   methods: {
     // 左侧导航栏
     AllQueryFolderData(e) {

+ 69 - 0
src/views/useCase/components/requirementCase.vue

@@ -0,0 +1,69 @@
+<template>
+  <section v-if="bizId !== -1" class="case-main">
+    <iframe
+      id="useCaseIframe"
+      frameborder="0"
+      scrolling="no"
+      :src="src"
+    />
+  </section>
+</template>
+<script>
+import { mapGetters } from 'vuex'
+import { EncryptId } from '@/utils/crypto-js.js'
+import { getEnv } from '@/apiConfig/requestIP.js'
+
+export default {
+  data() {
+    return {
+      ifr: null,
+      srcHost: '/case/caseList/zhihui/'
+    }
+  },
+  computed: {
+    ...mapGetters(['bizId']),
+    src() {
+      const bizId = EncryptId(`${this.bizId}`)
+      const host = getEnv() === 'test' ? 'http://10.96.83.94:9000/index.html#' : 'http://agiletc.intra.xiaojukeji.com/#'
+      const src = `${host}${this.srcHost}${bizId}`
+      return src
+    }
+  },
+  watch: {
+    bizId: {
+      handler(newV) {
+        if (newV === -1) return
+        this.matchObj = { params: { product_id: newV }}
+      },
+      immediate: true
+    }
+  },
+  mounted() {
+    window.addEventListener('message', (e) => {
+      if (e.data === 'useCaseDone') {
+        this.loaded()
+      }
+    }, false)
+  },
+  methods: {
+    loaded() {
+      const ifr = document.getElementById('useCaseIframe')
+      if (ifr) {
+        ifr.contentWindow.postMessage({ user: localStorage.getItem('username') }, '*')
+      }
+    }
+  }
+}
+</script>
+<style lang="scss" scoped>
+.case-main {
+  // padding: 20px 0 20px 18px;
+  margin: 10px;
+  // border-radius: 10px;
+  overflow: scroll;
+}
+#useCaseIframe {
+  width: 100%;
+  height: 100vh;
+}
+</style>

+ 58 - 0
src/views/useCase/index.vue

@@ -0,0 +1,58 @@
+<template>
+  <section class="all-useCase">
+    <div class="control-pages">
+      <span class="control-item" :class="{'is-active':isActive === 1}" @click="isActive=1">需求用例</span>
+      <span class="control-item" :class="{'is-active':isActive === 2}" @click="isActive=2">老版用例</span>
+    </div>
+    <keep-alive>
+      <requirement-case v-if="isActive === 1" />
+      <test-use-case v-if="isActive === 2" />
+    </keep-alive>
+  </section>
+</template>
+<script>
+import requirementCase from '@/views/useCase/components/requirementCase'
+import testUseCase from '@/views/Platform/useCasePage'
+export default {
+  components: {
+    requirementCase,
+    testUseCase
+  },
+  data() {
+    return {
+      isActive: 1
+    }
+  },
+  watch: {
+    isActive: {
+      handler(newV) {
+        newV > 0
+          ? this.$router.replace({ path: this.$route.path, query: { ...this.$route.query, page: newV }})
+          : this.$router.replace({ path: this.$route.path, query: { ...this.$route.query, page: 1 }})
+      }
+    }
+  },
+  created() {
+    this.$nextTick(() => {
+      this.isActive = this.$route.query.page ? Number(this.$route.query.page) : 1
+    })
+  }
+}
+</script>
+<style scoped lang="scss">
+.control-pages {
+  margin: 10px 10px 0 10px;
+  padding: 10px 20px 10px 20px;
+  border-radius: 4px;
+  background-color: #ffffff;
+  .control-item {
+    margin-right: 30px;
+    padding-bottom: 10px;
+    cursor: pointer;
+  }
+  .is-active {
+    color:#4099ff;
+    border-bottom: 1px solid #4099ff;
+  }
+}
+</style>

+ 4 - 1
src/views/workbench/components/statisticsSection.vue

@@ -34,7 +34,7 @@
               </el-tooltip>
             </el-radio-button>
           </el-radio-group>
-          <h3 @click="getAll()">总数:<span>{{ totalTask }}</span></h3>
+          <h3 class="mt5" @click="getAll()">总数:<span>{{ totalTask }}</span></h3>
           <div class="chart-contain">
             <status-stay-chart :chart-data="echartsOption" @onClick="chartChange" />
             <!-- <normal-echart v-if="echartsOption" :chart-id="type+title" :option="echartsOption" @onClick="chartChange" /> -->
@@ -319,6 +319,9 @@ export default {
   }
 }
 .statistics-chart {
+  .mt5 {
+    margin-top: 5px;
+  }
   .two-title {
     width: 100%;
     display: grid;