search.tsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import { Button, Card, Col, Form, Input, InputNumber, Row, Select, Space } from "antd"
  2. import React, { useEffect } from "react"
  3. import { getUserAllApi } from "@/services/operating/account";
  4. import { useAjax } from "@/Hook/useAjax";
  5. import { SearchOutlined } from "@ant-design/icons";
  6. import moment from "moment";
  7. import '../../tencentAdPutIn/index.less'
  8. interface Props {
  9. onSearch?: (value: Partial<CLOUDNEW.GetMaterialListProps>) => void
  10. }
  11. /**
  12. * 远程素材库
  13. * @param param0
  14. * @returns
  15. */
  16. const Search: React.FC<Props> = ({ onSearch }) => {
  17. /**********************************/
  18. const [form] = Form.useForm();
  19. const getUserAll = useAjax(() => getUserAllApi())
  20. /**********************************/
  21. useEffect(() => {
  22. getUserAll.run()
  23. }, [])
  24. const handleOk = (values: any) => {
  25. console.log(values)
  26. let params: any = []
  27. Object.keys(values).forEach(key => {
  28. let value = values[key]
  29. if (['accountIds', 'adgroupIds', 'dynamicCreativeIds', 'tencentMaterialId'].includes(key) && value) {
  30. let value1 = value.replace(/[,,\s]/g, ',')
  31. params[key] = value1.split(',').filter((a: any) => a)
  32. } else if ('uploadTime' === key && value?.length === 2) {
  33. params.uploadTimeMin = moment(value?.[0]).format('YYYY-MM-DD')
  34. params.uploadTimeMax = moment(value?.[1]).format('YYYY-MM-DD')
  35. } else if ('sizeQueries' === key) {
  36. params[key] = [value]
  37. } else {
  38. params[key] = value
  39. }
  40. })
  41. onSearch?.(params)
  42. }
  43. return <Card
  44. bodyStyle={{ padding: '5px 10px', overflow: 'auto hidden', display: 'flex', gap: 6, flexWrap: 'wrap' }}
  45. className="cardResetCss buttonResetCss"
  46. bordered
  47. >
  48. <Form
  49. layout="inline"
  50. name="basicSelectSearch"
  51. colon={false}
  52. form={form}
  53. onFinish={handleOk}
  54. initialValues={{
  55. sizeQueries: {
  56. relation: '='
  57. }
  58. }}
  59. >
  60. <Row gutter={[0, 6]}>
  61. <Col><Form.Item name="materialType">
  62. <Select
  63. placeholder="素材类型"
  64. filterOption={(input, option) =>
  65. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  66. }
  67. allowClear
  68. style={{ width: 120 }}
  69. options={[
  70. { label: '图片', value: 'image' },
  71. { label: '视频', value: 'video' }
  72. ]}
  73. />
  74. </Form.Item></Col>
  75. <Col><Form.Item name={['sizeQueries', 'width']}>
  76. <InputNumber placeholder="素材宽" />
  77. </Form.Item></Col>
  78. <Col><Form.Item name={['sizeQueries', 'height']}>
  79. <InputNumber placeholder="素材高" />
  80. </Form.Item></Col>
  81. <Col>
  82. <Form.Item name={['sizeQueries', 'relation']}>
  83. <Select
  84. placeholder="运算符"
  85. filterOption={(input, option) =>
  86. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  87. }
  88. style={{ width: 100 }}
  89. options={[
  90. { label: '小于', value: '<' },
  91. { label: '小于等于', value: '<=' },
  92. { label: '等于', value: '=' },
  93. { label: '大于', value: '>' },
  94. { label: '大于等于', value: '>=' },
  95. ]}
  96. />
  97. </Form.Item>
  98. </Col>
  99. {/* <Col><Form.Item name={'sysUserIds'}>
  100. <Select
  101. placeholder="投手"
  102. filterOption={(input, option) =>
  103. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  104. }
  105. style={{ width: 190 }}
  106. maxTagCount={1}
  107. mode="multiple"
  108. allowClear
  109. options={getUserAll?.data?.map((item: { nickname: any; userId: any }) => ({ label: item.nickname, value: item.userId }))}
  110. />
  111. </Form.Item></Col> */}
  112. <Col><Form.Item>
  113. <Space>
  114. <Button onClick={() => form.resetFields()}>重置</Button>
  115. <Button type="primary" htmlType="submit" icon={<SearchOutlined />} className="modalResetCss">搜索</Button>
  116. </Space>
  117. </Form.Item></Col>
  118. </Row>
  119. </Form>
  120. </Card>
  121. }
  122. export default React.memo(Search)