fix(接口测试): 修复接口场景显示子模块资源时批量查询有误的问题

--bug=1039945 --user=宋天阳 https://www.tapd.cn/55049933/s/1506768
This commit is contained in:
Jianguo-Genius 2024-04-23 16:14:45 +08:00 committed by Craftsman
parent ff16b3b801
commit 33aea96d91
2 changed files with 53 additions and 31 deletions

View File

@ -1,3 +1,4 @@
import { BatchActionQueryParams } from '@/components/pure/ms-table/type';
import type { CaseLevel } from '@/components/business/ms-case-associate/types'; import type { CaseLevel } from '@/components/business/ms-case-associate/types';
import { ApiDefinitionCustomField, ApiRunModeRequest } from '@/models/apiTest/management'; import { ApiDefinitionCustomField, ApiRunModeRequest } from '@/models/apiTest/management';
@ -174,6 +175,10 @@ export interface ExecutePageParams extends TableQueryParams {
id: string; id: string;
} }
export interface ApiScenarioBatchParam extends BatchActionQueryParams {
moduleIds: string[];
}
// 场景-执行历史-请求参数 // 场景-执行历史-请求参数
export interface ExecuteHistoryItem { export interface ExecuteHistoryItem {
id: string; id: string;

View File

@ -435,7 +435,7 @@
<div class="text-[var(--color-text-4)]"> <div class="text-[var(--color-text-4)]">
{{ {{
t('api_scenario.table.batchModalSubTitle', { t('api_scenario.table.batchModalSubTitle', {
count: batchParams.currentSelectCount || tableSelected.length, count: batchParams?.currentSelectCount || tableSelected.length,
}) })
}} }}
</div> </div>
@ -586,7 +586,7 @@
</a-modal> </a-modal>
<batch-run-modal <batch-run-modal
v-model:visible="showBatchExecute" v-model:visible="showBatchExecute"
:batch-condition-params="batchConditionParams" :batch-condition-params="batchOptionParams"
:batch-params="batchParams" :batch-params="batchParams"
:table-selected="tableSelected" :table-selected="tableSelected"
:batch-run-func="batchRunScenario" :batch-run-func="batchRunScenario"
@ -639,8 +639,14 @@
import { hasAnyPermission } from '@/utils/permission'; import { hasAnyPermission } from '@/utils/permission';
import { Environment } from '@/models/apiTest/management'; import { Environment } from '@/models/apiTest/management';
import { ApiScenarioScheduleConfig, ApiScenarioTableItem, ApiScenarioUpdateDTO } from '@/models/apiTest/scenario'; import {
import { DragSortParams } from '@/models/common'; ApiScenarioBatchParam,
ApiScenarioBatchParams,
ApiScenarioScheduleConfig,
ApiScenarioTableItem,
ApiScenarioUpdateDTO,
} from '@/models/apiTest/scenario';
import { DragSortParams, type TableQueryParams } from '@/models/common';
import { ResourcePoolItem } from '@/models/setting/resourcePool'; import { ResourcePoolItem } from '@/models/setting/resourcePool';
import { ApiScenarioStatus } from '@/enums/apiEnum'; import { ApiScenarioStatus } from '@/enums/apiEnum';
import { ReportEnum, ReportStatus } from '@/enums/reportEnum'; import { ReportEnum, ReportStatus } from '@/enums/reportEnum';
@ -984,19 +990,6 @@
return props.activeModule === 'all' ? [] : [props.activeModule]; return props.activeModule === 'all' ? [] : [props.activeModule];
}); });
const batchConditionParams = computed(() => {
return {
condition: {
keyword: keyword.value,
filter: {
status: statusFilters.value,
},
},
projectId: appStore.currentProjectId,
moduleIds: activeModules.value,
};
});
async function loadScenarioList(refreshTreeCount?: boolean) { async function loadScenarioList(refreshTreeCount?: boolean) {
let moduleIds: string[] = []; let moduleIds: string[] = [];
if (props.activeModule && props.activeModule !== 'all') { if (props.activeModule && props.activeModule !== 'all') {
@ -1076,17 +1069,19 @@
const tableSelected = ref<(string | number)[]>([]); const tableSelected = ref<(string | number)[]>([]);
const batchParams = ref<BatchActionQueryParams>({ const batchParams = ref<ApiScenarioBatchParam>();
selectedIds: [],
const batchOptionParams = ref<ApiScenarioBatchParams>({
projectId: appStore.currentProjectId,
selectIds: [],
selectAll: false, selectAll: false,
excludeIds: [], condition: {},
currentSelectCount: 0,
}); });
/** /**
* 删除接口 * 删除接口
*/ */
function deleteScenario(record?: ApiScenarioTableItem, isBatch?: boolean, params?: BatchActionQueryParams) { function deleteScenario(record?: ApiScenarioTableItem, isBatch?: boolean, params?: ApiScenarioBatchParam) {
let title = t('api_scenario.table.deleteScenarioTipTitle', { name: record?.name }); let title = t('api_scenario.table.deleteScenarioTipTitle', { name: record?.name });
let selectIds = [record?.id || '']; let selectIds = [record?.id || ''];
if (isBatch) { if (isBatch) {
@ -1125,7 +1120,7 @@
excludeIds: params?.excludeIds || [], excludeIds: params?.excludeIds || [],
condition: { ...params?.condition, keyword: keyword.value }, condition: { ...params?.condition, keyword: keyword.value },
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: props.activeModule === 'all' ? [] : [props.activeModule], moduleIds: params?.moduleIds || [],
deleteAll: true, deleteAll: true,
}); });
} else { } else {
@ -1333,8 +1328,6 @@
try { try {
batchUpdateLoading.value = true; batchUpdateLoading.value = true;
// value: 'PRIORITY',
// value: 'STATUS',
const batchEditParam = { const batchEditParam = {
selectIds: batchParams.value?.selectedIds || [], selectIds: batchParams.value?.selectedIds || [],
selectAll: !!batchParams.value?.selectAll, selectAll: !!batchParams.value?.selectAll,
@ -1350,7 +1343,7 @@
}, },
}, },
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: props.activeModule === 'all' ? [] : [props.activeModule], moduleIds: batchParams.value?.moduleIds || [],
type: batchForm.value?.attr, type: batchForm.value?.attr,
priority: '', priority: '',
status: '', status: '',
@ -1419,7 +1412,7 @@
}, },
}, },
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: props.activeModule === 'all' ? [] : [props.activeModule], moduleIds: batchParams.value?.moduleIds || [],
targetModuleId: selectedBatchOptModuleKey.value, targetModuleId: selectedBatchOptModuleKey.value,
}); });
@ -1466,9 +1459,19 @@
* 处理表格选中后批量操作 * 处理表格选中后批量操作
* @param event 批量操作事件对象 * @param event 批量操作事件对象
*/ */
function handleTableBatch(event: BatchActionParams, params: BatchActionQueryParams) { async function handleTableBatch(event: BatchActionParams, params: BatchActionQueryParams) {
batchParams.value = params;
tableSelected.value = params?.selectedIds || []; tableSelected.value = params?.selectedIds || [];
//
let moduleIds: string[] = [];
const getAllChildren = await tableStore.getSubShow(TableKeyEnum.API_SCENARIO);
if (getAllChildren) {
moduleIds = [props.activeModule, ...props.offspringIds];
} else {
moduleIds = [props.activeModule];
}
batchParams.value = { ...params, moduleIds: [] };
batchParams.value.moduleIds = moduleIds;
const filterParams = { const filterParams = {
lastReportStatus: lastReportStatusListFilters.value, lastReportStatus: lastReportStatusListFilters.value,
status: statusFilters.value, status: statusFilters.value,
@ -1478,10 +1481,10 @@
}; };
if (batchParams.value.condition) { if (batchParams.value.condition) {
batchParams.value.condition.filter = { ...filterParams }; batchParams.value.condition.filter = { ...filterParams };
batchParams.value.condition.keyword = keyword.value;
} else { } else {
batchParams.value.condition = { filter: { ...filterParams } }; batchParams.value.condition = { filter: { ...filterParams }, keyword: keyword.value };
} }
switch (event.eventTag) { switch (event.eventTag) {
case 'delete': case 'delete':
deleteScenario(undefined, true, batchParams.value); deleteScenario(undefined, true, batchParams.value);
@ -1507,6 +1510,20 @@
moveModalVisible.value = true; moveModalVisible.value = true;
break; break;
case 'execute': case 'execute':
batchOptionParams.value = {
projectId: appStore.currentProjectId,
selectIds: [],
selectAll: false,
condition: {},
};
//
batchOptionParams.value.selectAll = params.selectAll;
batchOptionParams.value.excludeIds = params.excludeIds;
batchOptionParams.value.selectIds = params.selectedIds?.length ? params.selectedIds : [];
batchOptionParams.value.moduleIds = moduleIds;
batchOptionParams.value.condition = batchParams.value?.condition || {};
showBatchExecute.value = true; showBatchExecute.value = true;
break; break;
default: default: