refactor(接口测试): 修复查看接口引用项目显示不全以及版本查询不全问题

--bug=1022722 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001022722
--bug=1022720 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001022720
This commit is contained in:
guoyuqi 2023-02-10 15:14:59 +08:00 committed by xiaomeinvG
parent a122001c75
commit 80fae150a3
2 changed files with 43 additions and 24 deletions

View File

@ -24,6 +24,10 @@ export function getProjectVersions(projectId) {
return get('/project/version/get-project-versions/' + projectId);
}
export function getVersionsByProjectIds(param) {
return post('/project/version/get-versions', param);
}
export function versionEnableByProjectId(projectId) {
return get('/project/version/enable/' + projectId);
}

View File

@ -167,15 +167,21 @@
</template>
<script>
import MsTablePagination from 'metersphere-frontend/src/components/pagination/TablePagination';
import { apiProjectRelated, getOwnerProjectIds, getProject, getUserWorkspace, projectRelated } from '@/api/project';
import { getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId } from 'metersphere-frontend/src/utils/token';
import {
getOwnerProjectIds,
getOwnerProjects,
getProject,
getUserWorkspace,
projectRelated
} from '@/api/project';
import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId} from 'metersphere-frontend/src/utils/token';
import {getUUID} from 'metersphere-frontend/src/utils';
import {hasLicense} from 'metersphere-frontend/src/utils/permission';
import {getDefinitionReference, getPlanReference} from '@/api/definition';
import MsTable from 'metersphere-frontend/src/components/table/MsTable';
import MsTableColumn from 'metersphere-frontend/src/components/table/MsTableColumn';
import MsTabButton from '@/business/commons/MsTabs';
import {getProjectVersions} from "@/api/xpack";
import {getVersionsByProjectIds} from "@/api/xpack";
export default {
name: 'ShowReference',
@ -247,23 +253,34 @@ export default {
this.projectList = res.data ? res.data : [];
});
},
getVersionOptions(currentVersion) {
getVersionOptions(projectIds, data) {
if (!projectIds || projectIds.length === 0) {
projectIds = [];
}
if (hasLicense()) {
getProjectVersions(getCurrentProjectID()).then((response) => {
if (currentVersion) {
this.versionFilters = response.data
.filter((u) => u.id === currentVersion)
.map((u) => {
return {text: u.name, value: u.id};
});
getVersionsByProjectIds(projectIds).then((response) => {
if (this.projectFilters.length === 0 || !this.projectFilters.length) {
this.versionFilters = [];
} else {
this.versionFilters = response.data.map((u) => {
return {text: u.name, value: u.id};
this.versionFilters = response.data.filter((version) => {
return data.listObject.find((i) => i.versionId === version.id);
}).map((u) => {
return {text: u.name + "-" + this.getProjectName(u.projectId), value: u.id};
});
}
});
}
},
getProjectName(id) {
let name
for (let item of this.projectFilters) {
if (item.value === id) {
name = item.text;
break;
}
}
return name;
},
/**
* 操作方法
*/
@ -281,7 +298,6 @@ export default {
this.init();
this.getUserProjectList();
this.getWorkSpaceList();
this.getVersionOptions();
this.isVisible = true;
this.scenarioId = row.id;
this.type = type;
@ -318,17 +334,16 @@ export default {
workspaceIds.push(item.value);
});
}
apiProjectRelated({
userId: getCurrentUserId(),
workspaceIds: workspaceIds,
}).then((res) => {
getOwnerProjects().then((res) => {
this.projectFilters = res.data
.filter((project) => {
return data.listObject.find((i) => i.projectId === project.id);
})
.map((e) => {
return {text: e.name, value: e.id};
});
.filter((project) => {
return data.listObject.find((i) => i.projectId === project.id);
})
.map((e) => {
return {text: e.name, value: e.id};
});
let map = res.data.map(item => item.id);
this.getVersionOptions(map, data);
});
}
this.scenarioData = data.listObject || [];