zhaojijng 2 éve
szülő
commit
98721ff610

+ 3 - 1
src/assets/css/antd-reset.less

@@ -43,7 +43,9 @@
   .ant-select-item-option-selected:not(.ant-select-item-option-disabled) {
     background: @primary-color;
   }
-
+  .ant-select-arrow {
+    font-size: 16px;
+  }
   .ant-modal-content {
     background: transparent;
     box-shadow: none;

+ 25 - 16
src/components/SearchInput/index.tsx

@@ -1,6 +1,6 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useState, useRef } from 'react';
 import styles from './index.less';
-import { Select } from 'antd';
+import { Select, Spin } from 'antd';
 //import { mapListData } from '@/hooks/useMapList';
 import { SearchOutlined } from '@ant-design/icons';
 import { useModel } from 'umi';
@@ -21,19 +21,15 @@ const SearchInput: React.FC<SearchInputProps> = ({ mapList }) => {
   const [matchData, setMatchData] = useState<mapResType[]>([]);
   const [value, setValue] = useState<any>();
   const { changeSearchBuildId, changeSearchFloorId, changeSearchText } = useModel('searchInfo');
+  const [loading, setLoading] = useState<boolean>(false);
+  const ref = useRef<any>(0);
+  const searchQuery = (value: string) => {
+    if (ref.current) {
+      clearTimeout(ref.current);
+    }
 
-  //这是搜索 的下拉列表的显示
-  const handleSearch = (value: string) => {
-    if (value) {
-      // let data: mapResType[] = [];
-      //   mapList.map((item, index) => {
-      //     if ((item.localName || '').indexOf(value) > -1) {
-      //       data.push({
-      //         text: item.localName,
-      //         value: item.localName,
-      //       });
-      //     }
-      //   });
+    function fake() {
+      setLoading(true);
       var paramsObj = {
         criteria: {
           projectId: projectId,
@@ -47,11 +43,24 @@ const SearchInput: React.FC<SearchInputProps> = ({ mapList }) => {
         var resContent = res.content || [];
         console.log('setMatch', 'data');
         setMatchData(resContent);
+        setLoading(false);
       });
+    }
+    // debugger;
+    if (value) {
+      ref.current = setTimeout(fake, 600);
     } else {
       setMatchData([]);
     }
   };
+  //这是搜索 的下拉列表的显示
+  const handleSearch = (value: string) => {
+    //if (value) {
+    searchQuery(value);
+    // } else {
+    //   setMatchData([]);
+    // }
+  };
 
   //这是搜索的下拉列表的点击
   const handleChange = (sel: string) => {
@@ -84,19 +93,19 @@ const SearchInput: React.FC<SearchInputProps> = ({ mapList }) => {
 
   return (
     <div className={styles.headerSearch}>
-      <SearchOutlined style={{ fontSize: 16 }} />
+      {/* <SearchOutlined style={{ fontSize: 16 }} /> */}
       <Select
         showSearch
         value={value}
         placeholder="搜索空间"
         defaultActiveFirstOption={false}
-        showArrow={false}
         filterOption={false}
         onSearch={handleSearch}
         onChange={handleChange}
         onInputKeyDown={handelInputKeyDown}
         notFoundContent={null}
         bordered={false}
+        loading={loading}
         style={{ width: 150, borderColor: '#c4c4c4' }}
         //   suffixIcon={
         //     <AudioOutlined

+ 4 - 4
src/components/map/index.tsx

@@ -99,8 +99,8 @@ const Map: React.FC<MapProps> = ({ type, selFloorId, render, mapList, mapSize })
       if (filterItem.length == 0) return;
       left = -((filterItem[0] || {}).left || 0);
       top = -((filterItem[0] || {}).top || 0);
-      setTranslateX(left);
-      setTranslateY(top);
+      setTranslateX(left * mscale);
+      setTranslateY(top * mscale);
       //搜索完成
       changeSearchBuildId(''); //清空搜索记录  以防两次搜索一样的建筑的 没反应
       changeSearchFloorId(''); //清空搜索记录 以防两次搜索一样的楼层时 没反应 要不要换位置
@@ -124,8 +124,8 @@ const Map: React.FC<MapProps> = ({ type, selFloorId, render, mapList, mapSize })
       if (filterItem.length == 0) return;
       left = -((filterItem[0] || {}).left || 0);
       top = -((filterItem[0] || {}).top || 0);
-      setTranslateX(left);
-      setTranslateY(top);
+      setTranslateX(left * mscale);
+      setTranslateY(top * mscale);
       changeSearchText({});
     }
   }, [searchText]);