import { useState, useEffect } from 'react' 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 { DevUserId, get, post,uploadFileUrl } from "../../util/AjaxUtils.ts"; // import { getMenuActive } from '../../util/cache.ts' import { useDispatch } from 'react-redux' const { Search } = Input; const { TextArea } = Input; interface DataType { key: React.Key; projName: string; projContext: string; gmtCreate: string; projId: string, applyContactName: string; } export default function RefunModal(props: any) { const columns: TableColumnsType = [ { title: '序号', dataIndex: 'index', align: 'center', width: 80, render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始 }, { title: '项目名称', dataIndex: 'projName', align: 'center', render: (text: string) => <>{text}, }, { title: '所属者名称', dataIndex: 'applyContactName', align: 'center', render: (text: string) => <>{text}, }, { title: '编号', dataIndex: 'projContext', align: 'center', }, { title: '创建时间', dataIndex: 'gmtCreate', align: 'center', }, ]; const [messageApi, contextHolder] = message.useMessage(); // 上传附件 const [refunArray, setRefunArray] = useState([]); // const [selectedReason, setSelectedReason] = useState(''); //选择原因 // const handleReasonChange = (value: any) => { // setSelectedReason(value); // }; // 获取当前选择类型 // const type = getMenuActive() const dispath = useDispatch() // 选择项目得临时name const [newprojName, setnewprojName] = useState('') // 选择项目得name const [projName, setProjName] = useState('') // 选择得项目临时id const [newprojId, setnewProjId] = useState('') // 选择 项目的id const [projId, setProjId] = useState('') //默认选择得项目 const [selectedRowKeys, setselectedRowKeys] = useState([]) // 分页 const [page, setPage] = useState(1) const [total, setTotal] = useState(0) // 搜索关键字 const [keywords, setKeywords] = useState('') const [refunDataArray, setRefunDataArray] = useState([]) //未退款项目数组 // 选择项目弹窗 const [projModal, setProjModal] = useState(false) const [isDisabled, setIsDisabled] = useState(false) //提交按钮是否禁用 const [form] = Form.useForm(); // 关键字搜索 const handleSearch = (value: string) => { setKeywords(value) } const handleChange = (e: any) => { if (e.target.value == '') { setKeywords('') } } // 提交表单 const onFinish = (values: any) => { // console.log('Form values:', values); post({ messageApi, url: `/api/proj/refund/apply/save`, body: { projId: projId, refundReason: values.other, refundVoucher: refunArray.join(',') }, onBefore() { setIsDisabled(true) }, onSuccess() { messageApi.success('提交成功') setIsDisabled(true) setTimeout(() => { props.closeModal() }, 500) getData() }, onFinally() { setIsDisabled(false) } }) }; const getData = () => { get({ messageApi, url: `/api/proj/refund/apply/listpage/self`, config: { params: { page: 1, rows: 20, applyStatus: '' } }, onSuccess(data: any) { dispath({ type: 'upRefunArray', val: data.data.rows }) dispath({ type: 'upRefunTotal', val: data.data.total }) } }) } // 获取未退款项目 const getRefunData = () => { get({ messageApi, url: `/api/proj/refund/apply/listpage-proj-unapply/self`, config: { params: { page: page, rows: 20, keywords } }, onBefore() { }, onSuccess(data: any) { setRefunDataArray(data.data.rows) setTotal(data.data.total) }, onFinally() { }, }) } useEffect(() => { getRefunData() }, [page, keywords]) return (
{contextHolder}
退款软著*
{ setProjModal(true) setKeywords('') setPage(1) getRefunData() }}> 选择
退款原因*