From b17ba5cdb06c079e5f676721e6e848c29ddeafca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= <3311118881@qq.com> Date: Fri, 18 Oct 2024 13:12:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E7=B1=BB=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Cate/index.tsx | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/pages/Cate/index.tsx b/src/pages/Cate/index.tsx index 2615059..62b3a97 100644 --- a/src/pages/Cate/index.tsx +++ b/src/pages/Cate/index.tsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; import { Cate } from '@/types/app/cate'; import { addCateDataAPI, delCateDataAPI, editCateDataAPI, getCateDataAPI, getCateListAPI } from '@/api/Cate'; import { DownOutlined } from '@ant-design/icons'; -import { Form, Input, Button, Tree, Modal, Spin, Dropdown, Card, MenuProps, Popconfirm, message } from 'antd'; +import { Form, Input, Button, Tree, Modal, Spin, Dropdown, Card, MenuProps, Popconfirm, message, Radio } from 'antd'; import Title from '@/components/Title'; import "./index.scss" @@ -12,6 +12,7 @@ const CatePage = () => { const [cate, setCate] = useState({} as Cate); const [list, setList] = useState([]); const [isMethod, setIsMethod] = useState<'create' | 'edit'>('create'); + const [isCateShow, setIsCateShow] = useState(false) const [form] = Form.useForm(); const getCateList = async () => { @@ -23,18 +24,22 @@ const CatePage = () => { const addCateData = (id: number) => { setIsMethod("create") setIsModelOpen(true); + setIsCateShow(false) form.resetFields(); - setCate({ ...cate, level: id }); + setCate({ ...cate, level: id, type: "cate" }); }; const editCateData = async (id: number) => { setIsMethod("edit") setLoading(true); setIsModelOpen(true); + const { data } = await getCateDataAPI(id); + setIsCateShow(data.type === "cate" ? false : true) setCate(data); + form.setFieldsValue(data); setLoading(false); }; @@ -48,6 +53,8 @@ const CatePage = () => { const submit = async () => { form.validateFields().then(async (values: Cate) => { + if (values.type === "cate") values.url = '/' + if (isMethod === "edit") { await editCateDataAPI({ ...cate, ...values }); message.success('🎉 修改分类成功'); @@ -67,6 +74,7 @@ const CatePage = () => { }; const closeModel = () => { + setIsCateShow(false) setIsMethod("create") setIsModelOpen(false); form.resetFields(); @@ -143,15 +151,25 @@ const CatePage = () => { - - - + { + isCateShow && + + + } - {/* TODO:有时间做个分类的类型,导航或者分类选项 */} + + { + const type = e.target.value + type === "nav" ? setIsCateShow(true) : setIsCateShow(false) + }}> + 分类 + 导航 + +