feat(测试计划): 接口/用例列表缺陷count按钮组件

This commit is contained in:
xinxin.wu 2024-08-22 17:02:04 +08:00 committed by Craftsman
parent 01a912b399
commit 8992c63585
6 changed files with 139 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<a-popover position="br" content-class="case-count-popover"> <a-popover position="br" content-class="case-count-popover">
<div class="one-line-text cursor-pointer px-0 text-[rgb(var(--primary-5))]">{{ props.caseItem.bugCount ?? 0 }}</div> <div class="one-line-text cursor-pointer px-0 text-[rgb(var(--primary-5))]">{{ props.bugCount ?? 0 }}</div>
<template #content> <template #content>
<div class="w-[500px]"> <div class="w-[500px]">
<MsBaseTable ref="tableRef" v-bind="propsRes" v-on="propsEvent"> <MsBaseTable ref="tableRef" v-bind="propsRes" v-on="propsEvent">
@ -26,12 +26,13 @@
import { testPlanCancelBug } from '@/api/modules/test-plan/testPlan'; import { testPlanCancelBug } from '@/api/modules/test-plan/testPlan';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import type { PlanDetailFeatureCaseItem } from '@/models/testPlan/testPlan'; import type { CaseBugItem } from '@/models/testPlan/testPlan';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
const props = defineProps<{ const props = defineProps<{
caseItem: PlanDetailFeatureCaseItem; bugList?: CaseBugItem[]; //
canEdit: boolean; canEdit: boolean;
bugCount: number;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -69,7 +70,7 @@
}, },
]), ]),
]); ]);
const tableProps = ref<Partial<MsTableProps<PlanDetailFeatureCaseItem>>>({ const tableProps = ref<Partial<MsTableProps<CaseBugItem[]>>>({
columns: columns.value, columns: columns.value,
size: 'mini', size: 'mini',
tableKey: TableKeyEnum.TEST_PLAN_DETAIL_CASE_TABLE_BUG_COUNT, tableKey: TableKeyEnum.TEST_PLAN_DETAIL_CASE_TABLE_BUG_COUNT,
@ -81,7 +82,7 @@
const { propsRes, propsEvent, setLoading } = useTable(undefined, tableProps.value); const { propsRes, propsEvent, setLoading } = useTable(undefined, tableProps.value);
watchEffect(() => { watchEffect(() => {
propsRes.value.data = props.caseItem.bugList; propsRes.value.data = props.bugList || [];
}); });
// //

View File

@ -0,0 +1,78 @@
<template>
<div class="flex items-center">
<BugCountPopover :bug-list="bugList || []" :bug-count="bugCount" :can-edit="props.canEdit" @load-list="loadList" />
<a-dropdown
v-if="hasAllPermission(['PROJECT_BUG:READ', ...(props.linkBugPermission || [])])"
position="bl"
@select="handleSelect"
>
<a-button
v-permission="['PROJECT_BUG:READ+ADD']"
class="arco-btn-outline--secondary ml-[8px] !p-[4px]"
type="outline"
size="small"
>
<icon-plus class="text-[14px]" />
</a-button>
<template #content>
<a-doption v-if="hasAnyPermission(props.linkBugPermission || []) && props.bugCount" value="linkBug">
{{ t('caseManagement.featureCase.linkDefect') }}
</a-doption>
<a-doption v-if="hasAnyPermission(['PROJECT_BUG:READ+ADD'])" value="newBug">
{{ t('testPlan.featureCase.noBugDataNewBug') }}
</a-doption>
</template>
</a-dropdown>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import BugCountPopover from './bugCountPopover.vue';
import { useI18n } from '@/hooks/useI18n';
import { hasAllPermission, hasAnyPermission } from '@/utils/permission';
import type { CaseBugItem } from '@/models/testPlan/testPlan';
const { t } = useI18n();
const props = defineProps<{
resourceId: string; // id: id/id/id
bugCount: number; //
canEdit: boolean;
bugList?: CaseBugItem[];
linkBugPermission?: string[];
}>();
const emit = defineEmits<{
(e: 'associated'): void;
(e: 'create'): void;
(e: 'loadList'): void;
}>();
function handleSelect(value: string | number | Record<string, any> | undefined) {
switch (value) {
case 'newBug':
emit('create');
break;
default:
emit('associated');
break;
}
}
function loadList() {
emit('loadList');
}
</script>
<style scoped lang="less">
:deep(.arco-btn-outline--secondary) {
&:hover {
border-color: rgb(var(--primary-5)) !important;
}
}
</style>

View File

@ -164,6 +164,14 @@ export interface TestPlanBaseParams {
triggerMode?: string; triggerMode?: string;
} }
export interface CaseBugItem {
bugId: string;
id: string;
title: string;
type: string;
caseId: string;
}
export interface PlanDetailFeatureCaseItem { export interface PlanDetailFeatureCaseItem {
id: string; id: string;
num: string; num: string;
@ -182,13 +190,7 @@ export interface PlanDetailFeatureCaseItem {
caseId: string; caseId: string;
testPlanId: string; testPlanId: string;
testPlanCollectionName: string; // 测试集名称 testPlanCollectionName: string; // 测试集名称
bugList: { bugList: CaseBugItem[];
bugId: string;
id: string;
title: string;
type: string;
caseId: string;
}[];
} }
export interface PlanDetailFeatureCaseListQueryParams extends TableQueryParams, TestPlanBaseParams {} export interface PlanDetailFeatureCaseListQueryParams extends TableQueryParams, TestPlanBaseParams {}

View File

@ -37,6 +37,14 @@
<template #caseLevel="{ record }"> <template #caseLevel="{ record }">
<CaseLevel :case-level="record.priority" /> <CaseLevel :case-level="record.priority" />
</template> </template>
<template #bugCount="{ record }">
<MsBugOperation
:can-edit="props.canEdit"
:bug-list="record.bugList"
:resource-id="record.id"
:bug-count="record.bugCount || 0"
/>
</template>
<template #[FilterSlotNameEnum.API_TEST_CASE_API_LAST_EXECUTE_STATUS]="{ filterContent }"> <template #[FilterSlotNameEnum.API_TEST_CASE_API_LAST_EXECUTE_STATUS]="{ filterContent }">
<ExecutionStatus :module-type="ReportEnum.API_REPORT" :status="filterContent.value" /> <ExecutionStatus :module-type="ReportEnum.API_REPORT" :status="filterContent.value" />
</template> </template>
@ -114,6 +122,7 @@
MsTableProps, MsTableProps,
} from '@/components/pure/ms-table/type'; } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import MsBugOperation from '@/components/business/ms-bug-operation/index.vue';
import CaseLevel from '@/components/business/ms-case-associate/caseLevel.vue'; import CaseLevel from '@/components/business/ms-case-associate/caseLevel.vue';
import ApiMethodName from '@/views/api-test/components/apiMethodName.vue'; import ApiMethodName from '@/views/api-test/components/apiMethodName.vue';
import apiStatus from '@/views/api-test/components/apiStatus.vue'; import apiStatus from '@/views/api-test/components/apiStatus.vue';
@ -246,6 +255,14 @@
width: 200, width: 200,
showDrag: true, showDrag: true,
}, },
{
title: 'testPlan.featureCase.bugCount',
dataIndex: 'bugCount',
slotName: 'bugCount',
width: 150,
showDrag: true,
showInTable: true,
},
{ {
title: 'case.caseLevel', title: 'case.caseLevel',
dataIndex: 'priority', dataIndex: 'priority',
@ -638,6 +655,11 @@
} }
} }
const showLinkDrawer = ref(false);
const showCreateDrawer = ref(false);
const drawerLoading = ref(false);
// //
function toDetail(record: PlanDetailApiCaseItem) { function toDetail(record: PlanDetailApiCaseItem) {
openNewPage(ApiTestRouteEnum.API_TEST_MANAGEMENT, { openNewPage(ApiTestRouteEnum.API_TEST_MANAGEMENT, {

View File

@ -49,6 +49,14 @@
<template #status="{ record }"> <template #status="{ record }">
<apiStatus :status="record.status" /> <apiStatus :status="record.status" />
</template> </template>
<template #bugCount="{ record }">
<MsBugOperation
:can-edit="props.canEdit"
:bug-list="record.bugList"
:resource-id="record.id"
:bug-count="record.bugCount || 0"
/>
</template>
<template v-if="props.canEdit" #operation="{ record }"> <template v-if="props.canEdit" #operation="{ record }">
<MsButton <MsButton
v-permission="['PROJECT_TEST_PLAN:READ+EXECUTE']" v-permission="['PROJECT_TEST_PLAN:READ+EXECUTE']"
@ -113,6 +121,7 @@
MsTableProps, MsTableProps,
} from '@/components/pure/ms-table/type'; } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import MsBugOperation from '@/components/business/ms-bug-operation/index.vue';
import CaseLevel from '@/components/business/ms-case-associate/caseLevel.vue'; import CaseLevel from '@/components/business/ms-case-associate/caseLevel.vue';
import apiStatus from '@/views/api-test/components/apiStatus.vue'; import apiStatus from '@/views/api-test/components/apiStatus.vue';
import CaseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue'; import CaseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue';
@ -273,6 +282,14 @@
width: 200, width: 200,
showDrag: true, showDrag: true,
}, },
{
title: 'testPlan.featureCase.bugCount',
dataIndex: 'bugCount',
slotName: 'bugCount',
width: 150,
showDrag: true,
showInTable: true,
},
{ {
title: 'common.belongProject', title: 'common.belongProject',
dataIndex: 'projectName', dataIndex: 'projectName',

View File

@ -77,7 +77,12 @@
</span> </span>
</template> </template>
<template #bugCount="{ record }"> <template #bugCount="{ record }">
<BugCountPopover :case-item="record" :can-edit="props.canEdit" @load-list="loadList" /> <BugCountPopover
:bug-list="record.bugList"
:bug-count="record.bugCount"
:can-edit="props.canEdit"
@load-list="loadList"
/>
</template> </template>
<template v-if="props.canEdit" #operation="{ record }"> <template v-if="props.canEdit" #operation="{ record }">
<MsButton <MsButton
@ -183,11 +188,11 @@
MsTableProps, MsTableProps,
} from '@/components/pure/ms-table/type'; } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import BugCountPopover from '@/components/business/ms-bug-operation/bugCountPopover.vue';
import CaseLevel from '@/components/business/ms-case-associate/caseLevel.vue'; import CaseLevel from '@/components/business/ms-case-associate/caseLevel.vue';
import ExecuteResult from '@/components/business/ms-case-associate/executeResult.vue'; import ExecuteResult from '@/components/business/ms-case-associate/executeResult.vue';
import { getMinderOperationParams } from '@/components/business/ms-minders/caseReviewMinder/utils'; import { getMinderOperationParams } from '@/components/business/ms-minders/caseReviewMinder/utils';
import MsTestPlanFeatureCaseMinder from '@/components/business/ms-minders/testPlanFeatureCaseMinder/index.vue'; import MsTestPlanFeatureCaseMinder from '@/components/business/ms-minders/testPlanFeatureCaseMinder/index.vue';
import BugCountPopover from './bugCountPopover.vue';
import BatchApiMoveModal from '@/views/test-plan/testPlan/components/batchApiMoveModal.vue'; import BatchApiMoveModal from '@/views/test-plan/testPlan/components/batchApiMoveModal.vue';
import BatchUpdateExecutorModal from '@/views/test-plan/testPlan/components/batchUpdateExecutorModal.vue'; import BatchUpdateExecutorModal from '@/views/test-plan/testPlan/components/batchUpdateExecutorModal.vue';
import ExecuteForm from '@/views/test-plan/testPlan/detail/featureCase/components/executeForm.vue'; import ExecuteForm from '@/views/test-plan/testPlan/detail/featureCase/components/executeForm.vue';