-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...c/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/FullTextSearch/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Button, Col, Form, Input, Popover, Row } from 'antd' | ||
import React, { useEffect, useState } from 'react' | ||
import { useLogsContext } from 'src/contexts/LogsContext' | ||
|
||
const FullTextSearch = () => { | ||
const { query, updateQuery } = useLogsContext() | ||
const [form] = Form.useForm() | ||
const [open, setOpen] = useState(false) | ||
|
||
const hide = () => { | ||
setOpen(false) | ||
} | ||
|
||
const handleOpenChange = (newOpen) => { | ||
setOpen(newOpen) | ||
} | ||
|
||
const clickSubmit = () => { | ||
form.validateFields().then(() => { | ||
const formState = form.getFieldsValue(true) | ||
let newQuery = query | ||
if (newQuery.length > 0) { | ||
newQuery += ' AND ' | ||
} | ||
newQuery += '`' + formState.key + '` like ' + `'` + formState.value + `'` | ||
updateQuery(newQuery) | ||
hide() | ||
}) | ||
} | ||
useEffect(() => { | ||
form.resetFields() | ||
}, [open]) | ||
return ( | ||
<Popover | ||
destroyTooltipOnHide | ||
content={ | ||
<div> | ||
<Form layout="vertical" className="px-2" form={form} initialValues={{ key: 'content' }}> | ||
<Row gutter={10}> | ||
<Col span={7}> | ||
<Form.Item | ||
label="全文检索字段" | ||
name="key" | ||
rules={[ | ||
{ | ||
required: true, | ||
message: '请输入全文检索字段', | ||
}, | ||
]} | ||
> | ||
<Input placeholder="请输入全文检索字段" /> | ||
</Form.Item> | ||
</Col> | ||
<Col span={13}> | ||
<Form.Item | ||
label="全文检索内容" | ||
name="value" | ||
rules={[ | ||
{ | ||
required: true, | ||
message: '请输入全文检索内容', | ||
}, | ||
]} | ||
> | ||
<Input placeholder="请输入全文检索内容" /> | ||
</Form.Item> | ||
</Col> | ||
<Col> | ||
<Form.Item label=" "> | ||
<Button type="primary" htmlType="submit" onClick={clickSubmit}> | ||
确认 | ||
</Button> | ||
</Form.Item> | ||
</Col> | ||
</Row> | ||
</Form> | ||
</div> | ||
} | ||
title="全文检索" | ||
trigger="click" | ||
open={open} | ||
onOpenChange={handleOpenChange} | ||
> | ||
<Button type="primary">全文检索</Button> | ||
</Popover> | ||
) | ||
} | ||
export default FullTextSearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters