ApiHeaderMenus.vue 4.8 KB
Newer Older
C
chenjianxing 已提交
1
<template>
Q
q4speed 已提交
2
  <div id="menu-bar">
Q
q4speed 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    <el-row type="flex">
      <el-col :span="8">
        <el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'>
          <el-menu-item :index="'/api/home'">
            {{ $t("i18n.home") }}
          </el-menu-item>

          <el-submenu v-if="isCurrentWorkspaceUser"
                      index="3" popper-class="submenu" v-permission="['test_manager']">
            <template v-slot:title>{{$t('commons.project')}}</template>
            <ms-recent-list :options="projectRecent"/>
            <el-divider/>
            <ms-show-all :index="'/api/project/all'"/>
            <ms-create-button :index="'/api/project/create'" :title="$t('project.create')"/>
          </el-submenu>

          <el-submenu v-if="isCurrentWorkspaceUser"
                      index="4" popper-class="submenu" v-permission="['test_manager', 'test_user']">
            <template v-slot:title>{{$t('commons.test')}}</template>
            <ms-recent-list :options="testRecent"/>
            <el-divider/>
Q
q4speed 已提交
24
            <ms-show-all :index="'/api/test/list/all'"/>
Q
q4speed 已提交
25
            <ms-create-button :index="'/api/test/create'" :title="$t('load_test.create')"/>
Q
q4speed 已提交
26 27
<!--            <el-menu-item :index="testCaseProjectPath" class="blank_item"></el-menu-item>-->
<!--            <el-menu-item :index="testEditPath" class="blank_item"></el-menu-item>-->
Q
q4speed 已提交
28 29 30 31 32 33 34 35
          </el-submenu>

          <el-submenu v-if="isCurrentWorkspaceUser"
                      index="5" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
            <template v-slot:title>{{$t('commons.report')}}</template>
            <ms-recent-list :options="reportRecent"/>
            <el-divider/>
            <ms-show-all :index="'/api/report/all'"/>
Q
q4speed 已提交
36
<!--            <el-menu-item :index="reportViewPath" class="blank_item"></el-menu-item>-->
Q
q4speed 已提交
37 38 39 40 41 42 43 44 45 46
          </el-submenu>
        </el-menu>
      </el-col>
      <el-col :span="8">
        <el-row type="flex" justify="center">
          <ms-create-test :show="isCurrentWorkspaceUser" :to="'/api/test/create'"/>
        </el-row>
      </el-col>
      <el-col :span="8"/>
    </el-row>
C
chenjianxing 已提交
47 48 49 50 51 52
  </div>

</template>

<script>

C
Captain.B 已提交
53
  import {checkoutCurrentWorkspace} from "../../../../common/js/utils";
Q
q4speed 已提交
54 55 56 57
  import MsRecentList from "../../common/head/RecentList";
  import MsShowAll from "../../common/head/ShowAll";
  import MsCreateButton from "../../common/head/CreateButton";
  import MsCreateTest from "../../common/head/CreateTest";
C
chenjianxing 已提交
58 59

  export default {
Q
q4speed 已提交
60
    name: "MsApiHeaderMenus",
Q
q4speed 已提交
61
    components: {MsCreateTest, MsCreateButton, MsShowAll, MsRecentList},
C
chenjianxing 已提交
62 63 64
    data() {
      return {
        isCurrentWorkspaceUser: false,
Q
q4speed 已提交
65 66 67 68
        // testCaseProjectPath: '',
        // testEditPath: '',
        // reportViewPath: '',
        // isRouterAlive: true,
Q
q4speed 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
        projectRecent: {
          title: this.$t('project.recent'),
          url: "/project/recent/5",
          index: function (item) {
            return '/api/' + item.id;
          },
          router: function (item) {
            return {name: 'fucPlan', params: {projectId: item.id, projectName: item.name}}
          }
        },
        testRecent: {
          title: this.$t('load_test.recent'),
          url: "/api/recent/5",
          index: function (item) {
            return '/api/test/edit/' + item.id;
Q
q4speed 已提交
84 85 86
          },
          router: function (item) {
            return {path: '/api/test/edit', query: {id: item.id}}
Q
q4speed 已提交
87 88 89
          }
        },
        reportRecent: {
Q
q4speed 已提交
90
          title: this.$t('report.recent'),
Q
q4speed 已提交
91 92 93 94 95
          url: "/api/report/recent/5",
          index: function (item) {
            return '/api/report/view/' + item.id;
          }
        }
C
chenjianxing 已提交
96 97
      }
    },
Q
q4speed 已提交
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
    // watch: {
    //   '$route'(to, from) {
    //     let path = to.path;
    //     //激活菜单栏
    //     if (path.indexOf("/api/test/") >= 0) {
    //       this.testCaseProjectPath = '/api/test/' + this.$route.params.projectId;
    //       this.reload();
    //     }
    //     if (path.indexOf("/api/test/edit/") >= 0) {
    //       this.testEditPath = '/api/test/edit/' + this.$route.params.testId;
    //       this.reload();
    //     }
    //     if (path.indexOf("/api/report/view/") >= 0) {
    //       this.reportViewPath = '/api/report/view/' + this.$route.params.reportId;
    //       this.reload();
    //     }
    //   }
    // },
C
chenjianxing 已提交
116 117
    mounted() {
      this.isCurrentWorkspaceUser = checkoutCurrentWorkspace();
C
chenjianxing 已提交
118
    },
Q
q4speed 已提交
119 120 121 122 123 124 125 126
    // methods: {
    //   reload() {
    //     this.isRouterAlive = false;
    //     this.$nextTick(function () {
    //       this.isRouterAlive = true;
    //     })
    //   }
    // }
C
chenjianxing 已提交
127 128 129 130 131 132 133 134
  }

</script>

<style scoped>
  .el-divider--horizontal {
    margin: 0;
  }
Q
q4speed 已提交
135

Q
q4speed 已提交
136 137 138 139
  .el-menu.el-menu--horizontal {
    border-bottom: none;
  }

C
chenjianxing 已提交
140 141
  #menu-bar {
    border-bottom: 1px solid #E6E6E6;
Q
q4speed 已提交
142
    background-color: #FFF;
C
chenjianxing 已提交
143
  }
C
chenjianxing 已提交
144 145 146 147 148

  .blank_item {
    display: none;
  }

C
chenjianxing 已提交
149
</style>