refactor(接口测试): 优化场景导入系统请求过滤未开启接口模块的项目
This commit is contained in:
parent
6852d6199b
commit
341ed433ea
|
@ -1,4 +1,5 @@
|
||||||
import MSR from '@/api/http/index';
|
import MSR from '@/api/http/index';
|
||||||
|
import { associatedProjectOptionsUrl } from '@/api/requrls/case-management/featureCase';
|
||||||
import { ProjectListUrl, ProjectSwitchUrl } from '@/api/requrls/project-management/project';
|
import { ProjectListUrl, ProjectSwitchUrl } from '@/api/requrls/project-management/project';
|
||||||
|
|
||||||
import type { ProjectListItem } from '@/models/setting/project';
|
import type { ProjectListItem } from '@/models/setting/project';
|
||||||
|
@ -14,3 +15,7 @@ export function switchProject(data: { projectId: string; userId: string }) {
|
||||||
export function getProjectInfo(projectId: string) {
|
export function getProjectInfo(projectId: string) {
|
||||||
return MSR.get<ProjectListItem>({ url: `/project/get/${projectId}` });
|
return MSR.get<ProjectListItem>({ url: `/project/get/${projectId}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getProjectListByOrgAndModule(orgId: string, module: string) {
|
||||||
|
return MSR.get<ProjectListItem[]>({ url: `${ProjectListUrl}/${orgId}/${module}` });
|
||||||
|
}
|
||||||
|
|
|
@ -103,9 +103,9 @@
|
||||||
import MsButton from '@/components/pure/ms-button/index.vue';
|
import MsButton from '@/components/pure/ms-button/index.vue';
|
||||||
import MsDrawer from '@/components/pure/ms-drawer/index.vue';
|
import MsDrawer from '@/components/pure/ms-drawer/index.vue';
|
||||||
import { MsTableDataItem } from '@/components/pure/ms-table/type';
|
import { MsTableDataItem } from '@/components/pure/ms-table/type';
|
||||||
import MsProjectSelect from '@/components/business/ms-project-select/index.vue';
|
|
||||||
import { MsTreeNodeData } from '@/components/business/ms-tree/types';
|
import { MsTreeNodeData } from '@/components/business/ms-tree/types';
|
||||||
import moduleTree from './moduleTree.vue';
|
import moduleTree from './moduleTree.vue';
|
||||||
|
import MsProjectSelect from './projectSelect.vue';
|
||||||
import apiTable from './table.vue';
|
import apiTable from './table.vue';
|
||||||
|
|
||||||
import { getProtocolList } from '@/api/modules/api-test/common';
|
import { getProtocolList } from '@/api/modules/api-test/common';
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<template>
|
||||||
|
<a-select class="w-[260px]" :default-value="innerProject" allow-search @change="selectProject">
|
||||||
|
<template #arrow-icon>
|
||||||
|
<icon-caret-down />
|
||||||
|
</template>
|
||||||
|
<a-tooltip v-for="item of projectList" :key="item.id" :mouse-enter-delay="500" :content="item.name">
|
||||||
|
<a-option :value="item.id" :class="item.id === innerProject ? 'arco-select-option-selected' : ''">
|
||||||
|
{{ item.name }}
|
||||||
|
</a-option>
|
||||||
|
</a-tooltip>
|
||||||
|
</a-select>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getProjectList, getProjectListByOrgAndModule } from '@/api/modules/project-management/project';
|
||||||
|
import useAppStore from '@/store/modules/app';
|
||||||
|
|
||||||
|
import type { ProjectListItem } from '@/models/setting/project';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
project: string;
|
||||||
|
}>();
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:project', val: string): void;
|
||||||
|
(e: 'change', val: string): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const appStore = useAppStore();
|
||||||
|
const projectList = ref<ProjectListItem[]>([]);
|
||||||
|
const innerProject = ref(props.project || appStore.currentProjectId);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.project,
|
||||||
|
(val) => {
|
||||||
|
innerProject.value = val;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => innerProject.value,
|
||||||
|
(val) => {
|
||||||
|
emit('update:project', val);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
try {
|
||||||
|
if (appStore.currentOrgId) {
|
||||||
|
const res = await getProjectListByOrgAndModule(appStore.getCurrentOrgId, 'SCENARIO');
|
||||||
|
projectList.value = res;
|
||||||
|
} else {
|
||||||
|
projectList.value = [];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function selectProject(
|
||||||
|
value: string | number | boolean | Record<string, any> | (string | number | boolean | Record<string, any>)[]
|
||||||
|
) {
|
||||||
|
emit('update:project', value as string);
|
||||||
|
emit('change', value as string);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
Loading…
Reference in New Issue