上传文件添加pdf

This commit is contained in:
xixi 2024-09-11 15:04:59 +08:00
parent 9b7c2429cf
commit 3438db919f
2 changed files with 33 additions and 13 deletions

View File

@ -5,7 +5,7 @@ import { Form, Select, Button, Upload, message, Input, Modal, Table,Empty } from
import type { TableColumnsType } from 'antd';
const { Search } = Input;
import { UploadOutlined } from '@ant-design/icons';
import { uploadImageUrl, DevUserId, get, post } from "../../util/AjaxUtils.ts";
import { DevUserId, get, post,uploadFileUrl} from "../../util/AjaxUtils.ts";
// import { getMenuActive } from '../../util/cache.ts'
import { useDispatch } from 'react-redux'
const { TextArea } = Input;
@ -32,6 +32,13 @@ export default function CorrectionModal(props: any) {
render: (text: string) => <>{text}</>,
},
{
title: '所属者名称',
dataIndex: 'applyContactName',
align: 'center',
render: (text: string) => <>{text}</>,
},
{
title: '编号',
dataIndex: 'projContext',
@ -345,13 +352,14 @@ export default function CorrectionModal(props: any) {
rules={[{ required: true, message: '请上传补正通知书' }]}
>
<Upload
name="image"
action={uploadImageUrl()}
name="file"
action={uploadFileUrl()}
headers={{ 'X-USER-ID': DevUserId }}
beforeUpload={(file) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'|| file.type === 'application/pdf';
// const isPdf = file.type === 'application/pdf';
if (!isJpgOrPng ) {
message.error('只能上传 JPG/PNG 格式文件!');
message.error('只能上传 JPG/PNG/PDF 格式文件!');
return Upload.LIST_IGNORE; // 不允许上传非
}
return isJpgOrPng;

View File

@ -3,7 +3,7 @@ import './RefunModal.css'
import { Form, Button, Upload, message, Input, Modal, Table, Empty } from 'antd';
import type { TableColumnsType } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import { uploadImageUrl, DevUserId, get, post } from "../../util/AjaxUtils.ts";
import { DevUserId, get, post,uploadFileUrl } from "../../util/AjaxUtils.ts";
// import { getMenuActive } from '../../util/cache.ts'
import { useDispatch } from 'react-redux'
const { Search } = Input;
@ -13,7 +13,8 @@ interface DataType {
projName: string;
projContext: string;
gmtCreate: string;
projId: string
projId: string,
applyContactName: string;
}
export default function RefunModal(props: any) {
@ -32,6 +33,13 @@ export default function RefunModal(props: any) {
render: (text: string) => <>{text}</>,
},
{
title: '所属者名称',
dataIndex: 'applyContactName',
align: 'center',
render: (text: string) => <>{text}</>,
},
{
title: '编号',
dataIndex: 'projContext',
@ -238,8 +246,11 @@ export default function RefunModal(props: any) {
valuePropName="fileList"
getValueFromEvent={(e: any) => {
if (e.file.status === 'done') {
// console.log(e);
refunArray.push(e.file.response.data.fileId);
setRefunArray(refunArray);
}
if (e.file.status === 'removed') {
const idArray = refunArray.filter(item => item != e.file.response.data.fileId);
@ -250,13 +261,14 @@ export default function RefunModal(props: any) {
rules={[{ required: true, message: '请上传补正通知书' }]}
>
<Upload
name="image"
action={uploadImageUrl()}
name="file"
action={uploadFileUrl()}
headers={{ 'X-USER-ID': DevUserId }}
beforeUpload={(file) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' ||file.type === 'application/pdf';
// const isPng = file.type == 'application/pdf'
if (!isJpgOrPng ) {
message.error('只能上传 JPG/PNG 格式文件!');
message.error('只能上传 JPG/PNG/PDF 格式文件!');
return Upload.LIST_IGNORE; // 不允许上传非
}
return isJpgOrPng;