fix(接口测试): 解决接口导入问题

--user=郭雨琦
--bug=1015712
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015712
--bug=1015679
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015679
This commit is contained in:
guoyuqi 2022-08-18 19:10:04 +08:00 committed by xiaomeinvG
parent 0a0a81d1e1
commit 6dcd86994c
4 changed files with 488 additions and 452 deletions

View File

@ -597,7 +597,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
swaggerApiInfo.setSummary(apiDefinition.getName()); swaggerApiInfo.setSummary(apiDefinition.getName());
// 设置导入后的模块名 根据 api moduleID 查库获得所属模块作为导出的模块名 // 设置导入后的模块名 根据 api moduleID 查库获得所属模块作为导出的模块名
//直接导出完整路径 //直接导出完整路径
if (apiDefinition.getModulePath() != null) { if (StringUtils.isNotBlank(apiDefinition.getModulePath())) {
String[] split = new String[0]; String[] split = new String[0];
String modulePath = apiDefinition.getModulePath(); String modulePath = apiDefinition.getModulePath();
String substring = modulePath.substring(0, 1); String substring = modulePath.substring(0, 1);
@ -611,6 +611,8 @@ public class Swagger3Parser extends SwaggerAbstractParser {
split = new String[]{modulePath}; split = new String[]{modulePath};
} }
swaggerApiInfo.setTags(Arrays.asList(split)); swaggerApiInfo.setTags(Arrays.asList(split));
} else {
swaggerApiInfo.setTags(new ArrayList<>());
} }
// 设置请求体 // 设置请求体
@ -1009,6 +1011,9 @@ public class Swagger3Parser extends SwaggerAbstractParser {
} }
private String getModulePath(List<String> tagTree, StringBuilder modulePath) { private String getModulePath(List<String> tagTree, StringBuilder modulePath) {
if (CollectionUtils.isEmpty(tagTree)) {
return "/未规划接口";
}
for (String s : tagTree) { for (String s : tagTree) {
if (s.contains("/")) { if (s.contains("/")) {
String[] split = s.split("/"); String[] split = s.split("/");

View File

@ -848,12 +848,15 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
int finalI = i; int finalI = i;
//在选择的模块下建模块查看选择的模块下有没有同名的模块 //在选择的模块下建模块查看选择的模块下有没有同名的模块
List<ApiScenarioModule> moduleList = pidChildrenMap.get(parentModule.getId()); List<ApiScenarioModule> moduleList = pidChildrenMap.get(parentModule.getId());
List<ApiScenarioModule> collect1 = moduleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList()); List<ApiScenarioModule> filterModuleList = null;
if (collect1.isEmpty()) { if (!CollectionUtils.isEmpty(moduleList)) {
filterModuleList = moduleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(filterModuleList)) {
return createModule(tagTree, i, parentModule, moduleMap, pidChildrenMap, idPathMap); return createModule(tagTree, i, parentModule, moduleMap, pidChildrenMap, idPathMap);
} else { } else {
returnModule = collect1.get(0); returnModule = filterModuleList.get(0);
parentModule = collect1.get(0); parentModule = filterModuleList.get(0);
} }
} }
return returnModule; return returnModule;

View File

@ -44,290 +44,296 @@
</template> </template>
<script> <script>
import SelectMenu from "../../../track/common/SelectMenu"; import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario"; import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import MsNodeTree from "../../../track/common/NodeTree"; import MsNodeTree from "../../../track/common/NodeTree";
import {buildNodePath, buildTree} from "../../definition/model/NodeTree"; import {buildTree} from "../../definition/model/NodeTree";
import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton"; import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton";
import ApiImport from "./common/ScenarioImport"; import ApiImport from "./common/ScenarioImport";
import MsSearchBar from "@/business/components/common/components/search/MsSearchBar"; import MsSearchBar from "@/business/components/common/components/search/MsSearchBar";
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID} from "@/common/js/utils";
export default { export default {
name: 'MsApiScenarioModule', name: 'MsApiScenarioModule',
components: { components: {
MsSearchBar, MsSearchBar,
ApiImport, ApiImport,
ModuleTrashButton, ModuleTrashButton,
MsNodeTree, MsNodeTree,
MsAddBasisScenario, MsAddBasisScenario,
SelectMenu, SelectMenu,
}, },
props: { props: {
isReadOnly: { isReadOnly: {
type: Boolean, type: Boolean,
default() { default() {
return false; return false;
}
},
showOperator: Boolean,
relevanceProjectId: String,
planId: String,
pageSource: String,
total: Number,
},
computed: {
isPlanModel() {
return this.planId ? true : false;
},
isRelevanceModel() {
return this.relevanceProjectId ? true : false;
},
projectId() {
return getCurrentProjectID();
},
getIsRelevance(){
if(this.pageSource !== 'scenario'){
return this.openType;
}else {
return "scenario";
}
} }
}, },
data() { showOperator: Boolean,
return { relevanceProjectId: String,
openType: 'relevance', planId: String,
result: {}, pageSource: String,
condition: { total: Number,
filterText: "", },
trashEnable: false computed: {
isPlanModel() {
return this.planId ? true : false;
},
isRelevanceModel() {
return this.relevanceProjectId ? true : false;
},
projectId() {
return getCurrentProjectID();
},
getIsRelevance() {
if (this.pageSource !== 'scenario') {
return this.openType;
} else {
return "scenario";
}
}
},
data() {
return {
openType: 'relevance',
result: {},
condition: {
filterText: "",
trashEnable: false
},
data: [],
currentModule: undefined,
operators: [
{
label: this.$t('api_test.automation.add_scenario'),
callback: this.addScenario,
permissions: ['PROJECT_API_SCENARIO:READ+CREATE']
}, },
data: [], {
currentModule: undefined, label: this.$t('api_test.api_import.label'),
operators: [ callback: this.handleImport,
{ permissions: ['PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO']
label: this.$t('api_test.automation.add_scenario'), },
callback: this.addScenario, {
permissions: ['PROJECT_API_SCENARIO:READ+CREATE'] label: this.$t('report.export'),
}, children: [
{ {
label: this.$t('api_test.api_import.label'), label: this.$t('report.export_to_ms_format'),
callback: this.handleImport, permissions: ['PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO'],
permissions: ['PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO'] callback: () => {
}, this.exportAPI();
{
label: this.$t('report.export'),
children: [
{
label: this.$t('report.export_to_ms_format'),
permissions: ['PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO'],
callback: () => {
this.exportAPI();
}
},
{
label: this.$t('report.export_jmeter_format'),
permissions: ['PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO'],
callback: () => {
this.$emit('exportJmx');
}
} }
] },
} {
] label: this.$t('report.export_jmeter_format'),
} permissions: ['PROJECT_API_SCENARIO:READ+EXPORT_SCENARIO'],
callback: () => {
this.$emit('exportJmx');
}
}
]
}
]
}
},
mounted() {
this.list();
},
watch: {
'condition.filterText'() {
this.filter();
}, },
mounted() { 'condition.trashEnable'() {
this.$emit('enableTrash', this.condition.trashEnable);
},
planId() {
this.list(); this.list();
}, },
watch: { relevanceProjectId() {
'condition.filterText'() { this.list();
this.filter(); }
}, },
'condition.trashEnable'() { methods: {
this.$emit('enableTrash', this.condition.trashEnable); handleImport() {
}, if (this.projectId) {
planId() { this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
this.list();
},
relevanceProjectId() {
this.list();
}
},
methods: {
handleImport() {
if (this.projectId) {
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
buildTree(node, {path: ''});
});
}
});
this.$refs.apiImport.open(this.currentModule);
}
},
filter() {
this.$refs.nodeTree.filter(this.condition.filterText);
},
list(projectId) {
let url = undefined;
if (this.isPlanModel) {
url = '/api/automation/module/list/plan/' + this.planId;
} else if (this.isRelevanceModel) {
url = "/api/automation/module/list/" + this.relevanceProjectId;
} else {
url = "/api/automation/module/list/" + (projectId ? projectId : this.projectId);
if (!this.projectId) {
return;
}
}
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) { if (response.data != undefined && response.data != null) {
this.data = response.data; this.data = response.data;
this.data.forEach(node => { this.data.forEach(node => {
node.name = node.name === '未规划场景' ? this.$t('api_test.automation.unplanned_scenario') : node.name
buildTree(node, {path: ''}); buildTree(node, {path: ''});
}); });
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
} }
}); });
}, this.$refs.apiImport.open(this.currentModule);
edit(param) { }
param.projectId = this.projectId; },
param.protocol = this.condition.protocol; filter() {
this.$post("/api/automation/module/edit", param, () => { this.$refs.nodeTree.filter(this.condition.filterText);
},
list(projectId) {
let url = undefined;
if (this.isPlanModel) {
url = '/api/automation/module/list/plan/' + this.planId;
} else if (this.isRelevanceModel) {
url = "/api/automation/module/list/" + this.relevanceProjectId;
} else {
url = "/api/automation/module/list/" + (projectId ? projectId : this.projectId);
if (!this.projectId) {
return;
}
}
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === '未规划场景' ? this.$t('api_test.automation.unplanned_scenario') : node.name
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
}
});
},
edit(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
this.$post("/api/automation/module/edit", param, () => {
this.$success(this.$t('commons.save_success'));
this.list();
this.refresh();
}, (error) => {
this.list();
});
},
add(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
if (param && param.level >= 9) {
this.list();
this.$error(this.$t('commons.warning_module_add'));
return;
} else {
this.$post("/api/automation/module/add", param, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.list(); this.list();
this.refresh();
}, (error) => { }, (error) => {
this.list(); this.list();
}); });
}, }
add(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
if (param && param.level >= 9) {
this.list();
this.$error(this.$t('commons.warning_module_add'));
return;
} else {
this.$post("/api/automation/module/add", param, () => {
this.$success(this.$t('commons.save_success'));
this.list();
}, (error) => {
this.list();
});
}
}, },
remove(nodeIds) { remove(nodeIds) {
this.$post("/api/automation/module/delete", nodeIds, () => { this.$post("/api/automation/module/delete", nodeIds, () => {
this.list(); this.list();
this.refresh(); this.refresh();
}, (error) => { this.removeModuleId(nodeIds);
}, (error) => {
this.list();
});
},
drag(param, list) {
this.$post("/api/automation/module/drag", param, () => {
this.$post("/api/automation/module/pos", list, () => {
this.list(); this.list();
}); });
}, }, (error) => {
drag(param, list) { this.list();
this.$post("/api/automation/module/drag", param, () => { });
this.$post("/api/automation/module/pos", list, () => { },
this.list(); nodeChange(node, nodeIds, pNodes) {
}); this.currentModule = node.data;
}, (error) => { this.condition.trashEnable = false;
this.list(); if (node.data.id === 'root') {
}); this.$emit("nodeSelectEvent", node, [], pNodes);
}, } else {
nodeChange(node, nodeIds, pNodes) { this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
this.currentModule = node.data; }
this.condition.trashEnable = false; },
if (node.data.id === 'root') { exportAPI() {
this.$emit("nodeSelectEvent", node, [], pNodes); this.$emit('exportAPI', this.data);
} else { },
this.$emit("nodeSelectEvent", node, nodeIds, pNodes); // debug() {
} // this.$emit('debug');
}, // },
exportAPI() { saveAsEdit(data) {
this.$emit('exportAPI', this.data); this.$emit('saveAsEdit', data);
}, },
// debug() { refresh() {
// this.$emit('debug'); this.$emit("refreshAll");
// }, },
saveAsEdit(data) { addScenario() {
this.$emit('saveAsEdit', data); if (!this.projectId) {
}, this.$warning(this.$t('commons.check_project_tip'));
refresh() { return;
this.$emit("refreshAll"); }
}, this.$refs.basisScenario.open(this.currentModule);
addScenario() { },
if (!this.projectId) { enableTrash() {
this.$warning(this.$t('commons.check_project_tip')); this.condition.trashEnable = true;
return; this.$emit('enableTrash', this.condition.trashEnable);
} },
this.$refs.basisScenario.open(this.currentModule); removeModuleId(nodeIds) {
}, if (localStorage.getItem('scenarioModule') && localStorage.getItem('scenarioModule') === nodeIds[0]) {
enableTrash() { localStorage.setItem('scenarioModule', undefined);
this.condition.trashEnable = true;
this.$emit('enableTrash', this.condition.trashEnable);
} }
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.node-tree { .node-tree {
margin-top: 15px; margin-top: 15px;
margin-bottom: 15px; margin-bottom: 15px;
} }
.ms-el-input { .ms-el-input {
height: 25px; height: 25px;
line-height: 25px; line-height: 25px;
} }
.custom-tree-node { .custom-tree-node {
flex: 1 1 auto; flex: 1 1 auto;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
font-size: 14px; font-size: 14px;
padding-right: 8px; padding-right: 8px;
width: 100%; width: 100%;
} }
.father .child { .father .child {
display: none; display: none;
} }
.father:hover .child { .father:hover .child {
display: block; display: block;
} }
.node-title { .node-title {
width: 0; width: 0;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
flex: 1 1 auto; flex: 1 1 auto;
padding: 0 5px; padding: 0 5px;
overflow: hidden; overflow: hidden;
} }
.node-operate > i { .node-operate > i {
color: #409eff; color: #409eff;
margin: 0 5px; margin: 0 5px;
} }
/deep/ .el-tree-node__content { /deep/ .el-tree-node__content {
height: 33px; height: 33px;
} }
.ms-api-buttion { .ms-api-buttion {
width: 30px; width: 30px;
} }
</style> </style>

View File

@ -4,23 +4,23 @@
<slot name="header"></slot> <slot name="header"></slot>
<ms-node-tree <ms-node-tree
:is-display="getIsRelevance" :is-display="getIsRelevance"
v-loading="result.loading" v-loading="result.loading"
:tree-nodes="data" :tree-nodes="data"
:type="isReadOnly ? 'view' : 'edit'" :type="isReadOnly ? 'view' : 'edit'"
:allLabel="$t('api_test.definition.api_all')" :allLabel="$t('api_test.definition.api_all')"
:default-label="$t('api_test.definition.unplanned_api')" :default-label="$t('api_test.definition.unplanned_api')"
local-suffix="api_definition" local-suffix="api_definition"
@add="add" @add="add"
@edit="edit" @edit="edit"
@drag="drag" @drag="drag"
@remove="remove" @remove="remove"
@refresh="list" @refresh="list"
@filter="filter" @filter="filter"
:delete-permission="['PROJECT_API_DEFINITION:READ+DELETE_API']" :delete-permission="['PROJECT_API_DEFINITION:READ+DELETE_API']"
:add-permission="['PROJECT_API_DEFINITION:READ+CREATE_API']" :add-permission="['PROJECT_API_DEFINITION:READ+CREATE_API']"
:update-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']" :update-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']"
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
ref="nodeTree"> ref="nodeTree">
<template v-slot:header> <template v-slot:header>
@ -67,210 +67,232 @@ export default {
}, },
data() { data() {
return { return {
openType: 'relevance', openType: 'relevance',
result: {}, result: {},
condition: { condition: {
protocol: OPTIONS[0].value, protocol: OPTIONS[0].value,
filterText: "", filterText: "",
trashEnable: false trashEnable: false
}, },
data: [], data: [],
currentModule: {}, currentModule: {},
}
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false;
} }
}, },
props: { showOperator: Boolean,
isReadOnly: { planId: String,
type: Boolean, currentVersion: String,
default() { relevanceProjectId: String,
return false; reviewId: String,
} pageSource: String,
}, total: Number,
showOperator: Boolean, isRelevance: Boolean,
planId: String, options: {
currentVersion: String, type: Array,
relevanceProjectId: String, default() {
reviewId: String, return OPTIONS;
pageSource: String,
total: Number,
isRelevance: Boolean,
options: {
type: Array,
default() {
return OPTIONS;
}
} }
}
},
computed: {
isPlanModel() {
return this.planId ? true : false;
}, },
computed: { isRelevanceModel() {
isPlanModel() { return this.relevanceProjectId ? true : false;
return this.planId ? true : false; },
}, isReviewModel() {
isRelevanceModel() { return this.reviewId ? true : false;
return this.relevanceProjectId ? true : false; },
}, projectId() {
isReviewModel() { return getCurrentProjectID();
return this.reviewId ? true : false; },
}, getIsRelevance() {
projectId() { if (this.pageSource !== 'definition') {
return getCurrentProjectID(); return this.openType;
}, } else {
getIsRelevance(){ return "definition";
if(this.pageSource !== 'definition'){
return this.openType;
}else {
return "definition";
}
} }
}, }
mounted() { },
this.initProtocol(); mounted() {
}, this.initProtocol();
},
watch: { watch: {
'condition.filterText'() { 'condition.filterText'() {
this.filter(); this.filter();
}, },
'condition.protocol'() { 'condition.protocol'() {
this.$emit('protocolChange', this.condition.protocol);
this.list();
},
'condition.trashEnable'() {
this.$emit('enableTrash', this.condition.trashEnable);
},
planId() {
this.list();
},
relevanceProjectId() {
this.list();
},
reviewId() {
this.list();
}
},
methods: {
initProtocol() {
if (this.$route.params.type) {
this.condition.protocol = this.$route.params.type;
this.$emit('protocolChange', this.condition.protocol); this.$emit('protocolChange', this.condition.protocol);
this.list(); this.list();
}, } else if (!this.isRelevance) {
'condition.trashEnable'() { //
this.$emit('enableTrash', this.condition.trashEnable); this.$get('/api/module/getUserDefaultApiType/', response => {
}, this.condition.protocol = response.data;
planId() { this.$emit('protocolChange', this.condition.protocol);
this.list(); this.list();
}, });
relevanceProjectId() { } else {
this.list(); this.$emit('protocolChange', this.condition.protocol);
},
reviewId() {
this.list(); this.list();
} }
}, },
methods: { filter() {
initProtocol() { this.$refs.nodeTree.filter(this.condition.filterText);
if(this.$route.params.type){ },
this.condition.protocol = this.$route.params.type; list(projectId) {
this.$emit('protocolChange', this.condition.protocol); let url = undefined;
this.list(); if (this.isPlanModel) {
}else if (!this.isRelevance) { url = '/api/module/list/plan/' + this.planId + '/' + this.condition.protocol;
// } else if (this.isRelevanceModel) {
this.$get('/api/module/getUserDefaultApiType/', response => { url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol +
this.condition.protocol = response.data; (this.currentVersion ? '/' + this.currentVersion : '');
this.$emit('protocolChange', this.condition.protocol); } else {
this.list(); url = "/api/module/list/" + (projectId ? projectId : this.projectId) + "/" + this.condition.protocol +
(this.currentVersion ? '/' + this.currentVersion : '');
if (!this.projectId) {
return;
}
}
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === '未规划接口' ? this.$t('api_test.definition.unplanned_api') : node.name
buildTree(node, {path: ''});
}); });
} else { this.$emit('setModuleOptions', this.data);
this.$emit('protocolChange', this.condition.protocol); this.$emit('setNodeTree', this.data);
this.list(); if (this.$refs.nodeTree) {
} this.$refs.nodeTree.filter(this.condition.filterText);
},
filter() {
this.$refs.nodeTree.filter(this.condition.filterText);
},
list(projectId) {
let url = undefined;
if (this.isPlanModel) {
url = '/api/module/list/plan/' + this.planId + '/' + this.condition.protocol;
} else if (this.isRelevanceModel) {
url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol +
(this.currentVersion ? '/' + this.currentVersion : '');
} else {
url = "/api/module/list/" + (projectId ? projectId : this.projectId) + "/" + this.condition.protocol +
(this.currentVersion ? '/' + this.currentVersion : '');
if (!this.projectId) {
return;
} }
} }
this.result = this.$get(url, response => { });
if (response.data != undefined && response.data != null) { },
this.data = response.data; edit(param) {
this.data.forEach(node => { param.projectId = this.projectId;
node.name = node.name === '未规划接口' ? this.$t('api_test.definition.unplanned_api') : node.name param.protocol = this.condition.protocol;
buildTree(node, {path: ''}); this.$post("/api/module/edit", param, () => {
}); this.$success(this.$t('commons.save_success'));
this.$emit('setModuleOptions', this.data); this.list();
this.$emit('setNodeTree', this.data); this.refresh();
if (this.$refs.nodeTree) { }, (error) => {
this.$refs.nodeTree.filter(this.condition.filterText); this.list();
} });
} },
}); add(param) {
}, param.projectId = this.projectId;
edit(param) { param.protocol = this.condition.protocol;
param.projectId = this.projectId; if (param && param.level >= 9) {
param.protocol = this.condition.protocol; this.list();
this.$post("/api/module/edit", param, () => { this.$error(this.$t('commons.warning_module_add'));
return;
} else {
this.$post("/api/module/add", param, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.list(); this.list();
this.refresh();
}, (error) => { }, (error) => {
this.list(); this.list();
}); });
}, }
add(param) { },
param.projectId = this.projectId; remove(nodeIds) {
param.protocol = this.condition.protocol; this.$post("/api/module/delete", nodeIds, () => {
if (param && param.level >= 9) {
this.list();
this.$error(this.$t('commons.warning_module_add'));
return;
} else {
this.$post("/api/module/add", param, () => {
this.$success(this.$t('commons.save_success'));
this.list();
}, (error) => {
this.list();
});
}
},
remove(nodeIds) {
this.$post("/api/module/delete", nodeIds, () => {
this.list();
this.refresh();
}, (error) => {
this.list();
});
},
drag(param, list) {
this.$post("/api/module/drag", param, () => {
this.$post("/api/module/pos", list, () => {
this.list();
});
}, (error) => {
this.list();
});
},
nodeChange(node, nodeIds, pNodes) {
this.currentModule = node.data;
this.condition.trashEnable = false;
if (node.data.id === 'root') {
this.$emit("nodeSelectEvent", node, [], pNodes);
} else {
this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
}
},
//---使
createRootModel() {
let dataArr = this.$refs.nodeTree.extendTreeNodes;
if (dataArr.length > 0) {
this.$refs.nodeTree.append({}, dataArr[0]);
}
},
exportAPI(type) {
this.$emit('exportAPI', type, this.data);
},
debug() {
this.$emit('debug');
},
saveAsEdit(data) {
this.$emit('saveAsEdit', data);
},
refresh() {
this.list(); this.list();
this.$emit('refreshTable'); this.refresh();
}, this.removeModuleId(nodeIds);
}, (error) => {
this.list();
});
},
drag(param, list) {
this.$post("/api/module/drag", param, () => {
this.$post("/api/module/pos", list, () => {
this.list();
});
}, (error) => {
this.list();
});
},
nodeChange(node, nodeIds, pNodes) {
this.currentModule = node.data;
this.condition.trashEnable = false;
if (node.data.id === 'root') {
this.$emit("nodeSelectEvent", node, [], pNodes);
} else {
this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
}
},
//---使
createRootModel() {
let dataArr = this.$refs.nodeTree.extendTreeNodes;
if (dataArr.length > 0) {
this.$refs.nodeTree.append({}, dataArr[0]);
}
},
exportAPI(type) {
this.$emit('exportAPI', type, this.data);
},
debug() {
this.$emit('debug');
},
saveAsEdit(data) {
this.$emit('saveAsEdit', data);
},
refresh() {
this.list();
this.$emit('refreshTable');
},
removeModuleId(nodeIds) {
if (localStorage.getItem('tcp') || localStorage.getItem('http') || localStorage.getItem('sql') || localStorage.getItem('dubbo')) {
if (this.condition.protocol === 'TCP') {
if (localStorage.getItem('tcp') === nodeIds[0]) {
localStorage.setItem('tcp', undefined);
}
} else if (this.condition.protocol === 'HTTP') {
if (localStorage.getItem('http') === nodeIds[0]) {
localStorage.setItem('http', undefined);
}
} else if (this.condition.protocol === 'SQL') {
if (localStorage.getItem('sql') === nodeIds[0]) {
localStorage.setItem('sql', undefined);
}
} else if (this.condition.protocol === 'DUBBO') {
if (localStorage.getItem('dubbo') === nodeIds[0]) {
localStorage.setItem('dubbo', undefined);
}
}
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>