mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 20:19:16 +08:00
fix(测试计划): 新建测试计划后跳转到详情&tab显隐
This commit is contained in:
parent
9bd8d96c8a
commit
98cc05e01e
@ -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 };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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':
|
||||
|
Loading…
Reference in New Issue
Block a user