From 2649b869f8f429f9bbc49fcb6af9cb63dc5297e1 Mon Sep 17 00:00:00 2001 From: dongzhihuan Date: Mon, 23 Mar 2026 20:22:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?update=20fileTable=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/fileTable/index.vue | 100 +++++++++++++++------- 1 file changed, 67 insertions(+), 33 deletions(-) diff --git a/src/components/common/fileTable/index.vue b/src/components/common/fileTable/index.vue index c3119545..653746db 100644 --- a/src/components/common/fileTable/index.vue +++ b/src/components/common/fileTable/index.vue @@ -29,11 +29,28 @@ - + + + + + + + + + + + + @@ -41,42 +58,38 @@ import { ref, computed, onMounted, onBeforeUnmount } from 'vue'; import BaseTable from '@/components/common/table/baseTable.vue'; import FilePreview from '@/components/common/filePreview/index.vue'; -import { downloadFileById, isAcceptFileType } from '@/utils/file'; +import { downloadFileById } from '@/utils/file'; import FileTypeChange from '@/components/common/fileTable/fileTypeChange.vue'; import { ElMessage } from 'element-plus'; import { dataDelFileApi } from '@/api/data/data'; +import Dialog from '@/components/common/dialog/index.vue'; const props = defineProps({ actionList: { type: Array, default: () => [], }, - // 操作栏默认列表,不传默认需要所有 + // 操作栏默认列表 defaultActions: { type: Array, default: () => ['preview', 'download', 'delete'], }, - // 预览方式 如果想用onlyOffice,则 fileNameField 必传 - previewType: { - type: String, - default: 'kkFile', - }, - // 文件名的字段 用后缀来判断是否支持用 onlyOffice 预览,当previewType为onlyOffice时必传 - fileNameField: { - type: String, - default: '', - }, - // 文件id的字段, 1)用于下载,预览; 2)用于在右键时高亮当前行, 默认查找顺序:id -> fileId -> uuid + // 文件id的字段, 1)用于操作文件; 2)用于在右键时高亮当前行, 默认查找顺序:id -> fileId -> uuid fileIdField: { type: String, default: 'id', }, - // 是否需要右键菜单,默认不需要 + // 文件名称字段 + fileNameField: { + type: String, + default: 'fileName', + }, + // 是否需要右键菜单,默认不需要【待开发】 needContextMenu: { type: Boolean, default: false, }, - // 文件标签字段 + // 文件标签字段【待开发】 fileTagField: { type: String, default: 'fileType', @@ -86,7 +99,6 @@ const props = defineProps({ const fileTableRef = ref(); const previewVisible = ref(false); const previewFileId = ref(''); -const currentNeedPreviewType = ref(''); // 当前真实需要预览的方式 // #region ---------------------------操作栏--------------------------- // 默认的操作栏, 如果有业务判断,就在业务组件内部写 @@ -97,17 +109,6 @@ const defaultActionList = computed(() => [ title: '预览', type: 'primary', click: (row: any) => { - // 弃用 0226 好像不需要设置预览方式了了,预览组件内部根据文件类型判断 - // 如果外部没有传previewType或者传的是kkfile,则不需要额外处理; - // 如果传的是onlyOffice,那么需要把文件名字段也传过来,因为onlyOffice需要判断文件类型 isAcceptFileType - // if (props.previewType === 'onlyOffice' && props.fileNameField) { - // currentNeedPreviewType.value = isAcceptFileType( - // row[props.fileNameField], - // 'onlyOffice' - // ) - // ? 'onlyOffice' - // : 'kkFile'; - // } // 文件唯一标识 [id -> fileId -> uuid], 如果传了,优先用传过来的,没传就按这个顺序找 const fileId = row[props.fileIdField] || row.fileId || row.uuid; previewFileId.value = fileId; @@ -136,6 +137,15 @@ const defaultActionList = computed(() => [ }, ] : []), + ...(props.defaultActions?.includes('rename') + ? [ + { + title: '重命名', + type: 'primary', + click: (row: any) => renameFun(row[props.fileIdField] || row.fileId || row.uuid, row), + }, + ] + : []), ]); const deleteFileFun = async (id: number) => { @@ -153,6 +163,30 @@ const allActionList = computed(() => { const downloadFile = (id: any) => { downloadFileById(id); }; +// 文件重命名 +const currentRenameId = ref(); // 当前重命名文件的id +const currentRenameName = ref(); // 当前重命名文件的名称 +const currentRenameSuffix = ref(); // 当前重命名文件的扩展名 +const oldName = ref(); // 当前重命名文件的原始名称 +const diaVisible = ref(false); +const renameFun = (id: any, row: any) => { + currentRenameId.value = id; + diaVisible.value = true; + const fileName = row[props.fileNameField]; + if (fileName.includes('.')) { + currentRenameName.value = fileName.substring(0, fileName.lastIndexOf('.')); + oldName.value = currentRenameName.value; + currentRenameSuffix.value = fileName.substring(fileName.lastIndexOf('.')); + } else { + currentRenameName.value = fileName; + oldName.value = currentRenameName.value; + currentRenameSuffix.value = ''; + } +}; +const submitFun = () => { + // dzh todo 重命名接口 + // console.log(currentRenameId.value, currentRenameName.value); +}; // #endregion // #region ---------------------------右键菜单模块--------------------------- @@ -219,6 +253,7 @@ defineExpose({ [ 'tableData', 'tableRef', + 'tableHeadVisible', 'resetFun', 'setDataFun', 'getSearchParamsFun', @@ -226,7 +261,6 @@ defineExpose({ 'setSearchParamsFun', 'setSearchParamByKeyFun', 'setOptionsFun', - 'getTableDataFun', ].map((method) => [method, (...args: any[]) => fileTableRef.value?.[method](...args)]) ), }); From 0502880b9c12ff56ba20978ba866f7fbbc6ff9f2 Mon Sep 17 00:00:00 2001 From: dongzhihuan Date: Mon, 23 Mar 2026 20:50:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?update=20fileTable=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/fileTable/fileRename.vue | 95 +++++++++++++++++++ src/components/common/fileTable/index.vue | 56 ++++------- 2 files changed, 111 insertions(+), 40 deletions(-) create mode 100644 src/components/common/fileTable/fileRename.vue diff --git a/src/components/common/fileTable/fileRename.vue b/src/components/common/fileTable/fileRename.vue new file mode 100644 index 00000000..68cc8c54 --- /dev/null +++ b/src/components/common/fileTable/fileRename.vue @@ -0,0 +1,95 @@ + + + diff --git a/src/components/common/fileTable/index.vue b/src/components/common/fileTable/index.vue index 653746db..b17f5be2 100644 --- a/src/components/common/fileTable/index.vue +++ b/src/components/common/fileTable/index.vue @@ -31,26 +31,13 @@ - - - - - - - - - - + @@ -62,7 +49,7 @@ import { downloadFileById } from '@/utils/file'; import FileTypeChange from '@/components/common/fileTable/fileTypeChange.vue'; import { ElMessage } from 'element-plus'; import { dataDelFileApi } from '@/api/data/data'; -import Dialog from '@/components/common/dialog/index.vue'; +import FileRename from '@/components/common/fileTable/fileRename.vue'; const props = defineProps({ actionList: { @@ -164,28 +151,17 @@ const downloadFile = (id: any) => { downloadFileById(id); }; // 文件重命名 -const currentRenameId = ref(); // 当前重命名文件的id -const currentRenameName = ref(); // 当前重命名文件的名称 -const currentRenameSuffix = ref(); // 当前重命名文件的扩展名 -const oldName = ref(); // 当前重命名文件的原始名称 -const diaVisible = ref(false); +const renameVisible = ref(false); +const currentRenameId = ref(); +const currentRenameData = ref({}); + const renameFun = (id: any, row: any) => { currentRenameId.value = id; - diaVisible.value = true; - const fileName = row[props.fileNameField]; - if (fileName.includes('.')) { - currentRenameName.value = fileName.substring(0, fileName.lastIndexOf('.')); - oldName.value = currentRenameName.value; - currentRenameSuffix.value = fileName.substring(fileName.lastIndexOf('.')); - } else { - currentRenameName.value = fileName; - oldName.value = currentRenameName.value; - currentRenameSuffix.value = ''; - } + currentRenameData.value = { ...row }; + renameVisible.value = true; }; -const submitFun = () => { - // dzh todo 重命名接口 - // console.log(currentRenameId.value, currentRenameName.value); +const renameFinishFun = () => { + // dzh todo 刷新数据 }; // #endregion