diff --git a/src/components/CorrectionModal/CorrectionModal.tsx b/src/components/CorrectionModal/CorrectionModal.tsx new file mode 100644 index 0000000..4daa2b8 --- /dev/null +++ b/src/components/CorrectionModal/CorrectionModal.tsx @@ -0,0 +1,304 @@ +import React from 'react' +import { useEffect, useState } from 'react' +// import './RefunModal.css' +import { Form, Select, Button, Upload, message, Input } from 'antd'; +import { UploadOutlined } from '@ant-design/icons'; +import { uploadImageUrl, DevUserId, get, post } from "../../util/AjaxUtils.ts"; +import { getMenuActive } from '../../util/cache.ts' +import { useDispatch } from 'react-redux' +const { TextArea } = Input; +export default function CorrectionModal(props: any) { + const [messageApi, contextHolder] = message.useMessage(); + // 上传附件 + const [correctionArray, setCorrectionArray] = useState([]); + // const [selectedReason, setSelectedReason] = useState(''); //选择原因 + + // const handleReasonChange = (value: any) => { + // setSelectedReason(value); + // }; + // 获取当前选择类型 + const type = getMenuActive() == 'Correction-PENDING' ? 'PENDING' : getMenuActive() == 'Correction-APPROVED' ? 'APPROVED' : getMenuActive() == 'Correction-REJECTED' ? 'REJECTED' : getMenuActive() == 'Correction-CANCELED' ? 'CANCELED' : '' + const dispath = useDispatch() + const [correctionDataArray, setCorrectionDataArray] = useState([]) //未退款项目 + const [isDisabled,setIsDisabled] = useState(false) //提交按钮是否禁用 + // 提交表单 + const onFinish = (values: any) => { + // console.log('Form values:', values); + + // console.log(refunArray); + + + post({ + messageApi, + url: `/api/proj/correction/apply/save`, + body: { + projId: values.title, + correctionReason: values.other, + correctionVoucher: correctionArray.join(','), + correctionType:values.correctionType + }, + onBefore() { + setIsDisabled(true) + }, + onSuccess() { + messageApi.success('提交成功') + setIsDisabled(true) + setTimeout(() => { + props.closeModal() + + }, 500) + if (type === 'PENDING') { + getData() + + } + + }, + onFinally() { + setIsDisabled(false) + } + }) + }; + const getData = () => { + get({ + messageApi, + url: `/api/proj/correction/apply/listpage`, + // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`, + config: { + params: { + page: 1, + rows: 20, + applyStatus: type + } + }, + onSuccess(data: any) { + // console.log('更新'); + + dispath({ + type: 'upCorrectionArray', + val: data.data.rows + }) + dispath({ + type: 'upCorrectionTotal', + val: data.data.total + }) + } + }) + } + // 获取未补正项目 + const getCorrectionData = () => { + get({ + messageApi, + url: `/api/proj/correction/apply/list-proj-unapply/self`, + // config: { + // params: { + + // } + // }, + onBefore() { + + + }, + onSuccess(data: any) { + // console.log(data); + const newArray = (data.data).map((item: { projId: any; projName: any; }) => ({ + value: item.projId, + label: item.projName + })) + setCorrectionDataArray(newArray) + + }, + onFinally() { + + + }, + }) + } + useEffect(() => { + getCorrectionData() + // console.log(type); + + }, []) + return ( +
+ {contextHolder} +
+
+
+ 补正软著* +
+ + + +
+ {/*
+
+ 退款原因* +
+ +