fix(接口测试): 修复接口定义进入页面不展示数据的问题

This commit is contained in:
song-tianyang 2024-04-07 23:19:59 +08:00 committed by Craftsman
parent a0c6ed78a7
commit 24181eada0
7 changed files with 35 additions and 12 deletions

View File

@ -412,7 +412,12 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
<addDependencyDrawer v-if="props.isDefinition" v-model:visible="showAddDependencyDrawer" :mode="addDependencyMode" /> <addDependencyDrawer
v-if="props.isDefinition"
v-model:visible="showAddDependencyDrawer"
:member-options="memberOptions"
:mode="addDependencyMode"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -439,6 +444,7 @@
import { getPluginScript, getProtocolList } from '@/api/modules/api-test/common'; import { getPluginScript, getProtocolList } from '@/api/modules/api-test/common';
import { addCase } from '@/api/modules/api-test/management'; import { addCase } from '@/api/modules/api-test/management';
import { getSocket } from '@/api/modules/project-management/commonScript'; import { getSocket } from '@/api/modules/project-management/commonScript';
import { getProjectOptions } from '@/api/modules/project-management/projectMember';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import useUserStore from '@/store/modules/user'; import useUserStore from '@/store/modules/user';
@ -1532,8 +1538,13 @@
function handleCancel() { function handleCancel() {
saveModalFormRef.value?.resetFields(); saveModalFormRef.value?.resetFields();
} }
const memberOptions = ref<{ label: string; value: string }[]>([]);
async function initMemberOptions() {
memberOptions.value = await getProjectOptions(appStore.currentProjectId);
memberOptions.value = memberOptions.value.map((e: any) => ({ label: e.name, value: e.id }));
}
onMounted(() => { onMounted(() => {
initMemberOptions();
if (!props.isDefinition) { if (!props.isDefinition) {
registerCatchSaveShortcut(handleSaveShortcut); registerCatchSaveShortcut(handleSaveShortcut);
} }

View File

@ -19,6 +19,7 @@
:offspring-ids="offspringIds" :offspring-ids="offspringIds"
class="flex-1 overflow-hidden !pl-0 !pr-[16px]" class="flex-1 overflow-hidden !pl-0 !pr-[16px]"
:protocol="protocol" :protocol="protocol"
:member-options="memberOptions"
read-only read-only
/> />
</div> </div>
@ -30,13 +31,17 @@
import apiTable from './management/api/apiTable.vue'; import apiTable from './management/api/apiTable.vue';
import moduleTree from '@/views/api-test/management/components/moduleTree.vue'; import moduleTree from '@/views/api-test/management/components/moduleTree.vue';
import { getProjectOptions } from '@/api/modules/project-management/projectMember';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { ModuleTreeNode } from '@/models/common'; import { ModuleTreeNode } from '@/models/common';
import useAppStore from '../../../../store/modules/app';
const props = defineProps<{ const props = defineProps<{
visible: boolean; visible: boolean;
mode: 'pre' | 'post'; // pre: post: mode: 'pre' | 'post'; // pre: post:
memberOptions: { label: string; value: string }[];
}>(); }>();
const { t } = useI18n(); const { t } = useI18n();

View File

@ -363,6 +363,7 @@
protocol: string; // protocol: string; //
readOnly?: boolean; // readOnly?: boolean; //
refreshTimeStamp?: number; refreshTimeStamp?: number;
memberOptions: { label: string; value: string }[];
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'openApiTab', record: ApiDefinitionDetail, isExecute?: boolean): void; (e: 'openApiTab', record: ApiDefinitionDetail, isExecute?: boolean): void;
@ -554,7 +555,6 @@
const statusFilters = ref<string[]>([]); const statusFilters = ref<string[]>([]);
const createUserFilterVisible = ref(false); const createUserFilterVisible = ref(false);
const createUserFilters = ref<string[]>([]); const createUserFilters = ref<string[]>([]);
const memberOptions = ref<{ label: string; value: string }[]>([]);
async function getModuleIds() { async function getModuleIds() {
let moduleIds: string[] = []; let moduleIds: string[] = [];
@ -567,11 +567,9 @@
} }
return moduleIds; return moduleIds;
} }
async function loadApiList() { async function loadApiList() {
const moduleIds = await getModuleIds(); const moduleIds = await getModuleIds();
memberOptions.value = await getProjectOptions(appStore.currentProjectId, keyword.value);
memberOptions.value = memberOptions.value.map((e: any) => ({ label: e.name, value: e.id }));
const params = { const params = {
keyword: keyword.value, keyword: keyword.value,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,

View File

@ -6,6 +6,7 @@
:offspring-ids="props.offspringIds" :offspring-ids="props.offspringIds"
:protocol="props.protocol" :protocol="props.protocol"
:refresh-time-stamp="refreshTableTimeStamp" :refresh-time-stamp="refreshTableTimeStamp"
:member-options="memberOptions"
@open-api-tab="(record, isExecute) => openApiTab(record, false, isExecute)" @open-api-tab="(record, isExecute) => openApiTab(record, false, isExecute)"
@open-copy-api-tab="openApiTab($event, true)" @open-copy-api-tab="openApiTab($event, true)"
@add-api-tab="addApiTab" @add-api-tab="addApiTab"
@ -109,6 +110,7 @@
:protocol="activeApiTab.protocol" :protocol="activeApiTab.protocol"
:api-detail="activeApiTab" :api-detail="activeApiTab"
:offspring-ids="props.offspringIds" :offspring-ids="props.offspringIds"
:member-options="memberOptions"
/> />
</a-tab-pane> </a-tab-pane>
<!-- <a-tab-pane v-if="!activeApiTab.isNew" key="mock" title="MOCK" class="ms-api-tab-pane"> </a-tab-pane> --> <!-- <a-tab-pane v-if="!activeApiTab.isNew" key="mock" title="MOCK" class="ms-api-tab-pane"> </a-tab-pane> -->
@ -168,6 +170,7 @@
offspringIds: string[]; offspringIds: string[];
moduleTree: ModuleTreeNode[]; // moduleTree: ModuleTreeNode[]; //
protocol: string; protocol: string;
memberOptions: { label: string; value: string }[];
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{

View File

@ -423,6 +423,7 @@
protocol: string; // protocol: string; //
apiDetail?: RequestParam; apiDetail?: RequestParam;
offspringIds: string[]; offspringIds: string[];
memberOptions: { label: string; value: string }[];
}>(); }>();
const caseExecute = ref(false); const caseExecute = ref(false);
@ -634,7 +635,6 @@
const caseFilters = ref<string[]>([]); const caseFilters = ref<string[]>([]);
const createUserFilterVisible = ref(false); const createUserFilterVisible = ref(false);
const createUserFilters = ref<string[]>([]); const createUserFilters = ref<string[]>([]);
const memberOptions = ref<{ label: string; value: string }[]>([]);
const lastReportStatusFilterVisible = ref(false); const lastReportStatusFilterVisible = ref(false);
const lastReportStatusList = computed(() => { const lastReportStatusList = computed(() => {
return Object.keys(ReportStatus[ReportEnum.API_REPORT]); return Object.keys(ReportStatus[ReportEnum.API_REPORT]);
@ -652,12 +652,8 @@
} }
return moduleIds; return moduleIds;
} }
async function loadCaseList() { async function loadCaseList() {
const selectModules = await getModuleIds(); const selectModules = await getModuleIds();
memberOptions.value = await getProjectOptions(appStore.currentProjectId, keyword.value);
memberOptions.value = memberOptions.value.map((e: any) => ({ label: e.name, value: e.id }));
const params = { const params = {
apiDefinitionId: props.apiDetail?.id, apiDefinitionId: props.apiDetail?.id,
keyword: keyword.value, keyword: keyword.value,

View File

@ -7,6 +7,7 @@
:is-api="false" :is-api="false"
:active-module="props.activeModule" :active-module="props.activeModule"
:protocol="props.protocol" :protocol="props.protocol"
:member-options="memberOptions"
@open-case-tab="openCaseTab" @open-case-tab="openCaseTab"
@open-case-tab-and-execute="openCaseTabAndExecute" @open-case-tab-and-execute="openCaseTabAndExecute"
/> />
@ -46,6 +47,7 @@
protocol: string; protocol: string;
offspringIds: string[]; offspringIds: string[];
moduleTree: ModuleTreeNode[]; // moduleTree: ModuleTreeNode[]; //
memberOptions: { label: string; value: string }[];
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'deleteCase', id: string): void; (e: 'deleteCase', id: string): void;

View File

@ -39,6 +39,7 @@
:offspring-ids="props.offspringIds" :offspring-ids="props.offspringIds"
:protocol="props.protocol" :protocol="props.protocol"
:module-tree="props.moduleTree" :module-tree="props.moduleTree"
:member-options="memberOptions"
@import="emit('import')" @import="emit('import')"
@delete-api="(id) => handleDeleteApiFromModuleTree(id)" @delete-api="(id) => handleDeleteApiFromModuleTree(id)"
/> />
@ -51,6 +52,7 @@
:protocol="props.protocol" :protocol="props.protocol"
:module-tree="props.moduleTree" :module-tree="props.moduleTree"
:offspring-ids="props.offspringIds" :offspring-ids="props.offspringIds"
:member-options="memberOptions"
@delete-case="(id) => handleDeleteApiFromModuleTree(id)" @delete-case="(id) => handleDeleteApiFromModuleTree(id)"
/> />
</template> </template>
@ -67,6 +69,7 @@
// import MockTable from '@/views/api-test/management/components/management/mock/mockTable.vue'; // import MockTable from '@/views/api-test/management/components/management/mock/mockTable.vue';
import { getProtocolList } from '@/api/modules/api-test/common'; import { getProtocolList } from '@/api/modules/api-test/common';
import { getProjectOptions } from '@/api/modules/project-management/projectMember';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useLeaveTabUnSaveCheck from '@/hooks/useLeaveTabUnSaveCheck'; import useLeaveTabUnSaveCheck from '@/hooks/useLeaveTabUnSaveCheck';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
@ -98,7 +101,11 @@
const { t } = useI18n(); const { t } = useI18n();
const setActiveApi: ((params: RequestParam) => void) | undefined = inject('setActiveApi'); const setActiveApi: ((params: RequestParam) => void) | undefined = inject('setActiveApi');
const memberOptions = ref<{ label: string; value: string }[]>([]);
async function initMemberOptions() {
memberOptions.value = await getProjectOptions(appStore.currentProjectId);
memberOptions.value = memberOptions.value.map((e: any) => ({ label: e.name, value: e.id }));
}
const currentTab = ref('api'); const currentTab = ref('api');
const tabOptions = [ const tabOptions = [
{ label: 'API', value: 'api' }, { label: 'API', value: 'api' },
@ -297,6 +304,7 @@
const currentEnvConfig = computed<EnvConfig | undefined>(() => environmentSelectRef.value?.currentEnvConfig); const currentEnvConfig = computed<EnvConfig | undefined>(() => environmentSelectRef.value?.currentEnvConfig);
onBeforeMount(() => { onBeforeMount(() => {
initMemberOptions();
initProtocolList(); initProtocolList();
}); });