fix(接口定义): 修复通知跳转到接口定义,模块缺失的缺陷 (#18130)

--bug=1017085 --user=王孝刚 【接口管理】接口定义修改接口后提示信息跳转至编辑页面模块无提示请选择模块
https://www.tapd.cn/55049933/s/1248536

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-09-21 17:07:34 +08:00 committed by GitHub
parent 1051ab591a
commit c7ce36f268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View File

@ -87,10 +87,7 @@ import MsApiReportDetail from "@/business/components/api/automation/report/ApiRe
import MsTableMoreBtn from "@/business/components/api/automation/scenario/TableMoreBtn"; import MsTableMoreBtn from "@/business/components/api/automation/scenario/TableMoreBtn";
import PriorityTableItem from "@/business/components/track/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "@/business/components/track/common/tableItems/planview/PriorityTableItem";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import { import {API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components";
API_SCENARIO_CONFIGS,
TEST_PLAN_RELEVANCE_API_SCENARIO_CONFIGS
} from "@/business/components/common/components/search/search-components";
import {ENV_TYPE} from "@/common/js/constants"; import {ENV_TYPE} from "@/common/js/constants";
import {getCurrentProjectID, hasLicense} from "@/common/js/utils"; import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
@ -174,22 +171,21 @@ export default {
this.getVersionOptions(); this.getVersionOptions();
}, },
methods: { methods: {
search(projectId) { search(currentProjectId) {
this.selectRows = new Set(); this.selectRows = new Set();
this.condition.moduleIds = this.selectNodeIds; this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) { if (this.trashEnable) {
this.condition.filters = {status: ["Trash"]}; this.condition.filters = {status: ["Trash"]};
this.condition.moduleIds = []; this.condition.moduleIds = [];
} }
if (projectId) {
this.projectId = projectId;
}
if (this.projectId != null && typeof projectId === 'string') { if (this.projectId != null && typeof projectId === 'string') {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} else if (this.projectId != null) { } else if (this.projectId != null) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} }
if (currentProjectId) {
this.condition.projectId = currentProjectId;
}
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize; let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
if (this.condition.projectId) { if (this.condition.projectId) {

View File

@ -134,7 +134,7 @@
@handleTestCase="handleTestCase" @handleTestCase="handleTestCase"
@refreshTree="refreshTree" @refreshTree="refreshTree"
@changeSelectDataRangeAll="changeSelectDataRangeAll" @changeSelectDataRangeAll="changeSelectDataRangeAll"
@editApi="editApi" @editApiModule="editApiModule"
@copyApi="copyApi" @copyApi="copyApi"
@handleCase="handleCase" @handleCase="handleCase"
@showExecResult="showExecResult" @showExecResult="showExecResult"
@ -273,6 +273,7 @@ import ApiSchedule from "@/business/components/api/definition/components/import/
import MsEditCompleteContainer from "./components/EditCompleteContainer"; import MsEditCompleteContainer from "./components/EditCompleteContainer";
import MsEnvironmentSelect from "./components/case/MsEnvironmentSelect"; import MsEnvironmentSelect from "./components/case/MsEnvironmentSelect";
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants"; import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
import {buildTree} from "@/business/components/api/definition/model/NodeTree";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
@ -808,6 +809,23 @@ export default {
} }
} }
}, },
editApiModule(row) {
if (this.moduleOptions && this.moduleOptions.length === 0) {
let url = "/api/module/list/" + (row.projectId ? row.projectId : this.projectId) + "/" + row.protocol;
this.$get(url, response => {
if (response.data) {
response.data.forEach(node => {
node.name = node.name === '未规划接口' ? this.$t('api_test.definition.unplanned_api') : node.name
buildTree(node, {path: ''});
});
this.moduleOptions = response.data;
}
this.editApi(row);
});
} else {
this.editApi(row);
}
},
editApi(row) { editApi(row) {
const index = this.apiTabs.find(p => p.api && p.api.id === row.id); const index = this.apiTabs.find(p => p.api && p.api.id === row.id);
if (!index) { if (!index) {

View File

@ -777,7 +777,7 @@ export default {
}, },
editApi(row) { editApi(row) {
this.$emit('editApi', row); this.$emit('editApiModule', row);
}, },
handleCopy(row) { handleCopy(row) {
let obj = JSON.parse(JSON.stringify(row)); let obj = JSON.parse(JSON.stringify(row));