Commit 790b67d1 authored by 皮倩雯's avatar 皮倩雯

fix: 'web配置关联角色增加多选,角色管理新增默认分组'

parent c1facb6f
Pipeline #44182 skipped with stages
...@@ -85,8 +85,10 @@ const RoalChoose = props => { ...@@ -85,8 +85,10 @@ const RoalChoose = props => {
}; };
// 复选框监听事件 // 复选框监听事件
const selectChange = (e, index, value) => { const selectChange = (e, index, value) => {
console.log(plainOptions);
let list = JSON.parse(JSON.stringify(plainOptions)); let list = JSON.parse(JSON.stringify(plainOptions));
list[index].isChecked = e.target.checked; list[index].isChecked = e.target.checked;
console.log(list);
// 存储勾选角色或站点信息 // 存储勾选角色或站点信息
if (e.target.checked) { if (e.target.checked) {
// 存储已选角色或站点的默认承办人 // 存储已选角色或站点的默认承办人
...@@ -106,6 +108,9 @@ const RoalChoose = props => { ...@@ -106,6 +108,9 @@ const RoalChoose = props => {
delArr.set(value.id, selected.get(value.id)); delArr.set(value.id, selected.get(value.id));
selected.delete(value.id); selected.delete(value.id);
} }
console.log(list);
console.log(selected);
console.log(list);
setDelArr(delArr); setDelArr(delArr);
setSelected(selected); setSelected(selected);
setPlainOptions(list); setPlainOptions(list);
......
...@@ -42,7 +42,7 @@ const VectorData = props => { ...@@ -42,7 +42,7 @@ const VectorData = props => {
return ( return (
<> <>
<Spin tip="loading..." spinning={treeLoading}> <Spin tip="loading..." spinning={treeLoading}>
<div style={{ height: '780px', overflow: 'scroll' }}> <div>
<div className={styles.tileBtn}> <div className={styles.tileBtn}>
<Button <Button
type="primary" type="primary"
...@@ -53,22 +53,24 @@ const VectorData = props => { ...@@ -53,22 +53,24 @@ const VectorData = props => {
新增 新增
</Button> </Button>
</div> </div>
<div className={styles.cardsList}> <div style={{ height: '700px', overflow: 'scroll' }}>
{tileData && tileData.length <div className={styles.cardsList}>
? tileData.map((item, index) => { {tileData && tileData.length
return ( ? tileData.map((item, index) => {
<div return (
className={styles.cardItem} <div
key={index} className={styles.cardItem}
span={5} key={index}
offset={2} span={5}
style={{ marginBottom: '1rem' }} offset={2}
> style={{ marginBottom: '1rem' }}
<Cards item={item} deletebaseMaps={onDeletebaseMap} /> >
</div> <Cards item={item} deletebaseMaps={onDeletebaseMap} />
); </div>
}) );
: ''} })
: ''}
</div>
</div> </div>
<AddModal <AddModal
visible={visible} visible={visible}
......
...@@ -17,11 +17,11 @@ import AddModal from './AddModal'; ...@@ -17,11 +17,11 @@ import AddModal from './AddModal';
const VectorData = props => { const VectorData = props => {
const [treeLoading, setTreeLoading] = useState(false); // 弹窗显示 const [treeLoading, setTreeLoading] = useState(false); // 弹窗显示
const [schemename, setSchemename] = useState([]); const [schemename, setSchemename] = useState([]);
const [record, setRecord] = useState({}); //选中关联角色的方案名 const [record, setRecord] = useState({}); // 选中关联角色的方案名
const [webCurrent, setWebCurrent] = useState(0); // web列表下标 const [webCurrent, setWebCurrent] = useState(0); // web列表下标
const [handCurrent, setHandCurrent] = useState(0); // hand列表下标 const [handCurrent, setHandCurrent] = useState(0); // hand列表下标
const [webData, setWebData] = useState([]); // web数据 const [webData, setWebData] = useState([]); // web数据
const [handData, setHandData] = useState([]); //手持数据 const [handData, setHandData] = useState([]); // 手持数据
const [visible, setVisible] = useState(false); // 弹窗 const [visible, setVisible] = useState(false); // 弹窗
const [flag, setFlag] = useState(0); // 更新list const [flag, setFlag] = useState(0); // 更新list
const [handStatus, setHandStatus] = useState([]); // 更新状态 const [handStatus, setHandStatus] = useState([]); // 更新状态
...@@ -416,6 +416,7 @@ const VectorData = props => { ...@@ -416,6 +416,7 @@ const VectorData = props => {
columns={columns} columns={columns}
dataSource={webData} dataSource={webData}
bordered bordered
style={{ height: 'calc(100vh - 230px)' }}
pagination={{ pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`, showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
defaultPageSize: 8, defaultPageSize: 8,
...@@ -424,7 +425,7 @@ const VectorData = props => { ...@@ -424,7 +425,7 @@ const VectorData = props => {
}, },
}} }}
rowKey={(record, index) => record.scheme.schemename} rowKey={(record, index) => record.scheme.schemename}
scroll={{ y: 600 }} scroll={{ y: 300 }}
/> />
</div> </div>
{/* <Divider orientation="left"><div className={styles.divider}>手持 <PlusOutlined {/* <Divider orientation="left"><div className={styles.divider}>手持 <PlusOutlined
......
...@@ -46,7 +46,7 @@ const VectorData = props => { ...@@ -46,7 +46,7 @@ const VectorData = props => {
return ( return (
<> <>
<Spin tip="loading..." spinning={treeLoading}> <Spin tip="loading..." spinning={treeLoading}>
<div> <div style={{ height: '780px', overflow: 'scroll' }}>
<div className={styles.tileBtn}> <div className={styles.tileBtn}>
<Button <Button
type="primary" type="primary"
......
...@@ -250,7 +250,7 @@ const ProjectManage = props => { ...@@ -250,7 +250,7 @@ const ProjectManage = props => {
}; };
const onTypeChange = value => { const onTypeChange = value => {
if (value == '全部') { if (value == '全部') {
setCurrentType(''); setCurrentType('全部');
GetMessageList({ pageIndex, pageSize: 10 }); GetMessageList({ pageIndex, pageSize: 10 });
} else { } else {
GetMessageList({ GetMessageList({
...@@ -264,7 +264,7 @@ const ProjectManage = props => { ...@@ -264,7 +264,7 @@ const ProjectManage = props => {
}; };
const onNameChange = value => { const onNameChange = value => {
if (value == '全部') { if (value == '全部') {
setCurrentName(''); setCurrentName('全部');
GetMessageList({ pageIndex, pageSize: 10 }); GetMessageList({ pageIndex, pageSize: 10 });
} else { } else {
GetMessageList({ GetMessageList({
......
...@@ -253,7 +253,11 @@ const TemplateManage = () => { ...@@ -253,7 +253,11 @@ const TemplateManage = () => {
const placeholder = '请输入模板名称'; const placeholder = '请输入模板名称';
const handleSearch = value => { const handleSearch = value => {
setValue(value); setValue(value);
getTemplateList({ queryInfo: value }); if (currentType == '全部') {
getTemplateList({ queryInfo: value });
} else {
getTemplateList({ queryInfo: value, tempType: currentType });
}
setShowSearchStyle(true); setShowSearchStyle(true);
}; };
const handleReset = () => { const handleReset = () => {
...@@ -267,7 +271,7 @@ const TemplateManage = () => { ...@@ -267,7 +271,7 @@ const TemplateManage = () => {
}; };
const handleSelectType = value => { const handleSelectType = value => {
if (value === '全部') { if (value === '全部') {
setCurrentType(''); setCurrentType('全部');
getTemplateList(); getTemplateList();
} else { } else {
getTemplateList({ tempType: value }); getTemplateList({ tempType: value });
......
.formStyle{ .formStyle {
margin-bottom: 40px; margin-bottom: 40px;
padding-bottom: 30px; padding-bottom: 30px;
} }
.rolebox{ .rolebox {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
flex-wrap: nowrap; flex-wrap: nowrap;
} }
\ No newline at end of file .cardItemData {
display: flex;
justify-content: space-around;
width: 100%;
padding: 1rem;
border: 1px solid #b5b8c8;
margin-bottom: 1rem;
overflow-x: scroll;
}
.divBox {
// display: flex;
width: 100%;
flex-wrap: wrap;
border: 1px solid #c2cdfd;
border-radius: 5px;
margin-top: 20px;
min-height: 50px;
padding: 0 10px 10px 20px;
.ant-checkbox-wrapper {
background-color: #fff;
}
.topCheckbox {
height: 20px;
margin: -10px 0 0 0px;
line-height: 20px;
}
.topCheckbox > label :hover {
font-weight: 600;
}
.checkdiv {
display: flex;
flex-wrap: wrap;
// margin-left: 20px;
// justify-content: space-between;
}
}
.boe {
border: 1px solid #d9d9d9;
width: 93%;
margin-left: 3%;
}
...@@ -8,10 +8,12 @@ import { ...@@ -8,10 +8,12 @@ import {
Select, Select,
Radio, Radio,
Checkbox, Checkbox,
checkedValue,
message, message,
notification, notification,
} from 'antd'; } from 'antd';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import classnames from 'classnames';
import styles from './addForm.less'; import styles from './addForm.less';
import PicturesWall from '@/components/Upload/index'; import PicturesWall from '@/components/Upload/index';
import EditeConfigWrapper from './editConfigFileWrapper'; import EditeConfigWrapper from './editConfigFileWrapper';
...@@ -25,6 +27,8 @@ const EditForm = props => { ...@@ -25,6 +27,8 @@ const EditForm = props => {
submitCallback, submitCallback,
nodeType, nodeType,
info, info,
infoAll,
checkList,
configFiles, configFiles,
valueCallback = () => {}, valueCallback = () => {},
productList, productList,
...@@ -32,6 +36,10 @@ const EditForm = props => { ...@@ -32,6 +36,10 @@ const EditForm = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [otherForm] = Form.useForm(); const [otherForm] = Form.useForm();
const [showParmarModal, setShowParmarModal] = useState(false); const [showParmarModal, setShowParmarModal] = useState(false);
const [plainOptions, setPlainOptions] = useState([]); // 存储一级数据
const [indeterminate, setIndeterminate] = useState([]);
const [indeterminateAll, setIndeterminateAll] = useState(false);
const [choo, setChoo] = useState(false); // 最外层复选框状态
const layout = { const layout = {
layout: 'horizontal', layout: 'horizontal',
labelCol: { span: 2 }, labelCol: { span: 2 },
...@@ -41,20 +49,71 @@ const EditForm = props => { ...@@ -41,20 +49,71 @@ const EditForm = props => {
useEffect(() => { useEffect(() => {
form.resetFields(); form.resetFields();
otherForm.resetFields(); otherForm.resetFields();
}, [info]); setPlainOptions(info);
}, [infoAll]);
useEffect(() => { useEffect(() => {
const targetForm = nodeType === 1 ? form : otherForm; const targetForm = nodeType === 1 ? form : otherForm;
let arr = Object.keys(targetForm.getFieldsValue()); let arr = Object.keys(targetForm.getFieldsValue());
let obj = {}; let obj = {};
arr.map(i => { arr.map(i => {
obj[i] = info[i]; obj[i] = infoAll[i];
}); });
targetForm.setFieldsValue({ ...obj, shortName: info.menuShortName }); targetForm.setFieldsValue({ ...obj, shortName: infoAll.menuShortName });
}, [info]); if (info.length > 0) {
let list = [];
info.map(item => {
list.push(item);
});
let chooseData = [];
let listData = [];
list.forEach((item, index) => {
chooseData.push(
!!list[index].checkedList.size && list[index].checkedList.size < list[index].list.length,
);
item.list.map(i => {
listData.push(i.related);
});
});
let data = new Set();
info.map(item => {
if (item.isChecked == true) {
data.add(item.groupName);
}
});
if (data.size == info.length) {
setChoo(true);
setIndeterminateAll(false);
} else {
setChoo(false);
if (listData.indexOf(true) != -1) {
setIndeterminateAll(true);
}
}
if (data.size == 0) {
setIndeterminateAll(false);
}
setIndeterminate(chooseData);
}
}, [infoAll]);
const submit = () => { const submit = () => {
const targetForm = nodeType === 1 ? form : otherForm; const targetForm = nodeType === 1 ? form : otherForm;
let obj = targetForm.getFieldsValue(); let obj = targetForm.getFieldsValue();
console.log(obj);
console.log(plainOptions);
let data = [];
if (nodeType == 1) {
plainOptions.map(item => {
item.checkedList.forEach(i => {
data.push(i);
});
});
if (data.length > 0) {
obj.relatedRoleList = data.toString();
} else {
obj.relatedRoleList = '';
}
}
submitCallback(obj); submitCallback(obj);
}; };
...@@ -71,6 +130,138 @@ const EditForm = props => { ...@@ -71,6 +130,138 @@ const EditForm = props => {
setShowParmarModal(true); setShowParmarModal(true);
}; };
const radioChange = e => {}; const radioChange = e => {};
// 一级复选框改变事件
const selectChange = (e, index, value) => {
let list = [];
plainOptions.map(item => {
list.push(item);
});
list[index].isChecked = e.target.checked;
if (e.target.checked) {
checkList.add(list[index].groupName);
list[index].list.map(i => {
i.related = true;
list[index].checkedList.add(i.relatedRoleCode);
});
} else {
checkList.delete(list[index].groupName);
list[index].list.map(i => {
i.related = false;
list[index].checkedList.delete(i.relatedRoleCode);
});
}
const indeterminateArr = [...indeterminate];
indeterminateArr[index] = false;
setIndeterminate(indeterminateArr);
let flag = [];
let data = [];
list.map(item => {
if (item.isChecked == false) {
flag.push(item);
}
});
list.map((k, i) => {
data.push(list[i].isChecked);
});
if (data.indexOf(true) == -1) {
setIndeterminateAll(false);
} else if (data.indexOf(false) == -1) {
setIndeterminateAll(false);
} else {
setIndeterminateAll(true);
}
if (flag.length > 0) {
setChoo(false);
} else {
setChoo(true);
}
setPlainOptions(list);
};
// 二级复选框改变事件
const handleChecked = (e, index, value, i) => {
let list = [];
plainOptions.map(item => {
list.push(item);
});
list[index].list[i].related = e.target.checked;
if (e.target.checked) {
list[index].checkedList.add(list[index].list[i].relatedRoleCode);
} else {
list[index].checkedList.delete(list[index].list[i].relatedRoleCode);
}
const indeterminateArr = [...indeterminate];
indeterminateArr[index] =
!!list[index].checkedList.size && list[index].checkedList.size < list[index].list.length;
setIndeterminate(indeterminateArr);
if (
list[index].checkedList.size == 0 ||
list[index].checkedList.size < list[index].list.length
) {
list[index].isChecked = false;
}
if (list[index].checkedList.size == list[index].list.length) {
list[index].isChecked = true;
}
let flag = [];
let data = [];
list.map(item => {
if (item.isChecked == false) {
flag.push(item);
}
});
list.map((k, i) => {
k.list.map(p => {
data.push(p.related);
});
// data.push(list[i].isChecked);
});
if (data.indexOf(true) == -1) {
setIndeterminateAll(false);
} else if (data.indexOf(false) == -1) {
setIndeterminateAll(false);
} else {
setIndeterminateAll(true);
}
if (flag.length > 0) {
setChoo(false);
} else {
setChoo(true);
}
setPlainOptions(list);
};
// 全选复选框改变事件
const checkAll = () => {
let list = [];
plainOptions.map(item => {
list.push(item);
});
if (choo == false) {
indeterminate.forEach((i, j) => {
if (i == true) {
indeterminate[j] = false;
}
});
setChoo(true);
list.map((item, index) => {
item.isChecked = true;
item.list.map(i => {
i.related = true;
list[index].checkedList.add(i.relatedRoleCode);
});
});
} else {
setChoo(false);
list.map((item, index) => {
item.isChecked = false;
item.list.map(i => {
i.related = false;
list[index].checkedList.delete(i.relatedRoleCode);
});
});
}
setIndeterminateAll(false);
setPlainOptions(list);
};
return ( return (
<div style={{ marginTop: '10px' }}> <div style={{ marginTop: '10px' }}>
{nodeType === 1 && ( {nodeType === 1 && (
...@@ -153,7 +344,95 @@ const EditForm = props => { ...@@ -153,7 +344,95 @@ const EditForm = props => {
</Select> </Select>
</EditeConfigWrapper> </EditeConfigWrapper>
</Item> </Item>
<CheckList info={info} nodeType={nodeType} valueCallback={valueCallback} /> <div className={styles.boe}>
{/* <div style={{ marginTop: '-16px', fontSize: '16px', marginLeft: '21px' }}>关联角色</div> */}
<div
style={{ width: '95%', marginLeft: '2%', marginTop: '10px', marginBottom: '20px' }}
>
<div style={{ marginTop: '-23px', backgroundColor: 'white', width: '92px' }}>
<Checkbox
onChange={checkAll}
checked={choo}
nodeType={nodeType}
indeterminate={indeterminateAll}
>
<span style={{ fontWeight: 'bold', fontSize: '15px' }}>关联角色</span>
</Checkbox>
</div>
{plainOptions && plainOptions.length > 0 ? (
plainOptions.map((item, index) => {
return (
<div
className={classnames({
[styles.divBox]: item.groupName.length > 0,
})}
>
<div style={{ marginTop: '-12px' }}>
{item.groupName.length == 0 ? (
<span style={{ marginLeft: '15px', marginTop: '0px' }} />
) : (
<Checkbox
onChange={e => {
selectChange(e, index, item);
}}
checked={item.isChecked}
indeterminate={indeterminate[index]}
>
<span style={{ fontWeight: 'bold', fontSize: '15px' }}>
{item.groupName}
</span>
</Checkbox>
)}
</div>
<div style={{ marginLeft: '0px', marginTop: '5px' }}>
{item.groupName.length == 0 ? (
<>
<Row>
{item.list.map((val, i) => {
return (
<Col span={4} style={{ marginBottom: '10px' }}>
<Checkbox
onChange={e => {
handleChecked(e, index, item, i);
}}
checked={val.related}
>
{val.relatedRoleName}
</Checkbox>
</Col>
);
})}
</Row>
</>
) : (
<>
<Row>
{item.list.map((val, i) => {
return (
<Col span={4}>
<Checkbox
onChange={e => {
handleChecked(e, index, item, i);
}}
checked={val.related}
>
{val.relatedRoleName}
</Checkbox>
</Col>
);
})}
</Row>
</>
)}
</div>
</div>
);
})
) : (
<span />
)}
</div>
</div>
<Item wrapperCol={{ offset: 10 }} style={{ marginTop: '20px' }}> <Item wrapperCol={{ offset: 10 }} style={{ marginTop: '20px' }}>
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit">
提交 提交
......
...@@ -35,6 +35,7 @@ const MiniMenu = props => { ...@@ -35,6 +35,7 @@ const MiniMenu = props => {
const [menuID, setMenuID] = useState(''); // 选中的树ID const [menuID, setMenuID] = useState(''); // 选中的树ID
const [nodeType, setNodeType] = useState(''); // 选中的节点类型 const [nodeType, setNodeType] = useState(''); // 选中的节点类型
const [info, setInfo] = useState({}); const [info, setInfo] = useState({});
const [infoAll, setInfoAll] = useState({});
const [importOrExportVisible, setImportOrExportVisible] = useState(false); // 导入导出弹窗 const [importOrExportVisible, setImportOrExportVisible] = useState(false); // 导入导出弹窗
const [addVisible, setAddVisible] = useState(false); // 新增弹窗 const [addVisible, setAddVisible] = useState(false); // 新增弹窗
const [addTwoVisible, setAddTwoVisible] = useState(false); // 编辑弹窗 const [addTwoVisible, setAddTwoVisible] = useState(false); // 编辑弹窗
...@@ -46,6 +47,8 @@ const MiniMenu = props => { ...@@ -46,6 +47,8 @@ const MiniMenu = props => {
const [modalLoading, setModalLoading] = useState(false); const [modalLoading, setModalLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false); const [submitLoading, setSubmitLoading] = useState(false);
const [newTreeList, setNewTreeList] = useState([]); const [newTreeList, setNewTreeList] = useState([]);
const [checkList, setCheckList] = useState([]);
const [flagg, setFlagg] = useState(0);
const [menuList, setMenuList] = useState([]); // 菜单树 const [menuList, setMenuList] = useState([]); // 菜单树
...@@ -141,7 +144,26 @@ const MiniMenu = props => { ...@@ -141,7 +144,26 @@ const MiniMenu = props => {
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
setInfo({ ...res.data }); let infoList = res.data.relatedRoleList.map(item => ({
groupName: item.groupName,
isChecked: item.isChecked,
list: item.list,
checkedList: new Set([]),
}));
setInfo(infoList);
setInfoAll({ ...res.data });
let data = new Set();
infoList.map(item => {
if (item.isChecked == true) {
data.add(item.groupName);
}
item.list.map(i => {
if (i.related) {
item.checkedList.add(i.relatedRoleCode);
}
});
});
setCheckList(data);
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -285,8 +307,9 @@ const MiniMenu = props => { ...@@ -285,8 +307,9 @@ const MiniMenu = props => {
setLoading(true); setLoading(true);
let baseUrl = handleGeturl(prop.imageUrl); let baseUrl = handleGeturl(prop.imageUrl);
let obj = { ...prop, baseUrl }; let obj = { ...prop, baseUrl };
console.log(obj);
if (nodeType === 1) { if (nodeType === 1) {
obj.relatedRoleList = String(roleList) || ''; // obj.relatedRoleList = roleList || '';
editWebMenu({ editWebMenu({
_dc: Date.now(), _dc: Date.now(),
menuID: Number(menuID), menuID: Number(menuID),
...@@ -295,7 +318,6 @@ const MiniMenu = props => { ...@@ -295,7 +318,6 @@ const MiniMenu = props => {
}) })
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
// setFlag(flag + 1); // setFlag(flag + 1);
getTree(); getTree();
...@@ -331,7 +353,6 @@ const MiniMenu = props => { ...@@ -331,7 +353,6 @@ const MiniMenu = props => {
}) })
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
// setFlag(flag + 1); // setFlag(flag + 1);
getTree(); getTree();
...@@ -357,14 +378,15 @@ const MiniMenu = props => { ...@@ -357,14 +378,15 @@ const MiniMenu = props => {
} }
}; };
const valueCallback = val => { const valueCallback = val => {
let arr = [...val]; console.log(val);
let arr2 = []; // let arr = [...val];
arr.map(item => { // let arr2 = [];
if (item.related) { // arr.map(item => {
arr2.push(item.relatedRoleCode); // if (item.related) {
} // arr2.push(item.relatedRoleCode);
}); // }
setRoleList(arr2); // });
setRoleList(val.toString());
}; };
// 返回拖拽完毕后的信息 // 返回拖拽完毕后的信息
const loop = (data, key, parentID, callback) => { const loop = (data, key, parentID, callback) => {
...@@ -612,6 +634,8 @@ const MiniMenu = props => { ...@@ -612,6 +634,8 @@ const MiniMenu = props => {
<EditForm <EditForm
nodeType={nodeType} nodeType={nodeType}
info={info} info={info}
infoAll={infoAll}
checkList={checkList}
configFiles={configFiles} configFiles={configFiles}
productList={productList} productList={productList}
submitCallback={editSubmitCallback} submitCallback={editSubmitCallback}
......
...@@ -65,6 +65,7 @@ const SiteManage = () => { ...@@ -65,6 +65,7 @@ const SiteManage = () => {
const [mulu, setMulu] = useState(true); // 展示目录 const [mulu, setMulu] = useState(true); // 展示目录
const [siteList, setSiteList] = useState([]); const [siteList, setSiteList] = useState([]);
const [disFlag, setDisFlag] = useState(false); const [disFlag, setDisFlag] = useState(false);
// const [childData, setChildData] = useState({visibleValue:''})
// 点击树的回调 // 点击树的回调
const handleTreeSelect = (e, treenode) => { const handleTreeSelect = (e, treenode) => {
...@@ -114,10 +115,34 @@ const SiteManage = () => { ...@@ -114,10 +115,34 @@ 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 (k.visibleTitle != '默认分组') {
// console.log(11);
// let childData = { visibleTitle: '默认分组', roleList: [] };
// childData.visibleValue = i.visibleValue;
// i.child.push(childData);
// }
});
if (arr.indexOf('默认分组') == -1) {
let childData = { visibleTitle: '默认分组', roleList: [] };
childData.visibleValue = i.visibleValue;
i.child.push(childData);
}
}
});
console.log(res.data.roleList);
const { roleList } = res.data; const { roleList } = res.data;
let arr = transTree(roleList); let arr = transTree(roleList);
console.log(roleList);
console.log(arr);
setTreeData(arr); setTreeData(arr);
} }
}); });
...@@ -198,6 +223,7 @@ const SiteManage = () => { ...@@ -198,6 +223,7 @@ const SiteManage = () => {
// 树形数据转换; // 树形数据转换;
const transTree = val => { const transTree = val => {
let arr = val; let arr = val;
console.log(arr);
let newArr = []; let newArr = [];
// 提取child里面的数组 // 提取child里面的数组
let arr2 = arr.filter(item => { let arr2 = arr.filter(item => {
...@@ -273,7 +299,7 @@ const SiteManage = () => { ...@@ -273,7 +299,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' }}
...@@ -338,7 +364,7 @@ const SiteManage = () => { ...@@ -338,7 +364,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' }}
...@@ -387,7 +413,7 @@ const SiteManage = () => { ...@@ -387,7 +413,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' }}
......
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