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

fix: '角色管理'

parent af2d48f3
Pipeline #46119 skipped with stages
/* eslint-disable import/order */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Checkbox } from 'antd'; import { Checkbox } from 'antd';
import classnames from 'classnames'; import classnames from 'classnames';
import styles from './itemCard.less'; import styles from './itemCard.less';
import { checkChildrenByCondition, checkIsGroup, getId } from '.'; import { checkChildrenByCondition, checkIsGroup, getId } from '.';
import { FolderOpenOutlined, FolderOutlined } from '@ant-design/icons';
const ListCardItem = props => { const ListCardItem = props => {
const { const { searchWord, item, valueList, updateValueList, ouid, changedItem, flag } = props;
searchWord,
item,
valueList,
updateValueList,
ouid,
changedItem,
} = props;
// id // id
const id = getId(item); const id = getId(item);
...@@ -21,46 +16,55 @@ const ListCardItem = props => { ...@@ -21,46 +16,55 @@ const ListCardItem = props => {
// 当前组件是否是分组id // 当前组件是否是分组id
const isGroup = checkIsGroup(item); const isGroup = checkIsGroup(item);
const [indeterminate, setIndeterminate] = useState(!isGroup); const [indeterminate, setIndeterminate] = useState(isGroup);
const [childrenKeys, setChildrenKeys] = useState([]); const [childrenKeys, setChildrenKeys] = useState([]);
useEffect(() => { useEffect(() => {
console.log(valueList);
console.log(changedItem); // 改变项
console.log(item); // 本次进循环的项
// console.log(childrenKeys); // 本次循环item的全部子元素id
// 子节点勾选状态变化时
if (isGroup) { if (isGroup) {
const keys = item.children const keys = item.children
.map(child => .map(child => checkChildrenByCondition(child, c => getId(c), true, 'map'))
checkChildrenByCondition(child, c => getId(c), true, 'map'),
)
.flat(Infinity); .flat(Infinity);
setChildrenKeys(keys); setChildrenKeys(keys);
} else {
//
} }
}, [item]);
useEffect(() => {
// 子节点勾选状态变化时
if ( if (
isGroup && isGroup
changedItem.item !== item && // changedItem.item !== item &&
!checkIsGroup(changedItem.item) && // !checkIsGroup(changedItem.item) &&
childrenKeys.includes(getId(changedItem.item)) // childrenKeys.includes(getId(changedItem.item))
) { ) {
if (changedItem.value && childrenKeys.every(c => valueList.includes(c))) { // console.log(childrenKeys.every(c => valueList.includes(c)));
console.log(item);
console.log(childrenKeys);
if (childrenKeys.every(c => valueList.includes(c))) {
// 全选 // 全选
updateValueList([id], [id]); console.log(2121);
updateValueList([id], [id], { item, value: true });
console.log(valueList);
setIndeterminate(false); setIndeterminate(false);
} else if (childrenKeys.some(c => valueList.includes(c))) { } else if (childrenKeys.some(c => valueList.includes(c))) {
console.log(211231);
console.log(valueList);
console.log(id);
// 半选 // 半选
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
valueList.includes(id) && updateValueList([], [id]); valueList.includes(id) && updateValueList([], [id], { item, value: false });
setIndeterminate(true); setIndeterminate(true);
} else { } else {
// 零选 // 零选
console.log(232323);
console.log(valueList);
console.log(id);
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
valueList.includes(id) && updateValueList([], [id]); valueList.includes(id) && updateValueList([], [id], { item, value: false });
setIndeterminate(false); setIndeterminate(false);
} }
} }
}, [changedItem.item, changedItem.value]); }, [changedItem.item, changedItem.value, flag]);
// 勾选事件处理 // 勾选事件处理
const handleChecked = e => { const handleChecked = e => {
...@@ -70,6 +74,8 @@ const ListCardItem = props => { ...@@ -70,6 +74,8 @@ const ListCardItem = props => {
updateValueList(v ? result : [], result, { item, value: v }); updateValueList(v ? result : [], result, { item, value: v });
setIndeterminate(false); setIndeterminate(false);
} else { } else {
// console.log(item);
// console.log(v);
updateValueList(v ? [id] : [], [id], { item, value: v }); updateValueList(v ? [id] : [], [id], { item, value: v });
} }
}; };
...@@ -85,11 +91,13 @@ const ListCardItem = props => { ...@@ -85,11 +91,13 @@ const ListCardItem = props => {
ouid={ouid} ouid={ouid}
changedItem={changedItem} changedItem={changedItem}
searchWord={searchWord} searchWord={searchWord}
flag={flag}
/> />
)); ));
// 通过把isChecked为true的id存在valueList集合里面,递归数据当id是否被包含在valueList中时返回值来渲染true或false
return ( return (
<> <>
{/* {console.log(valueList, 'valueList')} */}
<div <div
className={classnames({ className={classnames({
[styles.divBox]: isGroup, [styles.divBox]: isGroup,
...@@ -113,11 +121,20 @@ const ListCardItem = props => { ...@@ -113,11 +121,20 @@ const ListCardItem = props => {
<span <span
className={classnames({ className={classnames({
[styles.boldLabel]: isGroup, [styles.boldLabel]: isGroup,
[styles.isSearch]: [styles.isSearch]: searchWord && item.text.includes(searchWord),
searchWord && item.text.includes(searchWord),
})} })}
> >
{item.text} {isGroup ? (
<>
<FolderOpenOutlined style={{ color: '#1890ff' }} />
<span style={{ marginLeft: '5px' }}>{item.text}</span>
</>
) : (
<>
<FolderOutlined style={{ color: '#1890ff' }} />
<span style={{ marginLeft: '5px' }}>{item.text}</span>
</>
)}
</span> </span>
)} )}
</Checkbox> </Checkbox>
......
/* eslint-disable no-unused-expressions */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Spin, Checkbox, Button, Empty } from 'antd'; import { Spin, Checkbox, Button, Empty } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
...@@ -33,40 +34,80 @@ const ListCard = props => { ...@@ -33,40 +34,80 @@ const ListCard = props => {
btnLoading = false, btnLoading = false,
loading, loading,
} = props; } = props;
const [valueList, setValueList] = useState([]); const [valueList, setValueList] = useState([]); // 选中值
const [changedItem, setChangedItem] = useState({ item: {} }); const [changedItem, setChangedItem] = useState({ item: {} }); // 改变的项
const [indeterminate, setIndeterminate] = useState(false);
const [keepAA, setKeepAA] = useState('');
const [checkValue, setCheckValue] = useState(false);
const [flag, setFlag] = useState(0);
// 首次进入处理数据后续不触发
useEffect(() => { useEffect(() => {
console.log(dataList);
let aa = dataList
.map(l => checkChildrenByCondition(l, it => [getId(it)], true, 'map').flat(Infinity))
.flat(Infinity)
.filter(Boolean).length;
setKeepAA(aa);
setValueList(checkList); setValueList(checkList);
if (checkList.length === 0) {
setIndeterminate(false);
setCheckValue(false);
} else if (checkList.length < aa) {
setIndeterminate(true);
setCheckValue(false);
} else {
setIndeterminate(false);
setCheckValue(true);
}
}, [dataList, loading, checkList]); }, [dataList, loading, checkList]);
// 处理选中的值
const updateValueList = (checkedKeys, childrenKeys, sourceItem) => { const updateValueList = (checkedKeys, childrenKeys, sourceItem) => {
// eslint-disable-next-line no-console // console.log(checkedKeys);
// console.time('updateValueList:'); // console.log(childrenKeys);
console.log(sourceItem);
console.log(changedItem);
const removekeys = _.difference(childrenKeys, checkedKeys); const removekeys = _.difference(childrenKeys, checkedKeys);
let result = _.uniq(_.union(checkedKeys, valueList)); let result = _.uniq(_.union(checkedKeys, valueList));
_.remove(result, v => removekeys.includes(v)); _.remove(result, v => removekeys.includes(v));
setValueList(result); setValueList(result);
if (sourceItem) setChangedItem(sourceItem); console.log(result);
// eslint-disable-next-line no-unused-expressions setChangedItem(sourceItem);
onChange && onChange(result); onChange && onChange(result);
// eslint-disable-next-line no-console if (result.length === 0) {
// console.timeEnd('updateValueList:'); setIndeterminate(false);
setCheckValue(false);
} else if (result.length < keepAA) {
setIndeterminate(true);
setCheckValue(false);
} else {
setIndeterminate(false);
setCheckValue(true);
}
}; };
// 全选
const checkAll = e => { const checkAll = e => {
setFlag(flag + 1);
if (e.target.checked) { if (e.target.checked) {
const result = dataList.map(item => getAllID(item)).flat(Infinity); const arr = JSON.parse(JSON.stringify(dataList));
const result = arr.map(item => getAllID(item)).flat(Infinity);
setValueList(result); setValueList(result);
setCheckValue(true);
setIndeterminate(false);
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
onChange && onChange(result); onChange && onChange(result);
} else { } else {
setValueList([]); setValueList([]);
setCheckValue(false);
setIndeterminate(false);
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
onChange && onChange([]); onChange && onChange([]);
} }
}; };
// 获取所有ID
const getAllID = item => { const getAllID = item => {
let result = []; let result = [];
const haveChildren = Array.isArray(item.children) && item.children.length > 0; const haveChildren = Array.isArray(item.children) && item.children.length > 0;
...@@ -95,8 +136,19 @@ const ListCard = props => { ...@@ -95,8 +136,19 @@ const ListCard = props => {
}} }}
/> />
) : ( ) : (
<> <div className={styles.divBox}>
<Checkbox onChange={checkAll}>全选/全不选</Checkbox> <span
style={{
display: 'block',
marginTop: '-14px',
width: '120px',
backgroundColor: 'white',
}}
>
<Checkbox onChange={checkAll} indeterminate={indeterminate} checked={checkValue}>
<span style={{ fontSize: '16px', fontWeight: 'bold' }}>全选/全不选</span>
</Checkbox>
</span>
{dataList && dataList.length > 0 ? ( {dataList && dataList.length > 0 ? (
dataList dataList
.filter(d => d.type === 'widgetGroup' || 'widget') .filter(d => d.type === 'widgetGroup' || 'widget')
...@@ -104,6 +156,7 @@ const ListCard = props => { ...@@ -104,6 +156,7 @@ const ListCard = props => {
<ListCardItem <ListCardItem
item={item} item={item}
ouid={ouid} ouid={ouid}
flag={flag}
changedItem={changedItem} changedItem={changedItem}
updateValueList={updateValueList} updateValueList={updateValueList}
valueList={valueList} valueList={valueList}
...@@ -115,7 +168,7 @@ const ListCard = props => { ...@@ -115,7 +168,7 @@ const ListCard = props => {
) : ( ) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
)} )}
</> </div>
)} )}
{true && !loading && dataList && dataList.length > 0 && ( {true && !loading && dataList && dataList.length > 0 && (
<div className={styles.btnBox}> <div className={styles.btnBox}>
......
.divBox { .divBox {
// display: flex; // display: flex;
width: 100%; width: 100%;
...@@ -8,15 +7,15 @@ ...@@ -8,15 +7,15 @@
margin-top: 20px; margin-top: 20px;
min-height: 50px; min-height: 50px;
padding: 0 10px 10px 20px; padding: 0 10px 10px 20px;
.ant-checkbox-wrapper{ .ant-checkbox-wrapper {
background-color: #fff; background-color: #fff;
} }
.topCheckbox{ .topCheckbox {
height: 20px; height: 20px;
margin: -10px 0 0 0px; margin: -10px 0 0 0px;
line-height: 20px; line-height: 20px;
} }
.topCheckbox>label :hover{ .topCheckbox > label :hover {
font-weight: 600; font-weight: 600;
} }
.checkdiv { .checkdiv {
...@@ -26,9 +25,10 @@ ...@@ -26,9 +25,10 @@
// justify-content: space-between; // justify-content: space-between;
} }
} }
.divSingle{ .divSingle {
border: none; border: none;
margin-top: 20px; margin-top: 20px;
padding-left: 20px;
min-width: 180px; min-width: 180px;
flex-grow: 0; flex-grow: 0;
flex-shrink: 0; flex-shrink: 0;
...@@ -37,16 +37,16 @@ ...@@ -37,16 +37,16 @@
margin-right: 10px; margin-right: 10px;
background: transparent; background: transparent;
} }
.isSearch{ .isSearch {
color: red; color: red;
background-color: yellow; background-color: yellow;
} }
.boldLabel{ .boldLabel {
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
background-color: #fff; background-color: #fff;
} }
.btnBox{ .btnBox {
position: sticky; position: sticky;
bottom: 0px; bottom: 0px;
right: 0px; right: 0px;
...@@ -57,4 +57,4 @@ ...@@ -57,4 +57,4 @@
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
} }
\ No newline at end of file
...@@ -199,7 +199,8 @@ const MapScope = props => { ...@@ -199,7 +199,8 @@ const MapScope = props => {
title={ title={
<span> <span>
<span style={{ marginRight: '20px' }}> <span style={{ marginRight: '20px' }}>
<span style={{ fontWeight: 'blod', color: 'red' }}>{title}</span>的范围选择 <span style={{ fontWeight: 'blod', color: 'rgb(24, 144, 255)' }}>{title}</span>
的范围选择
</span> </span>
<span style={{ color: 'red' }}>提示:必须框选范围</span> <span style={{ color: 'red' }}>提示:必须框选范围</span>
</span> </span>
...@@ -210,6 +211,7 @@ const MapScope = props => { ...@@ -210,6 +211,7 @@ const MapScope = props => {
setFlag(0); setFlag(0);
}} }}
width="800px" width="800px"
maskClosable={false}
cancelText="取消" cancelText="取消"
okText="确认" okText="确认"
onOk={() => onSubmit()} onOk={() => onSubmit()}
......
/* eslint-disable no-unused-expressions */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Input, notification, Select } from 'antd'; import { Form, Input, notification, Select, Radio, Tooltip } from 'antd';
import SiteModal from '@/components/Modal/SiteModa'; import SiteModal from '@/components/Modal/SiteModa';
import { import { addRole, GetRoleGroup, getWebConfigTypes } from '@/services/RoleManage/api';
addRole, import { InfoCircleOutlined } from '@ant-design/icons';
GetRoleGroup,
getWebConfigTypes,
} from '@/services/RoleManage/api';
const { Item } = Form; const { Item } = Form;
const { Option } = Select; const { Option } = Select;
const AddModal = props => { const AddModal = props => {
...@@ -15,6 +13,7 @@ const AddModal = props => { ...@@ -15,6 +13,7 @@ const AddModal = props => {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const { confirmModal, itemObj, siteList } = props; const { confirmModal, itemObj, siteList } = props;
const [typeList, setTypeList] = useState([]); // 应用类别 const [typeList, setTypeList] = useState([]); // 应用类别
const [value, setValue] = useState(2);
useEffect(() => { useEffect(() => {
itemObj.groupflag && itemObj.groupflag &&
form.setFieldsValue({ form.setFieldsValue({
...@@ -61,15 +60,23 @@ const AddModal = props => { ...@@ -61,15 +60,23 @@ const AddModal = props => {
.then(res => { .then(res => {
console.log(form.getFieldsValue()); console.log(form.getFieldsValue());
setLoading(true); setLoading(true);
console.log(res.BuiltInRole);
if (!res.BuiltInRole || res.BuiltInRole == 2) {
res.BuiltInRole = false;
} else if (res.BuiltInRole == 1) {
res.BuiltInRole = true;
}
console.log(res.BuiltInRole);
addRole({ addRole({
roleName: res.roleName, roleName: res.roleName,
description: res.description, description: res.description,
group: res.group, group: res.group,
subSystemValue: res.subSystemValue || '', subSystemValue: res.subSystemValue || '',
BuiltInRole: res.BuiltInRole,
}) })
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (res.msg==='') { if (res.msg === '') {
let id = res.roleID; let id = res.roleID;
form.resetFields(); form.resetFields();
notification.success({ notification.success({
...@@ -111,7 +118,6 @@ const AddModal = props => { ...@@ -111,7 +118,6 @@ const AddModal = props => {
setGroupList([]); setGroupList([]);
console.log(form.getFieldsValue().subSystemValue); console.log(form.getFieldsValue().subSystemValue);
GetRoleGroup({ GetRoleGroup({
// subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '', // subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '',
// subSystemName: itemObj.subSystemValue || itemObj.visibleValue || '', // subSystemName: itemObj.subSystemValue || itemObj.visibleValue || '',
subSystemValue: form.getFieldsValue().subSystemValue || '', subSystemValue: form.getFieldsValue().subSystemValue || '',
...@@ -157,6 +163,10 @@ const AddModal = props => { ...@@ -157,6 +163,10 @@ const AddModal = props => {
console.log(e); console.log(e);
}; };
const onChangeRadio = e => {
console.log(e.target.value);
setValue(e.target.value);
};
const onFinish = value => {}; const onFinish = value => {};
return ( return (
<SiteModal <SiteModal
...@@ -220,6 +230,22 @@ const AddModal = props => { ...@@ -220,6 +230,22 @@ const AddModal = props => {
))} ))}
</Select> </Select>
</Item> </Item>
<Item
label={
<div>
<Tooltip title="内置角色不能配置菜单权限">
<InfoCircleOutlined style={{ color: 'rgb(24, 144, 255)', marginRight: '5px' }} />
</Tooltip>
<span>内置角色</span>
</div>
}
name="BuiltInRole"
>
<Radio.Group onChange={onChangeRadio} value={value} defaultValue={value}>
<Radio value={1}></Radio>
<Radio value={2}></Radio>
</Radio.Group>
</Item>
<Item label="角色分组" name="group"> <Item label="角色分组" name="group">
<Select <Select
mode="tags" mode="tags"
......
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Form, Input, notification, Select } from 'antd'; import { Form, Input, notification, Select, Radio, Tooltip } from 'antd';
import SiteModal from '@/components/Modal/SiteModa'; import SiteModal from '@/components/Modal/SiteModa';
import { editRole, GetRoleGroup } from '@/services/RoleManage/api'; import { editRole, GetRoleGroup } from '@/services/RoleManage/api';
import { InfoCircleOutlined } from '@ant-design/icons';
const { Item } = Form; const { Item } = Form;
const { Option } = Select; const { Option } = Select;
const AddModal = props => { const AddModal = props => {
...@@ -9,16 +10,24 @@ const AddModal = props => { ...@@ -9,16 +10,24 @@ const AddModal = props => {
const [formLayout, setFormLayout] = useState('horizontal'); const [formLayout, setFormLayout] = useState('horizontal');
const [groupList, setGroupList] = useState([]); const [groupList, setGroupList] = useState([]);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const { confirmModal, itemObj, editVisible } = props; const { confirmModal = () => {}, itemObj, editVisible } = props;
const [value, setValue] = useState('');
console.log(itemObj, 'itemObj'); console.log(itemObj, 'itemObj');
useEffect(() => { useEffect(() => {
console.log(itemObj.BuiltInRole);
form.setFieldsValue({ form.setFieldsValue({
roleName: itemObj.roleName, roleName: itemObj.roleName,
description: itemObj.description, description: itemObj.description,
group: itemObj.group, group: itemObj.group,
subSystemValue: itemObj.subSystemValue, subSystemValue: itemObj.subSystemValue,
}); });
if (itemObj.BuiltInRole === true) {
setValue(1);
} else {
setValue(2);
}
}, [itemObj]); }, [itemObj]);
const onSubmit = () => { const onSubmit = () => {
form form
...@@ -26,23 +35,36 @@ const AddModal = props => { ...@@ -26,23 +35,36 @@ const AddModal = props => {
.then(res => { .then(res => {
console.log(res, 'res'); console.log(res, 'res');
setLoading(true); setLoading(true);
console.log(value);
if (value == 2) {
res.BuiltInRole = false;
} else {
res.BuiltInRole = true;
}
console.log(res.BuiltInRole);
editRole({ editRole({
roleID: itemObj.roleID, roleID: itemObj.roleID,
roleName: res.roleName, roleName: res.roleName,
description: res.description, description: res.description,
remark: res.group, remark: res.group,
BuiltInRole: res.BuiltInRole,
// subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '', // subSystemValue: itemObj.subSystemValue || itemObj.visibleValue || '',
}) })
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (res.msg==='') { if (res.msg === '') {
form.resetFields(); form.resetFields();
notification.success({ notification.success({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: '编辑成功', description: '编辑成功',
}); });
confirmModal(); console.log(value);
if (value == 1) {
confirmModal(true);
} else {
confirmModal(false);
}
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -95,6 +117,10 @@ const AddModal = props => { ...@@ -95,6 +117,10 @@ const AddModal = props => {
}); });
}; };
const onChangeRadio = e => {
console.log(e.target.value);
setValue(e.target.value);
};
const onFinish = value => {}; const onFinish = value => {};
return ( return (
<SiteModal <SiteModal
...@@ -109,12 +135,7 @@ const AddModal = props => { ...@@ -109,12 +135,7 @@ const AddModal = props => {
onOk={() => onSubmit()} onOk={() => onSubmit()}
confirmLoading={loading} confirmLoading={loading}
> >
<Form <Form form={form} layout={formLayout} onFinish={onFinish} labelCol={{ span: 4 }}>
form={form}
layout={formLayout}
onFinish={onFinish}
labelCol={{ span: 4 }}
>
<Item <Item
label="角色名称" label="角色名称"
name="roleName" name="roleName"
...@@ -127,9 +148,26 @@ const AddModal = props => { ...@@ -127,9 +148,26 @@ const AddModal = props => {
> >
<Input placeholder="请输入角色名称" /> <Input placeholder="请输入角色名称" />
</Item> </Item>
<Item label="角色类别" name="subSystemValue"> <Item label="虚拟目录" name="subSystemValue">
{itemObj.subSystemValue || itemObj.visibleValue} {itemObj.subSystemValue || itemObj.visibleValue}
</Item> </Item>
<Item
label={
<div>
<Tooltip title="内置角色不能配置菜单权限">
<InfoCircleOutlined style={{ color: 'rgb(24, 144, 255)', marginRight: '5px' }} />
</Tooltip>
<span>内置角色</span>
</div>
}
name="BuiltInRole"
>
{console.log(value, 'nalie')}
<Radio.Group onChange={onChangeRadio} value={value}>
<Radio value={1}></Radio>
<Radio value={2}></Radio>
</Radio.Group>
</Item>
<Item label="角色分组" name="group"> <Item label="角色分组" name="group">
<Select <Select
mode="tags" mode="tags"
......
...@@ -91,12 +91,12 @@ const SiteManage = () => { ...@@ -91,12 +91,12 @@ const SiteManage = () => {
const { node } = treenode; const { node } = treenode;
const { roleID: id } = node; const { roleID: id } = node;
setItemObj(node); setItemObj(node);
let aa = chileID.find(i => i.roleID === id); console.log(id);
if (id) { if (id) {
setSaveTreeId(id); setSaveTreeId(id);
if (aa) { if (node.BuiltInRole === true) {
setRoleID(''); setRoleID('');
setDescrip('系统分组下的角色不可配置菜单权限'); setDescrip('内置角色不可配置菜单权限');
setFlagSearch(0); setFlagSearch(0);
} else { } else {
setRoleID(id); setRoleID(id);
...@@ -144,47 +144,10 @@ const SiteManage = () => { ...@@ -144,47 +144,10 @@ const SiteManage = () => {
getRoleGroupList({ userID: '1' }).then(res => { getRoleGroupList({ userID: '1' }).then(res => {
setSpinLoading(false); setSpinLoading(false);
if (res.code === 0) { if (res.code === 0) {
console.log(res.data.roleList);
res.data.roleList.map((i, j) => {
console.log(i);
if (i.child.length == 0) {
let childData = { visibleTitle: '系统分组', roleList: [] };
childData.visibleValue = i.visibleValue;
i.child.push(childData);
} else {
let arr = [];
i.child.map(k => {
arr.push(k.visibleTitle);
});
if (arr.indexOf('系统分组') == -1) {
let childData = { visibleTitle: '系统分组', roleList: [] };
childData.visibleValue = i.visibleValue;
console.log(childData.roleList);
i.child.push(childData);
}
}
});
const { roleList } = res.data; const { roleList } = res.data;
console.log(res.data);
let arr = transTree(roleList); let arr = transTree(roleList);
setTreeData(arr); setTreeData(arr);
console.log(arr);
let dataA = [];
arr.map(i => {
console.log(i.child);
dataA.push(i.child.find(j => j.visibleTitle === '系统分组'));
// if (i.child.find(j => j.visibleTitle === '系统分组')) {
// data.push(j);
// }
});
console.log(dataA);
let Arr = [];
dataA.map(i => {
i.children.map(j => {
Arr.push(j);
});
});
console.log(Arr);
setChildID(Arr);
} }
}); });
}; };
...@@ -341,7 +304,7 @@ const SiteManage = () => { ...@@ -341,7 +304,7 @@ const SiteManage = () => {
/> />
</Tooltip> </Tooltip>
)} )}
{i.groupflag && i.groupflag != '系统分组' && ( {i.groupflag && (
<Tooltip title="编辑分组" className={styles.fs}> <Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined <EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }} style={{ fontSize: '16px', color: '#1890FF' }}
...@@ -406,7 +369,7 @@ const SiteManage = () => { ...@@ -406,7 +369,7 @@ const SiteManage = () => {
/> />
</Tooltip> </Tooltip>
)} )}
{itemRole.groupflag && itemRole.groupflag != '系统分组' && ( {itemRole.groupflag && (
<Tooltip title="编辑分组" className={styles.fs}> <Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined <EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }} style={{ fontSize: '16px', color: '#1890FF' }}
...@@ -455,7 +418,7 @@ const SiteManage = () => { ...@@ -455,7 +418,7 @@ const SiteManage = () => {
/> />
</Tooltip> </Tooltip>
)} )}
{item.groupflag && item.groupflag != '系统分组' && ( {item.groupflag && (
<Tooltip title="编辑分组" className={styles.fs}> <Tooltip title="编辑分组" className={styles.fs}>
<EditOutlined <EditOutlined
style={{ fontSize: '16px', color: '#1890FF' }} style={{ fontSize: '16px', color: '#1890FF' }}
...@@ -497,12 +460,6 @@ const SiteManage = () => { ...@@ -497,12 +460,6 @@ const SiteManage = () => {
}; };
// 新增角色 // 新增角色
const addsUser = (e, record) => { const addsUser = (e, record) => {
if (record.visibleTitle == '系统分组') {
message.warn({
duration: 5,
content: '系统分组下的角色不能配置菜单权限',
});
}
e.stopPropagation(); e.stopPropagation();
setItemObj(record); setItemObj(record);
setModalVisible(true); setModalVisible(true);
...@@ -530,11 +487,26 @@ const SiteManage = () => { ...@@ -530,11 +487,26 @@ const SiteManage = () => {
setItemObj(''); setItemObj('');
}; };
// 编辑弹窗回调 // 编辑弹窗回调
const editModal = () => { const editModal = prop => {
setEditVisible(false); setEditVisible(false);
// setFlag(flag + 1); // setFlag(flag + 1);
getRoleGroup(); getRoleGroup();
handleTreeSelect(saveCurId); handleTreeSelect(saveCurId);
console.log(currentSelectId);
console.log(itemObj);
console.log(roleID);
console.log(prop);
if (itemObj.roleID === currentSelectId[0]) {
if (prop == true) {
setRoleID('');
setDescrip('内置角色不可配置菜单权限');
setFlagSearch(0);
} else {
setRoleID(currentSelectId);
setFlagSearch(1);
}
}
// setItemObj(''); // setItemObj('');
}; };
// 分组编辑回调 // 分组编辑回调
......
...@@ -124,6 +124,7 @@ const SiteManageV2 = () => { ...@@ -124,6 +124,7 @@ const SiteManageV2 = () => {
}; };
// 添加下级站点 // 添加下级站点
const addSite = (e, recode) => { const addSite = (e, recode) => {
console.log(e);
e.stopPropagation(); e.stopPropagation();
setCurrentStation(recode.id); setCurrentStation(recode.id);
handleShowModal('addChildVisible', true); handleShowModal('addChildVisible', true);
......
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