| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 240, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='name' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <TextFilter |
| | | // name='name' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '上级部门', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='leader' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <TextFilter |
| | | // name='leader' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '数量', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='sort' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <TextFilter |
| | | // name='sort' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | render: (_, record) => { |
| | | return <span style={{ fontWeight: "bold" }}>{_}</span> |
| | | } |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='status' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '正常', value: 1 }, |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | />, |
| | | // filterDropdown: (props) => <SelectFilter |
| | | // name='status' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // data={[ |
| | | // { label: '正常', value: 1 }, |
| | | // { label: '禁用', value: 0 }, |
| | | // ]} |
| | | // />, |
| | | render: (_, record) => { |
| | | const status = statusMap[record.status] |
| | | return <Tag color={status.color}>{status.text}</Tag> |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='updateTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <DatetimeRangeFilter |
| | | // name='updateTime' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '修改人员', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='updateBy' |
| | | major='user' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <LinkFilter |
| | | // name='updateBy' |
| | | // major='user' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '备注', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 240, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='name' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <TextFilter |
| | | // name='name' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '上级菜单', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 200, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='route' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <TextFilter |
| | | // name='route' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '页面组件', |
| | |
| | | const type = typeMap[record.type] |
| | | return <Tag color={type.color}>{type.text}</Tag> |
| | | }, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='type' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '菜单', value: 0 }, |
| | | { label: '按钮', value: 1 }, |
| | | ]} |
| | | />, |
| | | // filterDropdown: (props) => <SelectFilter |
| | | // name='type' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // data={[ |
| | | // { label: '菜单', value: 0 }, |
| | | // { label: '按钮', value: 1 }, |
| | | // ]} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '权限标识', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='authority' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <TextFilter |
| | | // name='authority' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '菜单图标', |
| | |
| | | const status = statusMap[record.status] |
| | | return <Tag color={status.color}>{status.text}</Tag> |
| | | }, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='status' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '正常', value: 1 }, |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | />, |
| | | // filterDropdown: (props) => <SelectFilter |
| | | // name='status' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // data={[ |
| | | // { label: '正常', value: 1 }, |
| | | // { label: '禁用', value: 0 }, |
| | | // ]} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '添加时间', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='updateTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <DatetimeRangeFilter |
| | | // name='updateTime' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '修改人员', |
| | |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='updateBy' |
| | | major='user' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | // filterDropdown: (props) => <LinkFilter |
| | | // name='updateBy' |
| | | // major='user' |
| | | // {...props} |
| | | // actionRef={actionRef} |
| | | // setSearchParam={setSearchParam} |
| | | // />, |
| | | }, |
| | | { |
| | | title: '备注', |
| | |
| | | const [deptExpandedKeys, setDeptExpandedKeys] = useState([]); |
| | | const [pwdModalVisible, setPwdModalVisible] = useState(false); |
| | | |
| | | useEffect(() => { |
| | | const handleResize = () => setBoxHeight(window.innerHeight - 368); |
| | | window.addEventListener('resize', handleResize); |
| | | handleResize(); |
| | | |
| | | Http.doPostPromise('/api/dept/tree', {}, (res) => { |
| | | const loadDeptTreeData = (param) => { |
| | | Http.doPostPromise('/api/dept/tree', param, (res) => { |
| | | const rootMenu = { id: 0, name: '全部', value: 0, children: [] }; |
| | | rootMenu.children = res.data; |
| | | // const treeData = transformTreeData([rootMenu]); |
| | |
| | | const treeAllKeys = getTreeAllKeys(treeData); |
| | | setDeptExpandedKeys(treeAllKeys); |
| | | }) |
| | | } |
| | | |
| | | useEffect(() => { |
| | | const handleResize = () => setBoxHeight(window.innerHeight - 368); |
| | | window.addEventListener('resize', handleResize); |
| | | handleResize(); |
| | | |
| | | loadDeptTreeData(); |
| | | |
| | | return () => window.removeEventListener('resize', handleResize); |
| | | }, []); |
| | |
| | | placeholder="Search" |
| | | onChange={(e) => { |
| | | const { value } = e.target; |
| | | console.log(value); |
| | | loadDeptTreeData({ |
| | | condition: value |
| | | }) |
| | | }} |
| | | /> |
| | | <div style={{height: 'calc(100vh - 350px)', overflowY: 'auto' }}> |
| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | |
| | | @PreAuthorize("hasAuthority('system:dept:list')") |
| | | @PostMapping("/dept/tree") |
| | | public R tree(@RequestBody Map<String, Object> map) { |
| | | PageParam<Dept, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Dept.class); |
| | | QueryWrapper<Dept> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort")); |
| | | List<Dept> deptList = deptService.list(wrapper); |
| | | return R.ok().add(Utils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren)); |
| | | // PageParam<Dept, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Dept.class); |
| | | // QueryWrapper<Dept> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort")); |
| | | List<Dept> deptList = deptService.list(new LambdaQueryWrapper<Dept>().orderByAsc(Dept::getSort)); |
| | | List<Dept> treeData = Utils.toTreeData(deptList, 0L, Dept::getParentId, Dept::getId, Dept::setChildren); |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | treeData = Utils.treeRemove(deptList, String.valueOf(map.get("condition")), Dept::getName, Dept::getChildren, Dept::setChildren); |
| | | } |
| | | return R.ok().add(treeData); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:dept:list')") |
| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | |
| | | @PreAuthorize("hasAuthority('system:menu:list')") |
| | | @PostMapping("/menu/tree") |
| | | public R tree(@RequestBody Map<String, Object> map) { |
| | | PageParam<Menu, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Menu.class); |
| | | QueryWrapper<Menu> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort")); |
| | | List<Menu> menus = menuService.list(wrapper); |
| | | return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | // PageParam<Menu, BaseParam> param = new PageParam<>(buildParam(map, BaseParam.class), Menu.class); |
| | | // QueryWrapper<Menu> wrapper = param.buildWrapper(true, queryWrapper -> queryWrapper.orderByAsc("sort")); |
| | | // List<Menu> menus = menuService.list(wrapper); |
| | | // return R.ok().add(Utils.toTreeData(menus, 0L, Menu::getParentId, Menu::getId, Menu::setChildren)); |
| | | List<Menu> menuList = menuService.list(new LambdaQueryWrapper<Menu>().orderByAsc(Menu::getSort)); |
| | | List<Menu> treeData = Utils.toTreeData(menuList, 0L, Menu::getParentId, Menu::getId, Menu::setChildren); |
| | | if (!Cools.isEmpty(map.get("condition"))) { |
| | | treeData = Utils.treeRemove(menuList, String.valueOf(map.get("condition")), Menu::getName, Menu::getChildren, Menu::setChildren); |
| | | } |
| | | return R.ok().add(treeData); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:menu:list')") |
| | |
| | | import java.util.Optional; |
| | | import java.util.function.BiConsumer; |
| | | import java.util.function.Function; |
| | | import java.util.function.Predicate; |
| | | |
| | | /** |
| | | * Created by vincent on 2023/3/14 |
| | |
| | | return result; |
| | | } |
| | | |
| | | // public static <T> List<T> treeRemove(List<T> data, String condition, |
| | | // Function<? super T, ? extends String> fetcher, |
| | | // Function<T, List<T>> childrenGetter, |
| | | // BiConsumer<T, List<T>> childrenSetter) { |
| | | // List<T> result = new ArrayList<>(); |
| | | // for (T node : data) { |
| | | // List<T> children = childrenGetter.apply(node); |
| | | // |
| | | // if (children != null && !children.isEmpty()) { |
| | | // List<T> newChildren = treeRemove(children, condition, fetcher, childrenGetter, childrenSetter); |
| | | // childrenSetter.accept(node, newChildren); |
| | | // } |
| | | // |
| | | // if (fetcher.apply(node).contains(condition)) { |
| | | // result.add(node); |
| | | // } |
| | | // } |
| | | // return result; |
| | | // } |
| | | |
| | | public static <T> List<T> treeRemove(List<T> data, String condition, |
| | | Function<? super T, ? extends String> fetcher, |
| | | Function<T, List<T>> childrenGetter, |
| | | BiConsumer<T, List<T>> childrenSetter) { |
| | | List<T> result = new ArrayList<>(); |
| | | Predicate<T> predicate = node -> fetcher.apply(node).contains(condition); |
| | | for (T node : data) { |
| | | List<T> children = childrenGetter.apply(node); |
| | | if (children != null && !children.isEmpty()) { |
| | | List<T> newChildren = treeRemove(children, condition, fetcher, childrenGetter, childrenSetter); |
| | | childrenSetter.accept(node, newChildren); |
| | | } |
| | | if (predicate.test(node)) { |
| | | result.add(node); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 数组倒序 |
| | | * @param bytes |