selectSearch.tsx 7.1 KB

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