index.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { useAjax } from "@/Hook/useAjax";
  2. import { addV3StrategyApi } from "@/services/adqV3";
  3. import { Button, Form, Input, message, Modal } from "antd"
  4. import React, { useState } from "react"
  5. import '../../index.less'
  6. interface Props {
  7. strategyValue: {
  8. adData: any[],
  9. addelivery: PULLIN.AddeliveryProps,
  10. accountCreateLogs: PULLIN.AccountCreateLogsProps[],
  11. materialData: any,
  12. textData: any
  13. }
  14. putInType?: 'NOVEL' | 'GAME'
  15. }
  16. /**
  17. * 存为策略组
  18. * @returns
  19. */
  20. const TacticsS: React.FC<Props> = ({ strategyValue, putInType }) => {
  21. /*********************************/
  22. const [form] = Form.useForm();
  23. const [visible, setVisible] = useState<boolean>(false)
  24. const addV3Strategy = useAjax((params) => addV3StrategyApi(params))
  25. /*********************************/
  26. const seve = () => {
  27. setVisible(true)
  28. }
  29. const handleOk = () => {
  30. form.validateFields().then(values => {
  31. addV3Strategy.run({ ...values, strategyValue: JSON.stringify(strategyValue), type: 'updateAd', taskType: putInType }).then(res => {
  32. if (res) {
  33. message.success('保存成功')
  34. form.resetFields()
  35. setVisible(false)
  36. }
  37. })
  38. })
  39. }
  40. return <>
  41. <Button type='primary' onClick={seve}>存为策略组</Button>
  42. {visible && <Modal
  43. title="存为策略组"
  44. open={visible}
  45. onCancel={() => { form.resetFields(); setVisible(false) }}
  46. onOk={handleOk}
  47. confirmLoading={addV3Strategy.loading}
  48. className="modalResetCss"
  49. >
  50. <Form
  51. form={form}
  52. layout='vertical'
  53. name="saveUpdateAd"
  54. colon={false}
  55. initialValues={{}}
  56. >
  57. <Form.Item label={<strong>策略组名称</strong>} name='strategyKey' rules={[{ required: true, message: '请输入策略组名称' }]}>
  58. <Input placeholder="请输入策略组名称" showCount maxLength={30} />
  59. </Form.Item>
  60. </Form>
  61. </Modal>}
  62. </>
  63. }
  64. export default React.memo(TacticsS)