feat: add rental_category/rate to Room, rental_type/tenant_id to Occupancy, tenant_id to Student

This commit is contained in:
2026-07-05 19:31:03 +08:00
parent 92e6ba0e34
commit 881e9c6175
8 changed files with 95 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ const OccupanciesPage: React.FC = () => {
const [data, setData] = useState<any[]>([]);
const [students, setStudents] = useState<any[]>([]);
const [rooms, setRooms] = useState<any[]>([]);
const [tenants, setTenants] = useState<any[]>([]);
const [loading, setLoading] = useState(false);
const [checkInModal, setCheckInModal] = useState(false);
const [checkOutModal, setCheckOutModal] = useState<any>(null);
@@ -52,14 +53,16 @@ const OccupanciesPage: React.FC = () => {
const fetchData = async () => {
setLoading(true);
try {
const [occ, stu, rm]: any[] = await Promise.all([
const [occ, stu, rm, tn]: any[] = await Promise.all([
api.get('/occupancies', { params: { active: showActive ? 'true' : undefined } }),
api.get('/students'),
api.get('/rooms/overview'),
api.get('/tenants'),
]);
setData(occ);
setStudents(stu);
setRooms(rm);
setTenants(tn);
} catch (e) {
console.error(e);
}
@@ -89,6 +92,8 @@ const OccupanciesPage: React.FC = () => {
roomId: values.roomId,
checkInDate: values.checkInDate.format('YYYY-MM-DD'),
billingStartDate: values.billingStartDate?.format('YYYY-MM-DD'),
rentalType: values.rentalType,
tenantId: values.tenantId,
notes: values.notes,
});
message.success('入住登记成功');
@@ -508,6 +513,28 @@ const OccupanciesPage: React.FC = () => {
format="YYYY-MM-DD"
/>
</Form.Item>
<Form.Item name="rentalType" label="租赁类型">
<Select
allowClear
options={[
{ value: 'short', label: '短租' },
{ value: 'long', label: '长租' },
]}
placeholder="默认为短租"
/>
</Form.Item>
<Form.Item name="tenantId" label="关联单位">
<Select
showSearch
allowClear
optionFilterProp="label"
placeholder="选择关联单位"
options={tenants.map((t: { id: number; name: string }) => ({
value: t.id,
label: t.name,
}))}
/>
</Form.Item>
<Form.Item name="notes" label="备注">
<Input.TextArea rows={2} />
</Form.Item>