| | |
| | | import { |
| | | ProForm, |
| | | ProFormDigit, |
| | | ProFormText, |
| | | ProFormSelect, |
| | | } from '@ant-design/pro-components'; |
| | | import { Col, Form, Modal, Row, Checkbox, Skeleton, Tree } from 'antd'; |
| | | import Http from '@/utils/http'; |
| | |
| | | setMenuTreeLoading(true); |
| | | Http.doPostPromise('/api/menu/tree', param, (res) => { |
| | | setMenuTreeLoading(false); |
| | | const rootMenu = { id: 0, name: '全部', value: 0, children: [] }; |
| | | rootMenu.children = res.data; |
| | | // const treeData = transformTreeData([rootMenu]); |
| | | const treeData = transformTreeData(res.data); |
| | | setMenuTreeData(treeData); |
| | | const treeAllKeys = getTreeAllKeys(treeData); |
| | |
| | | } |
| | | |
| | | const handleFinish = async (values) => { |
| | | props.onSubmit({ ...values }); |
| | | console.log({ ...values, menuIds }); return |
| | | props.onSubmit({ ...values, menuIds }); |
| | | } |
| | | |
| | | return ( |
| | |
| | | { label: '全选/全不选', value: 'checkAll' }, |
| | | ]} |
| | | onChange={(values) => { |
| | | if(values.includes('expandAll')) { |
| | | if (values.includes('expandAll')) { |
| | | setMenuExpandedKeys(menuTreeAllKeys); |
| | | } else { |
| | | setMenuExpandedKeys([]); |
| | | } |
| | | if(values.includes('checkAll')) { |
| | | if (values.includes('checkAll')) { |
| | | |
| | | } else { |
| | | |
| | |
| | | onExpand={(expandedKeys) => { |
| | | setMenuExpandedKeys(expandedKeys) |
| | | }} |
| | | // checkedKeys={menuIds} |
| | | |
| | | |
| | | // onCheck={(checkedKeys, checkInfo) => { |
| | | // console.log(checkedKeys, checkInfo); |
| | | // }} |
| | | // defaultCheckedKeys={onSelect} |
| | | checkedKeys={menuIds} |
| | | onCheck={(checkedKeys, checkInfo) => { |
| | | return setMenuIds({ |
| | | checked: checkedKeys, |
| | | halfChecked: checkInfo.halfCheckedKeys // 父节点 |
| | | }); |
| | | }} |
| | | // defaultCheckedKeys={onSelect} |
| | | /> |
| | | )} |
| | | </Col> |