feat:文件请求接口

main
chunquansang 1 year ago
parent 4bba679cb0
commit 4abab076d7

@ -10,6 +10,7 @@ import { Form, Image } from 'antd';
import React, { useState } from 'react'; import React, { useState } from 'react';
// @ts-ignore // @ts-ignore
import cookie from 'react-cookies'; import cookie from 'react-cookies';
import axios from 'axios';
const ShowInfoDemo: React.FC = () => { const ShowInfoDemo: React.FC = () => {
const [form] = Form.useForm<API.ModelImage>(); const [form] = Form.useForm<API.ModelImage>();
const [imageUrl, setImageUrl] = useState<string>(''); const [imageUrl, setImageUrl] = useState<string>('');
@ -27,7 +28,7 @@ const ShowInfoDemo: React.FC = () => {
<ProFormUploadDragger <ProFormUploadDragger
width={800} width={800}
name="projectFilePath" name="projectFilePath"
action="/api/v1/file/uploadFile" action="/api/v1/common/upload_file/"
max={1} max={1}
fieldProps={{ fieldProps={{
showUploadList: false, showUploadList: false,
@ -47,10 +48,8 @@ const ShowInfoDemo: React.FC = () => {
maxCount: 1, maxCount: 1,
name: 'file', name: 'file',
// beforeUpload: beforeUploadFile, // beforeUpload: beforeUploadFile,
data: { path: 'project/files' },
headers: { headers: {
'X-CSRFToken': cookie.load('csrftoken'), 'X-CSRFToken': cookie.load('csrftoken'),
Authorization: `Bearer ${localStorage.getItem('access') || ''}`,
}, },
}} }}
> >
@ -72,6 +71,7 @@ const ShowInfoDemo: React.FC = () => {
} // 配置 submitter } // 配置 submitter
> >
<ProFormSelect <ProFormSelect
style={{width: 160}}
fieldProps={{ fieldProps={{
labelInValue: true, labelInValue: true,
}} }}
@ -88,7 +88,7 @@ const ShowInfoDemo: React.FC = () => {
if (name1) { if (name1) {
console.log(name1, 'ProFormDependency_name1'); console.log(name1, 'ProFormDependency_name1');
return ( return (
<ProFormText label={name1.label} name={name1.value} disabled required={false} /> <ProFormText width={160} label={name1.label} name={name1.value} disabled required={false}/>
); );
} }
return <></>; return <></>;

Loading…
Cancel
Save