From 9589e0e1bfd14f2297563fa9a9b3bdcbc7723b74 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 16 二月 2024 21:12:52 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/components/TableSearch/index.jsx |   88 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/zy-asrs-flow/src/components/TableSearch/index.jsx b/zy-asrs-flow/src/components/TableSearch/index.jsx
index f91197d..fec61cd 100644
--- a/zy-asrs-flow/src/components/TableSearch/index.jsx
+++ b/zy-asrs-flow/src/components/TableSearch/index.jsx
@@ -1,8 +1,10 @@
 import React from 'react';
 import { Input, Button, Space, Select, DatePicker } from 'antd';
+import Http from '@/utils/http';
 import moment from 'moment';
 
 const NONE_OPTION = -9999;
+const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
 
 const TextFilter = (props) => {
     return (
@@ -120,9 +122,9 @@
                         onChange={changeDates => {
                             setDates(changeDates);
                             if (changeDates && changeDates[0] && changeDates[1]) {
-                                const changeStartStr = changeDates[0]?.toISOString()
+                                const changeStartStr = moment(changeDates[0]).format(DATE_FORMAT);
                                 setStartDate(changeStartStr);
-                                const changeEndStr = changeDates[1]?.toISOString()
+                                const changeEndStr = moment(changeDates[1]).format(DATE_FORMAT);
                                 setEndDate(changeEndStr);
                                 props.setSelectedKeys([changeStartStr + '-' + changeEndStr]);
                             }
@@ -170,5 +172,85 @@
     );
 }
 
+const LinkFilter = (props) => {
+    const [currentOption, setCurrentOption] = React.useState();
+    const [options, setOptions] = React.useState([]);
 
-export { TextFilter, SelectFilter, DatetimeRangeFilter };
\ No newline at end of file
+    const fetchData = async (value) => {
+        return await Http.doPostForm(`api/${props.name}/query`, { condition: value });
+    }
+
+    async function initOptions(value) {
+        const { data } = await fetchData(value);
+        setOptions(data);
+    }
+
+    React.useEffect(() => {
+        initOptions()
+    }, []);
+
+    const handleSearch = (value) => {
+        initOptions(value)
+    }
+
+    return (
+        <div style={{ padding: 8 }}>
+            <div>
+                <Select
+                    style={{ width: 188, marginBottom: 8, display: 'block' }}
+                    placeholder="璇烽�夋嫨"
+                    value={currentOption === NONE_OPTION ? undefined : currentOption}
+                    onChange={value => {
+                        setCurrentOption(value)
+                        props.setSelectedKeys(value !== undefined && value !== null ? [value] : []);
+                    }}
+                    onSearch={handleSearch}
+                    options={options.map(item => ({ value: item.value, label: item.label }))}
+                    filterOption={false}
+                    showSearch={true}
+                >
+                </Select>
+            </div>
+            <Space>
+                <Button
+                    type="primary"
+                    onClick={() => {
+                        props.confirm();
+                        if (currentOption === NONE_OPTION) {
+                            props.setSearchParam(prevState => {
+                                const state = { ...prevState };
+                                delete state[props.name];
+                                return state;
+                            })
+                        } else {
+                            props.setSearchParam(prevState => ({
+                                ...prevState,
+                                [props.name]: currentOption
+                            }));
+                        }
+                        props.actionRef.current?.reload();
+                    }}
+                    size="small"
+                    style={{ width: 90 }}
+                >
+                    纭畾
+                </Button>
+                <Button
+                    onClick={() => {
+                        setCurrentOption(NONE_OPTION)
+                        props.setSelectedKeys([]);
+                        props.clearFilters();
+                        initOptions()
+                    }}
+                    size="small"
+                    style={{ width: 90 }}
+                >
+                    閲嶇疆
+                </Button>
+            </Space>
+        </div>
+    );
+}
+
+
+export { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter };
\ No newline at end of file

--
Gitblit v1.9.1