Commit 7cda0c2d authored by 邓超's avatar 邓超

fix: 表字段界面优化

parent 898a5e41
Pipeline #48030 skipped with stages
......@@ -412,7 +412,15 @@ const AddModal = props => {
// 返回上一级
const back = () => {
console.log(props.location.state);
let { template, tableScroll, keepValue, pickIndex, groupArr } = props.location.state;
let {
template,
tableScroll,
keepValue,
pickIndex,
groupArr,
searchValue,
select,
} = props.location.state;
console.log(keepValue);
console.log(pickIndex, groupArr, 'back');
history.push({
......@@ -423,6 +431,8 @@ const AddModal = props => {
backIndex: pickIndex,
group: groupArr,
keepValue,
searchV: searchValue,
selectValue: select,
},
});
};
......
/* eslint-disable object-shorthand */
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useRef } from 'react';
import classnames from 'classnames';
import {
// Tree,
......@@ -57,7 +57,7 @@ const TableManager = props => {
const [groupArr, setGroupArr] = useState([]);
const [allData, setAllData] = useState([]);
const [tableData, setTableData] = useState([]);
const [select, setSelect] = useState([]);
const [select, setSelect] = useState();
const [selectTableName, setSelectTableName] = useState('');
const [showSearchStyle, setShowSearchStyle] = useState(false); // 是否显示模糊查询样式
const [chooseLine, setChooseLine] = useState([0]);
......@@ -67,10 +67,17 @@ const TableManager = props => {
const [treeVisible, setTreeVisible] = useState(true); // 是否显示左侧树
const [hoverItemIndex, setHoverItemIndex] = useState(0); // hover流程索引
const [pickIndex, setPickIndex] = useState(0);
let initNum = 0;
const initNum = useRef(0);
useEffect(
record => {
loadTable(searchValue);
if (props.history.location.query && initNum.current == 0) {
loadTable(props.history.location.query.searchV);
setSearchValue(props.history.location.query.searchV);
} else {
loadTable(searchValue);
}
getField();
// if (props.history.location.query && selectTableName !== {}) {
// let { template } = props.history.location.query;
......@@ -82,20 +89,28 @@ const TableManager = props => {
// 重字段配置返回后需要返回到原来的位置
useEffect(() => {
let arr = Object.keys(allData);
console.log(selectTableName, 'selectTableName');
console.log(arr, 'arr');
console.log(initNum, 'initNum');
console.log(props.history.location.query, 'props.history.location.query');
if (arr.length > 0 && props.history.location.query && selectTableName == '' && initNum == 0) {
console.log(234534256342);
let { tableScroll, template, keepValue, group, backIndex } = props.history.location.query;
setSelectTableName(template);
console.log(group, 'group');
if (
arr.length > 0 &&
props.history.location.query &&
selectTableName == '' &&
initNum.current == 0
) {
let {
tableScroll,
template,
keepValue,
group,
backIndex,
selectValue,
} = props.history.location.query;
setSelectTableName(template);
const i = group.findIndex(item => {
return item.type == selectValue;
});
setTimeout(() => {
setSelect(group[backIndex].type);
setPickIndex(backIndex);
console.log(group, 'group');
setSelect(selectValue);
setPickIndex(i);
setGroupArr(group);
document.querySelector('.ant-table-body').scrollTop = tableScroll;
}, 0);
......@@ -103,9 +118,6 @@ const TableManager = props => {
setKeepValue(keepValue);
}
}, [allData]);
useEffect(() => {
console.log(groupArr, 'groupArr');
}, [groupArr]);
// 附加
const add = record => {
......@@ -158,7 +170,6 @@ const TableManager = props => {
const fieldsConfig = (record, e) => {
e.stopPropagation();
setFormObj(record);
console.log(keepValue);
history.push({
pathname: `/bsmanger/base/filedConfig/${record.tableName}`,
state: {
......@@ -166,6 +177,8 @@ const TableManager = props => {
tableScroll: document.querySelector('.ant-table-body').scrollTop,
groupArr: groupArr,
pickIndex: pickIndex,
searchValue: searchValue,
select: select,
keepValue: keepValue,
keepTreeSelect: keepTreeSelect,
keepTreeFirst: keepTreeFirst,
......@@ -186,10 +199,11 @@ const TableManager = props => {
};
// 搜索
const handleSearch = text => {
loadTable(text);
loadTable(text, 'search');
setSearchValue(text);
setSelectTableName('');
setPickIndex(1);
setPickIndex(0);
setSelect(groupArr[0].type);
setShowSearchStyle(true);
};
const getField = () => {
......@@ -200,8 +214,7 @@ const TableManager = props => {
});
};
// 加载表
const loadTable = keyword => {
console.log(222);
const loadTable = (keyword, isSearch) => {
setTreeLoading(true);
CM_Table_LoadTable({
_version: 9999,
......@@ -220,26 +233,22 @@ const TableManager = props => {
aa.push({ name: item, key: index, ID: index, children: groupData[item] });
bb.push(item);
});
console.log(groupData, 'groupData');
setAllData(groupData);
if (!props.history.location.query || keyword) {
console.log(keyword, 'keyword');
console.log(newArr, 'newArr');
setSelect(newArr[0].type);
setGroupArr(newArr);
if (!props.history.location.query || initNum.current > 0) {
if (newArr.length > 0 && (!select || isSearch)) {
setSelect(newArr[0].type);
}
if (groupArr.length == 0 || isSearch) {
setGroupArr(newArr);
}
}
console.log(bb);
setKeepTreeFirst(bb);
setKeepTreeSelect(aa);
// setIntNum(initNum + 1);
initNum += 1;
initNum.current += 1;
}
})
.catch(e => {
setTreeLoading(true);
setTreeLoading(false);
});
};
const formateArrDataA = (initialArr, name) => {
......@@ -518,7 +527,6 @@ const TableManager = props => {
rowClassName={setRowClassName}
onRow={record => ({
onDoubleClick: event => {
console.log(keepValue);
event.stopPropagation();
history.push({
pathname: `/bsmanger/base/filedConfig/${record.tableName}`,
......@@ -527,6 +535,8 @@ const TableManager = props => {
tableScroll: document.querySelector('.ant-table-body').scrollTop,
groupArr: groupArr,
pickIndex: pickIndex,
searchValue: searchValue,
select: select,
keepValue: keepValue,
keepTreeSelect: keepTreeSelect,
keepTreeFirst: keepTreeFirst,
......
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