Commit 03d16e7a authored by 张烨's avatar 张烨
parents 6b83c760 bacac5ec
......@@ -8,10 +8,12 @@ const ListCardItem = props => {
const {
getValueCallback,
itemid,
userList,
// userList,
Child,
OUName,
searchWord,
Child,
children,
text,
} = props;
const [indeterminate, setIndeterminate] = useState(false);
const [childValues, setChildValues] = useState({});
......@@ -23,20 +25,18 @@ const ListCardItem = props => {
useEffect(() => {
let arr = [];
userList.map((item, index) => {
children.map((item, index) => {
let obj = { ...item };
obj.label = (
<span
className={
searchWord && obj.userName.includes(searchWord)
? styles.isSearch
: ''
searchWord && obj.text.includes(searchWord) ? styles.isSearch : ''
}
>
{obj.userName || obj.roleName || obj.stationName}
{obj.text}
</span>
);
obj.value = obj.userID || obj.roleID || obj.stationID;
obj.value = obj.userID || obj.roleID || obj.stationID || obj.id;
arr.push(obj);
});
setDefaultList(arr);
......@@ -44,19 +44,19 @@ const ListCardItem = props => {
useEffect(() => {
let arr2 = [];
userList.map((item, index) => {
children.map((item, index) => {
if (item.isChecked) {
arr2.push(item.userID || item.roleID || item.stationID);
arr2.push(item.userID || item.roleID || item.stationID || item.id);
}
});
// eslint-disable-next-line no-unused-expressions
getValueCallback && getValueCallback(arr2, itemid);
const all = userList.every(u => u.isChecked);
setIndeterminate(!all && userList.some(u => u.isChecked));
const all = children.every(u => u.isChecked);
setIndeterminate(!all && children.some(u => u.isChecked));
setAllChecked(all);
setCheckList(arr2);
}, [userList]);
}, [children]);
const handleAllChecked = e => {
const { checked } = e.target;
......@@ -82,9 +82,6 @@ const ListCardItem = props => {
getValueCallback(e, itemid);
}
};
if (defaultList.length === 0) {
return null;
}
const handleChildValueCallback = (arr, childIndex) => {
childValues[childIndex] = arr;
......@@ -105,6 +102,9 @@ const ListCardItem = props => {
/>
));
if (defaultList.length === 0) {
return null;
}
return (
<>
<div className={`${styles.divBox}`}>
......@@ -116,7 +116,7 @@ const ListCardItem = props => {
handleAllChecked(e);
}}
>
{OUName}
{text}
</Checkbox>
</div>
<div style={{ width: '100%' }} className={styles.checkdiv}>
......
......@@ -24,10 +24,15 @@ const ListCard = props => {
title: '默认组',
id: '',
};
// /Cityinterface/rest/services/OMS.svc/P_GetUserByStation
//
// /Cityinterface/rest/services/OMS.svc/U_GetUserListForBatchOper
get('/Cityinterface/rest/services/OMS.svc/P_GetUserByStation', {
get('/Cityinterface/rest/services/OMS.svc/W4_GetMenuByRoleWithLevel', {
// OUID:ouid||'',
stationID: ouid || '',
// stationID: ouid || '',
roleID: ouid,
subSystemValue: 'city',
subSystemName: 'city',
_version: 9999,
_dc: new Date().getTime(),
})
......@@ -35,8 +40,8 @@ const ListCard = props => {
setLoading(false);
const list = [];
// eslint-disable-next-line no-unused-expressions
res &&
res.forEach(item => {
res.success &&
res.root.forEach(item => {
list.push({ ...defaultConfig, ...item });
});
setdataList(list);
......
......@@ -22,6 +22,7 @@ import {
getTree,
addMenuApi,
addMenuGroupApi,
submitMenuInfo,
getRoleList,
getMenuInfo,
deleteMenuApi,
......@@ -34,6 +35,8 @@ const SevenParams = () => {
const [treeLoading, setTreeLoading] = useState(true);
const [treeData, setTreeData] = useState([]); // 菜单树
const [treeState, setTreeState] = useState(true);
const [nodeType, setNodeType] = useState(1); // 根据节点类型渲染不同的编辑表单item,0-0一级菜单,0-0-0二级,0-0-0-0三级
const [rolelist, setRolelist] = useState([]);
const [roleValueList, setRoleValueList] = useState({});
......@@ -44,9 +47,10 @@ const SevenParams = () => {
const [addMenuVisible, setAddMenuVisible] = useState(false);
const [addMenuGroupVisible, setAddMenuGroupVisible] = useState(false);
const [tipVisible, setTipVisible] = useState(false);
// const [editMenuVisible, setEditMenuVisible] = useState(false);
const [deleteMenuVisible, setDeleteMenuVisible] = useState(false);
const [addMenuForm] = Form.useForm();
const [editMenuForm] = Form.useForm();
const [addMenuGroupForm] = Form.useForm();
const getRoleValueCallback = useCallback((value, index) => {
......@@ -65,8 +69,14 @@ const SevenParams = () => {
.then(res => {
if (res.length > 0) {
setTreeLoading(false);
setTreeData(res[0].children[0].children[2].children);
console.log(res[0].children[0].children[2].children);
const result = res[0].children[0].children[2].children;
setTreeData(result);
console.log(result);
// 第一次加载,默认选择第一个组织
if (treeState) {
onSelect([result[0].menuID], false);
setTreeState(false);
}
}
})
.catch(err => {
......@@ -109,11 +119,11 @@ const SevenParams = () => {
onClick={() => addMenuGroup(menu, '分组图标')}
/>
</Tooltip>
<Tooltip title="添加菜单组">
{/* <Tooltip title="添加菜单组">
<EditTwoTone
onClick={() => editMenuGroup(menu, '在线图标')}
/>
</Tooltip>
</Tooltip> */}
</>
)}
{menu.menuType === 'MiniAppMenuGroupTwo' && (
......@@ -121,20 +131,20 @@ const SevenParams = () => {
<Tooltip title="添加菜单">
<FileAddTwoTone onClick={() => addMenu(menu)} />
</Tooltip>
<Tooltip title="编辑菜单组">
{/* <Tooltip title="编辑菜单组">
<EditTwoTone
onClick={() => editMenuGroup(menu, '分组图标')}
/>
</Tooltip>
</Tooltip> */}
</>
)}
{menu.menuType === 'MiniAppMenuThree' && (
{/* {menu.menuType === 'MiniAppMenuThree' && (
<>
<Tooltip title="编辑菜单">
<EditTwoTone onClick={() => editMenu(menu)} />
</Tooltip>
</>
)}
)} */}
<Tooltip title="删除菜单">
<DeleteTwoTone onClick={() => deleteMenu(menu)} />
</Tooltip>
......@@ -148,6 +158,38 @@ const SevenParams = () => {
};
};
// 获取当前菜单详细
const onSelect = (props, e) => {
// e.node.pos节点类型,根据这个渲染不同的编辑表单item,0-x一级菜单,0-0-x二级,0-0-0-x三级
if (e) {
if (e.node.pos.lastIndexOf('-') === 1) {
setNodeType(1);
} else if (e.node.pos.lastIndexOf('-') === 3) {
setNodeType(2);
} else {
setNodeType(3);
}
}
setMenuID(props[0]);
getMenuInfo(props[0])
.then(res => {
if (res.success) {
editMenuForm.setFieldsValue({
menuName: res.menuName,
shortName: res.menuShortName,
imageUrl: res.imageUrl,
pageUrl: res.pageUrl,
offlineImgUrl: res.offlineImgUrl,
funParam: res.funParam,
relatedRoleList: res.relatedRoleList || '',
});
}
})
.catch(err => {
message.error(err);
});
};
// 左侧目录树相关操作
const addMenu = menu => {
setAddMenuVisible(true);
......@@ -199,34 +241,35 @@ const SevenParams = () => {
message.error(err);
});
};
const editMenuGroup = (menu, label) => {
setAddMenuGroupVisible(true);
setMenuTitle(`编辑${menu.text}`);
setMenuID(menu.menuID);
setMenuLabel(label);
getMenuInfo(menu.menuID)
.then(res => {
if (res.success) {
addMenuGroupForm.setFieldsValue({
menuName: res.menuName,
shortName: res.menuShortName,
imageUrl: res.imageUrl,
pageUrl: res.pageUrl,
offlineImgUrl: res.offlineImgUrl,
funParam: res.funParam,
relatedRoleList: res.relatedRoleList || [],
});
} else {
notification.error({
message: '获取失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
};
// const editMenuGroup = (menu, label) => {
// setAddMenuGroupVisible(true);
// setMenuTitle(`编辑${menu.text}`);
// setMenuID(menu.menuID);
// setMenuLabel(label);
// getMenuInfo(menu.menuID)
// .then(res => {
// if (res.success) {
// addMenuGroupForm.setFieldsValue({
// menuName: res.menuName,
// shortName: res.menuShortName,
// imageUrl: res.imageUrl,
// pageUrl: res.pageUrl,
// offlineImgUrl: res.offlineImgUrl,
// funParam: res.funParam,
// relatedRoleList: res.relatedRoleList || [],
// });
// } else {
// notification.error({
// message: '获取失败',
// description: res.message,
// });
// }
// })
// .catch(err => {
// message.error(err);
// });
// };
const deleteMenu = menu => {
setDeleteMenuVisible(true);
setMenuTitle(`删除菜单${menu.text}`);
......@@ -300,6 +343,65 @@ const SevenParams = () => {
setTipVisible(true);
}
};
// 提交-编辑菜单
const submitEditMenu = () => {
let menuName = editMenuForm.getFieldValue('menuName');
let shortName = editMenuForm.getFieldValue('shortName');
let imageUrl = editMenuForm.getFieldValue('imageUrl');
let offlineImgUrl = editMenuForm.getFieldValue('offlineImgUrl') || '';
let pageUrl = editMenuForm.getFieldValue('pageUrl') || '';
let funParam = editMenuForm.getFieldValue('funParam') || '';
let relatedRoleList = editMenuForm.getFieldValue('funParam') || '';
const params = {
menuID,
menuName,
shortName,
imageUrl,
offlineImgUrl,
pageUrl,
funParam,
relatedRoleList,
};
// 根据节点类型,加一层判断,必填项全部不为空时才能提交
if (nodeType === 1) {
if (menuName && shortName && imageUrl && offlineImgUrl) {
submitMenu(params);
} else {
setTipVisible(true);
}
} else if (nodeType === 2) {
if (menuName && shortName && imageUrl) {
submitMenu(params);
} else {
setTipVisible(true);
}
} else if (nodeType === 3) {
if (menuName && shortName && imageUrl && pageUrl) {
submitMenu(params);
} else {
setTipVisible(true);
}
}
};
const submitMenu = params => {
submitMenuInfo(params)
.then(res => {
if (res.success) {
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '获取失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
};
// 提交删除菜单
const submitDeleteMenu = () => {
deleteMenuApi(menuID)
......@@ -359,45 +461,18 @@ const SevenParams = () => {
showLine={{ showLeafIcon: false }}
defaultExpandAll="true"
// selectedKeys={[currentSelectMenu]}
// onSelect={onSelect}
onSelect={onSelect}
treeData={treeData.map(t => mapTree(t))}
/>
</Spin>
)}
</div>
<div className={styles.previewContainer}>123</div>
{/* 必填项提示 */}
<Modal
title="提示"
visible={tipVisible}
onCancel={() => setTipVisible(false)}
width="300px"
centered
footer={[
<Button
key="back"
type="primary"
onClick={() => setTipVisible(false)}
>
关闭
</Button>,
]}
<div className={styles.editContainer}>
<Form
form={editMenuForm}
labelCol={{ span: 4 }}
wrapperCol={{ span: 19 }}
>
<p>
标记<span className={styles.redText}>*</span>的为必填
</p>
</Modal>
{/* 添加菜单 */}
<Modal
title={menuTitle}
visible={addMenuVisible}
onOk={submitAddMenu}
onCancel={() => setAddMenuVisible(false)}
okText="确认"
cancelText="取消"
centered
>
<Form form={addMenuForm} labelCol={{ span: 4 }}>
<Form.Item
name="menuName"
label="菜单名称"
......@@ -419,93 +494,46 @@ const SevenParams = () => {
>
<Input placeholder="请输入菜单图标" />
</Form.Item>
<Form.Item
name="imageUrl"
label="菜单图标"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入菜单图标" />
</Form.Item>
<Form.Item label="图标预览">
<PicturesWall maxLen={3} />
</Form.Item>
<Form.Item name="funParam" label="功能参数">
<Input placeholder="请输入功能参数" />
</Form.Item>
</Form>
<ListCardItem
itemid="1"
key="1"
userList={rolelist}
OUName="关联角色"
getValueCallback={getRoleValueCallback}
/>
</Modal>
{/* 添加菜单组 */}
<Modal
title={menuTitle}
visible={addMenuGroupVisible}
onOk={submitAddMenuGroup}
onCancel={() => setAddMenuGroupVisible(false)}
okText="确认"
cancelText="取消"
centered
>
<Form form={addMenuGroupForm} labelCol={{ span: 4 }}>
<Form.Item
name="menuName"
label="分组名称"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入分组名称" />
</Form.Item>
<Form.Item
name="shortName"
label="分组别名"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入分组别名" />
</Form.Item>
{nodeType === 1 && (
<>
<Form.Item
name="imageUrl"
label={menuLabel}
name="offlineImgUrl"
label="离线图标"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入菜单图标" />
<Input placeholder="请输入离线图标" />
</Form.Item>
<Form.Item label="图标预览">
<PicturesWall maxLen={3} />
</Form.Item>
{/* 添加菜单组,label名称为在线图标才有离线图标 */}
{menuLabel === '在线图标' && (
</>
)}
{nodeType === 3 && (
<>
<Form.Item
name="offlineImgUrl"
label="离线图标"
name="pageUrl"
label="功能路径"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入离线图标" />
<Input placeholder="请输入功能路径" />
</Form.Item>
</>
)}
<Form.Item label="图标预览">
<PicturesWall maxLen={3} />
</Form.Item>
<Form.Item name="funParam" label="功能参数">
<Input placeholder="请输入功能参数" />
</Form.Item>
<Form.Item wrapperCol={{ offset: 12 }}>
<Button key="back" type="primary" onClick={() => submitEditMenu()}>
提交
</Button>
</Form.Item>
</Form>
</Modal>
{/* 删除菜单 */}
<Modal
title={menuTitle}
visible={deleteMenuVisible}
onOk={submitDeleteMenu}
onCancel={() => setDeleteMenuVisible(false)}
okText="确认"
cancelText="取消"
centered
>
<span>确定删除?</span>
</Modal>
</div>
<div className={styles.previewContainer}>界面预览</div>
{/* 必填项提示 */}
</div>
);
};
......
.contentContainer{
// min-height: calc(100vh - 194px);
overflow-x: auto;
display: flex;
.menuContainer{
min-width: 300px;
border:1px solid #abaeb1;
min-height:calc(100vh - 300px);
// min-height:calc(100vh - 300px);
overflow-y:auto;
.ant-tree-list{
padding: 10px;
height:calc(100vh - 300px);
height:calc(100vh - 330px);
.ant-tree-switcher{
line-height: 1;
color:#1890FF;
......@@ -19,11 +20,23 @@
}
}
}
.previewContainer{
.editContainer{
margin-left: 12px;
flex: 1;
padding: 16px;
float: left;
// background: white;
min-width: 500px;
border:1px solid #abaeb1;
.ant-table-pagination-right{
padding-right: 12px;
}
}
.previewContainer{
margin-left: 12px;
// flex: 1;
float: left;
min-width: 400px;
border:1px solid #abaeb1;
.ant-table-pagination-right{
padding-right: 12px;
}
......@@ -54,15 +67,3 @@
color: red;
cursor: pointer;
}
\ No newline at end of file
// .ant-modal-root{
// .ant-tree-switcher{
// line-height: 1;
// color:#1890FF;
// }
// }
// .menuContainer{
// width: 300px;
// padding: 10px;
// background: #1890FF;
// }
\ No newline at end of file
......@@ -206,9 +206,9 @@ const SevenParams = () => {
return (
<Form
form={sevenForm}
labelCol={{ span: 4, offset: 4 }}
labelCol={{ span: 2, offset: 2 }}
wrapperCol={{ span: 16, offset: 1 }}
style={{ width: '900px' }}
style={{ height: 'calc(100vh - 300px)' }}
onFinish={submitSevenParams}
initialValues={{ ellipseType: '1', transType: '1' }}
>
......@@ -324,14 +324,7 @@ const SevenParams = () => {
</Form.Item>
</>
)}
<Form.Item
wrapperCol={{
sm: {
span: 16,
offset: 16,
},
}}
>
<Form.Item wrapperCol={{ offset: 12 }}>
<Button type="primary" htmlType="submit">
提交
</Button>
......
......@@ -101,7 +101,7 @@ const SiteConfig = props => {
</Item>
<Item label="系统图标预览:">
<PicturesWall maxLen={3} />
<PicturesWall />
</Item>
<Item
label="登陆页面:"
......
import React, { useState, useEffect, useCallback } from 'react';
import {
message,
notification,
Form,
Spin,
Tree,
Tooltip,
Modal,
Input,
Button,
} from 'antd';
import {
FileAddTwoTone,
FolderAddTwoTone,
EditTwoTone,
DeleteTwoTone,
FolderOpenOutlined,
FileOutlined,
} from '@ant-design/icons';
import {
getTree,
addMenuApi,
addMenuGroupApi,
getRoleList,
getMenuInfo,
deleteMenuApi,
} from '@/services/appConfig/api';
import ListCardItem from '@/pages/orgnazation/listCardItem';
import styles from './LeftPart.less';
import PicturesWall from '@/components/Upload/index';
const LeftPart = () => {
const [treeLoading, setTreeLoading] = useState(true);
const [treeData, setTreeData] = useState([]); // 菜单树
const [rolelist, setRolelist] = useState([]);
const [roleValueList, setRoleValueList] = useState({});
const [menuID, setMenuID] = useState('');
const [menuTitle, setMenuTitle] = useState('菜单管理');
const [menuLabel, setMenuLabel] = useState('在线图标');
const [addMenuVisible, setAddMenuVisible] = useState(false);
const [addMenuGroupVisible, setAddMenuGroupVisible] = useState(false);
const [tipVisible, setTipVisible] = useState(false);
// const [editMenuVisible, setEditMenuVisible] = useState(false);
const [deleteMenuVisible, setDeleteMenuVisible] = useState(false);
const [addMenuForm] = Form.useForm();
const [addMenuGroupForm] = Form.useForm();
const getRoleValueCallback = useCallback((value, index) => {
roleValueList[index] = value;
setRoleValueList({ ...roleValueList });
}, []);
// 获取菜单树
useEffect(() => {
updateTrees();
}, []);
const updateTrees = () => {
setTreeLoading(true);
getTree()
.then(res => {
if (res.length > 0) {
setTreeLoading(false);
setTreeData(res[0].children[0].children[2].children);
console.log(res[0].children[0].children[2].children);
}
})
.catch(err => {
setTreeLoading(false);
message.error(err);
});
};
// 获取角色列表
useEffect(() => {
getRoleList()
.then(res => {
if (res && res.list) {
setRolelist(res.list);
} else {
notification.error({
message: '获取失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
}, []);
// 渲染菜单树
const mapTree = menu => {
const haveChildren =
Array.isArray(menu.children) && menu.children.length > 0;
return {
title: (
<>
<span>{menu.text}</span>
<div className={styles.iconWraper1}>
{menu.menuType === 'MiniAppMenuGroup' && (
<>
<Tooltip title="添加菜单组">
<FolderAddTwoTone
onClick={() => addMenuGroup(menu, '分组图标')}
/>
</Tooltip>
<Tooltip title="添加菜单组">
<EditTwoTone
onClick={() => editMenuGroup(menu, '在线图标')}
/>
</Tooltip>
</>
)}
{menu.menuType === 'MiniAppMenuGroupTwo' && (
<>
<Tooltip title="添加菜单">
<FileAddTwoTone onClick={() => addMenu(menu)} />
</Tooltip>
<Tooltip title="编辑菜单组">
<EditTwoTone
onClick={() => editMenuGroup(menu, '分组图标')}
/>
</Tooltip>
</>
)}
{menu.menuType === 'MiniAppMenuThree' && (
<>
<Tooltip title="编辑菜单">
<EditTwoTone onClick={() => editMenu(menu)} />
</Tooltip>
</>
)}
<Tooltip title="删除菜单">
<DeleteTwoTone onClick={() => deleteMenu(menu)} />
</Tooltip>
</div>
</>
),
key: menu.menuID,
icon: menu.leaf ? <FileOutlined /> : <FolderOpenOutlined />,
// 判断它是否存在子集,若果存在就进行再次进行遍历操作,知道不存在子集便对其他的元素进行操作
children: haveChildren ? menu.children.map(i => mapTree(i)) : [],
};
};
// 左侧目录树相关操作
const addMenu = menu => {
setAddMenuVisible(true);
setMenuTitle(`在${menu.text}下添加菜单`);
setMenuID(menu.menuID);
addMenuForm.setFieldsValue({
menuName: '',
shortName: '',
imageUrl: '',
pageUrl: '',
funParam: '',
});
};
const addMenuGroup = (menu, label) => {
setAddMenuGroupVisible(true);
setMenuTitle(`在${menu.text}下添加菜单组`);
setMenuLabel(label);
addMenuGroupForm.setFieldsValue({
menuName: '',
shortName: '',
imageUrl: '',
offlineImgUrl: '',
funParam: '',
});
};
const editMenu = menu => {
setAddMenuVisible(true);
setMenuTitle(`编辑${menu.text}`);
setMenuID(menu.menuID);
getMenuInfo(menu.menuID)
.then(res => {
if (res.success) {
addMenuForm.setFieldsValue({
menuName: res.menuName,
shortName: res.menuShortName,
imageUrl: res.imageUrl,
pageUrl: res.pageUrl,
funParam: res.funParam,
relatedRoleList: res.relatedRoleList || [],
});
} else {
notification.error({
message: '获取失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
};
const editMenuGroup = (menu, label) => {
setAddMenuGroupVisible(true);
setMenuTitle(`编辑${menu.text}`);
setMenuID(menu.menuID);
setMenuLabel(label);
getMenuInfo(menu.menuID)
.then(res => {
if (res.success) {
addMenuGroupForm.setFieldsValue({
menuName: res.menuName,
shortName: res.menuShortName,
imageUrl: res.imageUrl,
pageUrl: res.pageUrl,
offlineImgUrl: res.offlineImgUrl,
funParam: res.funParam,
relatedRoleList: res.relatedRoleList || [],
});
} else {
notification.error({
message: '获取失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
};
const deleteMenu = menu => {
setDeleteMenuVisible(true);
setMenuTitle(`删除菜单${menu.text}`);
setMenuID(menu.menuID);
};
// 提交添加菜单
const submitAddMenu = () => {
console.log(menuID);
let menuName = addMenuForm.getFieldValue('menuName');
let shortName = addMenuForm.getFieldValue('shortName');
let imageUrl = addMenuForm.getFieldValue('imageUrl');
let pageUrl = addMenuForm.getFieldValue('pageUrl');
let funParam = addMenuForm.getFieldValue('funParam');
if (menuName && shortName && imageUrl && pageUrl) {
addMenuApi(menuID, menuName, shortName, imageUrl, pageUrl, funParam)
.then(res => {
if (res.success) {
setAddMenuVisible(false);
notification.success({
message: '提交成功',
});
updateTrees();
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
} else {
setTipVisible(true);
}
};
// 提交添加菜单组
const submitAddMenuGroup = () => {
let menuName = addMenuGroupForm.getFieldValue('menuName');
let shortName = addMenuGroupForm.getFieldValue('shortName');
let imageUrl = addMenuGroupForm.getFieldValue('imageUrl');
let offlineImgUrl = addMenuGroupForm.getFieldValue('offlineImgUrl');
let funParam = addMenuGroupForm.getFieldValue('funParam');
if (menuName && shortName && imageUrl && offlineImgUrl) {
addMenuGroupApi(
menuID,
menuName,
shortName,
imageUrl,
offlineImgUrl,
funParam,
)
.then(res => {
if (res.success) {
setAddMenuGroupVisible(false);
notification.success({
message: '提交成功',
});
updateTrees();
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
} else {
setTipVisible(true);
}
};
// 提交删除菜单
const submitDeleteMenu = () => {
deleteMenuApi(menuID)
.then(res => {
if (res.success) {
setDeleteMenuVisible(false);
notification.success({
message: '删除成功',
});
updateTrees();
} else {
notification.error({
message: '删除失败',
description: res.message,
});
}
})
.catch(err => {
setTreeLoading(false);
message.error(err);
});
};
return (
<div className={styles.contentContainer}>
<div className={styles.menuContainer}>
<div style={{ padding: '10px 10px 0 16px' }}>
菜单列表
<Tooltip title="添加菜单">
<FileAddTwoTone
style={{
fontSize: '18px',
float: 'right',
margin: '4px 4px 0px 12px',
color: '#1890FF',
}}
onClick={() => addMenu({ text: '根目录', menuID: -1 })}
/>
</Tooltip>
<Tooltip title="添加菜单组">
<FolderAddTwoTone
style={{
fontSize: '18px',
float: 'right',
marginTop: '4px',
}}
onClick={() =>
addMenuGroup({ text: '根目录', menuID: -1 }, '在线图标')
}
/>
</Tooltip>
</div>
{treeData.length > 0 && (
<Spin spinning={treeLoading} tip="loading...">
<Tree
showIcon="true"
showLine={{ showLeafIcon: false }}
defaultExpandAll="true"
// selectedKeys={[currentSelectMenu]}
// onSelect={onSelect}
treeData={treeData.map(t => mapTree(t))}
/>
</Spin>
)}
</div>
{/* 必填项提示 */}
<Modal
title="提示"
visible={tipVisible}
onCancel={() => setTipVisible(false)}
width="300px"
centered
footer={[
<Button
key="back"
type="primary"
onClick={() => setTipVisible(false)}
>
关闭
</Button>,
]}
>
<p>
标记<span className={styles.redText}>*</span>的为必填项
</p>
</Modal>
{/* 添加菜单 */}
<Modal
title={menuTitle}
visible={addMenuVisible}
onOk={submitAddMenu}
onCancel={() => setAddMenuVisible(false)}
okText="确认"
cancelText="取消"
centered
>
<Form form={addMenuForm} labelCol={{ span: 4 }}>
<Form.Item
name="menuName"
label="菜单名称"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入菜单名称" />
</Form.Item>
<Form.Item
name="shortName"
label="菜单别名"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入菜单别名" />
</Form.Item>
<Form.Item
name="imageUrl"
label="菜单图标"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入菜单图标" />
</Form.Item>
<Form.Item
name="imageUrl"
label="菜单图标"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入菜单图标" />
</Form.Item>
<Form.Item label="图标预览">
<PicturesWall maxLen={3} />
</Form.Item>
<Form.Item name="funParam" label="功能参数">
<Input placeholder="请输入功能参数" />
</Form.Item>
</Form>
<ListCardItem
itemid="1"
key="1"
userList={rolelist}
OUName="关联角色"
getValueCallback={getRoleValueCallback}
/>
</Modal>
{/* 添加菜单组 */}
<Modal
title={menuTitle}
visible={addMenuGroupVisible}
onOk={submitAddMenuGroup}
onCancel={() => setAddMenuGroupVisible(false)}
okText="确认"
cancelText="取消"
centered
>
<Form form={addMenuGroupForm} labelCol={{ span: 4 }}>
<Form.Item
name="menuName"
label="分组名称"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入分组名称" />
</Form.Item>
<Form.Item
name="shortName"
label="分组别名"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入分组别名" />
</Form.Item>
<Form.Item
name="imageUrl"
label={menuLabel}
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入菜单图标" />
</Form.Item>
<Form.Item label="图标预览">
<PicturesWall maxLen={3} />
</Form.Item>
{/* 添加菜单组,label名称为在线图标才有离线图标 */}
{menuLabel === '在线图标' && (
<Form.Item
name="offlineImgUrl"
label="离线图标"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入离线图标" />
</Form.Item>
)}
<Form.Item label="图标预览">
<PicturesWall maxLen={3} />
</Form.Item>
<Form.Item name="funParam" label="功能参数">
<Input placeholder="请输入功能参数" />
</Form.Item>
</Form>
</Modal>
{/* 删除菜单 */}
<Modal
title={menuTitle}
visible={deleteMenuVisible}
onOk={submitDeleteMenu}
onCancel={() => setDeleteMenuVisible(false)}
okText="确认"
cancelText="取消"
centered
>
<span>确定删除?</span>
</Modal>
</div>
);
};
export default LeftPart;
.contentContainer{
// min-height: calc(100vh - 194px);
display: flex;
.menuContainer{
min-width: 300px;
border:1px solid #abaeb1;
min-height:calc(100vh - 300px);
overflow-y:auto;
.ant-tree-list{
padding: 10px;
height:calc(100vh - 300px);
.ant-tree-switcher{
line-height: 1;
color:#1890FF;
}
.ant-tree-iconEle{
line-height: 1.2;
color:#1890FF;
}
}
}
.previewContainer{
margin-left: 12px;
flex: 1;
float: left;
// background: white;
.ant-table-pagination-right{
padding-right: 12px;
}
}
.ant-tree-treenode{
width: 100% !important;
.ant-tree-node-content-wrapper{
display: inline-block;
width: 100%;
}
.iconWraper1{
float: right;
span{
display: none;
}
}
}
.ant-tree-treenode:hover{
.iconWraper1>span{
margin-left: 12px;
font-size: 18px;
display: inline-block;
}
}
}
.redText{
color: red;
cursor: pointer;
}
// .ant-modal-root{
// .ant-tree-switcher{
// line-height: 1;
// color:#1890FF;
// }
// }
// .menuContainer{
// width: 300px;
// padding: 10px;
// background: #1890FF;
// }
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import ProCard from '@ant-design/pro-card';
import AddForm from './AddForm';
import LeftPart from './LeftPart';
const MenuConfig = props => {
const [flag, setFlag] = useState(1);
return (
<ProCard split="vertical">
<ProCard colSpan="400px">
<div style={{ height: '60px', backgroundColor: 'red' }}> a</div>
<LeftPart />
</ProCard>
<ProCard>
<AddForm />
......
......@@ -58,7 +58,7 @@ const UserManage = () => {
const [loading, setLoading] = useState(true);
const [treeData, setTreeData] = useState([]); // 用户机构树
const [treeData1, setTreeData1] = useState([]);
const [treeData1, setTreeData1] = useState([]); // 用户机构树-备份,供更改机构使用
const [treeData2, setTreeData2] = useState([]);
const [tableData, setTableData] = useState([]); // 用户表
const [searchData, setSearchData] = useState([]);
......
......@@ -5,11 +5,13 @@ import { PageContainer, GridContent } from '@ant-design/pro-layout';
import {
getWebModuleTree,
chooseUserToStation,
getUserRelationList,
setMenuToRole,
} from '@/services/userCenter/roleManage/api';
import ListCard from '@/pages/orgnazation/ListCard';
import ListCard from '@/components/CheckGroup';
// import ListCard from '@/pages/orgnazation/ListCard';
import qs from 'qs';
import styles from '@/pages/userCenter/roleManage/RoleManage.less';
import { version } from 'less';
import AddModal from './AddModal';
import DelModal from './DelModal';
import EditModal from './EditModal';
......@@ -39,31 +41,43 @@ const SiteManage = () => {
setOuid(saveTreeId);
}
};
// useEffect(() => {
// setSpinLoading(true);
// getWebModuleTree({
// userMode: 'super',
// select: '',
// _version: 9999,
// _dc: Date.now(),
// node: -2,
// })
// .then(res => {
// setSpinLoading(false);
// let arr = [];
// if (res) {
// arr.push(res.find(item => item.id === 'Web4StationRoot'));
// console.log(arr, 'arr');
// }
// let arr2 = transTree(arr);
// setTreeData(arr2);
// })
// .catch(err => {
// setSpinLoading(false);
// console.error(err);
// });
// }, [flag]);
useEffect(() => {
setSpinLoading(true);
getWebModuleTree({
userMode: 'super',
select: '',
getUserRelationList({
userID: 82,
_version: 9999,
_dc: Date.now(),
node: -2,
})
.then(res => {
setSpinLoading(false);
let arr = [];
if (res) {
arr.push(res.find(item => item.id === 'Web4StationRoot'));
console.log(arr, 'arr');
}
let arr2 = transTree(arr);
}).then(res => {
let arr = res.roleList;
let arr2 = transTree2(arr);
console.log(arr2, 'arr2');
setTreeData(arr2);
})
.catch(err => {
setSpinLoading(false);
console.error(err);
});
}, [flag]);
}, []);
const Title = props => {
const { text } = props;
console.log(props);
......@@ -111,25 +125,46 @@ const SiteManage = () => {
setEditVisible(true);
};
// 树形数据转换
const transTree = val => {
console.log(val);
// const transTree = val => {
// console.log(val);
// let arr = val;
// return arr.map((item, index) => {
// item.title = Title(item) || item.text;
// item.key = item.stationID || '';
// let obj = {};
// if (Array.isArray(item.children) && item.children.length > 0) {
// transTree(item.children);
// obj = item;
// return obj;
// }
// return item;
// });
// };
const transTree2 = val => {
let arr = val;
return arr.map((item, index) => {
item.title = Title(item) || item.text;
item.key = item.stationID || '';
let obj = {};
if (Array.isArray(item.children) && item.children.length > 0) {
transTree(item.children);
obj = item;
return obj;
console.log(arr, 'arr');
let arr2 = arr.map((item, index) => {
item.title = item.visibleTitle;
item.key = item.visibleValue;
if (item.roleList && item.roleList.length > 0) {
item.roleList.map(child => {
child.title = child.roleName;
child.key = child.roleID;
});
}
item.children = item.roleList;
return item;
});
return arr2;
};
// 获取搜索框的值
const handleSearch = value => {
setSearchWord(value);
};
const handleChange = e => {
const { value } = e.target;
setSearchWord(value);
};
const confirmModal = e => {
setModalVisible(false);
setFlag(flag + 1);
......@@ -147,10 +182,10 @@ const SiteManage = () => {
};
const handleCommit = value => {
let arr = Object.values(subList);
chooseUserToStation(
setMenuToRole(
qs.stringify({
userList: String(arr.flat()),
stationID: ouid,
roleID: ouid,
menuNameList: String(arr.flat()),
}),
{
headers: {
......@@ -193,6 +228,7 @@ const SiteManage = () => {
showIcon
onSelect={e => handleTreeSelect(e)}
treeData={treeData}
blockNode
/>
</Spin>
<AddModal
......@@ -223,6 +259,7 @@ const SiteManage = () => {
allowClear
placeholder={placeholder}
onSearch={handleSearch}
onChange={handleChange}
enterButton
/>
</Col>
......
......@@ -76,7 +76,6 @@ export const addMenuGroupApi = (
subSystemValue: 'miniapp',
relatedRoleList: '',
});
// 获取角色列表
export const getRoleList = () =>
get(`/Cityinterface/rest/services/OMS.svc/P_GetRoleListPlain`, {
......@@ -84,14 +83,17 @@ export const getRoleList = () =>
_dc: new Date().getTime(),
subSystemValue: 'miniapp',
});
// 获取菜单
// 编辑-获取菜单
export const getMenuInfo = id =>
get(`/Cityinterface/rest/services/OMS.svc/Mini_GetMenuInfo`, {
_version: 9999,
_dc: new Date().getTime(),
menuID: id,
});
// 获取菜单
// 编辑-提交菜单
export const submitMenuInfo = params =>
get(`/Cityinterface/rest/services/OMS.svc/MiniApp_EditMenu`, params);
// 删除菜单
export const deleteMenuApi = id =>
get(`/Cityinterface/rest/services/OMS.svc/MiniApp_DeleteMenu`, {
_version: 9999,
......
......@@ -24,4 +24,12 @@ export const chooseUserToStation = (params, options) =>
// 获取所有角色信息
export const getUserRelationList = params =>
get('Cityinterface/rest/services/OMS.svc/W4_GetUserRelationList', params);
get('/Cityinterface/rest/services/OMS.svc/W4_GetUserRelationList', params);
// 角色管理保存选择
export const setMenuToRole = (params, options) =>
post(
'/Cityinterface/rest/services/OMS.svc/P_SetMenuToRole?_version: 9999',
params,
options,
);
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