Commit e2292fa3 authored by shaoan123's avatar shaoan123

更改变量

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