Skip to content

Commit

Permalink
fix add menu bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
yirius committed Feb 23, 2018
1 parent 158ce2d commit 3ff52dd
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/assets/js/app/setting_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/builder/TableBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
103 changes: 46 additions & 57 deletions src/controller/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/view/form/include/text.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group {$_icesRender['config']['class']}">
<label class="control-label" for="ices{$_icesRender['name']}">{$_icesRender['title']}</label>
<input type="text" class="form-control {$_icesRender['config']['inputclass']}" name="{$_icesRender['name']}" id="ices{$_icesRender['name']}" value="{$_icesRender['value']}" {if $_icesRender['config']['readonly']}readonly="readonly"{/if} />
<input type="text" class="form-control {$_icesRender['config']['inputclass']}" name="{$_icesRender['name']}" id="ices{$_icesRender['name']}" value="{$_icesRender['value']}" placeholder="{$_icesRender['config']['placeholder']}" {if $_icesRender['config']['readonly']}readonly="readonly"{/if} />
</div>

0 comments on commit 3ff52dd

Please sign in to comment.