#
luxiaotao1123
2024-02-22 b9efed08b3cf24f3f30b915b17557efd93195940
zy-asrs-flow/src/pages/system/role/index.jsx
@@ -10,6 +10,7 @@
import { PlusOutlined, ExportOutlined } from '@ant-design/icons';
import Http from '@/utils/http';
import Edit from './components/edit'
import Scope from './components/scope'
import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch'
import { statusMap } from '@/utils/enum-util'
@@ -87,6 +88,24 @@
    }
};
const handleScope = async (val) => {
    const hide = message.loading('正在分配');
    try {
        const resp = await Http.doPost('api/role/scope', val);
        if (resp.code === 200) {
            message.success('分配成功');
            return true;
        } else {
            message.error(resp.msg);
            return false;
        }
    } catch (error) {
        message.error('分配失败请重试!');
        return false;
    } finally {
        hide();
    }
};
const Main = () => {
    const formTableRef = useRef();
@@ -95,6 +114,8 @@
    const [modalVisible, setModalVisible] = useState(false);
    const [currentRow, setCurrentRow] = useState();
    const [searchParam, setSearchParam] = useState({});
    const [scopeModalVisible, setScopeModalVisible] = useState(false);
    useEffect(() => {
@@ -180,6 +201,16 @@
            width: 140,
            valueType: 'option',
            render: (_, record) => [
                <Button
                    type="link"
                    key="scope"
                    onClick={() => {
                        setScopeModalVisible(true);
                        setCurrentRow(record);
                    }}
                >
                    分配权限
                </Button>,
                <Button
                    type="link"
                    key="edit"
@@ -356,6 +387,30 @@
                }
                }
            />
            <Scope
                open={scopeModalVisible}
                values={currentRow || {}}
                onCancel={
                    () => {
                        setScopeModalVisible(false);
                        setCurrentRow(undefined);
                    }
                }
                onSubmit={async (values) => {
                    let ok = false;
                    if (values.id) {
                        ok = await handleScope({ ...values })
                    }
                    if (ok) {
                        setScopeModalVisible(false);
                        setCurrentRow(undefined);
                        if (actionRef.current) {
                            actionRef.current.reload();
                        }
                    }
                }}
            />
        </PageContainer>
    );
};