角色绑定增加提示语
parent
ad68d57037
commit
b99e0542f4
|
|
@ -1,20 +1,20 @@
|
|||
import useUrlState from "@ahooksjs/use-url-state";
|
||||
import { ApiOutlined } from "@ant-design/icons";
|
||||
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||
import { Button, Form, message, Modal, Space, Tabs, Tag } from "antd";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import {ApiOutlined} from "@ant-design/icons";
|
||||
import {Connect} from "@cqsjjb/jjb-dva-runtime";
|
||||
import {Button, Form, message, Modal, Space, Tabs, Tag} from "antd";
|
||||
import {useEffect, useRef, useState} from "react";
|
||||
import FormBuilder from "zy-react-library/components/FormBuilder";
|
||||
import AddIcon from "zy-react-library/components/Icon/AddIcon";
|
||||
import Page from "zy-react-library/components/Page";
|
||||
import Table from "zy-react-library/components/Table";
|
||||
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
|
||||
import {FORM_ITEM_RENDER_ENUM} from "zy-react-library/enum/formItemRender";
|
||||
import useTable from "zy-react-library/hooks/useTable";
|
||||
import { getLabelName, getMatchedItems } from "zy-react-library/utils";
|
||||
import { NS_APP_MENU } from "~/enumerate/namespace";
|
||||
import {getLabelName, getMatchedItems} from "zy-react-library/utils";
|
||||
import {NS_APP_MENU} from "~/enumerate/namespace";
|
||||
|
||||
const MENU_TYPE_ENUM = [
|
||||
{ bianma: 1, name: "菜单" },
|
||||
{ bianma: 2, name: "按钮" },
|
||||
{bianma: 1, name: "菜单"},
|
||||
{bianma: 2, name: "按钮"},
|
||||
];
|
||||
|
||||
function Menu(props) {
|
||||
|
|
@ -32,18 +32,18 @@ function Menu(props) {
|
|||
}, {
|
||||
navigateMode: "replace",
|
||||
});
|
||||
const { tableProps, getData } = useTable(props["appMenuListTree"], {
|
||||
params: { eqMenuAttribution: urlState.menuAttribution },
|
||||
const {tableProps, getData} = useTable(props["appMenuListTree"], {
|
||||
params: {eqMenuAttribution: urlState.menuAttribution},
|
||||
usePagination: false,
|
||||
manual: true,
|
||||
});
|
||||
|
||||
const getMenuAppByTenantId = async () => {
|
||||
const { data } = await props["appMenuGetMenuAppByTenantId"]();
|
||||
const {data} = await props["appMenuGetMenuAppByTenantId"]();
|
||||
setMenuAttribution(data);
|
||||
const menuAttribution = data?.[0]?.menuAttribution;
|
||||
const menuAttributionName = data?.[0]?.menuAttributionName;
|
||||
setUrlState({ menuAttribution, menuAttributionName });
|
||||
setUrlState({menuAttribution, menuAttributionName});
|
||||
menuAttribution && getData();
|
||||
};
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ function Menu(props) {
|
|||
okText: "确定",
|
||||
cancelText: "取消",
|
||||
onOk: async () => {
|
||||
const { success } = await props["appMenuDelete"]({ id });
|
||||
const {success} = await props["appMenuDelete"]({id});
|
||||
if (success) {
|
||||
message.success("删除成功");
|
||||
getData();
|
||||
|
|
@ -78,7 +78,7 @@ function Menu(props) {
|
|||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={(<AddIcon />)}
|
||||
icon={(<AddIcon/>)}
|
||||
onClick={() => {
|
||||
setAddModalVisible(true);
|
||||
setParentId(0);
|
||||
|
|
@ -91,7 +91,7 @@ function Menu(props) {
|
|||
<Button
|
||||
type="primary"
|
||||
ghost
|
||||
icon={(<ApiOutlined />)}
|
||||
icon={(<ApiOutlined/>)}
|
||||
onClick={() => {
|
||||
setRoleBindingModalVisible(true);
|
||||
}}
|
||||
|
|
@ -105,7 +105,7 @@ function Menu(props) {
|
|||
headerTitle={(
|
||||
<Tabs
|
||||
activeKey={urlState.menuAttribution}
|
||||
items={menuAttribution.map(item => ({ key: item.menuAttribution, label: item.menuAttributionName }))}
|
||||
items={menuAttribution.map(item => ({key: item.menuAttribution, label: item.menuAttributionName}))}
|
||||
onChange={(event) => {
|
||||
setUrlState({
|
||||
menuAttribution: event,
|
||||
|
|
@ -116,9 +116,9 @@ function Menu(props) {
|
|||
/>
|
||||
)}
|
||||
columns={[
|
||||
{ title: "名称", dataIndex: "menuName" },
|
||||
{ title: "路径", dataIndex: "menuUrl" },
|
||||
{ title: "标识", dataIndex: "menuPerms" },
|
||||
{title: "名称", dataIndex: "menuName"},
|
||||
{title: "路径", dataIndex: "menuUrl"},
|
||||
{title: "标识", dataIndex: "menuPerms"},
|
||||
{
|
||||
title: "类型",
|
||||
dataIndex: "menuType",
|
||||
|
|
@ -214,7 +214,7 @@ const AddModalComponent = (props) => {
|
|||
const [form] = Form.useForm();
|
||||
|
||||
const getData = async () => {
|
||||
const { data } = await props["appMenuInfo"]({ id: props.id });
|
||||
const {data} = await props["appMenuInfo"]({id: props.id});
|
||||
form.setFieldsValue(data);
|
||||
};
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ const AddModalComponent = (props) => {
|
|||
}, [props.id]);
|
||||
|
||||
const onSubmit = async (values) => {
|
||||
const { success } = await props[props.id ? "appMenuUpdate" : "appMenuAdd"]({
|
||||
const {success} = await props[props.id ? "appMenuUpdate" : "appMenuAdd"]({
|
||||
...values,
|
||||
id: props.id,
|
||||
parentId: props.parentId,
|
||||
|
|
@ -251,7 +251,7 @@ const AddModalComponent = (props) => {
|
|||
<FormBuilder
|
||||
showActionButtons={false}
|
||||
span={24}
|
||||
labelCol={{ span: 6 }}
|
||||
labelCol={{span: 6}}
|
||||
loading={props.appMenu.appMenuLoading}
|
||||
form={form}
|
||||
onFinish={onSubmit}
|
||||
|
|
@ -270,12 +270,12 @@ const AddModalComponent = (props) => {
|
|||
name: "menuType",
|
||||
label: "类型",
|
||||
render: FORM_ITEM_RENDER_ENUM.RADIO,
|
||||
items: props.parentId === 0 ? getMatchedItems({ list: MENU_TYPE_ENUM, value: [1] }) : MENU_TYPE_ENUM,
|
||||
items: props.parentId === 0 ? getMatchedItems({list: MENU_TYPE_ENUM, value: [1]}) : MENU_TYPE_ENUM,
|
||||
},
|
||||
{ name: "menuName", label: "名称" },
|
||||
{ name: "menuUrl", label: "路径", useConstraints: false },
|
||||
{ name: "menuPerms", label: "标识", useConstraints: false },
|
||||
{ name: "sort", label: "排序", onlyForLabel: true },
|
||||
{name: "menuName", label: "名称"},
|
||||
{name: "menuUrl", label: "路径", useConstraints: false},
|
||||
{name: "menuPerms", label: "标识", useConstraints: false},
|
||||
{name: "sort", label: "排序", onlyForLabel: true},
|
||||
]}
|
||||
/>
|
||||
</Modal>
|
||||
|
|
@ -287,14 +287,14 @@ const RoleBindingModalComponent = (props) => {
|
|||
|
||||
const selectedRowsRef = useRef([]);
|
||||
|
||||
const { tableProps } = useTable(props["systemPermsGroupsList"], {
|
||||
const {tableProps} = useTable(props["systemPermsGroupsList"], {
|
||||
useStorageQueryCriteria: false,
|
||||
});
|
||||
|
||||
const getData = async () => {
|
||||
const { data } = await props["appMenuGetMenuRoleByMenuAttribution"]({ menuAttribution: props.menuAttribution });
|
||||
const {data} = await props["appMenuGetMenuRoleByMenuAttribution"]({menuAttribution: props.menuAttribution});
|
||||
setSelectedRowKeys(data.map(item => item.roleId));
|
||||
selectedRowsRef.current = data.map(item => ({ id: item.roleId, roleName: item.roleName }));
|
||||
selectedRowsRef.current = data.map(item => ({id: item.roleId, roleName: item.roleName}));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -302,10 +302,10 @@ const RoleBindingModalComponent = (props) => {
|
|||
}, []);
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { success } = await props["appMenuGetMenuRoleByMenuAttributionSave"]({
|
||||
const {success} = await props["appMenuGetMenuRoleByMenuAttributionSave"]({
|
||||
menuAttribution: props.menuAttribution,
|
||||
menuAttributionName: props.menuAttributionName,
|
||||
roleList: selectedRowsRef.current.map(item => ({ roleId: item.id, roleName: item.roleName })),
|
||||
roleList: selectedRowsRef.current.map(item => ({roleId: item.id, roleName: item.roleName})),
|
||||
});
|
||||
if (success) {
|
||||
message.success("保存成功");
|
||||
|
|
@ -323,6 +323,7 @@ const RoleBindingModalComponent = (props) => {
|
|||
onOk={onSubmit}
|
||||
confirmLoading={props.appMenu.appMenuLoading}
|
||||
>
|
||||
<div style={{fontSize: 12, color: "red", marginBottom: 10}}>注:取消勾选会清空角色的APP使用权限,请谨慎操作!</div>
|
||||
<Table
|
||||
rowSelection={{
|
||||
preserveSelectedRowKeys: true,
|
||||
|
|
@ -335,7 +336,7 @@ const RoleBindingModalComponent = (props) => {
|
|||
options={false}
|
||||
disabledResizer={true}
|
||||
columns={[
|
||||
{ title: "角色名称(权限组)", dataIndex: "roleName" },
|
||||
{title: "角色名称(权限组)", dataIndex: "roleName"},
|
||||
]}
|
||||
{...tableProps}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue