import React from 'react';
import {
  ProFormSelect,
  ProFormText,
  ModalForm,
  ProFormDependency
} 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.leverSort" defaultMessage="分摊层级序号是必填项" />
                ),
              },
            ]}
            width="sm"
            name="leverSort"
          />

          <ProFormText
            label="分摊层级名"
            rules={[
              {
                required: true,
                message: (
                  <FormattedMessage id="pages.searchTable.shareName" defaultMessage="分摊层级名是必填项" />
                ),
              },
            ]}
            width="sm"
            name="shareName"
          />
          <ProFormText
            label="目标层级"
            rules={[
              {
                required: true,
                message: (
                  <FormattedMessage id="pages.searchTable.targetLevel" defaultMessage="目标层级是必填项" />
                ),
              },
            ]}
            width="sm"
            name="targetLevel"
          />
          <ProFormSelect
            rules={[
              {
                required: true,
                message: (
                  <FormattedMessage id="pages.searchTable.calcType" defaultMessage="请选择计算方式" />
                ),
              },
            ]}
            options={[
              {
                value: 0,
                label: '合并计算',
              },
              {
                value: 1,
                label: '分开计算',
              },
            ]}
            width="sm"
            name="calcType"
            label="计算方式"
          />
        </ModalForm>
      }
    </>
  );
};

export default UpdateForm;
