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

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

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