Commit 77a80fae authored by Sixiang_Zzb's avatar Sixiang_Zzb

修改物业费详情pdf展示

parent 388f05b7
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import styles from './ChargeDetail.less'; import styles from './ChargeDetail.less';
import { Pagination, Tooltip } from 'antd'; import { Pagination, Tooltip, Spin } from 'antd';
import { useIntl, connect } from 'umi'; import { useIntl, connect } from 'umi';
...@@ -12,19 +12,39 @@ import { timestampToTime } from '../../utils/time'; ...@@ -12,19 +12,39 @@ import { timestampToTime } from '../../utils/time';
import TitleBack from '../../components/TitleBack/TitleBack'; import TitleBack from '../../components/TitleBack/TitleBack';
const ChargeDetail = (props: any) => { const ChargeDetail = (props: any) => {
const { CurData } = props; const { CurData, dispatch, FileImg } = props;
const [scale, setState] = useState(1.3); const [scale, setState] = useState(1.3);
const [pages, setPages] = useState(1); const [pages, setPages] = useState(1);
const [curpage, setCurpage] = useState(1); const [curpage, setCurpage] = useState(1);
const [loading, setLoading] = useState(false);
useEffect(() => { useEffect(() => {
console.log(CurData); if (CurData) {
if (!CurData) { dispatch({
type: 'Contract/RA',
playload: {
index: 47,
body: {
type: 'tosAccountPreview',
fileName: CurData.billName,
extends: CurData.communityName,
},
},
});
setLoading(true);
} else {
history.back(); history.back();
} }
}, []); }, []);
useEffect(() => {
if (FileImg) {
setLoading(false);
}
}, [FileImg]);
const pdfpages = (pages: any) => { const pdfpages = (pages: any) => {
setPages(pages); setPages(pages);
}; };
...@@ -64,7 +84,7 @@ const ChargeDetail = (props: any) => { ...@@ -64,7 +84,7 @@ const ChargeDetail = (props: any) => {
<div className={styles.box4}> <div className={styles.box4}>
<Pagination simple defaultCurrent={curpage} total={pages * 10} onChange={pageChange} /> <Pagination simple defaultCurrent={curpage} total={pages * 10} onChange={pageChange} />
</div> </div>
<> <Spin spinning={loading}>
<Tooltip title={scale == 1.3 ? '点击放大查看' : '还原视图'}> <Tooltip title={scale == 1.3 ? '点击放大查看' : '还原视图'}>
<div className={scale == 1.3 ? styles.box3out : null}> <div className={scale == 1.3 ? styles.box3out : null}>
<div className={scale == 1.3 ? styles.box3 : styles.box3of} onClick={lookup}> <div className={scale == 1.3 ? styles.box3 : styles.box3of} onClick={lookup}>
...@@ -72,7 +92,7 @@ const ChargeDetail = (props: any) => { ...@@ -72,7 +92,7 @@ const ChargeDetail = (props: any) => {
// key="pdfjs" // key="pdfjs"
file={ file={
// 'data:application/pdf;base64,' + stringSplit(CurData.billFileUrl, 'm/cash') // 'data:application/pdf;base64,' + stringSplit(CurData.billFileUrl, 'm/cash')
stringSplit(CurData.billFileUrl, 'm/cash') stringSplit(CurData.billFileUrl || FileImg[0].fileUrl, 'm/cash')
} }
// workerSrc="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.228/pdf.worker.js" // workerSrc="//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.228/pdf.worker.js"
scale={scale} scale={scale}
...@@ -82,7 +102,7 @@ const ChargeDetail = (props: any) => { ...@@ -82,7 +102,7 @@ const ChargeDetail = (props: any) => {
</div> </div>
</div> </div>
</Tooltip> </Tooltip>
</> </Spin>
</> </>
) : null} ) : null}
</div> </div>
...@@ -91,8 +111,10 @@ const ChargeDetail = (props: any) => { ...@@ -91,8 +111,10 @@ const ChargeDetail = (props: any) => {
function mapStateToProps(state: any) { function mapStateToProps(state: any) {
const { CurData } = state.PropertyManagement; const { CurData } = state.PropertyManagement;
const { FileImg } = state.Contract;
return { return {
CurData, CurData,
FileImg,
}; };
} }
export default connect(mapStateToProps)(ChargeDetail); export default connect(mapStateToProps)(ChargeDetail);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment