feat(接口管理): 新增用例执行跳转

This commit is contained in:
guoyuqi 2024-03-22 13:12:26 +08:00 committed by 刘瑞斌
parent d6decdbcdc
commit b26c85d198
5 changed files with 50 additions and 7 deletions

View File

@ -39,6 +39,7 @@
environmentId: string; environmentId: string;
request?: (...args) => Record<string, any>; request?: (...args) => Record<string, any>;
isCaseDetail?: boolean; isCaseDetail?: boolean;
executeCase?: boolean;
}>(); }>();
const { t } = useI18n(); const { t } = useI18n();
@ -132,6 +133,16 @@
caseDetail.value.executeLoading = false; caseDetail.value.executeLoading = false;
} }
watch(
() => props.executeCase,
(val) => {
if (val === true) {
execute(isPriorityLocalExec.value ? 'localExec' : 'serverExec');
}
},
{ immediate: true }
);
defineExpose({ defineExpose({
isPriorityLocalExec, isPriorityLocalExec,
execute, execute,

View File

@ -7,6 +7,7 @@
<execute <execute
ref="executeRef" ref="executeRef"
v-model:detail="caseDetail" v-model:detail="caseDetail"
:execute-case="props.executeCase"
:environment-id="environmentId as string" :environment-id="environmentId as string"
is-case-detail is-case-detail
/> />
@ -102,6 +103,7 @@
const props = defineProps<{ const props = defineProps<{
isDrawer?: boolean; // isDrawer?: boolean; //
executeCase?: boolean;
detail: RequestParam; detail: RequestParam;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{

View File

@ -55,7 +55,14 @@
</MsButton> </MsButton>
</div> </div>
</template> </template>
<caseDetail ref="caseDerailRef" is-drawer :detail="props.detail" :api-detail="props.apiDetail" v-bind="$attrs" /> <caseDetail
ref="caseDerailRef"
is-drawer
:execute-case="props.executeCase"
:detail="props.detail"
:api-detail="props.apiDetail"
v-bind="$attrs"
/>
</MsDrawer> </MsDrawer>
</template> </template>
@ -71,7 +78,8 @@
const props = defineProps<{ const props = defineProps<{
detail: RequestParam; detail: RequestParam;
apiDetail: RequestParam; apiDetail?: RequestParam;
executeCase?: boolean;
}>(); }>();
const { t } = useI18n(); const { t } = useI18n();

View File

@ -163,7 +163,7 @@
v-permission="['PROJECT_API_DEFINITION_CASE:READ+EXECUTE']" v-permission="['PROJECT_API_DEFINITION_CASE:READ+EXECUTE']"
type="text" type="text"
class="!mr-0" class="!mr-0"
@click="onExecute(record.id)" @click="isApi ? openCaseDetailDrawerAndExecute(record.id) : openCaseTabAndExecute(record)"
> >
{{ t('apiTestManagement.execute') }} {{ t('apiTestManagement.execute') }}
</MsButton> </MsButton>
@ -265,6 +265,7 @@
v-model:visible="caseDetailDrawerVisible" v-model:visible="caseDetailDrawerVisible"
:detail="caseDetail as RequestParam" :detail="caseDetail as RequestParam"
:api-detail="apiDetail as RequestParam" :api-detail="apiDetail as RequestParam"
:execute-case="caseExecute"
@update-follow="caseDetail.follow = !caseDetail.follow" @update-follow="caseDetail.follow = !caseDetail.follow"
@load-case="(id: string) => loadCase(id)" @load-case="(id: string) => loadCase(id)"
@delete-case="deleteCaseByDetail" @delete-case="deleteCaseByDetail"
@ -418,9 +419,9 @@
offspringIds: string[]; offspringIds: string[];
}>(); }>();
const emit = defineEmits<{ const caseExecute = ref(false);
(e: 'openCaseTab', record: ApiCaseDetail): void;
}>(); const emit = defineEmits(['openCaseTab', 'openCaseTabAndExecute']);
const appStore = useAppStore(); const appStore = useAppStore();
const { t } = useI18n(); const { t } = useI18n();
@ -1016,6 +1017,7 @@
} }
const caseDetailDrawerVisible = ref(false); const caseDetailDrawerVisible = ref(false);
const defaultCaseParams = inject<RequestParam>('defaultCaseParams'); const defaultCaseParams = inject<RequestParam>('defaultCaseParams');
const caseDetail = ref<Record<string, any>>({}); const caseDetail = ref<Record<string, any>>({});
@ -1045,6 +1047,16 @@
caseDetailDrawerVisible.value = true; caseDetailDrawerVisible.value = true;
} }
async function openCaseDetailDrawerAndExecute(id: string) {
await getCaseDetailInfo(id);
caseExecute.value = true;
caseDetailDrawerVisible.value = true;
}
function openCaseTabAndExecute(record: ApiCaseDetail) {
emit('openCaseTabAndExecute', record);
}
function deleteCaseByDetail() { function deleteCaseByDetail() {
caseDetailDrawerVisible.value = false; caseDetailDrawerVisible.value = false;
loadCaseList(); loadCaseList();

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="flex flex-1 flex-col overflow-hidden"> <div class="flex flex-1 flex-col overflow-hidden">
<div v-show="activeApiTab.id === 'all'" class="flex-1 overflow-hidden"> <div v-if="activeApiTab.id === 'all'" class="flex-1 overflow-hidden">
<caseTable <caseTable
ref="caseTableRef" ref="caseTableRef"
:offspring-ids="props.offspringIds" :offspring-ids="props.offspringIds"
@ -8,11 +8,13 @@
:active-module="props.activeModule" :active-module="props.activeModule"
:protocol="props.protocol" :protocol="props.protocol"
@open-case-tab="openCaseTab" @open-case-tab="openCaseTab"
@open-case-tab-and-execute="openCaseTabAndExecute"
/> />
</div> </div>
<div v-if="activeApiTab.id !== 'all'" class="flex-1 overflow-hidden"> <div v-if="activeApiTab.id !== 'all'" class="flex-1 overflow-hidden">
<caseDetail <caseDetail
:detail="activeApiTab" :detail="activeApiTab"
:execute-case="caseExecute"
:module-tree="props.moduleTree" :module-tree="props.moduleTree"
@delete-case="deleteCase" @delete-case="deleteCase"
@update-follow="activeApiTab.follow = !activeApiTab.follow" @update-follow="activeApiTab.follow = !activeApiTab.follow"
@ -59,6 +61,8 @@
const defaultCaseParams = inject<RequestParam>('defaultCaseParams'); const defaultCaseParams = inject<RequestParam>('defaultCaseParams');
const caseExecute = ref(false);
const loading = ref(false); const loading = ref(false);
async function openOrUpdateCaseTab(isOpen: boolean, id: string) { async function openOrUpdateCaseTab(isOpen: boolean, id: string) {
try { try {
@ -109,6 +113,11 @@
await openOrUpdateCaseTab(true, typeof apiInfo === 'string' ? apiInfo : apiInfo.id); await openOrUpdateCaseTab(true, typeof apiInfo === 'string' ? apiInfo : apiInfo.id);
} }
async function openCaseTabAndExecute(apiInfo: ApiCaseDetail | string) {
caseExecute.value = true;
await openCaseTab(apiInfo);
}
const caseTableRef = ref<InstanceType<typeof caseTable>>(); const caseTableRef = ref<InstanceType<typeof caseTable>>();
function deleteCase(id: string) { function deleteCase(id: string) {
emit('deleteCase', id); emit('deleteCase', id);
@ -117,5 +126,6 @@
defineExpose({ defineExpose({
openCaseTab, openCaseTab,
openCaseTabAndExecute,
}); });
</script> </script>