selectSearch.tsx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import { Button, Card, Col, DatePicker, 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. interface Props {
  8. onSearch?: (value: Partial<CLOUDNEW.GetMaterialListProps>) => void
  9. }
  10. // 选择素材搜索
  11. const SelectSearch: React.FC<Props> = ({ onSearch }) => {
  12. /**********************************/
  13. const [form] = Form.useForm();
  14. const getUserAll = useAjax(() => getUserAllApi())
  15. /**********************************/
  16. useEffect(() => {
  17. getUserAll.run()
  18. }, [])
  19. const handleOk = (values: any) => {
  20. console.log(values)
  21. let params: any = []
  22. Object.keys(values).forEach(key => {
  23. let value = values[key]
  24. if (['accountIds', 'adgroupIds', 'dynamicCreativeIds', 'tencentMaterialId'].includes(key) && value !== undefined && value !== null) {
  25. let value1 = value.replace(/[,,\s]/g, ',')
  26. params[key] = value1.split(',').filter((a: any) => a)
  27. } else if ('uploadTime' === key && value?.length === 2) {
  28. params.uploadTimeMin = moment(value?.[0]).format('YYYY-MM-DD')
  29. params.uploadTimeMax = moment(value?.[1]).format('YYYY-MM-DD')
  30. } else if ('dataTime' === key && value?.length === 2) {
  31. params.dataTimeMin = moment(value?.[0]).format('YYYY-MM-DD')
  32. params.dataTimeMax = moment(value?.[1]).format('YYYY-MM-DD')
  33. } else {
  34. params[key] = value
  35. }
  36. })
  37. onSearch?.(params)
  38. }
  39. return <Card
  40. bodyStyle={{ padding: '5px 10px', overflow: 'auto hidden', display: 'flex', gap: 6, flexWrap: 'wrap' }}
  41. className="cardResetCss buttonResetCss"
  42. bordered
  43. >
  44. <Form
  45. layout="inline"
  46. name="basicSelectSearch"
  47. colon={false}
  48. form={form}
  49. onFinish={handleOk}
  50. >
  51. <Row gutter={[0, 6]}>
  52. <Col><Form.Item name={'materialName'}>
  53. <Input style={{ width: 190 }} allowClear placeholder="请输入名称关键词" />
  54. </Form.Item></Col>
  55. <Col><Form.Item name={'description'}>
  56. <Input style={{ width: 190 }} allowClear placeholder="请输入备注关键词" />
  57. </Form.Item></Col>
  58. <Col><Form.Item name={'designerIds'}>
  59. <Select
  60. placeholder="设计师"
  61. filterOption={(input, option) =>
  62. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  63. }
  64. style={{ width: 190 }}
  65. maxTagCount={1}
  66. mode="multiple"
  67. allowClear
  68. options={getUserAll?.data?.map((item: { nickname: any; userId: any }) => ({ label: item.nickname, value: item.userId }))}
  69. />
  70. </Form.Item></Col>
  71. <Col><Form.Item name={'sysUserIds'}>
  72. <Select
  73. placeholder="投手"
  74. filterOption={(input, option) =>
  75. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  76. }
  77. style={{ width: 190 }}
  78. maxTagCount={1}
  79. mode="multiple"
  80. allowClear
  81. options={getUserAll?.data?.map((item: { nickname: any; userId: any }) => ({ label: item.nickname, value: item.userId }))}
  82. />
  83. </Form.Item></Col>
  84. <Col><Form.Item name={'minCost'}>
  85. <InputNumber style={{ width: 80 }} placeholder="最小消耗" />
  86. </Form.Item></Col>
  87. <Col><Form.Item name={'accountIds'}>
  88. <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="广告账号(多个逗号、换行等隔开)" />
  89. </Form.Item></Col>
  90. <Col><Form.Item name={'adgroupIds'}>
  91. <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="广告ID(多个逗号、换行等隔开)" />
  92. </Form.Item></Col>
  93. <Col><Form.Item name={'dynamicCreativeIds'}>
  94. <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="创意ID(多个逗号、换行等隔开)" />
  95. </Form.Item></Col>
  96. <Col><Form.Item name={'tencentMaterialId'}>
  97. <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="腾讯素材ID(多个逗号、换行等隔开)" />
  98. </Form.Item></Col>
  99. <Col><Form.Item name={'useStatus'}>
  100. <Select
  101. placeholder="使用情况"
  102. filterOption={(input, option) =>
  103. ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
  104. }
  105. style={{ minWidth: 120 }}
  106. allowClear
  107. options={[{ label: '未使用', value: 0 }, { label: '无消耗', value: 1 }, { label: '有消耗', value: 2 }]}
  108. />
  109. </Form.Item></Col>
  110. <Col><Form.Item name={'uploadTime'}>
  111. <DatePicker.RangePicker style={{ width: 260 }} placeholder={['上传时间开始', '上传时间结束']} />
  112. </Form.Item></Col>
  113. <Col><Form.Item name={'dataTime'}>
  114. <DatePicker.RangePicker style={{ width: 260 }} placeholder={['数据时间开始', '数据时间结束']} />
  115. </Form.Item></Col>
  116. <Col><Form.Item>
  117. <Space>
  118. <Button onClick={() => form.resetFields()}>重置</Button>
  119. <Button type="primary" htmlType="submit" icon={<SearchOutlined />} className="modalResetCss">搜索</Button>
  120. </Space>
  121. </Form.Item></Col>
  122. </Row>
  123. </Form>
  124. </Card>
  125. }
  126. export default React.memo(SelectSearch)