Commit 3165d8ce authored by 邓超's avatar 邓超

fix: 重构建表交互

parent 60258174
Pipeline #66204 passed with stages
import React, { useEffect, useState } from 'react';
import { Modal } from 'antd';
import styles from './ChooseTableType.less';
const ChooseTableType = props => {
const { defalutFields, visible, onCancel, onTableClick } = props;
const [tableList, setTableList] = useState([]);
useEffect(() => {
if (visible) {
let list = new Map([]);
defalutFields.forEach(item => {
let groupChildren = list.get(item.groupName) || [];
list.set(item.groupName, [...groupChildren, item]);
});
setTableList(Object.fromEntries(list.entries()));
}
}, [visible]);
const onFinish = () => {};
const createTable = val => {
console.log(val);
onCancel();
onTableClick(val);
};
return (
<div>
<Modal
visible={visible}
title="选择表模型"
width="1000px"
onOk={onFinish}
onCancel={onCancel}
maskClosable={false}
footer={[]}
destroyOnClose
centered
>
<div className={styles.content}>
{Object.keys(tableList).map(item => (
<div className={styles.groupBox} key={item}>
<div className={styles.headerBox}>
<div className={styles.line} />
<div className={styles.groupName}>{item}</div>
</div>
<div className={styles.tableContent}>
{tableList[item].map(ele => (
<div
className={styles.tableBox}
key={ele.value}
onClick={() => createTable(ele.value)}
>
<div className={styles.imgBox}>
<img src={`${window.location.origin}/civweb4/${ele.icon}`} alt="" />
</div>
<div className={styles.title}>{ele.value}</div>
</div>
))}
</div>
</div>
))}
</div>
</Modal>
</div>
);
};
export default ChooseTableType;
.content {
height: 530px;
overflow-y: scroll;
.groupBox {
width: 100%;
margin-bottom: 30px;
.headerBox {
display: flex;
align-items: center;
justify-content: left;
.line {
height: 12px;
width: 3px;
background-color: #3D78FF;
}
.groupName {
margin-left: 7px;
}
}
.tableContent {
display: flex;
.tableBox {
display: flex;
flex-direction: column;
justify-content: center;
margin-right: 10px;
margin-top: 10px;
width: 100px;
cursor: pointer;
.imgBox {
display: flex;
justify-content: center;
width: 100px;
height: 50px;
img {
width: 50px;
height: 50px;
}
}
.title {
text-align: center;
margin-top: 5px;
}
}
}
}
}
\ No newline at end of file
......@@ -742,7 +742,7 @@ const TableView = props => {
bordered
dataSource={dataSource}
columns={columns}
scroll={{ x: 'max-content', y: '540px' }}
scroll={{ y: '540px' }}
pagination={false}
id="box"
/>
......
......@@ -55,6 +55,7 @@ import AddTablelList from './components/TableView';
import AffiliateAdd from './components/Field/affiliateAdd';
import LoadGroup from './components/Field/loadGroup';
import LoadGroupNew from './components/Field/loadGroupNew';
import ChooseTableType from './components/ChooseTableType';
// import { defaultFields } from './components/defaultFields';
import styles from './index.less';
const { Search } = Input;
......@@ -621,7 +622,7 @@ const TableManager = props => {
style={{ width: '300px' }}
/>
</div>
<Dropdown overlay={menu} arrow>
{/* <Dropdown overlay={menu} arrow>
<Button
type="primary"
icon={<BorderInnerOutlined />}
......@@ -629,7 +630,18 @@ const TableManager = props => {
>
建表
</Button>
</Dropdown>
</Dropdown> */}
<Button
type="primary"
icon={<BorderInnerOutlined />}
style={{ marginLeft: '10px' }}
onClick={() => {
setType('chooseType');
setVisible(true);
}}
>
建表
</Button>
<Button
type="primary"
style={{ marginLeft: '10px' }}
......@@ -708,6 +720,15 @@ const TableManager = props => {
defaultFieldsList={defaultFieldsList}
tableType={tableType}
/>
<ChooseTableType
visible={visible && type === 'chooseType'}
defalutFields={defaultFieldsList}
onCancel={() => setVisible(false)}
onTableClick={val => {
setTableType(val);
AddTable();
}}
/>
{visible && type === 'affiliateAdd' && (
<AffiliateAdd
visible={visible}
......
......@@ -286,7 +286,7 @@
.lookDetail {
display: none;
margin-right: 10px;
margin-right: 17px;
}
}
......
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