import React from 'react'; import { Modal, Form, Input, InputNumber, Select, Radio, Table, DatePicker, Space, Row, Col, Card } from 'kts-components-antd-x4'; import type { ColumnsType } from 'kts-components-antd-x4/es/table'; import { Button } from 'kts-xui'; import { v4 as uuidv4 } from 'uuid'; import moment from 'moment'; import './index.less'; /** 合计行 */ export interface IDifferenceTotal { /** 凭证合计金额总计 */ voucherTotal: number; /** 本次扣除金额总计 */ deductTotal: number; } /** 明细行 */ export interface IDifferenceRow { /** 唯一标识 */ $index?: string; /** 合计金额 */ voucherTotalAmt?: number; /** 本次扣除金额 */ currentDeductAmt?: number; /** 凭证类型 */ voucherType?: string; /** 凭证号码 */ deductVoucherNo?: string; /** 开具日期 */ issueDate?: string; /** 备注 */ remark?: string; /** 来源 */ source?: string; } export interface IData { /** 申报项目代码 */ projectCode?: string; /** 凭证合计金额总计 */ voucherTotal: number; /** 本次扣除金额总计 */ deductTotal: number; /** 明细数据 */ rows?: IDifferenceRow[]; } export interface IDifferenceInputModalProps { /** 是否可见 */ open?: boolean; /** 合计 */ total?: IDifferenceTotal; /** 点击取消 */ onCancel?: () => void; value?: IData; /** 点击确定 */ onOk?: (data: IData) => void; } /** 数据来源枚举 */ export enum DataSrcEnum { /** 手工录入 */ MANUAL = 1, /** 勾选录入 */ CHECK = 2, /** 模板录入 */ TEMPLATE = 3, } export const dataSrcOptions = [ { value: DataSrcEnum.MANUAL, label: '手工录入' }, { value: DataSrcEnum.CHECK, label: '勾选录入' }, { value: DataSrcEnum.TEMPLATE, label: '模板录入' }, ]; /** 静态的表格列定义(表头按参考图,待确认) */ const columns: ColumnsType = [ { title: '序号', dataIndex: 'sortNumber', key: 'sortNumber', width: 55, fixed: 'left', render: (text, record, index) => index + 1 }, { title: '合计金额', dataIndex: 'voucherTotalAmt', key: 'voucherTotalAmt', width: 90, align: 'right', render: (text) => text ? text.toFixed(2) : '0.00' }, { title: '扣除金额', dataIndex: 'currentDeductAmt', key: 'currentDeductAmt', width: 90, align: 'right', render: (text) => text ? text.toFixed(2) : '0.00' }, { title: '凭证类型', dataIndex: 'voucherType', key: 'voucherType', width: 110, render: (text) => voucherTypeOptions.find((item) => item.value === text)?.label }, // { title: '数电票号码', dataIndex: 'xxx', key: 'xxx', width: 110 }, { title: '凭证代码', dataIndex: 'deductVoucherCode', key: 'deductVoucherCode', width: 80 }, // { title: '发票号码', dataIndex: 'invoiceNumber', key: 'invoiceNumber', width: 80 }, { title: '凭证号码', dataIndex: 'deductVoucherNo', key: 'deductVoucherNo', width: 80 }, { title: '开具日期', dataIndex: 'issueDate', key: 'issueDate', width: 120, render: (text) => text ? moment(text).format('YYYY-MM-DD') : '' }, { title: '备注', dataIndex: 'remark', key: 'remark', width: 80 }, { title: '来源', dataIndex: 'dataSrc', key: 'dataSrc', width: 80, render: (text) => dataSrcOptions.find((item) => item.value === text)?.label }, ]; /** 凭证类型候枚举 */ enum VoucherType { /** 专用发票 */ SPECIAL_INVOICE = '10', /** 普通发票 */ COMMON_INVOICE = '11', /** 海关进口增值税专用缴款书 */ CUSTOMS_IMPORT_VAT_PAYMENT_BOOK = '12', /** 航空运输电子客票行程单 */ AIR_TRANSPORT_ELECTRONIC_TICKET = '13', /** 铁路电子客票 */ RAILWAY_ELECTRONIC_TICKET = '14', /** 税收完税证明(契税) */ TAX_PAYMENT_CERTIFICATE = '15', /** 中央非税收入统一票据(土地出让金) */ CENTRAL_NON_TAX_REVENUE_UNIFIED_RECEIPT = '16', /** 财政票据 */ FINANCIAL_BILL = '05', /** 法院裁决书 */ COURT_DECISION = '06', /** 其他扣除凭证 */ OTHER_DEDUCTION_VOUCHER = '09', } /** 凭证类型候选项 */ const voucherTypeOptions = [ { value: VoucherType.SPECIAL_INVOICE, label: '专用发票' }, { value: VoucherType.COMMON_INVOICE, label: '普通发票' }, { value: VoucherType.CUSTOMS_IMPORT_VAT_PAYMENT_BOOK, label: '海关进口增值税专用缴款书' }, { value: VoucherType.AIR_TRANSPORT_ELECTRONIC_TICKET, label: '航空运输电子客票行程单' }, { value: VoucherType.RAILWAY_ELECTRONIC_TICKET, label: '铁路电子客票' }, { value: VoucherType.TAX_PAYMENT_CERTIFICATE, label: '税收完税证明(契税)' }, { value: VoucherType.CENTRAL_NON_TAX_REVENUE_UNIFIED_RECEIPT, label: '中央非税收入统一票据(土地出让金)' }, { value: VoucherType.FINANCIAL_BILL, label: '财政票据' }, { value: VoucherType.COURT_DECISION, label: '法院裁决书' }, { value: VoucherType.OTHER_DEDUCTION_VOUCHER, label: '其他扣除凭证' }, ]; /** 凭证类型候 - 规则字典 */ const voucherTypeRules: Record> = { // 专用发票 [VoucherType.SPECIAL_INVOICE]: { 'deductVoucherNo': [{ required: true }], 'issueDate': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 普通发票 [VoucherType.COMMON_INVOICE]: { 'deductVoucherNo': [{ required: true }], 'issueDate': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 海关进口增值税专用缴款书 [VoucherType.CUSTOMS_IMPORT_VAT_PAYMENT_BOOK]: { 'deductVoucherNo': [{ required: true }], 'issueDate': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 航空运输电子客票行程单 [VoucherType.AIR_TRANSPORT_ELECTRONIC_TICKET]: { 'deductVoucherNo': [{ required: true }], 'issueDate': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 铁路电子客票 [VoucherType.RAILWAY_ELECTRONIC_TICKET]: { 'deductVoucherNo': [{ required: true }], 'issueDate': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 税收完税证明(契税) [VoucherType.TAX_PAYMENT_CERTIFICATE]: { 'deductVoucherNo': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 中央非税收入统一票据(土地出让金) [VoucherType.CENTRAL_NON_TAX_REVENUE_UNIFIED_RECEIPT]: { 'deductVoucherCode': [{ required: true }], 'deductVoucherNo': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 财政票据 [VoucherType.FINANCIAL_BILL]: { 'deductVoucherNo': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 法院裁决书 [VoucherType.COURT_DECISION]: { 'deductVoucherNo': [{ required: true }], 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], }, // 其他扣除凭证 [VoucherType.OTHER_DEDUCTION_VOUCHER]: { 'voucherTotalAmt': [{ required: true }], 'currentDeductAmt': [{ required: true }], 'remark': [{ required: true }], }, } /** 静态的申报项目名称候选项 */ const projectOptions = [ { value: 'KC0209', label: '小规模纳税人销售其取得(不含自建)的不动产(不含个人销售购买的住房)' }, { value: 'KC0210', label: '一般纳税人销售其取得(不含自建)的2016年4月30日前取得的不动产' }, { value: 'KC0211', label: '房地产开发企业销售房地产项目' }, { value: 'KC0212', label: '银行业金融机构、金融资产管理公司中的增值税一般纳税人处置抵债不动产' }, ]; /** * 差额录入弹窗(静态) */ export function DifferenceInputModal(props: IDifferenceInputModalProps) { const { open = true, onCancel, onOk } = props; const [form] = Form.useForm(); const [dataSource, setDataSource] = React.useState([]); const voucherType: VoucherType = Form.useWatch('voucherType', form) || form.getFieldValue('voucherType'); const [projectCode, setProjectCode] = React.useState(''); /** 扣除额 (明细汇总) */ const deductTotal = React.useMemo(() => { return dataSource.reduce((acc, curr) => acc + (curr.currentDeductAmt || 0), 0); }, [dataSource]); /** 合计金额(明细汇总) */ const voucherTotal = React.useMemo(() => { return dataSource.reduce((acc, curr) => acc + (curr.voucherTotalAmt || 0), 0); }, [dataSource]); const total = props.total || { voucherTotal: 0, deductTotal: 0 }; const onFinish = React.useCallback((values: any) => { setDataSource([...dataSource, { ...values, $index: uuidv4(), dataSrc: DataSrcEnum.MANUAL }]); form.resetFields(); }, [dataSource, form]); React.useEffect(() => { console.log('DifferenceInputModal props.value ===>', props.value) if (open) { form.resetFields(); setDataSource(props.value?.rows || []); setProjectCode(props.value?.projectCode || ''); } }, [open, props.value]); return ( } >
{/* 顶部:含税销售额、扣除额、申报项目名称 */}
{/* */} {/* */}
{/* 合计 */}
凭证合计金额总计:{total.voucherTotal.toFixed(2)} 元 本次扣除金额总计:{total.deductTotal.toFixed(2)} 元
{/* 明细列表 */} , }]} dataSource={dataSource} scroll={{ x: 1000 }} pagination={{ pageSize: 10, total: dataSource.length, showSizeChanger: false, showQuickJumper: false, showTotal: (total) => `共 ${total} 条`, }} /> ); } export default DifferenceInputModal;