JustApply.js 3.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
/**
 * 只包含一站式流程的申请页面 会带部分字段参数到申请表单
 * 返回也是返回到上一个路由
 * */

import { message } from "antd";
import React, { Fragment } from "react";
import { getToken } from "@/utils/authority";

import PageHeaderWrapper from "@/components/PageHeaderWrapper";
import ButtonDiy from "@/baseComponent/ButtonDiy";
import Shell from "@/baseComponent/Shell";
import config from "@/config/config";
import router from "umi/router";

export default class AffairPage extends React.Component {
  constructor(props) {
    super(props);
    let state = this.props.location.state;
    if(!state || !state.id){
      console.error('无法获取流程id', 'JustApply.js');
    }
    this.state = {
      workId: state.id,
      init: {...state},
    };
  };

  componentDidMount() {
    if (!getToken()) {
      message.error("您的数据未同步,请联系管理员!");
      return false;
    }
    window.addEventListener("message", (event) => { // 和Iframe页进行通迅
      if (event.data === "returnList") {
        this.returnList(true);
      }
      if (event && event.data && event.data.indexOf && event.data.indexOf("iframeHeight") > -1) {
        let height = Number(event.data.split("-")[1]);
        const iframe = document.getElementById("applyIframeId");
        if (iframe) {
          iframe.height = height;
        }
      }
    }, false);

    return true;
  }

  returnList = () => {
    router.goBack();
  };

  render() {
    const { workId, init} = this.state;
    if (!workId) {
      return null;
    }
    const url = config.onestopPC.split("/#/");
60 61
    const params = `id=${workId}&token=${getToken()}&init=${encodeURIComponent(JSON.stringify(init))}`;
    let iframeUrl = `${url[0]}/#/IFrameForApply?${params}`;
62
    console.log(iframeUrl);
63
     // iframeUrl = `http://localhost:8001/onestop/IFrameForApply?${params}`;
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
    return (
      <PageHeaderWrapper title="">
        <div style={{
          visibility: "visible",
          backgroundColor: "#fff",
          paddingLeft: "24px"
        }}>
          <Shell>
            <div style={{
              height: "54px",
              padding: "12px 0 12px 12px",
              display: "block",
            }}>
              <ButtonDiy name="返回"
                         className="defaultBlue"
                         handleClick={this.returnList}
                         icon="arrow-left"
              />
            </div>
          </Shell>
          <iframe src={iframeUrl}
                  frameBorder={0}
                  id="applyIframeId"
                  name="applyIframe"
                  marginWidth="0"
                  marginHeight="0"
                  allowtransparency="yes"
                  seamless
                  scrolling={"auto"}
                  style={{
                    width: "100%",
                    minHeight: "800px",
                    overflowY: "hidden",
                    backgroundColor: "#fff"
                  }}
          />
          : null
        </div>
      </PageHeaderWrapper>
    );

  }
}