ソースを参照

选择藏品修改为分页

shaogen1995 2 週間 前
コミット
7ed106601f

+ 1 - 1
src/pages/Zother/EditTop/index.tsx

@@ -12,7 +12,7 @@ import { API_objType } from '@/store/action/Dmanage/D1register'
 import { editPageToTopFu } from '@/utils/authority'
 import { FileUpInfoType } from '../data'
 
-const pageKeyTxtObj = {
+export const pageKeyTxtObj = {
   1: '新增',
   2: '编辑',
   3: '审批',

+ 29 - 5
src/pages/Zother/SelectGoods/index.tsx

@@ -61,6 +61,7 @@ function SelectGoods({
     }, 50)
   }, [baseFormData])
 
+  const [total, setTotal] = useState(0)
   const [tableList, setTableList] = useState<GoodsType[]>([])
   const [tableListAll, setTableListAll] = useState<GoodsType[]>([])
 
@@ -72,12 +73,21 @@ function SelectGoods({
       ...canObjTemp
     }
 
+    // 第一次进来,获取到所有数据
+    if (timeKey === 0) obj.pageSize = 99999
+
     const res = await API_getList(obj)
     if (res.code === 0) {
-      setTableList(res.data.records || [])
-      if (timeKey === 0) setTableListAll(res.data.records || [])
+      let resArr: any[] = res.data.records || []
+
+      if (timeKey === 0) {
+        resArr = resArr.filter((v, i) => i < baseFormData.pageSize)
+        setTableListAll(res.data.records || [])
+      }
+      setTotal(res.data.total)
+      setTableList(resArr)
     }
-  }, [API_getList, canObj, timeKey])
+  }, [API_getList, baseFormData.pageSize, canObj, timeKey])
 
   useEffect(() => {
     getList()
@@ -206,6 +216,17 @@ function SelectGoods({
     [formData]
   )
 
+  // 页码变化
+  const paginationChange = useCallback(
+    (pageNum: number, pageSize: number) => {
+      setFormData({ ...formData, pageNum, pageSize })
+      setTimeout(() => {
+        setTimeKey(Date.now())
+      }, 50)
+    },
+    [formData]
+  )
+
   return (
     <Modal
       wrapClassName={styles.SelectGoods}
@@ -231,13 +252,16 @@ function SelectGoods({
 
         {/* 表格 */}
         <MyTable
-          yHeight={575}
+          yHeight={565}
           classKey='SelectGoods'
           list={tableList}
           columnsTemp={columnsTemp}
           staBtn={staBtn}
           lastBtn={tableLastBtn}
-          pagingInfo={false}
+          pageNum={formData.pageNum}
+          pageSize={formData.pageSize}
+          total={total}
+          onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
         />
 
         <div className='sgMainBtn'>

+ 2 - 2
src/pages/Zother/SonGoodsList/data.ts

@@ -69,7 +69,7 @@ export type GoodsType = {
 // 选择线索-----------------
 export const sgBaseFormData = {
   pageNum: 1,
-  pageSize: 99999,
+  pageSize: 10,
 
   searchKey: '',
   typeDictId: '',
@@ -106,7 +106,7 @@ export const sgTopSelectDom = [
 // 选择藏品-----------------------
 export const sgBaseFormDataGood = {
   pageNum: 1,
-  pageSize: 99999,
+  pageSize: 10,
 
   searchKey: '',
   tagIds: '',