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

fix: 表字段界面优化

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