提交 3d9655ec authored 作者: 钟是志's avatar 钟是志

33647 【凯里市第一中等职业学校】学生证补办管理-辅导员审核,待审核列表中有审批通过的数据。账号:99040201

上级 33853767
import React from 'react';
import { Modal } from 'antd';
import { isJSON } from '@/webPublic/one_stop_public/copy';
const formatProps = (ModalFuncProps) => {
ModalFuncProps.getContainer = ModalFuncProps.getContainer || false;
return ModalFuncProps;
ModalFuncProps.getContainer = ModalFuncProps.getContainer || false;
return ModalFuncProps;
};
window.addEventListener(
'message',
(event) => {
if (event.data && event.data.indexOf) {
if (event.data.indexOf('iframeGetScrollHeight') > -1) {
const height = event.data.split('-')[1];
console.log('父页面向子iframe页面发送滚动高度: ', event.data);
let dom = document.getElementsByClassName('ant-modal-wrap');
if(dom && dom.length){
dom[0].style.top = height + 'px';
}
window.addEventListener('message', (event) => {
if (event.data && event.data.indexOf) {
if (event.data.indexOf('iframeGetScrollHeight') > -1) {
const height = event.data.split('-')[1];
console.log('父页面向子iframe页面发送滚动高度: ', event.data);
let dom = document.getElementsByClassName('ant-modal-wrap');
if (dom && dom.length) {
dom[0].style.top = height + 'px';
}
}
if (event.data.indexOf('parentRouteInfo') > -1) {
const info = event.data.split('-')[1];
console.log('父页面告知子页面路由信息: ', info);
if (info && isJSON(info)) {
localStorage.setItem('parentRouteInfo', info);
}
}
if (event.data.indexOf('setLocalStorage') > -1) {
const info = event.data.split('-');
console.log('父页面告知子页面localStorage信息: ', info);
if (info && info.length > 2) {
localStorage.setItem(info[1], info[2]);
}
}
}
});
const sendMessageAndGetHeight = () => { // 获取当前屏幕滚动的高度 并将Modal 弹窗的高度绝对定位到屏幕以内
window.top.postMessage('iframeGetScrollHeight', '*');
const sendMessageAndGetHeight = () => {
// 获取当前屏幕滚动的高度 并将Modal 弹窗的高度绝对定位到屏幕以内
window.top.postMessage('iframeGetScrollHeight', '*');
};
const DiyIframeModal = (props) => {
return <Modal {...props}/>;
return <Modal {...props} />;
};
const ModalFuncs = function (ModalFuncProps, type = 'info') {
sendMessageAndGetHeight();
const ModalFuncs = function(ModalFuncProps, type = 'info') {
sendMessageAndGetHeight();
return Modal[type](formatProps(ModalFuncProps));
return Modal[type](formatProps(ModalFuncProps));
};
DiyIframeModal.info = function(ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'info');
return ModalFuncs(ModalFuncProps, 'info');
};
DiyIframeModal.success = function (ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'success');
DiyIframeModal.success = function(ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'success');
};
DiyIframeModal.error = function (ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'error');
DiyIframeModal.error = function(ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'error');
};
DiyIframeModal.warning = function (ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'warning');
DiyIframeModal.warning = function(ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'warning');
};
DiyIframeModal.confirm = function (ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'confirm');
DiyIframeModal.confirm = function(ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'confirm');
};
DiyIframeModal.warn = function (ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'warn');
DiyIframeModal.warn = function(ModalFuncProps) {
return ModalFuncs(ModalFuncProps, 'warn');
};
DiyIframeModal.destroyAll = function (){
return Modal.destroyAll();
DiyIframeModal.destroyAll = function() {
return Modal.destroyAll();
};
export default DiyIframeModal;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论