TestPlanTestCaseList.vue 11.7 KB
Newer Older
C
chenjianxing 已提交
1
<template>
C
chenjianxing 已提交
2
  <el-card v-loading="result.loading">
C
chenjianxing 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
    <template v-slot:header>
      <ms-table-header :condition.sync="condition" @search="initTableData" :show-create="false">
        <template v-slot:title>
          <node-breadcrumb class="table-title" :node-names="selectNodeNames" @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')"/>
          <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')"/>
          <ms-table-button v-if="!testPlan.reportId" icon="el-icon-document" :content="$t('创建测试报告')" @click="openTestReport"/>
          <ms-table-button v-if="testPlan.reportId" icon="el-icon-document" :content="$t('查看测试报告')" @click="openReport"/>
        </template>
      </ms-table-header>
    </template>
C
chenjianxing 已提交
19

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

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

C
chenjianxing 已提交
29 30
      <el-table-column
        type="selection"></el-table-column>
31

C
chenjianxing 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45
      <el-table-column
        prop="name"
        :label="$t('commons.name')"
        show-overflow-tooltip>
      </el-table-column>
      <el-table-column
        prop="priority"
        :filters="priorityFilters"
        :filter-method="filter"
        :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 已提交
46

C
chenjianxing 已提交
47 48 49 50 51 52 53 54 55 56
      <el-table-column
        prop="type"
        :filters="typeFilters"
        :filter-method="filter"
        :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 已提交
57

C
chenjianxing 已提交
58 59 60 61 62 63 64 65 66 67
      <el-table-column
        prop="method"
        :filters="methodFilters"
        :filter-method="filter"
        :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 已提交
68

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

C
chenjianxing 已提交
74 75 76 77 78 79 80 81 82
      <el-table-column
        prop="status"
        :filters="statusFilters"
        :filter-method="filter"
        :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 已提交
83

C
chenjianxing 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
      <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 已提交
101

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

C
chenjianxing 已提交
105 106 107 108 109 110 111
    <test-plan-test-case-edit
      ref="testPlanTestCaseEdit"
      :search-param="condition"
      @refresh="refresh"
      @refreshTable="search"/>

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

C
chenjianxing 已提交
114 115 116 117
    </el-card>
</template>

<script>
118 119
  import ExecutorEdit from './ExecutorEdit';
  import StatusEdit from './StatusEdit';
C
chenjianxing 已提交
120 121 122 123 124 125
  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 已提交
126

C
chenjianxing 已提交
127 128
  import {TokenKey} from '../../../../../../common/js/constants';
  import {tableFilter} from '../../../../../../common/js/utils';
C
chenjianxing 已提交
129 130 131 132
  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 已提交
133
  import MsTableOperator from "../../../../common/components/MsTableOperator";
C
chenjianxing 已提交
134
  import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
C
chenjianxing 已提交
135 136
  import TestReportTemplateList from "./TestReportTemplateList";
  import TestCaseReportView from "./TestCaseReportView";
C
chenjianxing 已提交
137

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

<style scoped>

C
chenjianxing 已提交
326 327 328 329 330
  .search {
    margin-left: 10px;
    width: 240px;
  }

C
chenjianxing 已提交
331
</style>