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());
// 设置导入后的模块名 根据 api moduleID 查库获得所属模块作为导出的模块名
//直接导出完整路径
if (apiDefinition.getModulePath() != null) {
if (StringUtils.isNotBlank(apiDefinition.getModulePath())) {
String[] split = new String[0];
String modulePath = apiDefinition.getModulePath();
String substring = modulePath.substring(0, 1);
@ -611,6 +611,8 @@ public class Swagger3Parser extends SwaggerAbstractParser {
split = new String[]{modulePath};
}
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) {
if (CollectionUtils.isEmpty(tagTree)) {
return "/未规划接口";
}
for (String s : tagTree) {
if (s.contains("/")) {
String[] split = s.split("/");

View File

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

View File

@ -44,290 +44,296 @@
</template>
<script>
import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import MsNodeTree from "../../../track/common/NodeTree";
import {buildNodePath, buildTree} from "../../definition/model/NodeTree";
import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton";
import ApiImport from "./common/ScenarioImport";
import MsSearchBar from "@/business/components/common/components/search/MsSearchBar";
import {getCurrentProjectID} from "@/common/js/utils";
import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import MsNodeTree from "../../../track/common/NodeTree";
import {buildTree} from "../../definition/model/NodeTree";
import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton";
import ApiImport from "./common/ScenarioImport";
import MsSearchBar from "@/business/components/common/components/search/MsSearchBar";
import {getCurrentProjectID} from "@/common/js/utils";
export default {
name: 'MsApiScenarioModule',
components: {
MsSearchBar,
ApiImport,
ModuleTrashButton,
MsNodeTree,
MsAddBasisScenario,
SelectMenu,
},
props: {
isReadOnly: {
type: Boolean,
default() {
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";
}
export default {
name: 'MsApiScenarioModule',
components: {
MsSearchBar,
ApiImport,
ModuleTrashButton,
MsNodeTree,
MsAddBasisScenario,
SelectMenu,
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false;
}
},
data() {
return {
openType: 'relevance',
result: {},
condition: {
filterText: "",
trashEnable: 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() {
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,
operators: [
{
label: this.$t('api_test.automation.add_scenario'),
callback: this.addScenario,
permissions: ['PROJECT_API_SCENARIO:READ+CREATE']
},
{
label: this.$t('api_test.api_import.label'),
callback: this.handleImport,
permissions: ['PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO']
},
{
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('api_test.api_import.label'),
callback: this.handleImport,
permissions: ['PROJECT_API_SCENARIO:READ+IMPORT_SCENARIO']
},
{
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');
}
}
]
}
]
}
},
mounted() {
this.list();
},
watch: {
'condition.filterText'() {
this.filter();
},
mounted() {
'condition.trashEnable'() {
this.$emit('enableTrash', this.condition.trashEnable);
},
planId() {
this.list();
},
watch: {
'condition.filterText'() {
this.filter();
},
'condition.trashEnable'() {
this.$emit('enableTrash', this.condition.trashEnable);
},
planId() {
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 => {
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 => {
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.$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) {
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.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.list();
}, (error) => {
this.list();
});
}
}
},
remove(nodeIds) {
this.$post("/api/automation/module/delete", nodeIds, () => {
this.list();
this.refresh();
}, (error) => {
},
remove(nodeIds) {
this.$post("/api/automation/module/delete", nodeIds, () => {
this.list();
this.refresh();
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();
});
},
drag(param, list) {
this.$post("/api/automation/module/drag", param, () => {
this.$post("/api/automation/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);
}
},
exportAPI() {
this.$emit('exportAPI', this.data);
},
// debug() {
// this.$emit('debug');
// },
saveAsEdit(data) {
this.$emit('saveAsEdit', data);
},
refresh() {
this.$emit("refreshAll");
},
addScenario() {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
this.$refs.basisScenario.open(this.currentModule);
},
enableTrash() {
this.condition.trashEnable = true;
this.$emit('enableTrash', this.condition.trashEnable);
}, (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);
}
},
exportAPI() {
this.$emit('exportAPI', this.data);
},
// debug() {
// this.$emit('debug');
// },
saveAsEdit(data) {
this.$emit('saveAsEdit', data);
},
refresh() {
this.$emit("refreshAll");
},
addScenario() {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
this.$refs.basisScenario.open(this.currentModule);
},
enableTrash() {
this.condition.trashEnable = true;
this.$emit('enableTrash', this.condition.trashEnable);
},
removeModuleId(nodeIds) {
if (localStorage.getItem('scenarioModule') && localStorage.getItem('scenarioModule') === nodeIds[0]) {
localStorage.setItem('scenarioModule', undefined);
}
}
}
}
</script>
<style scoped>
.node-tree {
margin-top: 15px;
margin-bottom: 15px;
}
.node-tree {
margin-top: 15px;
margin-bottom: 15px;
}
.ms-el-input {
height: 25px;
line-height: 25px;
}
.ms-el-input {
height: 25px;
line-height: 25px;
}
.custom-tree-node {
flex: 1 1 auto;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
width: 100%;
}
.custom-tree-node {
flex: 1 1 auto;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
width: 100%;
}
.father .child {
display: none;
}
.father .child {
display: none;
}
.father:hover .child {
display: block;
}
.father:hover .child {
display: block;
}
.node-title {
width: 0;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1 1 auto;
padding: 0 5px;
overflow: hidden;
}
.node-title {
width: 0;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1 1 auto;
padding: 0 5px;
overflow: hidden;
}
.node-operate > i {
color: #409eff;
margin: 0 5px;
}
.node-operate > i {
color: #409eff;
margin: 0 5px;
}
/deep/ .el-tree-node__content {
height: 33px;
}
/deep/ .el-tree-node__content {
height: 33px;
}
.ms-api-buttion {
width: 30px;
}
.ms-api-buttion {
width: 30px;
}
</style>

View File

@ -4,23 +4,23 @@
<slot name="header"></slot>
<ms-node-tree
:is-display="getIsRelevance"
v-loading="result.loading"
:tree-nodes="data"
:type="isReadOnly ? 'view' : 'edit'"
:allLabel="$t('api_test.definition.api_all')"
:default-label="$t('api_test.definition.unplanned_api')"
local-suffix="api_definition"
@add="add"
@edit="edit"
@drag="drag"
@remove="remove"
@refresh="list"
@filter="filter"
:delete-permission="['PROJECT_API_DEFINITION:READ+DELETE_API']"
:add-permission="['PROJECT_API_DEFINITION:READ+CREATE_API']"
:update-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']"
@nodeSelectEvent="nodeChange"
:is-display="getIsRelevance"
v-loading="result.loading"
:tree-nodes="data"
:type="isReadOnly ? 'view' : 'edit'"
:allLabel="$t('api_test.definition.api_all')"
:default-label="$t('api_test.definition.unplanned_api')"
local-suffix="api_definition"
@add="add"
@edit="edit"
@drag="drag"
@remove="remove"
@refresh="list"
@filter="filter"
:delete-permission="['PROJECT_API_DEFINITION:READ+DELETE_API']"
:add-permission="['PROJECT_API_DEFINITION:READ+CREATE_API']"
:update-permission="['PROJECT_API_DEFINITION:READ+EDIT_API']"
@nodeSelectEvent="nodeChange"
ref="nodeTree">
<template v-slot:header>
@ -67,210 +67,232 @@ export default {
},
data() {
return {
openType: 'relevance',
result: {},
condition: {
protocol: OPTIONS[0].value,
filterText: "",
trashEnable: false
},
data: [],
currentModule: {},
openType: 'relevance',
result: {},
condition: {
protocol: OPTIONS[0].value,
filterText: "",
trashEnable: false
},
data: [],
currentModule: {},
}
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false;
}
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false;
}
},
showOperator: Boolean,
planId: String,
currentVersion: String,
relevanceProjectId: String,
reviewId: String,
pageSource: String,
total: Number,
isRelevance: Boolean,
options: {
type: Array,
default() {
return OPTIONS;
}
showOperator: Boolean,
planId: String,
currentVersion: String,
relevanceProjectId: String,
reviewId: String,
pageSource: String,
total: Number,
isRelevance: Boolean,
options: {
type: Array,
default() {
return OPTIONS;
}
}
},
computed: {
isPlanModel() {
return this.planId ? true : false;
},
computed: {
isPlanModel() {
return this.planId ? true : false;
},
isRelevanceModel() {
return this.relevanceProjectId ? true : false;
},
isReviewModel() {
return this.reviewId ? true : false;
},
projectId() {
return getCurrentProjectID();
},
getIsRelevance(){
if(this.pageSource !== 'definition'){
return this.openType;
}else {
return "definition";
}
isRelevanceModel() {
return this.relevanceProjectId ? true : false;
},
isReviewModel() {
return this.reviewId ? true : false;
},
projectId() {
return getCurrentProjectID();
},
getIsRelevance() {
if (this.pageSource !== 'definition') {
return this.openType;
} else {
return "definition";
}
},
mounted() {
this.initProtocol();
},
}
},
mounted() {
this.initProtocol();
},
watch: {
'condition.filterText'() {
this.filter();
},
'condition.protocol'() {
watch: {
'condition.filterText'() {
this.filter();
},
'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.list();
},
'condition.trashEnable'() {
this.$emit('enableTrash', this.condition.trashEnable);
},
planId() {
this.list();
},
relevanceProjectId() {
this.list();
},
reviewId() {
} else if (!this.isRelevance) {
//
this.$get('/api/module/getUserDefaultApiType/', response => {
this.condition.protocol = response.data;
this.$emit('protocolChange', this.condition.protocol);
this.list();
});
} else {
this.$emit('protocolChange', this.condition.protocol);
this.list();
}
},
methods: {
initProtocol() {
if(this.$route.params.type){
this.condition.protocol = this.$route.params.type;
this.$emit('protocolChange', this.condition.protocol);
this.list();
}else if (!this.isRelevance) {
//
this.$get('/api/module/getUserDefaultApiType/', response => {
this.condition.protocol = response.data;
this.$emit('protocolChange', this.condition.protocol);
this.list();
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;
this.data.forEach(node => {
node.name = node.name === '未规划接口' ? this.$t('api_test.definition.unplanned_api') : node.name
buildTree(node, {path: ''});
});
} else {
this.$emit('protocolChange', this.condition.protocol);
this.list();
}
},
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.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
}
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: ''});
});
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/module/edit", param, () => {
});
},
edit(param) {
param.projectId = this.projectId;
param.protocol = this.condition.protocol;
this.$post("/api/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/module/add", 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/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() {
}
},
remove(nodeIds) {
this.$post("/api/module/delete", nodeIds, () => {
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>
<style scoped>