Initial commit: ERP system with advance verification fixes
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Card, Button, Table, message } from 'antd';
|
||||
|
||||
const TestPage: React.FC = () => {
|
||||
const [advances, setAdvances] = useState<any[]>([]);
|
||||
const [reimbursements, setReimbursements] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const fetchAdvances = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await fetch('http://localhost:3005/api/advances');
|
||||
console.log('Advances response:', res);
|
||||
const data = await res.json();
|
||||
console.log('Advances data:', data);
|
||||
if (data.success) {
|
||||
setAdvances(data.data);
|
||||
message.success(`获取到 ${data.data.length} 条预支申请`);
|
||||
} else {
|
||||
message.error('获取预支申请失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching advances:', error);
|
||||
message.error('获取预支申请失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const fetchReimbursements = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await fetch('http://localhost:3005/api/reimbursements');
|
||||
console.log('Reimbursements response:', res);
|
||||
const data = await res.json();
|
||||
console.log('Reimbursements data:', data);
|
||||
if (data.success) {
|
||||
setReimbursements(data.data);
|
||||
message.success(`获取到 ${data.data.length} 条报销申请`);
|
||||
} else {
|
||||
message.error('获取报销申请失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching reimbursements:', error);
|
||||
message.error('获取报销申请失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchAdvances();
|
||||
fetchReimbursements();
|
||||
}, []);
|
||||
|
||||
const advanceColumns = [
|
||||
{ title: 'ID', dataIndex: 'id', key: 'id' },
|
||||
{ title: '编号', dataIndex: 'advance_code', key: 'advance_code' },
|
||||
{ title: '申请人', dataIndex: 'applicant', key: 'applicant' },
|
||||
{ title: '金额', dataIndex: 'amount', key: 'amount' },
|
||||
{ title: '币种', dataIndex: 'currency', key: 'currency' },
|
||||
{ title: '日期', dataIndex: 'advance_date', key: 'advance_date' },
|
||||
{ title: '事由', dataIndex: 'reason', key: 'reason' },
|
||||
{ title: '状态', dataIndex: 'status', key: 'status' },
|
||||
];
|
||||
|
||||
const reimbursementColumns = [
|
||||
{ title: 'ID', dataIndex: 'id', key: 'id' },
|
||||
{ title: '编号', dataIndex: 'reimbursement_code', key: 'reimbursement_code' },
|
||||
{ title: '申请人', dataIndex: 'applicant', key: 'applicant' },
|
||||
{ title: '金额', dataIndex: 'amount', key: 'amount' },
|
||||
{ title: '币种', dataIndex: 'currency', key: 'currency' },
|
||||
{ title: '日期', dataIndex: 'reimbursement_date', key: 'reimbursement_date' },
|
||||
{ title: '事由', dataIndex: 'reason', key: 'reason' },
|
||||
{ title: '状态', dataIndex: 'status', key: 'status' },
|
||||
{ title: '支出类型', dataIndex: 'expense_type', key: 'expense_type' },
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<div style={{ marginBottom: 24 }}>
|
||||
<h2>测试API数据</h2>
|
||||
<p>此页面用于测试API是否正常返回数据</p>
|
||||
</div>
|
||||
|
||||
<Card title="预支申请" style={{ marginBottom: 24 }}>
|
||||
<Button type="primary" onClick={fetchAdvances} loading={loading} style={{ marginBottom: 16 }}>
|
||||
刷新预支申请
|
||||
</Button>
|
||||
<Table dataSource={advances} columns={advanceColumns} rowKey="id" />
|
||||
</Card>
|
||||
|
||||
<Card title="报销申请">
|
||||
<Button type="primary" onClick={fetchReimbursements} loading={loading} style={{ marginBottom: 16 }}>
|
||||
刷新报销申请
|
||||
</Button>
|
||||
<Table dataSource={reimbursements} columns={reimbursementColumns} rowKey="id" />
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TestPage;
|
||||
Reference in New Issue
Block a user