import React from 'react'; import { Card, DatePicker, Empty, Form, Input, InputNumber, Modal, Popconfirm, Select, Space, Table, Tag, } from 'antd'; import { DollarOutlined, InboxOutlined, PlusOutlined } from '@ant-design/icons'; import PermissionButton from '../../components/PermissionButton'; import EditableCell from '../../components/EditableCell'; import type { DepositStudentLookup } from './deposit-student-option'; import { useSubmitShortcut } from '../../hooks/useSubmitShortcut'; export interface DepositRecord { id: number; studentId: number; amount: number; status: string; paidDate: string; refundDate?: string | null; notes?: string | null; installments?: Array<{ id: number; amount: number; dueDate: string; paidDate?: string | null; status: string; }>; student?: DepositStudentLookup; } export interface EligibleStudent { studentId: number; studentName: string; studentNo?: string | null; roomId: number; roomNumber: string; building?: string | null; roomType?: string | null; capacity: number; depositAmount: number; } export const statusMap: Record = { paid: { text: '有余额', color: 'green' }, refunded: { text: '已全退', color: 'blue' }, depleted: { text: '已扣完', color: 'red' }, }; export const installmentStatusMap: Record = { pending: { text: '待缴', color: 'orange' }, paid: { text: '已缴', color: 'green' }, }; export const roomTypeOptions = [ { value: '单人间', label: '单人间' }, { value: '四人间', label: '四人间' }, ]; export const suggestedDepositByRoomType: Record = { 单人间: 200, 四人间: 100, }; export interface DepositModalsProps { batchModal: boolean; createModal: boolean; refundModal: DepositRecord | null; detailModal: DepositRecord | null; installmentModal: number | null; batchForm: ReturnType[0]; createForm: ReturnType[0]; refundForm: ReturnType[0]; installmentForm: ReturnType[0]; saving: boolean; batchRoomType: string; effectiveSelectedEligibleIds: number[]; eligibleStudents: EligibleStudent[]; eligibleLoading: boolean; eligibleColumns: Array<{ title: string; render?: unknown; dataIndex?: string }>; studentOptions: Array<{ value: number; label: string }>; onBatchRoomTypeChange: (roomType: string) => void; onBatchCreate: () => void; onCreate: () => void; onRefund: () => void; onAddInstallment: () => void; onPayInstallment: (installmentId: number) => void; onSaveInstallmentCell: ( installmentId: number, field: 'status' | 'paidDate', value: unknown, ) => void; onDeleteInstallment: (installmentId: number) => void; onCloseBatch: () => void; onCloseCreate: () => void; onCloseRefund: () => void; onCloseDetail: () => void; onCloseInstallment: () => void; onOpenInstallment: (id: number) => void; onSelectEligible: (ids: number[]) => void; } export const DepositModals: React.FC = ({ batchModal, createModal, refundModal, detailModal, installmentModal, batchForm, createForm, refundForm, installmentForm, saving, batchRoomType, effectiveSelectedEligibleIds, eligibleStudents, eligibleLoading, eligibleColumns, studentOptions, onBatchRoomTypeChange, onBatchCreate, onCreate, onRefund, onAddInstallment, onPayInstallment, onSaveInstallmentCell, onDeleteInstallment, onCloseBatch, onCloseCreate, onCloseRefund, onCloseDetail, onCloseInstallment, onOpenInstallment, onSelectEligible, }) => { useSubmitShortcut(batchModal && !saving, onBatchCreate); useSubmitShortcut(createModal && !saving, onCreate); useSubmitShortcut(!!refundModal && !saving, onRefund); useSubmitShortcut(!!installmentModal && !saving, onAddInstallment); return ( <>
当前可用押金: ¥{Number(refundModal?.amount || 0).toFixed(2)}
{detailModal && (

当前可用押金: ¥{Number(detailModal.amount).toFixed(2)}

最近收取日期: {detailModal.paidDate}

状态:{' '} {statusMap[detailModal.status]?.text || detailModal.status}

{detailModal.notes && (

备注: {detailModal.notes}

)}

分期记录

} onClick={() => onOpenInstallment(detailModal.id)} > 添加分期
{detailModal.installments && detailModal.installments.length > 0 ? ( `¥${value.toFixed(2)}`, }, { title: '到期日', dataIndex: 'dueDate' }, { title: '实付日', dataIndex: 'paidDate', render: (value: string, item: any) => ( onSaveInstallmentCell(item.id, 'paidDate', next) } > {value || '-'} ), }, { title: '状态', dataIndex: 'status', render: (value: string, item: any) => ( onSaveInstallmentCell(item.id, 'status', next) } > {installmentStatusMap[value]?.text || value} ), }, { title: '操作', render: (_: unknown, item: any) => ( {item.status === 'pending' && ( } onClick={() => onPayInstallment(item.id)} > 标记已缴 )} onDeleteInstallment(item.id)} > } > 归档 ), }, ]} /> ) : (

暂无分期记录

)} )}
); };