上传文件添加pdf

This commit is contained in:
xixi 2024-09-11 16:45:19 +08:00
parent c345e7af5c
commit 19dcb55b2c
5 changed files with 58 additions and 10 deletions

View File

@ -1,11 +1,11 @@
// import React from 'react'
import { useEffect, useState } from 'react'
// import './RefunModal.css'
import { Form, Select, Button, Upload, message, Input, Modal, Table,Empty } from 'antd';
import { Form, Select, Button, Upload, message, Input, Modal, Table, Empty } from 'antd';
import type { TableColumnsType } from 'antd';
const { Search } = Input;
import { UploadOutlined } from '@ant-design/icons';
import { DevUserId, get, post,uploadFileUrl} 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;
@ -100,7 +100,7 @@ export default function CorrectionModal(props: any) {
// console.log(refunArray);
// console.log(values);
post<any>({
messageApi,
url: `/api/proj/correction/apply/save`,
@ -153,6 +153,8 @@ export default function CorrectionModal(props: any) {
type: 'upCorrectionTotal',
val: data.data.total
})
}
})
}
@ -188,11 +190,13 @@ export default function CorrectionModal(props: any) {
},
})
}
useEffect(() => {
getCorrectionData()
}, [page, keywords])
return (
<div className='refunModal'>
{contextHolder}
@ -356,9 +360,9 @@ export default function CorrectionModal(props: any) {
action={uploadFileUrl()}
headers={{ 'X-USER-ID': DevUserId }}
beforeUpload={(file) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'|| file.type === 'application/pdf';
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'application/pdf';
// const isPdf = file.type === 'application/pdf';
if (!isJpgOrPng ) {
if (!isJpgOrPng) {
message.error('只能上传 JPG/PNG/PDF 格式文件!');
return Upload.LIST_IGNORE; // 不允许上传非
}
@ -394,7 +398,6 @@ export default function CorrectionModal(props: any) {
open={projModal}
onOk={
() => {
if (newprojId) {
setProjName(newprojName)

View File

@ -576,6 +576,7 @@ export default function Correction() {
const redxuState: any = useSelector(state => state)
const correctionArray = redxuState.correctionArray
const total = redxuState.correctionTotal
const newCorrection = redxuState.newCorrection
const [projCorrectionApplyId, setprojCorrectionApplyId] = useState('') //要撤销的id
// const correctionType = state?state.correctionType:''
@ -678,6 +679,19 @@ export default function Correction() {
// console.log('嘻嘻',correctionArray);
}, [keyWords, applyStatus, authorId, correctionNumType, correctionType])
useEffect(() => {
// getData(1)
if (newCorrection) {
setPage(1)
getData(1)
dispath({
type: 'newCorrection',
val: false
})
}
}, [newCorrection])
return (
<div>
{contextHolder}

View File

@ -404,7 +404,7 @@ export default function Refun() {
const redxuState: any = useSelector(state => state)
const refunArray = redxuState.refunArray
const total = redxuState.refunTotal
const newRefun = redxuState.newRefun
const getData = (page: number) => {
get({
messageApi,
@ -503,6 +503,20 @@ export default function Refun() {
// console.log(authorId);
}, [keyWords, applyStatus, authorId])
useEffect(() => {
// getData(1)
if (newRefun) {
setPage(1)
getData(1)
dispath({
type: 'newRefun',
val: false
})
}
}, [newRefun])
return (
<div>

View File

@ -1307,6 +1307,10 @@ export default function Index() {
<Button type="primary" onClick={() => {
setRefunModal(true)
refunInit()
dispath({
type: 'newRefun',
val: true
})
}}
style={{ background: '#FF9F08' }}
>
@ -1370,6 +1374,10 @@ export default function Index() {
<Button type="primary" onClick={() => {
setCorrectionModal(true)
correctionInit()
dispath({
type: 'newCorrection',
val: true
})
}}
style={{ background: '#FF9F08' }}
>
@ -1609,7 +1617,8 @@ export default function Index() {
okButtonProps={{ style: { background: 'red', color: 'white' } }}
width={592}
>
<CorrectionModal closeModal={() => { setCorrectionModal(false) }}></CorrectionModal>
<CorrectionModal closeModal={() => { setCorrectionModal(false) }}
></CorrectionModal>
</Modal>
<Modal title="优惠券"
footer={null}
@ -1682,7 +1691,7 @@ export default function Index() {
</div>
<div className='content-button' style={{
background:'#1677FF'
background: '#1677FF'
}} onClick={() => {
// props.closeModal()
receiveCoupons(item.couponId)

View File

@ -15,7 +15,9 @@ const baseState = {
correctionTotal:0,
couponModal:false,
projName:'',
projStatus:''
projStatus:'',
newRefun:false,
newCorrection:false
}
// 创建仓库
@ -54,6 +56,12 @@ const reducer = (state = baseState, action: any) => {
if (action.type == 'upProjStatus') {
nstate.projStatus = action.val
}
if (action.type == 'newRefun') {
nstate.newRefun = action.val
}
if (action.type == 'newCorrection') {
nstate.newCorrection = action.val
}
return nstate
}
const store = createStore(reducer)