refactor: 去掉冗余代码
This commit is contained in:
parent
df73916d7d
commit
b5d7140aa8
|
@ -2,7 +2,7 @@
|
||||||
<div></div>
|
<div></div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
|
import {getUUID, getCurrentProjectID, strMapToObj} from "@/common/js/utils";
|
||||||
import {createComponent} from "../../definition/components/jmeter/components";
|
import {createComponent} from "../../definition/components/jmeter/components";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -117,22 +117,15 @@
|
||||||
threadGroup.hashTree.push(this.runData);
|
threadGroup.hashTree.push(this.runData);
|
||||||
testPlan.hashTree.push(threadGroup);
|
testPlan.hashTree.push(threadGroup);
|
||||||
let reqObj = {id: this.reportId, reportId: this.reportId, scenarioName: this.runData.name,
|
let reqObj = {id: this.reportId, reportId: this.reportId, scenarioName: this.runData.name,
|
||||||
scenarioId: this.runData.id, testElement: testPlan, projectId: getCurrentProjectID(), environmentMap: this.strMapToObj(map)};
|
scenarioId: this.runData.id, testElement: testPlan, projectId: getCurrentProjectID(), environmentMap: strMapToObj(map)};
|
||||||
let bodyFiles = this.getBodyUploadFiles(reqObj);
|
let bodyFiles = this.getBodyUploadFiles(reqObj);
|
||||||
let url = "/api/automation/run/debug";
|
let url = "/api/automation/run/debug";
|
||||||
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
||||||
this.runId = response.data;
|
this.runId = response.data;
|
||||||
this.$emit('runRefresh', {});
|
this.$emit('runRefresh', {});
|
||||||
}, erro => {
|
}, error => {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
strMapToObj(strMap){
|
|
||||||
let obj= Object.create(null);
|
|
||||||
for (let[k,v] of strMap) {
|
|
||||||
obj[k] = v;
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -221,7 +221,7 @@ import {
|
||||||
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
|
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
|
||||||
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
|
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
|
||||||
import MsApiCustomize from "./ApiCustomize";
|
import MsApiCustomize from "./ApiCustomize";
|
||||||
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
|
import {getCurrentProjectID, getUUID, objToStrMap, strMapToObj} from "@/common/js/utils";
|
||||||
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
|
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
|
||||||
import MsInputTag from "./MsInputTag";
|
import MsInputTag from "./MsInputTag";
|
||||||
import MsRun from "./DebugRun";
|
import MsRun from "./DebugRun";
|
||||||
|
@ -901,14 +901,6 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
objToStrMap(obj) {
|
|
||||||
let strMap = new Map();
|
|
||||||
for (let k of Object.keys(obj)) {
|
|
||||||
strMap.set(k, obj[k]);
|
|
||||||
}
|
|
||||||
return strMap;
|
|
||||||
},
|
|
||||||
|
|
||||||
getApiScenario() {
|
getApiScenario() {
|
||||||
if (this.currentScenario.tags != undefined && !(this.currentScenario.tags instanceof Array)) {
|
if (this.currentScenario.tags != undefined && !(this.currentScenario.tags instanceof Array)) {
|
||||||
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
|
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
|
||||||
|
@ -928,7 +920,7 @@ export default {
|
||||||
if (obj) {
|
if (obj) {
|
||||||
this.currentEnvironmentId = obj.environmentId;
|
this.currentEnvironmentId = obj.environmentId;
|
||||||
if (obj.environmentMap) {
|
if (obj.environmentMap) {
|
||||||
this.projectEnvMap = this.objToStrMap(obj.environmentMap);
|
this.projectEnvMap = objToStrMap(obj.environmentMap);
|
||||||
} else {
|
} else {
|
||||||
// 兼容历史数据
|
// 兼容历史数据
|
||||||
this.projectEnvMap.set(getCurrentProjectID(), obj.environmentId);
|
this.projectEnvMap.set(getCurrentProjectID(), obj.environmentId);
|
||||||
|
@ -964,13 +956,6 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
strMapToObj(strMap){
|
|
||||||
let obj= Object.create(null);
|
|
||||||
for (let[k,v] of strMap) {
|
|
||||||
obj[k] = v;
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
},
|
|
||||||
setParameter() {
|
setParameter() {
|
||||||
this.currentScenario.stepTotal = this.scenarioDefinition.length;
|
this.currentScenario.stepTotal = this.scenarioDefinition.length;
|
||||||
this.currentScenario.projectId = getCurrentProjectID();
|
this.currentScenario.projectId = getCurrentProjectID();
|
||||||
|
@ -984,7 +969,7 @@ export default {
|
||||||
variables: this.currentScenario.variables,
|
variables: this.currentScenario.variables,
|
||||||
headers: this.currentScenario.headers,
|
headers: this.currentScenario.headers,
|
||||||
referenced: 'Created',
|
referenced: 'Created',
|
||||||
environmentMap: this.strMapToObj(this.projectEnvMap),
|
environmentMap: strMapToObj(this.projectEnvMap),
|
||||||
hashTree: this.scenarioDefinition,
|
hashTree: this.scenarioDefinition,
|
||||||
projectId: this.projectId,
|
projectId: this.projectId,
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,7 +86,7 @@ import {getUUID, getBodyUploadFiles, getCurrentProjectID, strMapToObj} from "@/c
|
||||||
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
||||||
this.runId = response.data;
|
this.runId = response.data;
|
||||||
this.getResult();
|
this.getResult();
|
||||||
}, erro => {
|
}, error => {
|
||||||
this.$emit('runRefresh', {});
|
this.$emit('runRefresh', {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,3 +336,11 @@ export function strMapToObj(strMap){
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function objToStrMap(obj) {
|
||||||
|
let strMap = new Map();
|
||||||
|
for (let k of Object.keys(obj)) {
|
||||||
|
strMap.set(k, obj[k]);
|
||||||
|
}
|
||||||
|
return strMap;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue