Procházet zdrojové kódy

feat: 合同回款、文件序号序号累加当前页码

lanjianrong před 4 roky
rodič
revize
3ffcbe4d48

+ 4 - 3
src/pages/Contract/Content/Income/components/Tabs/File/index.tsx

@@ -44,10 +44,11 @@ const File: React.FC<{ type: 'income' | 'expenditure' }> = ({ type }) => {
   }, [ contractStore.contract.id, contractStore.activeKey ])
 
   const initData = async (pageNo: number = 1, pageSize: number = 8) => {
-    setState({ ...state, pageNo, pageSize })
     const { code = -1, data = [], total = 0 } = await apiGetFileList(type === ContractType.INCOME ? consts.DATA_TYPE.INCOME : consts.DATA_TYPE.EXPENDITURE, contractStore.contract.id, pageNo, pageSize)
     if (code === consts.RET_CODE.SUCCESS) {
-      setState({ ...state, data, total })
+      setState({ ...state, data, total, pageNo, pageSize })
+      console.log(state.pageNo)
+
       contractStore.activeKey && (contractStore.changeActiveKey(''))
     }
   }
@@ -63,7 +64,7 @@ const File: React.FC<{ type: 'income' | 'expenditure' }> = ({ type }) => {
     {
       dataIndex: 'sort',
       // eslint-disable-next-line react/display-name
-      render: (_: any, record: iFileState, idx: number) => <span>{idx + 1}</span>,
+      render: (_: any, record: iFileState, idx: number) => <span>{((state.pageNo - 1) * state.pageSize) + idx + 1}</span>,
       width: '5%'
     },
     {

+ 8 - 6
src/pages/Contract/Content/Income/components/Tabs/Receivable/index.tsx

@@ -69,7 +69,8 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
   const y = useTabHeighAuto()
   const [ form ] = Form.useForm()
   const [ data, setData ] = useState<Array<iReceivableState>>([])
-  const [ id, setId ] = useState<string>('')
+  const [ rowId, setRowId ] = useState<string>('')
+  const [ page, setPage ] = useState(1)
   const [ fileModal, setFileModal ] = useState<iFileModal>({
     visible: false,
     dataType: consts.DATA_TYPE[type === ContractType.INCOME ? 'CONTRACT_RETURN' : 'CONTRACT_PAID'],
@@ -90,15 +91,15 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
 
     !commonStore.returnWayOptions.length && (commonStore.queryWayOptions())
     if (contractStore.contract.id) {
-      if (contractStore.contract.id !== id) {
-        setId(contractStore.contract.id)
+      if (contractStore.contract.id !== rowId) {
+        setRowId(contractStore.contract.id)
         initData()
       } else if (contractStore.activeKey && contractStore.activeKey === '2') {
 
         initData()
       }
     } else {
-      setId('')
+      setRowId('')
       // 项目节的点击,数据为空数组
       setData([])
     }
@@ -144,7 +145,7 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
       width: '5%',
       // eslint-disable-next-line react/display-name
       render: (_: any, record: any, index: number) => {
-        return <span>{index + 1}</span>
+        return <span>{((page - 1) * 8 ) +index + 1}</span>
       }
     },
     {
@@ -229,7 +230,8 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
     }
   }
 
-  const cancel = () => {
+  const cancel = (pageNo: number) => {
+    setPage(pageNo)
     setEditingKey('')
   }