shaogen1995 7 달 전
부모
커밋
90fe566e80
1개의 변경된 파일14개의 추가작업 그리고 11개의 파일을 삭제
  1. 14 11
      展示端/src/pages/B3start/index.tsx

+ 14 - 11
展示端/src/pages/B3start/index.tsx

@@ -39,10 +39,12 @@ function B3start() {
 
       if (arrRes && arrRes.length) setNowTime(arrRes[0].date)
 
+      // 设置顶部数组
       setZhouArr(arrRes)
 
       setLoding(true)
 
+      // 设置入馆时间数组
       setList(res.data.time)
     }
   }, [])
@@ -69,16 +71,14 @@ function B3start() {
     }, 500)
   }, [])
 
-  // 获取当前时间
+  // 顶部日期选中
   const [nowTime, setNowTime] = useState('')
 
-  // 顶部一共七天日期
+  // 顶部一共七天日期数组
   const [zhouArr, setZhouArr] = useState<TimeChageResType[]>([])
 
-  const [acInd, setAcInd] = useState({
-    index: -1,
-    id: 0
-  })
+  // 选中的顶部索引
+  const [acInd, setAcInd] = useState(-1)
 
   // 判断当天时间是否已经超时
   const nowDayFlag = useCallback(
@@ -106,8 +106,11 @@ function B3start() {
     const res = await B1_APIgetInfoByDay(varRes)
 
     if (res.code === 0) {
+      // 切换顶部选中
       setNowTime(val)
-      setAcInd({ index: -1, id: 0 })
+      // 清空底部索引选中
+      setAcInd(-1)
+      // 设置入馆时间数组
       setList(res.data.time)
     }
   }, [])
@@ -144,10 +147,10 @@ function B3start() {
             {list.map((item, index) => (
               <div
                 key={item.id}
-                onClick={() => setAcInd({ index, id: item.id })}
+                onClick={() => setAcInd(index)}
                 className={classNames(
                   'B3timeRow',
-                  acInd.index === index ? 'B3timeRowAc' : '',
+                  acInd === index ? 'B3timeRowAc' : '',
                   item.pcs <= 0 || nowDayFlag(item.time) ? 'myBtnNo' : ''
                 )}
               >
@@ -163,8 +166,8 @@ function B3start() {
         )}
       </div>
       <ZexhiBtn
-        nextOk={acInd.index > -1}
-        nextFu={() => history.push(`/exhiForm/${nowTime.replaceAll('.', '_')}/${acInd.index}`)}
+        nextOk={acInd > -1}
+        nextFu={() => history.push(`/exhiForm/${nowTime.replaceAll('.', '_')}/${acInd}`)}
       />
     </div>
   )