From ae671e401db4b158b6bd4292fb99fab58e40844c Mon Sep 17 00:00:00 2001 From: wupengfei <834520024@qq.com> Date: 星期五, 11 四月 2025 09:14:04 +0800 Subject: [PATCH] feat: 接口 --- src/components/commonView/FourStreamsMaterialFileTable.vue | 145 +++++++++++++++++++++++++----------------------- 1 files changed, 76 insertions(+), 69 deletions(-) diff --git a/src/components/commonView/FourStreamsMaterialFileTable.vue b/src/components/commonView/FourStreamsMaterialFileTable.vue index c109630..e51d00d 100644 --- a/src/components/commonView/FourStreamsMaterialFileTable.vue +++ b/src/components/commonView/FourStreamsMaterialFileTable.vue @@ -4,12 +4,12 @@ :tableData="list" :columns="columns" :autoHeight="false" - :operationBtns="operationBtns" + :operationBtns="columnsProps.operationBtns" :operationColumnWidth="240" :showTableColumnSetting="false" > <template #fileBusinessType="{ row }"> - {{ AllEnterpriseMaterialFileBusinessTypeEnumText[row.fileBusinessType] }} + {{ FourStreamsMaterialFileBusinessTypeEnumText[row.fileBusinessType] }} </template> <template #operationBtn-uploadBtn="{ data, row }"> <BlFileUpload @@ -29,7 +29,11 @@ </template> <script setup lang="ts"> -import { FourStreamsMaterialFileTableProps, FourStreamsMaterialFileTableItem } from './types'; +import { + FourStreamsMaterialFileTableProps, + FourStreamsMaterialFileTableItem, + FourStreamsMaterialFileBusinessTypeEnumText, +} from './types'; import { ProTableV2, defineColumns, @@ -37,9 +41,9 @@ BlFileUpload, bolePreview, } from '@bole-core/components'; -import { AllEnterpriseMaterialFileBusinessTypeEnumText } from '@/constants'; import { downloadFileByUrl } from '@/utils'; import { Message, isFileCanPreview } from '@bole-core/core'; +import { useDefineColumns } from '@/hooks'; defineOptions({ name: 'FourStreamsMaterialFileTable', @@ -50,6 +54,7 @@ showCheckBtn: true, showDownloadBtn: true, showDeleteBtn: true, + downloadBtnText: '涓嬭浇', }); const list = defineModel<FourStreamsMaterialFileTableItem[]>('list'); @@ -62,81 +67,83 @@ }, ]); -const operationBtns = defineOperationBtns([ - { - data: { - enCode: 'uploadBtn', - name: '涓婁紶', - }, - extraProps: { - hide: (row: FourStreamsMaterialFileTableItem) => { - if (!props.showUploadBtn) return true; - let fileList = row?.fileList?.filter?.((item) => item.status === 'success'); - return fileList?.length > 0; +const columnsProps = useDefineColumns({ + operationBtns: [ + { + data: { + enCode: 'uploadBtn', + name: '涓婁紶', + }, + extraProps: { + hide: (row: FourStreamsMaterialFileTableItem) => { + if (!props.showUploadBtn) return true; + let fileList = row?.fileList?.filter?.((item) => item.status === 'success'); + return fileList?.length > 0; + }, }, }, - }, - { - data: { - enCode: 'detailBtn', - name: '鏌ョ湅', - }, - emits: { - onClick: (row) => handlePreview(row), - }, - extraProps: { - hide: (row: FourStreamsMaterialFileTableItem) => { - if (!props.showCheckBtn) return true; - let fileList = row?.fileList?.filter?.((item) => item.status === 'success'); - if (!fileList?.length) { - return true; - } else { - if (fileList.length > 1) { - return false; + { + data: { + enCode: 'detailBtn', + name: '鏌ョ湅', + }, + emits: { + onClick: (row) => handlePreview(row), + }, + extraProps: { + hide: (row: FourStreamsMaterialFileTableItem) => { + if (!props.showCheckBtn) return true; + let fileList = row?.fileList?.filter?.((item) => item.status === 'success'); + if (!fileList?.length) { + return true; } else { - return !isFileCanPreview(fileList[0].path); + if (fileList.length > 1) { + return false; + } else { + return !isFileCanPreview(fileList[0].path); + } } - } + }, }, }, - }, - { - data: { - enCode: 'downloadBtn', - name: '涓嬭浇', - }, - emits: { - onClick: (row) => handleBatchDownload(row), - }, - extraProps: { - hide: (row: FourStreamsMaterialFileTableItem) => { - return ( - !props.showDownloadBtn || - !row?.fileList?.filter?.((item) => item.status === 'success')?.length - ); + { + data: { + enCode: 'downloadBtn', + name: props.downloadBtnText, + }, + emits: { + onClick: (row) => handleBatchDownload(row), + }, + extraProps: { + hide: (row: FourStreamsMaterialFileTableItem) => { + return ( + !props.showDownloadBtn || + !row?.fileList?.filter?.((item) => item.status === 'success')?.length + ); + }, }, }, - }, - { - data: { - enCode: 'delBtn', - name: '鍒犻櫎', - }, - props: { - type: 'danger', - }, - emits: { - onClick: (row) => handleDelete(row), - }, - extraProps: { - hide: (row: FourStreamsMaterialFileTableItem) => { - if (!props.showDeleteBtn) return true; - let fileList = row?.fileList?.filter?.((item) => item.status === 'success'); - return !fileList?.length; + { + data: { + enCode: 'delBtn', + name: '鍒犻櫎', + }, + props: { + type: 'danger', + }, + emits: { + onClick: (row) => handleDelete(row), + }, + extraProps: { + hide: (row: FourStreamsMaterialFileTableItem) => { + if (!props.showDeleteBtn) return true; + let fileList = row?.fileList?.filter?.((item) => item.status === 'success'); + return !fileList?.length; + }, }, }, - }, -]); + ], +}); async function handleDelete(row: FourStreamsMaterialFileTableItem) { try { -- Gitblit v1.9.1