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