Commit e2292fa3 authored by shaoan123's avatar shaoan123

更改变量

parent 5aaf3257
Pipeline #31267 skipped with stages
......@@ -36,9 +36,10 @@ const TableManager = () => {
const [searchValue, setSearchValue] = useState('')
const [treeLoading, setTreeLoading] = useState(true)
const [tableList, setTableList] = useState([])
const [groupArr, setGroupArr] = useState({})
const [groupArr, setGroupArr] = useState([])
const [allData, setAllData] = useState([])
const [tableData, setTableData] = useState([])
const [spread , setSpread]=useState([])
const [spread, setSpread] = useState([])
useEffect((record) => {
loadTable(searchValue)
getField()
......@@ -135,13 +136,16 @@ const TableManager = () => {
setTableData(res.data.root)
let groupData = formateArrDataA(res.data.root, 'groupName')
let newArr = []
Object.keys(groupData).map((item,index) => {
newArr.push({ type: item,key:index })
Object.keys(groupData).map((item, index) => {
newArr.push({ type: item, key: index })
})
setGroupArr({ groupData, newArr })
setAllData(groupData)
setGroupArr(newArr)
}
}
)
).catch(e=>{
setTreeLoading(true)
})
}
const formateArrDataA = (initialArr, name) => {
// 判定传参是否符合规则
......@@ -288,26 +292,27 @@ const TableManager = () => {
},
];
return <Table columns={columns1} dataSource={spread} pagination={false} />;
return <Table columns={columns1} dataSource={spread} pagination={false} />;
};
const columns = [
{ title: '类型', dataIndex: 'type', key: 'type',
render: text => {
return (<div>{text}({ groupArr.groupData[text].length}个)</div>)
} },
{
title: '类型', dataIndex: 'type', key: 'type',
render: text => {
return (<div style={{ color: '#3764a0' }}>{text}({allData[text].length}个)</div>)
}
},
];
const openClick=(status, item)=>{
if (!status) return
let arr = []
groupArr.groupData[item.type].map((item,index)=>{
arr.push({...item,key:index})
})
setSpread(arr)
}
const openClick = (status, item) => {
if (!status) return
let arr = []
allData[item.type].map((item, index) => {
arr.push({ ...item, key: index })
})
setSpread(arr)
}
return (
<Spin tip="loading..." spinning={treeLoading}>
<PageContainer>
......@@ -353,11 +358,11 @@ const TableManager = () => {
className="components-table-demo-nested"
columns={columns}
expandable={{ expandedRowRender }}
dataSource={groupArr.newArr}
dataSource={groupArr}
onExpand={openClick} // 展开时触发的回调
size="small"
style={{height:'8rem'}}
style={{ height: '8rem' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
......
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