import {
  MyBetaModalFormProps,
  MyButtons,
  MyModalFormProps,
  rulesHelper,
} from '@/common';
import { Selects } from '@/components/Select';
import { Apis } from '@/gen/Apis';
import { BetaSchemaForm } from '@ant-design/pro-components';
import { message } from 'antd';

export default function Create(props: MyBetaModalFormProps) {
  return (
    <BetaSchemaForm<ApiTypes.Company.CompanyPositions.Store>
      {...MyModalFormProps.props}
      title={`添加${props.title}`}
      wrapperCol={{ span: 24 }}
      width="500px"
      trigger={<MyButtons.Create title={`添加${props.title}`} />}
      onFinish={async (values) =>
        Apis.Company.CompanyPositions.Store(values)
          .then(() => {
            props.reload?.();
            message.success(props.title + '成功');
            return true;
          })
          .catch(() => false)
      }
      columns={[
        Selects?.Companies({
          title: '机构',
          key: 'companies_id',
          formItemProps: { ...rulesHelper.text },
        }),
        {
          key: 'name',
          title: '岗位名称',
          colProps: { span: 12 },
          formItemProps: { ...rulesHelper.text },
        },
        {
          key: 'code',
          title: '岗位编号',
          colProps: { span: 12 },
          // formItemProps: { ...rulesHelper.text },
        },
        // {
        //   key: 'sort',
        //   title: '岗位排序',
        //   colProps: { span: 24 },
        //   valueType: 'number',
        // },
        {
          key: 'remark',
          title: '备注',
          colProps: { span: 24 },
          valueType: 'textarea',
        },
      ]}
    />
  );
}
