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

更新

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