fix(测试计划): 新建测试计划后跳转到详情&tab显隐

This commit is contained in:
teukkk 2024-06-17 21:08:45 +08:00 committed by Craftsman
parent 9bd8d96c8a
commit 98cc05e01e
2 changed files with 73 additions and 28 deletions

View File

@ -136,6 +136,7 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { FormInstance, Message, SelectOptionData, TreeNodeData, ValidatedError } from '@arco-design/web-vue';
import { cloneDeep } from 'lodash-es';
import dayjs from 'dayjs';
@ -155,6 +156,7 @@
import { ModuleTreeNode } from '@/models/common';
import type { AddTestPlanParams, SwitchListModel } from '@/models/testPlan/testPlan';
import { TestPlanRouteEnum } from '@/enums/routeEnum';
import { testPlanTypeEnum } from '@/enums/testPlanEnum';
import { DisabledTimeProps } from '@arco-design/web-vue/es/date-picker/interface';
@ -175,6 +177,7 @@
const { t } = useI18n();
const appStore = useAppStore();
const router = useRouter();
const drawerLoading = ref(false);
const formRef = ref<FormInstance>();
@ -270,10 +273,21 @@
emit('close');
}
function toDetail(id: string) {
router.push({
name: TestPlanRouteEnum.TEST_PLAN_INDEX_DETAIL,
query: {
id,
isNew: 'true',
},
});
}
function handleDrawerConfirm(isContinue: boolean) {
formRef.value?.validate(async (errors: undefined | Record<string, ValidatedError>) => {
if (!errors) {
drawerLoading.value = true;
let res = null;
try {
const params: AddTestPlanParams = {
...cloneDeep(form.value),
@ -285,7 +299,7 @@
delete params.groupId;
}
if (!props.planId?.length) {
await addTestPlan(params);
res = await addTestPlan(params);
Message.success(t('common.createSuccess'));
} else {
await updateTestPlan(params);
@ -299,9 +313,14 @@
drawerLoading.value = false;
}
if (!isContinue) {
if (!props.planId?.length) {
//
toDetail(res.id);
}
handleCancel();
} else {
form.value = { ...cloneDeep(initForm), moduleId: form.value.moduleId };
}
form.value = { ...cloneDeep(initForm), moduleId: form.value.moduleId };
}
});
}

View File

@ -305,32 +305,58 @@
}
const activeTab = ref('plan');
const tabList = ref([
{
value: 'plan',
label: t('testPlan.plan'),
},
{
value: 'featureCase',
label: t('menu.caseManagement.featureCase'),
},
{
value: 'apiCase',
label: t('testPlan.testPlanIndex.apiCase'),
},
{
value: 'apiScenario',
label: t('caseManagement.featureCase.sceneCase'),
},
{
value: 'defectList',
label: t('caseManagement.featureCase.defectList'),
},
{
value: 'executeHistory',
label: t('testPlan.featureCase.executionHistory'),
},
]);
const showBugAndExecTab = ref(route.query.isNew !== 'true'); // [/]tab
watch(
() => detail.value,
() => {
const { functionalCaseCount, apiCaseCount, apiScenarioCount } = detail.value || {};
// ,[/],,tab
if (functionalCaseCount || apiCaseCount || apiScenarioCount) {
showBugAndExecTab.value = true;
}
if (
(!functionalCaseCount && activeTab.value === 'featureCase') ||
(!apiCaseCount && activeTab.value === 'apiCase') ||
(!apiScenarioCount && activeTab.value === 'apiScenario')
) {
activeTab.value = 'plan';
}
}
);
const tabList = computed(() => {
return [
{
value: 'plan',
label: t('testPlan.plan'), //
show: true,
},
{
value: 'featureCase',
label: t('menu.caseManagement.featureCase'), //
show: detail.value.functionalCaseCount,
},
{
value: 'apiCase',
label: t('testPlan.testPlanIndex.apiCase'),
show: detail.value?.apiCaseCount,
},
{
value: 'apiScenario',
label: t('caseManagement.featureCase.sceneCase'),
show: detail.value?.apiScenarioCount,
},
{
value: 'defectList',
label: t('caseManagement.featureCase.defectList'), //
show: showBugAndExecTab.value,
},
{
value: 'executeHistory',
label: t('testPlan.featureCase.executionHistory'), //
show: showBugAndExecTab.value,
},
].filter((tab) => tab.show); // tab
});
function getTabBadge(tabKey: string) {
switch (tabKey) {
case 'featureCase':