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

templateWillMount公式修改

上级 1d49f9c1
import React, {useEffect, useState, useRef, memo} from 'react';
import React from 'react';
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) {
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 && !window.zdyTableTemplateWillMountInit) {
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);
console.log('开始执行templateWillMount公式');
window.zdyTableTemplateWillMountInit = true;
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);
}
} else {
setPrepareShow(true);
}
}, []);
return prepareShow ? <ZdyTable {...props} /> : <Spin size={'large'}/>;
export default function Index(props) {
return <ZdyTable {...props} />;
}
import React, {useEffect, useState, useRef, memo} from 'react';
import {isJSON} from '@/webPublic/one_stop_public/copy';
import {uaaRequest} from '@/webPublic/one_stop_public/utils/request';
import {Modal, message, Spin} from 'antd';
import {deepCopy} from "@/webPublic/one_stop_public/utils/myutils";
export default function prepareShow(postData) {
let agg = deepCopy(postData);
return new Promise((resolve, reject) => {
if(window.location.href.indexOf('mobile/FlowDetail') > -1){
resolve(true);
return;
}
// resolve(true);
// return;
let data = postData?.unifiedServicePatternModel?.content;
let g = !!data && isJSON(data) && 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: agg,
};
let newFunc = new Function('props', g);
console.log('开始执行templateWillMount公式');
window.zdyTableTemplateWillMountInit = true;
try {
newFunc(p)
.then(res => {
if (res) {
console.log('执行templateWillMount公式完成', res);
window.zdyTableTemplateWillMountProps = res;
resolve(true);
// return postData;
}
})
.catch(error => {
window.zdyTableTemplateWillMountProps = undefined;
resolve(true);
console.log('模板挂载时公式执行失败', error);
});
} catch (e) {
resolve(true);
console.log(e);
}
}
});
}
......@@ -5,6 +5,8 @@
*/
import { uaaRequest } from '../utils/request';
import { Base16Encode } from '../Base16/index';
import prepareShow from "@/webPublic/one_stop_public/Table/prepareShow";
import {deepCopy} from "@/webPublic/one_stop_public/utils/myutils";
const api = '/UnifiedAppFormApi';
const myCollect = {
......@@ -126,9 +128,10 @@ const myCollect = {
if (payload.taskForm) {
payload.taskForm = Base16Encode(payload.taskForm);
}
const response = yield call(uaaRequest, `${api}/examineProcess`, {
let response = yield call(uaaRequest, `${api}/examineProcess`, {
...payload,
});
if (response == null) {
yield put({ type: 'nom' });
return;
......@@ -149,6 +152,8 @@ const myCollect = {
yield put({ type: 'nom' });
return;
}
yield call(prepareShow, deepCopy(response));
if (callback) {
callback(response);
}
......
......@@ -4,6 +4,8 @@
* 主页接口
*/
import { uaaRequest } from '../utils/request';
import prepareShow from "@/webPublic/one_stop_public/Table/prepareShow";
const myCollect = {
namespace: 'modileHome',
state: {
......@@ -101,7 +103,9 @@ const myCollect = {
yield put({ type: 'nom' });
return;
}
if (callback) {
yield call(prepareShow, response);
if (callback) {
callback(response);
}
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论