system-copyright-react/src/route/Refun/Refun.tsx

314 lines
10 KiB
TypeScript
Raw Normal View History

2024-08-22 16:33:01 +08:00
import './refun.css';
2024-08-22 18:28:15 +08:00
import { useState, useEffect } from 'react';
import {
Table,
2024-08-22 16:33:01 +08:00
// Pagination,
2024-08-22 18:28:15 +08:00
Modal, Tag, message
} from 'antd';
import { get,put } from '../../util/AjaxUtils'
2024-08-22 16:33:01 +08:00
import type { TableProps } from 'antd';
interface DataType {
2024-08-22 18:28:15 +08:00
projName: string;
projPayment: string;
refundReason: string;
gmtCreate: string;
refundVoucherFileKVs: string;
projRefundApplyId: string;
gmtReview: string;
applyStatus: string;
reviewReason: string;
2024-08-22 16:33:01 +08:00
}
import revokeImg from '../../static/revoke.png'
import { useLocation } from 'react-router-dom'
export default function Refun() {
const height = window.innerHeight - 180;
const [messageApi, contextHolder] = message.useMessage();
const [page, setPage] = useState(1) // 分页
const [total, setTotal] = useState(50) // 数据总数
2024-08-22 18:28:15 +08:00
const [data, setData] = useState<any[]>([])
2024-08-22 16:33:01 +08:00
const [revokeModal, setRevokeModal] = useState(false) //撤销弹窗
2024-08-22 18:28:15 +08:00
const [projRefundApplyId, setprojRefundApplyId] = useState('') //要撤销的id
2024-08-22 16:33:01 +08:00
const { state } = useLocation()
// {state.type}
const columns: TableProps<DataType>['columns'] = state.type == 'CANCELED' ? [
{
title: '序号',
dataIndex: 'index',
align: 'center',
width: 80,
render: (_text, _record, index) => (page - 1) * 10 + index + 1, // 显示序号从1开始
},
{
title: '系统名称',
2024-08-22 18:28:15 +08:00
dataIndex: 'projName',
2024-08-22 16:33:01 +08:00
align: 'center',
2024-08-22 18:28:15 +08:00
key: 'projName',
2024-08-22 16:33:01 +08:00
render: (text) => <div className='ellipsis-text' title={text}>{text}</div>,
},
{
title: '金额',
2024-08-22 18:28:15 +08:00
dataIndex: 'projPayment',
key: 'projPayment',
2024-08-22 16:33:01 +08:00
align: 'center',
width: 150,
},
{
title: '退款原因',
2024-08-22 18:28:15 +08:00
dataIndex: 'refundReason',
key: 'refundReason',
2024-08-22 16:33:01 +08:00
align: 'center',
render: (text) => <div className='ellipsis-text' title={text}>{text}</div>,
},
{
title: '申请退款时间',
2024-08-22 18:28:15 +08:00
dataIndex: 'gmtCreate',
key: 'gmtCreate',
2024-08-22 16:33:01 +08:00
align: 'center',
2024-08-22 18:28:15 +08:00
width: 200,
2024-08-22 16:33:01 +08:00
},
{
title: '审核时间',
2024-08-22 18:28:15 +08:00
dataIndex: 'gmtReview',
key: 'gmtReview',
2024-08-22 16:33:01 +08:00
align: 'center',
2024-08-22 18:28:15 +08:00
width: 200,
2024-08-22 16:33:01 +08:00
},
{
title: '审核状态',
2024-08-22 18:28:15 +08:00
dataIndex: 'applyStatus',
key: 'applyStatus',
2024-08-22 16:33:01 +08:00
align: 'center',
width: 100,
render: (text) => <Tag
color={text == "PASS" ? '#87d068' : text == "NOPASS" ? '#f50' : text == "WAIT" ? '#2db7f5' : ''}
>{text == "PASS" ? '通过' : text == "NOPASS" ? '未通过' : text == "WAIT" ? '待审核' : '未知'}</Tag>,
},
{
title: '审核意见',
2024-08-22 18:28:15 +08:00
dataIndex: 'reviewReason',
key: 'reviewReason',
2024-08-22 16:33:01 +08:00
align: 'center',
// width: 150,
render: (text) => <div className='ellipsis-text' title={text}>{text}</div>,
},
{
title: '退款凭证',
2024-08-22 18:28:15 +08:00
dataIndex: 'refundVoucherFileKVs',
key: 'refundVoucherFileKVs',
2024-08-22 16:33:01 +08:00
width: 100,
align: 'center',
render: (_, record) => (
// {record.name}
<div className='refunBtn' onClick={() => {
2024-08-22 18:28:15 +08:00
// console.log(record.img);
2024-08-22 16:33:01 +08:00
}}> </div>
),
},
] : [
{
title: '序号',
dataIndex: 'index',
align: 'center',
width: 80,
render: (_text, _record, index) => (page - 1) * 10 + index + 1, // 显示序号从1开始
},
{
title: '系统名称',
2024-08-22 18:28:15 +08:00
dataIndex: 'projName',
2024-08-22 16:33:01 +08:00
align: 'center',
2024-08-22 18:28:15 +08:00
key: 'projName',
2024-08-22 16:33:01 +08:00
render: (text) => <div className='ellipsis-text' title={text}>{text}</div>,
},
{
title: '金额',
2024-08-22 18:28:15 +08:00
dataIndex: 'projPayment',
key: 'projPayment',
2024-08-22 16:33:01 +08:00
align: 'center',
width: 150,
},
{
title: '退款原因',
2024-08-22 18:28:15 +08:00
dataIndex: 'refundReason',
key: 'refundReason',
2024-08-22 16:33:01 +08:00
align: 'center',
render: (text) => <div className='ellipsis-text' title={text}>{text}</div>,
},
{
title: '申请退款时间',
2024-08-22 18:28:15 +08:00
dataIndex: 'gmtCreate',
key: 'gmtCreate',
2024-08-22 16:33:01 +08:00
align: 'center',
2024-08-22 18:28:15 +08:00
width: 200,
2024-08-22 16:33:01 +08:00
},
{
title: '审核时间',
2024-08-22 18:28:15 +08:00
dataIndex: 'gmtReview',
key: 'gmtReview',
2024-08-22 16:33:01 +08:00
align: 'center',
2024-08-22 18:28:15 +08:00
width: 200,
2024-08-22 16:33:01 +08:00
},
{
title: '审核状态',
2024-08-22 18:28:15 +08:00
dataIndex: 'applyStatus',
key: 'applyStatus',
2024-08-22 16:33:01 +08:00
align: 'center',
width: 100,
render: (text) => <Tag
color={text == "PASS" ? '#87d068' : text == "NOPASS" ? '#f50' : text == "WAIT" ? '#2db7f5' : ''}
>{text == "PASS" ? '通过' : text == "NOPASS" ? '未通过' : text == "WAIT" ? '待审核' : '未知'}</Tag>,
},
{
title: '审核意见',
2024-08-22 18:28:15 +08:00
dataIndex: 'reviewReason',
key: 'reviewReason',
2024-08-22 16:33:01 +08:00
align: 'center',
// width: 150,
render: (text) => <div className='ellipsis-text' title={text}>{text}</div>,
},
{
title: '退款凭证',
2024-08-22 18:28:15 +08:00
dataIndex: 'refundVoucherFileKVs',
key: 'refundVoucherFileKVs',
2024-08-22 16:33:01 +08:00
width: 100,
align: 'center',
render: (_, record) => (
// {record.name}
<div className='refunBtn' onClick={() => {
2024-08-22 18:28:15 +08:00
// console.log(record.img);
2024-08-22 16:33:01 +08:00
}}> </div>
),
},
{
title: '操作',
align: 'center',
width: 100,
render: (_, record) => (
// {record.name}
<div className='refunBtn' onClick={() => {
2024-08-22 18:28:15 +08:00
console.log(record.projRefundApplyId);
2024-08-22 16:33:01 +08:00
setRevokeModal(true)
2024-08-22 18:28:15 +08:00
setprojRefundApplyId(record.projRefundApplyId)
2024-08-22 16:33:01 +08:00
}}> </div>
),
},
];
2024-08-22 18:28:15 +08:00
const getData = (page: number) => {
2024-08-22 16:33:01 +08:00
get({
messageApi,
url: `/api/proj/refund/apply/listpage`,
// url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`,
config: {
params: {
page: page,
rows: 10,
2024-08-22 18:28:15 +08:00
applyStatus: state.type
2024-08-22 16:33:01 +08:00
}
},
2024-08-22 18:28:15 +08:00
onSuccess(data: any) {
console.log(data.data.rows);
setData(data.data.rows)
}
})
}
// 撤销退款
const projRefund = () => {
put<any>({
messageApi,
url: `/api/proj/refund/apply/cancel/self/${projRefundApplyId}`,
onBefore() {
2024-08-22 16:33:01 +08:00
2024-08-22 18:28:15 +08:00
},
onSuccess() {
setRevokeModal(false)
messageApi.success('已撤销');
},
onFinally() {
// setIsProjIntroductionLoading(false)
// renderData()
2024-08-22 16:33:01 +08:00
}
})
}
// useEffect(()=>{
// getData(page)
// },[])
2024-08-22 18:28:15 +08:00
useEffect(() => {
2024-08-22 16:33:01 +08:00
// getData(1)
setPage(1)
getData(1)
2024-08-22 18:28:15 +08:00
}, [state.type])
2024-08-22 16:33:01 +08:00
return (
<div>
{contextHolder}
<div className='refun' style={{ height: `${height}px`, overflow: 'auto' }}>
{/* {state.type} */}
<Table columns={columns} dataSource={data}
style={{
// height: height - 80,
// height: 620,
// background: 'skyblue'
}}
// pagination={false} // 不显示分页
pagination={
{
pageSize: 10,
total: total,
onChange: (currentPage) => {
setPage(currentPage);
getData(currentPage)
},
showSizeChanger: false,
current: page
}
}
scroll={{ y: height - 128 }}
2024-08-22 18:28:15 +08:00
rowKey="projId"
2024-08-22 16:33:01 +08:00
/>
{/* <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: 15 ,width:'100%'}}>
<Pagination defaultCurrent={page} total={total} pageSize={10} showSizeChanger={false} onChange={(page) => {
setPage(page)
// getData(page)
}} />
</div> */}
</div>
<Modal
title="确认撤销"
okText="撤销"
cancelText="取消"
destroyOnClose={true}
open={revokeModal}
onOk={() => {
2024-08-22 18:28:15 +08:00
// setRevokeModal(false)
projRefund()
2024-08-22 16:33:01 +08:00
}}
onCancel={() => {
setRevokeModal(false)
}}
okButtonProps={{ style: { background: 'red', color: 'white' } }}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: `${height}px`,
}}>
<div style={{ width: 384, display: 'flex', height: 50, alignItems: 'center' }}>
<img src={revokeImg} alt="" style={{ width: 32, height: 32, marginLeft: 10 }} />
<div style={{ marginLeft: 10, fontSize: 18 }}>
退
</div>
</div>
</Modal>
</div>
)
}