Commit 39a277af authored by 皮倩雯's avatar 皮倩雯

fix: '重构站点管理勾选站点人员模块'

parent 7b02121e
Pipeline #43210 skipped with stages
......@@ -1272,7 +1272,11 @@ const AddModal = props => {
},
]}
>
<Input value={prefixName} placeholder="请输入编码前缀" />
<Input
value={prefixName}
placeholder="请输入编码前缀"
style={{ marginLeft: '-3px' }}
/>
</Item>
</Col>
<Col span={24}>
......
......@@ -59,7 +59,7 @@ const ProxyConfig = () => {
OperateStopNginx();
}
};
//开启Nginx
// 开启Nginx
const OperateStartNginx = () => {
StartNginx().then(res => {
if (res.code === 0) {
......@@ -70,7 +70,7 @@ const ProxyConfig = () => {
}
});
};
//停止Nginx
// 停止Nginx
const OperateStopNginx = () => {
StopNginx().then(res => {
if (res.code === 0) {
......@@ -81,7 +81,7 @@ const ProxyConfig = () => {
}
});
};
//开启/关闭缓存
// 开启/关闭缓存
const OperateNginxCache = isOpen => {
NginxCache({
isOpen: isOpen ? 1 : 0,
......@@ -94,7 +94,7 @@ const ProxyConfig = () => {
}
});
};
//开启/关闭日志
// 开启/关闭日志
const OperateNginxLog = isOpen => {
NginxLog({
isOpen: isOpen ? 1 : 0,
......@@ -133,7 +133,6 @@ const ProxyConfig = () => {
Object.keys(currentConfig).forEach(k => {
obj[k] = res.data[k];
});
console.log(obj);
form.setFieldsValue(obj);
} else {
message.errorInfo(res.msg);
......@@ -181,22 +180,24 @@ const ProxyConfig = () => {
</div>
<Divider />
<Form.Item
style={{ marginLeft: '20px' }}
label="端口(ngnix)"
style={{ marginLeft: '12px' }}
label="Nginx端口"
labelAlign="right"
name="NginxPort"
rules={[
{
required: true,
pattern: new RegExp(/^[1-9]\d*$/, 'g'),
message: '请输入ngnix端口,例如:8091',
message: '请输入Nginx端口,例如:8091',
},
]}
>
<Input style={{ marginLeft: '15px', width: '300px' }} placeholder="请输入ngnix端口" />
<Input style={{ width: '300px' }} placeholder="请输入Nginx端口" />
</Form.Item>
<Form.Item
style={{ marginLeft: '20px' }}
label="地址(IIS)"
style={{ marginLeft: '34px' }}
label="IIS地址"
labelAlign="right"
name="IISIPProt"
rules={[
{
......@@ -208,15 +209,14 @@ const ProxyConfig = () => {
message: '请输入正确的IP例如:192.168.12.231:8231',
},
]}
hasFeedback
>
<Input style={{ marginLeft: '34px', width: '300px' }} placeholder="请输入IIS地址" />
<Input style={{ width: '300px' }} placeholder="请输入IIS地址" />
</Form.Item>
<Form.Item
style={{ marginLeft: '20px' }}
label="地址(EMQ)"
label="EMQ地址"
labelAlign="right"
name="EMQIPPort"
hasFeedback
rules={[
{
required: true,
......@@ -228,10 +228,10 @@ const ProxyConfig = () => {
},
]}
>
<Input style={{ marginLeft: '18px', width: '300px' }} placeholder="请输入EMQ地址" />
<Input style={{ width: '300px' }} placeholder="请输入EMQ地址" />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit" style={{ marginLeft: '130px' }}>
<Button type="primary" htmlType="submit" style={{ marginLeft: '103px' }}>
保存
</Button>
</Form.Item>
......
......@@ -28,10 +28,7 @@ import {
} from '@ant-design/icons';
import voca from 'voca';
import styles from './index.less';
import {
GetVideoConfigList,
deleteInsertVideoConfig,
} from '@/services/videoManger/videoManger';
import { GetVideoConfigList, deleteInsertVideoConfig } from '@/services/videoManger/videoManger';
import AddModal from './AddModal';
import CheckModal from './CheckModal';
import VideoModal from './VideoModal';
......@@ -149,10 +146,7 @@ const videoManager = () => {
render: record => (
<Space size="middle">
<Tooltip title="编辑">
<EditTwoTone
onClick={() => edit(record)}
style={{ fontSize: '16px' }}
/>
<EditTwoTone onClick={() => edit(record)} style={{ fontSize: '16px' }} />
</Tooltip>
<Tooltip title="预览">
<VideoCameraOutlined
......@@ -171,10 +165,7 @@ const videoManager = () => {
placement="bottomRight"
title={
<p>
即将删除{' '}
<span className={styles.redText}>
{voca.stripTags(record.Name)}
</span>
即将删除 <span className={styles.redText}>{voca.stripTags(record.Name)}</span>
,是否确认删除?
</p>
}
......@@ -194,10 +185,7 @@ const videoManager = () => {
const searchStyle = val => {
let n;
if (showSearchStyle) {
n = val.replace(
new RegExp(searchWord, 'g'),
`<span style='color:red'>${searchWord}</span>`,
);
n = val.replace(new RegExp(searchWord, 'g'), `<span style='color:red'>${searchWord}</span>`);
} else {
n = val;
}
......@@ -356,12 +344,12 @@ const videoManager = () => {
<Col span={24}>
<span>配置类型:</span>
<Select
defaultValue="石云"
defaultValue="石云"
value={configurationType}
onChange={selectChange}
className={styles.sel}
>
<Option value="1">石云</Option>
<Option value="1">石云</Option>
<Option value="2">海康</Option>
<Option value="3">海康1.2</Option>
<Option value="4">海康NVR</Option>
......@@ -415,8 +403,7 @@ const videoManager = () => {
}, // 双击
})}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 20,
showQuickJumper: true,
......
/* eslint-disable no-shadow */
/* eslint-disable array-callback-return */
/* eslint-disable consistent-return */
/* eslint-disable react/no-multi-comp */
/* eslint-disable eqeqeq */
import React, { useEffect, useState } from 'react';
import {
// Tree,
Table,
Space,
message,
Modal,
Input,
notification,
Tooltip,
Card,
Button,
Spin,
Dropdown,
Menu,
Row,
Col,
Empty,
......@@ -22,15 +22,11 @@ import {
import classnames from 'classnames';
import {
UserOutlined,
PlusSquareOutlined,
UsergroupAddOutlined,
EditOutlined,
FormOutlined,
DeleteOutlined,
DoubleLeftOutlined,
DoubleRightOutlined,
DownOutlined,
PlusOutlined,
ApartmentOutlined,
CaretUpOutlined,
......@@ -46,16 +42,12 @@ import lodash, { clone } from 'lodash';
import styles from './SiteManage.less';
import {
getWebModuleTree,
chooseUserToStation,
getAllGroup,
getUserByStation,
getStationUserList,
groupUserPagingList,
addChildSiteNode,
getSiteTree,
getStationUsers,
DragGroup,
getGroupUserTree,
} from '@/services/siteManage/api';
import AddModal from './AddModal';
import DelModal from './DelModal';
......@@ -72,8 +64,6 @@ const SiteManageV2 = () => {
const [treeLoading, setTreeLoading] = useState(false);
const [currentStation, setCurrentStation] = useState(''); // 当前选中站点
const [currentStationMsg, setCurrentStationMsg] = useState({}); // 当前编辑节点信息
const [currentStationOperate, setCurrentStationOperate] = useState(false);
const [flag, setFlag] = useState(1); // 操作标致触发界面刷新
const [dataList, setdataList] = useState([]); // 当前站点对应的分页用户列表
const [selectedState, setSelectedState] = useState(false); // 已选列表展开状态true为展开false为收起
const [visibleParams, setvisibleParams] = useState({
......@@ -87,7 +77,7 @@ const SiteManageV2 = () => {
});
const [total, setTotal] = useState(0); // 分页总数
const [page, setPage] = useState({ pageNum: 1, pageSize: 10 });
const [selectList, setSelectList] = useState([]); // 选择列表数据
const [selectList, setSelectList] = useState([]); // 已勾选列表数据
const [updatePageUser, setUpdatePageUser] = useState(1); //
const [updateCheck, setUpdateCheck] = useState(1);
const [name, setName] = useState('');
......@@ -147,7 +137,6 @@ const SiteManageV2 = () => {
// 编辑当前站点
const editorSite = (e, recode) => {
e.stopPropagation();
// console.log(recode);
// 保存编辑回显信息
setCurrentStationMsg(recode);
// setCurrentStation(recode.id);
......@@ -200,30 +189,28 @@ const SiteManageV2 = () => {
getAllCheckListNew();
}, [currentStation, updateCheck]);
// 获取当前站点可编辑用户(已勾选和未勾选)分页展示
const getList = () => {
let params = {
id: +currentStation || '',
PageIndex: +page.pageNum,
PageSize: +page.pageSize,
};
if (name) params = { ...params, name };
groupUserPagingList(params).then(res => {
if (name) params = { ...params, key: name };
getGroupUserTree(params).then(res => {
if (res.code === 0 && res.data) {
setShowSearchStyle(true);
let { list } = res.data;
let list = res.data.data;
// 还原选择的数据
if (selectList.length > 0) {
selectList.forEach(item => {
list.forEach((value, index) => {
if (item.GroupId === value.GroupId) {
list[index].Users.forEach((user, userIndex) => {
if (user.userID === item.userID) {
list[index].Users[userIndex].isChecked = true;
if (item.groupId == value.groupId) {
list[index].users.forEach((user, userIndex) => {
if (user.userId === item.userId) {
list[index].users[userIndex].isChecked = true;
}
});
let checkedLen = list[index].Users.filter(v => v.isChecked).length;
if (checkedLen === list[index].Users.length) {
let checkedLen = list[index].users.filter(v => v.isChecked).length;
if (checkedLen === list[index].users.length) {
list[index].isChecked = true;
}
}
......@@ -232,45 +219,96 @@ const SiteManageV2 = () => {
}
handleShowModal('loading', false);
setdataList(lodash.cloneDeep(list));
setTotal(res.data.TotalCount);
setTotal(res.data.count);
} else {
handleShowModal('loading', false);
setdataList(lodash.cloneDeep([]));
}
});
};
// 获取当前站点所有已经勾选的用户
const getAllcheckList = async () => {
let res = await getUserByStation({
stationID: currentStation,
_version: 9999,
_dc: new Date().getTime(),
// 搜索状态时获取当前站点可编辑用户(已勾选和未勾选)分页展示
const getSearchList = value => {
let params = {
PageIndex: 1,
PageSize: 10,
};
if (value) params = { ...params, key: value };
getGroupUserTree(params).then(res => {
if (res.code === 0 && res.data) {
setShowSearchStyle(true);
let list = res.data.data;
// 还原选择的数据
if (selectList.length > 0) {
selectList.forEach(item => {
list.forEach((value, index) => {
if (item.groupId == value.groupId) {
list[index].users.forEach((user, userIndex) => {
if (user.userId === item.userId) {
list[index].users[userIndex].isChecked = true;
}
});
let checkedLen = list[index].users.filter(v => v.isChecked).length;
if (checkedLen === list[index].users.length) {
list[index].isChecked = true;
}
}
});
});
}
handleShowModal('loading', false);
setdataList(lodash.cloneDeep(list));
setTotal(res.data.count);
} else {
handleShowModal('loading', false);
setdataList(lodash.cloneDeep([]));
}
});
if (res.length > 0) {
// 还原从后台返回的数据 选中的列表
let list = [];
// console.log(res);
res.forEach(item => {
if (item.userList.length > 0) {
item.userList.forEach(value => {
// console.log(value);
if (
value.isChecked &&
list.findIndex(v => +v.GroupId === +item.OUID && +v.userID === +value.userID) === -1
) {
list.push({
GroupId: +item.OUID,
GroupName: item.OUName,
userName: value.userName,
userID: value.userID,
});
}
setPage({ pageNum: 1, pageSize: 10 });
};
// 重置
const restButton = () => {
let params = {
PageIndex: 1,
PageSize: 10,
};
params = { ...params };
getGroupUserTree(params).then(res => {
if (res.code === 0 && res.data) {
setShowSearchStyle(true);
let list = res.data.data;
// 还原选择的数据
if (selectList.length > 0) {
selectList.forEach(item => {
list.forEach((value, index) => {
if (item.groupId == value.groupId) {
list[index].users.forEach((user, userIndex) => {
if (user.userId === item.userId) {
list[index].users[userIndex].isChecked = true;
}
});
let checkedLen = list[index].users.filter(v => v.isChecked).length;
if (checkedLen === list[index].users.length) {
list[index].isChecked = true;
}
}
});
});
}
});
setSelectList(lodash.cloneDeep(list));
setUpdatePageUser(updatePageUser + 1);
}
handleShowModal('loading', false);
setdataList(lodash.cloneDeep(list));
setTotal(res.data.count);
} else {
handleShowModal('loading', false);
setdataList(lodash.cloneDeep([]));
}
});
setName('');
setPage({ pageNum: 1, pageSize: 10 });
};
const handleChange = e => {
setName(e.target.value);
};
// 获取当前站点所有已经勾选的用户新接口
......@@ -282,10 +320,10 @@ const SiteManageV2 = () => {
if (res.data.length > 0) {
res.data.map((item, index) => {
list.push({
GroupId: +item.OUID,
GroupName: item.OUName,
groupId: +item.OUID,
groupName: item.OUName,
userName: item.userName,
userID: item.userID,
userId: item.userID,
});
});
}
......@@ -295,7 +333,6 @@ const SiteManageV2 = () => {
};
// 选中某个站点
const onSelect = (props, e) => {
console.log('props[0]', props[0]);
setCh(props[0]);
if (!props[0]) {
setCurrentStation(currentStation);
......@@ -303,11 +340,8 @@ const SiteManageV2 = () => {
setCurrentStation(props[0]);
}
setPage({ pageNum: 1, pageSize: 10 });
console.log(data);
data.map((item, index) => {
if (item.id == props[0]) {
console.log(item.id);
console.log(item.describe);
setDes(item.describe);
}
});
......@@ -315,19 +349,16 @@ const SiteManageV2 = () => {
const getValue = () => {
getSiteTree({ selectNode: -1 }).then(res => {
console.log(res.data);
getData1(res.data);
});
};
const getData1 = e => {
console.log(e);
e.map((i, j) => {
a.push(i);
if (i.children.length > 0) {
getData1(i.children);
}
});
console.log(a);
setData(a);
};
......@@ -337,8 +368,8 @@ const SiteManageV2 = () => {
};
// 获取搜索框的值
const handleSearch = value => {
setName(value);
getList(value);
// setName(value);
getSearchList(value);
};
const confirmModal = e => {
handleShowModal('modalVisible', false);
......@@ -362,7 +393,7 @@ const SiteManageV2 = () => {
};
const handleChangeCollpase = (groupId, isShow) => {
let index = dataList.findIndex(item => item.GroupId === groupId);
let index = dataList.findIndex(item => item.groupId === groupId);
if (dataList[index].children && dataList[index].children.length > 0) {
setdataList(lodash.cloneDeep(dataList));
return;
......@@ -379,18 +410,18 @@ const SiteManageV2 = () => {
// 每组全选全不选
const handleChangeAll = (e, index) => {
dataList[index].isChecked = e.target.checked;
dataList[index].Users.forEach(item => {
dataList[index].users.forEach(item => {
item.isChecked = e.target.checked;
let delIndex = selectList.findIndex(
v => v.GroupId === dataList[index].GroupId && v.userID === item.userID,
v => v.groupId == dataList[index].groupId && v.userId == item.userId,
);
if (e.target.checked) {
if (delIndex === -1) {
selectList.push({
GroupId: dataList[index].GroupId,
GroupName: dataList[index].GroupName,
groupId: dataList[index].groupId,
groupName: dataList[index].groupName,
userName: item.userName,
userID: item.userID,
userId: item.userId,
});
}
}
......@@ -398,41 +429,41 @@ const SiteManageV2 = () => {
selectList.splice(delIndex, 1);
}
});
setSelectList(lodash.cloneDeep(selectList));
setdataList(lodash.cloneDeep(dataList));
};
// 单个选择checkbox
const handleChangeSignel = (e, index, vIndex) => {
dataList[index].Users[vIndex].isChecked = e.target.checked;
dataList[index].users[vIndex].isChecked = e.target.checked;
let checked = isAllChecked(index);
let hasIndex = selectList.findIndex(
item =>
item.userID === dataList[index].Users[vIndex].userID &&
item.GroupId === dataList[index].GroupId,
item.userId == dataList[index].users[vIndex].userId &&
item.groupId == dataList[index].groupId,
);
dataList[index].isChecked = checked;
if (e.target.checked && hasIndex === -1) {
selectList.push({
GroupId: dataList[index].GroupId,
GroupName: dataList[index].GroupName,
userName: dataList[index].Users[vIndex].userName,
userID: dataList[index].Users[vIndex].userID,
groupId: dataList[index].groupId,
groupName: dataList[index].groupName,
userName: dataList[index].users[vIndex].userName,
userId: dataList[index].users[vIndex].userId,
});
} else {
selectList.splice(hasIndex, 1);
}
setSelectList(lodash.cloneDeep(selectList));
setdataList(lodash.cloneDeep(dataList));
};
const isAllChecked = index =>
dataList[index].Users.filter(item => item.isChecked).length === dataList[index].Users.length;
dataList[index].users.filter(item => item.isChecked).length === dataList[index].users.length;
// 删除已选列表
const handleDel = index => {
let { GroupId, userID } = selectList[index];
let outerIndex = dataList.findIndex(item => item.GroupId === GroupId);
let { groupId, userId } = selectList[index];
let outerIndex = dataList.findIndex(item => item.groupId == groupId);
if (outerIndex > -1) {
let innerIndex = dataList[outerIndex].Users.findIndex(item => item.userID === userID);
dataList[outerIndex].Users[innerIndex].isChecked = false;
let innerIndex = dataList[outerIndex].users.findIndex(item => item.userId == userId);
dataList[outerIndex].users[innerIndex].isChecked = false;
dataList[outerIndex].isChecked = isAllChecked(outerIndex);
}
selectList.splice(index, 1);
......@@ -445,10 +476,10 @@ const SiteManageV2 = () => {
let result = [];
let obj = {};
selectList.forEach(item => {
if (obj[item.GroupId]) {
obj[item.GroupId].push(item.userID);
if (obj[item.groupId]) {
obj[item.groupId].push(item.userId);
} else {
obj[item.GroupId] = [item.userID];
obj[item.groupId] = [item.userId];
}
});
// dataList.forEach(item => {
......@@ -488,7 +519,6 @@ const SiteManageV2 = () => {
})
.catch(err => {
handleShowModal('btnLoading', false);
console.log(err);
});
};
// 分页
......@@ -504,15 +534,12 @@ const SiteManageV2 = () => {
// 模糊查询匹配的样式
const searchStyle = val => {
console.log(showSearchStyle);
console.log(name);
let n;
if (showSearchStyle) {
n = val.replace(new RegExp(name, 'g'), `<span style='color:red'>${name}</span>`);
} else {
n = val;
}
console.log(n);
return <div dangerouslySetInnerHTML={{ __html: n }} />;
};
// 返回拖拽完毕后的信息
......@@ -528,15 +555,12 @@ const SiteManageV2 = () => {
};
// 树的拖拽
const handleDrop = infos => {
console.log(infos);
const dropKey = infos.node.key;
const dragKey = infos.dragNode.key;
const dropPos = infos.node.pos.split('-');
const dropPosition = infos.dropPosition - Number(dropPos[dropPos.length - 1]);
const datas = JSON.parse(JSON.stringify(treeData));
console.log(dropKey, 'dropKey');
console.log(dragKey, 'dragKey');
// 找到拖拽的元素
let dragObj;
let dropObj;
......@@ -553,7 +577,6 @@ const SiteManageV2 = () => {
});
// 将节点插入到正确的位置
if (!infos.dropToGap) {
console.log('33333333333');
dropObj.children = dropObj.children || [];
// 在哪里插入,示例添加到头部,可以是随意位置
dropObj.children.unshift(dragObj);
......@@ -588,9 +611,9 @@ const SiteManageV2 = () => {
});
};
const Panels = React.memo(props => {
let { index, GroupId, GroupName, Users, isChecked, isShow, color } = props;
let { index, groupId, groupName, users, isChecked, isShow, color } = props;
return (
<div className={styles.sitePanel} key={GroupId} id={`siteId${GroupId}`}>
<div className={styles.sitePanel} key={groupId} id={`siteId${groupId}`}>
{/* onClick={() => props.handleChangeCollpase(GroupId, isShow)} */}
<div className={styles.sitePanelHead}>
{/* {isShow ? (
......@@ -600,7 +623,7 @@ const SiteManageV2 = () => {
)} */}
{/* <UpOutlined className={styles.siteIcon} /> */}
<ApartmentOutlined className={styles.siteIcon} />
{searchStyle(GroupName)}
{searchStyle(groupName)}
<Checkbox
key="0"
className={styles.siteListTitle}
......@@ -611,13 +634,13 @@ const SiteManageV2 = () => {
</Checkbox>
</div>
<div className={styles.sitePanelCon}>
{Users.length > 0 &&
Users.map((v, vIndex) => (
{users.length > 0 &&
users.map((v, vIndex) => (
<CheckBoxRow
{...v}
index={index}
vIndex={vIndex}
key={v.userID}
key={v.userId}
handleChangeSignel={props.handleChangeSignel}
/>
))}
......@@ -724,11 +747,14 @@ const SiteManageV2 = () => {
allowClear
placeholder={placeholder}
onSearch={handleSearch}
// onChange={handleChange}
value={name}
onChange={e => handleChange(e)}
enterButton
/>
</Col>
<Col span={3} />
<Col span={3}>
<Button onClick={restButton}>重置</Button>
</Col>
</Row>
</Card>
<div style={{ background: '#fff' }}>
......@@ -759,10 +785,10 @@ const SiteManageV2 = () => {
<ul className={styles.siteSelectUl}>
{selectList.map((item, index) => (
<li
key={`${item.userName}${item.GroupId}${index}`}
key={`${item.userName}${item.groupId}${index}`}
onClick={() => handleDel(index)}
>
{`${item.userName}(${item.GroupName})`}
{`${item.userName}(${item.groupName})`}
</li>
))}
</ul>
......@@ -804,7 +830,7 @@ const SiteManageV2 = () => {
<Panels
{...item}
index={index}
key={item.GroupId}
key={item.groupId}
handleChangeCollpase={handleChangeCollpase}
handleChangeAll={handleChangeAll}
handleChangeSignel={handleChangeSignel}
......
/*
* @Description:
* @Author: leizhe
* @Date: 2022-01-13 17:26:14
* @LastEditTime: 2022-01-19 17:00:53
* @LastEditors: leizhe
*/
import { get, post, CITY_SERVICE, PUBLISH_SERVICE } from '@/services/index';
/*
......@@ -37,6 +44,9 @@ export const getStationUserList = params =>
// 获取站点管理一二级列表+分页
export const groupUserPagingList = params =>
post(`${PUBLISH_SERVICE}/UserCenter/GroupUserPagingList`, params);
export const getGroupUserTree = params =>
get(`${PUBLISH_SERVICE}/UserCenter/GetGroupUserTree`, params);
// 添加子站点
export const addChildSiteNode = params =>
get(`${PUBLISH_SERVICE}/UserCenter/AddChildSiteNode`, params);
......
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