Initial commit: ERP system with advance verification fixes

This commit is contained in:
System Administrator
2026-03-25 23:55:36 +07:00
commit 563ca12d76
5920 changed files with 828689 additions and 0 deletions
@@ -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;