fix(接口测试): 回收站和场景-协议调整

This commit is contained in:
teukkk 2024-06-07 17:52:36 +08:00 committed by 刘瑞斌
parent 2ab3c8d2d5
commit dd6b5f8525
9 changed files with 92 additions and 52 deletions

View File

@ -100,8 +100,7 @@ export interface ApiDefinitionGetModuleParams {
filter?: Record<string, any>; filter?: Record<string, any>;
combine?: Record<string, any>; combine?: Record<string, any>;
moduleIds: string[]; moduleIds: string[];
protocols?: string[]; // TODO 协议 必填 protocols: string[];
protocol?: string; // TODO 协议 改完回收站删除这行
projectId: string; projectId: string;
versionId?: string; versionId?: string;
refId?: string; refId?: string;
@ -181,8 +180,7 @@ export interface mockParams {
} }
// 批量操作参数 // 批量操作参数
export interface ApiDefinitionBatchParams extends BatchApiParams { export interface ApiDefinitionBatchParams extends BatchApiParams {
protocols?: string[]; // TODO 协议 必填 protocols: string[];
protocol?: string; // TODO 协议 改完回收站删除这行
} }
// 批量更新定义参数 // 批量更新定义参数
export interface ApiDefinitionBatchUpdateParams extends ApiDefinitionBatchParams { export interface ApiDefinitionBatchUpdateParams extends ApiDefinitionBatchParams {
@ -281,7 +279,6 @@ export interface DefinitionReferencePageParams extends TableQueryParams {
export interface ApiDefinitionDeleteParams { export interface ApiDefinitionDeleteParams {
id: string; id: string;
projectId: string; projectId: string;
protocol: string;
deleteAll?: boolean; deleteAll?: boolean;
} }
@ -334,8 +331,7 @@ export interface ApiCaseDetail extends ExecuteRequestParams {
} }
// 批量操作参数 // 批量操作参数
export interface ApiCaseBatchParams extends BatchApiParams { export interface ApiCaseBatchParams extends BatchApiParams {
protocols?: string[]; // TODO 协议 必填 protocols: string[];
protocol?: string; // TODO 协议 改完回收站删除这行
apiDefinitionId?: string; apiDefinitionId?: string;
versionId?: string; versionId?: string;
} }

View File

@ -105,7 +105,7 @@
try { try {
apiModuleTree.value = await getModuleTreeOnlyModules({ apiModuleTree.value = await getModuleTreeOnlyModules({
keyword: '', keyword: '',
protocol, protocols: [protocol],
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: [], moduleIds: [],
}); });

View File

@ -9,10 +9,7 @@
/> />
<template v-if="!props.readOnly && !props.trash"> <template v-if="!props.readOnly && !props.trash">
<a-dropdown-button <a-dropdown-button
v-if=" v-if="hasAllPermission(['PROJECT_API_DEFINITION:READ+ADD', 'PROJECT_API_DEFINITION:READ+IMPORT'])"
selectedProtocols.includes('HTTP') &&
hasAllPermission(['PROJECT_API_DEFINITION:READ+ADD', 'PROJECT_API_DEFINITION:READ+IMPORT'])
"
type="primary" type="primary"
@click="handleSelect('newApi')" @click="handleSelect('newApi')"
> >
@ -28,7 +25,6 @@
</a-dropdown-button> </a-dropdown-button>
<a-button <a-button
v-else-if=" v-else-if="
selectedProtocols.includes('HTTP') &&
!hasAnyPermission(['PROJECT_API_DEFINITION:READ+ADD']) && !hasAnyPermission(['PROJECT_API_DEFINITION:READ+ADD']) &&
hasAnyPermission(['PROJECT_API_DEFINITION:READ+IMPORT']) hasAnyPermission(['PROJECT_API_DEFINITION:READ+IMPORT'])
" "

View File

@ -19,6 +19,7 @@
</div> </div>
</div> </div>
<ms-base-table <ms-base-table
ref="apiTableRef"
v-bind="propsRes" v-bind="propsRes"
:action-config="batchActions" :action-config="batchActions"
:first-column-width="44" :first-column-width="44"
@ -28,7 +29,7 @@
@selected-change="handleTableSelect" @selected-change="handleTableSelect"
@batch-action="handleTableBatch" @batch-action="handleTableBatch"
> >
<template v-if="props.protocol === 'HTTP'" #[FilterSlotNameEnum.API_TEST_API_REQUEST_METHODS]="{ filterContent }"> <template #[FilterSlotNameEnum.API_TEST_API_REQUEST_METHODS]="{ filterContent }">
<apiMethodName :method="filterContent.value" /> <apiMethodName :method="filterContent.value" />
</template> </template>
<template #[FilterSlotNameEnum.API_TEST_API_REQUEST_API_STATUS]="{ filterContent }"> <template #[FilterSlotNameEnum.API_TEST_API_REQUEST_API_STATUS]="{ filterContent }">
@ -50,6 +51,9 @@
<template #deleteUserName="{ record }"> <template #deleteUserName="{ record }">
<span type="text" class="px-0">{{ record.deleteUserName || '-' }}</span> <span type="text" class="px-0">{{ record.deleteUserName || '-' }}</span>
</template> </template>
<template #protocol="{ record }">
<apiMethodName :method="record.protocol" />
</template>
<template #method="{ record }"> <template #method="{ record }">
<apiMethodName :method="record.method" is-tag /> <apiMethodName :method="record.method" is-tag />
</template> </template>
@ -92,6 +96,7 @@
import apiStatus from '@/views/api-test/components/apiStatus.vue'; import apiStatus from '@/views/api-test/components/apiStatus.vue';
import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue'; import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue';
import { getProtocolList } from '@/api/modules/api-test/common';
import { import {
batchCleanOutDefinition, batchCleanOutDefinition,
batchRecoverDefinition, batchRecoverDefinition,
@ -105,6 +110,7 @@
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { characterLimit, operationWidth } from '@/utils'; import { characterLimit, operationWidth } from '@/utils';
import { ProtocolItem } from '@/models/apiTest/common';
import { import {
ApiDefinitionDetail, ApiDefinitionDetail,
ApiDefinitionGetModuleParams, ApiDefinitionGetModuleParams,
@ -112,13 +118,13 @@
} from '@/models/apiTest/management'; } from '@/models/apiTest/management';
import { RequestDefinitionStatus, RequestMethods } from '@/enums/apiEnum'; import { RequestDefinitionStatus, RequestMethods } from '@/enums/apiEnum';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
import {FilterSlotNameEnum} from "@/enums/tableFilterEnum"; import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
const props = defineProps<{ const props = defineProps<{
class?: string; class?: string;
activeModule: string; activeModule: string;
offspringIds: string[]; offspringIds: string[];
protocol: string; // selectedProtocols: string[];
readOnly?: boolean; // readOnly?: boolean; //
memberOptions: { label: string; value: string }[]; memberOptions: { label: string; value: string }[];
}>(); }>();
@ -132,13 +138,43 @@
const refreshModuleTree: (() => Promise<any>) | undefined = inject('refreshModuleTree'); const refreshModuleTree: (() => Promise<any>) | undefined = inject('refreshModuleTree');
const refreshModuleTreeCount: ((data: ApiDefinitionGetModuleParams) => Promise<any>) | undefined = const refreshModuleTreeCount: ((data: ApiDefinitionGetModuleParams) => Promise<any>) | undefined =
inject('refreshModuleTreeCount'); inject('refreshModuleTreeCount');
// TODO: store
const protocolList = ref<ProtocolItem[]>([]);
async function initProtocolList() {
try {
const res = await getProtocolList(appStore.currentOrgId);
protocolList.value = res.map((e) => ({
protocol: e.protocol,
polymorphicName: e.polymorphicName,
pluginId: e.pluginId,
}));
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
onBeforeMount(() => {
initProtocolList();
});
// TODO apiTest
const requestMethodsOptions = computed(() => { const requestMethodsOptions = computed(() => {
return Object.values(RequestMethods).map((e) => { const otherMethods = protocolList.value
.filter((e) => e.protocol !== 'HTTP')
.map((item) => {
return {
value: item.protocol,
key: item.protocol,
};
});
const httpMethods = Object.values(RequestMethods).map((e) => {
return { return {
value: e, value: e,
key: e, key: e,
}; };
}); });
return [...httpMethods, ...otherMethods];
}); });
const requestApiStatus = computed(() => { const requestApiStatus = computed(() => {
return Object.values(RequestDefinitionStatus).map((e) => { return Object.values(RequestDefinitionStatus).map((e) => {
@ -148,7 +184,7 @@
}; };
}); });
}); });
const columns: MsTableColumn = [ let columns: MsTableColumn = [
{ {
title: 'ID', title: 'ID',
dataIndex: 'num', dataIndex: 'num',
@ -176,6 +212,7 @@
{ {
title: 'apiTestManagement.protocol', title: 'apiTestManagement.protocol',
dataIndex: 'protocol', dataIndex: 'protocol',
slotName: 'protocol',
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
@ -309,7 +346,7 @@
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: props.activeModule === 'all' ? [] : queryModuleIds, moduleIds: props.activeModule === 'all' ? [] : queryModuleIds,
deleted: true, deleted: true,
protocol: props.protocol, protocols: props.selectedProtocols,
filter: { filter: {
status: statusFilters.value, status: statusFilters.value,
method: methodFilters.value, method: methodFilters.value,
@ -325,7 +362,7 @@
deleteUser: deleteUserFilters.value, deleteUser: deleteUserFilters.value,
}, },
moduleIds: [], moduleIds: [],
protocol: props.protocol, protocols: props.selectedProtocols,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
}); });
} }
@ -347,8 +384,9 @@
} }
); );
// onBeforeMount
watch( watch(
() => props.protocol, () => props.selectedProtocols,
() => { () => {
resetSelector(); resetSelector();
loadApiList(true); loadApiList(true);
@ -378,10 +416,6 @@
loadApiList(false); loadApiList(false);
} }
onBeforeMount(() => {
loadApiList(true);
});
const tableSelected = ref<(string | number)[]>([]); const tableSelected = ref<(string | number)[]>([]);
const batchParams = ref<BatchActionQueryParams>({ const batchParams = ref<BatchActionQueryParams>({
selectedIds: [], selectedIds: [],
@ -424,7 +458,7 @@
selectIds: batchParams.value.selectedIds as string[], selectIds: batchParams.value.selectedIds as string[],
moduleIds: props.activeModule === 'all' ? [] : queryModuleIds, moduleIds: props.activeModule === 'all' ? [] : queryModuleIds,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
protocol: props.protocol, protocols: props.selectedProtocols,
condition: { condition: {
keyword: keyword.value, keyword: keyword.value,
filter: { filter: {
@ -535,7 +569,6 @@
await recoverDefinition({ await recoverDefinition({
id: record.id, id: record.id,
projectId: record.projectId, projectId: record.projectId,
protocol: props.protocol,
}); });
Message.success(t('apiTestManagement.recycle.recoveredSuccessfully')); Message.success(t('apiTestManagement.recycle.recoveredSuccessfully'));
resetSelector(); resetSelector();
@ -552,7 +585,31 @@
loadApiList, loadApiList,
}); });
function initFilterColumn() {
columns = columns.map((item) => {
if (item.dataIndex === 'method') {
return {
...item,
filterConfig: {
...item.filterConfig,
options: requestMethodsOptions.value,
},
};
}
return item;
});
}
await initFilterColumn();
await tableStore.initColumn(TableKeyEnum.API_TEST, columns, 'drawer', true); await tableStore.initColumn(TableKeyEnum.API_TEST, columns, 'drawer', true);
const apiTableRef = ref();
watch(
() => requestMethodsOptions.value,
() => {
initFilterColumn();
apiTableRef.value.initColumn(columns);
}
);
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -38,6 +38,9 @@
<template #[FilterSlotNameEnum.API_TEST_CASE_API_STATUS]="{ filterContent }"> <template #[FilterSlotNameEnum.API_TEST_CASE_API_STATUS]="{ filterContent }">
<apiStatus :status="filterContent.value" /> <apiStatus :status="filterContent.value" />
</template> </template>
<template #protocol="{ record }">
<apiMethodName :method="record.protocol" />
</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>
@ -102,6 +105,7 @@
import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type'; import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
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 apiStatus from '@/views/api-test/components/apiStatus.vue'; import apiStatus from '@/views/api-test/components/apiStatus.vue';
import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue'; import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue';
@ -128,7 +132,7 @@
const props = defineProps<{ const props = defineProps<{
activeModule: string; activeModule: string;
offspringIds: string[]; offspringIds: string[];
protocol: string; // selectedProtocols: string[];
memberOptions: { label: string; value: string }[]; memberOptions: { label: string; value: string }[];
}>(); }>();
@ -184,6 +188,7 @@
{ {
title: 'apiTestManagement.protocol', title: 'apiTestManagement.protocol',
dataIndex: 'protocol', dataIndex: 'protocol',
slotName: 'protocol',
showTooltip: true, showTooltip: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
@ -380,7 +385,7 @@
keyword: keyword.value, keyword: keyword.value,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: moduleIds.value, moduleIds: moduleIds.value,
protocol: props.protocol, protocols: props.selectedProtocols,
}; };
setLoadListParams(params); setLoadListParams(params);
loadList(); loadList();
@ -390,19 +395,9 @@
loadCaseList(); loadCaseList();
} }
watch( watch([() => props.activeModule, () => props.selectedProtocols], () => {
() => props.activeModule,
() => {
loadCaseListAndResetSelector(); loadCaseListAndResetSelector();
} });
);
watch(
() => props.protocol,
() => {
loadCaseListAndResetSelector();
}
);
const tableSelected = ref<(string | number)[]>([]); // const tableSelected = ref<(string | number)[]>([]); //
const batchParams = ref<BatchActionQueryParams>({ const batchParams = ref<BatchActionQueryParams>({
@ -469,7 +464,7 @@
selectIds: batchParams.value.selectedIds as string[], selectIds: batchParams.value.selectedIds as string[],
moduleIds: moduleIds.value, moduleIds: moduleIds.value,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
protocol: props.protocol, protocols: props.selectedProtocols,
condition: { condition: {
keyword: keyword.value, keyword: keyword.value,
filter: propsRes.value.filter, filter: propsRes.value.filter,

View File

@ -21,7 +21,6 @@
</template> </template>
</MsEditableTab> </MsEditableTab>
</div> </div>
<!-- TODO 协议 -->
<api <api
v-show="currentTab === 'api'" v-show="currentTab === 'api'"
ref="apiRef" ref="apiRef"
@ -29,15 +28,14 @@
:module-tree="props.moduleTree" :module-tree="props.moduleTree"
:active-module="props.activeModule" :active-module="props.activeModule"
:offspring-ids="props.offspringIds" :offspring-ids="props.offspringIds"
:protocol="props.selectedProtocols[0]" :selected-protocols="props.selectedProtocols"
/> />
<!-- TODO 协议 -->
<api-case <api-case
v-show="currentTab === 'case'" v-show="currentTab === 'case'"
:member-options="memberOptions" :member-options="memberOptions"
:active-module="props.activeModule" :active-module="props.activeModule"
:offspring-ids="props.offspringIds" :offspring-ids="props.offspringIds"
:protocol="props.selectedProtocols[0]" :selected-protocols="props.selectedProtocols"
></api-case> ></api-case>
</template> </template>

View File

@ -121,7 +121,7 @@
loading.value = true; loading.value = true;
const params = { const params = {
keyword: moduleKeyword.value, keyword: moduleKeyword.value,
protocol: props.protocol, protocols: [props.protocol],
projectId: props.projectId, projectId: props.projectId,
moduleIds: [], moduleIds: [],
}; };
@ -144,7 +144,7 @@
try { try {
const params = { const params = {
keyword: moduleKeyword.value, keyword: moduleKeyword.value,
protocol: props.protocol, protocols: [props.protocol],
projectId: props.projectId, projectId: props.projectId,
moduleIds: [], moduleIds: [],
}; };

View File

@ -483,7 +483,7 @@
keyword: keyword.value, keyword: keyword.value,
projectId: props.projectId, projectId: props.projectId,
moduleIds: ids || props.moduleIds, moduleIds: ids || props.moduleIds,
protocol: props.protocol, protocols: [props.protocol],
filter: { filter: {
status: statusFilters.value, status: statusFilters.value,
method: methodFilters.value, method: methodFilters.value,

View File

@ -462,12 +462,10 @@
// //
loadCaseDetail(); loadCaseDetail();
loadCaseList(); loadCaseList();
// TODO
} }
} else { } else {
// //
loadCase(); loadCase();
// TODO
} }
} }