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

增加 表单模版挂载前的配置公式 获取全局变量

上级 4cddf515
import React, {useEffect, useState, useRef, memo} from 'react'; import React, {useEffect, useState, useRef, memo} from 'react';
import ZdyTable from './ZdyTable'; import ZdyTable from './ZdyTable';
import {isJSON} from '@/webPublic/one_stop_public/copy';
import {uaaRequest} from '@/webPublic/one_stop_public/utils/request';
import {Modal, message, Spin} from 'antd';
export default function PrentIndex(props) { export default function PrentIndex(props) {
useEffect(() => {
const [prepareShow, setPrepareShow] = useState(false);
useEffect(() => {
let data = props?.postData?.unifiedServicePatternModel?.content;
if (data && isJSON(data)) { // 模板挂载时公式执行
let g = JSON.parse(data)?.templateWillMount;
if (g && typeof g === 'string' && g.length > 10) {
let p = {
message,
Modal,
uaaRequest,
userNowInfo:
(isJSON(localStorage.getItem('user')) && JSON.parse(localStorage.getItem('user'))) ||
{},
templateData: props.postData,
routerState: props?.routerState,
};
let newFunc = new Function('props', g);
try {
newFunc(p)
.then(res => {
if (res) {
window.zdyTableTemplateWillMountProps = res;
setPrepareShow(true);
}
})
.catch(error => {
window.zdyTableTemplateWillMountProps = undefined;
setPrepareShow(true);
console.log('模板挂载时公式执行失败', error);
});
} catch (e) {
console.log(e);
setPrepareShow(true);
}
}
}
else{
setPrepareShow(true);
}
}, []); }, []);
return <ZdyTable {...props}/>; return prepareShow ? <ZdyTable {...props} /> : <Spin size={'large'}/>;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论