From 55a23e672d37869342ef19b12c25f8e548a42aa6 Mon Sep 17 00:00:00 2001
From: b2894lxlx <517289602@qq.com>
Date: Fri, 12 Jun 2026 17:58:54 +0800
Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=B2=BE=E7=AE=80=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=AD=97=E6=AE=B5=202=E3=80=81=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9pdf=E5=9C=A8=E7=BA=BF=E6=9F=A5=E7=9C=8B=E9=80=BB?=
=?UTF-8?q?=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pwlProject/components/reportContent.vue | 141 +++++++--
src/views/pwl/pwlProject/index.vue | 274 ++----------------
src/views/pwl/pwlProjectLibrary/index.vue | 274 ++----------------
3 files changed, 151 insertions(+), 538 deletions(-)
diff --git a/src/views/pwl/pwlProject/components/reportContent.vue b/src/views/pwl/pwlProject/components/reportContent.vue
index c4ce0ac..2aeeb81 100644
--- a/src/views/pwl/pwlProject/components/reportContent.vue
+++ b/src/views/pwl/pwlProject/components/reportContent.vue
@@ -320,12 +320,11 @@
"
>

- {{ fileItem.fileName || '未命名文件' }}
+ {{ getFileInfo(fileItem).name || '未命名文件' }}
-
- {{ fileItem.fileName || fileItem || '未命名文件' }}
+
+ {{ getFileInfo(fileItem).name || '未命名文件' }}
@@ -2011,12 +2014,89 @@
});
};
- const openDoc = (fileItem) => {
- console.log(fileItem);
- // window.open(
- // `http://view.officeapps.live.com/op/view.aspx?src=文件地址`,
- // '_blank'
- // );
+ const getFileInfo = (fileItem: any) => {
+ if (typeof fileItem === 'string') {
+ const [fileId = '', fileName = '', fileUrl = ''] = fileItem.split('||');
+ return {
+ id: fileId,
+ name: fileName || fileItem,
+ url: fileUrl,
+ ext: getFileExt(fileName || fileUrl || fileItem)
+ };
+ }
+
+ if (fileItem && typeof fileItem === 'object') {
+ const name =
+ fileItem.fileName || fileItem.file_name || fileItem.name || '';
+ const url = fileItem.fileUrl || fileItem.url || '';
+ const ext =
+ fileItem.fileExt ||
+ fileItem.fileType ||
+ getFileExt(name || url || '');
+
+ return {
+ id: fileItem.fileId || fileItem.file_id || '',
+ name: name || '未命名文件',
+ url,
+ ext: String(ext || '').toLowerCase().replace(/^\./, '')
+ };
+ }
+
+ return {
+ id: '',
+ name: '未命名文件',
+ url: '',
+ ext: ''
+ };
+ };
+
+ const getFileExt = (value: string) => {
+ const cleanValue = String(value || '').split('?')[0].trim();
+ if (!cleanValue) return '';
+ const ext = cleanValue.includes('.') ? cleanValue.split('.').pop() : '';
+ return String(ext || '').toLowerCase().replace(/^\./, '');
+ };
+
+ const buildFileIconDataUri = (label: string, color: string) => {
+ const svg = `
+
+ `;
+ return `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(svg)}`;
+ };
+
+ const getFileIcon = (fileItem: any) => {
+ const ext = getFileInfo(fileItem).ext;
+
+ if (ext === 'pdf') {
+ return buildFileIconDataUri('PDF', '#e53935');
+ }
+ if (['doc', 'docx'].includes(ext)) {
+ return buildFileIconDataUri('DOC', '#2f6fed');
+ }
+ if (['xls', 'xlsx', 'csv'].includes(ext)) {
+ return buildFileIconDataUri('XLS', '#2e7d32');
+ }
+ if (['ppt', 'pptx'].includes(ext)) {
+ return buildFileIconDataUri('PPT', '#ef6c00');
+ }
+ if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp', 'svg'].includes(ext)) {
+ return buildFileIconDataUri('IMG', '#8e24aa');
+ }
+ if (['txt', 'md'].includes(ext)) {
+ return buildFileIconDataUri('TXT', '#546e7a');
+ }
+ return buildFileIconDataUri('FILE', '#607d8b');
+ };
+
+ const openDoc = (fileItem: any) => {
+ const file = getFileInfo(fileItem);
+ if (!file.url) {
+ return;
+ }
+ window.open(file.url, '_blank', 'noopener,noreferrer');
};
/* 键盘快捷键处理 */
@@ -2168,18 +2248,31 @@
}
);
- const handleFilePreview = (file) => {
- console.log(
- file.fileUrl,
- `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
- file.fileUrl
- )}`
- );
- window.open(
- `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
- file.fileUrl
- )}`
- );
+ const handleFilePreview = (fileItem: any) => {
+ const file = getFileInfo(fileItem);
+ if (!file.url) {
+ message.warning('该文件暂无可访问地址');
+ return;
+ }
+
+ if (file.ext === 'pdf') {
+ window.open(file.url, '_blank', 'noopener,noreferrer');
+ return;
+ }
+
+ const officePreviewExts = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
+ if (officePreviewExts.includes(file.ext)) {
+ window.open(
+ `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
+ file.url
+ )}`,
+ '_blank',
+ 'noopener,noreferrer'
+ );
+ return;
+ }
+
+ window.open(file.url, '_blank', 'noopener,noreferrer');
};
diff --git a/src/views/pwl/pwlProject/index.vue b/src/views/pwl/pwlProject/index.vue
index 1184cda..691973a 100644
--- a/src/views/pwl/pwlProject/index.vue
+++ b/src/views/pwl/pwlProject/index.vue
@@ -261,19 +261,21 @@
:loading="docLoading"
:row-selection="docRowSelection"
rowKey="id"
- :scroll="{ x: 2600, y: 500 }"
+ :scroll="{ x: 980, y: 500 }"
:pagination="pagination"
@change="handleTableChange"
size="middle"
>
- {{ record.fileName }}
+ {{ renderDocText(record, ['fileName', 'name']) }}
- 编辑
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
({
- id: undefined,
- docId: undefined,
- fileName: undefined,
- fileSize: undefined,
- fileType: undefined,
- workspaceId: undefined,
- fileId: undefined,
- fileUrl: undefined,
- fileExt: undefined,
- title: undefined,
- issueNumber: undefined,
- version: undefined,
- documentDate: undefined,
- effectiveDate: undefined,
- abolishDate: undefined,
- businessScope: undefined,
- relatedDocuments: undefined,
- region: undefined,
- comments: undefined,
- uploadTime: undefined,
- sortNumber: 0,
- status: 0
- });
-
// 计算目录弹窗标题
const dirModalTitle = computed(() => {
const mode = isEditingDir.value ? '编辑' : '新增';
@@ -634,47 +541,6 @@
return value === '-' ? '' : String(value).trim();
};
- const getDocFileExt = (record: AiCloudFile) => {
- const candidates = [
- record.fileExt,
- record.fileType,
- record.fileName,
- getDocFileUrl(record)
- ].filter(Boolean) as string[];
-
- for (const item of candidates) {
- const cleanValue = item.split('?')[0];
- const ext = cleanValue.includes('.')
- ? cleanValue.split('.').pop()
- : cleanValue;
- if (ext) {
- return ext.toLowerCase().replace(/^\./, '');
- }
- }
- return '';
- };
-
- const openDocPreview = (record: AiCloudFile) => {
- const fileUrl = getDocFileUrl(record);
- if (!fileUrl) {
- message.warning('该文件暂无可预览地址');
- return;
- }
-
- const ext = getDocFileExt(record);
- const officePreviewExts = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
- const previewUrl =
- ext === 'pdf'
- ? fileUrl
- : officePreviewExts.includes(ext)
- ? `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
- fileUrl
- )}`
- : fileUrl;
-
- window.open(previewUrl, '_blank', 'noopener,noreferrer');
- };
-
const resetDocSelection = () => {
selectedDocRowKeys.value = [];
selectedDocRows.value = [];
@@ -693,119 +559,33 @@
title: '文件名称',
dataIndex: 'fileName',
key: 'fileName',
- width: 180,
+ width: 260,
ellipsis: true,
customRender: ({ record }: { record: AiCloudFile }) =>
renderDocText(record, ['fileName', 'name'])
},
- {
- title: '制度标题',
- dataIndex: 'title',
- key: 'title',
- width: 220,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['title', 'documentTitle'])
- },
- {
- title: '发文字号',
- dataIndex: 'issueNumber',
- key: 'issueNumber',
- width: 160,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['issueNumber', 'documentNo', 'fileNo'])
- },
- {
- title: '版本号(反映当前制度更新状态,如有)',
- dataIndex: 'version',
- key: 'version',
- width: 220,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text ||
- renderDocText(record, ['version', 'versionNumber', 'versionName'])
- },
- {
- title: '成文日期(落款日期)',
- dataIndex: 'documentDate',
- key: 'documentDate',
- width: 180,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['documentDate', 'signDate', 'writeDate'])
- },
- {
- title: '生效日期',
- dataIndex: 'effectiveDate',
- key: 'effectiveDate',
- width: 160,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['effectiveDate'])
- },
- {
- title: '废止日期',
- dataIndex: 'abolishDate',
- key: 'abolishDate',
- width: 160,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['abolishDate', 'invalidDate'])
- },
- {
- title: '适用业务范围',
- dataIndex: 'businessScope',
- key: 'businessScope',
- width: 220,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['businessScope'])
- },
- {
- title: '关联制度(与本制度相关的其他文件,如新旧制度间的关联文件)',
- dataIndex: 'relatedDocuments',
- key: 'relatedDocuments',
- width: 260,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text ||
- renderDocText(record, [
- 'relatedDocuments',
- 'relatedDoc',
- 'relatedFiles'
- ])
- },
- {
- title:
- '适用区域(全国/广西/南宁市等)如果是公司文档管理的模板,不需要这个字段内容',
- dataIndex: 'region',
- key: 'region',
- width: 280,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['region', 'applyRegion'])
- },
{
title: '下载链接',
dataIndex: 'fileUrl',
key: 'fileUrl',
- width: 220,
+ width: 360,
ellipsis: true,
customRender: ({ record }: { record: AiCloudFile }) =>
renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
},
{
- title: '备注',
- dataIndex: 'comments',
- key: 'comments',
- width: 200,
- ellipsis: true
+ title: '上传时间',
+ dataIndex: 'uploadTime',
+ key: 'uploadTime',
+ width: 180,
+ ellipsis: true,
+ customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
+ text || renderDocText(record, ['uploadTime', 'createTime'])
},
{
title: '操作',
key: 'action',
- width: 80
+ width: 100
}
]);
@@ -989,26 +769,6 @@
});
};
- const openDocEdit = (record: AiCloudFile) => {
- docForm.value = { ...record };
- showDocEdit.value = true;
- };
-
- const closeDocEdit = () => {
- showDocEdit.value = false;
- };
-
- const handleSaveDoc = async () => {
- try {
- await updateAiCloudFile(docForm.value);
- message.success('修改成功');
- closeDocEdit();
- await loadCloudFiles();
- } catch (error: any) {
- message.error(error.message || '修改失败');
- }
- };
-
// 打开导入弹窗
const openImport = () => {
if (selectedKeys.value.length === 0) {
diff --git a/src/views/pwl/pwlProjectLibrary/index.vue b/src/views/pwl/pwlProjectLibrary/index.vue
index ef92f13..9f605e0 100644
--- a/src/views/pwl/pwlProjectLibrary/index.vue
+++ b/src/views/pwl/pwlProjectLibrary/index.vue
@@ -173,23 +173,23 @@
:loading="docLoading"
:row-selection="docRowSelection"
rowKey="id"
- :scroll="{ x: 2600, y: 500 }"
+ :scroll="{ x: 980, y: 500 }"
:pagination="pagination"
@change="handleTableChange"
size="middle"
>
- {{
+ {{
renderDocText(record, ['fileName', 'name'])
}}
- 预览
-
- 编辑
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
({
- id: undefined,
- docId: undefined,
- fileName: undefined,
- fileSize: undefined,
- fileType: undefined,
- workspaceId: undefined,
- fileId: undefined,
- fileUrl: undefined,
- fileExt: undefined,
- title: undefined,
- issueNumber: undefined,
- version: undefined,
- documentDate: undefined,
- effectiveDate: undefined,
- abolishDate: undefined,
- businessScope: undefined,
- relatedDocuments: undefined,
- region: undefined,
- comments: undefined,
- uploadTime: undefined,
- sortNumber: 0,
- status: 0
- });
-
// 计算目录弹窗标题
const dirModalTitle = computed(() => {
const mode = isEditingDir.value ? '编辑' : '新增';
@@ -536,44 +440,6 @@
return value === '-' ? '' : String(value).trim();
};
- const getDocFileExt = (record: AiCloudFile) => {
- const candidates = [
- record.fileExt,
- record.fileType,
- record.fileName,
- getDocFileUrl(record)
- ].filter(Boolean) as string[];
-
- for (const item of candidates) {
- const cleanValue = item.split('?')[0];
- const ext = cleanValue.includes('.')
- ? cleanValue.split('.').pop()
- : cleanValue;
- if (ext) {
- return ext.toLowerCase().replace(/^\./, '');
- }
- }
- return '';
- };
-
- const openDocPreview = (record: AiCloudFile) => {
- const fileUrl = getDocFileUrl(record);
- if (!fileUrl) {
- message.warning('该文件暂无可预览地址');
- return;
- }
-
- const ext = getDocFileExt(record);
- const officePreviewExts = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'];
- const previewUrl = officePreviewExts.includes(ext)
- ? `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
- fileUrl
- )}`
- : fileUrl;
-
- window.open(previewUrl, '_blank', 'noopener,noreferrer');
- };
-
const docRowSelection = computed(() => ({
selectedRowKeys: selectedDocRowKeys.value,
onChange: (keys: (string | number)[], rows: AiCloudFile[]) => {
@@ -588,119 +454,33 @@
title: '文件名称',
dataIndex: 'fileName',
key: 'fileName',
- width: 180,
+ width: 260,
ellipsis: true,
customRender: ({ record }: { record: AiCloudFile }) =>
renderDocText(record, ['fileName', 'name'])
},
- {
- title: '制度标题',
- dataIndex: 'title',
- key: 'title',
- width: 220,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['title', 'documentTitle'])
- },
- {
- title: '发文字号',
- dataIndex: 'issueNumber',
- key: 'issueNumber',
- width: 160,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['issueNumber', 'documentNo', 'fileNo'])
- },
- {
- title: '版本号(反映当前制度更新状态,如有)',
- dataIndex: 'version',
- key: 'version',
- width: 220,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text ||
- renderDocText(record, ['version', 'versionNumber', 'versionName'])
- },
- {
- title: '成文日期(落款日期)',
- dataIndex: 'documentDate',
- key: 'documentDate',
- width: 180,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['documentDate', 'signDate', 'writeDate'])
- },
- {
- title: '生效日期',
- dataIndex: 'effectiveDate',
- key: 'effectiveDate',
- width: 160,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['effectiveDate'])
- },
- {
- title: '废止日期',
- dataIndex: 'abolishDate',
- key: 'abolishDate',
- width: 160,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['abolishDate', 'invalidDate'])
- },
- {
- title: '适用业务范围',
- dataIndex: 'businessScope',
- key: 'businessScope',
- width: 220,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['businessScope'])
- },
- {
- title: '关联制度(与本制度相关的其他文件,如新旧制度间的关联文件)',
- dataIndex: 'relatedDocuments',
- key: 'relatedDocuments',
- width: 260,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text ||
- renderDocText(record, [
- 'relatedDocuments',
- 'relatedDoc',
- 'relatedFiles'
- ])
- },
- {
- title:
- '适用区域(全国/广西/南宁市等)如果是公司文档管理的模板,不需要这个字段内容',
- dataIndex: 'region',
- key: 'region',
- width: 280,
- ellipsis: true,
- customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
- text || renderDocText(record, ['region', 'applyRegion'])
- },
{
title: '下载链接',
dataIndex: 'fileUrl',
key: 'fileUrl',
- width: 220,
+ width: 360,
ellipsis: true,
customRender: ({ record }: { record: AiCloudFile }) =>
renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
},
{
- title: '备注',
- dataIndex: 'comments',
- key: 'comments',
- width: 200,
- ellipsis: true
+ title: '上传时间',
+ dataIndex: 'uploadTime',
+ key: 'uploadTime',
+ width: 180,
+ ellipsis: true,
+ customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
+ text || renderDocText(record, ['uploadTime', 'createTime'])
},
{
title: '操作',
key: 'action',
- width: 80
+ width: 100
}
]);
@@ -973,26 +753,6 @@
});
};
- const openDocEdit = (record: AiCloudFile) => {
- docForm.value = { ...record };
- showDocEdit.value = true;
- };
-
- const closeDocEdit = () => {
- showDocEdit.value = false;
- };
-
- const handleSaveDoc = async () => {
- try {
- await updateAiCloudFile(docForm.value);
- message.success('修改成功');
- closeDocEdit();
- await loadCloudFiles();
- } catch (error: any) {
- message.error(error.message || '修改失败');
- }
- };
-
// 打开导入弹窗
const openImport = () => {
if (selectedKeys.value.length === 0) {