UNPKG

957 BJavaScriptView Raw
1import React from "react";
2import { DebounceBtn, ResetButton } from "@comps/Buttons";
3import styles from "./SearchBar.scss";
4import { message } from "antd";
5let loading = false;
6/**
7 * ----------------------------------------
8 * 搜索栏
9 * @param {Function} onRest - 重置按钮
10 * @param {Function} onSearch - 搜索按钮
11 * ----------------------------------------
12 */
13export default function SearchBar({ children, onReset, onSearch }) {
14 const _search = () => {
15 if (loading) return;
16 message.info("正在查询..", 1);
17 loading = true;
18 setTimeout(() => (loading = false), 1500);
19 onSearch();
20 };
21 return (
22 <div className={styles.container}>
23 <div className={styles.forms}>{children}</div>
24 <div className={styles.btns}>
25 {onReset && <ResetButton onClick={onReset} />}
26 <DebounceBtn onClick={_search} style={{ marginLeft: "5px" }}>
27 查询
28 </DebounceBtn>
29 </div>
30 </div>
31 );
32}