feat(文件管理): 文件管理部分接口&部分组件调整&文件上传接口返回接口错误信息
This commit is contained in:
parent
d1ec8d00bc
commit
03109b9bff
|
@ -96,6 +96,13 @@ export class MSAxios {
|
|||
const requestData = JSON.stringify(params.request);
|
||||
formData.append('request', new Blob([requestData], { type: ContentTypeEnum.JSON }));
|
||||
}
|
||||
const transform = this.getTransform();
|
||||
|
||||
const { requestOptions } = this.options;
|
||||
|
||||
const opt = { ...requestOptions, isTransformResponse: false };
|
||||
|
||||
const { transformRequestHook } = transform || {};
|
||||
return new Promise((resolve, reject) => {
|
||||
this.axiosInstance
|
||||
.request<any, AxiosResponse<Result>>({
|
||||
|
@ -109,11 +116,6 @@ export class MSAxios {
|
|||
},
|
||||
})
|
||||
.then((res: AxiosResponse<Result>) => {
|
||||
const transform = this.getTransform();
|
||||
const { requestOptions } = this.options;
|
||||
const opt = { ...requestOptions };
|
||||
|
||||
const { transformRequestHook } = transform || {};
|
||||
// 请求成功后的处理
|
||||
if (transformRequestHook && isFunction(transformRequestHook)) {
|
||||
try {
|
||||
|
|
|
@ -170,7 +170,7 @@ const transform: AxiosTransform = {
|
|||
throw new Error(e as unknown as string);
|
||||
}
|
||||
checkStatus(error?.response?.status, msg, errorMessageMode);
|
||||
return Promise.reject(error);
|
||||
return Promise.reject(error?.response?.data?.message);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@
|
|||
* 处理树节点选中(非复选框)
|
||||
*/
|
||||
function select(selectedKeys: Array<string | number>, data: MsTreeSelectedData) {
|
||||
emit('select', selectedKeys, data.selectedNodes);
|
||||
emit('select', selectedKeys, data.selectedNodes[0]);
|
||||
}
|
||||
|
||||
function checked(checkedKeys: Array<string | number>) {
|
||||
|
@ -472,6 +472,19 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
.arco-tree-node-disabled {
|
||||
&:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
* {
|
||||
color: var(--color-text-4) !important;
|
||||
}
|
||||
.arco-tree-node-title {
|
||||
&:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
class="w-[200px]"
|
||||
/>
|
||||
<div v-else-if="item.status === UploadStatus.error" class="text-[rgb(var(--danger-6))]">
|
||||
{{ t('ms.upload.uploadFail') }}
|
||||
{{ item.errMsg || t('ms.upload.uploadFail') }}
|
||||
</div>
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
|
|
|
@ -10,4 +10,5 @@ export type MsFileItem = FileItem & {
|
|||
status?: keyof typeof UploadStatus;
|
||||
enable?: boolean; // jar类型文件是否可用
|
||||
uploadedTime?: string | number; // 上传完成时间
|
||||
errMsg?: string; // 上传失败的错误信息
|
||||
};
|
||||
|
|
|
@ -197,6 +197,7 @@ const useAsyncTaskStore = defineStore('asyncTask', {
|
|||
console.log(error);
|
||||
if (fileItem) {
|
||||
fileItem.status = UploadStatus.error;
|
||||
fileItem.errMsg = error as string;
|
||||
}
|
||||
} finally {
|
||||
// 上传完成/失败,重置进度和定时器
|
||||
|
|
|
@ -77,12 +77,7 @@
|
|||
import type { MsTreeNodeData } from '@/components/business/ms-tree/types';
|
||||
import popConfirm from './popConfirm.vue';
|
||||
|
||||
import {
|
||||
deleteModule,
|
||||
getModules,
|
||||
getModulesCount,
|
||||
moveModule,
|
||||
} from '@/api/modules/project-management/fileManagement';
|
||||
import { deleteModule, getModules, moveModule } from '@/api/modules/project-management/fileManagement';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import useModal from '@/hooks/useModal';
|
||||
import useAppStore from '@/store/modules/app';
|
||||
|
@ -92,6 +87,7 @@
|
|||
|
||||
const props = defineProps<{
|
||||
isExpandAll: boolean;
|
||||
activeFolder?: string; // 当前选中的文件夹,弹窗模式下需要使用
|
||||
selectedKeys?: Array<string | number>; // 选中的节点 key
|
||||
isModal?: boolean; // 是否是弹窗模式
|
||||
modulesCount?: Record<string, number>; // 模块数量统计对象
|
||||
|
@ -158,11 +154,14 @@
|
|||
try {
|
||||
loading.value = true;
|
||||
const res = await getModules(appStore.currentProjectId);
|
||||
folderTree.value = res.map((e) => ({
|
||||
...e,
|
||||
hideMoreAction: e.id === 'root',
|
||||
draggable: e.id !== 'root' && !props.isModal,
|
||||
}));
|
||||
folderTree.value = mapTree<ModuleTreeNode>(res, (e) => {
|
||||
return {
|
||||
...e,
|
||||
hideMoreAction: e.id === 'root',
|
||||
draggable: e.id !== 'root' && !props.isModal,
|
||||
disabled: e.id === props.activeFolder && props.isModal,
|
||||
};
|
||||
});
|
||||
if (isSetDefaultKey) {
|
||||
selectedKeys.value = [folderTree.value[0].id];
|
||||
}
|
||||
|
@ -217,8 +216,14 @@
|
|||
/**
|
||||
* 处理文件夹树节点选中事件
|
||||
*/
|
||||
function folderNodeSelect(_selectedKeys: (string | number)[]) {
|
||||
emit('folderNodeSelect', _selectedKeys);
|
||||
function folderNodeSelect(_selectedKeys: (string | number)[], node: MsTreeNodeData) {
|
||||
const offspringIds: string[] = [];
|
||||
mapTree(node.children || [], (e) => {
|
||||
offspringIds.push(e.id);
|
||||
return e;
|
||||
});
|
||||
|
||||
emit('folderNodeSelect', _selectedKeys, offspringIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -249,15 +249,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<folderTree
|
||||
<FolderTree
|
||||
v-if="moveModalVisible"
|
||||
v-model:selected-keys="selectedModuleKeys"
|
||||
:is-expand-all="true"
|
||||
:active-folder="props.activeFolder"
|
||||
is-modal
|
||||
@folder-node-select="folderNodeSelect"
|
||||
/>
|
||||
</a-modal>
|
||||
<fileDetailDrawerVue
|
||||
<FileDetailDrawer
|
||||
v-model:visible="showDetailDrawer"
|
||||
:file-id="activeFileId"
|
||||
:active-file-index="activeFileIndex"
|
||||
|
@ -287,8 +288,8 @@
|
|||
import MsCardList from '@/components/business/ms-card-list/index.vue';
|
||||
import MsFormItemSub from '@/components/business/ms-form-item-sub/index.vue';
|
||||
import MsThumbnailCard from '@/components/business/ms-thumbnail-card/index.vue';
|
||||
import fileDetailDrawerVue from './fileDetailDrawer.vue';
|
||||
import folderTree from './folderTree.vue';
|
||||
import FileDetailDrawer from './fileDetailDrawer.vue';
|
||||
import FolderTree from './folderTree.vue';
|
||||
|
||||
import {
|
||||
batchDownloadFile,
|
||||
|
@ -298,7 +299,6 @@
|
|||
getFileList,
|
||||
getFileTypes,
|
||||
toggleJarFileStatus,
|
||||
updateFile,
|
||||
uploadFile,
|
||||
} from '@/api/modules/project-management/fileManagement';
|
||||
import { CompressImgUrl } from '@/api/requrls/project-management/fileManagement';
|
||||
|
@ -320,6 +320,7 @@
|
|||
const props = defineProps<{
|
||||
activeFolder: string;
|
||||
activeFolderType: 'folder' | 'module' | 'storage';
|
||||
offspringIds: string[]; // 当前选中文件夹的所有子孙节点id
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'init', params: FileListQueryParams): void;
|
||||
|
@ -466,7 +467,7 @@
|
|||
];
|
||||
const tableStore = useTableStore();
|
||||
tableStore.initColumn(TableKeyEnum.FILE_MANAGEMENT_FILE, columns, 'drawer');
|
||||
const { propsRes, propsEvent, loadList, setLoadListParams } = useTable(
|
||||
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(
|
||||
getFileList,
|
||||
{
|
||||
tableKey: TableKeyEnum.FILE_MANAGEMENT_FILE,
|
||||
|
@ -543,6 +544,7 @@
|
|||
moduleIds: [props.activeFolder],
|
||||
});
|
||||
downloadByteFile(res, 'files.zip');
|
||||
resetSelector();
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
|
@ -608,6 +610,7 @@
|
|||
cardListRef.value?.reload();
|
||||
} else {
|
||||
loadList();
|
||||
resetSelector();
|
||||
}
|
||||
emitTableParams();
|
||||
} catch (error) {
|
||||
|
@ -620,7 +623,7 @@
|
|||
}
|
||||
|
||||
const moveModalVisible = ref(false); // 移动文件弹窗
|
||||
const selectedModuleKeys = ref<(string | number)[]>([]); // 移动文件搜索关键字
|
||||
const selectedModuleKeys = ref<(string | number)[]>([]); // 移动文件选中节点
|
||||
const isBatchMove = ref(false); // 是否批量移动文件
|
||||
const activeFile = ref<FileItem | null>(null); // 当前查看的文件信息
|
||||
|
||||
|
@ -682,6 +685,7 @@
|
|||
cardListRef.value?.reload();
|
||||
} else {
|
||||
loadList();
|
||||
resetSelector();
|
||||
}
|
||||
emitTableParams();
|
||||
} catch (error) {
|
||||
|
@ -704,10 +708,14 @@
|
|||
if (fileType.value === 'storage') {
|
||||
combine.value.storage = 'git';
|
||||
}
|
||||
let moduleIds: string[] = [props.activeFolder, ...props.offspringIds];
|
||||
if (['all', 'my'].includes(props.activeFolder)) {
|
||||
moduleIds = [];
|
||||
}
|
||||
setLoadListParams({
|
||||
keyword: keyword.value,
|
||||
fileType: tableFileType.value,
|
||||
moduleIds: ['all', 'my'].includes(props.activeFolder) ? [] : [props.activeFolder],
|
||||
moduleIds,
|
||||
projectId: appStore.currentProjectId,
|
||||
comebine: combine.value,
|
||||
});
|
||||
|
@ -745,6 +753,7 @@
|
|||
() => {
|
||||
keyword.value = '';
|
||||
searchList();
|
||||
resetSelector();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
|
|
@ -72,7 +72,12 @@
|
|||
</div>
|
||||
</template>
|
||||
<template #right>
|
||||
<rightBox :active-folder="activeFolder" :active-folder-type="activeFolderType" @init="handleModuleTableInit" />
|
||||
<rightBox
|
||||
:active-folder="activeFolder"
|
||||
:active-folder-type="activeFolderType"
|
||||
:offspring-ids="offspringIds"
|
||||
@init="handleModuleTableInit"
|
||||
/>
|
||||
</template>
|
||||
</MsSplitBox>
|
||||
</div>
|
||||
|
@ -127,6 +132,7 @@
|
|||
get: () => [activeFolder.value],
|
||||
set: (val) => val,
|
||||
});
|
||||
const offspringIds = ref<string[]>([]);
|
||||
|
||||
function setActiveFolder(id: string) {
|
||||
activeFolder.value = id;
|
||||
|
@ -151,9 +157,10 @@
|
|||
/**
|
||||
* 处理文件夹树节点选中事件
|
||||
*/
|
||||
function folderNodeSelect(keys: string[]) {
|
||||
function folderNodeSelect(keys: string[], _offspringIds: string[]) {
|
||||
[activeFolder.value] = keys;
|
||||
activeFolderType.value = 'module';
|
||||
offspringIds.value = [..._offspringIds];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue