提交 38791944 编写于 作者: wanhai_wu's avatar wanhai_wu

更新

上级 3dde90cd
......@@ -40,6 +40,8 @@ const Auth = () => {
const [total, setTotal] = useState<number | undefined>(0)
const [isModalOpen, setIsModalOpen] = useState(false);
let menuStatus = 0 // 菜单状态
const success = () => {
messageApi.open({
type: 'success',
......@@ -92,10 +94,28 @@ const Auth = () => {
const getHandle = () => {
( async ()=> {
setPidList([])
// 获取上级菜单
let msg = await getShowMenuList()
if (msg) {
setPidList(msg?.items)
let itemList = []
// // 新增具备上级
if (menuStatus === 0) {
itemList = [{
name: '父菜单',
options: [{ name: '无上级', id: 0,pid:0 }],
},{
name: '子菜单',
options: msg?.items || [],
}
]
setPidList(itemList)
} else {
setPidList(msg?.items || [])
}
// success()
// search()
}
......@@ -104,12 +124,20 @@ const Auth = () => {
const onGenderChange = (value: string) => {
debugger
if (status === 0) {
// 分组,如果是一级菜单
form.setFieldsValue({
pid: 0
})
} else {
const item = pidList[value.key - 1]
form.setFieldsValue({
pid: item.pid
})
console.log(form.getFieldsValue())
debugger
}
console.log()
};
const handleCancel = () => {
setIsModalOpen(false);
......@@ -184,6 +212,7 @@ const Auth = () => {
<a onClick={()=> {
showModal()
setStatus(1)
menuStatus = 1
getHandle()
form.setFieldsValue({
......@@ -197,6 +226,8 @@ const Auth = () => {
is_show:record.menu.is_show
});
debugger
}}>编辑菜单</a>
<a onClick={() =>{
delHandle(record.menu.id)
......@@ -229,7 +260,9 @@ const Auth = () => {
<Button type={'primary'} onClick={()=> {
formRef.current?.resetFields();
setStatus(0)
menuStatus = 0
showModal()
getHandle()
}}>
新增菜单
</Button>
......@@ -323,11 +356,11 @@ const Auth = () => {
allowClear
>
<Select.Option value={1}>菜单</Select.Option>
<Select.Option value={-1}>接口</Select.Option>
<Select.Option value={2}>接口</Select.Option>
</Select>
</Form.Item>
<Form.Item label={'是否启用'} name={'type'} rules={[{ required: true }]}>
<Form.Item label={'是否启用'} name={'is_show'} rules={[{ required: true }]}>
<Select
placeholder="请选择"
// onChange={onGenderChange}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册