feat(测试计划): 测试计划详情用例列表新建缺陷(不包含快填)

This commit is contained in:
xinxin.wu 2024-08-30 18:22:12 +08:00 committed by Craftsman
parent 69b42bdecc
commit 1560478751
5 changed files with 83 additions and 30 deletions

View File

@ -90,6 +90,7 @@ import {
import { ApiCaseDetail, ApiDefinitionDetail } from '@/models/apiTest/management';
import type { ReportDetail, ReportStepDetail } from '@/models/apiTest/report';
import { BugEditFormObject } from '@/models/bug-management';
import { ReviewUserItem } from '@/models/caseManagement/caseReview';
import type { CaseManagementTable, CreateOrUpdateModule, UpdateModule } from '@/models/caseManagement/featureCase';
import type { CommonList, MoveModules, TableQueryParams } from '@/models/common';
@ -480,6 +481,6 @@ export function batchAssociatedBugToCase(data: TableQueryParams) {
return MSR.post({ url: BatchAssociatedBugToCaseUrl, data });
}
// 测试计划-详情-批量新建缺陷
export function batchAddBugToCase(data: TableQueryParams) {
return MSR.post({ url: BatchAddBugToCaseUrl, data });
export function batchAddBugToCase(data: { request: BugEditFormObject; fileList: File[] }) {
return MSR.uploadFile({ url: BatchAddBugToCaseUrl }, data, '', true);
}

View File

@ -49,6 +49,7 @@
import BugDetail from '@/views/bug-management/edit.vue';
import { createOrUpdateBug, getTemplateOption } from '@/api/modules/bug-management';
import { batchAddBugToCase } from '@/api/modules/test-plan/testPlan';
import { useI18n } from '@/hooks/useI18n';
import { useAppStore } from '@/store';
@ -64,11 +65,13 @@
const props = defineProps<{
bugId?: string;
extraParams?: Record<string, any>;
extraParams?: Record<string, any> | (() => Record<string, any>);
isBatch?: boolean;
}>();
const emit = defineEmits<{
(e: 'success'): void;
(e: 'save', params: { request: BugEditFormObject; fileList: File[] }): void;
}>();
const showBugDrawer = defineModel<boolean>('visible', {
@ -104,7 +107,6 @@
drawerLoading.value = false;
}
};
function handleDrawerCancel() {
bugDetailRef.value?.resetForm();
showBugDrawer.value = false;
@ -114,7 +116,13 @@
try {
drawerLoading.value = true;
const { request, fileList } = params;
if (props.isBatch) {
const extraParam =
props.extraParams && typeof props.extraParams === 'function' ? await props.extraParams() : props.extraParams;
await batchAddBugToCase({ request: { ...request, ...extraParam }, fileList });
} else {
await createOrUpdateBug({ request: { ...request, ...props.extraParams }, fileList });
}
Message.success(props.bugId ? t('common.updateSuccess') : t('common.createSuccess'));

View File

@ -109,20 +109,20 @@
:batch-move="batchMoveApiCase"
@load-list="resetCaseList"
/>
<!-- TODO 等待联调 -->
<!-- TODO 等待联调快填 -->
<AddDefectDrawer
v-model:visible="showCreateBugDrawer"
:extra-params="{ caseId: associatedCaseId, testPlanId: props.planId, testPlanCaseId }"
:extra-params="getApiBugParams"
:is-batch="isBatchAssociateOrCreate"
@success="refreshDetailAndList()"
/>
<!-- TODO 等待联调 -->
<LinkDefectDrawer
v-model:visible="showLinkBugDrawer"
:case-id="testPlanCaseId"
:load-api="AssociatedBugApiTypeEnum.API_BUG_LIST"
:is-batch="isBatchAssociate"
:is-batch="isBatchAssociateOrCreate"
:drawer-loading="drawerLoading"
:show-selector-all="!isBatchAssociate"
:show-selector-all="!isBatchAssociateOrCreate"
@save="saveApiBugHandler"
/>
</div>
@ -672,10 +672,10 @@
const testPlanCaseId = ref<string>();
const existedDefect = inject<Ref<number>>('existedDefect', ref(0));
const showCreateBugDrawer = ref<boolean>(false);
const isBatchAssociate = ref(false);
const isBatchAssociateOrCreate = ref(false);
//
function associateAndCreateDefect(isAssociate: boolean, isBatch: boolean, record?: PlanDetailApiCaseItem) {
isBatchAssociate.value = isBatch;
isBatchAssociateOrCreate.value = isBatch;
if (record) {
const { id, apiTestCaseId } = record;
associatedCaseId.value = apiTestCaseId;
@ -695,7 +695,7 @@
try {
drawerLoading.value = true;
const tableParams = await getTableParams(true);
if (isBatchAssociate.value) {
if (isBatchAssociateOrCreate.value) {
await batchAssociatedBugToCase({
selectIds: tableSelected.value as string[],
selectAll: batchParams.value.selectAll,
@ -726,6 +726,21 @@
}
}
async function getApiBugParams() {
if (isBatchAssociateOrCreate.value) {
const tableParams = await getTableParams(true);
return {
...tableParams,
projectId: appStore.currentProjectId,
selectIds: tableSelected.value as string[],
selectAll: batchParams.value.selectAll,
excludeIds: batchParams.value?.excludeIds || [],
testPlanId: props.planId,
};
}
return { caseId: associatedCaseId.value, testPlanId: props.planId, testPlanCaseId: testPlanCaseId.value };
}
//
const batchUpdateParams = ref();
const batchMoveModalVisible = ref(false);

View File

@ -109,20 +109,20 @@
@load-list="resetCaseList"
/>
<!-- TODO 等待联调 -->
<!-- TODO 等待联调快填 -->
<AddDefectDrawer
v-model:visible="showCreateBugDrawer"
:extra-params="{ caseId: associatedCaseId, testPlanId: props.planId, testPlanCaseId }"
:extra-params="getScenarioBugParams"
:is-batch="isBatchAssociateOrCreate"
@success="refreshListAndDetail()"
/>
<!-- TODO 等待联调 -->
<LinkDefectDrawer
v-model:visible="showLinkBugDrawer"
:case-id="testPlanCaseId"
:load-api="AssociatedBugApiTypeEnum.SCENARIO_BUG_LIST"
:is-batch="isBatchAssociate"
:is-batch="isBatchAssociateOrCreate"
:drawer-loading="drawerLoading"
:show-selector-all="!isBatchAssociate"
:show-selector-all="!isBatchAssociateOrCreate"
@save="saveScenarioBugHandler"
/>
</div>
@ -657,7 +657,7 @@
const batchMoveModalVisible = ref(false);
const existedDefect = inject<Ref<number>>('existedDefect', ref(0));
const isBatchAssociate = ref(false);
const isBatchAssociateOrCreate = ref(false);
const showLinkBugDrawer = ref<boolean>(false);
const associatedCaseId = ref<string>();
const testPlanCaseId = ref<string>();
@ -666,7 +666,7 @@
const drawerLoading = ref<boolean>(false);
//
function associateAndCreateDefect(isAssociate: boolean, isBatch: boolean, record?: PlanDetailApiScenarioItem) {
isBatchAssociate.value = isBatch;
isBatchAssociateOrCreate.value = isBatch;
if (record) {
const { id, apiScenarioId } = record;
associatedCaseId.value = apiScenarioId;
@ -684,7 +684,7 @@
try {
drawerLoading.value = true;
const tableParams = await getTableParams(true);
if (isBatchAssociate.value) {
if (isBatchAssociateOrCreate.value) {
await batchAssociatedBugToCase({
selectIds: tableSelected.value as string[],
selectAll: batchParams.value.selectAll,
@ -715,6 +715,21 @@
}
}
async function getScenarioBugParams() {
if (isBatchAssociateOrCreate.value) {
const tableParams = await getTableParams(true);
return {
...tableParams,
projectId: appStore.currentProjectId,
selectIds: tableSelected.value as string[],
selectAll: batchParams.value.selectAll,
excludeIds: batchParams.value?.excludeIds || [],
testPlanId: props.planId,
};
}
return { caseId: associatedCaseId.value, testPlanId: props.planId, testPlanCaseId: testPlanCaseId.value };
}
//
async function handleTableBatch(event: BatchActionParams, params: BatchActionQueryParams) {
tableSelected.value = params?.selectedIds || [];

View File

@ -174,21 +174,21 @@
:batch-move="batchMoveFeatureCase"
@load-list="resetCaseList"
/>
<!-- TODO 等待联调快填 -->
<!-- TODO 等待联调 -->
<AddDefectDrawer
v-model:visible="showCreateBugDrawer"
:extra-params="{ caseId: associatedCaseId, testPlanId: props.planId, testPlanCaseId }"
:extra-params="getBugParams"
:is-batch="isBatchAssociateOrCreate"
@success="refreshList()"
/>
<!-- TODO 等待联调 -->
<LinkDefectDrawer
v-model:visible="showLinkBugDrawer"
:case-id="testPlanCaseId"
:drawer-loading="drawerLoading"
:load-api="AssociatedBugApiTypeEnum.TEST_PLAN_BUG_LIST"
:show-selector-all="!isBatchAssociate"
:is-batch="isBatchAssociate"
:show-selector-all="!isBatchAssociateOrCreate"
:is-batch="isBatchAssociateOrCreate"
@save="saveFunctionBugHandler"
/>
</div>
@ -775,7 +775,6 @@
const batchLoading = ref(false);
const batchExecuteModalVisible = ref(false);
const batchExecuteForm = ref<ExecuteFeatureCaseFormParams>({ ...defaultExecuteForm });
async function handleBatchExecute() {
try {
batchLoading.value = true;
@ -807,14 +806,29 @@
const associatedCaseId = ref<string>();
const testPlanCaseId = ref<string>();
const drawerLoading = ref<boolean>(false);
const isBatchAssociate = ref(false);
const isBatchAssociateOrCreate = ref(false);
async function getBugParams() {
if (isBatchAssociateOrCreate.value) {
const tableParams = await getTableParams(true);
return {
...tableParams,
projectId: appStore.currentProjectId,
selectIds: tableSelected.value as string[],
selectAll: batchParams.value.selectAll,
excludeIds: batchParams.value?.excludeIds || [],
testPlanId: props.planId,
};
}
return { caseId: associatedCaseId.value, testPlanId: props.planId, testPlanCaseId: testPlanCaseId.value };
}
//
async function saveFunctionBugHandler(params: TableQueryParams) {
try {
drawerLoading.value = true;
const tableParams = await getTableParams(true);
if (isBatchAssociate.value) {
if (isBatchAssociateOrCreate.value) {
await batchAssociatedBugToCase({
selectIds: tableSelected.value as string[],
selectAll: batchParams.value.selectAll,
@ -854,7 +868,7 @@
// /
function associateAndCreateDefect(isAssociate: boolean, isBatch: boolean, record?: PlanDetailFeatureCaseItem) {
isBatchAssociate.value = isBatch;
isBatchAssociateOrCreate.value = isBatch;
if (record) {
const { id, caseId } = record;
associatedCaseId.value = caseId;