TestPlanTestCaseList.vue 13.0 KB
Newer Older
C
chenjianxing 已提交
1
<template>
C
chenjianxing 已提交
2 3 4 5 6 7 8 9 10 11 12
  <div class="card-container">
    <el-card class="card-content" v-loading="result.loading">
      <template v-slot:header>
        <ms-table-header :condition.sync="condition" @search="initTableData" :show-create="false">
          <template v-slot:title>
            <node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="refresh"/>
          </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')"/>
C
chenjianxing 已提交
13
            <ms-table-button icon="el-icon-unlock" :content="$t('test_track.plan_view.cancel_relevance')" @click="handleBatch('delete')"/>
C
chenjianxing 已提交
14 15
            <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')"/>
C
chenjianxing 已提交
16 17
            <ms-table-button v-if="!testPlan.reportId" icon="el-icon-document" :content="$t('test_track.plan_view.create_report')" @click="openTestReport"/>
            <ms-table-button v-if="testPlan.reportId" icon="el-icon-document" :content="$t('test_track.plan_view.view_report')" @click="openReport"/>
C
chenjianxing 已提交
18 19 20
          </template>
        </ms-table-header>
      </template>
C
chenjianxing 已提交
21

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

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

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

C
chenjianxing 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49
        <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 已提交
50

C
chenjianxing 已提交
51 52 53 54 55 56 57 58 59 60
        <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 已提交
61

C
chenjianxing 已提交
62 63 64 65 66 67 68 69 70 71
        <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 已提交
72

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

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

C
chenjianxing 已提交
84 85 86 87 88 89 90 91 92
        <el-table-column
          prop="status"
          :filters="statusFilters"
          column-key="status"
          :label="$t('test_track.plan_view.execute_result')">
          <template v-slot:default="scope">
            <status-table-item :value="scope.row.status"/>
          </template>
        </el-table-column>
C
chenjianxing 已提交
93

C
chenjianxing 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
        <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">
            <ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="handleEdit(scope.row)" />
            <ms-table-operator-button :tip="$t('test_track.plan_view.cancel_relevance')" icon="el-icon-unlock" type="danger" @exec="handleDelete(scope.row)"/>
          </template>
        </el-table-column>
      </el-table>
C
chenjianxing 已提交
111

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

C
chenjianxing 已提交
115 116 117 118 119
      <test-plan-test-case-edit
        ref="testPlanTestCaseEdit"
        :search-param="condition"
        @refresh="initTableData"
        @refreshTable="search"/>
C
chenjianxing 已提交
120

C
chenjianxing 已提交
121 122
      <test-report-template-list @openReport="openReport" :plan-id="planId" ref="testReporTtemplateList"/>
      <test-case-report-view :plan-id="planId" ref="testCaseReportView"/>
123

C
chenjianxing 已提交
124
    </el-card>
C
chenjianxing 已提交
125
  </div>
C
chenjianxing 已提交
126 127 128
</template>

<script>
129 130
  import ExecutorEdit from './ExecutorEdit';
  import StatusEdit from './StatusEdit';
C
chenjianxing 已提交
131 132 133 134 135 136
  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 已提交
137

C
chenjianxing 已提交
138
  import {TokenKey} from '../../../../../../common/js/constants';
C
chenjianxing 已提交
139
  import {_filter, _sort, humpToLine, tableFilter} from '../../../../../../common/js/utils';
C
chenjianxing 已提交
140 141 142 143
  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 已提交
144
  import MsTableOperator from "../../../../common/components/MsTableOperator";
C
chenjianxing 已提交
145
  import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
C
chenjianxing 已提交
146
  import TestReportTemplateList from "./TestReportTemplateList";
C
chenjianxing 已提交
147
  import TestCaseReportView from "./report/TestCaseReportView";
C
chenjianxing 已提交
148

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

<style scoped>

C
chenjianxing 已提交
357 358 359 360
  .search {
    margin-left: 10px;
    width: 240px;
  }
C
chenjianxing 已提交
361
</style>