import {
    ModalForm,
    ProFormText,
    ProFormInstance,
    ProForm,
    ProFormTextArea,
    ProFormRadio
} from '@ant-design/pro-components';
import { message } from 'antd';
import { useRef, useEffect } from 'react';
import { operatingInvoice } from '@/services/payment/index';




export default ({ values, setModalVisit, modalVisit,onFinishOk }) => {
    const restFormRef = useRef<ProFormInstance>();
    useEffect(() => {
        restFormRef.current?.setFieldsValue(values);
    }, [values,modalVisit]);
    return (
        <>
            <ModalForm
                formRef={restFormRef}
                width={450}
                title="发票-修改状态"
                open={modalVisit}
                onFinish={async (data) => {
                    operatingInvoice(data).then((res) => {
                        message.success('修改成功')
                        restFormRef.current?.resetFields();
                        setModalVisit(false)
                        onFinishOk(data)
                    })
                }}
                onOpenChange={async (e) => {
                    setModalVisit(e)
                    restFormRef.current?.resetFields();
                }}
            >
                <ProFormText
                    label="ID"
                    name="id"
                    disabled
                />
                <ProFormRadio.Group
                    name="status"
                    options={[
                        {
                            label: '已提交',
                            value: 0,
                        },
                        {
                            label: '已开票',
                            value: 1,
                        },
                        {
                            label: '取消申请',
                            value: -1,
                        },
                    ]}
                    label={'状态'}
                    colProps={{ md: 12, xl: 12 }}
                />
                <ProForm.Group>
                    <ProFormTextArea
                        name="description"
                        label={'备注'}
                        colProps={{ md: 12, xl: 12 }}
                        placeholder="请输入备注"
                    />
                </ProForm.Group>
            </ModalForm>
        </>
    );
};