123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import { Button, Card, Col, DatePicker, Form, Input, InputNumber, Row, Select, Space } from "antd"
- import React, { useEffect } from "react"
- import { getUserAllApi } from "@/services/operating/account";
- import { useAjax } from "@/Hook/useAjax";
- import { SearchOutlined } from "@ant-design/icons";
- import moment from "moment";
- interface Props {
- onSearch?: (value: Partial<CLOUDNEW.GetMaterialListProps>) => void
- }
- // 选择素材搜索
- const SelectSearch: React.FC<Props> = ({ onSearch }) => {
- /**********************************/
- const [form] = Form.useForm();
- const getUserAll = useAjax(() => getUserAllApi())
- /**********************************/
- useEffect(() => {
- getUserAll.run()
- }, [])
- const handleOk = (values: any) => {
- console.log(values)
- let params: any = []
- Object.keys(values).forEach(key => {
- let value = values[key]
- if (['accountIds', 'adgroupIds', 'dynamicCreativeIds', 'tencentMaterialId'].includes(key) && value !== undefined && value !== null) {
- let value1 = value.replace(/[,,\s]/g, ',')
- params[key] = value1.split(',').filter((a: any) => a)
- } else if ('uploadTime' === key && value?.length === 2) {
- params.uploadTimeMin = moment(value?.[0]).format('YYYY-MM-DD')
- params.uploadTimeMax = moment(value?.[1]).format('YYYY-MM-DD')
- } else if ('dataTime' === key && value?.length === 2) {
- params.dataTimeMin = moment(value?.[0]).format('YYYY-MM-DD')
- params.dataTimeMax = moment(value?.[1]).format('YYYY-MM-DD')
- } else {
- params[key] = value
- }
- })
- onSearch?.(params)
- }
- return <Card
- bodyStyle={{ padding: '5px 10px', overflow: 'auto hidden', display: 'flex', gap: 6, flexWrap: 'wrap' }}
- className="cardResetCss buttonResetCss"
- bordered
- >
- <Form
- layout="inline"
- name="basicSelectSearch"
- colon={false}
- form={form}
- onFinish={handleOk}
- >
- <Row gutter={[0, 6]}>
- <Col><Form.Item name={'materialName'}>
- <Input style={{ width: 190 }} allowClear placeholder="请输入名称关键词" />
- </Form.Item></Col>
- <Col><Form.Item name={'description'}>
- <Input style={{ width: 190 }} allowClear placeholder="请输入备注关键词" />
- </Form.Item></Col>
- <Col><Form.Item name={'designerIds'}>
- <Select
- placeholder="设计师"
- filterOption={(input, option) =>
- ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
- }
- style={{ width: 190 }}
- maxTagCount={1}
- mode="multiple"
- allowClear
- options={getUserAll?.data?.map((item: { nickname: any; userId: any }) => ({ label: item.nickname, value: item.userId }))}
- />
- </Form.Item></Col>
- <Col><Form.Item name={'sysUserIds'}>
- <Select
- placeholder="投手"
- filterOption={(input, option) =>
- ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
- }
- style={{ width: 190 }}
- maxTagCount={1}
- mode="multiple"
- allowClear
- options={getUserAll?.data?.map((item: { nickname: any; userId: any }) => ({ label: item.nickname, value: item.userId }))}
- />
- </Form.Item></Col>
- <Col><Form.Item name={'minCost'}>
- <InputNumber style={{ width: 80 }} placeholder="最小消耗" />
- </Form.Item></Col>
- <Col><Form.Item name={'accountIds'}>
- <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="广告账号(多个逗号、换行等隔开)" />
- </Form.Item></Col>
- <Col><Form.Item name={'adgroupIds'}>
- <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="广告ID(多个逗号、换行等隔开)" />
- </Form.Item></Col>
- <Col><Form.Item name={'dynamicCreativeIds'}>
- <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="创意ID(多个逗号、换行等隔开)" />
- </Form.Item></Col>
- <Col><Form.Item name={'tencentMaterialId'}>
- <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="腾讯素材ID(多个逗号、换行等隔开)" />
- </Form.Item></Col>
- <Col><Form.Item name={'useStatus'}>
- <Select
- placeholder="使用情况"
- filterOption={(input, option) =>
- ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
- }
- style={{ minWidth: 120 }}
- allowClear
- options={[{ label: '未使用', value: 0 }, { label: '无消耗', value: 1 }, { label: '有消耗', value: 2 }]}
- />
- </Form.Item></Col>
- <Col><Form.Item name={'uploadTime'}>
- <DatePicker.RangePicker style={{ width: 260 }} placeholder={['上传时间开始', '上传时间结束']} />
- </Form.Item></Col>
- <Col><Form.Item name={'dataTime'}>
- <DatePicker.RangePicker style={{ width: 260 }} placeholder={['数据时间开始', '数据时间结束']} />
- </Form.Item></Col>
- <Col><Form.Item>
- <Space>
- <Button onClick={() => form.resetFields()}>重置</Button>
- <Button type="primary" htmlType="submit" icon={<SearchOutlined />} className="modalResetCss">搜索</Button>
- </Space>
- </Form.Item></Col>
- </Row>
- </Form>
- </Card>
- }
- export default React.memo(SelectSearch)
|