| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | 
							- <?php
 
- namespace app\admin\controller;
 
- use think\Db;
 
- class AssetCate extends Auth
 
- {
 
-     public function index(){
 
-         $tree = model('AssetCate')->showAllTree();
 
-         $this->assign('tree',$tree);
 
-         return $this->fetch();
 
-     }
 
-     /**
 
-      * 新增
 
-      */
 
-     public function add($pid=0){
 
-         if(request()->isPost()){
 
-             $res = model('AssetCate')->addSave();
 
-             if($res){
 
-                 $this->success('操作成功',url('index'));
 
-             }else{
 
-                 $this->error(model('AssetCate')->getError());
 
-             }
 
-         }else{
 
-             $this->assign('pid',$pid);
 
-             return $this->fetch();
 
-         }
 
-     }
 
-     /**
 
-      * 编辑
 
-      */
 
-     public function edit($id=0){
 
-         if(request()->isPost()){
 
-             $res = model('AssetCate')->editSave();
 
-             if($res){
 
-                 $this->success('操作成功',url('index'));
 
-             }else{
 
-                 $this->error(model('AssetCate')->getError());
 
-             }
 
-         }else{
 
-             $info = db('asset_cate')->where('id',$id)->find();
 
-             $this->assign('info',$info);
 
-             return $this->fetch();
 
-         }
 
-     }
 
-     /**
 
-      * 删除记录
 
-      * @param int $id
 
-      */
 
-     public function del($id=0){
 
-         if(!$id){
 
-             $this->error('参数错误');
 
-         }
 
-         // 检查是否有子级
 
-         $ret = Db::name('asset_cate')->where('parent_id',$id)->find();
 
-         if($ret){
 
-             $this->error('有子级不能删除');
 
-         }
 
-         $res = Db::name('asset_cate')->where('id',$id)->delete();
 
-         if($res){
 
-             $this->success('删除成功');
 
-         }else{
 
-             $this->error('删除失败');
 
-         }
 
-     }
 
- }
 
 
  |