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

View File

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

View File

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

View File

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

View File

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