fix: 接口定义创建到其他项目

This commit is contained in:
chenjianxing 2021-03-23 16:47:32 +08:00
parent 41a1a5f38b
commit e2285238d3
10 changed files with 64 additions and 40 deletions

View File

@ -140,7 +140,7 @@ import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage"; import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage"; import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage"; import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
import {checkoutTestManagerOrTestUser, getCurrentProjectID, getCurrentUser, getUUID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils";
import MsApiModule from "./components/module/ApiModule"; import MsApiModule from "./components/module/ApiModule";
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList"; import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
@ -159,7 +159,10 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
}, },
isReadOnly(){ isReadOnly(){
return !checkoutTestManagerOrTestUser(); return !checkoutTestManagerOrTestUser();
} },
projectId() {
return this.$store.state.projectId
},
}, },
components: { components: {
MsTabButton, MsTabButton,
@ -211,13 +214,9 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
}], }],
activeDom: "left", activeDom: "left",
syncTabs: [], syncTabs: [],
projectId: "",
nodeTree: [] nodeTree: []
} }
}, },
mounted() {
this.projectId = getCurrentProjectID();
},
watch: { watch: {
currentProtocol() { currentProtocol() {
this.handleCommand("CLOSE_ALL"); this.handleCommand("CLOSE_ALL");

View File

@ -59,7 +59,7 @@
import MsDialogFooter from "../../../../common/components/MsDialogFooter"; import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {WORKSPACE_ID} from '../../../../../../common/js/constants'; import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import {REQ_METHOD} from "../../model/JsonData"; import {REQ_METHOD} from "../../model/JsonData";
import {getCurrentProjectID, getCurrentUser} from "../../../../../../common/js/utils"; import {getCurrentUser} from "../../../../../../common/js/utils";
import {createComponent, Request} from "../jmeter/components"; import {createComponent, Request} from "../jmeter/components";
export default { export default {
@ -94,8 +94,12 @@
value: REQ_METHOD[0].id, value: REQ_METHOD[0].id,
options: REQ_METHOD, options: REQ_METHOD,
} }
} },
, computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: { methods: {
saveApi(saveAs) { saveApi(saveAs) {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
@ -137,7 +141,7 @@
break; break;
} }
this.httpForm.bodyUploadIds = []; this.httpForm.bodyUploadIds = [];
this.httpForm.projectId = getCurrentProjectID(); this.httpForm.projectId = this.projectId;
this.httpForm.id = this.httpForm.request.id; this.httpForm.id = this.httpForm.request.id;
this.httpForm.protocol = this.currentProtocol; this.httpForm.protocol = this.currentProtocol;

View File

@ -36,7 +36,6 @@
<script> <script>
import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel"; import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
export default { export default {
name: "MsSetEnvironment", name: "MsSetEnvironment",
@ -64,6 +63,11 @@ export default {
this.environmentChange(this.environmentId); this.environmentChange(this.environmentId);
}, },
}, },
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: { methods: {
environmentChange(value) { environmentChange(value) {
for (let i in this.environments) { for (let i in this.environments) {
@ -74,7 +78,7 @@ export default {
} }
}, },
getEnvironments() { getEnvironments() {
let selectProjectId = getCurrentProjectID(); let selectProjectId = this.projectId;
if (selectProjectId) { if (selectProjectId) {
this.$get('/api/environment/list/' + selectProjectId, response => { this.$get('/api/environment/list/' + selectProjectId, response => {
this.environments = response.data; this.environments = response.data;

View File

@ -50,7 +50,7 @@
import ApiCaseHeader from "./ApiCaseHeader"; import ApiCaseHeader from "./ApiCaseHeader";
import ApiCaseItem from "./ApiCaseItem"; import ApiCaseItem from "./ApiCaseItem";
import MsRun from "../Run"; import MsRun from "../Run";
import {getCurrentProjectID, getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import MsDrawer from "../../../../common/components/MsDrawer"; import MsDrawer from "../../../../common/components/MsDrawer";
import {CASE_ORDER} from "../../model/JsonData"; import {CASE_ORDER} from "../../model/JsonData";
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components"; import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
@ -89,7 +89,6 @@
runData: [], runData: [],
selectdCases: [], selectdCases: [],
reportId: "", reportId: "",
projectId: "",
testCaseId: "", testCaseId: "",
checkedCases: new Set(), checkedCases: new Set(),
visible: false, visible: false,
@ -128,7 +127,6 @@
}, },
created() { created() {
this.api = this.currentApi; this.api = this.currentApi;
this.projectId = getCurrentProjectID();
if (this.createCase) { if (this.createCase) {
this.sysAddition(); this.sysAddition();
} }
@ -136,7 +134,10 @@
computed: { computed: {
isCaseEdit() { isCaseEdit() {
return this.testCaseId ? true : false; return this.testCaseId ? true : false;
} },
projectId() {
return this.$store.state.projectId
},
}, },
methods: { methods: {
open(api, testCaseId) { open(api, testCaseId) {
@ -290,7 +291,7 @@
this.singleRunId = row.id; this.singleRunId = row.id;
row.request.name = row.id; row.request.name = row.id;
row.request.useEnvironment = this.environment; row.request.useEnvironment = this.environment;
row.request.projectId = getCurrentProjectID(); row.request.projectId = this.projectId;
this.runData.push(row.request); this.runData.push(row.request);
/*触发执行操作*/ /*触发执行操作*/
this.reportId = getUUID().substring(0, 8); this.reportId = getUUID().substring(0, 8);
@ -354,7 +355,7 @@
if (form) { if (form) {
param[form.type] = form.value; param[form.type] = form.value;
param.ids = this.selectdCases; param.ids = this.selectdCases;
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
param.envId = form.envId; param.envId = form.envId;
if (this.api) { if (this.api) {
param.protocol = this.api.protocol; param.protocol = this.api.protocol;

View File

@ -94,7 +94,6 @@
<script> <script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter"; import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {getCurrentProjectID} from "../../../../../../common/js/utils";
import ScheduleImport from "@/business/components/api/definition/components/import/ImportScheduleEdit"; import ScheduleImport from "@/business/components/api/definition/components/import/ImportScheduleEdit";
export default { export default {
@ -202,7 +201,10 @@ export default {
}, },
isScenarioModel() { isScenarioModel() {
return this.model === 'scenario'; return this.model === 'scenario';
} },
projectId() {
return this.$store.state.projectId
},
}, },
methods: { methods: {
scheduleEdit() { scheduleEdit() {
@ -283,7 +285,7 @@ export default {
}) })
param.modeId = this.formData.modeId param.modeId = this.formData.modeId
} }
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
if (!this.swaggerUrlEnable) { if (!this.swaggerUrlEnable) {
param.swaggerUrl = undefined; param.swaggerUrl = undefined;
} }

View File

@ -143,7 +143,7 @@ import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {getBodyUploadFiles, getCurrentProjectID, getCurrentUser} from "@/common/js/utils"; import {getBodyUploadFiles} from "@/common/js/utils";
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns"; import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
import MsReferenceView from "../reference/ReferenceView"; import MsReferenceView from "../reference/ReferenceView";
@ -282,11 +282,13 @@ export default {
} }
}, },
computed: { computed: {
// //
isApiModel() { isApiModel() {
return this.model === 'api' return this.model === 'api'
}, },
projectId() {
return this.$store.state.projectId
},
}, },
methods: { methods: {
customHeader() { customHeader() {
@ -305,7 +307,7 @@ export default {
this.selectAll = false; this.selectAll = false;
this.unSelection = []; this.unSelection = [];
this.selectDataCounts = 0; this.selectDataCounts = 0;
this.condition.projectId = getCurrentProjectID(); this.condition.projectId = this.projectId;
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
@ -409,7 +411,7 @@ export default {
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
let obj = {}; let obj = {};
obj.projectId = getCurrentProjectID(); obj.projectId = this.projectId;
obj.selectAllDate = this.isSelectAllDate; obj.selectAllDate = this.isSelectAllDate;
obj.unSelectIds = this.unSelection; obj.unSelectIds = this.unSelection;
obj.ids = Array.from(this.selectRows).map(row => row.id); obj.ids = Array.from(this.selectRows).map(row => row.id);
@ -456,7 +458,7 @@ export default {
let param = {}; let param = {};
param[form.type] = form.value; param[form.type] = form.value;
param.ids = ids; param.ids = ids;
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
param.selectAllDate = this.isSelectAllDate; param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection; param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition); param = Object.assign(param, this.condition);
@ -528,7 +530,7 @@ export default {
}, },
showEnvironment(row) { showEnvironment(row) {
let projectID = getCurrentProjectID(); let projectID = this.projectId;
if (this.projectId) { if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => { this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data; this.environments = response.data;
@ -580,7 +582,7 @@ export default {
id: row.id, id: row.id,
testElement: testPlan, testElement: testPlan,
name: row.name, name: row.name,
projectId: getCurrentProjectID(), projectId: this.projectId,
}; };
let bodyFiles = getBodyUploadFiles(reqObj, runData); let bodyFiles = getBodyUploadFiles(reqObj, runData);
reqObj.reportId = "run"; reqObj.reportId = "run";

View File

@ -225,7 +225,6 @@
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils";
import {PROJECT_NAME} from '@/common/js/constants'; import {PROJECT_NAME} from '@/common/js/constants';
import {getCurrentProjectID, getCurrentUser} from "@/common/js/utils";
import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants'; import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants';
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
@ -370,6 +369,11 @@
}, },
} }
}, },
computed: {
projectId() {
return this.$store.state.projectId
},
},
created: function () { created: function () {
if (this.trashEnable) { if (this.trashEnable) {
this.condition.filters = {status: ["Trash"]}; this.condition.filters = {status: ["Trash"]};
@ -409,7 +413,7 @@
initCondition(this.condition); initCondition(this.condition);
this.selectDataCounts = 0; this.selectDataCounts = 0;
this.condition.moduleIds = this.selectNodeIds; this.condition.moduleIds = this.selectNodeIds;
this.condition.projectId = getCurrentProjectID(); this.condition.projectId = this.projectId;
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
} }
@ -636,7 +640,7 @@
let arr = Array.from(this.selectRows); let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id); let ids = arr.map(row => row.id);
param.ids = ids; param.ids = ids;
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
param.moduleId = param.nodeId; param.moduleId = param.nodeId;
param.condition = this.condition; param.condition = this.condition;
param.selectAllDate = this.isSelectAllDate; param.selectAllDate = this.isSelectAllDate;

View File

@ -38,7 +38,6 @@ import MsAddBasisApi from "../basis/AddBasisApi";
import SelectMenu from "../../../../track/common/SelectMenu"; import SelectMenu from "../../../../track/common/SelectMenu";
import {OPTIONS} from "../../model/JsonData"; import {OPTIONS} from "../../model/JsonData";
import ApiImport from "../import/ApiImport"; import ApiImport from "../import/ApiImport";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../../track/common/NodeTree"; import MsNodeTree from "../../../../track/common/NodeTree";
import ApiModuleHeader from "./ApiModuleHeader"; import ApiModuleHeader from "./ApiModuleHeader";
import {buildNodePath} from "../../model/NodeTree"; import {buildNodePath} from "../../model/NodeTree";
@ -60,7 +59,6 @@ export default {
filterText: "", filterText: "",
trashEnable: false trashEnable: false
}, },
projectId: "",
data: [], data: [],
currentModule: {}, currentModule: {},
} }
@ -85,10 +83,12 @@ export default {
}, },
isReviewModel() { isReviewModel() {
return this.reviewId ? true : false; return this.reviewId ? true : false;
} },
projectId() {
return this.$store.state.projectId
},
}, },
mounted() { mounted() {
this.projectId = getCurrentProjectID();
this.$emit('protocolChange', this.condition.protocol); this.$emit('protocolChange', this.condition.protocol);
this.list(); this.list();
}, },

View File

@ -58,7 +58,6 @@ import {OPTIONS} from "../../model/JsonData";
import MsAddBasisApi from "../basis/AddBasisApi"; import MsAddBasisApi from "../basis/AddBasisApi";
import ApiImport from "../import/ApiImport"; import ApiImport from "../import/ApiImport";
import ModuleTrashButton from "./ModuleTrashButton"; import ModuleTrashButton from "./ModuleTrashButton";
import {getCurrentProjectID} from "../../../../../../common/js/utils";
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree"; import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
import TemplateComponent from "../../../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent"; import TemplateComponent from "../../../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
@ -91,6 +90,11 @@ export default {
} }
}, },
}, },
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: { methods: {
handleCommand(e) { handleCommand(e) {
@ -104,12 +108,12 @@ export default {
case "add-module": case "add-module":
break; break;
case "import": case "import":
if (!getCurrentProjectID()) { if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip')); this.$warning(this.$t('commons.check_project_tip'));
return; return;
} }
this.protocol = "HTTP"; this.protocol = "HTTP";
this.result = this.$get("/api/module/list/" + getCurrentProjectID() + "/" + this.protocol, response => { this.result = this.$get("/api/module/list/" + this.projectId + "/" + this.protocol, response => {
if (response.data != undefined && response.data != null) { if (response.data != undefined && response.data != null) {
this.data = response.data; this.data = response.data;
let moduleOptions = []; let moduleOptions = [];
@ -124,7 +128,7 @@ export default {
} }
}, },
chooseExportType(e) { chooseExportType(e) {
if (!getCurrentProjectID()) { if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip')); this.$warning(this.$t('commons.check_project_tip'));
return; return;
} }
@ -138,7 +142,7 @@ export default {
} }
}, },
addApi() { addApi() {
if (!getCurrentProjectID()) { if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip')); this.$warning(this.$t('commons.check_project_tip'));
return; return;
} }

View File

@ -75,7 +75,10 @@ export default {
let projectId = localStorage.getItem(PROJECT_ID); let projectId = localStorage.getItem(PROJECT_ID);
if (!projectId || projectId != userLastProjectId) { if (!projectId || projectId != userLastProjectId) {
localStorage.setItem(PROJECT_ID, userLastProjectId); localStorage.setItem(PROJECT_ID, userLastProjectId);
this.$store.commit('setProjectId', userLastProjectId);
window.location.reload(); window.location.reload();
} else {
this.$store.commit('setProjectId', projectId);
} }
} }
} }
@ -109,6 +112,7 @@ export default {
} }
this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => { this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => {
localStorage.setItem(PROJECT_ID, projectId); localStorage.setItem(PROJECT_ID, projectId);
this.$store.commit('setProjectId', projectId);
let path = this.$route.matched[0].path ? this.$route.matched[0].path : '/'; let path = this.$route.matched[0].path ? this.$route.matched[0].path : '/';
if (path === '/api') { if (path === '/api') {
if (this.isNewVersion) { if (this.isNewVersion) {