|
@@ -15,26 +15,30 @@ interface iFileState {
|
|
|
createTime: string
|
|
|
}
|
|
|
|
|
|
-const File: React.FC<{type: 'income' | 'expenditure'}> = ({ type }) => {
|
|
|
+const File: React.FC<{ type: 'income' | 'expenditure' }> = ({ type }) => {
|
|
|
const [ data, setData ] = useState<Array<iFileState>>([])
|
|
|
const [ total, setTotal ] = useState<number>(0)
|
|
|
const [ id, setId ] = useState<string>('')
|
|
|
+ const [ pagination, setPagination ] = useState({
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 7
|
|
|
+ })
|
|
|
useEffect(() => {
|
|
|
if (contractStore.contract.id) {
|
|
|
if (contractStore.contract.id !== id) {
|
|
|
setId(contractStore.contract.id)
|
|
|
initData()
|
|
|
} else if (contractStore.shouldUpdate && contractStore.shouldUpdate === '3') {
|
|
|
- initData()
|
|
|
+ initData(pagination.pageNo, pagination.pageSize)
|
|
|
}
|
|
|
contractStore.shouldUpdate && (contractStore.changeUpdate(''))
|
|
|
}
|
|
|
}, [ contractStore.contract.id, contractStore.shouldUpdate ])
|
|
|
|
|
|
const initData = async (pageNo: number = 1, pageSize: number = 7) => {
|
|
|
+ setPagination({ ...pagination, pageNo, pageSize })
|
|
|
const { code = -1, data = [], total = 0 } = await apiGetFileList(type === 'income' ? consts.DATA_TYPE.CONTRACT_RETURN : consts.DATA_TYPE.CONTRACT_PAID, contractStore.contract.id, pageNo, pageSize)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
-
|
|
|
setData(data)
|
|
|
setTotal(total)
|
|
|
}
|