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

templateWillMount公式修改

上级 1d49f9c1
import React, {useEffect, useState, useRef, memo} from 'react'; import React 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 Index(props) {
const [prepareShow, setPrepareShow] = useState(false); return <ZdyTable {...props} />;
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'}/>;
} }
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 @@ ...@@ -5,6 +5,8 @@
*/ */
import { uaaRequest } from '../utils/request'; import { uaaRequest } from '../utils/request';
import { Base16Encode } from '../Base16/index'; 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 api = '/UnifiedAppFormApi';
const myCollect = { const myCollect = {
...@@ -126,9 +128,10 @@ const myCollect = { ...@@ -126,9 +128,10 @@ const myCollect = {
if (payload.taskForm) { if (payload.taskForm) {
payload.taskForm = Base16Encode(payload.taskForm); payload.taskForm = Base16Encode(payload.taskForm);
} }
const response = yield call(uaaRequest, `${api}/examineProcess`, { let response = yield call(uaaRequest, `${api}/examineProcess`, {
...payload, ...payload,
}); });
if (response == null) { if (response == null) {
yield put({ type: 'nom' }); yield put({ type: 'nom' });
return; return;
...@@ -149,6 +152,8 @@ const myCollect = { ...@@ -149,6 +152,8 @@ const myCollect = {
yield put({ type: 'nom' }); yield put({ type: 'nom' });
return; return;
} }
yield call(prepareShow, deepCopy(response));
if (callback) { if (callback) {
callback(response); callback(response);
} }
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
* 主页接口 * 主页接口
*/ */
import { uaaRequest } from '../utils/request'; import { uaaRequest } from '../utils/request';
import prepareShow from "@/webPublic/one_stop_public/Table/prepareShow";
const myCollect = { const myCollect = {
namespace: 'modileHome', namespace: 'modileHome',
state: { state: {
...@@ -101,7 +103,9 @@ const myCollect = { ...@@ -101,7 +103,9 @@ const myCollect = {
yield put({ type: 'nom' }); yield put({ type: 'nom' });
return; return;
} }
if (callback) { yield call(prepareShow, response);
if (callback) {
callback(response); callback(response);
} }
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论