#
luxiaotao1123
2024-02-21 dca78d5fd0c67fd841d6841ef2cd94a10669c356
zy-asrs-flow/src/pages/system/dept/index.jsx
@@ -1,6 +1,6 @@
import React, { useState, useRef, useEffect } from 'react';
import { Button, message, Modal } from 'antd';
import { Button, message, Modal, Tag } from 'antd';
import {
    FooterToolbar,
    PageContainer,
@@ -11,6 +11,8 @@
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 { statusMap } from '@/utils/enum-util'
const handleSave = async (val) => {
    const hide = message.loading('正在添加');
@@ -95,24 +97,19 @@
    const [currentRow, setCurrentRow] = useState();
    const [searchParam, setSearchParam] = useState({});
    const [treeData, setTreeData] = useState([]);
    useEffect(() => {
    }, []);
    const columns = [
        {
            title: 'No',
            dataIndex: 'index',
            valueType: 'indexBorder',
            width: 48,
        },
        {
            title: '名称',
            title: '部门名称',
            dataIndex: 'name',
            valueType: 'text',
            hidden: false,
            width: 140,
            copyable: true,
            width: 240,
            filterDropdown: (props) => <TextFilter
                name='name'
                {...props}
@@ -122,22 +119,9 @@
        },
        {
            title: '上级部门',
            dataIndex: 'parentId',
            valueType: 'text',
            hidden: false,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='parentId'
                {...props}
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
        },
        {
            title: '上级部门名',
            dataIndex: 'parentName',
            valueType: 'text',
            hidden: false,
            hidden: true,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='parentName'
@@ -147,36 +131,10 @@
            />,
        },
        {
            title: '关联路径',
            dataIndex: 'path',
            valueType: 'text',
            hidden: false,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='path'
                {...props}
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
        },
        {
            title: '关联路径名',
            dataIndex: 'pathName',
            valueType: 'text',
            hidden: false,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='pathName'
                {...props}
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
        },
        {
            title: '全称',
            dataIndex: 'fullName',
            valueType: 'text',
            hidden: false,
            hidden: true,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='fullName'
@@ -189,7 +147,7 @@
            title: '简述',
            dataIndex: 'brief',
            valueType: 'text',
            hidden: false,
            hidden: true,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='brief'
@@ -202,7 +160,7 @@
            title: '标识',
            dataIndex: 'code',
            valueType: 'text',
            hidden: false,
            hidden: true,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='code'
@@ -215,7 +173,7 @@
            title: '类型',
            dataIndex: 'type',
            valueType: 'text',
            hidden: false,
            hidden: true,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='type'
@@ -241,7 +199,7 @@
            title: '数量',
            dataIndex: 'count',
            valueType: 'text',
            hidden: false,
            hidden: true,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='count'
@@ -262,6 +220,9 @@
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
            render: (_, record) => {
                return <span style={{ fontWeight: "bold" }}>{_}</span>
            }
        },
        {
            title: '状态',
@@ -279,33 +240,10 @@
                    { label: '禁用', value: 0 },
                ]}
            />,
        },
        {
            title: '添加时间',
            dataIndex: 'createTime$',
            valueType: 'text',
            hidden: false,
            width: 140,
            filterDropdown: (props) => <DatetimeRangeFilter
                name='createTime'
                {...props}
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
        },
        {
            title: '添加人员',
            dataIndex: 'createBy$',
            valueType: 'text',
            hidden: false,
            width: 140,
            filterDropdown: (props) => <LinkFilter
                name='createBy'
                major='user'
                {...props}
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
            render: (_, record) => {
                const status = statusMap[record.status]
                return <Tag color={status.color}>{status.text}</Tag>
            },
        },
        {
            title: '修改时间',
@@ -338,7 +276,7 @@
            title: '备注',
            dataIndex: 'memo',
            valueType: 'text',
            hidden: false,
            hidden: true,
            width: 140,
            filterDropdown: (props) => <TextFilter
                name='memo'
@@ -401,7 +339,7 @@
                    cardBordered
                    scroll={{ x: 1300 }}
                    dateFormatter="string"
                    pagination={{ pageSize: 20 }}
                    pagination={{ pageSize: 100 }}
                    search={false}
                    toolbar={{
                        search: {
@@ -443,10 +381,14 @@
                        ],
                    }}
                    request={(params, sorter, filter) =>
                        Http.doPostPromise('/api/dept/page', { ...params, ...searchParam }, (res) => {
                        Http.doPostPromise('/api/dept/tree', { ...params, ...searchParam }, (res) => {
                            const rootMenu = { id: 0, name: '根目录', value: 0, children: [] };
                            rootMenu.children = res.data;
                            const treeData = transformTreeData([rootMenu]);
                            setTreeData(treeData);
                            return {
                                data: res.data.records,
                                total: res.data.total,
                                data: res.data,
                                success: true,
                            }
                        })
@@ -503,6 +445,7 @@
            <Edit
                open={modalVisible}
                values={currentRow || {}}
                treeData={treeData}
                onCancel={
                    () => {
                        setModalVisible(false);