refactor(接口测试): 优化引用场景的批量操作
This commit is contained in:
parent
6e880576ca
commit
e22b5803e4
|
@ -161,15 +161,12 @@
|
||||||
<!-- 场景步骤内容 -->
|
<!-- 场景步骤内容 -->
|
||||||
<div ref="stepInfo">
|
<div ref="stepInfo">
|
||||||
<el-tree node-key="resourceId" :props="props" :data="scenarioDefinition" class="ms-tree"
|
<el-tree node-key="resourceId" :props="props" :data="scenarioDefinition" class="ms-tree"
|
||||||
:default-expanded-keys="expandedNode"
|
|
||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
:allow-drop="allowDrop"
|
:allow-drop="allowDrop"
|
||||||
:empty-text="$t('api_test.scenario.step_info')"
|
:empty-text="$t('api_test.scenario.step_info')"
|
||||||
highlight-current
|
highlight-current
|
||||||
:show-checkbox="isBatchProcess"
|
:show-checkbox="isBatchProcess"
|
||||||
@check-change="chooseHeadsUp"
|
@check-change="chooseHeadsUp"
|
||||||
@node-expand="nodeExpand"
|
|
||||||
@node-collapse="nodeCollapse"
|
|
||||||
@node-drag-end="allowDrag" @node-click="nodeClick" draggable ref="stepTree">
|
@node-drag-end="allowDrag" @node-click="nodeClick" draggable ref="stepTree">
|
||||||
|
|
||||||
<el-row class="custom-tree-node" :gutter="18" type="flex" align="middle" slot-scope="{node, data}" style="width: 100%">
|
<el-row class="custom-tree-node" :gutter="18" type="flex" align="middle" slot-scope="{node, data}" style="width: 100%">
|
||||||
|
@ -191,7 +188,6 @@
|
||||||
:scenario="data"
|
:scenario="data"
|
||||||
:response="response"
|
:response="response"
|
||||||
:currentScenario="currentScenario"
|
:currentScenario="currentScenario"
|
||||||
:expandedNode="expandedNode"
|
|
||||||
:currentEnvironmentId="currentEnvironmentId"
|
:currentEnvironmentId="currentEnvironmentId"
|
||||||
:node="node"
|
:node="node"
|
||||||
:project-list="projectList"
|
:project-list="projectList"
|
||||||
|
@ -455,7 +451,6 @@ export default {
|
||||||
operatingElements: [],
|
operatingElements: [],
|
||||||
selectedTreeNode: undefined,
|
selectedTreeNode: undefined,
|
||||||
selectedNode: undefined,
|
selectedNode: undefined,
|
||||||
expandedNode: [],
|
|
||||||
scenarioDefinition: [],
|
scenarioDefinition: [],
|
||||||
path: "/api/automation/create",
|
path: "/api/automation/create",
|
||||||
repositoryCreatePath: "/repository/api/automation/create",
|
repositoryCreatePath: "/repository/api/automation/create",
|
||||||
|
@ -589,30 +584,35 @@ export default {
|
||||||
},
|
},
|
||||||
checkedAll(v) {
|
checkedAll(v) {
|
||||||
if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) {
|
if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) {
|
||||||
this.stepCheckedAll(v, this.$refs.stepTree.root.childNodes);
|
this.recursionChecked(v, this.$refs.stepTree.root.childNodes);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
stepCheckedAll(v, array) {
|
recursionChecked(v, array) {
|
||||||
if (array) {
|
if (array) {
|
||||||
array.forEach(item => {
|
array.forEach(item => {
|
||||||
if (item.childNodes && item.childNodes.length > 0) {
|
if (item.childNodes && item.childNodes.length > 0) {
|
||||||
this.stepCheckedAll(v, item.childNodes);
|
this.recursionChecked(v, item.childNodes);
|
||||||
}
|
}
|
||||||
item.checked = v;
|
item.checked = v;
|
||||||
|
if (item.data && item.data.type === 'scenario' && item.data.referenced === 'REF') {
|
||||||
|
item.expanded = false;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
batchProcessing() {
|
batchProcessing() {
|
||||||
this.isBatchProcess = true;
|
this.isBatchProcess = true;
|
||||||
this.expandedNode = [];
|
|
||||||
this.hideAllTreeNode(this.scenarioDefinition);
|
this.hideAllTreeNode(this.scenarioDefinition);
|
||||||
|
if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) {
|
||||||
|
this.recursionExpansion([], this.$refs.stepTree.root.childNodes);
|
||||||
|
}
|
||||||
this.reloadTreeStatus();
|
this.reloadTreeStatus();
|
||||||
},
|
},
|
||||||
cancelBatchProcessing() {
|
cancelBatchProcessing() {
|
||||||
this.isBatchProcess = false;
|
this.isBatchProcess = false;
|
||||||
this.isCheckedAll = false;
|
this.isCheckedAll = false;
|
||||||
if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) {
|
if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) {
|
||||||
this.stepCheckedAll(false, this.$refs.stepTree.root.childNodes);
|
this.recursionChecked(false, this.$refs.stepTree.root.childNodes);
|
||||||
}
|
}
|
||||||
this.selectDataCounts = 0;
|
this.selectDataCounts = 0;
|
||||||
this.commandTreeNode();
|
this.commandTreeNode();
|
||||||
|
@ -641,12 +641,12 @@ export default {
|
||||||
},
|
},
|
||||||
hideAllTreeNode(array) {
|
hideAllTreeNode(array) {
|
||||||
array.forEach(item => {
|
array.forEach(item => {
|
||||||
if (item.hashTree && item.hashTree.length > 0) {
|
|
||||||
this.hideAllTreeNode(item.hashTree);
|
|
||||||
}
|
|
||||||
item.isLeaf = this.isBatchProcess;
|
item.isLeaf = this.isBatchProcess;
|
||||||
item.isBatchProcess = this.isBatchProcess;
|
item.isBatchProcess = this.isBatchProcess;
|
||||||
item.checkBox = this.isBatchProcess;
|
item.checkBox = this.isBatchProcess;
|
||||||
|
if (item.hashTree && item.hashTree.length > 0) {
|
||||||
|
this.hideAllTreeNode(item.hashTree);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
commandTreeNode(node, array) {
|
commandTreeNode(node, array) {
|
||||||
|
@ -1452,16 +1452,6 @@ export default {
|
||||||
this.forceRerender();
|
this.forceRerender();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
nodeExpand(data, node) {
|
|
||||||
if (data && data.resourceId && this.expandedNode.indexOf(data.resourceId) === -1) {
|
|
||||||
this.expandedNode.push(data.resourceId);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
nodeCollapse(data, node) {
|
|
||||||
if (data && data.resourceId) {
|
|
||||||
this.expandedNode.splice(this.expandedNode.indexOf(data.resourceId), 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
editScenario() {
|
editScenario() {
|
||||||
if (!document.getElementById("inputDelay")) {
|
if (!document.getElementById("inputDelay")) {
|
||||||
return;
|
return;
|
||||||
|
@ -1771,11 +1761,8 @@ export default {
|
||||||
},
|
},
|
||||||
changeNodeStatus(resourceIds, nodes) {
|
changeNodeStatus(resourceIds, nodes) {
|
||||||
for (let i in nodes) {
|
for (let i in nodes) {
|
||||||
if (nodes[i]) {
|
if (nodes[i] && !(nodes[i].type === 'scenario' && nodes[i].referenced === 'REF')) {
|
||||||
if (resourceIds.indexOf(nodes[i].resourceId) !== -1) {
|
if (resourceIds.indexOf(nodes[i].resourceId) !== -1) {
|
||||||
if (this.expandedStatus) {
|
|
||||||
this.expandedNode.push(nodes[i].resourceId);
|
|
||||||
}
|
|
||||||
nodes[i].active = this.expandedStatus;
|
nodes[i].active = this.expandedStatus;
|
||||||
if (this.stepSize > 35 && this.expandedStatus) {
|
if (this.stepSize > 35 && this.expandedStatus) {
|
||||||
nodes[i].active = false;
|
nodes[i].active = false;
|
||||||
|
@ -1797,18 +1784,33 @@ export default {
|
||||||
}
|
}
|
||||||
return selectValueArr;
|
return selectValueArr;
|
||||||
},
|
},
|
||||||
|
recursionExpansion(resourceIds, array) {
|
||||||
|
if (array) {
|
||||||
|
array.forEach(item => {
|
||||||
|
if (item.data && item.data.type === 'scenario' && item.data.referenced === 'REF') {
|
||||||
|
item.expanded = false;
|
||||||
|
} else {
|
||||||
|
if (resourceIds.indexOf(item.data.resourceId) !== -1) {
|
||||||
|
item.expanded = this.expandedStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.childNodes && item.childNodes.length > 0) {
|
||||||
|
this.recursionExpansion(resourceIds, item.childNodes);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
openExpansion() {
|
openExpansion() {
|
||||||
this.expandedNode = [];
|
|
||||||
this.expandedStatus = true;
|
this.expandedStatus = true;
|
||||||
let resourceIds = this.getAllResourceIds();
|
let resourceIds = this.getAllResourceIds();
|
||||||
this.changeNodeStatus(resourceIds, this.scenarioDefinition);
|
this.changeNodeStatus(resourceIds, this.scenarioDefinition);
|
||||||
|
this.recursionExpansion(resourceIds, this.$refs.stepTree.root.childNodes);
|
||||||
},
|
},
|
||||||
closeExpansion() {
|
closeExpansion() {
|
||||||
this.expandedStatus = false;
|
this.expandedStatus = false;
|
||||||
this.expandedNode = [];
|
|
||||||
let resourceIds = this.getAllResourceIds();
|
let resourceIds = this.getAllResourceIds();
|
||||||
this.changeNodeStatus(resourceIds, this.scenarioDefinition);
|
this.changeNodeStatus(resourceIds, this.scenarioDefinition);
|
||||||
this.forceRerender();
|
this.recursionExpansion(resourceIds, this.$refs.stepTree.root.childNodes);
|
||||||
},
|
},
|
||||||
stepStatus(resourceIds, nodes) {
|
stepStatus(resourceIds, nodes) {
|
||||||
for (let i in nodes) {
|
for (let i in nodes) {
|
||||||
|
|
|
@ -192,7 +192,6 @@ export default {
|
||||||
},
|
},
|
||||||
currentEnvironmentId: String,
|
currentEnvironmentId: String,
|
||||||
projectList: Array,
|
projectList: Array,
|
||||||
expandedNode: Array,
|
|
||||||
envMap: Map,
|
envMap: Map,
|
||||||
message: String,
|
message: String,
|
||||||
environmentGroupId: String,
|
environmentGroupId: String,
|
||||||
|
@ -608,13 +607,6 @@ export default {
|
||||||
if (this.node) {
|
if (this.node) {
|
||||||
this.node.expanded = this.request.active;
|
this.node.expanded = this.request.active;
|
||||||
}
|
}
|
||||||
if (this.node.expanded && this.expandedNode && this.expandedNode.indexOf(this.request.resourceId) === -1) {
|
|
||||||
this.expandedNode.push(this.request.resourceId);
|
|
||||||
} else {
|
|
||||||
if (this.expandedNode && this.expandedNode.indexOf(this.request.resourceId) !== -1) {
|
|
||||||
this.expandedNode.splice(this.expandedNode.indexOf(this.request.resourceId), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.apiActive = this.request.active;
|
this.apiActive = this.request.active;
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
:isMax="isMax"
|
:isMax="isMax"
|
||||||
:show-btn="showBtn"
|
:show-btn="showBtn"
|
||||||
:show-version="showVersion"
|
:show-version="showVersion"
|
||||||
:expandedNode="expandedNode"
|
|
||||||
:scenario="scenario"
|
:scenario="scenario"
|
||||||
:controller="scenario"
|
:controller="scenario"
|
||||||
:timer="scenario"
|
:timer="scenario"
|
||||||
|
@ -90,7 +89,6 @@ export default {
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
currentScenario: {},
|
currentScenario: {},
|
||||||
expandedNode: Array,
|
|
||||||
currentEnvironmentId: String,
|
currentEnvironmentId: String,
|
||||||
response: {},
|
response: {},
|
||||||
node: {},
|
node: {},
|
||||||
|
|
|
@ -280,10 +280,10 @@ export default {
|
||||||
change(fileName) {
|
change(fileName) {
|
||||||
},
|
},
|
||||||
changeDisplay(fileName) {
|
changeDisplay(fileName) {
|
||||||
if (fileName === 'number of received messages') {
|
if (fileName === 'number of received messages' && this.pluginForm && this.pluginForm.hidden instanceof Function) {
|
||||||
this.pluginForm.hidden(true, "conditionTime");
|
this.pluginForm.hidden(true, "conditionTime");
|
||||||
}
|
}
|
||||||
if (fileName === 'specified elapsed time (ms)') {
|
if (fileName === 'specified elapsed time (ms)' && this.pluginForm && this.pluginForm.hidden instanceof Function) {
|
||||||
this.pluginForm.hidden(false, "conditionTime");
|
this.pluginForm.hidden(false, "conditionTime");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -382,7 +382,9 @@ export default {
|
||||||
this.pluginForm.setValue(this.request);
|
this.pluginForm.setValue(this.request);
|
||||||
}
|
}
|
||||||
if (this.request.condition) {
|
if (this.request.condition) {
|
||||||
this.changeDisplay(this.request.condition);
|
this.$nextTick(() => {
|
||||||
|
this.changeDisplay(this.request.condition);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.request.enable = false;
|
this.request.enable = false;
|
||||||
|
|
Loading…
Reference in New Issue