import React, { useState, useEffect } from 'react';
import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker, InputNumber, Checkbox, Row, Col } from 'antd';
import { FormattedMessage } from 'umi-plugin-react/locale';
import XForm, { FieldTypes } from '../../../components/XForm';
import router from 'umi/router';
import moment from 'moment';
import apis from '../../../services/apis';
import request from '../../../utils/request';
import Navigate from '@/components/Navigate';

const header = props => {
  const templateId = props.location.query.id;
  const [data, setData] = useState({})

  useEffect(() => {
    getData(templateId);
  }, [])

  const getData = (templateId) => {
    request({ ...apis.taEcontract.getContractTemplate, urlData: { id: templateId } }).then((data) => {
      setData(data)
      props.form.setFieldsValue(data)
    })
  }

  const toCancel = () => {
    router.go(-1)
  }

  return (
    <>
      <div align="right"><Button onClick={() => toCancel()}>返回</Button></div>

      <Form labelCol={{ span: 6 }} wrapperCol={{ span: 14 }} style={{ position: 'relative' }}>
        <Form.Item label="合同标题">
          <span>{data.contractTemplateName}</span>
        </Form.Item>
        <Form.Item label="合同文件">
          <div>
            <Navigate to={data.contractTemplateAddress}>查看文件</Navigate>
          </div>
        </Form.Item>
      </Form>
    </>
  )
}

const WrappedHeader = Form.create({ name: 'header' })(header);
export default WrappedHeader
