作者 lyh

gx

@@ -35,30 +35,23 @@ class NavLogic extends BaseLogic @@ -35,30 +35,23 @@ class NavLogic extends BaseLogic
35 */ 35 */
36 public function navSave() 36 public function navSave()
37 { 37 {
38 -// DB::beginTransaction();  
39 -// try {  
40 - if(!empty($this->param['location'])){  
41 - if($this->param['location'] == 'header'){  
42 - $this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID;  
43 - }  
44 - if($this->param['location'] == 'footer'){  
45 - $this->param['group_id'] = BNavGroup::DEFAULT_FOOTER_ID;  
46 - } 38 + if(!empty($this->param['location'])){
  39 + if($this->param['location'] == 'header'){
  40 + $this->param['group_id'] = BNavGroup::DEFAULT_HEADER_ID;
47 } 41 }
48 - $this->param['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : '');  
49 - $this->param['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : '');  
50 - if(isset($this->param['id']) && !empty($this->param['id'])){  
51 - $this->handleEditParam();//验证是否可编辑分类  
52 - $this->model->edit($this->param,['id'=>$this->param['id']]);  
53 - }else{  
54 - $this->param['project_id'] = $this->user['project_id'];  
55 - $this->model->add($this->param); 42 + if($this->param['location'] == 'footer'){
  43 + $this->param['group_id'] = BNavGroup::DEFAULT_FOOTER_ID;
56 } 44 }
57 -// DB::commit();  
58 -// }catch (\Exception $e){  
59 -// DB::rollBack();  
60 -// $this->fail('error');  
61 -// } 45 + }
  46 + $this->param['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : '');
  47 + $this->param['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : '');
  48 + if(isset($this->param['id']) && !empty($this->param['id'])){
  49 + $this->handleEditParam();//验证是否可编辑分类
  50 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  51 + }else{
  52 + $this->param['project_id'] = $this->user['project_id'];
  53 + $this->model->add($this->param);
  54 + }
62 //编辑菜单后,通知更新 55 //编辑菜单后,通知更新
63 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']); 56 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NAV, 'route'=>'all']);
64 return $this->success(); 57 return $this->success();
@@ -35,6 +35,7 @@ class NavRequest extends FormRequest @@ -35,6 +35,7 @@ class NavRequest extends FormRequest
35 // 'group_id' => ['required','integer'], 35 // 'group_id' => ['required','integer'],
36 'pid' => ['required','integer'], 36 'pid' => ['required','integer'],
37 'name' => ['required','max:100'], 37 'name' => ['required','max:100'],
  38 + 'url' => ['required'],
38 ]; 39 ];
39 return $rule; 40 return $rule;
40 } 41 }
@@ -49,6 +50,7 @@ class NavRequest extends FormRequest @@ -49,6 +50,7 @@ class NavRequest extends FormRequest
49 'pid.integer' => '上级选择错误', 50 'pid.integer' => '上级选择错误',
50 'name.required' => '名称必须', 51 'name.required' => '名称必须',
51 'name.max' => '名称不能超过100个字符', 52 'name.max' => '名称不能超过100个字符',
  53 + 'url.required' => '链接不能为空',
52 ]; 54 ];
53 } 55 }
54 } 56 }