Commit 6f3ea24c authored by 邓超's avatar 邓超

fix: 工作流角色选择模块添加机构选择

parent db9cad40
Pipeline #35692 skipped with stages
...@@ -147,6 +147,7 @@ const Workflow = () => { ...@@ -147,6 +147,7 @@ const Workflow = () => {
if (res.code === 0) { if (res.code === 0) {
setFlowData(res.data); setFlowData(res.data);
} else { } else {
setFlowData({ Nodes: [], Lines: [] });
notification.error({ notification.error({
title: '提示', title: '提示',
duration: 3, duration: 3,
......
...@@ -95,7 +95,6 @@ const NodeModal = props => { ...@@ -95,7 +95,6 @@ const NodeModal = props => {
// 修改表格 // 修改表格
setNodeMsg({ ...nodeMsg, roleList: [...newList] }); setNodeMsg({ ...nodeMsg, roleList: [...newList] });
} }
console.log(chooseIndex, obj, '选中人');
setShowRoal(false); setShowRoal(false);
}; };
// 编辑默认承办人 // 编辑默认承办人
...@@ -110,6 +109,14 @@ const NodeModal = props => { ...@@ -110,6 +109,14 @@ const NodeModal = props => {
title: '机构(角色)名称', title: '机构(角色)名称',
dataIndex: 'roleName', dataIndex: 'roleName',
align: 'center', align: 'center',
ellipsis: {
showTitle: false,
},
render: text => (
<Tooltip placement="topLeft" title={text}>
{text}
</Tooltip>
),
}, },
{ {
title: '默认承办人', title: '默认承办人',
...@@ -228,6 +235,7 @@ const NodeModal = props => { ...@@ -228,6 +235,7 @@ const NodeModal = props => {
setShowRoal(true); setShowRoal(true);
setIsEdit('add'); setIsEdit('add');
}} }}
type="primary"
> >
添加 添加
</Button> </Button>
......
...@@ -11,12 +11,14 @@ import { ...@@ -11,12 +11,14 @@ import {
Divider, Divider,
notification, notification,
Empty, Empty,
Tabs,
} from 'antd'; } from 'antd';
import Tree from '@/components/ExpendableTree'; import Tree from '@/components/ExpendableTree';
import { UserOutlined } from '@ant-design/icons'; import { UserOutlined } from '@ant-design/icons';
import styles from '../../../workflow.less'; import styles from '../../../workflow.less';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const { TabPane } = Tabs;
const RoalChoose = props => { const RoalChoose = props => {
const { onSubumit, handleCancel, visible, modalType, chooseUser } = props; const { onSubumit, handleCancel, visible, modalType, chooseUser } = props;
...@@ -32,17 +34,22 @@ const RoalChoose = props => { ...@@ -32,17 +34,22 @@ const RoalChoose = props => {
const [loading, setLoading] = useState(false); // 加载时的loading const [loading, setLoading] = useState(false); // 加载时的loading
const [userList, setUserList] = useState([]); // 编辑选中的用户信息 const [userList, setUserList] = useState([]); // 编辑选中的用户信息
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const [roleType, setRoleType] = useState('2'); // 角色类型
// 初始化 // 初始化
useEffect(() => { useEffect(() => {
form.resetFields(); form.resetFields();
if (visible) { if (visible) {
setCurrentPage(1); setCurrentPage(1);
if (modalType === 'edit') { if (modalType === 'edit') {
console.log(chooseUser);
setRoleType(chooseUser.type.toString());
form.setFieldsValue({ roleName: chooseUser.roleName }); form.setFieldsValue({ roleName: chooseUser.roleName });
setUserList(chooseUser.defaultUserId); setUserList(chooseUser.defaultUserId);
getData('', 1, 10, chooseUser.roleId); getData('', 1, pageSize, chooseUser.roleId, chooseUser.type);
} else { } else {
getData('', 1, 10); getData('', 1, pageSize, 0, 2);
setRoleType('2');
} }
} else { } else {
setUserList([]); setUserList([]);
...@@ -75,11 +82,18 @@ const RoalChoose = props => { ...@@ -75,11 +82,18 @@ const RoalChoose = props => {
setCheckAll(false); setCheckAll(false);
} }
}, [plainOptions]); }, [plainOptions]);
// 获取左侧树回显 // 获取左侧树回显
const getData = (roleName, pageIndex, pageSize, roleId) => { const getData = (roleName, pageIndex, pageSizes, roleId, Type) => {
roleName = roleName || ''; roleName = roleName || '';
setLoading(true); setLoading(true);
GetRoleUser({ roleName, pageIndex, pageSize, roleId }).then(res => { GetRoleUser({
roleName,
pageIndex,
pageSize: pageSizes,
roleId,
Type: Number(Type),
}).then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
setTreeData(res.data.data); setTreeData(res.data.data);
...@@ -93,7 +107,7 @@ const RoalChoose = props => { ...@@ -93,7 +107,7 @@ const RoalChoose = props => {
} }
}); });
}; };
// 保存角色 // 查询角色
const onFinish = () => { const onFinish = () => {
form.validateFields().then(validate => { form.validateFields().then(validate => {
if (validate) { if (validate) {
...@@ -103,7 +117,7 @@ const RoalChoose = props => { ...@@ -103,7 +117,7 @@ const RoalChoose = props => {
setIndeterminate(false); setIndeterminate(false);
setCheckAll(false); setCheckAll(false);
setCurrentPage(1); setCurrentPage(1);
getData(validate.roleName, 1, 10); getData(validate.roleName, 1, pageSize, 0, roleType);
} }
}); });
}; };
...@@ -132,7 +146,7 @@ const RoalChoose = props => { ...@@ -132,7 +146,7 @@ const RoalChoose = props => {
} }
}; };
// 监听分页 // 监听分页
const paginationChange = (page, pageSize) => { const paginationChange = (page, pageSizes) => {
// 分页时清空复选框 // 分页时清空复选框
setCurrentSelectId(''); setCurrentSelectId('');
setPlainOptions([]); setPlainOptions([]);
...@@ -140,8 +154,9 @@ const RoalChoose = props => { ...@@ -140,8 +154,9 @@ const RoalChoose = props => {
setIndeterminate(false); setIndeterminate(false);
setCheckAll(false); setCheckAll(false);
setCurrentPage(page); setCurrentPage(page);
setPageSize(pageSizes);
let roleName = form.getFieldValue('roleName'); let roleName = form.getFieldValue('roleName');
getData(roleName, page, pageSize); getData(roleName, page, pageSizes, 0, roleType);
}; };
// 复选框全选监听 // 复选框全选监听
const onCheckAllChange = e => { const onCheckAllChange = e => {
...@@ -156,6 +171,19 @@ const RoalChoose = props => { ...@@ -156,6 +171,19 @@ const RoalChoose = props => {
setIndeterminate(!!list.length && list.length < plainOptions.length); setIndeterminate(!!list.length && list.length < plainOptions.length);
setCheckAll(list.length === plainOptions.length); setCheckAll(list.length === plainOptions.length);
}; };
// tab栏切换回调
const tabCallback = val => {
if (val === roleType) {
return;
}
setRoleType(val);
setPlainOptions([]);
setCheckedList([]);
setIndeterminate(false);
setCheckAll(false);
setCurrentPage(1);
getData(form.getFieldValue('roleName'), 1, pageSize, 0, val);
};
// 保存选择的角色列表 // 保存选择的角色列表
const onSave = () => { const onSave = () => {
// 默认承办人字符串拼接 // 默认承办人字符串拼接
...@@ -177,9 +205,26 @@ const RoalChoose = props => { ...@@ -177,9 +205,26 @@ const RoalChoose = props => {
roleId: currentSelectId, roleId: currentSelectId,
defaultUserId: checkedList, defaultUserId: checkedList,
defauletUserName: DeafaultUserName, defauletUserName: DeafaultUserName,
type: Number(roleType),
}; };
onSubumit(obj, treeData.length); onSubumit(obj, treeData.length);
}; };
// 角色列表样式
const roleDom = () =>
treeData.length > 0 ? (
<Tree
blockNode
autoExpandParent
onSelect={onSelect}
selectedKeys={[currentSelectId]}
treeData={treeData.map(item => mapTree(item))}
/>
) : (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description="未有查找到角色"
/>
);
return ( return (
<Modal <Modal
title="角色用户列表" title="角色用户列表"
...@@ -218,24 +263,22 @@ const RoalChoose = props => { ...@@ -218,24 +263,22 @@ const RoalChoose = props => {
{/* 角色树 */} {/* 角色树 */}
<Spin spinning={loading}> <Spin spinning={loading}>
<div className={styles.treeContent}> <div className={styles.treeContent}>
<span style={{ marginLeft: '28px', fontWeight: 700 }}> <Tabs activeKey={roleType} onChange={tabCallback}>
角色列表 <TabPane
</span> tab="角色列表"
<Divider style={{ margin: '10px 0' }} /> key="2"
{treeData.length > 0 ? ( disabled={modalType === 'edit' && chooseUser.type === 1}
<Tree >
blockNode {roleDom()}
autoExpandParent </TabPane>
onSelect={onSelect} <TabPane
selectedKeys={[currentSelectId]} tab="机构列表"
treeData={treeData.map(item => mapTree(item))} key="1"
/> disabled={modalType === 'edit' && chooseUser.type === 2}
) : ( >
<Empty {roleDom()}
image={Empty.PRESENTED_IMAGE_SIMPLE} </TabPane>
description="未有查找到角色" </Tabs>
/>
)}
</div> </div>
</Spin> </Spin>
{/* 分页 */} {/* 分页 */}
......
...@@ -109,13 +109,17 @@ ...@@ -109,13 +109,17 @@
width: 100%; width: 100%;
height: 370px; height: 370px;
margin: 10px 0 10px 0; margin: 10px 0 10px 0;
padding: 20px 20px 20px 20px; padding: 8px 20px 20px 20px;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #ccc; border: 1px solid #ccc;
.ant-tree-list-holder { .ant-tree-list-holder {
height: 285px; height: 285px;
} }
} }
.footer {
position: relative;
z-index: 999;
}
} }
.userContent { .userContent {
width: 50%; width: 50%;
......
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