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

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

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