#
luxiaotao1123
2024-02-21 dca78d5fd0c67fd841d6841ef2cd94a10669c356
zy-asrs-flow/src/pages/system/role/index.jsx
@@ -1,6 +1,5 @@
import React, { useState, useRef, useEffect } from 'react';
import { useIntl, FormattedMessage } from '@umijs/max';
import { Button, message, Modal } from 'antd';
import {
    FooterToolbar,
@@ -11,13 +10,12 @@
import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
import Http from '@/utils/http';
import Edit from './components/edit'
import { TextFilter, SelectFilter } from '@/components/TableSearch'
import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
const handleSave = async (val) => {
    const hide = message.loading('正在添加');
    try {
        const resp = await Http.doPost('api/role/save', val);
        hide();
        if (resp.code === 200) {
            message.success('添加成功');
            return true;
@@ -26,9 +24,10 @@
            return false;
        }
    } catch (error) {
        hide();
        message.error('添加失败请重试!');
        return false;
    } finally {
        hide();
    }
};
@@ -36,7 +35,6 @@
    const hide = message.loading('正在更新');
    try {
        const resp = await Http.doPost('api/role/update', val);
        hide();
        if (resp.code === 200) {
            message.success('更新成功');
            return true;
@@ -45,9 +43,10 @@
            return false;
        }
    } catch (error) {
        hide();
        message.error('配置失败请重试!');
        return false;
    } finally {
        hide();
    }
};
@@ -56,7 +55,6 @@
    const hide = message.loading('正在删除');
    try {
        const resp = await Http.doPost('api/role/remove/' + rows.map((row) => row.id).join(','));
        hide();
        if (resp.code === 200) {
            message.success('删除成功');
            return true;
@@ -65,23 +63,26 @@
            return false;
        }
    } catch (error) {
        hide();
        message.error('删除失败,请重试');
        return false;
    } finally {
        hide();
    }
};
const handleExport = async () => {
    const hide = message.loading('正在导出');
    try {
        await Http.doPost('api/role/export');
        hide();
        const resp = await Http.doPostBlob('api/role/export');
        const blob = new Blob([resp], { type: 'application/vnd.ms-excel' });
        window.location.href = window.URL.createObjectURL(blob);
        message.success('导出成功');
        return true;
    } catch (error) {
        hide();
        message.error('导出失败,请重试');
        return false;
    } finally {
        hide();
    }
};
@@ -93,8 +94,6 @@
    const [modalVisible, setModalVisible] = useState(false);
    const [currentRow, setCurrentRow] = useState();
    const [searchParam, setSearchParam] = useState({});
    const intl = useIntl();
    useEffect(() => {
@@ -131,9 +130,16 @@
            />,
        },
        {
            title: '公司',
            title: '机构',
            dataIndex: 'hostId$',
            valueType: 'text',
            filterDropdown: (props) => <LinkFilter
                name='hostId'
                major='host'
                {...props}
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
        },
        {
            title: '状态',
@@ -149,17 +155,22 @@
                    { label: '禁用', value: 0 },
                ]}
            />,
        },
        {
            title: '修改时间',
            dataIndex: 'updateTime$',
            valueType: 'text',
            filterDropdown: (props) => <DatetimeRangeFilter
                name='updateTime'
                {...props}
                actionRef={actionRef}
                setSearchParam={setSearchParam}
            />,
        },
        {
            title: '操作',
            dataIndex: 'option',
            width: '220px',
            width: 140,
            valueType: 'option',
            render: (_, record) => [
                <Button
@@ -208,8 +219,10 @@
                    columns={columns}
                    cardBordered
                    dateFormatter="string"
                    pagination={{ pageSize: 20 }}
                    search={false}
                    toolbar={{
                        multipleLine: true,
                        search: {
                            onSearch: (value) => {
                                setSearchParam(prevState => ({
@@ -278,9 +291,9 @@
                <FooterToolbar
                    extra={
                        <div>
                            <FormattedMessage id="pages.searchTable.chosen" defaultMessage="已选择" />
                            已选择
                            <a style={{ fontWeight: 600 }}>{selectedRows.length}</a>
                            <FormattedMessage id="pages.searchTable.item" defaultMessage="项" />
                            项
                        </div>
                    }
                >