TestPlanTestCaseList.vue 10.0 KB
Newer Older
C
chenjianxing 已提交
1
<template>
C
chenjianxing 已提交
2
  <el-card v-loading="result.loading">
C
chenjianxing 已提交
3
      <template v-slot:header>
C
chenjianxing 已提交
4 5
        <ms-table-header :condition.sync="condition" @search="initTableData" :show-create="false">
          <template v-slot:title>
C
样式  
chenjianxing 已提交
6
            <node-breadcrumb class="table-title" :node-names="selectNodeNames" @refresh="refresh"/>
C
chenjianxing 已提交
7 8 9 10 11 12 13 14 15
          </template>
          <template v-slot:button>
            <ms-table-button v-if="!showMyTestCase" icon="el-icon-s-custom" :content="$t('test_track.plan_view.my_case')" @click="searchMyTestCase"/>
            <ms-table-button v-if="showMyTestCase" icon="el-icon-files" :content="$t('test_track.plan_view.all_case')" @click="searchMyTestCase"/>
            <ms-table-button icon="el-icon-connection" :content="$t('test_track.plan_view.relevance_test_case')" @click="$emit('openTestCaseRelevanceDialog')"/>
            <ms-table-button icon="el-icon-edit-outline" :content="$t('test_track.plan_view.change_execution_results')" @click="handleBatch('status')"/>
            <ms-table-button icon="el-icon-user" :content="$t('test_track.plan_view.change_executor')" @click="handleBatch('executor')"/>
          </template>
        </ms-table-header>
C
chenjianxing 已提交
16
      </template>
C
chenjianxing 已提交
17

C
chenjianxing 已提交
18 19 20
      <executor-edit ref="executorEdit" :select-ids="selectIds" @refresh="initTableData"/>
      <status-edit ref="statusEdit" :select-ids="selectIds" @refresh="initTableData"/>

C
chenjianxing 已提交
21
      <el-table
22 23 24
        @select-all="handleSelectAll"
        @select="handleSelectionChange"
        row-key="id"
C
chenjianxing 已提交
25 26
        :data="tableData">

27 28 29
        <el-table-column
          type="selection"></el-table-column>

C
chenjianxing 已提交
30 31
        <el-table-column
          prop="name"
C
chenjianxing 已提交
32
          :label="$t('commons.name')">
C
chenjianxing 已提交
33 34 35
        </el-table-column>
        <el-table-column
          prop="priority"
C
chenjianxing 已提交
36 37
          :filters="priorityFilters"
          :filter-method="filter"
C
chenjianxing 已提交
38
          :label="$t('test_track.case.priority')">
C
chenjianxing 已提交
39
          <template v-slot:default="scope">
C
chenjianxing 已提交
40
            <priority-table-item :value="scope.row.priority" ref="priority"/>
C
chenjianxing 已提交
41
          </template>
C
chenjianxing 已提交
42
        </el-table-column>
C
chenjianxing 已提交
43

C
chenjianxing 已提交
44 45
        <el-table-column
          prop="type"
C
chenjianxing 已提交
46 47
          :filters="typeFilters"
          :filter-method="filter"
C
chenjianxing 已提交
48
          :label="$t('test_track.case.type')"
C
chenjianxing 已提交
49
          show-overflow-tooltip>
C
v-slot  
Captain.B 已提交
50
          <template v-slot:default="scope">
C
chenjianxing 已提交
51
            <type-table-item :value="scope.row.type"/>
C
chenjianxing 已提交
52 53
          </template>
        </el-table-column>
C
chenjianxing 已提交
54

C
chenjianxing 已提交
55 56
        <el-table-column
          prop="method"
C
chenjianxing 已提交
57 58
          :filters="methodFilters"
          :filter-method="filter"
C
chenjianxing 已提交
59
          :label="$t('test_track.case.method')"
C
chenjianxing 已提交
60
          show-overflow-tooltip>
C
v-slot  
Captain.B 已提交
61
          <template v-slot:default="scope">
C
chenjianxing 已提交
62
            <method-table-item :value="scope.row.method"/>
C
chenjianxing 已提交
63 64
          </template>
        </el-table-column>
C
chenjianxing 已提交
65

C
chenjianxing 已提交
66
        <el-table-column
C
chenjianxing 已提交
67
          prop="executor"
C
chenjianxing 已提交
68
          :label="$t('test_track.plan_view.executor')">
C
chenjianxing 已提交
69
        </el-table-column>
C
chenjianxing 已提交
70

C
chenjianxing 已提交
71
        <el-table-column
C
chenjianxing 已提交
72
          prop="status"
C
chenjianxing 已提交
73 74
          :filters="statusFilters"
          :filter-method="filter"
C
chenjianxing 已提交
75
          :label="$t('test_track.plan_view.execute_result')">
C
v-slot  
Captain.B 已提交
76
          <template v-slot:default="scope">
C
chenjianxing 已提交
77
            <status-table-item :value="scope.row.status"/>
C
chenjianxing 已提交
78 79
          </template>
        </el-table-column>
C
chenjianxing 已提交
80

C
chenjianxing 已提交
81
        <el-table-column
C
chenjianxing 已提交
82 83
          sortable
          prop="updateTime"
C
chenjianxing 已提交
84
          :label="$t('commons.update_time')">
C
v-slot  
Captain.B 已提交
85
          <template v-slot:default="scope">
C
chenjianxing 已提交
86 87 88 89 90
            <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
          </template>
        </el-table-column>
        <el-table-column
          :label="$t('commons.operating')">
C
v-slot  
Captain.B 已提交
91
          <template v-slot:default="scope">
C
chenjianxing 已提交
92
            <ms-table-operator @editClick="handleEdit(scope.row, scope.$index)" @deleteClick="handleDelete(scope.row)"/>
C
chenjianxing 已提交
93 94 95 96
          </template>
        </el-table-column>
      </el-table>

C
chenjianxing 已提交
97
      <ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
C
chenjianxing 已提交
98
                           :total="total"/>
C
chenjianxing 已提交
99

100 101
      <test-plan-test-case-edit
        ref="testPlanTestCaseEdit"
C
chenjianxing 已提交
102
        :search-param="condition"
C
chenjianxing 已提交
103 104
        @refresh="refresh"
        @refreshTable="search"/>
105

C
chenjianxing 已提交
106 107 108 109
    </el-card>
</template>

<script>
110 111
  import ExecutorEdit from './ExecutorEdit';
  import StatusEdit from './StatusEdit';
C
chenjianxing 已提交
112 113 114 115 116 117
  import TestPlanTestCaseEdit from "./TestPlanTestCaseEdit";
  import MsTipButton from '../../../../common/components/MsTipButton';
  import MsTablePagination from '../../../../common/pagination/TablePagination';
  import MsTableHeader from '../../../../common/components/MsTableHeader';
  import MsTableButton from '../../../../common/components/MsTableButton';
  import NodeBreadcrumb from '../../../common/NodeBreadcrumb';
C
chenjianxing 已提交
118

C
chenjianxing 已提交
119 120
  import {TokenKey} from '../../../../../../common/js/constants';
  import {tableFilter} from '../../../../../../common/js/utils';
C
chenjianxing 已提交
121 122 123 124
  import PriorityTableItem from "../../../common/tableItems/planview/PriorityTableItem";
  import StatusTableItem from "../../../common/tableItems/planview/StatusTableItem";
  import TypeTableItem from "../../../common/tableItems/planview/TypeTableItem";
  import MethodTableItem from "../../../common/tableItems/planview/MethodTableItem";
C
chenjianxing 已提交
125
  import MsTableOperator from "../../../../common/components/MsTableOperator";
C
chenjianxing 已提交
126

C
v-slot  
Captain.B 已提交
127
  export default {
C
chenjianxing 已提交
128
      name: "TestPlanTestCaseList",
C
chenjianxing 已提交
129
      components: {
C
chenjianxing 已提交
130
        MsTableOperator,
C
chenjianxing 已提交
131 132 133 134
        MethodTableItem,
        TypeTableItem,
        StatusTableItem,
        PriorityTableItem, StatusEdit, ExecutorEdit, MsTipButton, MsTablePagination,
C
chenjianxing 已提交
135
        TestPlanTestCaseEdit, MsTableHeader, NodeBreadcrumb, MsTableButton},
C
chenjianxing 已提交
136 137 138 139
      data() {
        return {
          result: {},
          deletePath: "/test/case/delete",
C
chenjianxing 已提交
140 141
          condition: {},
          showMyTestCase: false,
C
chenjianxing 已提交
142 143 144 145
          tableData: [],
          currentPage: 1,
          pageSize: 5,
          total: 0,
C
chenjianxing 已提交
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
          selectIds: new Set(),
          priorityFilters: [
            {text: 'P0', value: 'P0'},
            {text: 'P1', value: 'P1'},
            {text: 'P2', value: 'P2'}
          ],
          methodFilters: [
            {text: this.$t('test_track.case.manual'), value: 'manual'},
            {text: this.$t('test_track.case.auto'), value: 'auto'}
          ],
          typeFilters: [
            {text: this.$t('commons.functional'), value: 'functional'},
            {text: this.$t('commons.performance'), value: 'performance'},
            {text: this.$t('commons.api'), value: 'api'}
          ],
          statusFilters: [
            {text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
            {text: this.$t('test_track.plan_view.pass'), value: 'Pass'},
            {text: this.$t('test_track.plan_view.failure'), value: 'Failure'},
            {text: this.$t('test_track.plan_view.blocking'), value: 'Blocking'},
            {text: this.$t('test_track.plan_view.skip'), value: 'Skip'},
          ]
C
chenjianxing 已提交
168 169
        }
      },
C
chenjianxing 已提交
170 171 172
      props:{
        planId: {
          type: String
C
chenjianxing 已提交
173 174 175
        },
        selectNodeIds: {
          type: Array
C
chenjianxing 已提交
176 177 178
        },
        selectNodeNames: {
          type: Array
C
chenjianxing 已提交
179 180
        }
      },
C
chenjianxing 已提交
181 182 183
      watch: {
        planId() {
          this.initTableData();
C
chenjianxing 已提交
184 185
        },
        selectNodeIds() {
C
chenjianxing 已提交
186
          this.search();
C
chenjianxing 已提交
187 188
        }
      },
C
chenjianxing 已提交
189 190 191 192
      created: function () {
        this.initTableData();
      },
      methods: {
C
chenjianxing 已提交
193
        initTableData() {
C
chenjianxing 已提交
194
          if (this.planId) {
C
chenjianxing 已提交
195 196 197
            this.condition.planId = this.planId;
            this.condition.nodeIds = this.selectNodeIds;
            this.result = this.$post(this.buildPagePath('/test/plan/case/list'), this.condition, response => {
C
chenjianxing 已提交
198 199 200 201
              let data = response.data;
              this.total = data.itemCount;
              this.tableData = data.listObject;
            });
C
chenjianxing 已提交
202 203
          }
        },
C
chenjianxing 已提交
204 205
        refresh() {
          this.condition = {};
C
chenjianxing 已提交
206
          this.$emit('refresh');
C
chenjianxing 已提交
207
        },
C
chenjianxing 已提交
208 209 210
        search() {
          this.initTableData();
        },
C
chenjianxing 已提交
211 212 213
        buildPagePath(path) {
          return path + "/" + this.currentPage + "/" + this.pageSize;
        },
214
        handleEdit(testCase, index) {
C
chenjianxing 已提交
215
          this.$refs.testPlanTestCaseEdit.openTestCaseEdit(testCase);
C
chenjianxing 已提交
216 217
        },
        handleDelete(testCase) {
C
chenjianxing 已提交
218
          this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + ' ' + testCase.name + "", '', {
C
chenjianxing 已提交
219 220 221 222 223 224 225 226 227 228
            confirmButtonText: this.$t('commons.confirm'),
            callback: (action) => {
              if (action === 'confirm') {
                this._handleDelete(testCase);
              }
            }
          });
        },
        _handleDelete(testCase) {
          let testCaseId = testCase.id;
C
chenjianxing 已提交
229
          this.$post('/test/plan/case/delete/' + testCaseId, {}, () => {
C
chenjianxing 已提交
230
            this.$emit("refresh");
C
chenjianxing 已提交
231 232 233 234 235
            this.$message({
              message: this.$t('commons.delete_success'),
              type: 'success'
            });
          });
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
        },
        handleSelectAll(selection) {
          if(selection.length > 0) {
            this.tableData.forEach(item => {
              this.selectIds.add(item.id);
            });
          } else {
            this.selectIds.clear();
          }
        },
        handleSelectionChange(selection, row) {
          if(this.selectIds.has(row.id)){
            this.selectIds.delete(row.id);
          } else {
            this.selectIds.add(row.id);
          }
        },
        handleBatch(type){
          if (this.selectIds.size < 1) {
C
chenjianxing 已提交
255
            this.$message.warning(this.$t('test_track.plan_view.select_manipulate'));
256 257 258 259 260 261 262
            return;
          }
          if (type === 'executor'){
            this.$refs.executorEdit.openExecutorEdit();
          } else if (type === 'status'){
            this.$refs.statusEdit.openStatusEdit();
          }
C
chenjianxing 已提交
263 264 265 266 267 268 269 270 271 272
        },
        searchMyTestCase() {
          this.showMyTestCase = !this.showMyTestCase;
          if (this.showMyTestCase) {
            let user =  JSON.parse(localStorage.getItem(TokenKey));
            this.condition.executor = user.id;
          } else {
            this.condition.executor = null;
          }
          this.initTableData();
C
chenjianxing 已提交
273 274 275 276
        },
        filter(value, row, column) {
          const property = column['property'];
          return row[property] === value;
C
chenjianxing 已提交
277 278 279 280 281 282 283
        }
      }
    }
</script>

<style scoped>

C
chenjianxing 已提交
284 285 286 287 288
  .search {
    margin-left: 10px;
    width: 240px;
  }

C
chenjianxing 已提交
289
</style>