恢复菜单分配关联勾选

dev
曾超新 5 years ago
parent 7cbd42849d
commit 654a129048
  1. 33
      frontend/views/permissions/permission.php

@ -12,13 +12,13 @@ use \common\libs\MyLib;
<form id="theFrm"> <form id="theFrm">
<input type="hidden" name="group_id" value="<?=$permissions_id?>"> <input type="hidden" name="group_id" value="<?=$permissions_id?>">
<?php foreach($menu_items as $item) { ?> <?php foreach($menu_items as $item) { ?>
<div class="col-sm-2"> <div class="col-md-2">
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading"> <div class="panel-heading">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-md-12">
<label class="i-checks"> <label class="i-checks">
<input type="checkbox" name="menu_ids[]" value="<?=$item->id?>" <?=in_array($item->id, $menu_ids)?'checked':''?>><i></i> <?=$item->name?> <input type="checkbox" class="parent_checkbox" name="menu_ids[]" value="<?=$item->id?>" <?=in_array($item->id, $menu_ids)?'checked':''?>><i></i> <?=$item->name?>
</label> </label>
</div> </div>
</div> </div>
@ -26,9 +26,9 @@ use \common\libs\MyLib;
<div class="panel-body"> <div class="panel-body">
<?php foreach($item->menus as $sub_item) { ?> <?php foreach($item->menus as $sub_item) { ?>
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-md-12">
<label class="i-checks"> <label class="i-checks">
<input type="checkbox" name="menu_ids[]" value="<?=$sub_item->id?>" <?=in_array($sub_item->id, $menu_ids)?'checked':''?>><i></i> <?=$sub_item->name?> <input type="checkbox" class="sub_checkbox" name="menu_ids[]" value="<?=$sub_item->id?>" <?=in_array($sub_item->id, $menu_ids)?'checked':''?>><i></i> <?=$sub_item->name?>
</label> </label>
</div> </div>
</div> </div>
@ -40,7 +40,7 @@ use \common\libs\MyLib;
</form> </form>
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-5 col-sm-offset-5"> <div class="col-md-5 col-md-offset-5">
<button class="btn btn-primary btn-save" type="button"> <button class="btn btn-primary btn-save" type="button">
<strong>保 存</strong> <strong>保 存</strong>
</button> </button>
@ -67,6 +67,27 @@ use \common\libs\MyLib;
} }
},'json'); },'json');
}); });
//处理自动选择功能
$('.parent_checkbox').click(function() {
var checked = $(this).prop('checked');
var subs = $(this).parent().parent().parent().parent().next().find('.sub_checkbox');
for(var i = 0; i < subs.length; i++) {
if(checked) {
$(subs[i]).prop('checked', 'checked');
} else {
$(subs[i]).prop('checked', '');
}
}
});
$('.sub_checkbox').click(function() {
var checked = $(this).prop('checked');
var subs = $(this).parent().parent().parent().parent().prev().find('.parent_checkbox');
for(var i = 0; i < subs.length; i++) {
if(checked) {
$(subs[i]).prop('checked', 'checked');
}
}
});
}); });
</script> </script>
<?php $this->endBlock(); ?> <?php $this->endBlock(); ?>
Loading…
Cancel
Save