@@ -197,13 +199,20 @@
import MsThumbnailCard from '@/components/business/ms-thumbnail-card/index.vue';
import popConfirm from './popConfirm.vue';
- import { getFileDetail, reuploadFile, updateFile } from '@/api/modules/project-management/fileManagement';
+ import {
+ downloadFile,
+ getFileDetail,
+ reuploadFile,
+ toggleJarFileStatus,
+ updateFile,
+ } from '@/api/modules/project-management/fileManagement';
import { CompressImgUrl, OriginImgUrl } from '@/api/requrls/project-management/fileManagement';
import { useI18n } from '@/hooks/useI18n';
import useLocale from '@/locale/useLocale';
import useUserStore from '@/store/modules/user';
- import { downloadUrlFile, formatFileSize } from '@/utils';
+ import { downloadByteFile, downloadUrlFile, formatFileSize } from '@/utils';
+ import { FileDetail } from '@/models/projectManagement/file';
import { TableKeyEnum } from '@/enums/tableEnum';
const props = defineProps<{
@@ -241,22 +250,38 @@
);
async function handleEnableIntercept(newValue: string | number | boolean) {
- await new Promise((resolve) => {
- setTimeout(() => {
- resolve(true);
- }, 1000);
- });
- return true;
+ try {
+ await toggleJarFileStatus(props.fileId, newValue as boolean);
+ return true;
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.log(error);
+ return false;
+ }
}
- function handleDownload(detail: any) {
- downloadUrlFile(detail.url, detail.name);
+ const downLoading = ref(false);
+ /**
+ * 下载单个文件
+ * @param record 表格数据项
+ */
+ async function handleDownload(detail: FileDetail) {
+ try {
+ downLoading.value = true;
+ const res = await downloadFile(detail.id);
+ downloadByteFile(res, `${detail.name}.${detail.fileType}`);
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.log(error);
+ } finally {
+ downLoading.value = false;
+ }
}
const fileType = ref('unknown');
const renameTitle = ref(''); // 重命名的文件名称
- function loadedFile(detail: any) {
+ function loadedFile(detail: FileDetail) {
if (detail.fileType) {
fileType.value = getFileEnum(`/${detail.fileType.toLowerCase()}`);
}
@@ -269,7 +294,7 @@
},
{
label: t('project.fileManagement.desc'),
- value: detail.desc,
+ value: detail.description,
key: 'desc',
},
{
@@ -291,9 +316,10 @@
},
{
label: t('project.fileManagement.tag'),
- value: detail.tag,
+ value: detail.tags,
isTag: true,
showTagAdd: true,
+ closable: true,
key: 'tag',
},
{
@@ -306,18 +332,18 @@
3,
0,
...[
- {
- label: t('project.fileManagement.gitBranch'),
- value: detail.gitBranch,
- },
- {
- label: t('project.fileManagement.gitPath'),
- value: detail.gitPath,
- },
- {
- label: t('project.fileManagement.gitVersion'),
- value: detail.gitVersion,
- },
+ // {
+ // label: t('project.fileManagement.gitBranch'),
+ // value: detail.gitBranch,
+ // },
+ // {
+ // label: t('project.fileManagement.gitPath'),
+ // value: detail.gitPath,
+ // },
+ // {
+ // label: t('project.fileManagement.gitVersion'),
+ // value: detail.gitVersion,
+ // },
]
);
}
@@ -359,10 +385,17 @@
const previewVisible = ref(false);
- async function addFileTag(val: string) {
+ async function addFileTag(val: string, item: Description) {
await updateFile({
id: props.fileId,
- tags: [val],
+ tags: Array.isArray(item.value) ? [...item.value, val] : [item.value, val],
+ });
+ }
+
+ async function handleFileTagClose(tag: string | number, item: Description) {
+ await updateFile({
+ id: props.fileId,
+ tags: Array.isArray(item.value) ? item.value.filter((e) => e !== tag) : [],
});
}
diff --git a/frontend/src/views/project-management/fileManagement/components/rightBox.vue b/frontend/src/views/project-management/fileManagement/components/rightBox.vue
index 351c3db473..e3d409b21f 100644
--- a/frontend/src/views/project-management/fileManagement/components/rightBox.vue
+++ b/frontend/src/views/project-management/fileManagement/components/rightBox.vue
@@ -466,12 +466,21 @@
];
const tableStore = useTableStore();
tableStore.initColumn(TableKeyEnum.FILE_MANAGEMENT_FILE, columns, 'drawer');
- const { propsRes, propsEvent, loadList, setLoadListParams } = useTable(getFileList, {
- tableKey: TableKeyEnum.FILE_MANAGEMENT_FILE,
- showSetting: true,
- selectable: true,
- showSelectAll: true,
- });
+ const { propsRes, propsEvent, loadList, setLoadListParams } = useTable(
+ getFileList,
+ {
+ tableKey: TableKeyEnum.FILE_MANAGEMENT_FILE,
+ showSetting: true,
+ selectable: true,
+ showSelectAll: true,
+ },
+ (item) => {
+ return {
+ ...item,
+ tags: item.tags?.map((e: string) => ({ id: e, name: e })) || [],
+ };
+ }
+ );
const moduleFileBatchActions = {
baseAction: [
{
@@ -653,7 +662,7 @@
try {
batchMoveFileLoading.value = true;
await batchMoveFile({
- selectIds: batchParams.value?.selectedIds || [activeFile.value?.id || ''],
+ selectIds: isBatchMove.value ? batchParams.value?.selectedIds || [] : [activeFile.value?.id || ''],
selectAll: !!batchParams.value?.selectAll,
excludeIds: batchParams.value?.excludeIds || [],
condition: { keyword: keyword.value, comebine: combine.value },
@@ -834,6 +843,15 @@
activeFileIndex.value = index;
}
+ watch(
+ () => showDetailDrawer.value,
+ (val) => {
+ if (!val) {
+ loadList();
+ }
+ }
+ );
+
const uploadDrawerVisible = ref(false); // 模块-上传文件抽屉
const fileList = ref(asyncTaskStore.uploadFileTask.fileList);
// 是否非上传中状态