Commit d7dbb073 authored by 张烨's avatar 张烨

feat: 站点管理

parent 18d9d940
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { push } from 'connected-react-router';
import * as actionCreators from './actions'; import * as actionCreators from './actions';
import * as constants from './constants'; import * as constants from './constants';
import reducer from './reducer'; import reducer from './reducer';
......
...@@ -2,14 +2,14 @@ import React, { useState, useEffect } from 'react'; ...@@ -2,14 +2,14 @@ import React, { useState, useEffect } from 'react';
import { import {
Row, Row,
Col, Col,
Tree,
Card, Card,
Input, Input,
Tooltip, Tooltip,
Button, Button,
notification, notification,
Spin, Spin,
Tabs, List,
Space,
} from 'antd'; } from 'antd';
import { FileAddTwoTone, EditTwoTone, DeleteTwoTone } from '@ant-design/icons'; import { FileAddTwoTone, EditTwoTone, DeleteTwoTone } from '@ant-design/icons';
import { PageContainer, GridContent } from '@ant-design/pro-layout'; import { PageContainer, GridContent } from '@ant-design/pro-layout';
...@@ -20,38 +20,25 @@ import { ...@@ -20,38 +20,25 @@ import {
import ListCard from '@/pages/orgnazation/ListCard'; import ListCard from '@/pages/orgnazation/ListCard';
import styles from '@/pages/userCenter/siteManage/SiteManage.less'; import styles from '@/pages/userCenter/siteManage/SiteManage.less';
import qs from 'qs'; import qs from 'qs';
import classnames from 'classnames';
import AddModal from './AddModal'; import AddModal from './AddModal';
import DelModal from './DelModal'; import DelModal from './DelModal';
import EditModal from './EditModal'; import EditModal from './EditModal';
const { Search } = Input; const { Search } = Input;
const { TabPane } = Tabs;
const placeholder = '请输入人员姓名'; const placeholder = '请输入人员姓名';
const SiteManage = () => { const SiteManage = () => {
const [treeData, setTreeData] = useState([]); // 树结构数据 const [treeData, setTreeData] = useState([]); // 树结构数据
const [currentStation, setCurrentStation] = useState({}); // 当前选中站点
const [searchWord, setSearchWord] = useState(''); // 关键字 const [searchWord, setSearchWord] = useState(''); // 关键字
const [ouid, setOuid] = useState(''); // 站点id
const [saveTreeId, setSaveTreeId] = useState(''); // 保存点击回调的id
const [modalVisible, setModalVisible] = useState(false); // 新增弹窗 const [modalVisible, setModalVisible] = useState(false); // 新增弹窗
const [flag, setFlag] = useState(1); const [flag, setFlag] = useState(1);
const [stationId, setStationId] = useState(''); // 选择的站点
const [stationObj, setStationObj] = useState({}); // 选择的站点
const [delVisible, setDelVisible] = useState(false); // 删除弹窗 const [delVisible, setDelVisible] = useState(false); // 删除弹窗
const [editVisible, setEditVisible] = useState(false); // 修改弹窗 const [editVisible, setEditVisible] = useState(false); // 修改弹窗
const [subList, setSubList] = useState([]); // 选中的数组 const [subList, setSubList] = useState([]); // 选中的数组
const [spinLoading, setSpinLoading] = useState(false); const [spinLoading, setSpinLoading] = useState(false);
const now = new Date().getTime(); const now = new Date().getTime();
// 点击树的回调
const handleTreeSelect = (e, info) => {
console.log(e, info);
let id = e[0];
if (id) {
setSaveTreeId(id);
setOuid(id);
} else {
setOuid(saveTreeId);
}
};
useEffect(() => { useEffect(() => {
setSpinLoading(true); setSpinLoading(true);
getWebModuleTree({ getWebModuleTree({
...@@ -66,16 +53,21 @@ const SiteManage = () => { ...@@ -66,16 +53,21 @@ const SiteManage = () => {
let arr = []; let arr = [];
if (res) { if (res) {
arr.push(res.find(item => item.id === 'Web4StationRoot')); arr.push(res.find(item => item.id === 'Web4StationRoot'));
console.log(arr, 'arr');
} }
let arr2 = transTree(arr); if (arr[0]) {
setTreeData(arr2); const stations = arr[0].children;
setTreeData(stations);
if (!currentStation.stationID) {
setCurrentStation(stations[0]);
}
}
}) })
.catch(err => { .catch(err => {
setSpinLoading(false); setSpinLoading(false);
console.error(err); console.error(err);
}); });
}, [flag]); }, [flag]);
const Title = props => { const Title = props => {
const { text } = props; const { text } = props;
return ( return (
...@@ -113,12 +105,10 @@ const SiteManage = () => { ...@@ -113,12 +105,10 @@ const SiteManage = () => {
}; };
// 站点删除 // 站点删除
const handleDel = e => { const handleDel = e => {
setStationId(e);
setDelVisible(true); setDelVisible(true);
}; };
// 编辑站点 // 编辑站点
const handleEdit = e => { const handleEdit = e => {
setStationObj(e);
setEditVisible(true); setEditVisible(true);
}; };
// 树形数据转换 // 树形数据转换
...@@ -164,7 +154,7 @@ const SiteManage = () => { ...@@ -164,7 +154,7 @@ const SiteManage = () => {
chooseUserToStation( chooseUserToStation(
qs.stringify({ qs.stringify({
userList: String(arr.flat()), userList: String(arr.flat()),
stationID: ouid, stationID: currentStation.stationID,
}), }),
{ {
headers: { headers: {
...@@ -195,28 +185,29 @@ const SiteManage = () => { ...@@ -195,28 +185,29 @@ const SiteManage = () => {
<PageContainer> <PageContainer>
<GridContent> <GridContent>
<Row gutter={12}> <Row gutter={12}>
<Col lg={6}> <Col lg={6} sm={6}>
<Card className={styles.cardBox}> <Card className={styles.cardBox}>
<Spin <Spin
tip="loading...." tip="loading...."
spinning={spinLoading} spinning={spinLoading}
style={{ marginTop: '20px' }} style={{ marginTop: '20px' }}
> >
{/* <Tabs <List>
tabPosition="left" {treeData.map(t => (
defaultValue="0" <List.Item
type="card" onClick={() => {
style={{ width: '100%' }} setCurrentStation(t);
}}
key={t.id}
className={classnames({
[styles.listItem]: true,
[styles.selected]: currentStation.id === t.id,
})}
> >
<TabPane key="0" tab="tab1" /> {t.text}
<TabPane key="1" tab="tab2" /> </List.Item>
</Tabs> */} ))}
<Tree </List>
showLine={{ showLeafIcon: false }}
showIcon
onSelect={e => handleTreeSelect(e)}
treeData={treeData}
/>
</Spin> </Spin>
<AddModal <AddModal
visible={modalVisible} visible={modalVisible}
...@@ -225,19 +216,19 @@ const SiteManage = () => { ...@@ -225,19 +216,19 @@ const SiteManage = () => {
/> />
<DelModal <DelModal
visible={delVisible} visible={delVisible}
stationId={stationId} stationId={currentStation.stationID}
onCancel={() => setDelVisible(false)} onCancel={() => setDelVisible(false)}
confirmModal={delModal} confirmModal={delModal}
/> />
<EditModal <EditModal
visible={editVisible} visible={editVisible}
stationObj={stationObj} stationObj={currentStation}
onCancel={() => setEditVisible(false)} onCancel={() => setEditVisible(false)}
confirmModal={editModal} confirmModal={editModal}
/> />
</Card> </Card>
</Col> </Col>
<Col lg={18}> <Col lg={18} sm={18}>
<Card style={{ marginBottom: '10px' }}> <Card style={{ marginBottom: '10px' }}>
<Row align="middle"> <Row align="middle">
<Col span={1}>搜索</Col> <Col span={1}>搜索</Col>
...@@ -251,7 +242,8 @@ const SiteManage = () => { ...@@ -251,7 +242,8 @@ const SiteManage = () => {
/> />
</Col> </Col>
<Col span={3} /> <Col span={3} />
{/* <Col span={2}> <Col span={8}>
<Space>
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={() => {
...@@ -260,35 +252,32 @@ const SiteManage = () => { ...@@ -260,35 +252,32 @@ const SiteManage = () => {
> >
新增 新增
</Button> </Button>
</Col>
<Col span={2}>
<Button <Button
type="primary" type="primary"
onClick={() => { onClick={() => {
handleEdit(); handleEdit();
}} }}
disabled={!ouid} disabled={!currentStation.stationID}
> >
编辑 编辑
</Button> </Button>
</Col>
<Col span={2}>
<Button <Button
danger danger
onClick={() => { onClick={() => {
handleDel(ouid); handleDel(currentStation.stationID);
}} }}
disabled={!ouid} disabled={!currentStation.stationID}
> >
删除 删除
</Button> </Button>
</Col> */} </Space>
</Col>
</Row> </Row>
</Card> </Card>
<Card className={styles.cardBoxR}> <Card className={styles.cardBoxR}>
{ouid && ( {currentStation.stationID && (
<ListCard <ListCard
ouid={ouid} ouid={currentStation.stationID}
searchWord={searchWord} searchWord={searchWord}
valueCallback={valueCallback} valueCallback={valueCallback}
onCommit={handleCommit} onCommit={handleCommit}
......
...@@ -26,3 +26,9 @@ ...@@ -26,3 +26,9 @@
justify-content: space-around; justify-content: space-around;
align-items: center; align-items: center;
} }
.listItem{
padding-left: 5px;
}
.selected{
background-color: #bae7ff;
}
\ No newline at end of file
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