<?php /*a:3:{s:60:"/www/wwwroot/btn.millet-mirth.com/view/admin/cate/index.html";i:1647496390;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 class="active"><a href="<?php echo url('index'); ?>">栏目管理</a></li>
    </ul>
</div>

<div class="body_content_list">

<script type="text/html" id="barDemo">
<span class="tq_table_bar">
  <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="add">添加</a>
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  {{#  if(d.is_system == 1){ }}
  <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled" <?php if(env('APP_IS_SYSTEM') == 1): ?>lay-event="del"<?php endif; ?>>删除</a>
  {{#  } else { }}
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  {{#  } }}
</span>
</script>

<script type="text/html" id="is_effect">
<span class="tq_table_bar">
	<input type="checkbox" name="is_effect" value="{{d.id}}" lay-skin="switch" lay-text="停用|启用" lay-filter="is_effect" {{ d.is_effect ==2 ? 'checked' : '' }}>
</span>
</script>

<script type="text/html" id="sort">
<span class="tq_table_bar">
	<a class="layui-btn layui-btn-xs tq_sort"><input type="text" name="{{d.id}}" autocomplete="off" value="{{d.sort}}"></a>
  	<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="sort_t" title="置顶">置顶</a>
  	<a class="layui-btn layui-btn-xs btn_tq1" lay-event="sort_p" title="上移">上移</a>
  	<a class="layui-btn layui-btn-xs btn_tq1" lay-event="sort_n" title="下移">下移</a>
</span>
</script>

<script type="text/html" id="tq_btn">
  	<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="add">添加</a>
  	<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="sort_all">排序</a>
</script>
<style>
.layui-table-body {overflow-y: scroll;}
.layui-table-main table tr { display:none}
.layui-table-main table .reid_0 { display:table-row}
</style>

<table lay-filter="list" id="list" style="display:none">
  <thead>
    <tr>
      <th lay-data="{field:'id', width:80, sort:true}">编号</th>
      <th lay-data="{field:'sort', width:222, toolbar:'#sort'}">排序</th>
      <th lay-data="{field:'catename',}">栏目名称</th>
      <th lay-data="{field:'cateseo',}">展开/关闭</th>
      <th lay-data="{field:'model_id', width:110}">所属模型</th>
      <th lay-data="{field:'view_list'}">列表模板</th>
      <th lay-data="{field:'view_info'}">详情模板</th>
      <th lay-data="{field:'is_effect', width:110, align:'center', toolbar:'#is_effect'}">状态</th>
      <th lay-data="{field:'is_system', hide:true}">222</th>
      <th lay-data="{field:'pid', width:166, align:'center', toolbar:'#barDemo'}">操作</th>
    </tr> 
  </thead>
  <tbody>
	
    <?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;?>
    <tr>
      <td><?php echo htmlentities($v['id']); ?></td>
      <td><?php echo htmlentities($v['sort']); ?></td>
      <td><?php echo htmlentities($v['catename']); ?></td>
      <td><?php if($v['is_xj']==1): ?><span class="open_<?php echo htmlentities($v['id']); ?>" style="cursor:pointer; color:#22b581" onclick="cate_open(1,<?php echo htmlentities($v['id']); ?>)">展开</span><?php endif; ?></td>
      <td><?php echo htmlentities($v['model_name']); ?></td>
      <td><?php echo htmlentities($v['view_list']); ?></td>
      <td><?php echo htmlentities($v['view_info']); ?></td>
      <td><?php echo htmlentities($v['is_effect']); ?></td>
      <td><?php echo htmlentities($v['is_system']); ?></td>
      <td><?php echo htmlentities($v['pid']); ?></td>
    </tr>
	<?php endforeach; endif; else: echo "" ;endif; ?>
    
  </tbody>
</table>

</div>
<script>
function cate_open(t,id){
	if(t==1){
		$('.layui-table-main table .reid_'+id+'').show();
		$('.open_'+id+'').text('关闭').css('color','#f00');
		$('.open_'+id+'').attr('onclick','cate_open(2,'+id+')');
	}else{
		$.post('/admin/Common/cate_open',{id:id},function(data){
			var sl=data.id_array.length;
			$.each(data.id_array,function(index,value){
					$('.layui-table-main table .reid_'+value+'').hide();
				$('.open_'+value+'').attr('onclick','cate_open(1,'+value+')');
				$('.open_'+value+'').text('展开').css('color','#22b581');
			});
			console.log(sl);
		});		

	}
}


</script>
<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>
<script>
iname=self.frameElement.name;
layui.use('table', function(){
var table = layui.table,form = layui.form;
table.init('list', {
	height:'full-71' //设置高度
	,toolbar: '#tq_btn'
	,limit:Number.MAX_VALUE
	,defaultToolbar: ['filter']

});   
  
//监听工具条
table.on('tool(list)', function(obj){
	var data = obj.data;
	//删除
	if(obj.event === 'del'){
		window.top.delete_c(obj,iname);
	}
	
	//添加弹窗-添加到某栏目下
	if(obj.event==='add'){
		var title='添加栏目';
		var url="<?php echo url('add'); ?>?pid="+data.id+"";
		var area=["634px", "450px"];
		window.top.openiframe(title,url,area,iname);
	}
	
	if(obj.event==='edit'){
		var title='修改栏目';
		var url="<?php echo url('edit'); ?>?id="+data.id+"";
		var area=["634px", "450px"];
		window.top.openiframe(title,url,area,iname);
	}
	if(obj.event==='sort_t'){
		is_sort('t',data['id'],'cate',data['sort'],data['pid']);
	}
	if(obj.event==='sort_p'){
		is_sort('p',data['id'],'cate',data['sort'],data['pid']);
	}
	if(obj.event==='sort_n'){
		is_sort('n',data['id'],'cate',data['sort'],data['pid']);
	}	

});

//表头操作
table.on('toolbar(list)', function(obj){

	//添加
	if(obj.event==='add'){
		var title='添加栏目';
		var url="<?php echo url('add'); ?>";
		var area=["634px", "450px"];
		window.top.openiframe(title,url,area,iname);
	}	
	
	//input排序
	if(obj.event==='sort_all'){
		var idArray = new Array();
		var sortArray = new Array();
		$('.tq_sort input').each(function(){
            idArray.push($(this).attr('name'));
            sortArray.push($(this).val());
		});
		$.post('/admin/Common/sort_all',{id:idArray,sort:sortArray,dbname:'cate'},function(data){
			window.location.reload();
		});
	}
		
	if(obj.event==='tq_help'){
		alert(2);
	}	

});

//监听状态操作
form.on('switch(is_effect)', function(obj){
	var is_effect=obj.elem.checked==true?2:1;
	$.post('/admin/Common/is_edit',{id:obj.value,is_effect:is_effect,dbname:'cate'},function(data){ });
});

  
});
//layui end;

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

//排序
function is_sort(type,id,dbname,sort,pid){
	$.post('/admin/Common/is_sort',{type:type,id:id,dbname:dbname,sort:sort,pid:pid},function(data){
		if(data['type']==1){
			layui.use('table', function(){
				var table = layui.table;
				window.location.reload();
			});
		}
	});
}
</script>