Commit 69e4aaab authored by mayongxin's avatar mayongxin

角色选择组件支持传入初始值

parent 6c76bf43
...@@ -267,7 +267,11 @@ const EditModal = props => { ...@@ -267,7 +267,11 @@ const EditModal = props => {
name="to_person" name="to_person"
> >
<VisibleRoleModal onSubmit={onPushSubmit} title={"推送人员"} operate={<Button>adfasdf</Button>}/> <VisibleRoleModal
onSubmit={onPushSubmit}
title={"推送人员"}
initValues={["58","13"]}
/>
</Item> </Item>
<Item <Item
label="定时计划" label="定时计划"
......
...@@ -24,7 +24,7 @@ const VisibleRoleModal = props => { ...@@ -24,7 +24,7 @@ const VisibleRoleModal = props => {
const [dataTree, setDataTree] = useState([]) const [dataTree, setDataTree] = useState([])
const [dataLeafs, setDataLeafs] = useState([]) const [dataLeafs, setDataLeafs] = useState([])
const [selectValues, setSelectValues] = useState([]) const [selectValues, setSelectValues] = useState([])
const { onSubmit, title, operate } = props const { onSubmit, title, operate,initValues } = props
const GetRoleGroupList = () => { const GetRoleGroupList = () => {
...@@ -42,13 +42,19 @@ const VisibleRoleModal = props => { ...@@ -42,13 +42,19 @@ const VisibleRoleModal = props => {
name: roleItem.roleName, name: roleItem.roleName,
id: roleItem.roleID, id: roleItem.roleID,
}) })
return ( const leafNode = {
{ name: roleItem.roleName,
name: roleItem.roleName, id: roleItem.roleID,
id: roleItem.roleID, children: []
children: [] }
} // for (const id of initValues) {
) // if(id == roleItem.roleID){
// leafNode.checked = true
// }
// }
return leafNode
}) })
}) })
}) })
...@@ -118,7 +124,7 @@ const VisibleRoleModal = props => { ...@@ -118,7 +124,7 @@ const VisibleRoleModal = props => {
> >
<div className={styles.list_card}> <div className={styles.list_card}>
<ListCard {...props} onChange2={onChange2} data={dataTree} dataLeafs={dataLeafs} /> <ListCard {...props} onChange2={onChange2} data={dataTree} dataLeafs={dataLeafs} initValues={initValues}/>
</div> </div>
</SiteModal> </SiteModal>
</div> </div>
...@@ -141,7 +147,7 @@ const checkChildrenByCondition = ( ...@@ -141,7 +147,7 @@ const checkChildrenByCondition = (
const ListCard = props => { const ListCard = props => {
const { onChange, onChange2, data, dataLeafs } = props const { onChange, onChange2, data, dataLeafs,initValues } = props
const [changedItem, setChangedItem] = useState({ item: {} }); const [changedItem, setChangedItem] = useState({ item: {} });
const [valueList, setValueList] = useState([]); const [valueList, setValueList] = useState([]);
...@@ -213,7 +219,7 @@ const ListCard = props => { ...@@ -213,7 +219,7 @@ const ListCard = props => {
} }
useEffect(() => { useEffect(() => {
initValues&&setValueList(initValues)
}, []) }, [])
return ( return (
<div> <div>
......
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