import React, { useRef, useEffect } from 'react';
import { Modal, Form, Upload, Input } from 'antd';
import { merchantView } from '../service';

const formItemLayout = {
  labelCol: { span: 4 },
  wrapperCol: { span: 19 },
};

/**
 * 查看发票
 * */
const InvoiceListModal = props => {
  const refForm = useRef();
  const { id } = props;

  const getDetail = async () => {
    // const data = await merchantView(id);
    // if (data.businessCode === '0000') {
    //   // settoExamineData({ ...data.data });
    //   // setToExamineModalVisibel(true);
    //   // setVisibleInvoiceList(true);
    //   refForm.current?.setFieldsValue?.({
    //     fileList: [{ url: 'https://kdspstatic.q-gp.com//CAA61F398F500001A395224099801D75.png', name: '18.png', uid: 0, status: 'done' }],
    //     other: '11111',
    //     sFileList: [{ url: 'https://kdspstatic.q-gp.com//CAA61F398F500001A395224099801D75.png', name: '18.png', uid: 0, status: 'done' }],
    //     sOther: '2222',
    //   })
    // }
    refForm.current?.setFieldsValue?.({
      fileList: [
        {
          url: 'https://kdspstatic.q-gp.com/CAA61F398F500001A395224099801D75.png',
          name: '18.png',
          uid: 0,
          status: 'done',
        },
      ],
      other: '11111',
      sFileList: [
        {
          url: 'https://kdspstatic.q-gp.com/CAA61F398F500001A395224099801D75.png',
          name: '18.png',
          uid: 0,
          status: 'done',
        },
        {
          url: 'https://kdspstatic.q-gp.com/CAA61F398F500001A395224099801D75.png',
          name: '18.png',
          uid: 1,
          status: 'done',
        },
        {
          url: 'https://kdspstatic.q-gp.com/CAA61F398F500001A395224099801D75.png',
          name: '18.png',
          uid: 2,
          status: 'done',
        },
        {
          url: 'https://kdspstatic.q-gp.com/CAA61F398F500001A395224099801D75.png',
          name: '18.png',
          uid: 3,
          status: 'done',
        },
        {
          url: 'https://kdspstatic.q-gp.com/CAA61F398F500001A395224099801D75.png',
          name: '18.png',
          uid: 4,
          status: 'done',
        },
        {
          url: 'https://kdspstatic.q-gp.com/CAA61F398F500001A395224099801D75.png',
          name: '18.png',
          uid: 5,
          status: 'done',
        },
      ],
      sOther: '2222',
    });
  };

  useEffect(() => {
    getDetail();
  }, []);

  return (
    <Modal width={800} title="查看发票" open footer={null} onCancel={() => props.onCancel(false)}>
      <Form ref={refForm} {...formItemLayout}>
        <Form.Item label="发票" name="fileList" valuePropName="fileList">
          <Upload disabled listType="picture-card" />
        </Form.Item>
        <Form.Item label="发票备注" name="other">
          <Input disabled />
        </Form.Item>
        <Form.Item label="补充发票" name="sFileList" valuePropName="fileList">
          <Upload disabled listType="picture-card" />
        </Form.Item>
        <Form.Item label="补充发票备注" name="sOther">
          <Input disabled />
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default InvoiceListModal;
