Commit 96e08733 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents d664a35f 6d2b2382
File deleted
import React, { useState, useEffect } from 'react';
import {
Button,
Input,
Table,
Typography,
Space
} from 'antd';
import { PublicApi } from '@/services/api';
import style from '../index.less';
import { IAntdSchemaFormProps } from '@formily/antd'
import EyePreview from '@/components/EyePreview';
import moment from 'moment';
export interface Iprops extends IAntdSchemaFormProps {
contractId: any
}
const { Text } = Typography;
const situationList: React.FC<Iprops> = ({ contractId }) => {
const [page, setPage] = useState(1);
const [size, setSize] = useState(10);
const [total, setTotal] = useState(0);
const [listLoading, setListLoading] = useState(false);
/* 单据总金额 */
const [orderAmount, setorderAmount] = useState<number>(0);
/* 已付款 */
const [payAmount, setpayAmount] = useState<number>(0);
/* 已请款待付款 */
const [unPayApplyAmount, setunPayApplyAmount] = useState<number>(0)
/* 待请款 */
const [unApplyAmount, setunApplyAmount] = useState<number>(0)
const [data, setdata] = useState<any>([])
/* 执行请款的选中 */
const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([])
/* 搜素 */
const onSearch = (values) => {
const data = {
contractId,
orderNo: values,
orderAbstract: '',
startTime: "",
endTime: "",
current: 1,
pageSize: 5,
}
getContracInfoList(data)
}
/* 执行情况分页 */
const getContracInfoList = (data) => {
setListLoading(true);
PublicApi.getContractExecutePageExecuteInfoList(data).then(res => {
if (res.code === 1000) {
let orderAmount = 0, payAmount = 0, unPayApplyAmount = 0, unApplyAmount = 0;
if (res.data.data) {
let list = res.data.data.map((item: any, index: number) => {
orderAmount += item.orderAmount;
payAmount += item.payAmount;
unApplyAmount += item.unApplyAmount;
unPayApplyAmount += item.unPayApplyAmount;
return {
...item,
keyId: index + 1,
}
})
setdata(list)
}
setTotal(res.data.totalCount)
setunApplyAmount(unApplyAmount)
setunPayApplyAmount(unPayApplyAmount)
setpayAmount(payAmount)
setorderAmount(orderAmount)
}
}).finally(() => {
setListLoading(false);
});
}
const rowSelection: any = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
console.log(selectedRowKeys, selectedRows)
setSelectedRowKeys(selectedRowKeys)
setSelectRow(selectedRows)
}
};
/* 查看付款明细 */
const columns: any = [
{
title: '单据号/摘要', dataIndex: 'orderNO', align: 'center',
render: (text: any, record: any) => {
return (
<div>
<EyePreview
url={`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/preview?id=${record.orderId}`}
>
{text}
</EyePreview>
<p>{record.orderAbstract}</p>
</div>
);
},
},
{
title: '单据类型', dataIndex: 'orderTypeName', align: 'center',
},
{ title: '单据状态', dataIndex: 'orderStatusName', align: 'center', },
{
title: '单据时间', dataIndex: 'orderTime', align: 'center',
render: (text: any, record: any) => {
return (
<Text>{moment(Number(text)).format('YYYY-MM-DD')}</Text>
)
}
},
{
dataIndex: 'orderAmount', align: 'center',
title: (
<Space direction='vertical'>
<Text>单据金额</Text>
<Text>合计: ¥{orderAmount}</Text>
</Space>
),
render: (text) => (
<span>{text}</span>
)
},
{
title: '含税/税率', dataIndex: 'taxRate', align: 'center',
render: (text, record) => (
<Space direction='vertical'>
<Text>{record.isHasTax == 1 ? '是' : '否'}</Text>
<Text>{text}%</Text>
</Space>
)
},
{
dataIndex: 'payAmount', align: 'center',
title: (
<Space direction='vertical'>
<Text>已付款</Text>
<Text>合计: ¥{payAmount}</Text>
</Space>
),
render: (text) => (
<span>{text}</span>
)
},
{
title: (
<Space direction='vertical'>
<Text>已请款待付款</Text>
<Text>合计: ¥{unPayApplyAmount}</Text>
</Space>
),
dataIndex: 'unPayApplyAmount', align: 'center',
render: (text) => (
<span>{text}</span>
)
},
{
title: (
<Space direction='vertical'>
<Text>待请款</Text>
<Text>合计: ¥{unApplyAmount}</Text>
</Space>
),
dataIndex: 'unApplyAmount', align: 'center',
render: (text) => (
<span>{text}</span>
)
},
{
title: '操作', dataIndex: 'type', align: 'center',
render: (text, record) => {
// 已付款大于0或已请款待付款大于0的才显示查看付款明细按钮。
return (
<div>
{
// onClick = {() => getPayment(record.id)}
record.payAmount > 0 || record.unPayApplyAmount > 0 && <a className={style.gesture}>查看付款明细</a>
}
</div>
)
}
},
];
const handlePaginationChange = (current: number, pageSize: number) => {
const data = {
contractId,
orderNo: '',
orderAbstract: '',
startTime: "",
endTime: "",
current: current,
pageSize: pageSize,
}
setSize(pageSize)
getContracInfoList(data)
};
useEffect(() => {
if (contractId) {
let data = {
contractId,
current: 1,
pageSize: 8
}
getContracInfoList(data)
}
console.log(data, '13132131')
}, [contractId])
return (
<div id='docking' className='ant-card ant-card-bordered'>
<div className='ant-card-head'>
<div className='ant-card-head-wrapper' style={{ display: 'flex', justifyContent: 'space-between' }}>
<div className='ant-card-head-wrapper'>
执行情况
</div>
<div className={style.wrapper}>
<Input.Search
style={{ width: 240 }}
placeholder="搜素"
allowClear
onSearch={onSearch}
/>
<Button style={{ paddingLeft: 10, paddingRight: 10, marginLeft: 10, marginRight: 10 }}> 重置 </Button>
</div>
</div>
</div>
<div className='ant-card-body'>
<Table
rowKey='keyId'
rowSelection={rowSelection}
columns={columns}
dataSource={data}
loading={listLoading}
pagination={
{
defaultPageSize: 20,
pageSize: size,
total,
onChange: handlePaginationChange
}
}
style={{
width: "100%"
}}
/>
</div>
</div>
)
}
export default situationList;
......@@ -2,4 +2,4 @@
.ellipsis {
.textOverflow();
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment