import React from 'react';
import { Modal } from 'antd';
import {
  ProFormSelect,
  ProFormText,
  ModalForm,
} from '@ant-design/pro-form';
import { useIntl, FormattedMessage } from 'umi';


const UpdateForm = (props) => {
  const { updateModalVisible, updateModalVisibleChange, values, onSubmit } = props;
  // console.log({values});
  return (
    <>
      {
        JSON.stringify(values) !== '{}' && <ModalForm
          title="编辑成本项目"
          width="800px"
          initialValues={{ ...values }}
          labelCol={{ span:5,offset: 3 }}
          layout={'horizontal'}
          visible={updateModalVisible}
          onVisibleChange={(visible) => updateModalVisibleChange(visible)}
          onFinish={(value) => onSubmit({ ...values, ...value })}
        >
          <ProFormText
          label="成本项目编码"
          rules={[
            {
              required: true,
              message: (
                <FormattedMessage id="pages.searchTable.productCode" defaultMessage="成本项目编码是必填项" />
              ),
            },
          ]}
          width="sm"
          name="productCode"
        />
        <ProFormText
          label="成本项目名"
          rules={[
            {
              required: true,
              message: (
                <FormattedMessage id="pages.searchTable.productName" defaultMessage="成本项目名是必填项" />
              ),
            },
          ]}
          width="sm"
          name="productName"
        />
        </ModalForm>
      }
    </>
  );
};

export default UpdateForm;
