addUserPotatePolicy.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import React from 'react';
  2. import { Modal, Form, Input, InputNumber, message } from 'antd';
  3. import '../../../tencentAdPutIn/index.less'
  4. import { useAjax } from '@/Hook/useAjax';
  5. import { addUserRotatePolicyApi, modifyUserRotatePolicyApi } from '@/services/adqV3/global';
  6. interface AddUserRotatePolicyProps {
  7. value?: any;
  8. visible?: boolean;
  9. onClose?: () => void;
  10. onChange?: () => void;
  11. }
  12. const AddUserRotatePolicy: React.FC<AddUserRotatePolicyProps> = ({ value, visible, onClose, onChange }) => {
  13. /**************************************/
  14. const [form] = Form.useForm();
  15. const addUserRotatePolicy = useAjax((params) => addUserRotatePolicyApi(params))
  16. const modifyUserRotatePolicy = useAjax((params) => modifyUserRotatePolicyApi(params))
  17. /**************************************/
  18. const handleOk = () => {
  19. form.validateFields().then(values => {
  20. if (value?.id) {
  21. modifyUserRotatePolicy.run({ ...values, id: value?.id }).then(res => {
  22. if (res) {
  23. message.success('修改成功')
  24. onChange?.()
  25. }
  26. })
  27. } else {
  28. addUserRotatePolicy.run(values).then((res) => {
  29. if (res) {
  30. message.success('新增成功')
  31. onChange?.()
  32. }
  33. })
  34. }
  35. })
  36. }
  37. return <Modal
  38. title={<strong>{(value && Object.keys(value).length > 0) ? '修改' : '新增'}客服号轮换策略</strong>}
  39. open={visible}
  40. onOk={handleOk}
  41. onCancel={onClose}
  42. className='modalResetCss'
  43. confirmLoading={addUserRotatePolicy.loading}
  44. width={600}
  45. >
  46. <Form
  47. form={form}
  48. name='basicUserRotatePolicy'
  49. autoComplete="off"
  50. colon={false}
  51. layout='vertical'
  52. initialValues={value}
  53. >
  54. <Form.Item label={<strong>策略名称</strong>} name="policyName" rules={[{ required: true, message: '请输入策略名称!' }]}>
  55. <Input placeholder='请输入策略名称' />
  56. </Form.Item>
  57. <Form.Item
  58. label={<strong>{`加粉成本的计算周期(/分钟,必须 >= 20,且必须是 10 的整数倍数)`}</strong>}
  59. name="addCostCalculationCycle"
  60. rules={[{
  61. pattern: /^(|[1-9]\d{2,}|[2-9]0)$/, // 空值或≥20且为10的倍数
  62. message: '必须≥20且为10的整数倍',
  63. }]}
  64. >
  65. <InputNumber style={{ width: '100%' }} placeholder='请输入加粉成本的计算周期' />
  66. </Form.Item>
  67. <Form.Item
  68. label={<strong>{`加粉成本异常值 (单位:/分)`}</strong>}
  69. name="addCostException"
  70. >
  71. <InputNumber style={{ width: '100%' }} placeholder='请输入加粉成本异常值' />
  72. </Form.Item>
  73. <Form.Item
  74. label={<strong>单号单日最小加粉数量,默认20,加粉数少于该值永远不触发风控</strong>}
  75. name="minAddFansCount"
  76. >
  77. <InputNumber style={{ width: '100%' }} placeholder='请输入单号单日最小加粉数量' />
  78. </Form.Item>
  79. <Form.Item
  80. label={<strong>单号单日最大加粉数量</strong>}
  81. name="maxAddFansCount"
  82. >
  83. <InputNumber style={{ width: '100%' }} placeholder='请输入单号单日最大加粉数量' />
  84. </Form.Item>
  85. <Form.Item
  86. label={<strong>组内客服号在线数量</strong>}
  87. name="onlineCount"
  88. >
  89. <InputNumber style={{ width: '100%' }} placeholder='请输入组内客服号在线数量' />
  90. </Form.Item>
  91. <Form.Item
  92. label={<strong>{`客服组内滚动客服号的周期(/分钟,必须 >= 10)`}</strong>}
  93. name="rollingCustomerTime"
  94. rules={[{
  95. type: 'number',
  96. min: 10,
  97. message: '输入值必须≥10'
  98. }]}
  99. >
  100. <InputNumber style={{ width: '100%' }} placeholder='请输入加粉成本的计算周期' />
  101. </Form.Item>
  102. </Form>
  103. </Modal>
  104. };
  105. export default React.memo(AddUserRotatePolicy);