submitModal.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { SpeedMode } from "@/services/launchAdq/enum"
  2. import { QuestionCircleOutlined } from "@ant-design/icons"
  3. import { Form, Input, Modal, InputNumber, Tooltip, Select } from "antd"
  4. import React, { useState } from "react"
  5. /**
  6. * 设置名称
  7. * @returns
  8. */
  9. interface Props {
  10. data: any,
  11. visible?: boolean,
  12. onClose?: () => void,
  13. onChange?: (data: any) => void
  14. ajax?: any
  15. }
  16. const SubmitModal: React.FC<Props> = (props) => {
  17. /********************/
  18. const { visible, onClose, onChange, ajax, data } = props
  19. const [form] = Form.useForm()
  20. const [initialValues, setInitialValues] = useState<{ speedMode: string, count?: number }>({ count: 1, speedMode: 'SPEED_MODE_STANDARD' })
  21. const handleOk = async () => {
  22. form.submit()
  23. let data = await form.validateFields()
  24. onChange && onChange(data)
  25. }
  26. return <Modal title="设置名称" visible={visible} confirmLoading={ajax?.loading} onOk={handleOk} onCancel={() => { onClose && onClose() }}>
  27. <Form
  28. name="basic"
  29. form={form}
  30. labelCol={{ span: 4 }}
  31. wrapperCol={{ span: 20 }}
  32. autoComplete="off"
  33. initialValues={{ ...initialValues }}
  34. >
  35. <Form.Item label={<strong>计划名称</strong>} name="campaignName">
  36. <Input placeholder="请输入计划名称" />
  37. </Form.Item>
  38. <Form.Item label={<strong>投放方式</strong>} name="speedMode" rules={[{ required: true, message: '请选择投放方式!' }]}>
  39. <Select
  40. style={{ width: 200 }}
  41. placeholder="请选择投放方式"
  42. showSearch
  43. filterOption={(input: any, option: any) =>
  44. (option!.children as unknown as string).toLowerCase().includes(input.toLowerCase())
  45. }
  46. >
  47. {Object.keys(SpeedMode).map(key => {
  48. return <Select.Option value={key} key={key}>{SpeedMode[key]}</Select.Option>
  49. })}
  50. </Select>
  51. </Form.Item>
  52. <Form.Item label={<strong>创建数量<Tooltip title='每条计划创建的数量!'><QuestionCircleOutlined /></Tooltip></strong>} name="count">
  53. <InputNumber placeholder="创建数量" min={1} max={30} />
  54. </Form.Item>
  55. </Form>
  56. </Modal>
  57. }
  58. export default React.memo(SubmitModal)