提交 78ae0673 authored 作者: wanyielin's avatar wanyielin

上传快照公共组件

上级 9934afe4
...@@ -6,81 +6,84 @@ import router from 'umi/router'; ...@@ -6,81 +6,84 @@ import router from 'umi/router';
import { getToken } from '@/utils/authority'; import { getToken } from '@/utils/authority';
import config from '@/config/config'; import config from '@/config/config';
export default class Detail extends Component {
constructor(props) {
super(props);
const { state } = this.props.location;
let id = '';
if (state && state.record && state.record.id) {
const { record } = state;
id = record.id;
}
this.state = {
id,
};
}
export default class Detail extends Component{ componentDidMount() {
constructor(props){ window.addEventListener(
super(props); 'message',
const { state } = this.props.location; (event) => {
let id = ''; if (event.data && event.data.indexOf && event.data.indexOf('iframeDetailHeight') > -1) {
if(state && state.record && state.record.id){ const height = Number(event.data.split('-')[1]);
const { record } = state; document.getElementById('detailIframeId').height = height;
id = record.id; }
} },
this.state={ false,
id, );
}; }
}
componentDidMount(){ showAll = () => {
window.addEventListener('message', (event) => { this.setState({
if(event.data && event.data.indexOf && event.data.indexOf('iframeDetailHeight') > -1){ showAll: true,
let height = Number(event.data.split('-')[1]); });
document.getElementById('detailIframeId').height = height; };
}
}, false);
}
showAll = () => { render() {
this.setState({ const { id, showAll } = this.state;
showAll: true, const url = config.onestopPC.split('/#/');
}); const iframeUrl = `${url[0]}/#/IframeForDetail?id=${id}&token=${getToken()}`;
}; // iframeUrl = `http://localhost:8000/onestop/IframeForDetail?id=${id}&token=${getToken()}`;
return (
render(){ <PageHeaderWrapper title="">
const { id, showAll } = this.state; <Shell>
const url = config.onestopPC.split('/#/'); <div
let iframeUrl = `${url[0]}/#/IframeForDetail?id=${id}&token=${getToken()}`; style={{
//iframeUrl = `http://localhost:8000/onestop/IframeForDetail?id=${id}&token=${getToken()}`; height: '54px',
return ( padding: '12px 0 12px 12px',
<PageHeaderWrapper title=""> }}>
{showAll ? (
<Shell> <ButtonDiy
<div style={{ name="返回"
height: '54px', className="defaultBlue"
padding: '12px 0 12px 12px', handleClick={() => {
}}> router.goBack();
{ }}
showAll ? icon="arrow-left"
<ButtonDiy name="返回" />
className="defaultBlue" ) : null}
handleClick={()=>{ </div>
router.goBack(); </Shell>
}} <Shell>
icon="arrow-left" <iframe
/> src={iframeUrl}
: null frameBorder={0}
} id="detailIframeId"
</div> name="applyIframe"
</Shell> marginWidth="0"
<Shell> marginHeight="0"
<iframe src={iframeUrl} onLoad={this.showAll}
frameBorder={0} allowTransparency="yes"
id='detailIframeId' seamless
name='applyIframe' scrolling={'no'}
marginWidth="0" style={{
marginHeight="0" width: '100%',
onLoad={this.showAll} overflowY: 'hidden',
allowTransparency="yes" minHeight: '800px',
seamless }}
scrolling={'no'} />
style={{ </Shell>
width: '100%', </PageHeaderWrapper>
overflowY: 'hidden', );
minHeight: '800px', }
}}
/>
</Shell>
</PageHeaderWrapper>
)
}
} }
import React, { Fragment, Component } from 'react';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import Shell from '@/baseComponent/Shell';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import router from 'umi/router';
import { getToken } from '@/utils/authority';
import config from '@/config/config';
export default class Detail extends Component {
constructor(props) {
super(props);
const { state } = this.props.location;
let id = '';
if (state && state.record && state.record.id) {
const { record } = state;
id = record.id;
}
this.state = {
id,
};
}
componentDidMount() {
window.addEventListener(
'message',
(event) => {
if (event.data && event.data.indexOf && event.data.indexOf('iframeDetailHeight') > -1) {
const height = Number(event.data.split('-')[1]);
document.getElementById('detailIframeId').height = height;
}
},
false,
);
}
showAll = () => {
this.setState({
showAll: true,
});
};
render() {
const { id, showAll } = this.state;
const url = config.onestopPC.split('/#/');
// console.log(url);
const iframeUrl = `${url[0]}/#/IFrameSnapshot?token=${getToken()}`;
// iframeUrl = `http://localhost:8000/onestop/IframeForDetail?id=${id}&token=${getToken()}`;
return (
<PageHeaderWrapper title="">
<Shell>
<div
style={{
height: '54px',
padding: '12px 0 12px 12px',
}}>
{showAll ? (
<ButtonDiy
name="返回"
className="defaultBlue"
handleClick={() => {
router.goBack();
}}
icon="arrow-left"
/>
) : null}
</div>
</Shell>
<Shell>
<iframe
src={iframeUrl}
frameBorder={0}
id="detailIframeId"
name="applyIframe"
marginWidth="0"
marginHeight="0"
onLoad={this.showAll}
allowTransparency="yes"
seamless
scrolling={'no'}
style={{
width: '100%',
overflowY: 'hidden',
minHeight: '800px',
}}
/>
</Shell>
</PageHeaderWrapper>
);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论