Commit 69e4aaab authored by mayongxin's avatar mayongxin

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

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