import React, { useCallback, useEffect, useRef } from "react";
import Edit from "@/components/Page/Edit";
import { Radio, Form } from 'antd';
import {
  ProForm,
  ProFormDatePicker,
  ProFormText,
  ProFormSelect,
  ProFormRadio
} from "@ant-design/pro-components/es";
import { postTaIncompatible, putTaIncompatible, getTaIncompatibleById } from "@/service/taIncompatible";
import { getSysPosition } from "@/service/sysposition";
import { queryDict } from "@/utils/request";

const queryPosition = queryDict(getSysPosition, { labelKey: "name", valueKey: "positionId" });

const request = {
  save: postTaIncompatible,
  update: putTaIncompatible,
  get: getTaIncompatibleById
};

export default (props) => {
  const formRef = useRef();

  const initialValues = { status: 1 };

  const statusOpt = [
    { label: "正常", value: 1 },
    { label: "不正常", value: 0 },
  ];
  const ruleOpt = [
    { label: "普通规则", value: "regularRules" },
    { label: "三个月规则", value: "monthRules" },
  ]

  return (
    <Edit
      formRef={formRef}
      request={request}
      initialValues={initialValues}
      renderItems={() => (
        <>
          <ProFormSelect
            labelCol={{ span: 6 }}
            name="primaryPost"
            label="原岗位"
            request={queryPosition}
          />
          <ProFormSelect
            labelCol={{ span: 6 }}
            name="targetPost"
            label="目标岗位"
            request={queryPosition}
          />
          {/* <ProFormText labelCol={{ span: 6 }} name="rule" label="规则" /> */}
          <ProFormRadio.Group
            labelCol={{ span: 6 }}
            name="rule"
            label="规则"
            options={ruleOpt}
          />
          <ProFormRadio.Group
            labelCol={{ span: 6 }}
            name="status"
            label="状态"
            options={statusOpt}
          />
          {/* <Form.Item labelCol={{ span: 6 }} label="状态" name="status">
            <Radio.Group>
              <Radio value={1}>正常</Radio>
              <Radio value={0}>不正常</Radio>
            </Radio.Group>
          </Form.Item> */}
        </>
      )}
    />
  )
}