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

fix: '解决移动配置新增bug'

parent fb3dc96f
/* eslint-disable no-unused-expressions */
import React, { useState, useEffect } from 'react';
import {
Form,
......@@ -44,6 +45,9 @@ const StandingBook = props => {
const [searchData, setSearchData] = useState([]);
const [showSearchStyle, setShowSearchStyle] = useState(false); // 是否显示模糊查询样式
const [keepTableData, setKeepTableData] = useState([]);
const [searchFlag, setSearchFlag] = useState(0);
const [currentPage, setCurrentPage] = useState(1);
const [currentPageSize, setCurrentPageSize] = useState(20);
const { Item } = Form;
const { Search } = Input;
......@@ -175,17 +179,25 @@ const StandingBook = props => {
setMaxLength(res.data.root.length + 1);
let arr = formateArrDataA(res.data.root, 'type');
let newArr = [];
newArr.push('全部');
Object.keys(arr).map((item, index) => {
newArr.push(item);
});
console.log(arr);
arr.全部 = res.data.root;
setAllData(arr);
setShowSearchStyle(false);
// 第一次进入展示第一页 不是第一次进入根据当前选择的来进行展示
console.log(flag);
console.log(pickItem);
flag === 0 ? setPickItem(newArr[0]) : setPickItem(pickItem);
setPickItem(newArr[0]);
// setPickItem(newArr[0]);
console.log(newArr, 'newArr');
// newArr.push('全部');
setTableData(newArr);
if (searchFlag === 1) {
onSearch();
}
}
});
}, [flag]);
......@@ -258,27 +270,31 @@ const StandingBook = props => {
};
const onSearch = () => {
console.log(searchWord);
console.log(pickItem);
setSearchFlag(1);
setTableLoading(true);
setCurrentPage(1);
setCurrentPageSize(20);
GetCM_Ledger_LoadLedgers({ accountName: searchWord }).then(res => {
setTableLoading(false);
if (res.msg === 'Ok' && res.data.root) {
console.log(res.data.root);
setMaxLength(res.data.root.length + 1);
let arr = formateArrDataA(res.data.root, 'type');
let newArr = [];
Object.keys(arr).map((item, index) => {
newArr.push(item);
});
let aa = res.data.root;
if (pickItem == '全部') {
if (aa.length > 0) {
aa.map(i => {
i.type = '全部';
});
}
}
console.log(aa);
setMaxLength(aa.length + 1);
let arr = formateArrDataA(aa, 'type');
console.log(arr);
setShowSearchStyle(true);
// setAllData(arr);
setSearchData(res.data.root);
setPickItem('');
setSearchData(arr);
// setPickItem('');
// 第一次进入展示第一页 不是第一次进入根据当前选择的来进行展示
// flag === 0 ? setPickItem(newArr[0]) : setPickItem(pickItem);
console.log(newArr, 'newArr');
// setTableData(newArr);
}
});
......@@ -287,29 +303,30 @@ const StandingBook = props => {
const handleSearch = e => {
console.log(e.target.value);
setSearchWord(e.target.value);
if (e.target.value == '') {
setTableLoading(true);
GetCM_Ledger_LoadLedgers().then(res => {
setTableLoading(false);
if (res.msg === 'Ok' && res.data.root) {
console.log(res.data.root);
setMaxLength(res.data.root.length + 1);
let arr = formateArrDataA(res.data.root, 'type');
let newArr = [];
Object.keys(arr).map((item, index) => {
newArr.push(item);
});
console.log(arr);
setAllData(arr);
setShowSearchStyle(false);
// 第一次进入展示第一页 不是第一次进入根据当前选择的来进行展示
flag === 0 ? setPickItem(newArr[0]) : setPickItem(pickItem);
setPickItem(newArr[0]);
console.log(newArr, 'newArr');
setTableData(newArr);
}
});
}
setSearchFlag(0);
// if (e.target.value == '') {
// setTableLoading(true);
// GetCM_Ledger_LoadLedgers().then(res => {
// setTableLoading(false);
// if (res.msg === 'Ok' && res.data.root) {
// console.log(res.data.root);
// setMaxLength(res.data.root.length + 1);
// let arr = formateArrDataA(res.data.root, 'type');
// let newArr = [];
// Object.keys(arr).map((item, index) => {
// newArr.push(item);
// });
// console.log(arr);
// setAllData(arr);
// setShowSearchStyle(false);
// // 第一次进入展示第一页 不是第一次进入根据当前选择的来进行展示
// flag === 0 ? setPickItem(newArr[0]) : setPickItem(pickItem);
// setPickItem(newArr[0]);
// console.log(newArr, 'newArr');
// setTableData(newArr);
// }
// });
// }
};
// 模糊查询匹配的样式
......@@ -325,6 +342,13 @@ const StandingBook = props => {
const handleReset = () => {
setFlag(flag + 1);
};
const pageChage = (page, pageSize) => {
console.log(page);
console.log(pageSize);
setCurrentPage(page);
setCurrentPageSize(pageSize);
};
return (
<PageContainer className={styles.userManageContainer}>
<div className={styles.contentContainers}>
......@@ -379,6 +403,9 @@ const StandingBook = props => {
onClick={() => {
setPickItem(item);
setSearchWord('');
setSearchFlag(0);
setCurrentPage(1);
setCurrentPageSize(20);
}}
onMouseEnter={() => {
setHoverItemIndex(item);
......@@ -448,7 +475,7 @@ const StandingBook = props => {
}}
columns={columns}
loading={tableLoading}
dataSource={pickItem ? allData[pickItem] : searchData}
dataSource={searchFlag === 0 ? allData[pickItem] : searchData[pickItem]}
// loading={tableLoading}
scroll={{ x: 'max-content', y: 'calc(100vh - 180px)' }}
// scroll={{ x: 'max-content' }}
......@@ -458,6 +485,9 @@ const StandingBook = props => {
defaultPageSize: 20,
showQuickJumper: true,
showSizeChanger: true,
current: currentPage,
pageSize: currentPageSize,
onChange: (page, pageSize) => pageChage(page, pageSize),
}}
/>
</div>
......
......@@ -78,7 +78,7 @@ const MiniMenu = props => {
}, [menuID]);
// 更新树
const updateTrees = (e, h) => {
const updateTrees = e => {
getMiniAppModuleTree({
userMode: userMode || 'super',
})
......@@ -97,9 +97,8 @@ const MiniMenu = props => {
if (result.length > 0) {
if (e) {
result.map(item => mapData(item, e));
let aa = [...mapDataList].find(i => i.text === e && i.menuType === h);
let aa = [...mapDataList].find(i => i.menuID == e);
console.log(aa);
console.log(h);
setMenuID(aa.menuID);
setExpendKey(aa.menuID);
switch (aa.menuType) {
......@@ -393,7 +392,7 @@ const MiniMenu = props => {
setFlag(flag + 1);
console.log(prop);
console.log(item);
updateTrees(prop.menuName, e);
updateTrees(res.data);
notification.success({
message: '提示',
description: '新增成功',
......
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