feat: 文件下载
This commit is contained in:
@@ -32,7 +32,7 @@ const ModelPage = () => {
|
||||
};
|
||||
|
||||
const onFetch = async (params: { pageSize?: number; current?: number }) => {
|
||||
const data = await getModelList(params);
|
||||
const data = await getModelList({ ...params, pageNo: params.current });
|
||||
return {
|
||||
data: data.list,
|
||||
success: true,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { ProColumns } from '@ant-design/pro-components';
|
||||
import { Tag } from 'antd';
|
||||
import GroupTagSelect from '@/components/GroupTag/GroupTagSelect';
|
||||
import {
|
||||
type AiSampleRespVO,
|
||||
@@ -15,13 +16,32 @@ export const baseTenantColumns: ProColumns<AiSampleRespVO>[] = [
|
||||
{
|
||||
title: '样本名称',
|
||||
dataIndex: 'sampleName',
|
||||
// width: 500,
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '文件格式',
|
||||
width: 100,
|
||||
dataIndex: 'sampleMineType',
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
dataIndex: 'tags',
|
||||
width: 200,
|
||||
hideInSearch: true,
|
||||
render: (_, record) => {
|
||||
return record.tags?.map((tag) => {
|
||||
return <Tag key={tag.id}>{tag.tagName}</Tag>;
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '注释',
|
||||
width: 100,
|
||||
dataIndex: 'remark',
|
||||
hideInSearch: true,
|
||||
},
|
||||
|
||||
{
|
||||
title: '标签',
|
||||
hideInTable: true,
|
||||
@@ -57,11 +77,6 @@ export const baseTenantColumns: ProColumns<AiSampleRespVO>[] = [
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '样本格式',
|
||||
hideInTable: true,
|
||||
dataIndex: 'sample_mine_type',
|
||||
},
|
||||
];
|
||||
|
||||
// export const formColumns = (data: {
|
||||
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
deleteSampleTag,
|
||||
deleteSampleTagGroup,
|
||||
deleteSampleTagRelate,
|
||||
downloadSample,
|
||||
downloadZipFile,
|
||||
getSampleTagGroup,
|
||||
getSampleTagPage,
|
||||
relateSample,
|
||||
@@ -123,7 +125,22 @@ const SampleTagDetail = <T extends Record<string, any>>(
|
||||
};
|
||||
|
||||
// 下载
|
||||
const handleDownloadAll = () => {};
|
||||
const handleDownloadAll = async () => {
|
||||
const ids = data?.map((sample) => sample.id) as number[];
|
||||
downloadZipFile(ids);
|
||||
// const res = await downloadSample(ids);
|
||||
// console.log(res);
|
||||
// const downloadUrl = window.URL.createObjectURL(res);
|
||||
// const link = document.createElement("a");
|
||||
// link.href = downloadUrl;
|
||||
// link.download = downloadUrl; // 设置下载的文件名
|
||||
// link.style.display = "none";
|
||||
// document.body.appendChild(link);
|
||||
// link.click();
|
||||
// document.body.removeChild(link);
|
||||
// // const blob = new Blob([response.data], { type: 'application/pdf' });
|
||||
// // const url = window.URL.createObjectURL(blob);
|
||||
};
|
||||
|
||||
const handleTagManager = () => {
|
||||
setTagManagerVisible(true);
|
||||
@@ -158,6 +175,16 @@ const SampleTagDetail = <T extends Record<string, any>>(
|
||||
setTagManagerVisible(false);
|
||||
};
|
||||
|
||||
const onDownload = () => {
|
||||
const item = data?.[0];
|
||||
const link = document.createElement('a');
|
||||
link.href = item?.sampleFilePath;
|
||||
link.download = item?.sampleName; // 设置下载的文件名
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<ProForm name="validate_other" formRef={formRef} submitter={false}>
|
||||
@@ -312,7 +339,7 @@ const SampleTagDetail = <T extends Record<string, any>>(
|
||||
onCancel={() => setTagManagerVisible(false)}
|
||||
></TagManager>
|
||||
<Space style={{ width: '100%', justifyContent: 'center', padding: 12 }}>
|
||||
<Button color="danger" onClick={() => {}}>
|
||||
<Button color="danger" onClick={onDownload}>
|
||||
下载
|
||||
</Button>
|
||||
<Button color="danger" variant="solid" onClick={handleDeleteAll}>
|
||||
|
||||
@@ -58,6 +58,7 @@ const SampleTag: React.FC = () => {
|
||||
const onFetch = async (params: SampleReqVo) => {
|
||||
const data = await getSamplePage({
|
||||
...params,
|
||||
pageNo: params.current,
|
||||
});
|
||||
return {
|
||||
data: data.list,
|
||||
@@ -86,7 +87,7 @@ const SampleTag: React.FC = () => {
|
||||
headerTitle="样本列表"
|
||||
showIndex={false}
|
||||
enableRowClick={true}
|
||||
scroll={{ x: 'max-content' }}
|
||||
scroll={{ x: 400 }}
|
||||
rowSelection={{
|
||||
type: selectTableType,
|
||||
selectedRowKeys: selectedRows.map((item) => item.id) as React.Key[],
|
||||
|
||||
Reference in New Issue
Block a user