selectGroupSearch.tsx 7.3 KB

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