1、精简文件表格字段
2、修改pdf在线查看逻辑
This commit is contained in:
@@ -320,12 +320,11 @@
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@click="openDoc(fileItem)"
|
|
||||||
v-for="(fileItem, fileIndex) in record.workPaperIndex"
|
v-for="(fileItem, fileIndex) in record.workPaperIndex"
|
||||||
:key="fileIndex"
|
:key="fileIndex"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src="@/assets/word.png"
|
:src="getFileIcon(fileItem)"
|
||||||
style="
|
style="
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
@@ -337,17 +336,21 @@
|
|||||||
|
|
||||||
<!-- 新格式支持 -->
|
<!-- 新格式支持 -->
|
||||||
<span
|
<span
|
||||||
v-if="fileItem.fileUrl"
|
v-if="getFileInfo(fileItem).url"
|
||||||
@click.stop="handleFilePreview(fileItem)"
|
@click.stop="handleFilePreview(fileItem)"
|
||||||
class="file-link cursor-pointer text-wrap"
|
class="file-link cursor-pointer text-wrap"
|
||||||
style="color: #1890ff; text-decoration: none"
|
style="color: #1890ff; text-decoration: none"
|
||||||
>
|
>
|
||||||
{{ fileItem.fileName || '未命名文件' }}
|
{{ getFileInfo(fileItem).name || '未命名文件' }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<!-- 旧格式兼容 -->
|
<!-- 旧格式兼容 -->
|
||||||
<span v-else class="cursor-pointer text-wrap">
|
<span
|
||||||
{{ fileItem.fileName || fileItem || '未命名文件' }}
|
v-else
|
||||||
|
class="cursor-pointer text-wrap"
|
||||||
|
@click.stop="openDoc(fileItem)"
|
||||||
|
>
|
||||||
|
{{ getFileInfo(fileItem).name || '未命名文件' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2011,12 +2014,89 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const openDoc = (fileItem) => {
|
const getFileInfo = (fileItem: any) => {
|
||||||
console.log(fileItem);
|
if (typeof fileItem === 'string') {
|
||||||
// window.open(
|
const [fileId = '', fileName = '', fileUrl = ''] = fileItem.split('||');
|
||||||
// `http://view.officeapps.live.com/op/view.aspx?src=文件地址`,
|
return {
|
||||||
// '_blank'
|
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 = `
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
||||||
|
<rect width="20" height="20" rx="4" fill="${color}"/>
|
||||||
|
<text x="10" y="13" text-anchor="middle" font-size="7" font-family="Arial, sans-serif" fill="#ffffff">${label}</text>
|
||||||
|
</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) => {
|
const handleFilePreview = (fileItem: any) => {
|
||||||
console.log(
|
const file = getFileInfo(fileItem);
|
||||||
file.fileUrl,
|
if (!file.url) {
|
||||||
`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
message.warning('该文件暂无可访问地址');
|
||||||
file.fileUrl
|
return;
|
||||||
)}`
|
}
|
||||||
);
|
|
||||||
window.open(
|
if (file.ext === 'pdf') {
|
||||||
`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
window.open(file.url, '_blank', 'noopener,noreferrer');
|
||||||
file.fileUrl
|
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');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -261,19 +261,21 @@
|
|||||||
:loading="docLoading"
|
:loading="docLoading"
|
||||||
:row-selection="docRowSelection"
|
:row-selection="docRowSelection"
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
:scroll="{ x: 2600, y: 500 }"
|
:scroll="{ x: 980, y: 500 }"
|
||||||
:pagination="pagination"
|
:pagination="pagination"
|
||||||
@change="handleTableChange"
|
@change="handleTableChange"
|
||||||
size="middle"
|
size="middle"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'fileName'">
|
<template v-if="column.key === 'fileName'">
|
||||||
<a @click="openDocPreview(record)">{{ record.fileName }}</a>
|
<a
|
||||||
|
:href="getDocFileUrl(record)"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>{{ renderDocText(record, ['fileName', 'name']) }}</a>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="column.key === 'action'">
|
<template v-if="column.key === 'action'">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a @click="openDocEdit(record)">编辑</a>
|
|
||||||
<a-divider type="vertical" />
|
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
title="确定要删除此文档吗?"
|
title="确定要删除此文档吗?"
|
||||||
@confirm="deleteDoc(record)"
|
@confirm="deleteDoc(record)"
|
||||||
@@ -297,74 +299,6 @@
|
|||||||
:doc="selectedDoc"
|
:doc="selectedDoc"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<a-modal
|
|
||||||
v-model:visible="showDocEdit"
|
|
||||||
title="编辑文档"
|
|
||||||
width="700px"
|
|
||||||
@ok="handleSaveDoc"
|
|
||||||
@cancel="closeDocEdit"
|
|
||||||
>
|
|
||||||
<a-form :model="docForm" layout="vertical">
|
|
||||||
<a-row :gutter="16">
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="文件名称"
|
|
||||||
><a-input v-model:value="docForm.fileName" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="制度标题"
|
|
||||||
><a-input v-model:value="docForm.title" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="发文字号"
|
|
||||||
><a-input v-model:value="docForm.issueNumber" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="版本号"
|
|
||||||
><a-input v-model:value="docForm.version" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="成文日期"
|
|
||||||
><a-date-picker
|
|
||||||
v-model:value="docForm.documentDate"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
style="width: 100%" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="生效日期"
|
|
||||||
><a-date-picker
|
|
||||||
v-model:value="docForm.effectiveDate"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
style="width: 100%" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="废止日期"
|
|
||||||
><a-date-picker
|
|
||||||
v-model:value="docForm.abolishDate"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
style="width: 100%" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="适用业务范围"
|
|
||||||
><a-input v-model:value="docForm.businessScope" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="适用区域"
|
|
||||||
><a-input v-model:value="docForm.region" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="24"
|
|
||||||
><a-form-item label="关联制度"
|
|
||||||
><a-input v-model:value="docForm.relatedDocuments" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="24"
|
|
||||||
><a-form-item label="备注"
|
|
||||||
><a-textarea
|
|
||||||
v-model:value="docForm.comments"
|
|
||||||
:rows="3" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
</a-modal>
|
|
||||||
|
|
||||||
<!-- 新增/编辑目录弹窗 -->
|
<!-- 新增/编辑目录弹窗 -->
|
||||||
<a-modal
|
<a-modal
|
||||||
v-model:visible="showDirModal"
|
v-model:visible="showDirModal"
|
||||||
@@ -430,8 +364,7 @@
|
|||||||
} from '@/api/ai/aiCloudDoc';
|
} from '@/api/ai/aiCloudDoc';
|
||||||
import {
|
import {
|
||||||
pageAiCloudFile,
|
pageAiCloudFile,
|
||||||
removeAiCloudFile,
|
removeAiCloudFile
|
||||||
updateAiCloudFile
|
|
||||||
} from '@/api/ai/aiCloudFile';
|
} from '@/api/ai/aiCloudFile';
|
||||||
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||||
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
||||||
@@ -465,7 +398,6 @@
|
|||||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||||
const showImport = ref(false); // 是否显示导入弹窗
|
const showImport = ref(false); // 是否显示导入弹窗
|
||||||
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
||||||
const showDocEdit = ref(false);
|
|
||||||
|
|
||||||
// 文档管理相关变量
|
// 文档管理相关变量
|
||||||
const currentKbId = ref(''); // 当前知识库ID
|
const currentKbId = ref(''); // 当前知识库ID
|
||||||
@@ -495,31 +427,6 @@
|
|||||||
sortNumber: 0
|
sortNumber: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
const docForm = ref<AiCloudFile>({
|
|
||||||
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 dirModalTitle = computed(() => {
|
||||||
const mode = isEditingDir.value ? '编辑' : '新增';
|
const mode = isEditingDir.value ? '编辑' : '新增';
|
||||||
@@ -634,47 +541,6 @@
|
|||||||
return value === '-' ? '' : String(value).trim();
|
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 = () => {
|
const resetDocSelection = () => {
|
||||||
selectedDocRowKeys.value = [];
|
selectedDocRowKeys.value = [];
|
||||||
selectedDocRows.value = [];
|
selectedDocRows.value = [];
|
||||||
@@ -693,119 +559,33 @@
|
|||||||
title: '文件名称',
|
title: '文件名称',
|
||||||
dataIndex: 'fileName',
|
dataIndex: 'fileName',
|
||||||
key: 'fileName',
|
key: 'fileName',
|
||||||
width: 180,
|
width: 260,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
customRender: ({ record }: { record: AiCloudFile }) =>
|
customRender: ({ record }: { record: AiCloudFile }) =>
|
||||||
renderDocText(record, ['fileName', 'name'])
|
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: '下载链接',
|
title: '下载链接',
|
||||||
dataIndex: 'fileUrl',
|
dataIndex: 'fileUrl',
|
||||||
key: 'fileUrl',
|
key: 'fileUrl',
|
||||||
width: 220,
|
width: 360,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
customRender: ({ record }: { record: AiCloudFile }) =>
|
customRender: ({ record }: { record: AiCloudFile }) =>
|
||||||
renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
|
renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '备注',
|
title: '上传时间',
|
||||||
dataIndex: 'comments',
|
dataIndex: 'uploadTime',
|
||||||
key: 'comments',
|
key: 'uploadTime',
|
||||||
width: 200,
|
width: 180,
|
||||||
ellipsis: true
|
ellipsis: true,
|
||||||
|
customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
|
||||||
|
text || renderDocText(record, ['uploadTime', 'createTime'])
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
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 = () => {
|
const openImport = () => {
|
||||||
if (selectedKeys.value.length === 0) {
|
if (selectedKeys.value.length === 0) {
|
||||||
|
|||||||
@@ -173,23 +173,23 @@
|
|||||||
:loading="docLoading"
|
:loading="docLoading"
|
||||||
:row-selection="docRowSelection"
|
:row-selection="docRowSelection"
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
:scroll="{ x: 2600, y: 500 }"
|
:scroll="{ x: 980, y: 500 }"
|
||||||
:pagination="pagination"
|
:pagination="pagination"
|
||||||
@change="handleTableChange"
|
@change="handleTableChange"
|
||||||
size="middle"
|
size="middle"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'fileName'">
|
<template v-if="column.key === 'fileName'">
|
||||||
<a @click="openDocPreview(record)">{{
|
<a
|
||||||
|
:href="getDocFileUrl(record)"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>{{
|
||||||
renderDocText(record, ['fileName', 'name'])
|
renderDocText(record, ['fileName', 'name'])
|
||||||
}}</a>
|
}}</a>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="column.key === 'action'">
|
<template v-if="column.key === 'action'">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a @click="openDocPreview(record)">预览</a>
|
|
||||||
<a-divider type="vertical" />
|
|
||||||
<a @click="openDocEdit(record)">编辑</a>
|
|
||||||
<a-divider type="vertical" />
|
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
title="确定要删除此文档吗?"
|
title="确定要删除此文档吗?"
|
||||||
@confirm="deleteDoc(record)"
|
@confirm="deleteDoc(record)"
|
||||||
@@ -213,75 +213,6 @@
|
|||||||
:doc="selectedDoc"
|
:doc="selectedDoc"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<a-modal
|
|
||||||
v-model:visible="showDocEdit"
|
|
||||||
title="编辑文档"
|
|
||||||
width="700px"
|
|
||||||
@ok="handleSaveDoc"
|
|
||||||
@cancel="closeDocEdit"
|
|
||||||
>
|
|
||||||
<a-form :model="docForm" layout="vertical">
|
|
||||||
<a-row :gutter="16">
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="文件名称"
|
|
||||||
><a-input v-model:value="docForm.fileName" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="制度标题"
|
|
||||||
><a-input v-model:value="docForm.title" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="发文字号"
|
|
||||||
><a-input v-model:value="docForm.issueNumber" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="版本号"
|
|
||||||
><a-input v-model:value="docForm.version" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="成文日期"
|
|
||||||
><a-date-picker
|
|
||||||
v-model:value="docForm.documentDate"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
style="width: 100%" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="生效日期"
|
|
||||||
><a-date-picker
|
|
||||||
v-model:value="docForm.effectiveDate"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
style="width: 100%" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="废止日期"
|
|
||||||
><a-date-picker
|
|
||||||
v-model:value="docForm.abolishDate"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
style="width: 100%" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="适用业务范围"
|
|
||||||
><a-input v-model:value="docForm.businessScope" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="12"
|
|
||||||
><a-form-item label="适用区域"
|
|
||||||
><a-input v-model:value="docForm.region" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="24"
|
|
||||||
><a-form-item label="关联制度"
|
|
||||||
><a-input
|
|
||||||
v-model:value="docForm.relatedDocuments" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
<a-col :span="24"
|
|
||||||
><a-form-item label="备注"
|
|
||||||
><a-textarea
|
|
||||||
v-model:value="docForm.comments"
|
|
||||||
:rows="3" /></a-form-item
|
|
||||||
></a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
</a-modal>
|
|
||||||
|
|
||||||
<!-- 新增/编辑目录弹窗 -->
|
<!-- 新增/编辑目录弹窗 -->
|
||||||
<a-modal
|
<a-modal
|
||||||
v-model:visible="showDirModal"
|
v-model:visible="showDirModal"
|
||||||
@@ -347,8 +278,7 @@
|
|||||||
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||||
import {
|
import {
|
||||||
listAiCloudFile,
|
listAiCloudFile,
|
||||||
removeAiCloudFile,
|
removeAiCloudFile
|
||||||
updateAiCloudFile
|
|
||||||
} from '@/api/ai/aiCloudFile';
|
} from '@/api/ai/aiCloudFile';
|
||||||
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
||||||
|
|
||||||
@@ -370,7 +300,6 @@
|
|||||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||||
const showImport = ref(false); // 是否显示导入弹窗
|
const showImport = ref(false); // 是否显示导入弹窗
|
||||||
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
||||||
const showDocEdit = ref(false);
|
|
||||||
|
|
||||||
// 文档管理相关变量
|
// 文档管理相关变量
|
||||||
const currentKbId = ref(''); // 当前知识库ID
|
const currentKbId = ref(''); // 当前知识库ID
|
||||||
@@ -397,31 +326,6 @@
|
|||||||
sortNumber: 0
|
sortNumber: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
const docForm = ref<AiCloudFile>({
|
|
||||||
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 dirModalTitle = computed(() => {
|
||||||
const mode = isEditingDir.value ? '编辑' : '新增';
|
const mode = isEditingDir.value ? '编辑' : '新增';
|
||||||
@@ -536,44 +440,6 @@
|
|||||||
return value === '-' ? '' : String(value).trim();
|
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(() => ({
|
const docRowSelection = computed(() => ({
|
||||||
selectedRowKeys: selectedDocRowKeys.value,
|
selectedRowKeys: selectedDocRowKeys.value,
|
||||||
onChange: (keys: (string | number)[], rows: AiCloudFile[]) => {
|
onChange: (keys: (string | number)[], rows: AiCloudFile[]) => {
|
||||||
@@ -588,119 +454,33 @@
|
|||||||
title: '文件名称',
|
title: '文件名称',
|
||||||
dataIndex: 'fileName',
|
dataIndex: 'fileName',
|
||||||
key: 'fileName',
|
key: 'fileName',
|
||||||
width: 180,
|
width: 260,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
customRender: ({ record }: { record: AiCloudFile }) =>
|
customRender: ({ record }: { record: AiCloudFile }) =>
|
||||||
renderDocText(record, ['fileName', 'name'])
|
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: '下载链接',
|
title: '下载链接',
|
||||||
dataIndex: 'fileUrl',
|
dataIndex: 'fileUrl',
|
||||||
key: 'fileUrl',
|
key: 'fileUrl',
|
||||||
width: 220,
|
width: 360,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
customRender: ({ record }: { record: AiCloudFile }) =>
|
customRender: ({ record }: { record: AiCloudFile }) =>
|
||||||
renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
|
renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '备注',
|
title: '上传时间',
|
||||||
dataIndex: 'comments',
|
dataIndex: 'uploadTime',
|
||||||
key: 'comments',
|
key: 'uploadTime',
|
||||||
width: 200,
|
width: 180,
|
||||||
ellipsis: true
|
ellipsis: true,
|
||||||
|
customRender: ({ record, text }: { record: AiCloudFile; text: any }) =>
|
||||||
|
text || renderDocText(record, ['uploadTime', 'createTime'])
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
key: 'action',
|
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 = () => {
|
const openImport = () => {
|
||||||
if (selectedKeys.value.length === 0) {
|
if (selectedKeys.value.length === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user