1、精简文件表格字段
2、修改pdf在线查看逻辑
This commit is contained in:
@@ -320,12 +320,11 @@
|
||||
"
|
||||
>
|
||||
<div
|
||||
@click="openDoc(fileItem)"
|
||||
v-for="(fileItem, fileIndex) in record.workPaperIndex"
|
||||
:key="fileIndex"
|
||||
>
|
||||
<img
|
||||
src="@/assets/word.png"
|
||||
:src="getFileIcon(fileItem)"
|
||||
style="
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
@@ -337,17 +336,21 @@
|
||||
|
||||
<!-- 新格式支持 -->
|
||||
<span
|
||||
v-if="fileItem.fileUrl"
|
||||
v-if="getFileInfo(fileItem).url"
|
||||
@click.stop="handleFilePreview(fileItem)"
|
||||
class="file-link cursor-pointer text-wrap"
|
||||
style="color: #1890ff; text-decoration: none"
|
||||
>
|
||||
{{ fileItem.fileName || '未命名文件' }}
|
||||
{{ getFileInfo(fileItem).name || '未命名文件' }}
|
||||
</span>
|
||||
|
||||
<!-- 旧格式兼容 -->
|
||||
<span v-else class="cursor-pointer text-wrap">
|
||||
{{ fileItem.fileName || fileItem || '未命名文件' }}
|
||||
<span
|
||||
v-else
|
||||
class="cursor-pointer text-wrap"
|
||||
@click.stop="openDoc(fileItem)"
|
||||
>
|
||||
{{ getFileInfo(fileItem).name || '未命名文件' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 = `
|
||||
<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) => {
|
||||
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');
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -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"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<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 v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openDocEdit(record)">编辑</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此文档吗?"
|
||||
@confirm="deleteDoc(record)"
|
||||
@@ -297,74 +299,6 @@
|
||||
: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
|
||||
v-model:visible="showDirModal"
|
||||
@@ -430,8 +364,7 @@
|
||||
} from '@/api/ai/aiCloudDoc';
|
||||
import {
|
||||
pageAiCloudFile,
|
||||
removeAiCloudFile,
|
||||
updateAiCloudFile
|
||||
removeAiCloudFile
|
||||
} from '@/api/ai/aiCloudFile';
|
||||
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
||||
@@ -465,7 +398,6 @@
|
||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||
const showImport = ref(false); // 是否显示导入弹窗
|
||||
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
||||
const showDocEdit = ref(false);
|
||||
|
||||
// 文档管理相关变量
|
||||
const currentKbId = ref(''); // 当前知识库ID
|
||||
@@ -495,31 +427,6 @@
|
||||
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 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) {
|
||||
|
||||
@@ -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"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'fileName'">
|
||||
<a @click="openDocPreview(record)">{{
|
||||
<a
|
||||
:href="getDocFileUrl(record)"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>{{
|
||||
renderDocText(record, ['fileName', 'name'])
|
||||
}}</a>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openDocPreview(record)">预览</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="openDocEdit(record)">编辑</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此文档吗?"
|
||||
@confirm="deleteDoc(record)"
|
||||
@@ -213,75 +213,6 @@
|
||||
: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
|
||||
v-model:visible="showDirModal"
|
||||
@@ -347,8 +278,7 @@
|
||||
import type { AiCloudDoc } from '@/api/ai/aiCloudDoc/model';
|
||||
import {
|
||||
listAiCloudFile,
|
||||
removeAiCloudFile,
|
||||
updateAiCloudFile
|
||||
removeAiCloudFile
|
||||
} from '@/api/ai/aiCloudFile';
|
||||
import type { AiCloudFile } from '@/api/ai/aiCloudFile/model';
|
||||
|
||||
@@ -370,7 +300,6 @@
|
||||
const showDocManage = ref(false); // 是否显示文档管理弹窗
|
||||
const showImport = ref(false); // 是否显示导入弹窗
|
||||
const showDirModal = ref(false); // 是否显示目录弹窗(新增/编辑)
|
||||
const showDocEdit = ref(false);
|
||||
|
||||
// 文档管理相关变量
|
||||
const currentKbId = ref(''); // 当前知识库ID
|
||||
@@ -397,31 +326,6 @@
|
||||
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 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) {
|
||||
|
||||
Reference in New Issue
Block a user