Explorar el Código

完善获取烈士所有数据

shaogen1995 hace 2 meses
padre
commit
7f26cdb215

+ 4 - 2
后台管理/src/pages/A1record/A1echarts/index.tsx

@@ -8,16 +8,17 @@ import { CanvasRenderer } from 'echarts/renderers'
 import { Button } from 'antd'
 import A1relation from '../A1relation'
 import { A1_APIgetRRlist } from '@/store/action/A1record'
-import { A1RRlistType } from '../data'
+import { A1ListSelectType, A1RRlistType } from '../data'
 
 echarts.use([TitleComponent, TooltipComponent, GraphChart, CanvasRenderer])
 
 type Props = {
   sId: number
   sName: string
+  listAllRes: A1ListSelectType
 }
 
-function A1echarts({ sId, sName }: Props) {
+function A1echarts({ sId, sName, listAllRes }: Props) {
   const [oldList, setOldList] = useState<A1RRlistType[]>([])
 
   const initFu = useCallback(async () => {
@@ -144,6 +145,7 @@ function A1echarts({ sId, sName }: Props) {
           closeFu={() => setShowId(0)}
           upDataFu={initFu}
           oldList={oldList}
+          listAllResTemp={listAllRes}
         />
       ) : null}
     </div>

+ 31 - 4
后台管理/src/pages/A1record/A1look/index.tsx

@@ -1,8 +1,8 @@
 import React, { useCallback, useEffect, useRef, useState } from 'react'
 import styles from './index.module.scss'
 import A1echarts from '../A1echarts'
-import { A1_APIgetInfo } from '@/store/action/A1record'
-import { A1ListType, jiGuanFu } from '../data'
+import { A1_APIgetInfo, A1_APIgetList } from '@/store/action/A1record'
+import { A1ListSelectType, A1ListType, jiGuanFu } from '../data'
 import ZupTypes from '@/components/ZupTypes'
 import ZupVideos from '@/components/ZupVideos'
 import { Button } from 'antd'
@@ -23,6 +23,33 @@ type Props = {
 }
 
 function A1look({ sId }: Props) {
+  // 获取所有烈士信息
+  const [listAllRes, setListAllRes] = useState<A1ListSelectType>([])
+
+  const getListAllFu = useCallback(async () => {
+    const res = await A1_APIgetList(
+      {
+        pageNum: 1,
+        pageSize: 99999
+      },
+      true
+    )
+    if (res.code === 0) {
+      const list: A1ListType[] = res.data.records || []
+      setListAllRes(
+        list.map(c => ({
+          value: c.id,
+          label: c.name
+        }))
+      )
+    }
+  }, [])
+
+  useEffect(() => {
+    getListAllFu()
+  }, [getListAllFu])
+  // 获取所有烈士信息-end
+
   // 多张图片的ref
   const ZupImgsRef = useRef<any>(null)
 
@@ -143,7 +170,7 @@ function A1look({ sId }: Props) {
               </div>
             </div>
             <div className='A1Top2'>
-              <A1echarts sId={info.id} sName={info.name} />
+              <A1echarts listAllRes={listAllRes} sId={info.id} sName={info.name} />
             </div>
           </div>
 
@@ -163,7 +190,7 @@ function A1look({ sId }: Props) {
 
             {tabAc === 1 ? <A1tab1life sId={sId} /> : null}
             {tabAc === 2 ? <A2tab2clan sId={sId} /> : null}
-            {tabAc === 3 ? <A3tab3clue sId={sId} /> : null}
+            {tabAc === 3 ? <A3tab3clue sId={sId} listAllRes={listAllRes} /> : null}
             {tabAc === 4 ? <A4tab4antique sId={sId} /> : null}
           </div>
         </>

+ 10 - 25
后台管理/src/pages/A1record/A1relation/index.tsx

@@ -3,10 +3,8 @@ import styles from './index.module.scss'
 import { Button, Empty, Input, Modal, Select } from 'antd'
 import { MessageFu } from '@/utils/message'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { A1RRlistType } from '../data'
-import { useDispatch, useSelector } from 'react-redux'
-import { A1_APIgetList, A1_APIsaveRR } from '@/store/action/A1record'
-import { RootState } from '@/store'
+import { A1ListSelectType, A1RRlistType } from '../data'
+import { A1_APIsaveRR } from '@/store/action/A1record'
 import { DeleteOutlined } from '@ant-design/icons'
 import classNames from 'classnames'
 
@@ -16,34 +14,21 @@ type Props = {
   closeFu: () => void
   upDataFu: () => void
   oldList: A1RRlistType[]
+  listAllResTemp: A1ListSelectType
 }
 
-function A1relation({ sId, closeFu, upDataFu, oldList, sName }: Props) {
-  // 获取所有烈士信息
-  const dispatch = useDispatch()
-
-  useEffect(() => {
-    dispatch(
-      A1_APIgetList({
-        pageNum: 1,
-        pageSize: 99999
-      })
-    )
-  }, [dispatch])
-
-  const listAll = useSelector((state: RootState) => state.A1record.tableInfo.list)
+function A1relation({ sId, closeFu, upDataFu, oldList, sName, listAllResTemp }: Props) {
   const [list, setList] = useState<A1RRlistType[]>([])
 
+  // 所有烈士信息改造
   const listAllRes = useMemo(() => {
-    return listAll
-      .filter(v => v.id !== sId)
+    return listAllResTemp
+      .filter(v => v.value !== sId)
       .map(c => ({
-        value: c.id,
-        label: c.name,
-        disabled: list.map(q => q.moduleId).includes(c.id)
+        ...c,
+        disabled: list.map(q => q.moduleId).includes(c.value)
       }))
-  }, [list, listAll, sId])
-  // 获取所有烈士信息-end
+  }, [list, listAllResTemp, sId])
 
   // useEffect(() => {
   //   console.log('xxxxx', list)

+ 3 - 26
后台管理/src/pages/A1record/A1tab/A3tab3clue/index.tsx

@@ -1,8 +1,5 @@
 import React, { useCallback, useEffect, useMemo, useState } from 'react'
 import styles from './index.module.scss'
-import { useDispatch, useSelector } from 'react-redux'
-import { A1_APIgetList } from '@/store/action/A1record'
-import { RootState } from '@/store'
 import { A2ListType } from '@/pages/A2clue/data'
 import { A2_APIdel, A2_APIgetList } from '@/store/action/A2clue'
 import MyTable from '@/components/MyTable'
@@ -11,34 +8,14 @@ import { MessageFu } from '@/utils/message'
 import { Button } from 'antd'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import A2add from '@/pages/A2clue/A2add'
+import { A1ListSelectType } from '../../data'
 
 type Props = {
   sId: number
+  listAllRes: A1ListSelectType
 }
 
-function A3tab3clue({ sId }: Props) {
-  const dispatch = useDispatch()
-  // 获取所有烈士信息
-
-  useEffect(() => {
-    dispatch(
-      A1_APIgetList({
-        pageNum: 1,
-        pageSize: 99999
-      })
-    )
-  }, [dispatch])
-
-  const listAll = useSelector((state: RootState) => state.A1record.tableInfo.list)
-
-  const listAllRes = useMemo(() => {
-    return listAll.map(c => ({
-      value: c.id,
-      label: c.name
-    }))
-  }, [listAll])
-  // 获取所有烈士信息-end
-
+function A3tab3clue({ sId, listAllRes }: Props) {
   // 获取列表信息
   const [list, setList] = useState<A2ListType[]>([])
 

+ 6 - 1
后台管理/src/pages/A1record/data.ts

@@ -35,6 +35,12 @@ export type A1ListType = {
   videoIds: string
 }
 
+// 列表改成下拉框
+export type A1ListSelectType = {
+  value: number
+  label: string
+}[]
+
 export type LookInfoType = {
   id: number
   txt: '' | '新增' | '编辑' | '查看'
@@ -288,7 +294,6 @@ export const jiGuanFu = (item: A1ListType, flag = false, val = '籍贯') => {
 }
 
 // 人物关系图
-
 export type A1RRlistType = {
   id: number
   // martyrName: string //当前烈士

+ 2 - 4
后台管理/src/pages/A2clue/A2add/index.tsx

@@ -9,16 +9,14 @@ import ZupTypes from '@/components/ZupTypes'
 import ZupVideos from '@/components/ZupVideos'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import TextArea from 'antd/es/input/TextArea'
+import { A1ListSelectType } from '@/pages/A1record/data'
 
 type Props = {
   sId: number
   closeFu: () => void
   addTableFu: () => void
   upTableFu: () => void
-  listAllRes: {
-    value: number
-    label: string
-  }[]
+  listAllRes: A1ListSelectType
   // 从烈士档案中进来
   martyrId?: number
 }

+ 20 - 13
后台管理/src/pages/A2clue/index.tsx

@@ -11,6 +11,7 @@ import { Button, Select } from 'antd'
 import { A2select1, A2select2 } from './data'
 import { A1_APIgetList } from '@/store/action/A1record'
 import A2add from './A2add'
+import { A1ListSelectType, A1ListType } from '../A1record/data'
 
 const baseFromData = {
   pageNum: 1,
@@ -24,24 +25,30 @@ function A2clue() {
   const dispatch = useDispatch()
 
   // 获取所有烈士信息
+  const [listAllRes, setListAllRes] = useState<A1ListSelectType>([])
 
-  useEffect(() => {
-    dispatch(
-      A1_APIgetList({
+  const getListAllFu = useCallback(async () => {
+    const res = await A1_APIgetList(
+      {
         pageNum: 1,
         pageSize: 99999
-      })
+      },
+      true
     )
-  }, [dispatch])
-
-  const listAll = useSelector((state: RootState) => state.A1record.tableInfo.list)
+    if (res.code === 0) {
+      const list: A1ListType[] = res.data.records || []
+      setListAllRes(
+        list.map(c => ({
+          value: c.id,
+          label: c.name
+        }))
+      )
+    }
+  }, [])
 
-  const listAllRes = useMemo(() => {
-    return listAll.map(c => ({
-      value: c.id,
-      label: c.name
-    }))
-  }, [listAll])
+  useEffect(() => {
+    getListAllFu()
+  }, [getListAllFu])
   // 获取所有烈士信息-end
 
   const [fromData, setFromData] = useState(baseFromData)

+ 12 - 9
后台管理/src/store/action/A1record.ts

@@ -3,16 +3,19 @@ import { AppDispatch } from '..'
 /**
  * 烈士档案-获取列表
  */
-export const A1_APIgetList = (data: any): any => {
-  return async (dispatch: AppDispatch) => {
-    const res = await http.post('cms/martyr/pageList', data)
-    if (res.code === 0) {
-      const obj = {
-        list: res.data.records,
-        total: res.data.total
-      }
+export const A1_APIgetList = (data: any, flag = false): any => {
+  if (flag) return http.post('cms/martyr/pageList', data)
+  else {
+    return async (dispatch: AppDispatch) => {
+      const res = await http.post('cms/martyr/pageList', data)
+      if (res.code === 0) {
+        const obj = {
+          list: res.data.records,
+          total: res.data.total
+        }
 
-      dispatch({ type: 'A1/getList', payload: obj })
+        dispatch({ type: 'A1/getList', payload: obj })
+      }
     }
   }
 }