Selaa lähdekoodia

更新数据获取方式

lanxin 1 viikko sitten
vanhempi
commit
ac1bda9f5a

+ 10 - 9
front/src/pages/A1home/index.tsx

@@ -38,7 +38,7 @@ function A1home() {
     () =>
       dispatch(
         Martyr_APIgetList({
-          nativeProvince: '山东省'
+          display: 1
         })
       ),
     [dispatch]
@@ -112,7 +112,7 @@ function A1home() {
 
   // 聚焦到指定城市
   const focusOnCity = useCallback((cityId: string) => {
-    if (panZoomInstance.current && svgRef.current) {
+    if (panZoomInstance.current && svgRef.current && cityId) {
       const zoomLevel = 1.8
       const svgPoint = svgRef.current.createSVGPoint()
       const city = svgRef.current.querySelector(`#${cityId}`)?.querySelector('ellipse')!
@@ -239,13 +239,14 @@ function A1home() {
 
         Object.keys(martyrListByCity).forEach(item => {
           console.log(martyrListByCity[item][0].cityId)
-          addTooltip(
-            `${martyrListByCity[item][0].cityId}`,
-            `烈士 ${martyrListByCity[item].length} | 亲属 ${
-              relativeList[item]?.length || 0
-            } | 线索 ${clueList[item]?.length || 0}`,
-            martyrListByCity[item].length
-          )
+          martyrListByCity[item][0].cityId &&
+            addTooltip(
+              `${martyrListByCity[item][0].cityId}`,
+              `烈士 ${martyrListByCity[item].length} | 亲属 ${
+                relativeList[item]?.length || 0
+              } | 线索 ${clueList[item]?.length || 0}`,
+              martyrListByCity[item].length
+            )
         })
       }
     },

+ 9 - 2
front/src/pages/components/Detail/index.tsx

@@ -273,14 +273,21 @@ function Detail({ classN, relationList, martyrDetail }: DetailProps) {
               <div className='introDetailBox'>
                 <Timeline
                   items={martyrDetail?.life?.map((item: any) => {
-                    const content = JSON.parse(item.rtf)
+                    let content = item.rtf
+                    let flag = false
+                    try {
+                      content = JSON.parse(item.rtf)
+                      if (content.txtArr) flag = true
+                    } catch (error) {}
                     console.log(content, '123321')
                     return {
                       children: (
                         <div className='introDetail' key={item.id}>
                           <div className='year'>{item.date}</div>
                           <div
-                            dangerouslySetInnerHTML={{ __html: content.txtArr[0].txt }}
+                            dangerouslySetInnerHTML={{
+                              __html: flag ? content.txtArr[0].txt : content
+                            }}
                           />
                         </div>
                       )

+ 30 - 30
front/src/pages/components/Left/index.tsx

@@ -16,16 +16,22 @@ type LeftProps = {
 function Left(props: LeftProps) {
   const dispatch = useDispatch()
   const [topInfo, setTopInfo] = useState<any>()
+  const [pagination, setPagination] = useState({
+    current: 1,
+    pageSize: 20
+  })
+  const [isFound, setIsFound] = useState<boolean>(true)
   const getListFu = useCallback(
     (pageNum: number, pageSize: number) => {
       dispatch(
         Clue_APIgetClueList({
           pageNum: pageNum,
-          pageSize: pageSize
+          pageSize: pageSize,
+          ...(isFound ? { status: 2 } : {})
         })
       )
     },
-    [dispatch]
+    [dispatch, isFound]
   )
 
   const getTopinfoFu = useCallback(async () => {
@@ -37,28 +43,13 @@ function Left(props: LeftProps) {
   const { list: listAll, total } = useSelector((state: RootState) => state.Clue.tableInfo)
 
   useEffect(() => {
-    getListFu(1, 20)
     getTopinfoFu()
-  }, [getListFu, getTopinfoFu])
-
-  const fingingList = useMemo(() => {
-    return listAll.filter((item: ClueItem) => item.status === '跟进中')
-  }, [listAll])
-  const foundList = useMemo(() => {
-    return listAll.filter((item: ClueItem) => item.status === '已找到')
-  }, [listAll])
-  const clueList = useMemo(() => {
-    return listAll.filter(
-      (item: ClueItem) => item.status !== '待确定' && item.status !== '作废'
-    )
-  }, [listAll])
-  const [curClueList, setCurClueList] = useState<ClueItem[]>()
+  }, [getTopinfoFu])
 
+  // 状态:0:待确认 | 1:跟进中 | 2:已找到 | 3:未找到 | 4:作废
   useEffect(() => {
-    if (foundList.length && !curClueList) {
-      setCurClueList(foundList)
-    }
-  }, [curClueList, foundList])
+    getListFu(pagination.current, pagination.pageSize)
+  }, [getListFu, pagination])
 
   // 预览视频
   const lookFileFu = useCallback((file: string) => {
@@ -111,14 +102,20 @@ function Left(props: LeftProps) {
         <div className='mainInfoBox'>
           <div className='tab'>
             <div
-              className={curClueList === foundList ? 'active' : ''}
-              onClick={() => setCurClueList(foundList)}
+              className={isFound ? 'active' : ''}
+              onClick={() => {
+                setIsFound(true)
+                setPagination({ current: 1, pageSize: 20 })
+              }}
             >
               寻亲案例
             </div>
             <div
-              className={curClueList === clueList ? 'active' : ''}
-              onClick={() => setCurClueList(clueList)}
+              className={!isFound ? 'active' : ''}
+              onClick={() => {
+                setIsFound(false)
+                setPagination({ current: 1, pageSize: 20 })
+              }}
             >
               线索更新
             </div>
@@ -126,7 +123,7 @@ function Left(props: LeftProps) {
           <div className='mainInfoListBox'>
             <div className='slide'></div>
             <div className='mainInfoList'>
-              {curClueList?.map((item: ClueItem) => {
+              {listAll?.map((item: ClueItem) => {
                 return (
                   <div className='mainInfo' key={item.id}>
                     <div className='labelList'>
@@ -175,10 +172,13 @@ function Left(props: LeftProps) {
               <Pagination
                 total={total}
                 simple
-                defaultPageSize={20}
-                defaultCurrent={1}
-                current={1}
-                onChange={(page, size) => getListFu(page, size)}
+                defaultPageSize={pagination.pageSize}
+                defaultCurrent={pagination.current}
+                current={pagination.current}
+                onChange={(page, size) => {
+                  setPagination({ current: page, pageSize: size })
+                  getListFu(page, size)
+                }}
               />
             </div>
           </div>

+ 1 - 1
front/src/store/action/martyr.ts

@@ -10,7 +10,7 @@ import { MartyrItem } from '@/types/api/martyr'
  * 获取烈士列表
  */
 type Martyr_APIgetListParams = {
-  nativeProvince: string
+  display: number
 }
 export const Martyr_APIgetList = (data: Martyr_APIgetListParams): any => {
   return async (dispatch: AppDispatch) => {