diff --git a/web/src/pages/admin/setting/SettingMenu.js b/web/src/pages/admin/setting/SettingMenu.js index 7218b00..c2cd43d 100644 --- a/web/src/pages/admin/setting/SettingMenu.js +++ b/web/src/pages/admin/setting/SettingMenu.js @@ -1,6 +1,18 @@ import React from "react"; import { useNavigate } from "react-router-dom"; -import { Row, Col, Space, Button, Tabs, message } from "antd"; +import { + Row, + Col, + Space, + Button, + Tabs, + Modal, + Form, + Input, + InputNumber, + Select, + message, +} from "antd"; import { PlusOutlined, MenuOutlined, NumberOutlined } from "@ant-design/icons"; import ApiClient from "../../../services/client"; import CONSTANTS from "../../../constants"; @@ -8,9 +20,12 @@ import SettingMenuTable from "./SettingMenuTable"; const SettingMenu = () => { const [isLoading, setIsLoading] = React.useState(true); - + const [isModalOpen, setIsModalOpen] = React.useState(false); const [tabItems, setTabItems] = React.useState([]); + const [menuTypes, setMenuTypes] = React.useState([]); + const [currentTab, setCurrentTab] = React.useState("admin"); const [messageApi, contextHolder] = message.useMessage(); + const [newForm] = Form.useForm(); const navigate = useNavigate(); React.useEffect(() => { @@ -33,6 +48,7 @@ const SettingMenu = () => { ), }) ); + setMenuTypes(Object.keys(response.data?.data)); setTabItems(data); } else if ( response.data?.code === CONSTANTS.ERRCODE.ErrAuthNoLogin || @@ -60,6 +76,30 @@ const SettingMenu = () => { getAllMenus(); }, [isLoading, messageApi, navigate]); + const handleModalOk = async () => { + newForm + .validateFields() + .then((row) => { + ApiClient.post("/admin/setting/menu", row) + .then((response) => { + if (response.data?.code === 0) { + messageApi.success("新增菜单项成功"); + setIsModalOpen(false); + setIsLoading(true); + } else { + messageApi.error(response.data?.message); + } + }) + .catch((error) => { + console.log(error); + messageApi.error("新增接口失败,请稍后重试!"); + }); + }) + .catch((info) => { + console.log("Validate Failed:", info); + }); + }; + return ( <> @@ -76,7 +116,7 @@ const SettingMenu = () => { float: "right", }} icon={} - // onClick={() => setIsModalOpen(true)} + onClick={() => setIsModalOpen(true)} > 添加菜单 @@ -84,9 +124,90 @@ const SettingMenu = () => { - + { + setCurrentTab(key); + // console.log("change to:", currentTab); + }} + /> + setIsModalOpen(false)} + okText="确认添加" + cancelText="取消" + > +
+ + + + + + + + + + + + + + + +
+
{contextHolder} ); diff --git a/web/src/pages/admin/setting/SettingMenuTable.js b/web/src/pages/admin/setting/SettingMenuTable.js index 24f681d..58b047a 100644 --- a/web/src/pages/admin/setting/SettingMenuTable.js +++ b/web/src/pages/admin/setting/SettingMenuTable.js @@ -22,7 +22,7 @@ const SettingMenuTable = ({ menus, isLoading, setIsLoading }) => { title: "菜单名称", dataIndex: "label", width: 360, - fixed: "left", + // fixed: "left", render: (text, record) => { return isEditing(record) ? ( <> @@ -134,7 +134,7 @@ const SettingMenuTable = ({ menus, isLoading, setIsLoading }) => { { title: "排序", dataIndex: "order", - width: 100, + width: 110, render: (text, record) => { return isEditing(record) ? ( { { pattern: /^[0-9]+$/, message: "排序只能是数字" }, ]} > - + ) : ( {text} @@ -250,12 +250,15 @@ const SettingMenuTable = ({ menus, isLoading, setIsLoading }) => { }; return ( <> -
+ {contextHolder}