feat: 接口定义批量移动

This commit is contained in:
wenyann 2021-02-01 17:36:45 +08:00
parent 6015752196
commit 89ad020b38
7 changed files with 679 additions and 496 deletions

View File

@ -33,4 +33,6 @@ public class ApiBatchRequest extends ApiDefinitionWithBLOBs {
private List<String> unSelectIds;
private String moduleId;
}

View File

@ -1,4 +1,5 @@
<template>
<div>
<ms-container v-if="renderComponent">
<ms-aside-container>
<ms-api-module
@ -9,6 +10,7 @@
@debug="debug"
@saveAsEdit="editApi"
@setModuleOptions="setModuleOptions"
@setNodeTree="setNodeTree"
@enableTrash="enableTrash"
:type="'edit'"
ref="nodeTree"/>
@ -25,6 +27,8 @@
<!-- 列表集合 -->
<ms-api-list
v-if="item.type === 'list' && isApiListEnable"
:module-tree="nodeTree"
:module-options="moduleOptions"
:current-protocol="currentProtocol"
:visible="visible"
:currentRow="currentRow"
@ -102,8 +106,12 @@
</template>
</el-tab-pane>
</el-tabs>
</ms-main-container>
</ms-container>
</div>
</template>
<script>
import MsApiList from './components/list/ApiList';
@ -177,7 +185,7 @@
currentModule: null,
selectNodeIds: [],
currentApi: {},
moduleOptions: {},
moduleOptions: [],
trashEnable: false,
apiTabs: [{
title: this.$t('api_test.definition.api_title'),
@ -187,7 +195,8 @@
}],
isApiListEnable: true,
syncTabs: [],
projectId: ""
projectId: "",
nodeTree: []
}
},
mounted() {
@ -215,6 +224,7 @@
}
},
methods: {
changeRedirectParam(redirectIDParam) {
this.redirectID = redirectIDParam;
},
@ -394,6 +404,10 @@
setModuleOptions(data) {
this.moduleOptions = data;
},
setNodeTree(data) {
this.nodeTree = data;
console.log( this.nodeTree)
},
changeSelectDataRangeAll(tableType) {
this.$route.params.dataSelectRange = 'all';
},

View File

@ -0,0 +1,127 @@
<template>
<div v-if="dialogVisible" class="batch-move" v-loading="result.loading">
<el-dialog :title="this.$t('test_track.case.select_catalog')"
:visible.sync="dialogVisible"
:before-close="close"
:destroy-on-close="true"
width="20%"
>
<div>
<el-input :placeholder="$t('test_track.module.search')" v-model="filterText" size="small"/>
<el-tree
class="filter-tree node-tree"
:data="treeNodes"
node-key="id"
:filter-node-method="filterNode"
:expand-on-click-node="false"
highlight-current
style="overflow: auto"
@node-click="nodeClick"
ref="tree"
>
<template v-slot:default="{node}">
<span>
<span class="node-icon">
<i class="el-icon-folder"/>
</span>
<span class="node-title">{{node.label}}</span>
</span>
</template>
</el-tree>
</div>
<template v-slot:footer>
<ms-dialog-footer
@cancel="close"
@confirm="save"/>
</template>
</el-dialog>
</div>
</template>
<script>
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
export default {
name: "CaseBatchMove",
components: {
MsDialogFooter
},
data() {
return {
treeNodes: [],
selectIds: [],
selectNode: {},
dialogVisible: false,
currentKey: "",
moduleOptions: [],
filterText: "",
result: {},
}
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
console.log( this.treeNodes)
}
},
methods: {
open(treeNodes, selectIds, moduleOptions) {
this.dialogVisible = true;
this.treeNodes = treeNodes;
this.selectIds = selectIds;
this.moduleOptions = moduleOptions;
},
save() {
if (!this.currentKey) {
this.$warning(this.$t('test_track.case.input_module'));
return;
}
let param = {};
param.nodeId = this.currentKey;
if (this.moduleOptions) {
this.moduleOptions.forEach(item => {
if (item.id === this.currentKey) {
param.nodePath = item.path;
}
});
}
param.ids = this.selectIds;
this.$emit('moveSave', param);
},
refresh() {
this.$emit("refresh");
},
close() {
this.filterText = "";
this.dialogVisible = false;
this.selectNode = {};
},
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
nodeClick() {
this.currentKey = this.$refs.tree.getCurrentKey();
}
}
}
</script>
<style scoped>
.node-title {
width: 0;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1 1 auto;
padding: 0 5px;
overflow: hidden;
}
.batch-move {
height: 500px;
}
</style>

View File

@ -4,8 +4,10 @@
:is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange">
<el-link type="primary" @click="open" style="float: right;margin-top: 5px">{{$t('commons.adv_search.title')}}</el-link>
<el-input :placeholder="$t('commons.search_by_id_name_tag')" @blur="search" class="search-input" size="small" @keyup.enter.native="search"
<el-link type="primary" @click="open" style="float: right;margin-top: 5px">{{ $t('commons.adv_search.title') }}
</el-link>
<el-input :placeholder="$t('commons.search_by_id_name_tag')" @blur="search" class="search-input" size="small"
@keyup.enter.native="search"
v-model="condition.name"/>
<el-table v-loading="result.loading"
@ -62,7 +64,8 @@
:label="$t('api_test.definition.api_type')"
show-overflow-tooltip min-width="120px">
<template v-slot:default="scope" class="request-method">
<el-tag size="mini" :style="{'background-color': getColor(true, scope.row.method), border: getColor(true, scope.row.method)}"
<el-tag size="mini"
:style="{'background-color': getColor(true, scope.row.method), border: getColor(true, scope.row.method)}"
class="api-el-tag">
{{ scope.row.method }}
</el-tag>
@ -116,10 +119,13 @@
:label="$t('api_test.definition.api_case_passing_rate')"
show-overflow-tooltip/>
<el-table-column fixed="right" v-if="!isReadOnly" :label="$t('commons.operating')" min-width="130" align="center">
<el-table-column fixed="right" v-if="!isReadOnly" :label="$t('commons.operating')" min-width="130"
align="center">
<template v-slot:default="scope">
<ms-table-operator-button :tip="$t('commons.reduction')" icon="el-icon-refresh-left" @exec="reductionApi(scope.row)" v-if="trashEnable" v-tester/>
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="editApi(scope.row)" v-else v-tester/>
<ms-table-operator-button :tip="$t('commons.reduction')" icon="el-icon-refresh-left"
@exec="reductionApi(scope.row)" v-if="trashEnable" v-tester/>
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" @exec="editApi(scope.row)" v-else
v-tester/>
<el-tooltip :content="$t('test_track.case.case_list')"
placement="bottom"
:enterable="false"
@ -132,7 +138,8 @@
size="mini">case
</el-button>
</el-tooltip>
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" @exec="handleDelete(scope.row)" type="danger" v-tester/>
<ms-table-operator-button :tip="$t('commons.delete')" icon="el-icon-delete" @exec="handleDelete(scope.row)"
type="danger" v-tester/>
</template>
</el-table-column>
</el-table>
@ -144,7 +151,7 @@
<ms-batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/>
<!--高级搜索-->
<ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="search"/>
<case-batch-move @refresh="initTable" @moveSave="moveSave" ref="testCaseBatchMove"></case-batch-move>
</div>
</template>
@ -171,10 +178,12 @@
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import {API_DEFINITION_CONFIGS} from "@/business/components/common/components/search/search-components";
import MsTipButton from "@/business/components/common/components/MsTipButton";
import CaseBatchMove from "@/business/components/api/definition/components/basis/BatchMove";
export default {
name: "ApiList",
components: {
CaseBatchMove,
ApiStatus,
MsTableHeaderSelectPopover,
ApiListContainer,
@ -205,7 +214,10 @@
selectRows: new Set(),
buttons: [
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
{name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
{name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch},
{
name: this.$t('api_test.definition.request.batch_move'), handleClick: this.handleBatchMove
}
],
typeArr: [
{id: 'status', name: this.$t('api_test.definition.api_status')},
@ -271,12 +283,23 @@
type: Boolean,
default: false
},
moduleTree: {
type: Array,
default() {
return []
},
},
moduleOptions: {
type: Array,
default() {
return []
},
}
},
created: function () {
if (this.trashEnable) {
this.condition.filters = {status: ["Trash"]};
}
else {
} else {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
}
this.initTable();
@ -300,6 +323,20 @@
}
},
methods: {
handleBatchMove() {
this.$refs.testCaseBatchMove.open(this.moduleTree, [], this.moduleOptions);
},
moveSave(param) {
param.projectId = getCurrentProjectID();
param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
param.moduleId=param.nodeId;
this.$post('/api/definition/batch/editByParams', param, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
});
},
isApiListEnableChange(data) {
this.$emit('isApiListEnableChange', data);
},

View File

@ -583,6 +583,7 @@ export default {
create_info: 'Create',
update_info: 'Update',
batch_edit: "Batch edit",
batch_move:"Batch move",
path_valid_info: "The request path is invalid",
other_config: "Other Config",
message_template: "Message Template",

View File

@ -584,6 +584,7 @@ export default {
create_info: '创建',
update_info: '更新',
batch_edit: "批量编辑",
batch_move:"批量移动",
path_valid_info: "请求路径无效",
other_config: "其他设置",
message_template: "报文模版",

View File

@ -583,6 +583,7 @@ export default {
create_info: '創建',
update_info: '更新',
batch_edit: "批量編輯",
batch_move:"批量移動",
path_valid_info: "請求路徑無效",
other_config: "其他設置",
message_template: "報文模版",