import './refun.css'; import { useState, useEffect, } from 'react'; import { // Table, Pagination, Modal, // Tag, message, Spin, Empty, Dropdown } from 'antd'; import { useSelector, useDispatch } from 'react-redux' import { get, put, downloadUrl } from '../../util/AjaxUtils' // import type { TableProps } from 'antd'; import { useLocation } from 'react-router-dom'; // import { useNavigate } from "react-router-dom"; // interface DataType { // projName: string; // projPayment: number; // refundReason: string; // gmtCreate: string; // refundVoucherFileKVs: any; // projRefundApplyId: string; // gmtReview: string; // applyStatus: string; // reviewReason: string; // projId: string; // authorName: string; // } import revokeImg from '../../static/revoke.png' import logoImg from '../../static/projBox/logo.png' import reason from '../../static/projBox/reson.png' import green from '../../static/projBox/green.png' import red from '../../static/projBox/red.png' import blue from '../../static/projBox/blue.png' import black from '../../static/projBox/black.png' export default function Refun() { const { state } = useLocation() const height = window.innerHeight - 180; const [messageApi, contextHolder] = message.useMessage(); const [isLoading, setIsLoading] = useState(false) const [page, setPage] = useState(1) // 分页 // const [total, setTotal] = useState(0) // 数据总数 // const [data, setData] = useState([]) const [revokeModal, setRevokeModal] = useState(false) //撤销弹窗 const [projRefundApplyId, setprojRefundApplyId] = useState('') //要撤销的id const keyWords = state ? state.keywords : '' const applyStatus = state ? state.applyStatus : '' const authorId = state ? state.authorId : '' // setMenuActive(type) // {state.type} // const columns: TableProps['columns'] = // // 撤销状态 // applyStatus == 'CANCELED' ? [ // { // title: '序号', // dataIndex: 'index', // align: 'center', // width: 80, // fixed: 'left', // render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始 // }, // { // title: '系统名称', // dataIndex: 'projName', // align: 'center', // key: 'projName', // width: 150, // fixed: 'left', // render: (text) =>
{text}
, // }, // { // title: '产权所属者', // dataIndex: 'authorName', // align: 'center', // key: 'authorName', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '金额', // dataIndex: 'projPayment', // key: 'projPayment', // align: 'center', // width: 100, // render: (text) =>
{(text / 100).toFixed(2)}
// }, // { // title: '退款原因', // dataIndex: 'refundReason', // key: 'refundReason', // align: 'center', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '申请退款时间', // dataIndex: 'gmtCreate', // key: 'gmtCreate', // align: 'center', // width: 200, // }, // { // title: '审核状态', // dataIndex: 'applyStatus', // key: 'applyStatus', // align: 'center', // width: 100, // render: (text) => {text == "APPROVED" ? '已通过' : text == "REJECTED" ? '未通过' : text == "PENDING" ? '待审核' : text == "CANCELED" ? '已取消' : '未知'}, // }, // { // title: '退款凭证', // dataIndex: 'refundVoucherFileKVs', // key: 'refundVoucherFileKVs', // width: 150, // align: 'center', // render: (_, record) => ( // (record.refundVoucherFileKVs).map((item: any, index: number) => ( //
{ // window.open(downloadUrl(item.key, false), '_blank') // }}>{item.value}
// )) // ), // }, // ] // : applyStatus == 'PENDING' ? // // PENDING待审核状态 // [ // { // title: '序号', // dataIndex: 'index', // align: 'center', // width: 80, // fixed: 'left', // render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始 // }, // { // title: '系统名称', // dataIndex: 'projName', // align: 'center', // key: 'projName', // fixed: 'left', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '产权所属者', // dataIndex: 'authorName', // align: 'center', // key: 'authorName', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '金额', // dataIndex: 'projPayment', // key: 'projPayment', // align: 'center', // width: 100, // render: (text) =>
{(text / 100).toFixed(2)}
, // }, // { // title: '退款原因', // dataIndex: 'refundReason', // key: 'refundReason', // align: 'center', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '申请退款时间', // dataIndex: 'gmtCreate', // key: 'gmtCreate', // align: 'center', // width: 200, // }, // { // title: '审核状态', // dataIndex: 'applyStatus', // key: 'applyStatus', // align: 'center', // width: 100, // render: (text) => {text == "APPROVED" ? '通过' : text == "REJECTED" ? '未通过' : text == "PENDING" ? '待审核' : text == "CANCELED" ? '已取消' : '未知'}, // }, // { // title: '退款凭证', // dataIndex: 'refundVoucherFileKVs', // key: 'refundVoucherFileKVs', // width: 150, // align: 'center', // render: (_, record) => ( // // {record.name} // //
{ // // console.log(record.refundVoucherFileKVs); // // }}> 预览
// (record.refundVoucherFileKVs).map((item: any, index: number) => ( //
{ // window.open(downloadUrl(item.key, false), '_blank') // }}>{item.value}
// )) // ), // }, // { // title: '操作', // fixed: 'right', // align: 'center', // width: 100, // render: (_, record) => ( // // {record.name} //
{ // // console.log(record.projRefundApplyId); // setRevokeModal(true) // setprojRefundApplyId(record.projRefundApplyId) // }}> 撤销
// ), // }, // ] // : applyStatus == 'APPROVED' || applyStatus == 'REJECTED' ? // // 已通过 和未通过 状态 // [ // { // title: '序号', // dataIndex: 'index', // align: 'center', // width: 80, // fixed: 'left', // render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始 // }, // { // title: '系统名称', // dataIndex: 'projName', // align: 'center', // key: 'projName', // fixed: 'left', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '产权所属者', // dataIndex: 'authorName', // align: 'center', // key: 'authorName', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '金额', // dataIndex: 'projPayment', // key: 'projPayment', // align: 'center', // width: 100, // render: (text) =>
{(text / 100).toFixed(2)}
, // }, // { // title: '退款原因', // dataIndex: 'refundReason', // key: 'refundReason', // align: 'center', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '申请退款时间', // dataIndex: 'gmtCreate', // key: 'gmtCreate', // align: 'center', // width: 200, // }, // { // title: '审核时间', // dataIndex: 'gmtReview', // key: 'gmtReview', // align: 'center', // width: 200, // render: (text) =>
// {text ? text : '—'} //
// }, // { // title: '审核状态', // dataIndex: 'applyStatus', // key: 'applyStatus', // align: 'center', // width: 100, // render: (text) => {text == "APPROVED" ? '通过' : text == "REJECTED" ? '未通过' : text == "PENDING" ? '待审核' : text == "CANCELED" ? '已取消' : '未知'}, // }, // { // title: '审核意见', // dataIndex: 'reviewReason', // key: 'reviewReason', // align: 'center', // width: 150, // render: (text) =>
{text ? text : '—'}
, // }, // { // title: '退款凭证', // dataIndex: 'refundVoucherFileKVs', // key: 'refundVoucherFileKVs', // width: 150, // align: 'center', // render: (_, record) => ( // (record.refundVoucherFileKVs).map((item: any, index: number) => ( //
{ // window.open(downloadUrl(item.key, false), '_blank') // }}>{item.value}
// )) // ), // }, // ] : [ // { // title: '序号', // dataIndex: 'index', // align: 'center', // width: 80, // render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始 // fixed: 'left', // }, // { // title: '系统名称', // dataIndex: 'projName', // align: 'center', // key: 'projName', // fixed: 'left', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '产权所属者', // dataIndex: 'authorName', // align: 'center', // key: 'authorName', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '金额', // dataIndex: 'projPayment', // key: 'projPayment', // align: 'center', // width: 100, // render: (text) =>
{(text / 100).toFixed(2)}
, // }, // { // title: '退款原因', // dataIndex: 'refundReason', // key: 'refundReason', // align: 'center', // width: 150, // render: (text) =>
{text}
, // }, // { // title: '申请退款时间', // dataIndex: 'gmtCreate', // key: 'gmtCreate', // align: 'center', // width: 200, // }, // { // title: '审核时间', // dataIndex: 'gmtReview', // key: 'gmtReview', // align: 'center', // width: 200, // render: (text) =>
// {text ? text : '—'} //
// }, // { // title: '审核状态', // dataIndex: 'applyStatus', // key: 'applyStatus', // align: 'center', // width: 100, // render: (text) => {text == "APPROVED" ? '通过' : text == "REJECTED" ? '未通过' : text == "PENDING" ? '待审核' : text == "CANCELED" ? '已取消' : '未知'}, // }, // { // title: '审核意见', // dataIndex: 'reviewReason', // key: 'reviewReason', // align: 'center', // width: 150, // render: (text) =>
{text ? text : '—'}
, // }, // { // title: '退款凭证', // dataIndex: 'refundVoucherFileKVs', // key: 'refundVoucherFileKVs', // width: 150, // align: 'center', // render: (_, record) => ( // // {record.name} // //
{ // // console.log(record.refundVoucherFileKVs); // // }}> 预览
// (record.refundVoucherFileKVs).map((item: any, index: number) => ( //
{ // window.open(downloadUrl(item.key, false), '_blank') // }}>{item.value}
// )) // ), // }, // { // title: '操作', // align: 'center', // width: 100, // fixed: 'right', // render: (_, record) => ( // // {record.applyStatus}PENDING //
{record.applyStatus == 'PENDING' ? ( //
{ // // console.log(record.projRefundApplyId); // setRevokeModal(true) // setprojRefundApplyId(record.projRefundApplyId) // }}> 撤销
// ) : (<>—) // }
// //
{ // // // console.log(record.projRefundApplyId); // // setRevokeModal(true) // // setprojRefundApplyId(record.projRefundApplyId) // // }}> 撤销
// ), // }, // ] const dispath = useDispatch() const redxuState: any = useSelector(state => state) const refunArray = redxuState.refunArray const total = redxuState.refunTotal const newRefun = redxuState.newRefun const getData = (page: number) => { get({ messageApi, url: `/api/proj/refund/apply/listpage/self`, // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`, config: { params: { page: page, rows: 20, applyStatus: applyStatus, projName: keyWords, authorId: authorId } }, onBefore() { setIsLoading(true) }, onSuccess(data: any) { // console.log(data.data.rows); // setData(data.data.rows) dispath({ type: 'upRefunArray', val: data.data.rows }) dispath({ type: 'upRefunTotal', val: data.data.total }) // setTotal(data.data.total) }, onFinally() { setIsLoading(false) }, }) } // 撤销退款 const projRefund = () => { put({ messageApi, url: `/api/proj/refund/apply/cancel/self/${projRefundApplyId}`, onBefore() { }, onSuccess() { setRevokeModal(false) messageApi.success('已撤销'); get({ messageApi, url: `/api/proj/refund/apply/listpage/self`, // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`, config: { params: { page: page, rows: 20, applyStatus: applyStatus, projName: keyWords, authorId: authorId } }, onSuccess(data: any) { // console.log(data.data.rows); // setData(data.data.rows) // setTotal(data.data.total) if (data.data.rows.length == 0 && page > 1) { getData(page - 1) } else { dispath({ type: 'upRefunArray', val: data.data.rows }) dispath({ type: 'upRefunTotal', val: data.data.total }) } } }) }, onFinally() { // setIsProjIntroductionLoading(false) // renderData() } }) } // useEffect(() => { // if (!state) { // nav('/home') // } // }, [state]) useEffect(() => { // getData(1) setPage(1) getData(1) // console.log(authorId); }, [keyWords, applyStatus, authorId]) useEffect(() => { // 获取id为refun的元素 const refun: any = document.getElementById('refun'); // 当更换页码时候滚动到最上面 refun.scrollTop = 0; }, [refunArray]) useEffect(() => { // getData(1) if (newRefun) { setPage(1) getData(1) dispath({ type: 'newRefun', val: false }) } }, [newRefun]) return (
{contextHolder}
{/* {state.type} */} {/* { setPage(currentPage); getData(currentPage) }, showSizeChanger: false, current: page } } locale={{ emptyText: , }} // scroll={{ }} rowKey="projRefundApplyId" /> */} {refunArray.length == 0 ?
: <> {refunArray.map((item: any, index: any) => { const voucherItems = item.refundVoucherFileKVs.map((item: any) => ({ key: item.key, label: (
{ window.open(downloadUrl(item.key, false), '_blank') }} > {item.value}
), })); return (
{/*
{(page - 1) * 20 + index + 1}
*/}
申请时间 : {item.gmtCreate}
{item.projName}
{(page - 1) * 20 + index + 1}
{item.authorName}
退款凭证
(查看)
退款原因
{item.refundReason}
{/*
{item.applyStatus}
*/}
{item.applyStatus == 'PENDING' ? '待审核' : item.applyStatus == 'CANCELED' ? '已撤销' : item.applyStatus == 'APPROVED' ? '已通过' : item.applyStatus == 'REJECTED' ? '未通过' : '未知状态'}
{item.gmtReview}
审核意见 : {item.reviewReason}
{/*
金额:{(item.projPayment / 100).toFixed(2)}元
*/}
金额:{(item.projPayment / 100)}元
{ setRevokeModal(true) setprojRefundApplyId(item.projRefundApplyId) }} style={{ display: item.applyStatus == 'PENDING' ? 'block' : 'none' }} >撤销退款
) })} }
{ setPage(page) getData(page) }} />
{ // setRevokeModal(false) projRefund() }} onCancel={() => { setRevokeModal(false) }} okButtonProps={{ style: { background: 'red', color: 'white' } }} style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', height: `${height}px`, }}>
是否撤销该条退款申请
) }