修改文档管理表格字段
This commit is contained in:
@@ -70,7 +70,7 @@
|
||||
<a-modal
|
||||
v-model:visible="showDocManage"
|
||||
:title="`文档管理 - ${currentKbName}`"
|
||||
width="1200px"
|
||||
width="80%"
|
||||
:footer="null"
|
||||
wrap-class-name="doc-manage-modal"
|
||||
>
|
||||
@@ -159,7 +159,7 @@
|
||||
:columns="docColumns"
|
||||
:loading="docLoading"
|
||||
rowKey="id"
|
||||
:scroll="{ y: 500 }"
|
||||
:scroll="{ x: 2600, y: 500 }"
|
||||
:pagination="pagination"
|
||||
@change="handleTableChange"
|
||||
size="middle"
|
||||
@@ -223,7 +223,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref, computed } from 'vue';
|
||||
import { createVNode, ref, computed, h } from 'vue';
|
||||
import { message, Modal, Empty } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
@@ -375,40 +375,143 @@
|
||||
return allDirs.value.some((item) => item.parentId === dirId);
|
||||
};
|
||||
|
||||
// 文档表格列配置 - 去掉固定宽度,使用自适应
|
||||
const getDocFieldValue = (record: AiCloudFile, keys: string[], fallback = '-') => {
|
||||
const row = record as Record<string, any>;
|
||||
for (const key of keys) {
|
||||
const value = row[key];
|
||||
if (value !== undefined && value !== null && value !== '') {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return fallback;
|
||||
};
|
||||
|
||||
const renderDocText = (record: AiCloudFile, keys: string[]) => {
|
||||
return getDocFieldValue(record, keys);
|
||||
};
|
||||
|
||||
const renderDocLink = (record: AiCloudFile, keys: string[]) => {
|
||||
const value = getDocFieldValue(record, keys);
|
||||
if (value === '-') {
|
||||
return '-';
|
||||
}
|
||||
return h(
|
||||
'a',
|
||||
{
|
||||
href: String(value),
|
||||
target: '_blank',
|
||||
rel: 'noreferrer'
|
||||
},
|
||||
String(value)
|
||||
);
|
||||
};
|
||||
|
||||
const docColumns = ref([
|
||||
{
|
||||
title: '文件名',
|
||||
title: '文件名称',
|
||||
dataIndex: 'fileName',
|
||||
key: 'fileName',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '文件大小',
|
||||
dataIndex: 'fileSize',
|
||||
key: 'fileSize',
|
||||
width: 120,
|
||||
customRender: ({ text }: { text: string }) => {
|
||||
if (!text) return '-';
|
||||
const size = Number(text);
|
||||
if (size < 1024) return size + ' B';
|
||||
if (size < 1024 * 1024) return (size / 1024).toFixed(1) + ' KB';
|
||||
return (size / (1024 * 1024)).toFixed(1) + ' MB';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '文件类型',
|
||||
dataIndex: 'fileType',
|
||||
key: 'fileType',
|
||||
width: 120,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '上传时间',
|
||||
dataIndex: 'uploadTime',
|
||||
key: 'uploadTime',
|
||||
width: 180,
|
||||
customRender: ({ text }: { text: string }) => toDateString(text)
|
||||
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,
|
||||
ellipsis: true,
|
||||
customRender: ({ record }: { record: AiCloudFile }) =>
|
||||
renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
width: 200,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<a-modal
|
||||
v-model:visible="showDocManage"
|
||||
:title="`文档管理 - ${currentKbName}`"
|
||||
width="1200px"
|
||||
width="80%"
|
||||
:footer="null"
|
||||
wrap-class-name="doc-manage-modal"
|
||||
>
|
||||
@@ -140,7 +140,7 @@
|
||||
:columns="docColumns"
|
||||
:loading="docLoading"
|
||||
rowKey="id"
|
||||
:scroll="{ y: 500 }"
|
||||
:scroll="{ x: 2600, y: 500 }"
|
||||
:pagination="pagination"
|
||||
@change="handleTableChange"
|
||||
size="middle"
|
||||
@@ -198,7 +198,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref, computed } from 'vue';
|
||||
import { createVNode, ref, computed, h } from 'vue';
|
||||
import { message, Modal, Empty } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined, PlusOutlined, UploadOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
@@ -318,40 +318,129 @@
|
||||
} : null;
|
||||
});
|
||||
|
||||
const getDocFieldValue = (record: AiCloudFile, keys: string[], fallback = '-') => {
|
||||
const row = record as Record<string, any>;
|
||||
for (const key of keys) {
|
||||
const value = row[key];
|
||||
if (value !== undefined && value !== null && value !== '') {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return fallback;
|
||||
};
|
||||
|
||||
const renderDocText = (record: AiCloudFile, keys: string[]) => {
|
||||
return getDocFieldValue(record, keys);
|
||||
};
|
||||
|
||||
const renderDocLink = (record: AiCloudFile, keys: string[]) => {
|
||||
const value = getDocFieldValue(record, keys);
|
||||
if (value === '-') {
|
||||
return '-';
|
||||
}
|
||||
return h('a', {
|
||||
href: String(value),
|
||||
target: '_blank',
|
||||
rel: 'noreferrer'
|
||||
}, String(value));
|
||||
};
|
||||
|
||||
// 文档表格列配置
|
||||
const docColumns = ref([
|
||||
{
|
||||
title: '文件名',
|
||||
title: '文件名称',
|
||||
dataIndex: 'fileName',
|
||||
key: 'fileName',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '文件大小',
|
||||
dataIndex: 'fileSize',
|
||||
key: 'fileSize',
|
||||
width: 120,
|
||||
customRender: ({ text }: { text: string }) => {
|
||||
if (!text) return '-';
|
||||
const size = Number(text);
|
||||
if (size < 1024) return size + ' B';
|
||||
if (size < 1024 * 1024) return (size / 1024).toFixed(1) + ' KB';
|
||||
return (size / (1024 * 1024)).toFixed(1) + ' MB';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '文件类型',
|
||||
dataIndex: 'fileType',
|
||||
key: 'fileType',
|
||||
width: 120,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '上传时间',
|
||||
dataIndex: 'uploadTime',
|
||||
key: 'uploadTime',
|
||||
width: 180,
|
||||
customRender: ({ text }: { text: string }) => toDateString(text)
|
||||
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,
|
||||
ellipsis: true,
|
||||
customRender: ({ record }: { record: AiCloudFile }) => renderDocLink(record, ['fileUrl', 'downloadUrl', 'url'])
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
width: 200,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
|
||||
Reference in New Issue
Block a user