#
luxiaotao1123
2024-02-21 6fc2ad3b34100cc0048618f6cedbf829a742a7b8
#
2个文件已修改
34 ■■■■ 已修改文件
zy-asrs-flow/src/pages/system/user/index.jsx 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/utils/tree-util.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/system/user/index.jsx
@@ -11,7 +11,7 @@
import Http from '@/utils/http';
import Edit from './components/edit'
import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
import { transformTreeData } from '@/utils/tree-util'
import { transformTreeData, getTreeAllKeys } from '@/utils/tree-util'
const handleSave = async (val) => {
    const hide = message.loading('正在添加');
@@ -97,6 +97,7 @@
    const [searchParam, setSearchParam] = useState({});
    const [boxHeight, setBoxHeight] = useState();
    const [deptTreeData, setDeptTreeData] = useState([]);
    const [deptExpandedKeys, setDeptExpandedKeys] = useState([]);
    useEffect(() => {
        const handleResize = () => setBoxHeight(window.innerHeight - 368);
@@ -104,8 +105,12 @@
        handleResize();
        Http.doPostPromise('/api/dept/tree', {}, (res) => {
            const treeData = transformTreeData(res.data);
            const rootMenu = { id: 0, name: '全部', value: 0, children: [] };
            rootMenu.children = res.data;
            const treeData = transformTreeData([rootMenu]);
            setDeptTreeData(treeData);
            const treeAllKeys = getTreeAllKeys(treeData);
            setDeptExpandedKeys(treeAllKeys);
        })
        return () => window.removeEventListener('resize', handleResize);
@@ -433,7 +438,7 @@
                <Col lg={6} md={24}>
                    <Card title="部门" style={{ width: '100%', height: 'calc(100vh - 200px)' }}>
                        <Input
                            style={{ marginBottom: 8 }}
                            style={{ marginBottom: 10 }}
                            placeholder="Search"
                            onChange={(e) => {
                                const { value } = e.target;
@@ -442,13 +447,15 @@
                        />
                        <Tree
                            showLine
                            switcherIcon={<DownOutlined />}
                            blockNode
                            defaultExpandAll
                            onSelect={(selectedKeys, info) => {
                                console.log(selectedKeys[0]);
                            }}
                            defaultExpandAll    // 异步加载失效
                            expandedKeys={deptExpandedKeys}
                            treeData={deptTreeData}
                            switcherIcon={<DownOutlined />}
                            onSelect={(selectedKeys, info) => {
                                const deptId = selectedKeys[0];
                                console.log(deptId);
                            }}
                        />
                    </Card>
                </Col>
zy-asrs-flow/src/utils/tree-util.js
@@ -14,3 +14,14 @@
    return newItem;
  });
}
export function getTreeAllKeys(data) {
  let keys = [];
  for (let item of data) {
      keys.push(item.key);
      if (item.children) {
          keys = keys.concat(getTreeAllKeys(item.children));
      }
  }
  return keys;
}