refactor(测试计划): 测试计划详情-缺陷列表-点id查看详情

This commit is contained in:
teukkk 2024-06-03 17:40:40 +08:00 committed by 刘瑞斌
parent 536185bdca
commit 2650120822
6 changed files with 70 additions and 29 deletions

View File

@ -20,6 +20,7 @@
<slot name="titleLeft" :loading="loading" :detail="detail"></slot> <slot name="titleLeft" :loading="loading" :detail="detail"></slot>
</div> </div>
<MsPrevNextButton <MsPrevNextButton
v-if="props.tableData && props.pagination && props.pageChange"
ref="prevNextButtonRef" ref="prevNextButtonRef"
v-model:loading="loading" v-model:loading="loading"
class="ml-[16px]" class="ml-[16px]"
@ -52,15 +53,15 @@
width: number; width: number;
detailId: string; // id detailId: string; // id
tooltipText?: string; // tooltip tooltipText?: string; // tooltip
detailIndex: number; // detailIndex?: number; //
tableData: any[]; // tableData?: any[]; //
pagination: MsPaginationI; // pagination?: MsPaginationI; //
showFullScreen?: boolean; // showFullScreen?: boolean; //
pageChange: (page: number) => Promise<void>; // pageChange?: (page: number) => Promise<void>; //
getDetailFunc: (id: string) => Promise<any>; // getDetailFunc: (id: string) => Promise<any>; //
}>(); }>();
const emit = defineEmits(['update:visible', 'loaded', 'loadingDetail']); const emit = defineEmits(['update:visible', 'loaded', 'loadingDetail', 'getDetail']);
const prevNextButtonRef = ref<InstanceType<typeof MsPrevNextButton>>(); const prevNextButtonRef = ref<InstanceType<typeof MsPrevNextButton>>();
@ -108,7 +109,11 @@
if (innerVisible.value) { if (innerVisible.value) {
nextTick(() => { nextTick(() => {
// prevNextButtonRef // prevNextButtonRef
if (props.tableData && props.pagination && props.pageChange) {
initDetail(); initDetail();
} else {
emit('getDetail');
}
}); });
} }
}); });

View File

@ -45,7 +45,7 @@
const props = defineProps<{ const props = defineProps<{
loading: boolean; loading: boolean;
detailId: string; // id detailId: string; // id
detailIndex: number; // detailIndex?: number; //
tableData: any[]; // tableData: any[]; //
pagination: MsPaginationI; // pagination: MsPaginationI; //
pageChange: (page: number) => Promise<void>; // pageChange: (page: number) => Promise<void>; //
@ -82,12 +82,12 @@
{ immediate: true } { immediate: true }
); );
const activeDetailIndex = ref(props.detailIndex); const activeDetailIndex = ref(props.detailIndex || 0);
watch( watch(
() => props.detailIndex, () => props.detailIndex,
(val) => { (val) => {
activeDetailIndex.value = val; activeDetailIndex.value = val as number;
} }
); );

View File

@ -69,6 +69,7 @@ export interface TestPlanDetail extends AddTestPlanParams {
reReviewedCount: number; reReviewedCount: number;
underReviewedCount: number; underReviewedCount: number;
functionalCaseCount?: number; functionalCaseCount?: number;
bugCount?: number;
apiCaseCount?: number; apiCaseCount?: number;
apiScenarioCount?: number; apiScenarioCount?: number;
} }

View File

@ -17,6 +17,7 @@
:mask="false" :mask="false"
@loading-detail="setDetailLoading" @loading-detail="setDetailLoading"
@loaded="loadedBug" @loaded="loadedBug"
@get-detail="getDetail"
> >
<template #titleLeft> <template #titleLeft>
<div class="flex items-center"> <div class="flex items-center">
@ -286,11 +287,11 @@
const props = defineProps<{ const props = defineProps<{
visible: boolean; visible: boolean;
detailId: string; // id detailId: string; // id
detailIndex: number; // detailIndex?: number; //
detailDefaultTab: string; // tab detailDefaultTab: string; // tab
tableData: any[]; // tableData?: any[]; //
pagination: MsPaginationI; // pagination?: MsPaginationI; //
pageChange: (page: number) => Promise<void>; // pageChange?: (page: number) => Promise<void>; //
currentPlatform: string; currentPlatform: string;
}>(); }>();
const caseCount = ref(0); const caseCount = ref(0);
@ -560,7 +561,11 @@
await deleteSingleBug(params); await deleteSingleBug(params);
Message.success(t('common.deleteSuccess')); Message.success(t('common.deleteSuccess'));
updateSuccess(); updateSuccess();
if (!props.pagination && !props.tableData) {
showDrawerVisible.value = false;
} else {
detailDrawerRef.value?.openPrevDetail(); detailDrawerRef.value?.openPrevDetail();
}
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(error); console.log(error);
@ -655,6 +660,12 @@
}); });
return data; return data;
} }
async function getDetail() {
const res = await getBugDetail(props.detailId);
loadedBug(res);
}
watch( watch(
() => showDrawerVisible.value, () => showDrawerVisible.value,
(val) => { (val) => {
@ -665,6 +676,7 @@
activeTab.value = 'detail'; activeTab.value = 'detail';
} }
} else { } else {
if (!props.pagination && !props.tableData) return;
const query = { ...route.query }; const query = { ...route.query };
delete query.id; delete query.id;
router.replace({ router.replace({

View File

@ -16,8 +16,8 @@
/> />
</div> </div>
<MsBaseTable ref="tableRef" v-bind="propsRes" v-on="propsEvent"> <MsBaseTable ref="tableRef" v-bind="propsRes" v-on="propsEvent">
<template #num="{ record }"> <template v-if="props.canEdit" #num="{ record }">
<MsButton type="text" @click="toDetail(record.id)">{{ record.num }}</MsButton> <MsButton type="text" @click="handleShowDetail(record.id)">{{ record.num }}</MsButton>
</template> </template>
<template #name="{ record }"> <template #name="{ record }">
<a-tooltip :content="record.title"> <a-tooltip :content="record.title">
@ -35,6 +35,13 @@
</template> </template>
</MsBaseTable> </MsBaseTable>
</div> </div>
<BugDetailDrawer
v-model:visible="detailVisible"
:detail-id="activeDetailId"
detail-default-tab="detail"
:current-platform="currentPlatform"
@submit="refresh"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -46,22 +53,28 @@
import type { MsTableColumn } from '@/components/pure/ms-table/type'; import type { MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import CaseCountPopover from './caseCountPopover.vue'; import CaseCountPopover from './caseCountPopover.vue';
import BugDetailDrawer from '@/views/bug-management/components/bug-detail-drawer.vue';
import { getCustomOptionHeader } from '@/api/modules/bug-management'; import { getCustomOptionHeader, getPlatform } from '@/api/modules/bug-management';
import { planDetailBugPage } from '@/api/modules/test-plan/testPlan'; import { planDetailBugPage } from '@/api/modules/test-plan/testPlan';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { addCommasToNumber } from '@/utils'; import { addCommasToNumber } from '@/utils';
import { hasAnyPermission } from '@/utils/permission'; import { hasAnyPermission } from '@/utils/permission';
// import { BugManagementRouteEnum } from '@/enums/routeEnum';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
import { makeColumns } from '@/views/case-management/caseManagementFeature/components/utils'; import { makeColumns } from '@/views/case-management/caseManagementFeature/components/utils';
const props = defineProps<{
canEdit: boolean;
}>();
const emit = defineEmits<{
(e: 'refresh'): void;
}>();
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
// const router = useRouter();
const appStore = useAppStore(); const appStore = useAppStore();
const keyword = ref<string>(''); const keyword = ref<string>('');
@ -166,20 +179,27 @@
tableRef.value?.initColumn(columns.value); tableRef.value?.initColumn(columns.value);
} }
function toDetail(id: string) { const detailVisible = ref(false);
// eslint-disable-next-line no-console const activeDetailId = ref<string>('');
console.log('id', id); const currentPlatform = ref('Local');
// TODO: const handleShowDetail = async (id: string) => {
// window.open( activeDetailId.value = id;
// `${window.location.origin}#${ detailVisible.value = true;
// router.resolve({ name: BugManagementRouteEnum.BUG_MANAGEMENT_INDEX }).fullPath };
// }?id=${id}&orgId=${appStore.currentOrgId}&pId=${appStore.currentProjectId}` const setCurrentPlatform = async () => {
// ); const res = await getPlatform(appStore.currentProjectId);
currentPlatform.value = res;
};
function refresh() {
loadList();
emit('refresh');
} }
onBeforeMount(() => { onBeforeMount(() => {
initFilterOptions(); initFilterOptions();
getFetch(); getFetch();
setCurrentPlatform();
}); });
</script> </script>

View File

@ -107,7 +107,7 @@
:can-edit="detail.status !== 'ARCHIVED'" :can-edit="detail.status !== 'ARCHIVED'"
@refresh="initDetail" @refresh="initDetail"
/> />
<BugManagement v-if="activeTab === 'defectList'" /> <BugManagement v-if="activeTab === 'defectList'" :can-edit="detail.status !== 'ARCHIVED'" @refresh="initDetail" />
<ApiCase <ApiCase
v-if="activeTab === 'apiCase'" v-if="activeTab === 'apiCase'"
ref="apiCaseRef" ref="apiCaseRef"
@ -326,6 +326,9 @@
case 'featureCase': case 'featureCase':
const count = detail.value.functionalCaseCount ?? 0; const count = detail.value.functionalCaseCount ?? 0;
return `${count > 0 ? count : ''}`; return `${count > 0 ? count : ''}`;
case 'defectList':
const bugCount = detail.value.bugCount ?? 0;
return `${bugCount > 0 ? bugCount : ''}`;
case 'apiCase': case 'apiCase':
const apiCaseCount = detail.value?.apiCaseCount ?? 0; const apiCaseCount = detail.value?.apiCaseCount ?? 0;
return `${apiCaseCount > 0 ? apiCaseCount : ''}`; return `${apiCaseCount > 0 ? apiCaseCount : ''}`;