<?php /*a:3:{s:63:"/www/wwwroot/btn.millet-mirth.com/view/admin/content/group.html";i:1645091768;s:60:"/www/wwwroot/btn.millet-mirth.com/view/admin/common/top.html";i:1625466448;s:63:"/www/wwwroot/btn.millet-mirth.com/view/admin/common/bottom.html";i:1629163316;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><?php echo config('common.CMS_NAME'); ?></title>
<link rel="stylesheet" href="/static/tqcms/css/common.css">
<link rel="stylesheet" href="/static/tqcms/layui/css/layui.css"><!--layui css-->
<link rel="stylesheet" href="/static/tqcms/css/skin.css">
<script src="/static/tqcms/js/jquery.js"></script>
</head>
<body>
<div class="body_top">
	<ul class="title">
    	<li><a href="<?php echo url('admin/index'); ?>">账号管理</a></li>
    	<li><a href="<?php echo url('Rule/group'); ?>">权限分组管理</a></li>

    	<li class="active"><a href="<?php echo url('Content/group'); ?>">内容权限分组管理</a></li>

        <?php if(env('APP_IS_SYSTEM') == 1): ?>
    	<li><a href="<?php echo url('Rule/index'); ?>">权限节点管理</a></li>
        <?php endif; ?>
    </ul>
</div>

<div class="body_content_list">

<script type="text/html" id="barDemo">
<span class="tq_table_bar">
	<a class="layui-btn layui-btn-xs" href="<?php echo url('Content/group'); ?>">新增</a>
	<a class="layui-btn layui-btn-xs" href="<?php echo url('Content/group'); ?>?id={{d.id}}">编辑</a>
	
	{{#  if(d.id == 1){ }}
	<a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled">删除</a>
	{{#  } else { }}
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
	{{#  } }}
</span>
</script>



<div class="auth_left">
<table class="layui-hide" id="list" lay-filter="list"></table>
</div>
<div class="auth_right">

<form action="" class="layui-form" name="group" id="group" method="post" onsubmit="return save_group();">
<input name="id" type="hidden" value="<?php echo htmlentities($info['id']); ?>" />
<ul>
    <li><label class="layui-form-label">名称</label><input type="text" name="name" value="<?php echo htmlentities($info['name']); ?>" placeholder="" autocomplete="off" class="layui-input"></li>
    <li><label class="layui-form-label">权限</label>
    	
        <ul>
            <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
        	<li><input type="checkbox" name="rid[]" value="<?php echo htmlentities($v['id']); ?>" <?php if(inarray($v['id'],$info['rid'])==1): ?>checked<?php endif; ?> lay-skin="primary" title="<?php echo htmlentities($v['title']); ?>"></li>
        	
            <?php if(is_array($v['children']) || $v['children'] instanceof \think\Collection || $v['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $v['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i;?>
            <li class="lv2"><input type="checkbox" name="rid[]" value="<?php echo htmlentities($c['id']); ?>" <?php if(inarray($c['id'],$info['rid'])==1): ?>checked<?php endif; ?> lay-skin="primary" title="<?php echo htmlentities($c['title']); ?>"></li>
        	
            <?php if(is_array($c['children']) || $c['children'] instanceof \think\Collection || $c['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $c['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$d): $mod = ($i % 2 );++$i;?>
            <li class="lv3"><input type="checkbox" name="rid[]" value="<?php echo htmlentities($d['id']); ?>" <?php if(inarray($d['id'],$info['rid'])==1): ?>checked<?php endif; ?> lay-skin="primary" title="<?php echo htmlentities($d['title']); ?>"></li>


            <?php endforeach; endif; else: echo "" ;endif; ?>
            
            <?php endforeach; endif; else: echo "" ;endif; ?>
            
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </ul>
        
    </li>
    <li>　　　<button class="layui-btn layui-btn-normal layui-btn-sm">提　交</button></li>
</ul>
</form>
</div>

</div>


<script src="/static/tqcms/layui/layui.js"></script><!--layui js-->
<script src="/static/tqcms/layui/laytq.js"></script><!--layui js-->
<script src="/static/tqcms/js/common.js"></script>
<script src="/static/tqcms/js/md5.js"></script>
<script src="/static/tqcms/js/url.js"></script>
</body>
</html>
<input name="" id="add_type" type="hidden" value="0" />
<script>
iname=self.frameElement.name;
layui.use('table', function(){
  var table = layui.table,form = layui.form;
  var mpage=1;

  table.render({
    elem: '#list'
	,title:'权限列表信息'
    ,url:'<?php echo url("admin/Content/group_list"); ?>'
    ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
	,even: true
	,cols: [[
      {field:'id', width:80, title: '编号', sort: true}
      ,{field:'name', title: '名称'}
      ,{field:'id', width:170,align:'center',toolbar:'#barDemo', title: '操作'}
    ]]
  });
  
//table列表内工具条操作
table.on('tool(list)', function(obj){
	
	var data = obj.data;
	//删除
	if(obj.event === 'del'){
		window.top.delete_c(obj,iname);
	}

});

});

function save_group(){
	$.post('/admin/Content/save_group',$("#group").serialize(),function(data){
		console.log(data);
		if(data.ok==1){
			layer.msg(data['msg'], {icon:1,time:1000});
			setTimeout(function(){ window.location.href = "<?php echo url('Content/group'); ?>"; },1500);
		}else{
			window.top.tq_alert(data.msg,'',4);
		}
    });
	return false;
}


//删除-父级返回
function delete_id(info){
	$.post('/admin/Common/delete_id',{id:info.data.id,table:'content_group'},function(data){ 
		if(data.ok==2){
			window.top.tq_alert(data.msg,'',4);
		}else{
			info.del();
		}
	});
}


function auth_ck(t,id){
	var d=$('.'+t+'_'+id+' input:checkbox[name="rid[]"]:checked').val();
	if(d!='' && d!=undefined){
		$('.'+t+'_'+id).find('input').prop('checked',true);
		$('.'+t+'_'+id).find('div').addClass('layui-form-checked');
	}else{
		$('.'+t+'_'+id).find('input').prop('checked',false);
		$('.'+t+'_'+id).find('div').removeClass('layui-form-checked');
	}
}
</script>