TestPlanView.vue 3.3 KB
Newer Older
C
chenjianxing 已提交
1
<template>
C
chenjianxing 已提交
2 3 4 5 6 7
  <div class="main-content">
    <el-container class="view-container">
      <el-aside class="tree-aside">
        <select-menu
          :data="testPlans"
          :current-data="currentPlan"
C
chenjianxing 已提交
8
          :title="$t('test_track.plan_view.plan')"
C
chenjianxing 已提交
9
          @dataChange="changePlan"/>
C
chenjianxing 已提交
10

C
chenjianxing 已提交
11 12 13 14 15 16
        <node-tree class="node-tree"
                   v-loading="result.loading"
                   @nodeSelectEvent="nodeChange"
                   @refresh="refresh"
                   :tree-nodes="treeNodes"
                   ref="nodeTree"/>
C
chenjianxing 已提交
17 18
      </el-aside>

C
样式  
chenjianxing 已提交
19
      <el-main>
C
chenjianxing 已提交
20 21
        <test-plan-test-case-list
          @openTestCaseRelevanceDialog="openTestCaseRelevanceDialog"
C
chenjianxing 已提交
22 23
          @refresh="refresh"
          :plan-id="planId"
C
chenjianxing 已提交
24
          :select-node-ids="selectNodeIds"
C
chenjianxing 已提交
25
          :select-node-names="selectNodeNames"
C
chenjianxing 已提交
26
          ref="testCasePlanList"/>
C
chenjianxing 已提交
27 28 29 30 31 32
      </el-main>
    </el-container>

    <test-case-relevance
      @refresh="refresh"
      :plan-id="planId"
C
chenjianxing 已提交
33
      ref="testCaseRelevance"/>
C
chenjianxing 已提交
34 35 36 37 38 39
  </div>

</template>

<script>

C
chenjianxing 已提交
40
    import NodeTree from "../common/NodeTree";
C
chenjianxing 已提交
41
    import TestPlanTestCaseList from "./components/TestPlanTestCaseList";
C
chenjianxing 已提交
42
    import TestCaseRelevance from "./components/TestCaseRelevance";
43
    import SelectMenu from "../common/SelectMenu";
C
chenjianxing 已提交
44 45 46

    export default {
      name: "TestPlanView",
C
chenjianxing 已提交
47
      components: {NodeTree, TestPlanTestCaseList, TestCaseRelevance, SelectMenu},
C
chenjianxing 已提交
48 49
      data() {
        return {
C
chenjianxing 已提交
50
          result: {},
51
          testPlans: [],
C
chenjianxing 已提交
52
          currentPlan: {},
C
chenjianxing 已提交
53
          selectNodeIds: [],
C
chenjianxing 已提交
54 55
          selectNodeNames: [],
          treeNodes: []
C
chenjianxing 已提交
56 57 58 59 60 61 62
        }
      },
      computed: {
        planId: function () {
          return this.$route.params.planId;
        }
      },
C
chenjianxing 已提交
63 64
      mounted() {
        this.initData();
65 66 67
      },
      watch: {
        planId() {
C
chenjianxing 已提交
68
          this.initData();
69 70
        }
      },
C
chenjianxing 已提交
71 72
      methods: {
        refresh() {
C
chenjianxing 已提交
73
          this.selectNodeIds = [];
C
chenjianxing 已提交
74
          this.selectNodeNames = [];
C
chenjianxing 已提交
75
          this.getNodeTreeByPlanId();
C
chenjianxing 已提交
76
        },
C
chenjianxing 已提交
77 78 79
        initData() {
          this.getTestPlans();
          this.getNodeTreeByPlanId();
C
chenjianxing 已提交
80
        },
C
chenjianxing 已提交
81
        openTestCaseRelevanceDialog() {
C
chenjianxing 已提交
82
          this.$refs.testCaseRelevance.openTestCaseRelevanceDialog();
C
chenjianxing 已提交
83
        },
84 85 86 87 88 89 90 91 92 93
        getTestPlans() {
          this.result = this.$post('/test/plan/list/all', {}, response => {
            this.testPlans = response.data;
            this.testPlans.forEach(plan => {
              if (this.planId && plan.id === this.planId) {
                this.currentPlan = plan;
              }
            });
          });
        },
C
chenjianxing 已提交
94 95 96 97
        nodeChange(nodeIds, nodeNames) {
          this.selectNodeIds = nodeIds;
          this.selectNodeNames = nodeNames;
        },
98 99 100
        changePlan(plan) {
          this.currentPlan = plan;
          this.$router.push('/track/plan/view/' + plan.id);
C
chenjianxing 已提交
101 102 103 104 105 106 107
        },
        getNodeTreeByPlanId() {
          if(this.planId){
            this.result = this.$get("/case/node/list/plan/" + this.planId, response => {
              this.treeNodes = response.data;
            });
          }
C
chenjianxing 已提交
108 109 110 111 112 113 114
        }
      }
    }
</script>

<style scoped>

C
chenjianxing 已提交
115 116 117

  .node-tree {
    margin: 3%;
C
chenjianxing 已提交
118 119
  }

C
chenjianxing 已提交
120 121 122
  .view-container {
    height: calc(100vh - 150px);
    min-height: 600px;
C
chenjianxing 已提交
123 124
  }

C
chenjianxing 已提交
125 126 127 128
  .tree-aside {
    position: relative;
    border: 1px solid #EBEEF5;
    box-sizing: border-box;
C
样式  
chenjianxing 已提交
129
    background: white;
C
chenjianxing 已提交
130
  }
C
chenjianxing 已提交
131

C
样式  
chenjianxing 已提交
132 133
  .el-main {
    padding: 15px;
134 135
  }

C
chenjianxing 已提交
136
</style>