From 3ff52ddd886f25081e065d21d58c9a225c6d15a6 Mon Sep 17 00:00:00 2001 From: Administrator <2951979767@qq.com> Date: Fri, 23 Feb 2018 17:51:19 +0800 Subject: [PATCH] fix add menu bugs --- src/assets/js/app/setting_menu.js | 1 + src/builder/TableBuilder.php | 2 +- src/controller/Setting.php | 103 +++++++++++++----------------- src/view/form/include/text.html | 2 +- 4 files changed, 49 insertions(+), 59 deletions(-) diff --git a/src/assets/js/app/setting_menu.js b/src/assets/js/app/setting_menu.js index ecf4d66..d57d5d3 100644 --- a/src/assets/js/app/setting_menu.js +++ b/src/assets/js/app/setting_menu.js @@ -101,6 +101,7 @@ $(document).ready(function(){ $.post(icesConfig.url + "/icesui/setting/doMenu", {data: json}, function(data){ if(data.code == 1){ toastr.success(data.msg); + location.reload(); }else{ toastr.error(data.msg); } diff --git a/src/builder/TableBuilder.php b/src/builder/TableBuilder.php index 9750450..88d3aef 100755 --- a/src/builder/TableBuilder.php +++ b/src/builder/TableBuilder.php @@ -43,7 +43,7 @@ class TableBuilder extends IBuilder * @param string $defaultcontent 默认的内容 false '' '' * @return \icesui\Builder\TableBuilder */ - public function addTableColmun($title, $name = null, $sortble = true, $render = null, $width = null, $class = null, $defaultcontent = null){ + public function addTableColmun($title, $name = null, $sortble = false, $render = null, $width = null, $class = null, $defaultcontent = null){ $temp = [ 'title' => $title, 'data' => $name, diff --git a/src/controller/Setting.php b/src/controller/Setting.php index fb297c2..1ed9a23 100755 --- a/src/controller/Setting.php +++ b/src/controller/Setting.php @@ -123,6 +123,46 @@ public function menu($id = 0){ ->render("setting/menu"); } + protected function _getAllMenu(AuthRule $authRule, $parentId, $val, $listOrder, &$saveAll){ + if(empty($val['id'])){ + $pid = $authRule->insertGetId([ + 'parentid' => $parentId, + 'status' => $val['status'], + 'type' => $val['type'], + 'icon' => $val['icon'], + 'name' => $val['name'], + 'text' => $val['text'], + 'list_order' => $listOrder + ]); + }else{ + if(!empty($val['id'])){ + $saveAll[] = [ + 'id' => $val['id'], + 'parentid' => $parentId, + 'status' => $val['status'], + 'type' => $val['type'], + 'icon' => $val['icon'], + 'name' => $val['name'], + 'text' => $val['text'], + 'list_order' => $listOrder + ]; + $pid = $val['id']; + }else{ + $saveAll[] = [ + 'parentid' => $parentId, + 'status' => $val['status'], + 'type' => $val['type'], + 'icon' => $val['icon'], + 'name' => $val['name'], + 'text' => $val['text'], + 'list_order' => $listOrder + ]; + $pid = $parentId; + } + } + return $pid; + } + public function doMenu(){ $post = input('post.data'); $data = json_decode($post, true); @@ -142,66 +182,15 @@ public function doMenu(){ $parentId = $v['id']; $listOrder++; foreach($v['children'] as $j => $val){ - if(empty($val['id'])){ - $pid = $authRule->insertGetId([ - 'parentid' => $parentId, - 'status' => $val['status'], - 'type' => $val['type'], - 'icon' => $val['icon'], - 'name' => $val['name'], - 'text' => $val['text'], - 'list_order' => $listOrder - ]); - }else{ - $saveAll[] = [ - 'id' => $val['id'], - 'parentid' => $parentId, - 'status' => $val['status'], - 'type' => $val['type'], - 'icon' => $val['icon'], - 'name' => $val['name'], - 'text' => $val['text'], - 'list_order' => $listOrder - ]; - $pid = $val['id']; - } + $pid = $this->_getAllMenu($authRule, $parentId, $val, $listOrder, $saveAll); $listOrder++; foreach($val['children'] as $k => $value){ - if(empty($val['id'])){ - $authRule->insertGetId([ - 'parentid' => $pid, - 'status' => $value['status'], - 'type' => $value['type'], - 'icon' => $value['icon'], - 'name' => $value['name'], - 'text' => $value['text'], - 'list_order' => $listOrder - ]); - }else{ - if(!empty($value['id'])){ - $saveAll[] = [ - 'id' => $value['id'], - 'parentid' => $pid, - 'status' => $value['status'], - 'type' => $value['type'], - 'icon' => $value['icon'], - 'name' => $value['name'], - 'text' => $value['text'], - 'list_order' => $listOrder - ]; - }else{ - $saveAll[] = [ - 'parentid' => $pid, - 'status' => $value['status'], - 'type' => $value['type'], - 'icon' => $value['icon'], - 'name' => $value['name'], - 'text' => $value['text'], - 'list_order' => $listOrder - ]; - } - } + $_pid = $this->_getAllMenu($authRule, $pid, $value, $listOrder, $saveAll); $listOrder++; + foreach($value['children'] as $l => $values){ + $__pid = $this->_getAllMenu($authRule, $_pid, $values, $listOrder, $saveAll); + $listOrder++; + } } } } diff --git a/src/view/form/include/text.html b/src/view/form/include/text.html index 54cf36b..4b8fd64 100755 --- a/src/view/form/include/text.html +++ b/src/view/form/include/text.html @@ -1,4 +1,4 @@
- +