<?php

namespace app\admin\controller;
use think\Controller;
use think\Db;
class  Menu extends Common
{
public function lst()
{
$list=Db::query("select * from sys_menu ");
$this->assign('list',$list);
return $this->fetch();
}
public function add()
{
if (request()->isPost()){
$data = input('post.');
if(db('sys_menu')->insert($data)){
return $this->success('ok','lst','',1);
}
else {
return $this->error('false',null,'',1);
}
return ;
}
return $this->fetch();
}
public function edit(){
$id=input('id');
$menus=db('sys_menu')->find($id);
if(request()->ispost()){
$data=[
'id'=>input('id'),
'mc'=>input('mc'),
'ztjcid'=>input('ztjcid'),
'hascac'=>input('hascac'),
'coordinate'=>input('coordinate'),
'voltagegrade'=>input('voltagegrade'),
'scale'=>input('scale'),
'note'=>input('note'),
'svgurl'=>input('svgurl'),
];
$save=db('sys_menu')->update($data);
if($save !== false){
$this->success('修改菜单成功！','lst','',1);
}else{
$this->error('修改菜单失败！',null,'',1);
}
return;
}
$this->assign('menus',$menus);
return $this->fetch();
}
public function del(){
$id=input('id');
if(db('sys_menu')->delete(input('id'))){
$this->success('删除菜单成功！','lst','',1);
}else{
$this->error('删除菜单失败！',null,'',1);
}
}
}
?>