Commit c2a47831 authored by 皮倩雯's avatar 皮倩雯

fix: '表/字段记住分页'

parent d4cc5161
Pipeline #82007 passed with stages
...@@ -103,6 +103,7 @@ const TableManager = props => { ...@@ -103,6 +103,7 @@ const TableManager = props => {
const [checkMsg, setCheckMsg] = useState(); const [checkMsg, setCheckMsg] = useState();
const [fieldConfigShow, setFieldConfigShow] = useState(false); const [fieldConfigShow, setFieldConfigShow] = useState(false);
const [tableInfo, setTableInfo] = useState({}); const [tableInfo, setTableInfo] = useState({});
const [keepGroupArr, setKeepGroupArr] = useState([]);
const initNum = useRef(0); const initNum = useRef(0);
useEffect(() => { useEffect(() => {
GetDefaultTableFields().then(res => { GetDefaultTableFields().then(res => {
...@@ -312,11 +313,15 @@ const TableManager = props => { ...@@ -312,11 +313,15 @@ const TableManager = props => {
} }
}); });
}); });
setKeepGroupArr(newArr);
setAllData(groupData); setAllData(groupData);
if (!props.history.location.query || initNum.current > 0) { if (!props.history.location.query || initNum.current > 0) {
if (newArr.length > 0 && (!select || isSearch)) { if (newArr.length > 0 && (!select || isSearch)) {
setSelect(newArr[0].type); setSelect(newArr[0].type);
} }
if (groupArr.length > 0 && !isSearch) {
newArr[pickIndex] = groupArr[pickIndex];
}
setGroupArr(newArr); setGroupArr(newArr);
} }
setKeepTreeFirst(bb); setKeepTreeFirst(bb);
...@@ -331,6 +336,8 @@ const TableManager = props => { ...@@ -331,6 +336,8 @@ const TableManager = props => {
setTreeLoading(false); setTreeLoading(false);
}); });
}; };
// 处理数据格式
const formateArrDataA = (initialArr, name) => { const formateArrDataA = (initialArr, name) => {
// 判定传参是否符合规则 // 判定传参是否符合规则
if (!(initialArr instanceof Array)) { if (!(initialArr instanceof Array)) {
...@@ -339,35 +346,18 @@ const TableManager = props => { ...@@ -339,35 +346,18 @@ const TableManager = props => {
if (!name) { if (!name) {
return '请传入对象属性'; return '请传入对象属性';
} }
// 先获取一下这个数组中有多少个"name" let arr = {};
let nameArr = []; initialArr.forEach((item, index) => {
for (let i in initialArr) { let data = item.groupName;
if (nameArr.indexOf(initialArr[i][`${name}`]) === -1) { if (!arr[data]) {
nameArr.push(initialArr[i][`${name}`]); arr[data] = [item];
} } else {
} arr[data].push(item);
// 新建一个包含多个list的结果对象
let tempObj = {};
// 根据不同的"name"生成多个数组
for (let k in nameArr) {
for (let j in initialArr) {
if (initialArr[j][`${name}`] == nameArr[k]) {
// 每次外循环时新建一个对应"name"的数组, 内循环时当前数组不变
tempObj[nameArr[k]] = tempObj[nameArr[k]] || [];
tempObj[nameArr[k]].push(initialArr[j]);
}
} }
} });
for (let keys in tempObj) { return arr;
let arr = [];
tempObj[keys].map((item, index) => {
tempObj[keys] = arr;
item.key = index;
arr.push(item);
});
}
return tempObj;
}; };
const setRowClassName = record => const setRowClassName = record =>
Object.entries(record).toString() === Object.entries(selectTableName).toString() Object.entries(record).toString() === Object.entries(selectTableName).toString()
? styles.clickRowStyle ? styles.clickRowStyle
...@@ -778,6 +768,7 @@ const TableManager = props => { ...@@ -778,6 +768,7 @@ const TableManager = props => {
setHoverItemIndex(''); setHoverItemIndex('');
}} }}
onClick={() => { onClick={() => {
setGroupArr(keepGroupArr);
setPickIndex(index); setPickIndex(index);
setSelect(item.type); setSelect(item.type);
setTableData(item.root); setTableData(item.root);
......
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