菜单接口

This commit is contained in:
red-deng-deng 2021-11-22 17:20:52 +08:00
parent dea38aa840
commit bbfdd35fd4
6 changed files with 59 additions and 19 deletions

View File

@ -389,6 +389,11 @@ export const postCreateMenu = (data) => {
export const putmodifyMenu = (id,data) => { export const putmodifyMenu = (id,data) => {
return req('put', baseurl + "/auth/menu/"+id,data) return req('put', baseurl + "/auth/menu/"+id,data)
} }
//删除菜单
export const delMenu = (id) => {
return req('delete', baseurl + "/auth/menu/"+id)
}
//获取落地页下拉菜单 //获取落地页下拉菜单

View File

@ -17,5 +17,5 @@
border: none!important; border: none!important;
} }
.zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"]{ .zent-dialog-r-anchor .zent-dialog-r[data-zv="9.11.0"]{
margin-top: -180px; margin-top: -100px;
} }

View File

@ -17,6 +17,12 @@ export default class leftnav extends React.Component{
} }
} }
onselect=(data, target)=>{ onselect=(data, target)=>{
console.log(target);
let doms=document.querySelectorAll('.leftTree .zent-tree-content');
doms.forEach(item=>{
item.style.background='#fff';
});
target.style.background='#A8C3F0';
this.setState({ this.setState({
selectdom: data selectdom: data
}); });
@ -24,8 +30,6 @@ export default class leftnav extends React.Component{
} }
onCheck = (checked, helpInfo) => { onCheck = (checked, helpInfo) => {
console.log(88,helpInfo);
this.setState({ this.setState({
checkedKeys: checked checkedKeys: checked
}); });

View File

@ -2,35 +2,63 @@ import ReactDOM from 'react-dom';
import React, { Component } from 'react'; import React, { Component } from 'react';
import "./main.less" import "./main.less"
import "../../../../assets/comm.css" import "../../../../assets/comm.css"
import { Card,Button,Notify,Dialog} from 'zent'; import { Card,Button,Notify,Dialog,Sweetalert} from 'zent';
import Leftnav from "../leftnav/leftnav" import Leftnav from "../leftnav/leftnav"
import Menuright from "../menuright/menuright" import Menuright from "../menuright/menuright"
import Menubody from "../menubody/menubody" import Menubody from "../menubody/menubody"
import {postCreateMenu,handelResponse} from "../../../../assets/api.js" import {postCreateMenu,handelResponse,delMenu} from "../../../../assets/api.js"
export default class menu extends React.Component{ export default class menu extends React.Component{
constructor(props){ constructor(props){
super(props) super(props)
this.state={ this.state={
visible:false, visible:false,
dialogtitle:'', dialogtitle:'',
selectdom:{} selectdom:{},
fid:0,
} }
} }
addchildmenu(){ addchildmenu(){
// 实现父子组件的双向绑定 // 实现父子组件的双向绑定
let item=this.refs.navitem.state.selectdom; let item=this.refs.navitem.state.selectdom;
if(item.id){ if(item.id){
Notify.clear(); this.setState({dialogtitle:'新建子菜单',visible:true,fid:item.id});
this.setState({dialogtitle:'新建子菜单',visible:true});
}else{ }else{
Notify.clear(); Notify.clear();
Notify.warn('请先点击选择一个菜单'); Notify.warn('请先点击选择一个菜单');
} }
} }
addmenu(){ addmenu(){
this.setState({dialogtitle:'添加一级菜单',visible:true}); this.setState({dialogtitle:'添加一级菜单',visible:true,fid:0});
}
//删除菜单
delmenuBtn(){
let item=this.refs.navitem.state.selectdom;
if(item.id){
Sweetalert.confirm({
type:'warning',
closeBtn:true,
title:'确认操作',
content: <p>是否删除<b>[{item.title}]</b></p>,
onConfirm:()=>{
delMenu(item.id).then(res=>{
handelResponse(res,(response,msg)=>{
Notify.clear();
Notify.success(msg);
window.history.go(0);
},(err)=>{
})
}).catch(err=>{
});
},
onCancel: this.onCancel,
className:'questModal',
parentComponent: this
});
}else{
Notify.clear();
Notify.warn('请先点击选择一个菜单');
}
} }
setVisible = visible => { setVisible = visible => {
this.setState({ visible }); this.setState({ visible });
@ -41,7 +69,7 @@ export default class menu extends React.Component{
let self=this; let self=this;
if(menuFlag){ if(menuFlag){
let data=this.refs.menubody.state.model; let data=this.refs.menubody.state.model;
data.fid=0; data.fid=this.state.fid;
postCreateMenu(data).then(res=>{ postCreateMenu(data).then(res=>{
handelResponse(res,(response,msg)=>{ handelResponse(res,(response,msg)=>{
Notify.clear(); Notify.clear();
@ -52,6 +80,7 @@ export default class menu extends React.Component{
}) })
} }
} }
//获取点击的值 //获取点击的值
getMenuInfo(e){ getMenuInfo(e){
this.setState({selectdom:e}); this.setState({selectdom:e});
@ -62,7 +91,8 @@ export default class menu extends React.Component{
<Card style={{ width:'100%' }}> <Card style={{ width:'100%' }}>
<p className="menuBtn"> <p className="menuBtn">
<Button type="primary" icon="plus" onClick={this.addchildmenu.bind(this)}>新建子菜单</Button> <Button type="primary" icon="plus" onClick={this.addchildmenu.bind(this)}>新建子菜单</Button>
<Button type="info" onClick={this.addmenu.bind(this)}>添加一级菜单</Button> <Button type="warn" onClick={this.addmenu.bind(this)}>添加一级菜单</Button>
<Button type="danger" onClick={this.delmenuBtn.bind(this)}>删除菜单</Button>
</p> </p>
</Card> </Card>
<div className="menu-body"> <div className="menu-body">
@ -80,6 +110,7 @@ export default class menu extends React.Component{
</div> </div>
{/* 弹出框 */} {/* 弹出框 */}
<Dialog <Dialog
style={{width:'50%'}}
visible={this.state.visible} visible={this.state.visible}
className="questModal" className="questModal"
onClose={() => this.setVisible(false)} onClose={() => this.setVisible(false)}
@ -92,7 +123,7 @@ export default class menu extends React.Component{
} }
title={this.state.dialogtitle} title={this.state.dialogtitle}
> >
<Menubody ref="menubody" /> <Menubody ref="menubody" fid={this.state.fid}/>
</Dialog> </Dialog>
</div> </div>
) )

View File

@ -108,13 +108,13 @@ export default class adduserinfo extends React.Component{
<FormItem required={false} labelname="是否显示"> <FormItem required={false} labelname="是否显示">
<RadioGroup onChange={this.statusChange} value={this.state.model.status}> <RadioGroup onChange={this.statusChange} value={this.state.model.status}>
<RadioButton value="1" ></RadioButton> <RadioButton value="1" ></RadioButton>
<RadioButton value="5" ></RadioButton> <RadioButton value="0" ></RadioButton>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem required={false} labelname="是否验证登陆"> <FormItem required={false} labelname="是否验证登陆">
<RadioGroup onChange={this.authChange} value={this.state.model.auth}> <RadioGroup onChange={this.authChange} value={this.state.model.auth}>
<RadioButton value="1" ></RadioButton> <RadioButton value="1" ></RadioButton>
<RadioButton value="5" ></RadioButton> <RadioButton value="0" ></RadioButton>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem required={false} labelname="菜单图标"> <FormItem required={false} labelname="菜单图标">

View File

@ -58,7 +58,6 @@ methodsonChange = e => {
} }
modifysubmit(){ modifysubmit(){
console.log(this.state.model);
let modifyFlag=this.refs.form1.validator(); let modifyFlag=this.refs.form1.validator();
let self=this; let self=this;
@ -75,6 +74,7 @@ methodsonChange = e => {
handelResponse(res,(response,msg)=>{ handelResponse(res,(response,msg)=>{
Notify.clear(); Notify.clear();
Notify.success(msg); Notify.success(msg);
window.history.go(0);
},(err)=>{ },(err)=>{
}) })
@ -175,13 +175,13 @@ methodsonChange = e => {
<FormItem required={false} labelname="是否显示"> <FormItem required={false} labelname="是否显示">
<RadioGroup onChange={this.statusChange} value={this.state.model.status}> <RadioGroup onChange={this.statusChange} value={this.state.model.status}>
<RadioButton value={1} ></RadioButton> <RadioButton value={1} ></RadioButton>
<RadioButton value={5} ></RadioButton> <RadioButton value={0} ></RadioButton>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem required={false} labelname="是否验证登陆"> <FormItem required={false} labelname="是否验证登陆">
<RadioGroup onChange={this.authChange} value={this.state.model.auth}> <RadioGroup onChange={this.authChange} value={this.state.model.auth}>
<RadioButton value={1} ></RadioButton> <RadioButton value={1} ></RadioButton>
<RadioButton value={5} ></RadioButton> <RadioButton value={0} ></RadioButton>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem required={false} labelname="菜单图标"> <FormItem required={false} labelname="菜单图标">