Detail.js 4.6 KB
Newer Older
1
import React, { Component } from 'react';
王绍森's avatar
王绍森 committed
2 3 4 5
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import Shell from '@/baseComponent/Shell';
import ButtonDiy from '@/baseComponent/ButtonDiy';
import router from 'umi/router';
6
import { getToken } from '@/utils/authority';
王绍森's avatar
王绍森 committed
7
import config from '@/config/config';
8
import { message, Modal, notification, Popconfirm } from 'antd';
钟是志's avatar
钟是志 committed
9
import DetailOneStop from '@/webPublic/one_stop_public/DetailForAudit/IframeForDetail';
10

钟是志's avatar
钟是志 committed
11 12 13 14
window.iframeParentComponent = {
  Modal,
  message,
  notification,
15
  Popconfirm,
钟是志's avatar
钟是志 committed
16
};
王绍森's avatar
王绍森 committed
17

18
const getUrlInfo = (param) => {
19 20 21 22 23 24 25 26 27 28 29 30 31
  let url = window.document.location.href.toString();
  let u = url.split('?');
  if (typeof u[1] == 'string') {
    u = u[1].split('&');
    let get = {};
    for (let i in u) {
      let j = u[i].split('=');
      get[j[0]] = decodeURIComponent(j[1]);
    }
    return get;
  } else {
    return {};
  }
32 33
};

34
export default class Detail extends Component {
35 36 37 38 39 40 41 42 43 44 45 46 47
  constructor(props) {
    super(props);
    const { state } = this.props.location;
    let id = '';
    if (state && state.record && state.record.id) {
      const { record } = state;
      id = record.id;
    }
    if (!id) {
      id = getUrlInfo()?.id;
    }
    this.state = {
      id,
48
      showAll: props.from !== 'onestopApp2.0'
49 50
    };
  }
王绍森's avatar
王绍森 committed
51

52 53 54 55 56 57
  componentDidMount() {
    window.addEventListener(
      'message',
      (event) => {
        if (event.data && event.data.indexOf && event.data.indexOf('iframeDetailHeight') > -1) {
          const height = Number(event.data.split('-')[1]);
58 59 60 61
          const dom = document.getElementById('detailIframeId');
          if(dom){
            document.getElementById('detailIframeId').height = height +  50;
          }
62 63 64 65 66
        }
      },
      false,
    );
  }
王绍森's avatar
王绍森 committed
67

68 69 70 71 72
  showAll = () => {
    this.setState({
      showAll: true,
    });
  };
王绍森's avatar
王绍森 committed
73

74
  render() {
75
    const { from } = this.props;
76 77 78
    const { id, showAll } = this.state;
    const url = config.onestopPC.split('/#/');
    let showPrint = this.props.location?.state?.showPrint;
79

80 81 82
    let iframeUrl = `${url[0]}/#/IframeForDetail?id=${id}&token=${getToken()}`;
    if (showPrint) {
      iframeUrl = iframeUrl + '&showPrint=true';
83
    }
84
    if (from === 'onestopApp2.0') {
85 86
      iframeUrl = config.gateWayPort + `/portal/#/showAuditIframe?id=${id}&hasSingle=false&token=${getToken()}&isPrint=false`;
    }
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
    // 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}
            <ButtonDiy
              name={'全屏查看'}
              className='defaultBlue'
              handleClick={() => {
                document.getElementById('detailIframeId').requestFullscreen();
              }} />
          </div>
        </Shell>
        <Shell>
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
          {
            from === 'onestopApp2.0' ?
              <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: '80vh',
                }}
              /> :
              <div id={'detailIframeId'}>
135
              <DetailOneStop id={id} {...this.props} showPrint={showPrint || false}/>
136 137 138
              </div>
          }

139 140 141 142 143 144 145
        </Shell>
        <Shell>
          <div
            style={{
              height: '54px',
              padding: '12px 0 12px 12px',
            }}>
146 147 148 149 150 151 152 153 154 155
            {showAll ? (
              <ButtonDiy
                name='返回'
                className='defaultBlue'
                handleClick={() => {
                  router.goBack();
                }}
                icon='arrow-left'
              />
            ) : null}
156 157 158 159 160 161 162 163 164 165 166 167
            <ButtonDiy
              name={'全屏查看'}
              type={'primary'}
              // className='primaryBlue'
              handleClick={() => {
                document.getElementById('detailIframeId').requestFullscreen();
              }} />
          </div>
        </Shell>
      </PageHeaderWrapper>
    );
  }
王绍森's avatar
王绍森 committed
168
}