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

C
chenjianxing 已提交
20
      <executor-edit ref="executorEdit" :select-ids="selectIds" @refresh="initTableData"/>
C
chenjianxing 已提交
21
      <status-edit ref="statusEdit" :plan-id="planId" :select-ids="selectIds" @refresh="initTableData"/>
C
chenjianxing 已提交
22

C
chenjianxing 已提交
23 24 25 26 27 28
      <el-table
        @select-all="handleSelectAll"
        @filter-change="filter"
        @sort-change="sort"
        @select="handleSelectionChange"
        row-key="id"
C
chenjianxing 已提交
29
        @row-click="showDetail"
C
chenjianxing 已提交
30
        :data="tableData">
C
chenjianxing 已提交
31

C
chenjianxing 已提交
32 33
        <el-table-column
          type="selection"></el-table-column>
34

C
chenjianxing 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47 48
        <el-table-column
          prop="name"
          :label="$t('commons.name')"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="priority"
          :filters="priorityFilters"
          column-key="priority"
          :label="$t('test_track.case.priority')">
          <template v-slot:default="scope">
            <priority-table-item :value="scope.row.priority" ref="priority"/>
          </template>
        </el-table-column>
C
chenjianxing 已提交
49

C
chenjianxing 已提交
50 51 52 53 54 55 56 57 58 59
        <el-table-column
          prop="type"
          :filters="typeFilters"
          column-key="type"
          :label="$t('test_track.case.type')"
          show-overflow-tooltip>
          <template v-slot:default="scope">
            <type-table-item :value="scope.row.type"/>
          </template>
        </el-table-column>
C
chenjianxing 已提交
60

C
chenjianxing 已提交
61 62 63 64 65 66 67 68 69 70
        <el-table-column
          prop="method"
          :filters="methodFilters"
          column-key="method"
          :label="$t('test_track.case.method')"
          show-overflow-tooltip>
          <template v-slot:default="scope">
            <method-table-item :value="scope.row.method"/>
          </template>
        </el-table-column>
C
chenjianxing 已提交
71

C
chenjianxing 已提交
72 73 74 75 76
        <el-table-column
          prop="nodePath"
          :label="$t('test_track.case.module')"
          show-overflow-tooltip>
        </el-table-column>
77

C
chenjianxing 已提交
78 79 80 81
        <el-table-column
          prop="executorName"
          :label="$t('test_track.plan_view.executor')">
        </el-table-column>
C
chenjianxing 已提交
82

C
chenjianxing 已提交
83 84 85 86 87 88
        <el-table-column
          prop="status"
          :filters="statusFilters"
          column-key="status"
          :label="$t('test_track.plan_view.execute_result')">
          <template v-slot:default="scope">
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
              <el-dropdown class="test-case-status" @command="statusChange">
                <span class="el-dropdown-link">
                  <status-table-item :value="scope.row.status"/>
                </span>
                <el-dropdown-menu slot="dropdown" chang>
                  <el-dropdown-item :command="{id: scope.row.id, status: 'Pass'}">
                    {{$t('test_track.plan_view.pass')}}
                  </el-dropdown-item>
                  <el-dropdown-item :command="{id: scope.row.id, status: 'Failure'}">
                    {{$t('test_track.plan_view.failure')}}
                  </el-dropdown-item>
                  <el-dropdown-item :command="{id: scope.row.id, status: 'Blocking'}">
                    {{$t('test_track.plan_view.blocking')}}
                  </el-dropdown-item>
                  <el-dropdown-item :command="{id: scope.row.id, status: 'Skip'}">
                    {{$t('test_track.plan_view.skip')}}
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
C
chenjianxing 已提交
108 109
          </template>
        </el-table-column>
C
chenjianxing 已提交
110

C
chenjianxing 已提交
111 112 113 114 115 116 117 118 119 120 121 122
        <el-table-column
          sortable
          prop="updateTime"
          :label="$t('commons.update_time')"
          show-overflow-tooltip>
          <template v-slot:default="scope">
            <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
          </template>
        </el-table-column>
        <el-table-column
          :label="$t('commons.operating')">
          <template v-slot:default="scope">
C
chenjianxing 已提交
123 124
            <ms-table-operator-button :is-tester-permission="true" :tip="$t('commons.edit')" icon="el-icon-edit" @exec="handleEdit(scope.row)" />
            <ms-table-operator-button :is-tester-permission="true" :tip="$t('test_track.plan_view.cancel_relevance')" icon="el-icon-unlock" type="danger" @exec="handleDelete(scope.row)"/>
C
chenjianxing 已提交
125 126 127
          </template>
        </el-table-column>
      </el-table>
C
chenjianxing 已提交
128

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

C
chenjianxing 已提交
132 133 134 135
      <test-plan-test-case-edit
        ref="testPlanTestCaseEdit"
        :search-param="condition"
        @refresh="initTableData"
C
chenjianxing 已提交
136
        :is-read-only="isReadOnly"
C
chenjianxing 已提交
137
        @refreshTable="search"/>
C
chenjianxing 已提交
138

C
chenjianxing 已提交
139
    </el-card>
C
chenjianxing 已提交
140
  </div>
C
chenjianxing 已提交
141 142 143
</template>

<script>
144 145
  import ExecutorEdit from './ExecutorEdit';
  import StatusEdit from './StatusEdit';
C
chenjianxing 已提交
146 147 148 149 150 151
  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 已提交
152

C
chenjianxing 已提交
153
  import {ROLE_TEST_MANAGER, ROLE_TEST_USER, TokenKey} from '../../../../../../common/js/constants';
C
chenjianxing 已提交
154 155 156 157 158 159 160 161
  import {
    _filter,
    _sort,
    checkoutTestManagerOrTestUser,
    hasRoles,
    humpToLine,
    tableFilter
  } from '../../../../../../common/js/utils';
C
chenjianxing 已提交
162 163 164 165
  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 已提交
166
  import MsTableOperator from "../../../../common/components/MsTableOperator";
C
chenjianxing 已提交
167
  import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
C
chenjianxing 已提交
168
  import TestReportTemplateList from "./TestReportTemplateList";
C
chenjianxing 已提交
169
  import TestCaseReportView from "./report/TestCaseReportView";
C
chenjianxing 已提交
170

C
v-slot  
Captain.B 已提交
171
  export default {
C
chenjianxing 已提交
172
      name: "TestPlanTestCaseList",
C
chenjianxing 已提交
173
      components: {
C
chenjianxing 已提交
174
        MsTableOperatorButton,
C
chenjianxing 已提交
175
        MsTableOperator,
C
chenjianxing 已提交
176 177 178 179
        MethodTableItem,
        TypeTableItem,
        StatusTableItem,
        PriorityTableItem, StatusEdit, ExecutorEdit, MsTipButton, MsTablePagination,
C
chenjianxing 已提交
180
        TestPlanTestCaseEdit, MsTableHeader, NodeBreadcrumb, MsTableButton},
C
chenjianxing 已提交
181 182 183 184
      data() {
        return {
          result: {},
          deletePath: "/test/case/delete",
C
chenjianxing 已提交
185 186
          condition: {},
          showMyTestCase: false,
C
chenjianxing 已提交
187 188
          tableData: [],
          currentPage: 1,
C
chenjianxing 已提交
189
          pageSize: 10,
C
chenjianxing 已提交
190
          total: 0,
C
chenjianxing 已提交
191
          selectIds: new Set(),
C
chenjianxing 已提交
192
          testPlan: {},
C
chenjianxing 已提交
193
          isReadOnly: false,
C
chenjianxing 已提交
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
          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 已提交
214
            {text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
C
chenjianxing 已提交
215
          ]
C
chenjianxing 已提交
216 217
        }
      },
C
chenjianxing 已提交
218 219 220
      props:{
        planId: {
          type: String
C
chenjianxing 已提交
221 222 223
        },
        selectNodeIds: {
          type: Array
C
chenjianxing 已提交
224
        },
C
chenjianxing 已提交
225
        selectParentNodes: {
C
chenjianxing 已提交
226
          type: Array
C
chenjianxing 已提交
227 228
        }
      },
C
chenjianxing 已提交
229 230
      watch: {
        planId() {
C
chenjianxing 已提交
231
          this.refreshTableAndPlan();
C
chenjianxing 已提交
232 233
        },
        selectNodeIds() {
C
chenjianxing 已提交
234
          this.search();
C
chenjianxing 已提交
235 236
        }
      },
C
chenjianxing 已提交
237
      mounted() {
C
chenjianxing 已提交
238
        this.refreshTableAndPlan();
C
chenjianxing 已提交
239 240
      },
      methods: {
C
chenjianxing 已提交
241
        initTableData() {
C
chenjianxing 已提交
242
          if (this.planId) {
C
chenjianxing 已提交
243 244 245
            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 已提交
246 247 248
              let data = response.data;
              this.total = data.itemCount;
              this.tableData = data.listObject;
C
chenjianxing 已提交
249
              this.selectIds.clear();
C
chenjianxing 已提交
250
            });
C
chenjianxing 已提交
251 252
          }
        },
C
chenjianxing 已提交
253 254 255 256
        showDetail(row, event, column) {
          this.isReadOnly = true;
          this.$refs.testPlanTestCaseEdit.openTestCaseEdit(row);
        },
C
chenjianxing 已提交
257 258
        refresh() {
          this.condition = {};
C
chenjianxing 已提交
259
          this.selectIds.clear();
C
chenjianxing 已提交
260
          this.$emit('refresh');
C
chenjianxing 已提交
261
        },
C
chenjianxing 已提交
262 263 264 265 266
        refreshTableAndPlan() {
          this.getTestPlanById();
          this.initTableData();
        },
        refreshTestPlanRecent() {
C
chenjianxing 已提交
267 268 269 270 271 272
          if (hasRoles(ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
            let param = {};
            param.id = this.planId;
            param.updateTime = Date.now();
            this.$post('/test/plan/edit', param);
          }
C
chenjianxing 已提交
273
        },
C
chenjianxing 已提交
274 275 276
        search() {
          this.initTableData();
        },
C
chenjianxing 已提交
277 278 279
        buildPagePath(path) {
          return path + "/" + this.currentPage + "/" + this.pageSize;
        },
280
        handleEdit(testCase, index) {
C
chenjianxing 已提交
281
          this.isReadOnly = false;
C
chenjianxing 已提交
282 283 284
          if (!checkoutTestManagerOrTestUser()) {
            this.isReadOnly = true;
          }
C
chenjianxing 已提交
285
          this.$refs.testPlanTestCaseEdit.openTestCaseEdit(testCase);
C
chenjianxing 已提交
286 287
        },
        handleDelete(testCase) {
C
chenjianxing 已提交
288
          this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + ' ' + testCase.name + "", '', {
C
chenjianxing 已提交
289 290 291 292 293 294 295 296
            confirmButtonText: this.$t('commons.confirm'),
            callback: (action) => {
              if (action === 'confirm') {
                this._handleDelete(testCase);
              }
            }
          });
        },
297 298 299 300 301 302 303 304 305 306 307 308 309 310
        handleDeleteBatch() {
          this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + "", '', {
            confirmButtonText: this.$t('commons.confirm'),
            callback: (action) => {
              if (action === 'confirm') {
                this.$post('/test/plan/case/batch/delete', {ids: [...this.selectIds]}, () => {
                  this.selectIds.clear();
                  this.$emit("refresh");
                  this.$success(this.$t('commons.delete_success'));
                });
              }
            }
          });
        },
C
chenjianxing 已提交
311 312
        _handleDelete(testCase) {
          let testCaseId = testCase.id;
C
chenjianxing 已提交
313
          this.$post('/test/plan/case/delete/' + testCaseId, {}, () => {
C
chenjianxing 已提交
314
            this.$emit("refresh");
C
chenjianxing 已提交
315
            this.$success(this.$t('commons.delete_success'));
C
chenjianxing 已提交
316
          });
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
        },
        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 已提交
336
            this.$warning(this.$t('test_track.plan_view.select_manipulate'));
337 338 339 340 341 342
            return;
          }
          if (type === 'executor'){
            this.$refs.executorEdit.openExecutorEdit();
          } else if (type === 'status'){
            this.$refs.statusEdit.openStatusEdit();
343 344
          } else if (type === 'delete') {
            this.handleDeleteBatch();
345
          }
C
chenjianxing 已提交
346 347 348 349 350 351 352 353 354 355
        },
        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 已提交
356
        },
357 358 359 360 361 362 363 364 365 366
        statusChange(param) {
          this.$post('/test/plan/case/edit' , param, () => {
            for (let i = 0; i < this.tableData.length; i++) {
              if (this.tableData[i].id == param.id) {
                this.tableData[i].status = param.status;
                break;
              }
            }
          });
        },
C
chenjianxing 已提交
367 368 369 370
        getTestPlanById() {
          if (this.planId) {
            this.$post('/test/plan/get/' + this.planId, {}, response => {
              this.testPlan = response.data;
C
chenjianxing 已提交
371
              this.refreshTestPlanRecent();
C
chenjianxing 已提交
372 373 374
            });
          }
        },
C
chenjianxing 已提交
375
        filter(filters) {
C
chenjianxing 已提交
376
          _filter(filters, this.condition);
C
chenjianxing 已提交
377 378 379
          this.initTableData();
        },
        sort(column) {
C
chenjianxing 已提交
380
          _sort(column, this.condition);
C
chenjianxing 已提交
381
          this.initTableData();
C
chenjianxing 已提交
382 383 384 385 386 387 388
        }
      }
    }
</script>

<style scoped>

C
chenjianxing 已提交
389 390 391 392
  .search {
    margin-left: 10px;
    width: 240px;
  }
393

C
chenjianxing 已提交
394
  .test-case-status,.el-table {
395 396 397
    cursor:pointer;
  }

C
chenjianxing 已提交
398
</style>