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

2073 开发需求1229

上级 3e485400
...@@ -4,50 +4,73 @@ import styles from './index.less'; ...@@ -4,50 +4,73 @@ import styles from './index.less';
import { fetchTemplateByCode, fetchTableItem } from '@/webPublic/Services'; import { fetchTemplateByCode, fetchTableItem } from '@/webPublic/Services';
import { isJSON } from '@/webPublic/zyd_public/utils/utils'; import { isJSON } from '@/webPublic/zyd_public/utils/utils';
import SelectPerson from '@/webPublic/FormInsertDiy/ExportComponent/SelectPerson/Index'; import SelectPerson from '@/webPublic/FormInsertDiy/ExportComponent/SelectPerson/Index';
import Detail from '@/webPublic/FormInsertDiy/AffairPage/Detail';
export default function RenderForm({ export default function RenderForm({ get = 'web', isCg = 'yes', style, ...rest }) {
get = 'web', let content = rest?.postData?.unifiedServicePatternModel?.content;
isCg = 'yes', if (isJSON(content)) {
style, content = JSON.parse(content);
...rest }
}) { const tableRoot = useRef();
let content = rest?.postData?.unifiedServicePatternModel?.content; const [showPageType, setShowPageType] = useState(0);
if (isJSON(content)) { const [pageProps, setPageProps] = useState({});
content = JSON.parse(content); useEffect(() => {
} const timerId = setTimeout(() => {
const tableRoot = useRef(); // 修改样式
useEffect(() => { const div = tableRoot.current && tableRoot.current.root;
const timerId = setTimeout(() => { if (div) {
const div = tableRoot.current && tableRoot.current.root; div.style.overflow = 'unset';
if (div) { }
div.style.overflow = 'unset'; let new_element = document.createElement('style');
} new_element.innerHTML = `main>div>#web_table .login-form>div>div>div{
let new_element = document.createElement('style');
new_element.innerHTML = `main>div>#web_table .login-form>div>div>div{
overflow: inherit !important; overflow: inherit !important;
}`; }`;
document.body.appendChild(new_element); document.body.appendChild(new_element);
}, 0); }, 0);
return () => {
clearTimeout(timerId);
};
}, []);
if (!content) {
return null;
}
return ( window.keepAliveCheckRecord = {
<div className={styles.zyd_onestop_style_class} style={style}> showList: (props) => {
<ZdyTable ref={tableRoot} setShowPageType(0);
get={get} setPageProps({});
{...rest} document.getElementById('listZdyTable').style.display = 'block';
isQuery={true} },
init={undefined} showDetail: (p) => {
{...content} setPageProps({
/> ...p,
<SelectPerson /> history: {...p},
</div> });
); setShowPageType(1);
console.log(p);
document.getElementById('listZdyTable').style.display = 'none';
},
};
return () => {
clearTimeout(timerId);
};
}, []);
if (!content) {
return null;
}
console.log(showPageType);
return (
<>
<div className={styles.zyd_onestop_style_class} style={style} id={'listZdyTable'}>
<ZdyTable
ref={tableRoot}
get={get}
{...rest}
isQuery={true}
init={undefined}
{...content}
/>
<SelectPerson />
</div>
{showPageType === 1 && <Detail {...pageProps} />}
</>
);
} }
/** /**
...@@ -55,37 +78,30 @@ export default function RenderForm({ ...@@ -55,37 +78,30 @@ export default function RenderForm({
* @param {Object} content 表单内容,传入对象 * @param {Object} content 表单内容,传入对象
* @param {String} templateCode 表单模板 * @param {String} templateCode 表单模板
*/ */
export function RenderFormByContent({ export function RenderFormByContent({ content, templateCode, form, get, isCg }) {
content, const [formTemplate, setFormTemplate] = useState();
templateCode, useEffect(
form, () => {
get, fetchTemplateByCode(templateCode).then((res) => {
isCg if (res) {
}) { setFormTemplate(res);
const [formTemplate, setFormTemplate] = useState(); }
useEffect( });
() => { },
fetchTemplateByCode(templateCode) [templateCode],
.then((res) => { );
if (res) {
setFormTemplate(res);
}
});
},
[templateCode],
);
return formTemplate ? ( return formTemplate ? (
<RenderForm <RenderForm
get={get} get={get}
isCg={isCg} isCg={isCg}
postData={{ postData={{
content: JSON.stringify(content), content: JSON.stringify(content),
unifiedServicePatternModel: formTemplate, unifiedServicePatternModel: formTemplate,
}} }}
form={form} form={form}
/> />
) : null; ) : null;
} }
/** /**
...@@ -96,40 +112,39 @@ export function RenderFormByContent({ ...@@ -96,40 +112,39 @@ export function RenderFormByContent({
* @param {Function} onLoad 数据加载的回调函数 * @param {Function} onLoad 数据加载的回调函数
*/ */
export function RenderFormByObjId({ export function RenderFormByObjId({
objId, objId,
dataTypeKey, dataTypeKey,
dataTypeValue, dataTypeValue,
onLoad, onLoad,
templateCode, templateCode,
form, form,
get, get,
isCg, isCg,
}) { }) {
const [content, setContent] = useState({}); const [content, setContent] = useState({});
useEffect( useEffect(
() => { () => {
fetchTableItem({ fetchTableItem({
dataObjId: objId, dataObjId: objId,
key: dataTypeKey, key: dataTypeKey,
value: dataTypeValue value: dataTypeValue,
}) }).then((res) => {
.then((res) => { setContent(res || {});
setContent(res || {}); if (onLoad) {
if (onLoad) { onLoad(res);
onLoad(res); }
} });
}); },
}, [objId, dataTypeKey, dataTypeValue],
[objId, dataTypeKey, dataTypeValue], );
);
return ( return (
<RenderFormByContent <RenderFormByContent
get={get} get={get}
isCg={isCg} isCg={isCg}
content={content} content={content}
templateCode={templateCode} templateCode={templateCode}
form={form} form={form}
/> />
); );
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论