Pārlūkot izejas kodu

修复搜索功能4

JXDS18FUJT 1 gadu atpakaļ
vecāks
revīzija
03cd73a0fe
1 mainītis faili ar 33 papildinājumiem un 27 dzēšanām
  1. 33 27
      src/views/examRoadVideo/index.tsx

+ 33 - 27
src/views/examRoadVideo/index.tsx

@@ -6,6 +6,7 @@ import { Link } from "react-router-dom";
 import { Toast } from 'react-vant';
 export const ExamRoadVideo: React.FC = (props: any) => {
 
+
   const [keyWord, setKeyWord] = useState('');
   const [city, setCity] = useState({
     city: "",
@@ -47,29 +48,35 @@ export const ExamRoadVideo: React.FC = (props: any) => {
     county: string,
     countyId: string
   }[]>([])
-  const getExamListByName = (name?: string) => {
-    () => {
-      setProvince({
-        province: "",
-        provinceId: ""
-      })
-      setCounty({
-        county: "",
-        countyId: ""
-      })
-      setCity({
-        city: "",
-        cityId: ""
-      })
-      api.studentExamInfoList({
-        name: name
-      }).then(res => {
-        console.log(res)
-        setExamList(res.data.rows)
+  const getExamListByName = function (name: string) {
 
 
+    setProvince({
+      province: "",
+      provinceId: ""
+    })
+    setCounty({
+      county: "",
+      countyId: ""
+    })
+    setCity({
+      city: "",
+      cityId: ""
+    })
+    api.studentExamInfoList({
+      name: name
+    }).then(res => {
+      Toast.loading({
+        message:"搜索中"
       })
-    }
+      //修复bug,这段必须
+     
+      window.setTimeout(()=>{setExamList(res.data.rows);Toast.clear();},1500)
+      
+
+
+    })
+
 
   }
 
@@ -101,11 +108,13 @@ export const ExamRoadVideo: React.FC = (props: any) => {
     "sign": null
   }[]>([])
   useEffect(() => {
+  
     api.studentExamInfoList({
       ...province,
       ...city,
       ...county
     }).then(res => {
+      
       setExamList(res.data.rows)
 
     })
@@ -166,15 +175,12 @@ export const ExamRoadVideo: React.FC = (props: any) => {
         <div className="rect">
           <div className="search">
             {/* <SearchOutline className="icon1" color="#8A9099" fontSize={18} /> */}
-            <Search onSearch={(val)=>{
-               getExamListByName(val)
+            <Search onSearch={(val) => {
+           
+              getExamListByName(val)
             }} onChange={val => {
               setKeyWord(val)
-            }} showAction actionText={<div style={
-              {
-                color:"#fff"
-              }
-            } onClick={() => getExamListByName(keyWord)}>搜索</div>} value={keyWord} shape="round" background="transparent" placeholder="请输入搜索关键词"></Search>
+            }} value={keyWord} shape="round" background="transparent" placeholder="请输入搜索关键词"></Search>
             {/* <input placeholder="输入系列课标题" className="bar" type="search"></input> */}
           </div>
           <div