import React from 'react' import { useState, useEffect, } from 'react'; import { Table, // Pagination, Modal, Tag, message, Spin } from 'antd'; import { useSelector, useDispatch } from 'react-redux' import { get, put, downloadUrl } from '../../util/AjaxUtils' import type { TableProps } from 'antd'; import { getMenuActive } from '../../util/cache' import { useNavigate } from "react-router-dom"; interface DataType { projName: string; type: string; //类型 correctionType: string; //补正类型 correctionReason: string; gmtCreate: string; //补正时间 gmtReview: string;//审核时间 reviewReason: string;//审核意见 projId: string; applyStatus: string;//审核状态 correctionVoucherFileKVs: any //补正凭证 projCorrectionApplyId: string } import revokeImg from '../../static/revoke.png' import { useLocation } from 'react-router-dom' export default function Correction() { const height = window.innerHeight - 180; const [messageApi, contextHolder] = message.useMessage(); const nav = useNavigate(); const { state } = useLocation() const MenuActive = getMenuActive() == 'Correction-PENDING' ? 'PENDING' : getMenuActive() == 'Correction-APPROVED' ? 'APPROVED' : getMenuActive() == 'Correction-REJECTED' ? 'REJECTED' : getMenuActive() == 'Correction-CANCELED' ? 'CANCELED' : '' const type = state ? state.type : MenuActive const [isLoading, setIsLoading] = useState(false) const [page, setPage] = useState(1) // 分页 const [revokeModal, setRevokeModal] = useState(false) //撤销弹窗 const columns: TableProps['columns'] = // 撤销状态 type == 'CANCELED' ? [ { title: '序号', dataIndex: 'index', align: 'center', width: 80, render: (_text, _record, index) => (page - 1) * 20 + index + 1, // 显示序号,从1开始 }, { title: '系统名称', dataIndex: 'projName', align: 'center', key: 'projName', render: (text) =>
{text}
, }, { title: '类型', dataIndex: 'type', key: 'type', align: 'center', render: (text) =>
{text=='CORRECTION1'?'一次补正':text=='CORRECTION2'?'二次补正':''}
, }, { title: '补正类型', dataIndex: 'correctionType', key: 'correctionType', align: 'center', render: (text) =>
{text=='CODE'?'代码':text=='MANUAL'?'操作手册':''}
, }, { title: '补正原因', dataIndex: 'correctionReason', key: 'correctionReason', align: 'center', 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: 'correctionVoucherFileKVs', key: 'correctionVoucherFileKVs', // width: 100, align: 'center', render: (_, record) => ( (record.correctionVoucherFileKVs).map((item: any, index: number) => (
{ window.open(downloadUrl(item.key, false), '_blank') }}>{item.value}
)) ), }, ] : type == 'PENDING' ? // PENDING待审核状态 [ { title: '序号', dataIndex: 'index', align: 'center', width: 80, render: (_text, _record, index) => (page - 1) * 10 + index + 1, // 显示序号,从1开始 }, { title: '系统名称', dataIndex: 'projName', align: 'center', key: 'projName', render: (text) =>
{text}
, }, { title: '类型', dataIndex: 'type', key: 'type', align: 'center', render: (text) =>
{text=='CORRECTION1'?'一次补正':text=='CORRECTION2'?'二次补正':''}
, }, { title: '补正类型', dataIndex: 'correctionType', key: 'correctionType', align: 'center', render: (text) =>
{text=='CODE'?'代码':text=='MANUAL'?'操作手册':''}
, }, { title: '补正原因', dataIndex: 'correctionReason', key: 'correctionReason', align: 'center', 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: 'correctionVoucherFileKVs', key: 'correctionVoucherFileKVs', // width: 100, align: 'center', render: (_, record) => ( (record.correctionVoucherFileKVs).map((item: any, index: number) => (
{ window.open(downloadUrl(item.key, false), '_blank') }}>{item.value}
)) ), }, { title: '操作', align: 'center', width: 100, render: (_, record) => ( // {record.name}
{ // console.log(record.projRefundApplyId); setRevokeModal(true) setprojCorrectionApplyId(record.projCorrectionApplyId) }}> 撤销
), }, ] : // 已通过 和未通过 状态 [ { title: '序号', dataIndex: 'index', align: 'center', width: 80, render: (_text, _record, index) => (page - 1) * 10 + index + 1, // 显示序号,从1开始 }, { title: '系统名称', dataIndex: 'projName', align: 'center', key: 'projName', render: (text) =>
{text}
, }, { title: '类型', dataIndex: 'type', key: 'type', align: 'center', render: (text) =>
{text=='CORRECTION1'?'一次补正':text=='CORRECTION2'?'二次补正':''}
, }, { title: '补正类型', dataIndex: 'correctionType', key: 'correctionType', align: 'center', render: (text) =>
{text=='CODE'?'代码':text=='MANUAL'?'操作手册':''}
, }, { title: '补正原因', dataIndex: 'correctionReason', key: 'correctionReason', align: 'center', render: (text) =>
{text}
, }, { title: '申请补正时间', dataIndex: 'gmtCreate', key: 'gmtCreate', align: 'center', width: 200, }, { title: '审核时间', dataIndex: 'gmtReview', key: 'gmtReview', 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: 'reviewReason', key: 'reviewReason', align: 'center', // width: 150, render: (text) =>
{text ? text : '—'}
, }, { title: '补正凭证', dataIndex: 'correctionVoucherFileKVs', key: 'correctionVoucherFileKVs', // width: 100, align: 'center', render: (_, record) => ( (record.correctionVoucherFileKVs).map((item: any, index: number) => (
{ window.open(downloadUrl(item.key, false), '_blank') }}>{item.value}
)) ), }, ]; const dispath = useDispatch() const redxuState: any = useSelector(state => state) const correctionArray = redxuState.correctionArray const total = redxuState.correctionTotal const [projCorrectionApplyId, setprojCorrectionApplyId] = useState('') //要撤销的id const getData = (page: number) => { get({ messageApi, url: `/api/proj/correction/apply/listpage`, // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`, config: { params: { page: page, rows: 20, applyStatus: type } }, onBefore() { setIsLoading(true) }, onSuccess(data: any) { // console.log('呵呵', data.data.rows); // setData(data.data.rows) dispath({ type: 'upCorrectionArray', val: data.data.rows }) dispath({ type: 'upCorrectionTotal', val: data.data.total }) // setTotal(data.data.total) }, onFinally() { setIsLoading(false) }, }) } // 撤销补正 const projRefund = () => { put({ messageApi, url: `/api/proj/correction/apply/cancel/self/${projCorrectionApplyId}`, onBefore() { }, onSuccess() { setRevokeModal(false) messageApi.success('已撤销'); get({ messageApi, url: `/api/proj/correction/apply/listpage`, // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`, config: { params: { page: page, rows: 20, applyStatus: type } }, 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: 'upCorrectionArray', val: data.data.rows }) dispath({ type: 'upCorrectionTotal', val: data.data.total }) } } }) }, onFinally() { // setIsProjIntroductionLoading(false) // renderData() } }) } useEffect(() => { if (!state) { nav('/home') } }, [state]) useEffect(() => { // getData(1) setPage(1) getData(1) // console.log(type); // console.log('嘻嘻',correctionArray); }, [type]) return (
{contextHolder}
{/* {state.type} */} { setPage(currentPage); getData(currentPage) }, showSizeChanger: false, current: page } } scroll={{ y: height - 150 }} rowKey="projId" />
{/* { 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`, }}>
是否撤销该条补正申请
) }