feat(测试跟踪): 测试计划批量操作

This commit is contained in:
shiziyuan9527 2020-08-06 18:31:23 +08:00
parent 7106c531a7
commit 1f64dd0c86
3 changed files with 163 additions and 69 deletions

View File

@ -1,7 +1,7 @@
<template>
<div>
<el-dialog
title="批量编辑用例"
:title="dialogTitle"
:visible.sync="dialogVisible"
width="25%"
class="batch-edit-dialog"
@ -11,15 +11,15 @@
<el-form :model="form" label-position="right" label-width="150px" size="medium" ref="form" :rules="rules">
<el-form-item :label="$t('test_track.case.batch_update', [size])" prop="type">
<el-select v-model="form.type" style="width: 80%" @change="changeType">
<el-option label="用例等级" value="priority"/>
<el-option label="类型" value="type"/>
<el-option label="测试方式" value="method"/>
<el-option label="维护人" value="maintainer"/>
<el-option v-for="(type, index) in typeArr" :key="index" :value="type.id" :label="type.name"/>
</el-select>
</el-form-item>
<el-form-item label="更新后属性值为" prop="value">
<el-select v-model="form.value" style="width: 80%" :filterable="filterable">
<el-option v-for="(option, index) in options" :key="index" :value="option.id" :label="option.name">
<div v-if="option.email">
<span>{{option.id}}({{option.name}})</span>
</div>
</el-option>
</el-select>
</el-form-item>
@ -35,7 +35,6 @@
<script>
import MsDialogFooter from "../../../common/components/MsDialogFooter";
import {WORKSPACE_ID} from "../../../../../common/js/constants";
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
export default {
@ -43,8 +42,13 @@
components: {
MsDialogFooter
},
created() {
this.getMaintainerOptions();
props: {
typeArr: Array,
valueArr: Object,
dialogTitle: {
type: String,
default: "批量操作"
}
},
data() {
return {
@ -56,22 +60,6 @@
value: {required: true, message: "请选择属性对应的值", trigger: ['blur','change']}
},
options: [],
priorities: [
{name: 'P0', id: 'P0'},
{name: 'P1', id: 'P1'},
{name: 'P2', id: 'P2'},
{name: 'P3', id: 'P3'}
],
types: [
{name: this.$t('commons.functional'), id: 'functional'},
{name: this.$t('commons.performance'), id: 'performance'},
{name: this.$t('commons.api'), id: 'api'}
],
methods: [
{name: this.$t('test_track.case.manual'), id: 'manual'},
{name: this.$t('test_track.case.auto'), id: 'auto'}
],
maintainers: [],
filterable: false,
}
},
@ -93,33 +81,13 @@
},
handleClose() {
this.form = {};
this.options = [];
removeGoBackListener(this.handleClose);
},
changeType(val) {
this.$set(this.form, "value", "");
this.filterable = val === "maintainer";
switch (val) {
case "priority":
this.options = this.priorities;
break;
case "type":
this.options = this.types;
break;
case "method":
this.options = this.methods;
break;
case "maintainer":
this.options = this.maintainers;
break;
default:
this.options = [];
}
},
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.maintainers = response.data;
});
this.filterable = val === "maintainer" || val === "executor";
this.options = this.valueArr[val];
}
}
}

View File

@ -120,7 +120,8 @@
</el-card>
<batch-edit ref="batchEdit" @batchEdit="batchEdit"/>
<batch-edit ref="batchEdit" @batchEdit="batchEdit"
:typeArr="typeArr" :value-arr="valueArr" dialog-title="批量编辑用例"/>
</div>
</template>
@ -142,6 +143,7 @@
import {TEST_CASE_CONFIGS} from "../../../common/components/search/search-components";
import ShowMoreBtn from "./ShowMoreBtn";
import BatchEdit from "./BatchEdit";
import {WORKSPACE_ID} from "../../../../../common/js/constants";
export default {
name: "TestCaseList",
@ -197,7 +199,31 @@
}, {
name: '批量删除用例', handleClick: this.handleDeleteBatch
}
]
],
typeArr: [
{id: 'priority', name: '用例等级'},
{id: 'type', name: '类型'},
{id: 'method', name: '测试方式'},
{id: 'maintainer', name: '维护人'},
],
valueArr: {
priority: [
{name: 'P0', id: 'P0'},
{name: 'P1', id: 'P1'},
{name: 'P2', id: 'P2'},
{name: 'P3', id: 'P3'}
],
type: [
{name: this.$t('commons.functional'), id: 'functional'},
{name: this.$t('commons.performance'), id: 'performance'},
{name: this.$t('commons.api'), id: 'api'}
],
method: [
{name: this.$t('test_track.case.manual'), id: 'manual'},
{name: this.$t('test_track.case.auto'), id: 'auto'}
],
maintainer: [],
}
}
},
props: {
@ -429,10 +455,17 @@
this.initTableData();
},
handleBatchEdit() {
this.getMaintainerOptions();
this.$refs.batchEdit.open();
},
handleBatchMove() {
this.$emit("batchMove", Array.from(this.selectRows).map(row => row.id));
},
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.valueArr.maintainer = response.data;
});
}
}
}

View File

@ -30,8 +30,10 @@
</ms-table-header>
</template>
<executor-edit ref="executorEdit" :select-ids="selectIds" @refresh="initTableData"/>
<status-edit ref="statusEdit" :plan-id="planId" :select-ids="selectIds" @refresh="initTableData"/>
<executor-edit ref="executorEdit" :select-ids="new Set(Array.from(this.selectRows).map(row => row.id))"
@refresh="initTableData"/>
<status-edit ref="statusEdit" :plan-id="planId"
:select-ids="new Set(Array.from(this.selectRows).map(row => row.id))" @refresh="initTableData"/>
<el-table
class="adjust-table"
@ -45,7 +47,12 @@
:data="tableData">
<el-table-column
type="selection"></el-table-column>
type="selection"/>
<el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectRows.size"/>
</template>
</el-table-column>
<el-table-column
prop="num"
:label="$t('commons.id')"
@ -163,8 +170,9 @@
<test-report-template-list @openReport="openReport" ref="testReportTemplateList"/>
<test-case-report-view @refresh="initTableData" ref="testCaseReportView"/>
</el-card>
<batch-edit ref="batchEdit" @batchEdit="batchEdit"
:type-arr="typeArr" :value-arr="valueArr" dialog-title="批量更改测试计划"/>
</div>
</template>
@ -178,7 +186,7 @@
import MsTableButton from '../../../../common/components/MsTableButton';
import NodeBreadcrumb from '../../../common/NodeBreadcrumb';
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, TokenKey} from '../../../../../../common/js/constants';
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, TokenKey, WORKSPACE_ID} from '../../../../../../common/js/constants';
import {_filter, _sort, checkoutTestManagerOrTestUser, hasRoles} from '../../../../../../common/js/utils';
import PriorityTableItem from "../../../common/tableItems/planview/PriorityTableItem";
import StatusTableItem from "../../../common/tableItems/planview/StatusTableItem";
@ -189,6 +197,8 @@
import TestReportTemplateList from "./TestReportTemplateList";
import TestCaseReportView from "./report/TestCaseReportView";
import {TEST_CASE_CONFIGS} from "../../../../common/components/search/search-components";
import ShowMoreBtn from "../../../case/components/ShowMoreBtn";
import BatchEdit from "../../../case/components/BatchEdit";
export default {
name: "TestPlanTestCaseList",
@ -201,7 +211,8 @@
TypeTableItem,
StatusTableItem,
PriorityTableItem, StatusEdit, ExecutorEdit, MsTipButton, MsTablePagination,
TestPlanTestCaseEdit, MsTableHeader, NodeBreadcrumb, MsTableButton
TestPlanTestCaseEdit, MsTableHeader, NodeBreadcrumb, MsTableButton, ShowMoreBtn,
BatchEdit
},
data() {
return {
@ -215,7 +226,8 @@
currentPage: 1,
pageSize: 10,
total: 0,
selectIds: new Set(),
// selectIds: new Set(),
selectRows: new Set(),
testPlan: {},
isReadOnly: false,
isTestManagerOrTestUser: false,
@ -241,7 +253,29 @@
{text: this.$t('test_track.plan_view.blocking'), value: 'Blocking'},
{text: this.$t('test_track.plan_view.skip'), value: 'Skip'},
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
]
],
showMore: false,
buttons: [
{
name: '批量更改测试计划', handleClick: this.handleBatchEdit
},
{
name: '批量取消用例关联', handleClick: this.handleDeleteBatch
}
],
typeArr: [
{id: 'status', name: '执行结果'},
{id: 'executor', name: '执行人'},
],
valueArr: {
executor: [],
status: [
{name: this.$t('test_track.plan_view.pass'), id: 'Pass'},
{name: this.$t('test_track.plan_view.failure'), id: 'Failure'},
{name: this.$t('test_track.plan_view.blocking'), id: 'Blocking'},
{name: this.$t('test_track.plan_view.skip'), id: 'Skip'}
]
}
}
},
props: {
@ -282,7 +316,8 @@
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
this.selectIds.clear();
// this.selectIds.clear();
this.selectRows.clear();
});
}
},
@ -292,7 +327,8 @@
},
refresh() {
this.condition = {components: TEST_CASE_CONFIGS};
this.selectIds.clear();
// this.selectIds.clear();
this.selectRows.clear();
this.$emit('refresh');
},
refreshTableAndPlan() {
@ -335,8 +371,10 @@
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
this.$post('/test/plan/case/batch/delete', {ids: [...this.selectIds]}, () => {
this.selectIds.clear();
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/test/plan/case/batch/delete', {ids: ids}, () => {
// this.selectIds.clear();
this.selectRows.clear();
this.$emit("refresh");
this.$success(this.$t('commons.delete_success'));
});
@ -352,23 +390,56 @@
});
},
handleSelectAll(selection) {
// if (selection.length > 0) {
// this.tableData.forEach(item => {
// this.selectIds.add(item.id);
// });
// } else {
// this.selectIds.clear();
// }
if (selection.length > 0) {
this.tableData.forEach(item => {
this.selectIds.add(item.id);
});
if (selection.length === 1) {
this.selectRows.add(selection[0]);
} else {
this.tableData.forEach(item => {
this.$set(item, "showMore", true);
this.selectRows.add(item);
});
}
} else {
this.selectIds.clear();
this.selectRows.clear();
this.tableData.forEach(row => {
this.$set(row, "showMore", false);
})
}
},
handleSelectionChange(selection, row) {
if (this.selectIds.has(row.id)) {
this.selectIds.delete(row.id);
// if (this.selectIds.has(row.id)) {
// this.selectIds.delete(row.id);
// } else {
// this.selectIds.add(row.id);
// }
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
} else {
this.selectIds.add(row.id);
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
let arr = Array.from(this.selectRows);
// 1
if (this.selectRows.size === 1) {
this.$set(arr[0], "showMore", false);
} else if (this.selectRows.size === 2) {
arr.forEach(row => {
this.$set(row, "showMore", true);
})
}
},
handleBatch(type) {
if (this.selectIds.size < 1) {
if (this.selectRows.size < 1) {
this.$warning(this.$t('test_track.plan_view.select_manipulate'));
return;
}
@ -428,6 +499,28 @@
sort(column) {
_sort(column, this.condition);
this.initTableData();
},
batchEdit(form) {
let param = {};
param[form.type] = form.value;
param.ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/test/plan/case/batch/edit', param, () => {
this.selectRows.clear();
this.status = '';
this.$post('/test/plan/edit/status/' + this.planId);
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
});
},
handleBatchEdit() {
this.getMaintainerOptions();
this.$refs.batchEdit.open();
},
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.valueArr.executor = response.data;
});
}
}
}