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

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

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