Commit 40e94a25 authored by Maofei94's avatar Maofei94

perf: perf

parent d777c01c
......@@ -19,8 +19,14 @@ export const checkChildrenByCondition = (item, fn, tag = 'every') => {
};
const ListCard = props => {
const { ouid, searchWord, onCommit = () => {}, itemObj } = props;
const [valueList, setValueList] = useState([]);
const {
ouid,
searchWord,
onCommit = () => {},
itemObj,
btnLoading = false,
} = props;
const [valueList, setValueList] = useState({});
const [dataList, setdataList] = useState([]);
const [loading, setLoading] = useState(true);
const [mapObj, setMapObj] = useState({});
......@@ -131,7 +137,11 @@ const ListCard = props => {
)}
{true && !loading && dataList && (
<div className={styles.btnBox}>
<Button type="primary" onClick={() => onCommit(valueList)}>
<Button
type="primary"
onClick={() => onCommit(valueList)}
loading={btnLoading}
>
提交
</Button>
</div>
......
......@@ -25,7 +25,7 @@
.divSingle{
border: none;
margin-top: 20px;
flex:0 0 200px;
flex:0 0 180px;
background: transparent;
}
.isSearch{
......
......@@ -12,6 +12,6 @@
line-height: 32px;
}
.btnBox {
display: flex;
display: flex !important;
justify-content: space-around;
}
\ No newline at end of file
......@@ -177,6 +177,13 @@ const ManagementDataBase = () => {
width: 200,
ellipsis: true,
},
{
title: '解决方案',
dataIndex: 'solutionName',
key: 'solutionName',
width: 200,
ellipsis: true,
},
{
title: '数据库版本',
dataIndex: 'version',
......
......@@ -163,6 +163,7 @@ const MongDBTable = props => {
title: '操作',
dataIndex: 'options',
key: 'options',
width: 300,
render: (val, item) => [
<Button
size="small"
......
import React, { useState, useEffect, useCallback, useRef } from 'react';
import React, { useState, useEffect, useCallback } from 'react';
import { Spin, Button } from 'antd';
import ListCardItem from './listCardItem';
import { get, post } from '../../services';
......@@ -6,7 +6,13 @@ import styles from './listCardItem.less';
const tip = 'loading...';
const ListCard = props => {
const { ouid, searchWord, valueCallback, onCommit = () => {} } = props;
const {
ouid,
searchWord,
valueCallback,
onCommit = () => {},
btnLoading = false,
} = props;
const [valueList, setValueList] = useState({});
const [dataList, setdataList] = useState([]);
const [loading, setLoading] = useState(true);
......@@ -77,7 +83,11 @@ const ListCard = props => {
)}
{true && !loading && dataList && (
<div className={styles.btnBox}>
<Button type="primary" onClick={() => onCommit()}>
<Button
type="primary"
onClick={() => onCommit()}
loading={btnLoading}
>
提交
</Button>
</div>
......
......@@ -25,8 +25,7 @@
flex-wrap: wrap;
align-items: center;
.ant-checkbox-group-item{
flex:0 0 auto;
margin-right: 100px;
flex:0 0 150px;
margin-bottom: 5px;
}
}
......
......@@ -9,7 +9,7 @@ const AddModal = props => {
const [formLayout, setFormLayout] = useState('horizontal');
const [groupList, setGroupList] = useState([]);
const [loading, setLoading] = useState(false);
const { confirmModal, itemObj } = props;
const { confirmModal, itemObj, editVisible } = props;
console.log(itemObj, 'itemObj');
useEffect(() => {
......
......@@ -8,9 +8,11 @@ import {
Spin,
notification,
Button,
Tooltip,
Space,
} from 'antd';
import PageContainer from '@/components/BasePageContainer';
import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons';
import {
setMenuToRole,
getRoleGroupList,
......@@ -29,7 +31,7 @@ const SiteManage = () => {
const [treeData, setTreeData] = useState([]);
const [searchWord, setSearchWord] = useState('');
const [roleID, setRoleID] = useState(''); // 角色ID
const [saveTreeId, setSaveTreeId] = useState(''); // 保存点击回调的ird
const [saveTreeId, setSaveTreeId] = useState(''); // 保存点击回调的roleid
const [modalVisible, setModalVisible] = useState(false); // 新增弹窗
const [flag, setFlag] = useState(1);
const [itemObj, setItemObj] = useState({}); // 选择的角色item
......@@ -38,29 +40,35 @@ const SiteManage = () => {
const [subList, setSubList] = useState([]); // 选中的数组
const [spinLoading, setSpinLoading] = useState(false);
const [currentSelectId, setCurrentSelectId] = useState([]); // 选中的树节点
const [saveCurId, setSaveCurId] = useState([]); // 树节点ID
const [groupVisible, setGroupVisible] = useState(false); // 分组编辑弹窗
const [btnLoading, setBtnLoading] = useState(false);
const [mulu, setMulu] = useState(true);
// 点击树的回调
const handleTreeSelect = (e, treenode) => {
const { node } = treenode;
setItemObj(node);
if (treenode) {
console.log(e, node, 'node');
const { node } = treenode;
const { roleID: id } = node;
// setCurrentSelectId(e);
if (e[0]) {
setCurrentSelectId(e);
setItemObj(node);
if (id) {
setSaveTreeId(id);
setRoleID(id);
} else {
setRoleID(saveTreeId);
}
}
if (e[0]) {
setCurrentSelectId(e);
setSaveCurId(e);
} else {
setCurrentSelectId(saveCurId);
}
};
useEffect(() => {
setSpinLoading(true);
getRoleGroupList({ userID: 1 }).then(res => {
console.log(res, 'res');
setSpinLoading(false);
if (res.code === 0) {
const { roleList } = res.data;
......@@ -68,6 +76,9 @@ const SiteManage = () => {
setTreeData(arr);
}
});
return () => {
setItemObj({});
};
}, [flag]);
const handleAdd = e => {
setModalVisible(true);
......@@ -99,23 +110,29 @@ const SiteManage = () => {
item.title = item.visibleTitle || '';
item.key = item.visibleValue || '';
if (item.roleList && item.roleList.length > 0) {
item.roleList.map(itemRole => {
item.roleList.map((itemRole, index) => {
if (itemRole.roleList) {
itemRole.title = itemRole.visibleTitle || '';
itemRole.key =
itemRole.visibleTitle + Math.floor(Math.random() * 100 + 1) || '';
itemRole.key = itemRole.visibleTitle + itemRole.visibleValue || '';
itemRole.groupflag = itemRole.visibleTitle;
itemRole.roleList.map(i => {
i.title = i.roleName;
i.key = i.roleID;
i.subSystemValue = item.visibleValue;
i.group = itemRole.visibleTitle;
if (roleID && roleID == i.roleID) {
setItemObj(i);
}
});
itemRole.children = itemRole.roleList;
} else {
itemRole.title = itemRole.roleName;
itemRole.key = itemRole.roleID;
itemRole.subSystemValue = item.visibleValue;
if (roleID && roleID == itemRole.roleID) {
setItemObj(itemRole);
}
}
return itemRole;
});
......@@ -149,19 +166,24 @@ const SiteManage = () => {
const editModal = () => {
setEditVisible(false);
setFlag(flag + 1);
setItemObj('');
handleTreeSelect(saveCurId);
// setItemObj('');
};
// 分组编辑回调
const groupModal = () => {
setGroupVisible(false);
setFlag(flag + 1);
setItemObj('');
handleTreeSelect(saveCurId);
};
const valueCallback = valueObj => {
setSubList(valueObj);
};
const handleHide = () => {
setMulu(!mulu);
};
const handleCommit = rusults => {
console.log(rusults);
setBtnLoading(true);
setMenuToRole(
qs.stringify({
roleID,
......@@ -174,6 +196,7 @@ const SiteManage = () => {
},
)
.then(res => {
setBtnLoading(false);
if (res.success) {
notification.success({
message: '提示',
......@@ -189,14 +212,15 @@ const SiteManage = () => {
}
})
.catch(err => {
setBtnLoading(false);
console.log(err);
});
};
return (
<PageContainer>
{/* <GridContent> */}
<Row gutter={12}>
<Col lg={6}>
<Row gutter={0}>
<Col lg={mulu ? 5 : 0}>
<Card className={styles.cardBox}>
<Spin
tip="loading...."
......@@ -209,12 +233,8 @@ const SiteManage = () => {
showIcon
onSelect={handleTreeSelect}
treeData={treeData}
// selectedKeys={currentSelectId}
selectedKeys={currentSelectId}
blockNode
defaultExpandAll
// defaultExpandedKeys={currentSelectId}
autoExpandParent
expandedKeys={currentSelectId}
/>
)}
</Spin>
......@@ -244,7 +264,19 @@ const SiteManage = () => {
/>
</Card>
</Col>
<Col lg={18}>
<Col span={1}>
{mulu && (
<Tooltip title="隐藏站点" className={styles.hide}>
<DoubleLeftOutlined onClick={() => handleHide()} />
</Tooltip>
)}
{!mulu && (
<Tooltip title="显示站点" className={styles.hide}>
<DoubleRightOutlined onClick={() => handleHide()} />
</Tooltip>
)}
</Col>
<Col lg={mulu ? 18 : 23}>
<Card style={{ marginBottom: '10px' }}>
<Row align="middle">
<Col span={1}>搜索</Col>
......@@ -306,6 +338,7 @@ const SiteManage = () => {
itemObj={itemObj}
searchWord={searchWord}
onCommit={handleCommit}
btnLoading={btnLoading}
/>
)}
</Card>
......
......@@ -40,3 +40,13 @@
}
}
}
.hide{
display: block;
position: relative;
font-size: 20px;
color: #1890FF!important;
top: 45%;
left: 50%;
transform: translate(-50%,-50%);
}
\ No newline at end of file
......@@ -11,7 +11,13 @@ import {
List,
Space,
} from 'antd';
import { FileAddTwoTone, EditTwoTone, DeleteTwoTone } from '@ant-design/icons';
import {
FileAddTwoTone,
EditTwoTone,
DeleteTwoTone,
DoubleLeftOutlined,
DoubleRightOutlined,
} from '@ant-design/icons';
import { GridContent } from '@ant-design/pro-layout';
import PageContainer from '@/components/BasePageContainer';
import {
......@@ -38,7 +44,8 @@ const SiteManage = () => {
const [editVisible, setEditVisible] = useState(false); // 修改弹窗
const [subList, setSubList] = useState([]); // 选中的数组
const [spinLoading, setSpinLoading] = useState(false);
const now = new Date().getTime();
const [btnLoading, setBtnLoading] = useState(false);
const [mulu, setMulu] = useState(true);
useEffect(() => {
setSpinLoading(true);
......@@ -46,7 +53,7 @@ const SiteManage = () => {
userMode: 'super',
select: '',
_version: 9999,
_dc: now,
_dc: Date.now(),
node: -2,
})
.then(res => {
......@@ -157,6 +164,7 @@ const SiteManage = () => {
};
const handleCommit = value => {
let arr = Object.values(subList);
setBtnLoading(true);
chooseUserToStation(
qs.stringify({
userList: String(arr.flat()),
......@@ -169,6 +177,7 @@ const SiteManage = () => {
},
)
.then(res => {
setBtnLoading(false);
if (res.success) {
notification.success({
message: '提示',
......@@ -184,10 +193,13 @@ const SiteManage = () => {
}
})
.catch(err => {
setBtnLoading(false);
console.log(err);
});
};
const handleHide = () => {
setMulu(!mulu);
};
const renderListItem = items =>
items.map(t => (
<List.Item
......@@ -207,8 +219,8 @@ const SiteManage = () => {
return (
<PageContainer>
<GridContent>
<Row gutter={12}>
<Col lg={6}>
<Row gutter={0}>
<Col lg={mulu ? 4 : 0}>
<Card className={styles.cardBox}>
<Spin
tip="loading...."
......@@ -236,7 +248,20 @@ const SiteManage = () => {
/>
</Card>
</Col>
<Col lg={18}>
<Col span={1}>
{mulu && (
<Tooltip title="隐藏站点" className={styles.hide}>
<DoubleLeftOutlined onClick={() => handleHide()} />
</Tooltip>
)}
{!mulu && (
<Tooltip title="显示站点" className={styles.hide}>
<DoubleRightOutlined onClick={() => handleHide()} />
</Tooltip>
)}
</Col>
<Col lg={mulu ? 19 : 23}>
<Card style={{ marginBottom: '10px' }}>
<Row align="middle">
<Col span={1}>搜索</Col>
......@@ -251,7 +276,7 @@ const SiteManage = () => {
</Col>
<Col span={3} />
<Col span={8}>
<Space>
<Space size="large">
<Button
type="primary"
onClick={() => {
......@@ -289,6 +314,7 @@ const SiteManage = () => {
searchWord={searchWord}
valueCallback={valueCallback}
onCommit={handleCommit}
btnLoading={btnLoading}
/>
)}
</Card>
......
......@@ -32,7 +32,7 @@
.listItem{
padding-left: 5px;
cursor: pointer;
font-size: 16px;
font-size: 14px;
}
.listItem:hover{
background-color: #f8f8f8 ;
......@@ -41,3 +41,13 @@
font-weight: bold;
background-color: #bae7ff!important;
}
.hide{
display: block;
position: relative;
font-size: 20px;
color: #1890FF!important;
top: 45%;
left: 50%;
transform: translate(-50%,-50%);
}
\ No newline at end of file
......@@ -113,6 +113,9 @@ export const getSQLServerConnectionTest = params =>
get(
'/Cityinterface/rest/services/OMS.svc/S_GetSQLServerConnectionTest',
params,
{
timeout: 30000,
},
);
/**
* @Oracle数据库
......@@ -128,7 +131,13 @@ export const editOracleConnString = params =>
get('/Cityinterface/rest/services/OMS.svc/S_EditOracleConnString', params);
// 测试连接
export const getOracleConnectionTest = params =>
get('/Cityinterface/rest/services/OMS.svc/S_GetOracleConnectionTest', params);
get(
'/Cityinterface/rest/services/OMS.svc/S_GetOracleConnectionTest',
params,
{
timeout: 30000,
},
);
/**
* @MongoDB连接
......@@ -144,7 +153,9 @@ export const editMongoDBConnString = params =>
get('/Cityinterface/rest/services/OMS.svc/S_EditMongoDBConnString', params);
// 测试连接
export const getMongoDBConnectionTest = params =>
get('/Cityinterface/rest/services/OMS.svc/S_MongoDBConnectionTest', params);
get('/Cityinterface/rest/services/OMS.svc/S_MongoDBConnectionTest', params, {
timeout: 30000,
});
/**
* @MySQL连接
*/
......@@ -157,5 +168,8 @@ export const addMySQLConnString = params =>
// 测试连接
export const getMySQLConnectionTest = params =>
get('/Cityinterface/rest/services/OMS.svc/S_GetMySQLConnectionTest', params);
// 编辑
export const editMySQLConnString = params =>
get('/Cityinterface/rest/services/OMS.svc/S_EditMySQLConnString', params);
get('/Cityinterface/rest/services/OMS.svc/S_EditMySQLConnString', params, {
timeout: 300000,
});
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