/**
  * @introduction: 修改权限规则
  * @author: 杨陈鹏
  * @date: 2016/3/30 16:04
  * @email: yangchenpeng@cdlinglu.com
  */
 public function update()
 {
     //获取模型
     $logic = D('AuthRule', 'Logic');
     //获取数据
     $data = I('post.data');
     $this->pid = $pid = $data['pid'];
     $id = $data['id'];
     unset($data['pid']);
     unset($data['id']);
     if ($data) {
         if (!$data['ismenu']) {
             $data['ismenu'] = 0;
         }
         if (!$data['type']) {
             $data['type'] = 0;
         }
         if ($result = $logic::update(['id' => $id], $data)) {
             $result['data']['pid'] = $pid;
             $this->ajaxReturn($result);
         } else {
             $this->ajaxReturn(['code' => 300, 'msg' => '保存失败']);
         }
     } else {
         if (!$id) {
             $this->ajaxReturn(['code' => 300, 'msg' => '参数错误']);
         }
         $this->info = $info = $logic::getOneData(['id' => $id], 'id,pid,title,name,type,ismenu,condition,status,icon');
         $rules = $logic::getData('', '0,100000', 'id,title,pid');
         $tree = new \Org\Util\Tree();
         $tree->init($rules);
         $this->rules = $tree->create(0, '<option \\$selected value=\'$id\'>$spacer $title</option>', $info['pid']);
         $this->display();
     }
 }