import React from 'react';
import Invoice from '../../..';
import 'antd/dist/antd.css';
import moment from 'moment';

export default () => {

    const controller = React.useMemo(() => new Invoice.InvoiceController(), [])

    React.useEffect(() => {
        (async () => {
            // await controller.run(async s => { s.model = 'readOnly' }); // 设置只读
            // await controller.run(async s => { s.stakeholder.enables = ['remarks'] });
            await controller.formList.get('invoiceHeader')?.setFieldsValue({
                no: '2029292029201920291029',
                invoicingDate: '2023年7月6日',
                tag: '成品油',
            })
            await controller.formList.get('stakeholder')?.setFieldsValue({
                buyerName: '国能供应链内蒙古有限公司',
                buyerTaxId: '91150291552838725H',
                buyerAddress: '内蒙古自治区包头稀士高新区总部经济园区9号楼204号',
                buyerPhone: '0472-5368680',
                buyerBank: '11050167360000000932中国银行股份有限公司包头开发区支行',
                buyerAccount: '',

                supplierName: '国星供应链管理(北京)有限公司上海分公司',
                supplierTaxId: '91310230MA1JWA3QX1',
                sellerAddress: '上海市宝山区南镇逸仙路华滋奔腾大厦A座1207室',
                sellerPhone: '13511077832',
                sellerBank: '广发银行股份有限公司上海大柏树支行',
                sellerAccount: '9550880218186900195',
            })
            await controller.formList.get('sign')?.setFieldsValue({
                remarks: '备注\n换行备注',
                drawer: '张自豪',
            })
            await controller.formList.get('realEstateInfo')?.setFieldsValue({
                realEstateAddress: ['北京市', '北京市', '东城区'],
                realEstateDetailedAddress: '东城区东华门大街',
                leaseTerm: [moment('2023-07-06'), moment('2023-07-06')],
                crossCitiesSign: 'Y',
                realEstateNumber: '123456789',
                realEstateUnit: '平方米',
            })
        })()
    }, [controller])

    return (
        <Invoice
            invoiceType='digtal'
            controller={controller}
            specialInfor={<Invoice.RealEstateInfo />}
        />
    )
};