Commit 3d10d01c authored by 邓超's avatar 邓超

fix: 修复web配置及app配置拖拽问题,及对发送消息测试模块进行优化

parent 63ef1bee
Pipeline #39720 passed with stages
in 27 minutes 1 second
...@@ -60,7 +60,7 @@ const MiniMenu = props => { ...@@ -60,7 +60,7 @@ const MiniMenu = props => {
useEffect(() => { useEffect(() => {
console.log(props); console.log(props);
updateTrees(); updateTrees();
}, [flag]); }, []);
// 获取角色列表 // 获取角色列表
useEffect(() => { useEffect(() => {
getRoleListPlain({ getRoleListPlain({
...@@ -80,24 +80,22 @@ const MiniMenu = props => { ...@@ -80,24 +80,22 @@ const MiniMenu = props => {
// 更新树 // 更新树
const updateTrees = () => { const updateTrees = () => {
setLoading(true);
getMiniAppModuleTree({ getMiniAppModuleTree({
userMode: userMode || 'super', userMode: userMode || 'super',
}) })
.then(res => { .then(res => {
console.log(res, 'res'); // console.log(res, 'res');
// const result1 = res[0].children[0].children[2].children; // const result1 = res[0].children[0].children[2].children;
// setNewTreeList(JSON.parse(JSON.stringify(result1))); // setNewTreeList(JSON.parse(JSON.stringify(result1)));
// setTreeData(result1); // setTreeData(result1);
// setLoading(false); // setLoading(false);
if (res.code === 0) { if (res.code === 0) {
const { data } = res; const { data } = res;
setLoading(false);
let obj = data[0].children.find(item => item.id === parentKey); let obj = data[0].children.find(item => item.id === parentKey);
const result = obj.children[1].children; const result = obj.children[1].children;
setNewTreeList(JSON.parse(JSON.stringify(result))); console.log(result, 'result');
setTreeData(result); setTreeData(result);
console.log(result); setLoading(false);
// 第一次加载,默认选择第一个组织 // 第一次加载,默认选择第一个组织
// if (treeFlag) { // if (treeFlag) {
// handleSelect([result[0].menuID], false); // handleSelect([result[0].menuID], false);
...@@ -118,7 +116,7 @@ const MiniMenu = props => { ...@@ -118,7 +116,7 @@ const MiniMenu = props => {
}; };
// 处理数据 // 处理数据
const mapTree = val => { const mapTree = val => {
const obj = { ...val }; const obj = JSON.parse(JSON.stringify(val));
const hasChild = obj.children.length > 0; const hasChild = obj.children.length > 0;
return { return {
title: ( title: (
...@@ -150,6 +148,7 @@ const MiniMenu = props => { ...@@ -150,6 +148,7 @@ const MiniMenu = props => {
) : ( ) : (
<FileOutlined /> <FileOutlined />
), ),
menuType: obj.menuType, menuType: obj.menuType,
children: hasChild ? obj.children.map(i => mapTree(i)) : [], children: hasChild ? obj.children.map(i => mapTree(i)) : [],
}; };
...@@ -237,6 +236,7 @@ const MiniMenu = props => { ...@@ -237,6 +236,7 @@ const MiniMenu = props => {
if (res.code === 0) { if (res.code === 0) {
setDelVisible(false); setDelVisible(false);
setFlag(flag + 1); setFlag(flag + 1);
updateTrees();
setNodeType(''); setNodeType('');
setNodeObj(''); setNodeObj('');
notification.success({ notification.success({
...@@ -307,6 +307,7 @@ const MiniMenu = props => { ...@@ -307,6 +307,7 @@ const MiniMenu = props => {
setAddVisible(false); setAddVisible(false);
setAddTwoVisible(false); setAddTwoVisible(false);
setFlag(flag + 1); setFlag(flag + 1);
updateTrees();
notification.success({ notification.success({
message: '提示', message: '提示',
description: '新增成功', description: '新增成功',
...@@ -345,6 +346,7 @@ const MiniMenu = props => { ...@@ -345,6 +346,7 @@ const MiniMenu = props => {
if (res.code === 0) { if (res.code === 0) {
setFlag(flag + 1); setFlag(flag + 1);
updateTrees();
notification.success({ notification.success({
message: '提示', message: '提示',
duration: 3, duration: 3,
...@@ -377,6 +379,9 @@ const MiniMenu = props => { ...@@ -377,6 +379,9 @@ const MiniMenu = props => {
}); });
setRoleList(arr2); setRoleList(arr2);
}; };
// 遍历数组,找出key值与之相同的对象(节点),执行callback函数
// 若key值不匹配且含有children,则循环遍历
// 否则不执行任何操作
const loop = (data, key, parentID, callback) => { const loop = (data, key, parentID, callback) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
if (data[i].menuID === key) { if (data[i].menuID === key) {
...@@ -394,54 +399,92 @@ const MiniMenu = props => { ...@@ -394,54 +399,92 @@ const MiniMenu = props => {
const dropPos = infos.node.pos.split('-'); const dropPos = infos.node.pos.split('-');
const dropPosition = const dropPosition =
infos.dropPosition - Number(dropPos[dropPos.length - 1]); infos.dropPosition - Number(dropPos[dropPos.length - 1]);
const data = [...treeData]; const data = JSON.parse(JSON.stringify(treeData));
// 找到拖拽的元素 // 找到拖拽的元素
let dragObj; let dragObj;
let dropObj; let dropObj;
let id; let id;
let dragList; let dragList;
// 保存拖拽到的节点信息
loop(data, dropKey, -1, item => { loop(data, dropKey, -1, item => {
dropObj = item; dropObj = item;
}); });
// 保存节点信息并删除节点
loop(data, dragKey, -1, (item, index, arr) => { loop(data, dragKey, -1, (item, index, arr) => {
if (infos.dropToGap) { arr.splice(index, 1);
arr.splice(index, 1); dragObj = item;
dragObj = item;
} else if (
dropObj.menuType !== 'MiniAppMenuThree' &&
dropObj.menuType !== 'MiniAppMenu'
) {
arr.splice(index, 1);
dragObj = item;
}
}); });
if (!infos.dropToGap) { console.log(dragObj.menuType, 'dragObj');
// Drop on the content console.log(dropObj.menuType, 'dropObj');
loop(data, dropKey, -1, item => { // console.log(dropPos, 'dropPosition');
item.children = item.children || []; // 拖拽到的位置不能在菜单下面
if ( if (
item.menuType !== 'MiniAppMenuThree' && (dropObj.menuType === 'MiniAppMenuThree' ||
dropObj.menuType !== 'MiniAppMenu' dropObj.menuType === 'MiniAppMenu') &&
) { !infos.dropToGap
// where to insert 示例添加到头部,可以是随意位置
item.children.unshift(dragObj);
id = item.menuID;
dragList = item.children.map(val => val.menuID);
}
});
} else if (
(infos.node.props.children || []).length > 0 && // Has children
infos.node.props.expanded && // Is expanded
dropPosition === 1 // On the bottom gap
) { ) {
loop(data, dropKey, -1, item => { return;
item.children = item.children || []; }
// where to insert 示例添加到头部,可以是随意位置
item.children.unshift(dragObj); // 将节点插入到正确位置
id = item.menuID; if (!infos.dropToGap) {
dragList = item.children.map(val => val.menuID); console.log('111111');
}); // 菜单不能拖拽到跟一级菜单组下
if (
dropObj.menuType === 'MiniAppMenuGroup' &&
(dragObj.menuType === 'MiniAppMenuThree' ||
dragObj.menuType === 'MiniAppMenu')
) {
return;
}
// 一级菜单组只能在一级菜单组平级拖拽
if (
dragObj.menuType === 'MiniAppMenuGroup' &&
(dropObj.menuType === 'MiniAppMenuGroup' ||
dropObj.menuType === 'MiniAppMenuGroupTwo')
) {
return;
}
// 二级菜单组只能在一级的菜单组下面
if (
dragObj.menuType === 'MiniAppMenuGroupTwo' &&
(dropObj.menuType === 'MiniAppMenuGroupTwo' ||
dropObj.menuType === 'MiniAppMenu')
) {
return;
}
dropObj.children = dropObj.children || [];
// 在哪里插入,示例添加到头部,可以是随意位置
dropObj.children.unshift(dragObj);
id = dropObj.menuID;
dragList = dropObj.children.map(val => val.menuID);
} else { } else {
// 菜单不能拖拽到跟一级菜单组下
if (
dropObj.menuType === 'MiniAppMenuGroupTwo' &&
(dragObj.menuType === 'MiniAppMenuThree' ||
dragObj.menuType === 'MiniAppMenu')
) {
return;
}
// 一级菜单组只能在一级菜单组平级拖拽
if (
dragObj.menuType === 'MiniAppMenuGroup' &&
(dropObj.menuType === 'MiniAppMenuGroupTwo' ||
dropObj.menuType === 'MiniAppMenuThree')
) {
return;
}
// 二级菜单组只能在一级的菜单组下面
if (
dragObj.menuType === 'MiniAppMenuGroupTwo' &&
(dropObj.menuType === 'MiniAppMenuGroup' ||
dropObj.menuType === 'MiniAppMenuThree' ||
dropObj.menuType === 'MiniAppMenu')
) {
return;
}
let ar; let ar;
let i; let i;
loop(data, dropKey, -1, (item, index, arr, parentID) => { loop(data, dropKey, -1, (item, index, arr, parentID) => {
...@@ -456,11 +499,11 @@ const MiniMenu = props => { ...@@ -456,11 +499,11 @@ const MiniMenu = props => {
} }
dragList = ar.map(val => val.menuID); dragList = ar.map(val => val.menuID);
} }
console.log(dragList, 'dragList');
// 如果拖拽到菜单下不做任何处理 // 如果拖拽到菜单下不做任何处理
if (!dragList) { if (!dragList) {
return; return;
} }
dragMenu({ dragMenu({
menuID: dragKey, menuID: dragKey,
newParentID: id.toString() || '-1', newParentID: id.toString() || '-1',
...@@ -468,9 +511,8 @@ const MiniMenu = props => { ...@@ -468,9 +511,8 @@ const MiniMenu = props => {
_version: 9999, _version: 9999,
_dc: Date.now(), _dc: Date.now(),
}).then(res => { }).then(res => {
console.log(res);
if (res.code === 0) { if (res.code === 0) {
setFlag(flag + 1); updateTrees();
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
......
...@@ -5,7 +5,16 @@ import styles from './ListCardItem.less'; ...@@ -5,7 +5,16 @@ import styles from './ListCardItem.less';
const CheckGroup = Checkbox.Group; const CheckGroup = Checkbox.Group;
const ListCardItem = props => { const ListCardItem = props => {
const { getValueCallback, itemid, userList, OUName, searchWord, multiRoleList, multistationList, mult } = props; const {
getValueCallback,
itemid,
userList,
OUName,
searchWord,
multiRoleList,
multistationList,
mult,
} = props;
const [indeterminate, setIndeterminate] = useState(false); const [indeterminate, setIndeterminate] = useState(false);
const [allChecked, setAllChecked] = useState(false); // 全选状态 const [allChecked, setAllChecked] = useState(false); // 全选状态
const [checkList, setCheckList] = useState([]); // 复选框列表选中的值 const [checkList, setCheckList] = useState([]); // 复选框列表选中的值
...@@ -36,56 +45,56 @@ const ListCardItem = props => { ...@@ -36,56 +45,56 @@ const ListCardItem = props => {
useEffect(() => { useEffect(() => {
if (mult == 'Yes') { if (mult == 'Yes') {
console.log(multiRoleList) console.log(multiRoleList);
console.log(multistationList) console.log(multistationList);
let arr2=[] let arr2 = [];
if(multiRoleList !=undefined){ if (multiRoleList != undefined) {
multiRoleList.map((item, index)=>{ multiRoleList.map((item, index) => {
arr2.push(item) arr2.push(item);
}) });
}
if (multistationList != undefined) {
multistationList.map((item1, index) => {
arr2.push(item1);
});
} }
if(multistationList !=undefined){ console.log(arr2);
multistationList.map((item1, index)=>{ console.log(userList);
arr2.push(item1) console.log(itemid);
})
}
console.log(arr2)
console.log(userList)
console.log(itemid)
//勾选展示 // 勾选展示
let flag=0 let flag = 0;
let aa = [] let aa = [];
userList.map((item,index)=>{ userList.map((item, index) => {
if(item.roleID!=undefined){ if (item.roleID != undefined) {
if(arr2.indexOf(item.roleID)!= -1){ if (arr2.indexOf(item.roleID) != -1) {
flag=flag+1 flag += 1;
aa.push(item.roleID) aa.push(item.roleID);
} }
}
if(item.stationID!=undefined){
if(arr2.indexOf(item.stationID)!= -1){
flag=flag+1
aa.push(item.stationID)
} }
if (item.stationID != undefined) {
if (arr2.indexOf(item.stationID) != -1) {
flag += 1;
aa.push(item.stationID);
}
} }
}) });
console.log(aa) console.log(aa);
console.log(userList.length) console.log(userList.length);
console.log(flag) console.log(flag);
if(flag==userList.length){ if (flag == userList.length) {
setIndeterminate(false) setIndeterminate(false);
setAllChecked(true) setAllChecked(true);
} }
if((flag<userList.length)&&(flag>0)){ if (flag < userList.length && flag > 0) {
setIndeterminate(true) setIndeterminate(true);
setAllChecked(false) setAllChecked(false);
} }
if(flag==0){ if (flag == 0) {
setIndeterminate(false) setIndeterminate(false);
setAllChecked(false) setAllChecked(false);
} }
// eslint-disable-next-line no-unused-expressions
getValueCallback && getValueCallback(aa, itemid); getValueCallback && getValueCallback(aa, itemid);
setCheckList(arr2); setCheckList(arr2);
} else { } else {
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
margin-bottom: 5px;
.nodeTip { .nodeTip {
display: none; display: none;
.fs { .fs {
......
...@@ -319,7 +319,7 @@ const ProjectManage = () => { ...@@ -319,7 +319,7 @@ const ProjectManage = () => {
}; };
const pagenation = { const pagenation = {
showTotal: (total, range) => `${range[0]}-${range[1]} 条/${total} 条`, showTotal: (total, range) => `共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100], pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 10, defaultPageSize: 10,
showQuickJumper: true, showQuickJumper: true,
......
...@@ -12,7 +12,7 @@ const CardCheck = props => { ...@@ -12,7 +12,7 @@ const CardCheck = props => {
}); });
return ref.current; return ref.current;
}; };
const { cardMsg, cardIndex, callback, checkList } = props; const { cardMsg, callback, checkList } = props;
const [checkedList, setCheckedList] = useState([]); const [checkedList, setCheckedList] = useState([]);
const [indeterminate, setIndeterminate] = useState(false); const [indeterminate, setIndeterminate] = useState(false);
const [checkAll, setCheckAll] = useState(false); const [checkAll, setCheckAll] = useState(false);
......
...@@ -16,7 +16,8 @@ const PushTest = props => { ...@@ -16,7 +16,8 @@ const PushTest = props => {
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
let username = form.getFieldValue('username'); let username = form.getFieldValue('username');
getData(username, currentPage, pageSize); setCurrentPage(1);
getData(username, 1, pageSize);
} else { } else {
setCheckList([]); setCheckList([]);
setAllist([]); setAllist([]);
...@@ -57,9 +58,9 @@ const PushTest = props => { ...@@ -57,9 +58,9 @@ const PushTest = props => {
}); });
}; };
const onSearch = () => { const onSearch = () => {
setCheckList([]);
let username = form.getFieldValue('username'); let username = form.getFieldValue('username');
getData(username, currentPage, pageSize); setCurrentPage(1);
getData(username, 1, pageSize);
}; };
const getData = (username, page, pageSizes) => { const getData = (username, page, pageSizes) => {
setLoading(true); setLoading(true);
...@@ -69,7 +70,6 @@ const PushTest = props => { ...@@ -69,7 +70,6 @@ const PushTest = props => {
PageIndex: page, PageIndex: page,
}).then(res => { }).then(res => {
setTotal(res.data.count); setTotal(res.data.count);
let list = res.data.data.map(item => { let list = res.data.data.map(item => {
let indeterminate = false; let indeterminate = false;
let checkedList = []; let checkedList = [];
...@@ -104,7 +104,6 @@ const PushTest = props => { ...@@ -104,7 +104,6 @@ const PushTest = props => {
plainOptions: options, plainOptions: options,
}; };
}); });
// checkList = list;
setAllist(list); setAllist(list);
setLoading(false); setLoading(false);
}); });
...@@ -140,8 +139,8 @@ const PushTest = props => { ...@@ -140,8 +139,8 @@ const PushTest = props => {
type="primary" type="primary"
htmlType="submit" htmlType="submit"
onClick={() => { onClick={() => {
setCheckList([]); setCurrentPage(1);
getData('', currentPage, pageSize); getData('', 1, pageSize);
form.setFieldsValue({ username: '' }); form.setFieldsValue({ username: '' });
}} }}
> >
...@@ -175,6 +174,8 @@ const PushTest = props => { ...@@ -175,6 +174,8 @@ const PushTest = props => {
current={currentPage} current={currentPage}
onChange={paginationChange} onChange={paginationChange}
style={{ marginBottom: '10px' }} style={{ marginBottom: '10px' }}
size="small"
showQuickJumper
/> />
</Modal> </Modal>
</> </>
......
...@@ -30,7 +30,5 @@ ...@@ -30,7 +30,5 @@
.checkdiv { .checkdiv {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
// margin-left: 20px;
// justify-content: space-between;
} }
} }
import React, { useState, useCallback, useEffect } from 'react'; import React, { useState, useCallback, useEffect } from 'react';
import { Modal, Spin, Tabs, notification, message, Checkbox, Divider } from 'antd'; import {
Modal,
Spin,
Tabs,
notification,
message,
Checkbox,
Divider,
} from 'antd';
import { import {
SetUserRelationList, SetUserRelationList,
setUserRelation, setUserRelation,
setUserRelations setUserRelations,
} from '@/services/userCenter/userManage/api'; } from '@/services/userCenter/userManage/api';
import ListCardItem from '../../orgnazation/listCardItem'; import ListCardItem from '../../orgnazation/listCardItem';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
...@@ -22,35 +30,36 @@ const RelateRoleModal = props => { ...@@ -22,35 +30,36 @@ const RelateRoleModal = props => {
loading, loading,
multiRoleList, multiRoleList,
multistationList, multistationList,
mult mult,
} = props; } = props;
const { TabPane } = Tabs; const { TabPane } = Tabs;
const [roleValueList, setRoleValueList] = useState({}); // 勾选的角色列表 const [roleValueList, setRoleValueList] = useState({}); // 勾选的角色列表
const [stationValueList, setStationValueList] = useState({}); // 勾选的站点列表 const [stationValueList, setStationValueList] = useState({}); // 勾选的站点列表
const authority = localStorage.getItem('panda-oms-authority');
const getRoleValueCallback = useCallback((value, index) => { const getRoleValueCallback = useCallback((value, index) => {
console.log(value) console.log(value);
roleValueList[index] = value; roleValueList[index] = value;
console.log(roleValueList) console.log(roleValueList);
setRoleValueList({ ...roleValueList }); setRoleValueList({ ...roleValueList });
console.log({ ...roleValueList }) console.log({ ...roleValueList });
}, []); }, []);
const getStationValueCallback = useCallback((value, index) => { const getStationValueCallback = useCallback((value, index) => {
console.log(value) console.log(value);
stationValueList[index] = value; stationValueList[index] = value;
console.log(stationValueList) console.log(stationValueList);
setStationValueList({ ...stationValueList }); setStationValueList({ ...stationValueList });
}, []); }, []);
useEffect(() => { useEffect(() => {
console.log(multiRoleList) console.log(multiRoleList);
console.log(multistationList) console.log(multistationList);
}, [visible]) }, [visible]);
// 提交-关联角色 // 提交-关联角色
const submitRole = () => { const submitRole = () => {
console.log(1212121212) console.log(1212121212);
SetUserRelationList( SetUserRelationList(
currentUser.userID, currentUser.userID,
Object.keys(roleValueList) Object.keys(roleValueList)
...@@ -61,7 +70,7 @@ const RelateRoleModal = props => { ...@@ -61,7 +70,7 @@ const RelateRoleModal = props => {
.flat(), .flat(),
) )
.then(res => { .then(res => {
if (res.code==0) { if (res.code == 0) {
onCancel(); onCancel();
// 跳转到新组织机构下的用户表 // 跳转到新组织机构下的用户表
if (currentSelectOrg !== '-1') { if (currentSelectOrg !== '-1') {
...@@ -84,7 +93,7 @@ const RelateRoleModal = props => { ...@@ -84,7 +93,7 @@ const RelateRoleModal = props => {
}; };
// 提交-批量关联角色 // 提交-批量关联角色
const submitRoles = () => { const submitRoles = () => {
console.log(64634676437) console.log(64634676437);
setUserRelations( setUserRelations(
userIDs, userIDs,
Object.keys(roleValueList) Object.keys(roleValueList)
...@@ -108,20 +117,18 @@ const RelateRoleModal = props => { ...@@ -108,20 +117,18 @@ const RelateRoleModal = props => {
duration: 2, duration: 2,
}); });
} else { } else {
console.log(1), console.log(1);
notification.error({ notification.error({
message: '提交失败', message: '提交失败',
description: res.msg, description: res.msg,
}); });
} }
}) })
.catch(err => { .catch(err => {
message.error(err); message.error(err);
}); });
}; };
const onChangeList =()=>{ const onChangeList = () => {};
}
const title = ( const title = (
<span> <span>
<span style={{ marginRight: '20px' }}>批量关联角色</span> <span style={{ marginRight: '20px' }}>批量关联角色</span>
...@@ -133,57 +140,12 @@ const RelateRoleModal = props => { ...@@ -133,57 +140,12 @@ const RelateRoleModal = props => {
<span>关联角色{currentUser.loginName}</span> <span>关联角色{currentUser.loginName}</span>
</span> </span>
); );
if (mult == 'Yes') { if (mult == 'Yes') {
return (
<Modal
title={title}
visible={visible}
onOk={submitRoles}
onCancel={onCancel}
okText="确认"
cancelText="取消"
width="500px"
>
<Spin spinning={loading} tip="loading">
<Tabs defaultActiveKey="1" style={{ marginTop: '-16px' }}>
<TabPane tab="角色" key="1">
{visible &&
rolelist.map((role, index) => (
<ListCardItem
itemid={index}
key={`item${index}key`}
userList={role.roleList}
multiRoleList={multiRoleList}
mult={mult}
OUName={role.visibleTitle}
getValueCallback={getRoleValueCallback}
/>
))}
</TabPane>
<TabPane tab="站点" key="2">
{visible &&
stationlist.map((station, index) => (
<ListCardItem
itemid={index}
key={`item${index}key`}
userList={station.stationList}
multistationList={multistationList}
mult={mult}
OUName={station.visibleTitle}
getValueCallback={getStationValueCallback}
/>
))}
</TabPane>
</Tabs>
</Spin>
</Modal>
);
}else{
return ( return (
<Modal <Modal
title={multiRelateRoles ? title : title1} title={title}
visible={visible} visible={visible}
onOk={multiRelateRoles ? submitRoles : submitRole} onOk={submitRoles}
onCancel={onCancel} onCancel={onCancel}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
...@@ -195,9 +157,11 @@ const RelateRoleModal = props => { ...@@ -195,9 +157,11 @@ const RelateRoleModal = props => {
{visible && {visible &&
rolelist.map((role, index) => ( rolelist.map((role, index) => (
<ListCardItem <ListCardItem
style={{ display: 'none' }}
itemid={index} itemid={index}
key={`item${index}key`} key={`item${index}key`}
userList={role.roleList} userList={role.roleList}
multiRoleList={multiRoleList}
mult={mult} mult={mult}
OUName={role.visibleTitle} OUName={role.visibleTitle}
getValueCallback={getRoleValueCallback} getValueCallback={getRoleValueCallback}
...@@ -211,6 +175,7 @@ const RelateRoleModal = props => { ...@@ -211,6 +175,7 @@ const RelateRoleModal = props => {
itemid={index} itemid={index}
key={`item${index}key`} key={`item${index}key`}
userList={station.stationList} userList={station.stationList}
multistationList={multistationList}
mult={mult} mult={mult}
OUName={station.visibleTitle} OUName={station.visibleTitle}
getValueCallback={getStationValueCallback} getValueCallback={getStationValueCallback}
...@@ -221,7 +186,49 @@ const RelateRoleModal = props => { ...@@ -221,7 +186,49 @@ const RelateRoleModal = props => {
</Spin> </Spin>
</Modal> </Modal>
); );
} }
return (
<Modal
title={multiRelateRoles ? title : title1}
visible={visible}
onOk={multiRelateRoles ? submitRoles : submitRole}
onCancel={onCancel}
okText="确认"
cancelText="取消"
width="500px"
>
<Spin spinning={loading} tip="loading">
<Tabs defaultActiveKey="1" style={{ marginTop: '-16px' }}>
<TabPane tab="角色" key="1">
{visible &&
rolelist.map((role, index) => (
<ListCardItem
itemid={index}
key={`item${index}key`}
userList={role.roleList}
mult={mult}
OUName={role.visibleTitle}
getValueCallback={getRoleValueCallback}
/>
))}
</TabPane>
<TabPane tab="站点" key="2">
{visible &&
stationlist.map((station, index) => (
<ListCardItem
itemid={index}
key={`item${index}key`}
userList={station.stationList}
mult={mult}
OUName={station.visibleTitle}
getValueCallback={getStationValueCallback}
/>
))}
</TabPane>
</Tabs>
</Spin>
</Modal>
);
}; };
export default RelateRoleModal; export default RelateRoleModal;
...@@ -74,34 +74,14 @@ const MiniMenu = props => { ...@@ -74,34 +74,14 @@ const MiniMenu = props => {
// setProductList(data); // setProductList(data);
} }
}); });
getTree();
}, []); }, []);
useEffect(() => { useEffect(() => {
setLoading(true); getTree();
getWebModuleTree(userMode || 'super')
.then(res => {
setLoading(false);
const { code, data } = res;
if (code === 0) {
let arr = data
.filter(item => item.id === 'Web4SingleStation')
.map(r => r.children.filter(i => i.id === webid))
.flat(2);
let arr2 =
arr[0].children.find(item => item.text === '菜单管理').children ||
[];
setMenuList(arr2 || []);
}
})
.catch(err => {
setLoading(false);
});
return () => { return () => {
setLoading(false); setLoading(false);
}; };
}, [flag, webid]); }, [webid]);
useEffect(() => {
setNewTreeList(menuList || []);
}, [menuList]);
// 处理数据 // 处理数据
const mapTree = val => { const mapTree = val => {
...@@ -202,7 +182,8 @@ const MiniMenu = props => { ...@@ -202,7 +182,8 @@ const MiniMenu = props => {
setModalLoading(false); setModalLoading(false);
if (res.code === 0) { if (res.code === 0) {
setDelVisible(false); setDelVisible(false);
setFlag(flag + 1); // setFlag(flag + 1);
getTree();
setNodeType(''); setNodeType('');
setNodeObj(''); setNodeObj('');
// updateMenuTree('delete', nodeObj); // updateMenuTree('delete', nodeObj);
...@@ -282,7 +263,8 @@ const MiniMenu = props => { ...@@ -282,7 +263,8 @@ const MiniMenu = props => {
if (res.code === 0) { if (res.code === 0) {
setAddVisible(false); setAddVisible(false);
setAddTwoVisible(false); setAddTwoVisible(false);
setFlag(flag + 1); // setFlag(flag + 1);
getTree();
// updateMenuTree('add', item); // updateMenuTree('add', item);
notification.success({ notification.success({
message: '提示', message: '提示',
...@@ -319,7 +301,8 @@ const MiniMenu = props => { ...@@ -319,7 +301,8 @@ const MiniMenu = props => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
setFlag(flag + 1); // setFlag(flag + 1);
getTree();
// updateMenuTree('edit'); // updateMenuTree('edit');
notification.success({ notification.success({
message: '提示', message: '提示',
...@@ -354,7 +337,8 @@ const MiniMenu = props => { ...@@ -354,7 +337,8 @@ const MiniMenu = props => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
setFlag(flag + 1); // setFlag(flag + 1);
getTree();
// updateMenuTree('edit'); // updateMenuTree('edit');
notification.success({ notification.success({
message: '提示', message: '提示',
...@@ -397,14 +381,34 @@ const MiniMenu = props => { ...@@ -397,14 +381,34 @@ const MiniMenu = props => {
} }
} }
}; };
const getTree = () => {
getWebModuleTree(userMode || 'super')
.then(res => {
setLoading(false);
const { code, data } = res;
if (code === 0) {
let arr = data
.filter(item => item.id === 'Web4SingleStation')
.map(r => r.children.filter(i => i.id === webid))
.flat(2);
let arr2 =
arr[0].children.find(item => item.text === '菜单管理').children ||
[];
setMenuList(arr2 || []);
}
})
.catch(err => {
setLoading(false);
});
};
// 树的拖动 // 树的拖动
const handleDrop = infos => { const handleDrop = infos => {
console.log(infos);
const dropKey = infos.node.key; const dropKey = infos.node.key;
const dragKey = infos.dragNode.key; const dragKey = infos.dragNode.key;
const dropPos = infos.node.pos.split('-'); const dropPos = infos.node.pos.split('-');
const dropPosition = const dropPosition =
infos.dropPosition - Number(dropPos[dropPos.length - 1]); infos.dropPosition - Number(dropPos[dropPos.length - 1]);
const data = [...menuList]; const data = [...menuList];
// 找到拖拽的元素 // 找到拖拽的元素
let dragObj; let dragObj;
...@@ -415,10 +419,7 @@ const MiniMenu = props => { ...@@ -415,10 +419,7 @@ const MiniMenu = props => {
dropObj = item; dropObj = item;
}); });
loop(data, dragKey, -1, (item, index, arr) => { loop(data, dragKey, -1, (item, index, arr) => {
if (infos.dropToGap) { if (infos.dropToGap || dropObj.menuType !== 'Web4Menu') {
arr.splice(index, 1);
dragObj = item;
} else if (dropObj.menuType !== 'Web4Menu') {
arr.splice(index, 1); arr.splice(index, 1);
dragObj = item; dragObj = item;
} }
...@@ -465,6 +466,7 @@ const MiniMenu = props => { ...@@ -465,6 +466,7 @@ const MiniMenu = props => {
if (!dragList) { if (!dragList) {
return; return;
} }
console.log(dragList, 'dragList');
dragMenu({ dragMenu({
menuID: dragKey, menuID: dragKey,
newParentID: id || -1, newParentID: id || -1,
...@@ -474,7 +476,9 @@ const MiniMenu = props => { ...@@ -474,7 +476,9 @@ const MiniMenu = props => {
}).then(res => { }).then(res => {
if (res.code === 0) { if (res.code === 0) {
// updateMenuTree(); // updateMenuTree();
setFlag(flag + 1); console.log(11111111);
getTree();
// setFlag(flag + 1);
} else { } else {
notification.error({ notification.error({
message: '提示', message: '提示',
......
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