feat(项目管理): 文件管理和接口定义表格支持是否显示子目录数据

This commit is contained in:
song-tianyang 2024-03-21 15:12:15 +08:00 committed by 刘瑞斌
parent 4e8b71f853
commit 3d0a99adef
8 changed files with 72 additions and 30 deletions

View File

@ -188,7 +188,7 @@
} }
}); });
tableStore.getSubShow(props.tableKey).then((res) => { tableStore.getSubShow(props.tableKey).then((res) => {
subdirectoryVal.value = res || true; subdirectoryVal.value = res === undefined ? true : res;
}); });
tableStore.getPageSize(props.tableKey).then((res) => { tableStore.getPageSize(props.tableKey).then((res) => {
pageSize.value = res; pageSize.value = res;

View File

@ -27,6 +27,7 @@
@selected-change="handleTableSelect" @selected-change="handleTableSelect"
@batch-action="handleTableBatch" @batch-action="handleTableBatch"
@drag-change="handleTableDragSort" @drag-change="handleTableDragSort"
@module-change="loadApiList"
> >
<template v-if="props.protocol === 'HTTP'" #methodFilter="{ columnConfig }"> <template v-if="props.protocol === 'HTTP'" #methodFilter="{ columnConfig }">
<a-trigger <a-trigger
@ -448,17 +449,26 @@
const methodFilters = ref(Object.keys(RequestMethods)); const methodFilters = ref(Object.keys(RequestMethods));
const statusFilterVisible = ref(false); const statusFilterVisible = ref(false);
const statusFilters = ref(Object.keys(RequestDefinitionStatus)); const statusFilters = ref(Object.keys(RequestDefinitionStatus));
const moduleIds = computed(() => {
if (props.activeModule === 'all') { const tableStore = useTableStore();
return []; async function getModuleIds() {
let moduleIds: string[] = [];
if (props.activeModule !== 'all') {
moduleIds = [props.activeModule];
const getAllChildren = await tableStore.getSubShow(TableKeyEnum.API_TEST);
if (getAllChildren) {
moduleIds = [props.activeModule, ...props.offspringIds];
}
} }
return [props.activeModule]; return moduleIds;
}); }
function loadApiList() { async function loadApiList() {
const moduleIds = await getModuleIds();
const params = { const params = {
keyword: keyword.value, keyword: keyword.value,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: moduleIds.value, moduleIds,
protocol: props.protocol, protocol: props.protocol,
filter: { filter: {
status: status:
@ -561,7 +571,7 @@
excludeIds: params?.excludeIds || [], excludeIds: params?.excludeIds || [],
condition: { keyword: keyword.value }, condition: { keyword: keyword.value },
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: props.activeModule === 'all' ? [] : [props.activeModule], moduleIds: await getModuleIds(),
deleteAll: true, deleteAll: true,
protocol: props.protocol, protocol: props.protocol,
}); });
@ -679,7 +689,7 @@
excludeIds: batchParams.value?.excludeIds || [], excludeIds: batchParams.value?.excludeIds || [],
condition: { keyword: keyword.value }, condition: { keyword: keyword.value },
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: props.activeModule === 'all' ? [] : [props.activeModule], moduleIds: await getModuleIds(),
protocol: props.protocol, protocol: props.protocol,
type: batchForm.value.attr, type: batchForm.value.attr,
[batchForm.value.attr]: batchForm.value.attr === 'tags' ? batchForm.value.values : batchForm.value.value, [batchForm.value.attr]: batchForm.value.attr === 'tags' ? batchForm.value.values : batchForm.value.value,
@ -716,7 +726,7 @@
excludeIds: batchParams.value?.excludeIds || [], excludeIds: batchParams.value?.excludeIds || [],
condition: { keyword: keyword.value }, condition: { keyword: keyword.value },
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: props.activeModule === 'all' ? [] : [props.activeModule], moduleIds: await getModuleIds(),
moduleId: selectedModuleKeys.value[0], moduleId: selectedModuleKeys.value[0],
protocol: props.protocol, protocol: props.protocol,
}); });
@ -805,7 +815,6 @@
}); });
if (!props.readOnly) { if (!props.readOnly) {
const tableStore = useTableStore();
await tableStore.initColumn(TableKeyEnum.API_TEST, columns, 'drawer', true); await tableStore.initColumn(TableKeyEnum.API_TEST, columns, 'drawer', true);
} else { } else {
columns = columns.filter( columns = columns.filter(

View File

@ -56,6 +56,7 @@
:active-module="props.activeModule" :active-module="props.activeModule"
:protocol="activeApiTab.protocol" :protocol="activeApiTab.protocol"
:api-detail="activeApiTab" :api-detail="activeApiTab"
:offspring-ids="props.offspringIds"
/> />
</a-tab-pane> </a-tab-pane>
<!-- <a-tab-pane v-if="!activeApiTab.isNew" key="mock" title="MOCK" class="ms-api-tab-pane"> </a-tab-pane> --> <!-- <a-tab-pane v-if="!activeApiTab.isNew" key="mock" title="MOCK" class="ms-api-tab-pane"> </a-tab-pane> -->

View File

@ -35,6 +35,7 @@
@selected-change="handleTableSelect" @selected-change="handleTableSelect"
@batch-action="handleTableBatch" @batch-action="handleTableBatch"
@drag-change="handleDragChange" @drag-change="handleDragChange"
@module-change="loadCaseList"
> >
<template #num="{ record }"> <template #num="{ record }">
<MsButton type="text" @click="isApi ? openCaseDetailDrawer(record.id) : openCaseTab(record)">{{ <MsButton type="text" @click="isApi ? openCaseDetailDrawer(record.id) : openCaseTab(record)">{{
@ -414,6 +415,7 @@
activeModule: string; activeModule: string;
protocol: string; // protocol: string; //
apiDetail?: RequestParam; apiDetail?: RequestParam;
offspringIds: string[];
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -617,15 +619,25 @@
const resourcePoolList = ref<ResourcePoolItem[]>(); const resourcePoolList = ref<ResourcePoolItem[]>();
const defaultPoolId = ref<string>(); const defaultPoolId = ref<string>();
const moduleIds = computed(() => { async function getModuleIds() {
return props.activeModule === 'all' ? [] : [props.activeModule]; let moduleIds: string[] = [];
}); if (props.activeModule !== 'all') {
function loadCaseList() { moduleIds = [props.activeModule];
const getAllChildren = await tableStore.getSubShow(TableKeyEnum.API_TEST_MANAGEMENT_CASE);
if (getAllChildren) {
moduleIds = [props.activeModule, ...props.offspringIds];
}
}
return moduleIds;
}
async function loadCaseList() {
const selectModules = await getModuleIds();
const params = { const params = {
apiDefinitionId: props.apiDetail?.id, apiDefinitionId: props.apiDetail?.id,
keyword: keyword.value, keyword: keyword.value,
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
moduleIds: moduleIds.value, moduleIds: selectModules,
protocol: props.protocol, protocol: props.protocol,
filter: { filter: {
status: statusFilters.value, status: statusFilters.value,
@ -734,7 +746,9 @@
excludeIds: [], excludeIds: [],
currentSelectCount: 0, currentSelectCount: 0,
}); });
const batchConditionParams = computed(() => {
async function genBatchConditionParams() {
const selectModules = await getModuleIds();
return { return {
condition: { condition: {
keyword: keyword.value, keyword: keyword.value,
@ -746,10 +760,10 @@
}, },
projectId: appStore.currentProjectId, projectId: appStore.currentProjectId,
protocol: props.protocol, protocol: props.protocol,
moduleIds: moduleIds.value, moduleIds: selectModules,
apiDefinitionId: props.apiDetail?.id as string, apiDefinitionId: props.apiDetail?.id as string,
}; };
}); }
function handleDeleteCase(record?: ApiCaseDetail, isBatch?: boolean) { function handleDeleteCase(record?: ApiCaseDetail, isBatch?: boolean) {
const title = isBatch const title = isBatch
@ -771,11 +785,12 @@
onBeforeOk: async () => { onBeforeOk: async () => {
try { try {
if (isBatch) { if (isBatch) {
const batchConditionParams = await genBatchConditionParams();
await batchDeleteCase({ await batchDeleteCase({
selectIds: tableSelected.value as string[], selectIds: tableSelected.value as string[],
selectAll: batchParams.value.selectAll, selectAll: batchParams.value.selectAll,
excludeIds: batchParams.value?.excludeIds || [], excludeIds: batchParams.value?.excludeIds || [],
...batchConditionParams.value, ...batchConditionParams,
}); });
} else { } else {
await deleteCase(record?.id as string); await deleteCase(record?.id as string);
@ -899,11 +914,12 @@
if (!errors) { if (!errors) {
try { try {
batchEditLoading.value = true; batchEditLoading.value = true;
const batchConditionParams = await genBatchConditionParams();
await batchEditCase({ await batchEditCase({
selectIds: batchParams.value?.selectedIds || [], selectIds: batchParams.value?.selectedIds || [],
selectAll: !!batchParams.value?.selectAll, selectAll: !!batchParams.value?.selectAll,
excludeIds: batchParams.value?.excludeIds || [], excludeIds: batchParams.value?.excludeIds || [],
...batchConditionParams.value, ...batchConditionParams,
type: batchForm.value.attr.charAt(0).toUpperCase() + batchForm.value.attr.slice(1), // type: batchForm.value.attr.charAt(0).toUpperCase() + batchForm.value.attr.slice(1), //
[batchForm.value.attr]: batchForm.value.attr === 'tags' ? batchForm.value.values : batchForm.value.value, [batchForm.value.attr]: batchForm.value.attr === 'tags' ? batchForm.value.values : batchForm.value.value,
}); });
@ -934,11 +950,12 @@
if (!errors) { if (!errors) {
try { try {
batchExecuteLoading.value = true; batchExecuteLoading.value = true;
const batchConditionParams = await genBatchConditionParams();
await batchExecuteCase({ await batchExecuteCase({
selectIds: batchParams.value?.selectedIds || [], selectIds: batchParams.value?.selectedIds || [],
selectAll: !!batchParams.value?.selectAll, selectAll: !!batchParams.value?.selectAll,
excludeIds: batchParams.value?.excludeIds || [], excludeIds: batchParams.value?.excludeIds || [],
...batchConditionParams.value, ...batchConditionParams,
runModeConfig: { runModeConfig: {
runMode: batchExecuteForm.value.runMode, runMode: batchExecuteForm.value.runMode,
integratedReport: batchExecuteForm.value.integratedReport === 'true', integratedReport: batchExecuteForm.value.integratedReport === 'true',

View File

@ -3,6 +3,7 @@
<div v-show="activeApiTab.id === 'all'" class="flex-1 overflow-hidden"> <div v-show="activeApiTab.id === 'all'" class="flex-1 overflow-hidden">
<caseTable <caseTable
ref="caseTableRef" ref="caseTableRef"
:offspring-ids="props.offspringIds"
:is-api="false" :is-api="false"
:active-module="props.activeModule" :active-module="props.activeModule"
:protocol="props.protocol" :protocol="props.protocol"
@ -41,6 +42,7 @@
const props = defineProps<{ const props = defineProps<{
activeModule: string; activeModule: string;
protocol: string; protocol: string;
offspringIds: string[];
moduleTree: ModuleTreeNode[]; // moduleTree: ModuleTreeNode[]; //
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{

View File

@ -41,6 +41,7 @@
:active-module="props.activeModule" :active-module="props.activeModule"
:protocol="props.protocol" :protocol="props.protocol"
:module-tree="props.moduleTree" :module-tree="props.moduleTree"
:offspring-ids="props.offspringIds"
@delete-case="(id) => handleDeleteApiFromModuleTree(id)" @delete-case="(id) => handleDeleteApiFromModuleTree(id)"
/> />
</template> </template>

View File

@ -1,7 +1,8 @@
<template> <template>
<div :class="['p-[16px_16px]', props.class]"> <div :class="['p-[16px_16px]', props.class]">
<div class="mb-[16px] flex items-center justify-between"> <div class="mb-[16px] flex items-center justify-between">
<div class="flex items-center gap-[8px]"> <div class="flex items-center"> </div>
<div class="items-right flex gap-[8px]">
<a-input-search <a-input-search
v-model:model-value="keyword" v-model:model-value="keyword"
:placeholder="t('api_scenario.table.searchPlaceholder')" :placeholder="t('api_scenario.table.searchPlaceholder')"

View File

@ -48,6 +48,7 @@
v-on="propsEvent" v-on="propsEvent"
@selected-change="handleTableSelect" @selected-change="handleTableSelect"
@batch-action="handleTableBatch" @batch-action="handleTableBatch"
@module-change="searchList"
> >
<template #name="{ record, rowIndex }"> <template #name="{ record, rowIndex }">
<MsTag <MsTag
@ -838,7 +839,16 @@
selectedModuleKeys.value = []; selectedModuleKeys.value = [];
} }
function setTableParams() { async function getModuleIds() {
let moduleIds = [props.activeFolder];
const getAllChildren = await tableStore.getSubShow(TableKeyEnum.FILE_MANAGEMENT_FILE);
if (getAllChildren) {
moduleIds = [props.activeFolder, ...props.offspringIds];
}
return moduleIds;
}
async function setTableParams() {
if (props.activeFolder === 'my') { if (props.activeFolder === 'my') {
combine.value.createUser = userStore.id; combine.value.createUser = userStore.id;
} else { } else {
@ -849,10 +859,11 @@
} else { } else {
combine.value.storage = 'minio'; combine.value.storage = 'minio';
} }
let moduleIds: string[] = [props.activeFolder, ...props.offspringIds]; let moduleIds: string[];
if (isMyOrAllFolder.value) { if (isMyOrAllFolder.value) {
moduleIds = []; moduleIds = [];
} else {
moduleIds = await getModuleIds();
} }
setLoadListParams({ setLoadListParams({
keyword: keyword.value, keyword: keyword.value,
@ -869,7 +880,7 @@
async function changeFileType() { async function changeFileType() {
await initFileTypes(); await initFileTypes();
resetSelector(); resetSelector();
setTableParams(); await setTableParams();
if (showType.value === 'card') { if (showType.value === 'card') {
cardListRef.value?.reload(); cardListRef.value?.reload();
} else { } else {
@ -898,8 +909,8 @@
} }
); );
const searchList = debounce(() => { const searchList = debounce(async () => {
setTableParams(); await setTableParams();
if (showType.value === 'card') { if (showType.value === 'card') {
cardListRef.value?.reload(); cardListRef.value?.reload();
} else { } else {