feat: 场景列表批量移动

This commit is contained in:
chenjianxing 2021-01-21 19:45:12 +08:00
parent 5d9cf69916
commit 27603bbf90
9 changed files with 73 additions and 47 deletions

View File

@ -652,6 +652,9 @@ public class ApiAutomationService {
} }
public void bathEdit(SaveApiScenarioRequest request) { public void bathEdit(SaveApiScenarioRequest request) {
if (CollectionUtils.isEmpty(request.getScenarioIds())) {
return;
}
if (request.isSelectAllDate()) { if (request.isSelectAllDate()) {
request.setScenarioIds(this.getAllScenarioIdsByFontedSelect( request.setScenarioIds(this.getAllScenarioIdsByFontedSelect(
request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds())); request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds()));

View File

@ -6,6 +6,7 @@
@refreshTable="refresh" @refreshTable="refresh"
@saveAsEdit="editScenario" @saveAsEdit="editScenario"
@setModuleOptions="setModuleOptions" @setModuleOptions="setModuleOptions"
@setNodeTree="setNodeTree"
@enableTrash="enableTrash" @enableTrash="enableTrash"
:type="'edit'" :type="'edit'"
ref="nodeTree"/> ref="nodeTree"/>
@ -15,6 +16,8 @@
<el-tabs v-model="activeName" @tab-click="addTab" @tab-remove="removeTab"> <el-tabs v-model="activeName" @tab-click="addTab" @tab-remove="removeTab">
<el-tab-pane name="default" :label="$t('api_test.automation.scenario_test')"> <el-tab-pane name="default" :label="$t('api_test.automation.scenario_test')">
<ms-api-scenario-list <ms-api-scenario-list
:module-tree="nodeTree"
:module-options="moduleOptions"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:trash-enable="trashEnable" :trash-enable="trashEnable"
:checkRedirectID="checkRedirectID" :checkRedirectID="checkRedirectID"
@ -98,6 +101,7 @@
tabs: [], tabs: [],
trashEnable: false, trashEnable: false,
selectNodeIds: [], selectNodeIds: [],
nodeTree: []
} }
}, },
watch: { watch: {
@ -209,6 +213,9 @@
setModuleOptions(data) { setModuleOptions(data) {
this.moduleOptions = data; this.moduleOptions = data;
}, },
setNodeTree(data) {
this.nodeTree = data;
},
changeSelectDataRangeAll(tableType) { changeSelectDataRangeAll(tableType) {
this.$route.params.dataSelectRange = 'all'; this.$route.params.dataSelectRange = 'all';
}, },

View File

@ -108,6 +108,8 @@
</template> </template>
</batch-edit> </batch-edit>
<batch-move @refresh="search" @moveSave="moveSave" ref="testBatchMove"/>
</div> </div>
</template> </template>
@ -129,10 +131,12 @@
import BatchEdit from "../../../track/case/components/BatchEdit"; import BatchEdit from "../../../track/case/components/BatchEdit";
import {WORKSPACE_ID} from "../../../../../common/js/constants"; import {WORKSPACE_ID} from "../../../../../common/js/constants";
import EnvironmentSelect from "../../definition/components/environment/EnvironmentSelect"; import EnvironmentSelect from "../../definition/components/environment/EnvironmentSelect";
import BatchMove from "../../../track/case/components/BatchMove";
export default { export default {
name: "MsApiScenarioList", name: "MsApiScenarioList",
components: { components: {
BatchMove,
EnvironmentSelect, EnvironmentSelect,
BatchEdit, BatchEdit,
PlanStatusTableItem, PlanStatusTableItem,
@ -157,6 +161,18 @@
trashEnable: { trashEnable: {
type: Boolean, type: Boolean,
default: false, default: false,
},
moduleTree: {
type: Array,
default() {
return []
},
},
moduleOptions: {
type: Array,
default() {
return []
},
} }
}, },
data() { data() {
@ -188,16 +204,15 @@
{ {
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
}, },
{
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
},
{ {
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit
}, },
{ {
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
}, }
// {
// name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
// }
], ],
isSelectAllDate: false, isSelectAllDate: false,
unSelection: [], unSelection: [],
@ -319,31 +334,22 @@
handleBatchAddCase() { handleBatchAddCase() {
this.planVisible = true; this.planVisible = true;
}, },
handleDeleteBatch() {
this.$alert(this.$t('test_track.case.delete_confirm') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/test/case/batch/delete', {ids: ids}, () => {
this.selectRows.clear();
this.$emit("refresh");
this.$success(this.$t('commons.delete_success'));
// 广 head
});
}
}
});
},
handleBatchEdit() { handleBatchEdit() {
this.$refs.batchEdit.open(this.selectDataCounts); this.$refs.batchEdit.open(this.selectDataCounts);
}, },
handleBatchMove() { handleBatchMove() {
this.$emit("batchMove", Array.from(this.selectRows).map(row => row.id)); this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions);
},
moveSave(param) {
this.buildBatchParam(param);
param.apiScenarioModuleId = param.nodeId;
this.$post('/api/automation/batch/edit', param, () => {
this.$success(this.$t('commons.save_success'));
this.$refs.testBatchMove.close();
this.search();
});
}, },
batchEdit(form) { batchEdit(form) {
let arr = this.selection;
let ids = this.selection;
let param = {}; let param = {};
param[form.type] = form.value; param[form.type] = form.value;
this.buildBatchParam(param); this.buildBatchParam(param);

View File

@ -119,6 +119,7 @@
buildNodePath(node, {path: ''}, moduleOptions); buildNodePath(node, {path: ''}, moduleOptions);
}); });
this.$emit('setModuleOptions', moduleOptions); this.$emit('setModuleOptions', moduleOptions);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) { if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText); this.$refs.nodeTree.filter(this.condition.filterText);
} }

View File

@ -35,7 +35,7 @@
<test-case-move @refresh="refresh" ref="testCaseMove"/> <test-case-move @refresh="refresh" ref="testCaseMove"/>
<batch-move @refresh="refresh" ref="testBatchMove"/> <batch-move @refresh="refresh" @moveSave="moveSave" ref="testBatchMove"/>
</ms-container> </ms-container>
@ -54,6 +54,7 @@ import MsMainContainer from "../../common/components/MsMainContainer";
import {checkoutTestManagerOrTestUser, getCurrentProjectID, hasRoles} from "../../../../common/js/utils"; import {checkoutTestManagerOrTestUser, getCurrentProjectID, hasRoles} from "../../../../common/js/utils";
import BatchMove from "./components/BatchMove"; import BatchMove from "./components/BatchMove";
import TestCaseNodeTree from "../common/TestCaseNodeTree"; import TestCaseNodeTree from "../common/TestCaseNodeTree";
import {TrackEvent,LIST_CHANGE} from "@/business/components/common/head/ListEvent";
export default { export default {
name: "TestCase", name: "TestCase",
@ -163,6 +164,15 @@ export default {
}, },
setTreeNodes(data) { setTreeNodes(data) {
this.treeNodes = data; this.treeNodes = data;
},
moveSave(param) {
this.result = this.$post('/test/case/batch/edit', param, () => {
this.$success(this.$t('commons.save_success'));
this.$refs.testBatchMove.close();
// 广 head
TrackEvent.$emit(LIST_CHANGE);
this.refresh();
});
} }
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div v-loading="result.loading"> <div class="batch-move" v-loading="result.loading">
<el-dialog :title="this.$t('test_track.case.select_catalog')" <el-dialog :title="this.$t('test_track.case.select_catalog')"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
:before-close="close" :before-close="close"
@ -39,7 +39,6 @@
<script> <script>
import MsDialogFooter from "../../../common/components/MsDialogFooter"; import MsDialogFooter from "../../../common/components/MsDialogFooter";
import {TrackEvent,LIST_CHANGE} from "@/business/components/common/head/ListEvent";
export default { export default {
name: "BatchMove", name: "BatchMove",
@ -77,19 +76,15 @@
} }
let param = {}; let param = {};
param.nodeId = this.currentKey; param.nodeId = this.currentKey;
if (this.moduleOptions) {
this.moduleOptions.forEach(item => { this.moduleOptions.forEach(item => {
if (item.id === this.currentKey) { if (item.id === this.currentKey) {
param.nodePath = item.path; param.nodePath = item.path;
} }
}); });
}
param.ids = this.selectIds; param.ids = this.selectIds;
this.result = this.$post('/test/case/batch/edit', param, () => { this.$emit('moveSave', param);
this.$success(this.$t('commons.save_success'));
this.close();
// 广 head
TrackEvent.$emit(LIST_CHANGE);
this.$emit('refresh');
});
}, },
refresh() { refresh() {
this.$emit("refresh"); this.$emit("refresh");
@ -120,4 +115,8 @@
overflow: hidden; overflow: hidden;
} }
.batch-move {
height: 500px;
}
</style> </style>

View File

@ -1042,7 +1042,7 @@ export default {
batch_operate: 'Batch operation', batch_operate: 'Batch operation',
please_select_attr: 'Please select attributes', please_select_attr: 'Please select attributes',
please_select_attr_value: 'Please select the value corresponding to the attribute', please_select_attr_value: 'Please select the value corresponding to the attribute',
batch_edit_case: 'Batch editing test cases', batch_edit_case: 'Batch editing',
batch_move_case: 'Batch move', batch_move_case: 'Batch move',
batch_delete_case: 'Batch delete', batch_delete_case: 'Batch delete',
batch_unlink: 'Batch Unlink', batch_unlink: 'Batch Unlink',

View File

@ -1045,9 +1045,9 @@ export default {
batch_operate: '批量操作', batch_operate: '批量操作',
please_select_attr: '请选择属性', please_select_attr: '请选择属性',
please_select_attr_value: '请选择属性对应的值', please_select_attr_value: '请选择属性对应的值',
batch_edit_case: '批量编辑用例', batch_edit_case: '批量编辑',
batch_move_case: '批量移动用例', batch_move_case: '批量移动',
batch_delete_case: '批量删除用例', batch_delete_case: '批量删除',
batch_unlink: '批量取消关联', batch_unlink: '批量取消关联',
project_name: '所属项目', project_name: '所属项目',
status: '评审状态', status: '评审状态',

View File

@ -1043,9 +1043,9 @@ export default {
batch_operate: '批量操作', batch_operate: '批量操作',
please_select_attr: '請選擇屬性', please_select_attr: '請選擇屬性',
please_select_attr_value: '請選擇屬性對應的值', please_select_attr_value: '請選擇屬性對應的值',
batch_edit_case: '批量編輯用例', batch_edit_case: '批量編輯',
batch_move_case: '批量移動用例', batch_move_case: '批量移動',
batch_delete_case: '批量刪除用例', batch_delete_case: '批量刪除',
batch_unlink: '批量取消關聯', batch_unlink: '批量取消關聯',
project_name: '所屬項目', project_name: '所屬項目',
status: '評審狀態', status: '評審狀態',