Commit fba7abdf authored by 涂伟's avatar 涂伟

fix: '代码还原'

parent 773f7611
Pipeline #69094 passed with stages
/* eslint-disable no-shadow */ /* eslint-disable no-shadow */
/* eslint-disable react/jsx-boolean-value */ /* eslint-disable react/jsx-boolean-value */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { import {
Form, Form,
Modal, Modal,
...@@ -25,6 +25,8 @@ import { ...@@ -25,6 +25,8 @@ import {
RollbackOutlined, RollbackOutlined,
ConsoleSqlOutlined, ConsoleSqlOutlined,
EyeOutlined, EyeOutlined,
ArrowLeftOutlined,
UploadOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { import {
reloadTableFields, reloadTableFields,
...@@ -38,7 +40,8 @@ import FieldEditor from './fieldEditor'; ...@@ -38,7 +40,8 @@ import FieldEditor from './fieldEditor';
import AffiliateAdd from '../components/Field/affiliateAdd'; import AffiliateAdd from '../components/Field/affiliateAdd';
import LoadGroup from '../components/Field/loadGroupNew'; import LoadGroup from '../components/Field/loadGroupNew';
import styles from './index.less'; import styles from './index.less';
import PerviewPrase from './PerviewPrase'; import clearSvg from '@/assets/font/omsfont/clear.svg';
// import PerviewPrase from './PerviewPrase';
import { LayerSetting } from '@/services/gis/gis'; import { LayerSetting } from '@/services/gis/gis';
const AddModal = props => { const AddModal = props => {
const history = useHistory(); const history = useHistory();
...@@ -49,6 +52,7 @@ const AddModal = props => { ...@@ -49,6 +52,7 @@ const AddModal = props => {
const [tableData, setTableData] = useState([]); const [tableData, setTableData] = useState([]);
const [treeLoading, setTreeLoading] = useState(false); const [treeLoading, setTreeLoading] = useState(false);
const [formObj, setFormObj] = useState(''); const [formObj, setFormObj] = useState('');
const [formName, setFormName] = useState('');
const [flag, setFlag] = useState(0); // 弹窗类型 const [flag, setFlag] = useState(0); // 弹窗类型
const [isVisible, setIsVisible] = useState(false); // 弹窗 const [isVisible, setIsVisible] = useState(false); // 弹窗
const [isType, setIsType] = useState(''); // 弹窗类型 const [isType, setIsType] = useState(''); // 弹窗类型
...@@ -74,6 +78,8 @@ const AddModal = props => { ...@@ -74,6 +78,8 @@ const AddModal = props => {
const [perviewPrase, setPerViewPrase] = useState(false); const [perviewPrase, setPerViewPrase] = useState(false);
const [tablesSchema, setTablesSchema] = useState(null); // 存储parseForm组件需要的数据格式 const [tablesSchema, setTablesSchema] = useState(null); // 存储parseForm组件需要的数据格式
const formRef = useRef(null);
const getField = () => { const getField = () => {
loadUnattachedTables().then(res => { loadUnattachedTables().then(res => {
if (res.data.root && res.data.root.length) { if (res.data.root && res.data.root.length) {
...@@ -109,12 +115,13 @@ const AddModal = props => { ...@@ -109,12 +115,13 @@ const AddModal = props => {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (props.location.state.id) { if (props.tableInfo.id) {
setSelectTreeData(props.location.state.keepData); setSelectTreeData(props.tableInfo.keepData);
setSelectDataFirst(props.location.state.keepTreeFirst); setSelectDataFirst(props.tableInfo.keepTreeFirst);
if (treeSelectValue) { if (treeSelectValue) {
let ss = treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@')); let ss = treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@'));
setFormObj(treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@'))); setFormObj(treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@')));
setFormName(treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@')));
reloadTableFields({ reloadTableFields({
tableName: treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@')), tableName: treeSelectValue.substring(0, treeSelectValue.lastIndexOf('@')),
}).then(res => { }).then(res => {
...@@ -151,7 +158,7 @@ const AddModal = props => { ...@@ -151,7 +158,7 @@ const AddModal = props => {
i.fieldName = i.name; i.fieldName = i.name;
i.configInfo = i.config; i.configInfo = i.config;
i.presetValue = i.preset == '(无)' ? '' : i.preset; i.presetValue = i.preset == '(无)' ? '' : i.preset;
i.showCss = props.location.state.template.tableStyle; i.showCss = props.tableInfo.template.tableStyle;
i.tableName = ss; i.tableName = ss;
i.uiGroup = item; i.uiGroup = item;
i.readOnly = i.readOnly == '是' ? 1 : 0; i.readOnly = i.readOnly == '是' ? 1 : 0;
...@@ -165,7 +172,7 @@ const AddModal = props => { ...@@ -165,7 +172,7 @@ const AddModal = props => {
}); });
flowNodeMeta.groups = arrdata; flowNodeMeta.groups = arrdata;
list.flowNodeMeta = flowNodeMeta; list.flowNodeMeta = flowNodeMeta;
list.showCss = props.location.state.template.tableStyle; list.showCss = props.tableInfo.template.tableStyle;
console.log(list); console.log(list);
let tablesSchema = { let tablesSchema = {
...@@ -187,10 +194,11 @@ const AddModal = props => { ...@@ -187,10 +194,11 @@ const AddModal = props => {
} }
}); });
} else { } else {
let ss = props.location.state.id; let ss = props.tableInfo.id;
setFormObj(props.location.state.id); setFormObj(props.tableInfo.id);
setFormName(props.tableInfo.name);
reloadTableFields({ reloadTableFields({
tableName: props.location.state.id, tableName: props.tableInfo.id,
}).then(res => { }).then(res => {
setTreeLoading(false); setTreeLoading(false);
if (res.msg === 'Ok') { if (res.msg === 'Ok') {
...@@ -206,7 +214,7 @@ const AddModal = props => { ...@@ -206,7 +214,7 @@ const AddModal = props => {
console.log(arrlist); console.log(arrlist);
setKeepTree(arrlist); setKeepTree(arrlist);
data.TableFieldNames = arrlist; data.TableFieldNames = arrlist;
data.TableName = props.location.state.id; data.TableName = props.tableInfo.id;
listArr.push(data); listArr.push(data);
setKeepTreeData(listArr); setKeepTreeData(listArr);
let arr = formateArrDataA(res.data.root, 'group'); let arr = formateArrDataA(res.data.root, 'group');
...@@ -226,7 +234,7 @@ const AddModal = props => { ...@@ -226,7 +234,7 @@ const AddModal = props => {
i.fieldName = i.name; i.fieldName = i.name;
i.configInfo = i.config; i.configInfo = i.config;
i.presetValue = i.preset == '(无)' ? '' : i.preset; i.presetValue = i.preset == '(无)' ? '' : i.preset;
i.showCss = props.location.state.template.tableStyle; i.showCss = props.tableInfo.template.tableStyle;
i.tableName = ss; i.tableName = ss;
i.uiGroup = item; i.uiGroup = item;
i.readOnly = i.readOnly == '是' ? 1 : 0; i.readOnly = i.readOnly == '是' ? 1 : 0;
...@@ -240,7 +248,7 @@ const AddModal = props => { ...@@ -240,7 +248,7 @@ const AddModal = props => {
}); });
flowNodeMeta.groups = arrdata; flowNodeMeta.groups = arrdata;
list.flowNodeMeta = flowNodeMeta; list.flowNodeMeta = flowNodeMeta;
list.showCss = props.location.state.template.tableStyle; list.showCss = props.tableInfo.template.tableStyle;
console.log(list); console.log(list);
let tablesSchema = { let tablesSchema = {
...@@ -308,7 +316,7 @@ const AddModal = props => { ...@@ -308,7 +316,7 @@ const AddModal = props => {
// 返回上一级 // 返回上一级
const back = () => { const back = () => {
console.log(props.location.state); console.log(props.tableInfo);
let { let {
template, template,
tableScroll, tableScroll,
...@@ -317,7 +325,7 @@ const AddModal = props => { ...@@ -317,7 +325,7 @@ const AddModal = props => {
groupArr, groupArr,
searchValue, searchValue,
select, select,
} = props.location.state; } = props.tableInfo;
console.log(keepValue); console.log(keepValue);
console.log(pickIndex, groupArr, 'back'); console.log(pickIndex, groupArr, 'back');
history.push({ history.push({
...@@ -381,7 +389,7 @@ const AddModal = props => { ...@@ -381,7 +389,7 @@ const AddModal = props => {
i.fieldName = i.name; i.fieldName = i.name;
i.configInfo = i.config; i.configInfo = i.config;
i.presetValue = i.preset == '(无)' ? '' : i.preset; i.presetValue = i.preset == '(无)' ? '' : i.preset;
i.showCss = props.location.state.template.tableStyle; i.showCss = props.tableInfo.template.tableStyle;
i.tableName = ss; i.tableName = ss;
i.uiGroup = item; i.uiGroup = item;
i.readOnly = i.readOnly == '是' ? 1 : 0; i.readOnly = i.readOnly == '是' ? 1 : 0;
...@@ -395,7 +403,7 @@ const AddModal = props => { ...@@ -395,7 +403,7 @@ const AddModal = props => {
}); });
flowNodeMeta.groups = arrdata; flowNodeMeta.groups = arrdata;
list.flowNodeMeta = flowNodeMeta; list.flowNodeMeta = flowNodeMeta;
list.showCss = props.location.state.template.tableStyle; list.showCss = props.tableInfo.template.tableStyle;
console.log(list); console.log(list);
let tablesSchema = { let tablesSchema = {
...@@ -441,7 +449,7 @@ const AddModal = props => { ...@@ -441,7 +449,7 @@ const AddModal = props => {
}); });
}); });
} else { } else {
setPramFormObj(props.location.state.template); setPramFormObj(props.tableInfo.template);
} }
setType('affiliateAdd'); setType('affiliateAdd');
setVisible(true); setVisible(true);
...@@ -451,15 +459,15 @@ const AddModal = props => { ...@@ -451,15 +459,15 @@ const AddModal = props => {
setVisible(false); setVisible(false);
setFlag(flag + 1); setFlag(flag + 1);
}; };
return ( return (
<> <>
<Spin tip="loading..." spinning={treeLoading}> {/* <Spin tip="loading..." spinning={treeLoading}> */}
<div className={styles.containerBox}> <div className={styles.containerBox}>
<div className={styles.config}> <div className={styles.config}>
<div className={styles.title}> 字段配置 【{formObj}</div> {/* <ArrowLeftOutlined onClick={back} className={styles.goBack} /> */}
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> <div className={styles.title}> 展示名称 【{formName}</div>
{/* <div style={{ lineHeight: '32px', marginRight: '5px' }}>快速切换表:</div> <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
{/* <div style={{ lineHeight: '32px', marginRight: '5px' }}>快速切换表:</div>
<div style={{ width: '350px', marginRight: '10px' }}> <div style={{ width: '350px', marginRight: '10px' }}>
<TreeSelect <TreeSelect
showSearch showSearch
...@@ -479,26 +487,52 @@ const AddModal = props => { ...@@ -479,26 +487,52 @@ const AddModal = props => {
)} )}
</TreeSelect> </TreeSelect>
</div> */} </div> */}
<div className={styles.btn}> <div className={styles.btn}>
<Button type="primary" icon={<PlusSquareOutlined />} onClick={add}> <Button
type="primary"
// icon={<PlusSquareOutlined />}
ghost
onClick={() => formRef.current.clear()}
>
<img src={clearSvg} style={{ marginRight: '6px' }} alt="" />
清空
</Button>
<Button
type="primary"
ghost
icon={<EyeOutlined />}
onClick={() => formRef.current.preview()}
style={{ marginLeft: '10px' }}
>
预览
</Button>
<Button
type="primary"
icon={<UploadOutlined />}
onClick={() => formRef.current.submit()}
style={{ marginLeft: '10px' }}
>
提交
</Button>
{/* <Button type="primary" icon={<PlusSquareOutlined />} onClick={add}>
附加 附加
</Button> </Button> */}
<Button {/* <Button
type="primary" type="primary"
icon={<RollbackOutlined />} icon={<RollbackOutlined />}
onClick={back} onClick={back}
style={{ marginLeft: '30px' }} style={{ marginLeft: '30px' }}
> >
返回 返回
</Button> </Button> */}
</div>
</div> </div>
</div> </div>
<div style={{ width: '100%', height: 'calc(100% - 63px)', padding: '10px' }}>
{formObj && <FormDesigner tableName={formObj} extra />}
</div>
</div> </div>
</Spin> <div style={{ width: '100%', height: 'calc(100% - 63px)', padding: '10px' }}>
{formObj && <FormDesigner ref={formRef} tableName={formObj} />}
</div>
</div>
{/* </Spin> */}
{visible && type === 'affiliateAdd' && ( {visible && type === 'affiliateAdd' && (
<AffiliateAdd <AffiliateAdd
visible={visible} visible={visible}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment