import React from "react"; import { Form } from 'kts-components-antd-x3'; import { FormComponentProps } from 'kts-components-antd-x3/lib/form'; import { decorator } from "grey-react-box"; import Invoice from "../../../../Invoice"; import './index.less' export interface IInvoiceHeader { /** 标题 */ title?: string; /** 标记文字 */ defaultTag?: string; /** 默认 发票号码 */ defaultNo?: string; /** 默认 开票日期 */ defaultInvoicingDate?: string; } export default decorator(Form.create())(props => { const { form } = props; /** 控制器 */ const controller = Invoice.useInvoiceController(); const title = React.useMemo(() => { if (props.title) { return props.title } return '电子发票(增值税专用发票)' }, [props.title]) controller.useForm('invoiceHeader', form); return (
{title}
{form.getFieldDecorator('tag', { initialValue: props.defaultTag })()}
{form.getFieldDecorator('no', { initialValue: props.defaultNo })()} {form.getFieldDecorator('invoicingDate', { initialValue: props.defaultInvoicingDate })()}
) }) /** 字段 */ class Field extends React.Component<{ title: string, value?: string }>{ render(): React.ReactNode { const { title, value } = this.props; if (value) { return (
{title}
{value}
) } else { return <> } } } class Tag extends React.Component<{ value?: string }>{ render(): React.ReactNode { return ( this.props.value ?
{this.props.value}
: <> ) } }