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