Commit 50f1962a authored by shaoan123's avatar shaoan123

优化表字段模块

parent 6868f417
Pipeline #32098 passed with stages
in 30 minutes 58 seconds
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import ReactHtmlParser from 'react-html-parser' import classnames from 'classnames';
import { import {
// Tree, // Tree,
Table, Table,
...@@ -26,7 +26,7 @@ const { Search } = Input; ...@@ -26,7 +26,7 @@ const { Search } = Input;
const { Option } = Select; const { Option } = Select;
const placeholder = "请输入表名" const placeholder = "请输入表名"
const TableManager = () => { const TableManager = (props) => {
const history = useHistory(); const history = useHistory();
const [visible, setVisible] = useState(false); // 弹窗 const [visible, setVisible] = useState(false); // 弹窗
const [type, setType] = useState(''); // 弹窗类型 const [type, setType] = useState(''); // 弹窗类型
...@@ -38,10 +38,15 @@ const TableManager = () => { ...@@ -38,10 +38,15 @@ const TableManager = () => {
const [groupArr, setGroupArr] = useState([]) const [groupArr, setGroupArr] = useState([])
const [allData, setAllData] = useState([]) const [allData, setAllData] = useState([])
const [tableData, setTableData] = useState([]) const [tableData, setTableData] = useState([])
const [select, setSelect] = useState([])
const [selectTableName, setSelectTableName] = useState({})
useEffect((record) => { useEffect((record) => {
loadTable(searchValue) loadTable(searchValue)
getField() getField()
if (props.history.location.state) {
let template = props.history.location.state.template
setSelectTableName(template)
}
}, [flag]) }, [flag])
//附加 //附加
...@@ -93,10 +98,10 @@ const TableManager = () => { ...@@ -93,10 +98,10 @@ const TableManager = () => {
setVisible(true); setVisible(true);
} }
//字段配置 //字段配置
const fieldsConfig = (record,e) => { const fieldsConfig = (record, e) => {
e.stopPropagation() e.stopPropagation()
setFormObj(record); setFormObj(record);
history.push(`/platformCenter/bsmanger/filedConfig/${record.tableName}`) history.push({ pathname: `/platformCenter/bsmanger/filedConfig/${record.tableName}`, state: { template: record } })
// setType('config'); // setType('config');
// setVisible(true); // setVisible(true);
} }
...@@ -139,12 +144,13 @@ const TableManager = () => { ...@@ -139,12 +144,13 @@ const TableManager = () => {
Object.keys(groupData).map((item, index) => { Object.keys(groupData).map((item, index) => {
newArr.push({ type: item, key: index }) newArr.push({ type: item, key: index })
}) })
console.log('groupData',groupData); console.log('groupData', groupData);
setAllData(groupData) setAllData(groupData)
setGroupArr(newArr) setGroupArr(newArr)
setSelect(newArr)
} }
} }
).catch(e=>{ ).catch(e => {
setTreeLoading(true) setTreeLoading(true)
}) })
} }
...@@ -177,7 +183,7 @@ const TableManager = () => { ...@@ -177,7 +183,7 @@ const TableManager = () => {
} }
for (let keys in tempObj) { for (let keys in tempObj) {
let arr = [] let arr = []
tempObj[keys].map((item,index) => { tempObj[keys].map((item, index) => {
tempObj[keys] = arr; tempObj[keys] = arr;
item.key = index item.key = index
arr.push(item) arr.push(item)
...@@ -185,6 +191,8 @@ const TableManager = () => { ...@@ -185,6 +191,8 @@ const TableManager = () => {
} }
return tempObj return tempObj
} }
const setRowClassName = record =>
Object.entries(record).toString() === Object.entries(selectTableName).toString() ? styles.clickRowStyle : '';
const expandedRowRender = (item) => { const expandedRowRender = (item) => {
const columns1 = [ const columns1 = [
{ {
...@@ -192,7 +200,7 @@ const TableManager = () => { ...@@ -192,7 +200,7 @@ const TableManager = () => {
dataIndex: 'tableName', dataIndex: 'tableName',
key: 'tableName', key: 'tableName',
width: 300, width: 300,
render: (text,record) => <a onClick={e=>fieldsConfig(record,e)}>{text}</a>, render: (text, record) => <div onClick={e => fieldsConfig(record, e)}>{text}</div>,
}, },
{ {
...@@ -200,31 +208,28 @@ const TableManager = () => { ...@@ -200,31 +208,28 @@ const TableManager = () => {
dataIndex: 'tableAlias', dataIndex: 'tableAlias',
key: 'tableAlias', key: 'tableAlias',
align: 'center', align: 'center',
width: 200,
}, },
{ {
title: '表格样式', title: '表格样式',
dataIndex: 'tableStyle', dataIndex: 'tableStyle',
key: 'tableStyle', key: 'tableStyle',
align: 'center', align: 'center'
width: 150,
}, },
{ {
title: '字段数量', title: '字段数量',
dataIndex: 'fieldCount', dataIndex: 'fieldCount',
key: 'fieldCount', key: 'fieldCount',
align: 'center', align: 'center',
width: 200,
}, },
{ {
title: '缺少字段', title: '缺少字段',
dataIndex: 'missingFieldCount', dataIndex: 'missingFieldCount',
key: 'missingFieldCount', key: 'missingFieldCount',
align: 'center', align: 'center',
width: 200,
render: text => { render: text => {
let dom = ReactHtmlParser(text) return (<div className={classnames({
return (<div>{dom}</div>) [styles.lack]:text!=='(无)' ,
})} >{text}</div>)
} }
}, },
{ {
...@@ -232,18 +237,15 @@ const TableManager = () => { ...@@ -232,18 +237,15 @@ const TableManager = () => {
dataIndex: 'extraFieldCount', dataIndex: 'extraFieldCount',
key: 'extraFieldCount', key: 'extraFieldCount',
align: 'center', align: 'center',
width: 200,
}, },
{ {
title: '分组数量', title: '分组数量',
dataIndex: 'groupCount', dataIndex: 'groupCount',
key: 'groupCount', key: 'groupCount',
align: 'center', align: 'center',
width: 200,
}, },
{ {
title: '操作', title: '操作',
width: 250,
ellipsis: true, ellipsis: true,
key: 'tableID', key: 'tableID',
align: 'center', align: 'center',
...@@ -257,7 +259,7 @@ const TableManager = () => { ...@@ -257,7 +259,7 @@ const TableManager = () => {
</Tooltip> </Tooltip>
<Tooltip title="字段配置"> <Tooltip title="字段配置">
<FontColorsOutlined <FontColorsOutlined
onClick={e => fieldsConfig(record,e)} onClick={e => fieldsConfig(record, e)}
style={{ fontSize: '16px', color: '#1890FF' }} style={{ fontSize: '16px', color: '#1890FF' }}
/> />
</Tooltip> </Tooltip>
...@@ -295,19 +297,89 @@ const TableManager = () => { ...@@ -295,19 +297,89 @@ const TableManager = () => {
]; ];
return <Table columns={columns1} dataSource={allData[item.type]} pagination={false} />; return <Table columns={columns1} bordered size="small" onRow={record => {
return {
onDoubleClick: event => {
event.stopPropagation()
history.push({ pathname: `/platformCenter/bsmanger/filedConfig/${record.tableName}`, state: { template: record } })
},
onClick: event => {
event.stopPropagation()
setSelectTableName(record)
}, // 点击行
}
}}
rowClassName={setRowClassName}
showHeader={false} dataSource={allData[item.type]} pagination={false} />;
}; };
const columns = [ const columns = [
{ {
title: '类型', dataIndex: 'type', key: 'type', title: '名称', dataIndex: 'type', key: 'type',
render: text => { render: text => {
return (<div style={{ color: '#3764a0' }}>{text}({allData&&allData[text]?allData[text].length:0}个)</div>) return (<a style={{ fontWeight:'bold' }}>{text}({allData && allData[text] ? allData[text].length : 0}个)</a>)
},
width: 260,
},
{
title: '别名',
dataIndex: 'tableAlias',
key: 'tableAlias',
align: 'center',
},
{
title: '表格样式',
dataIndex: 'tableStyle',
key: 'tableStyle',
align: 'center',
},
{
title: '字段数量',
dataIndex: 'fieldCount',
key: 'fieldCount',
align: 'center',
},
{
title: '缺少字段',
dataIndex: 'missingFieldCount',
key: 'missingFieldCount',
align: 'center',
render: text => {
return (<div>{text}</div>)
} }
}, },
{
title: '未附加',
dataIndex: 'extraFieldCount',
key: 'extraFieldCount',
align: 'center',
},
{
title: '分组数量',
dataIndex: 'groupCount',
key: 'groupCount',
align: 'center',
]; },
{
title: '操作',
dataIndex: 'title',
key: 'title',
align: 'center',
},
];
const onUnfold = (expanded, record) => {
const data = [...select]
let index = data.indexOf(record)
if (expanded) {
data.push(record)
} else {
data.splice(index, 1)
}
setSelect(data)
}
return ( return (
<Spin tip="loading..." spinning={treeLoading}> <Spin tip="loading..." spinning={treeLoading}>
<PageContainer> <PageContainer>
...@@ -352,18 +424,15 @@ const TableManager = () => { ...@@ -352,18 +424,15 @@ const TableManager = () => {
className="components-table-demo-nested" className="components-table-demo-nested"
columns={columns} columns={columns}
expandable={{ expandedRowRender }} expandable={{ expandedRowRender }}
showHeader={false} expandedRowKeys={select.map(item => item.key)} //展开的行
expandRowByClick={true}
defaultExpandAllRows={true}
dataSource={groupArr} dataSource={groupArr}
scroll={{ y: 'calc(100vh - 200px)' }}
size="small" size="small"
pagination={false}
onExpand={onUnfold}
style={{ height: '8rem' }} style={{ height: '8rem' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 20,
showQuickJumper: true,
showSizeChanger: true,
}}
/> />
</div> </div>
</div> </div>
......
...@@ -2,6 +2,24 @@ ...@@ -2,6 +2,24 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100vm; width: 100vm;
border: 1px solid #f0f0f0;
.lack{
background-color: rgb(255, 255, 0);
color: rgb(255, 0, 0);
}
.ant-table.ant-table-small .ant-table-tbody .ant-table-wrapper:only-child .ant-table{
margin-left: 0;
}
.ant-table.ant-table-bordered > .ant-table-container{
border: none;
}
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.clickRowStyle{
background: #cfe7fd;
}
.operate_bar { .operate_bar {
width: 100%; width: 100%;
height: 60px; height: 60px;
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
background-color: #ffffff; background-color: #ffffff;
display: flex; display: flex;
.ant-table {
min-height: 15rem !important;
}
padding: 0.8rem; padding: 0.8rem;
.ant-table-thead tr th { .ant-table-thead tr th {
font-weight: 600; font-weight: 600;
...@@ -98,9 +100,7 @@ ...@@ -98,9 +100,7 @@
cursor: pointer; cursor: pointer;
} }
} }
.ant-table {
min-height: 15rem !important;
}
.cardsList{ .cardsList{
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
......
...@@ -24,7 +24,8 @@ const AddModal = props => { ...@@ -24,7 +24,8 @@ const AddModal = props => {
const [isVisible, setIsVisible] = useState(false); // 弹窗 const [isVisible, setIsVisible] = useState(false); // 弹窗
const [isType, setIsType] = useState(''); // 弹窗类型 const [isType, setIsType] = useState(''); // 弹窗类型
const [itemData, setItemData] = useState({}); const [itemData, setItemData] = useState({});
const [select, setSelect] = useState([])
const [selectTableName, setSelectTableName] = useState({})
const editor = record => { const editor = record => {
setIsType('edit'); setIsType('edit');
setIsVisible(true); setIsVisible(true);
...@@ -41,8 +42,9 @@ const AddModal = props => { ...@@ -41,8 +42,9 @@ const AddModal = props => {
title: '字段名', title: '字段名',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
width: 150, width: 190,
render: text => <a>{text}</a>, align: 'left',
render: text => <div style={{paddingLeft:'2rem'}}>{text}</div>,
}, },
{ {
title: '别名', title: '别名',
...@@ -122,19 +124,89 @@ const AddModal = props => { ...@@ -122,19 +124,89 @@ const AddModal = props => {
}, },
]; ];
return <Table columns={columns} dataSource={allData[item.type]} pagination={false} />; return <Table columns={columns} onRow={record => {
return {
onDoubleClick: event => {
event.stopPropagation()
editor(record);
},
onClick: event => {
event.stopPropagation()
setSelectTableName(record)
}, // 点击行
}
}} bordered rowClassName={setRowClassName} showHeader={false} dataSource={allData[item.type]} pagination={false} />;
}; };
const setRowClassName = (record) =>
Object.entries(record).toString() === Object.entries(selectTableName).toString() ? styles.clickRowStyle : '';
const columns = [ const columns = [
{ {
title: '类型', dataIndex: 'type', key: 'type', title: '字段名',
dataIndex: 'type',
key: 'type',
align: 'left',
width: 150,
render: text => { render: text => {
return (<div style={{ color: '#3764a0' }}>{text}(共{allData[text].length}条)</div>) return (<a >{text}(共{allData[text] ? allData[text].length : ''}条)</a>)
} }
},
{
title: '别名',
dataIndex: 'alias',
key: 'alias',
align: 'center',
width: 200,
},
{
title: '字段类型',
dataIndex: 'storeType',
key: 'storeType',
align: 'center',
width: 200,
},
{
title: '形态',
dataIndex: 'shape',
key: 'shape',
align: 'center',
width: 200,
},
{
title: '配置',
dataIndex: 'config',
key: 'config',
align: 'center',
width: 200,
},
{
title: '只读',
dataIndex: 'readOnly',
key: 'readOnly',
align: 'center',
width: 200,
},
{
title: '同步',
dataIndex: 'syncEvent',
key: 'syncEvent',
align: 'center',
width: 200,
},
{
title: '操作',
width: 250,
ellipsis: true,
key: 'title',
align: 'center',
}, },
]; ];
useEffect(() => { useEffect(() => {
if (props.match.params.id) { if (props.match.params.id) {
setFormObj(props.match.params.id) setFormObj(props.match.params.id)
setTreeLoading(true); setTreeLoading(true);
...@@ -143,13 +215,14 @@ const AddModal = props => { ...@@ -143,13 +215,14 @@ const AddModal = props => {
}).then(res => { }).then(res => {
setTreeLoading(false); setTreeLoading(false);
if (res.msg === 'Ok') { if (res.msg === 'Ok') {
let arr =formateArrDataA(res.data.root,'group') let arr = formateArrDataA(res.data.root, 'group')
let newArr = [] let newArr = []
Object.keys(arr).map((item, index) => { Object.keys(arr).map((item, index) => {
newArr.push({ type: item, key: index,id:index }) newArr.push({ type: item, key: index, id: index })
}) })
setAllData(arr); setAllData(arr);
setTableData(newArr); setTableData(newArr);
setSelect(newArr)
} }
}); });
} }
...@@ -183,7 +256,7 @@ const AddModal = props => { ...@@ -183,7 +256,7 @@ const AddModal = props => {
} }
for (let keys in tempObj) { for (let keys in tempObj) {
let arr = [] let arr = []
tempObj[keys].map((item,index) => { tempObj[keys].map((item, index) => {
tempObj[keys] = arr; tempObj[keys] = arr;
item.key = index item.key = index
arr.push(item) arr.push(item)
...@@ -212,40 +285,46 @@ const AddModal = props => { ...@@ -212,40 +285,46 @@ const AddModal = props => {
}; };
// 返回上一级 // 返回上一级
const back = () => { const back = () => {
history.push('/platformCenter/bsmanger/tablemanger') let template = props.history.location.state.template
history.push({ pathname: '/platformCenter/bsmanger/tablemanger', state: { template } })
}
const onUnfold = (expanded, record) => {
const data = [...select]
let index = data.indexOf(record)
if (expanded) {
data.push(record)
} else {
data.splice(index, 1)
}
setSelect(data)
} }
return ( return (
<div style={{ width: '100vm', height: 'calc(100vh - 100px) ', background: '#ffffff' }}>
<Spin tip="loading..." spinning={treeLoading}> <><Spin tip="loading..." spinning={treeLoading}>
<div className={styles.containerBox}>
<div className={styles.config}><div className={styles.title}>{formObj}(字段配置)</div> <Button type="primary" onClick={back}>返回</Button></div> <div className={styles.config}><div className={styles.title}>{formObj}(字段配置)</div> <Button type="primary" onClick={back}>返回</Button></div>
<Table <Table
columns={columns} columns={columns}
dataSource={tableData} dataSource={tableData}
expandable={{ expandedRowRender }} expandable={{ expandedRowRender }}
showHeader={false}
// pagination={{ pageSize: 10 }}
scroll={{ y: '45rem' }}
size="small" size="small"
rowKey='id' rowKey='id'
pagination={{ expandedRowKeys={select.map(item => item.key)} //展开的行
showTotal: (total, range) => expandRowByClick={true}
`第${range[0]}-${range[1]} 条/共 ${total} 条`, defaultExpandAllRows={true}
pageSizeOptions: [10, 20, 50, 100], pagination={false}
defaultPageSize: 20, scroll={{ y: 'calc(100vh - 186px)' }}
showQuickJumper: true, size="small"
showSizeChanger: true, onExpand={onUnfold} />
}} </div>
/> </Spin><FieldEditor
</Spin>
<FieldEditor
isVisible={isVisible} isVisible={isVisible}
isType={isType} isType={isType}
itemData={itemData} itemData={itemData}
formObj1={formObj} formObj1={formObj}
onCancel={() => setIsVisible(false)} onCancel={() => setIsVisible(false)}
callBackSubmit={Submit} callBackSubmit={Submit} /></>
/>
</div>
); );
}; };
export default AddModal; export default AddModal;
...@@ -22,6 +22,20 @@ ...@@ -22,6 +22,20 @@
} }
} }
.containerBox {
width: 100vm;
height: calc(100vh - 90px) ;
background: #ffffff;
.ant-table.ant-table-small .ant-table-tbody .ant-table-wrapper:only-child .ant-table{
margin-left: 0;
}
.ant-table.ant-table-bordered > .ant-table-container{
border: none;
}
.clickRowStyle{
background: #cfe7fd;
}
}
.paneTitle{ .paneTitle{
font-weight: bold; font-weight: bold;
...@@ -93,6 +107,7 @@ ...@@ -93,6 +107,7 @@
.title{ .title{
font-size: 18px; font-size: 18px;
color: rgba(0, 114, 255, 1); color: rgba(0, 114, 255, 1);
font-weight: bold;
} }
} }
.container{ .container{
width: 100%; width: 100%;
background-color: #ffffff; background-color: #ffffff;
display: flex;
padding: 0.8rem; padding: 0.8rem;
display: flex;
.ant-table {
min-height: 15rem !important;
}
.ant-table-thead tr th { .ant-table-thead tr th {
font-weight: 600; font-weight: 600;
color: rgba(0, 0, 0, 0.85); color: rgba(0, 0, 0, 0.85);
...@@ -97,9 +98,7 @@ ...@@ -97,9 +98,7 @@
cursor: pointer; cursor: pointer;
} }
} }
.ant-table {
min-height: 15rem !important;
}
.cardsList{ .cardsList{
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
......
...@@ -193,7 +193,6 @@ const EditModal = props => { ...@@ -193,7 +193,6 @@ const EditModal = props => {
WebTemplateID: fv.web_template, WebTemplateID: fv.web_template,
PushGroup: fv.to_person ? fv.to_person.toString() : '' PushGroup: fv.to_person ? fv.to_person.toString() : ''
} }
console.log(b)
InsertMessageConfig(b).then( InsertMessageConfig(b).then(
res => { res => {
if (res.code === 0) { if (res.code === 0) {
...@@ -215,7 +214,6 @@ const EditModal = props => { ...@@ -215,7 +214,6 @@ const EditModal = props => {
) )
} else { } else {
message.success("保存成功") message.success("保存成功")
} }
} }
else { else {
......
...@@ -74,21 +74,21 @@ const standingBook = props => { ...@@ -74,21 +74,21 @@ const standingBook = props => {
dataIndex: 'fields', dataIndex: 'fields',
key: 'fields', key: 'fields',
align: 'center', align: 'center',
width: 100,
}, },
{ {
title: '检索字段', title: '检索字段',
dataIndex: 'searchFields', dataIndex: 'searchFields',
key: 'searchFields', key: 'searchFields',
align: 'center', align: 'center',
width: 100,
}, },
{ {
title: '添加字段', title: '添加字段',
dataIndex: 'addFields', dataIndex: 'addFields',
key: 'addFields', key: 'addFields',
align: 'center', align: 'center',
width: 100,
}, },
{ {
...@@ -96,21 +96,21 @@ const standingBook = props => { ...@@ -96,21 +96,21 @@ const standingBook = props => {
dataIndex: 'editFields', dataIndex: 'editFields',
key: 'editFields', key: 'editFields',
align: 'center', align: 'center',
width: 100,
}, },
{ {
title: '前端字段', title: '前端字段',
dataIndex: 'webFields', dataIndex: 'webFields',
key: 'webFields', key: 'webFields',
align: 'center', align: 'center',
width: 100,
}, },
{ {
title: '手持字段', title: '手持字段',
dataIndex: 'mobileFields', dataIndex: 'mobileFields',
key: 'mobileFields', key: 'mobileFields',
align: 'center', align: 'center',
width: 100,
}, },
{ {
title: '操作', title: '操作',
...@@ -270,11 +270,11 @@ const standingBook = props => { ...@@ -270,11 +270,11 @@ const standingBook = props => {
</Tooltip> </Tooltip>
<hr style={{ width: '100%', color: '#eeecec' }} /> <hr style={{ width: '100%', color: '#eeecec' }} />
{ {
tableData.length && (tableData.map((item, index) => { tableData.length>0 && (tableData.map((item, index) => {
return <div className={classnames({ return <div className={classnames({
[styles.listItem]: true, [styles.listItem]: true,
[styles.pickItem]: item === pickItem, [styles.pickItem]: item === pickItem,
})} onClick={e => setPickItem(item)} key={index}>{item}({allData[item] ? allData[item].length : ''}条) {item === pickItem ? <RightOutlined /> : ''} </div> })} onClick={e => setPickItem(item)} key={index}>{item}{allData[item] ? allData[item].length : ''} {item === pickItem ? <RightOutlined /> : ''} </div>
}) })
)} )}
</div></> : ''} </div></> : ''}
...@@ -308,7 +308,6 @@ const standingBook = props => { ...@@ -308,7 +308,6 @@ const standingBook = props => {
onDoubleClick: event => {event.stopPropagation(); editor(record)}, //双击 onDoubleClick: event => {event.stopPropagation(); editor(record)}, //双击
}; };
}} }}
columns={columns} columns={columns}
dataSource={allData[pickItem]} dataSource={allData[pickItem]}
// loading={tableLoading} // loading={tableLoading}
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
} }
.orgContainer{ .orgContainer{
height: calc(100vh - 74px); height: calc(100vh - 74px);
width: 340px; width: 240px;
left: 0; left: 0;
top: 0; top: 0;
overflow-x: hidden; overflow-x: hidden;
......
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