configPutStatus.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { useAjax } from "@/Hook/useAjax";
  2. import { iaaConfigPutStatusApi } from "@/services/iaaSystem/channel";
  3. import { Form, message, Modal, Select } from "antd";
  4. import React from "react"
  5. interface Props {
  6. selectedRows: any[]
  7. onChange?: () => void
  8. visible?: boolean
  9. onClose?: () => void
  10. }
  11. const ConfigPutStatus: React.FC<Props> = ({ selectedRows, onChange, visible, onClose }) => {
  12. /*******************************/
  13. const [form] = Form.useForm<IAAAPI.AddIaaAgentProps>();
  14. const iaaConfigPutStatus = useAjax((params) => iaaConfigPutStatusApi(params))
  15. /*******************************/
  16. const handleOk = async () => {
  17. form.submit()
  18. let data: any = await form.validateFields()
  19. iaaConfigPutStatus.run({...data, agentIds: selectedRows.map(item => item.id).toString()}).then(res => {
  20. if (res?.data) {
  21. message.success('变更成功')
  22. onChange && onChange()
  23. }
  24. })
  25. }
  26. return <Modal
  27. title={<strong>{'变更投放状态'}</strong>}
  28. open={visible}
  29. onCancel={onClose}
  30. onOk={handleOk}
  31. confirmLoading={iaaConfigPutStatus.loading}
  32. >
  33. <Form
  34. name="configPutStatus"
  35. layout="vertical"
  36. form={form}
  37. autoComplete="off"
  38. colon={false}
  39. >
  40. <Form.Item label={<strong>投放状态</strong>} name="putStatus">
  41. <Select
  42. placeholder="请选择投放状态"
  43. options={[
  44. {
  45. value: 'PUT_STATUS_PUT_ING',
  46. label: '投放中',
  47. },
  48. {
  49. value: 'PUT_STATUS_PUT_STOP',
  50. label: '投放结束',
  51. }
  52. ]}
  53. />
  54. </Form.Item>
  55. </Form>
  56. </Modal>
  57. }
  58. export default React.memo(ConfigPutStatus)