index.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { syncAccountDayApi, syncAccountDayV3Api } from "@/services/launchAdq/adminSpecialUseConsume"
  3. import { Button, Card, DatePicker, Form, FormProps, Input, message } from "antd"
  4. import React from "react"
  5. import moment from "moment"
  6. import { RangePickerProps } from "antd/lib/date-picker"
  7. /**
  8. * 管理员拉消耗专用
  9. * @returns
  10. */
  11. const AdminSpecialUseConsume: React.FC = () => {
  12. /*********************************/
  13. const [form] = Form.useForm()
  14. const syncAccountDay = useAjax((params) => syncAccountDayApi(params), { formatResult: true })
  15. const syncAccountDayV3 = useAjax((params) => syncAccountDayV3Api(params), { formatResult: true })
  16. /*********************************/
  17. const onFinish: FormProps<any>["onFinish"] = (values) => {
  18. const { accountIds, pullDate } = values
  19. let params: any = {}
  20. params.accountIds = accountIds.split(/[,,\s\n]+/);
  21. params.beginDate = moment(pullDate[0]).format('YYYY-MM-DD')
  22. params.endDate = moment(pullDate[1]).format('YYYY-MM-DD')
  23. console.log('Success:', params);
  24. syncAccountDay.run(params).then(res => {
  25. if (res?.data) {
  26. message.success('拉取成功')
  27. form.setFieldsValue({})
  28. }
  29. })
  30. syncAccountDayV3.run(params).then(res => {
  31. if (res?.data) {
  32. message.success('V3拉取成功')
  33. form.setFieldsValue({})
  34. }
  35. })
  36. };
  37. const disabledDate: RangePickerProps['disabledDate'] = (current) => {
  38. // Can not select days before today and today
  39. return current && current > moment().endOf('day');
  40. };
  41. return <Card
  42. title={<strong>管理员拉消耗专用</strong>}
  43. bodyStyle={{ height: 'calc(100vh - 155px)' }}
  44. >
  45. <Form
  46. name="asucBasic"
  47. layout="vertical"
  48. style={{ maxWidth: 600 }}
  49. onFinish={onFinish}
  50. autoComplete="off"
  51. form={form}
  52. >
  53. <Form.Item
  54. label={<strong>广告账号</strong>}
  55. name="accountIds"
  56. rules={[{ required: true, message: '请输入广告账号!' }]}
  57. >
  58. <Input.TextArea rows={6} placeholder="请输入广告账号(多个逗号,空格,换行)" />
  59. </Form.Item>
  60. <Form.Item
  61. label={<strong>日期区间</strong>}
  62. name="pullDate"
  63. rules={[{ required: true, message: '请选择日期!' }]}
  64. >
  65. <DatePicker.RangePicker disabledDate={disabledDate} />
  66. </Form.Item>
  67. <Form.Item wrapperCol={{ offset: 10, span: 14 }}>
  68. <Button type="primary" htmlType="submit" loading={syncAccountDay.loading}>
  69. 提交
  70. </Button>
  71. </Form.Item>
  72. </Form>
  73. </Card>
  74. }
  75. export default AdminSpecialUseConsume