mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-04 21:19:52 +08:00
refactor: 创建测试时选中默认项目
This commit is contained in:
parent
18310dcec3
commit
66b9962919
@ -8,10 +8,7 @@
|
|||||||
<el-input :disabled="isReadOnly" class="test-name" v-model="test.name" maxlength="60"
|
<el-input :disabled="isReadOnly" class="test-name" v-model="test.name" maxlength="60"
|
||||||
:placeholder="$t('api_test.input_name')"
|
:placeholder="$t('api_test.input_name')"
|
||||||
show-word-limit>
|
show-word-limit>
|
||||||
<el-select filterable class="test-project" v-model="test.projectId" slot="prepend"
|
<template slot="prepend">测试名称</template>
|
||||||
:placeholder="$t('api_test.select_project')">
|
|
||||||
<el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id"/>
|
|
||||||
</el-select>
|
|
||||||
</el-input>
|
</el-input>
|
||||||
|
|
||||||
<el-tooltip :content="'Ctrl + S'"
|
<el-tooltip :content="'Ctrl + S'"
|
||||||
@ -80,7 +77,7 @@ import MsApiScenarioConfig from "./components/ApiScenarioConfig";
|
|||||||
import {Scenario, Test} from "./model/ScenarioModel"
|
import {Scenario, Test} from "./model/ScenarioModel"
|
||||||
import MsApiReportStatus from "../report/ApiReportStatus";
|
import MsApiReportStatus from "../report/ApiReportStatus";
|
||||||
import MsApiReportDialog from "./ApiReportDialog";
|
import MsApiReportDialog from "./ApiReportDialog";
|
||||||
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils";
|
import {checkoutTestManagerOrTestUser, downloadFile, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||||
import MsScheduleConfig from "../../common/components/MsScheduleConfig";
|
import MsScheduleConfig from "../../common/components/MsScheduleConfig";
|
||||||
import ApiImport from "./components/import/ApiImport";
|
import ApiImport from "./components/import/ApiImport";
|
||||||
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
|
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
|
||||||
@ -124,8 +121,6 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
let projectId;
|
|
||||||
|
|
||||||
this.isReadOnly = !checkoutTestManagerOrTestUser();
|
this.isReadOnly = !checkoutTestManagerOrTestUser();
|
||||||
|
|
||||||
if (this.id) {
|
if (this.id) {
|
||||||
@ -137,14 +132,8 @@ export default {
|
|||||||
if (this.$refs.config) {
|
if (this.$refs.config) {
|
||||||
this.$refs.config.reset();
|
this.$refs.config.reset();
|
||||||
}
|
}
|
||||||
// 仅创建时获取选择的项目
|
|
||||||
projectId = this.$store.state.common.projectId;
|
|
||||||
}
|
}
|
||||||
this.result = this.$get("/project/listAll", response => {
|
this.test.projectId = getCurrentProjectID();
|
||||||
this.projects = response.data;
|
|
||||||
// 等待项目列表加载完
|
|
||||||
if (projectId) this.test.projectId = projectId;
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
updateReference() {
|
updateReference() {
|
||||||
let updateIds = [];
|
let updateIds = [];
|
||||||
@ -318,7 +307,6 @@ export default {
|
|||||||
break;
|
break;
|
||||||
case "performance":
|
case "performance":
|
||||||
this.$store.commit('setTest', {
|
this.$store.commit('setTest', {
|
||||||
projectId: this.test.projectId,
|
|
||||||
name: this.test.name,
|
name: this.test.name,
|
||||||
jmx: this.test.toJMX()
|
jmx: this.test.toJMX()
|
||||||
})
|
})
|
||||||
|
@ -8,17 +8,7 @@
|
|||||||
class="input-with-select"
|
class="input-with-select"
|
||||||
maxlength="30" show-word-limit
|
maxlength="30" show-word-limit
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template slot="prepend">测试名称</template>
|
||||||
<el-select filterable v-model="test.projectId"
|
|
||||||
:placeholder="$t('load_test.select_project')">
|
|
||||||
<el-option
|
|
||||||
v-for="item in projects"
|
|
||||||
:key="item.id"
|
|
||||||
:label="item.name"
|
|
||||||
:value="item.id">
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12" :offset="2">
|
<el-col :span="12" :offset="2">
|
||||||
@ -59,7 +49,7 @@ import PerformancePressureConfig from "./components/PerformancePressureConfig";
|
|||||||
import PerformanceAdvancedConfig from "./components/PerformanceAdvancedConfig";
|
import PerformanceAdvancedConfig from "./components/PerformanceAdvancedConfig";
|
||||||
import MsContainer from "../../common/components/MsContainer";
|
import MsContainer from "../../common/components/MsContainer";
|
||||||
import MsMainContainer from "../../common/components/MsMainContainer";
|
import MsMainContainer from "../../common/components/MsMainContainer";
|
||||||
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
import {checkoutTestManagerOrTestUser, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import MsScheduleConfig from "../../common/components/MsScheduleConfig";
|
import MsScheduleConfig from "../../common/components/MsScheduleConfig";
|
||||||
import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent";
|
import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent";
|
||||||
|
|
||||||
@ -77,7 +67,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
result: {},
|
result: {},
|
||||||
test: {schedule: {}},
|
test: {schedule: {}},
|
||||||
listProjectPath: "/project/listAll",
|
|
||||||
savePath: "/performance/save",
|
savePath: "/performance/save",
|
||||||
editPath: "/performance/edit",
|
editPath: "/performance/edit",
|
||||||
runPath: "/performance/run",
|
runPath: "/performance/run",
|
||||||
@ -127,9 +116,6 @@ export default {
|
|||||||
}
|
}
|
||||||
this.getTest(this.$route.params.testId);
|
this.getTest(this.$route.params.testId);
|
||||||
},
|
},
|
||||||
activated() {
|
|
||||||
this.listProjects();
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.importAPITest();
|
this.importAPITest();
|
||||||
},
|
},
|
||||||
@ -137,7 +123,6 @@ export default {
|
|||||||
importAPITest() {
|
importAPITest() {
|
||||||
let apiTest = this.$store.state.api.test;
|
let apiTest = this.$store.state.api.test;
|
||||||
if (apiTest && apiTest.name) {
|
if (apiTest && apiTest.name) {
|
||||||
this.$set(this.test, "projectId", apiTest.projectId);
|
|
||||||
this.$set(this.test, "name", apiTest.name);
|
this.$set(this.test, "name", apiTest.name);
|
||||||
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});
|
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});
|
||||||
let file = new File([blob], apiTest.jmx.name);
|
let file = new File([blob], apiTest.jmx.name);
|
||||||
@ -160,11 +145,6 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
listProjects() {
|
|
||||||
this.result = this.$get(this.listProjectPath, response => {
|
|
||||||
this.projects = response.data;
|
|
||||||
})
|
|
||||||
},
|
|
||||||
save() {
|
save() {
|
||||||
if (!this.validTest()) {
|
if (!this.validTest()) {
|
||||||
return;
|
return;
|
||||||
@ -237,6 +217,9 @@ export default {
|
|||||||
this.$router.push({path: '/performance/test/all'})
|
this.$router.push({path: '/performance/test/all'})
|
||||||
},
|
},
|
||||||
validTest() {
|
validTest() {
|
||||||
|
let currentProjectId = getCurrentProjectID();
|
||||||
|
this.test.projectId = currentProjectId;
|
||||||
|
|
||||||
if (!this.test.name) {
|
if (!this.test.name) {
|
||||||
this.$error(this.$t('load_test.test_name_is_null'));
|
this.$error(this.$t('load_test.test_name_is_null'));
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user