曹え 5811 发布于:2024-06-03 09:09:54
栏目权限只支持1级栏目选择
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> {include="style"} <style> .x-body{ padding-left: 10px;} .grow { overflow: hidden;} .gcol{ float: left; width: 192px; padding-left: 10px;} .gcor { overflow: hidden;} .gcol ul li.num1{ background-color: #fff; border-top-left-radius: 5px; border-bottom-left-radius: 5px; } .snv li { /* height: 30px; */ line-height: 30px; cursor: pointer; padding-left: 10px; color: #888; } /* .snv li.on { font-weight: bold; color: #000; background-color: #fff; box-shadow: -3px 2px 3px rgba(0,0,0,.1) !important; border-top-left-radius: 5px; border-bottom-left-radius: 5px; } */ .snv .ul1, .snv .ul2, .snv .ul3{ display: none; } .snv .ul1,.snv .ul2 { font-size: 12px;} .ul4 { background-color: #eee; } .snv .on2, .snv .on3{ color: #000; } .snv .on2::before{ content: '▶'; display: inline-block; line-height: 30px; font-size: 12px; } .snv .on3::before{ content: '▼'; display: inline-block; line-height: 30px; font-size: 12px; } </style> </head> <body> <div class="x-nav"> <span class="layui-breadcrumb"> <a><cite>{fun JZLANG('首页')}</cite></a> <a><cite>{$molds['name']}{fun JZLANG('管理')}</cite></a> <a><cite>{$molds['name']}{fun JZLANG('列表')}</cite></a> <a> <cite id="cur-tid"></cite> </a> </span> <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="{fun JZLANG('刷新')}"><i class="iconfont" style="line-height:30px"></i></a> </div> <div class="x-body"> <div class="grow"> <div class="gcol"> <ul class="snv"> <!-- {if($tid==$vvvv['id'])} class="on"{/if} --> {foreach $classtypes as $v} {if($v['molds']=='article')} {if($v['level']==0)} <li {if($classtypedata[$v['id']]['haschild'])} class="on2" {/if} data-tid="{$v['id']}"> {fun str_repeat('--', $v['level'])}{$v['classname']} {if($classtypedata[$v['id']]['haschild'])} <ul class="ul1"> {foreach $classtypedata[$v['id']]['children']['list'] as $vv} <li {if($classtypedata[$vv['id']]['haschild'])} class="on2" {/if} data-tid="{$vv['id']}"> {fun str_repeat('--', $vv['level'])}{$vv['classname']} {if($classtypedata[$vv['id']]['haschild'])} <ul class="ul2"> {foreach $classtypedata[$vv['id']]['children']['list'] as $vvv} <li {if($classtypedata[$vvv['id']]['haschild'])} class="on2"{/if} data-tid="{$vvv['id']}"> {fun str_repeat('--', $vvv['level'])}{$vvv['classname']} {if($classtypedata[$vvv['id']]['haschild'])} <ul class="ul3"> {foreach $classtypedata[$vvv['id']]['children']['list'] as $vvvv} <li data-tid="{$vvvv['id']}"> {fun str_repeat('--', $vvvv['level'])}{$vvvv['classname']} {if($classtypedata[$vvvv['id']]['haschild'])} <ul class="ul4"> {foreach $classtypedata[$vvvv['id']]['children']['list'] as $vvvvv} <li data-tid="{$vvvvv['id']}"> {fun str_repeat('--', $vvvvv['level'])}{$vvvvv['classname']}</li> {fun str_repeat('--', $vvvvv['level'])}{$vvvvv['classname']} {if($classtypedata[$vvvvv['id']]['haschild'])} <ul class="ul4"> {foreach $classtypedata[$vvvvv['id']]['children']['list'] as $vvvvvv} <li data-tid="{$vvvvvv['id']}"> {fun str_repeat('--', $vvvvvv['level'])}{$vvvvvv['classname']}</li> {/foreach} </ul> {/if} {/foreach} </ul> {/if} </li> {/foreach} </ul> {/if} </li> {/foreach} </ul> {/if} </li> {/foreach} </ul> {/if} </li> {/if} {/if} {/foreach} </ul> </div> <div class="gcor"> <div class="layui-card"> <div class="layui-card-body"> <div class="layui-collapse"> <div class="layui-colla-item"> <h2 class="layui-colla-title">{fun JZLANG('搜索')}</h2> <div class="layui-colla-content"> <div class="layui-row"> <form class="layui-form layui-col-md12 x-so" method="get" id="myform"> {$fields_search} <a class="layui-btn" lay-submit="" lay-filter="search">{fun JZLANG('搜索')}</a> </form> </div> </div> </div> </div> <table class="layui-hide" lay-data="{id: 'jizhi_table'}" id="jizhi_table" lay-filter="jizhi_table"></table> <input id="select_data" type="hidden" value="" /> </div> </div> </div> <script type="text/javascript"> $('.gcol ul li').click(function(e){ $('.gcol ul li').removeClass('num1'); $(this).addClass('num1'); e.stopPropagation(); if($(this).hasClass('on2')){ $(this).removeClass('on2').addClass('on3') }else if($(this).hasClass('on3')){ $(this).removeClass('on3').addClass('on2') } if($(this).hasClass('down')){ $(this).removeClass('down').children('ul').slideUp(); }else{ $(this).addClass('down').children('ul').slideDown(); } }) </script> <script type="text/html" id="rightbar"> <!-- <a class="layui-btn layui-btn-xs" lay-event="view">{fun JZLANG('预览')}</a> --> {if(checkAction('Article/editarticle'))} <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="edit">{fun JZLANG('编辑')}</a> {/if} {if(checkAction('Article/deletearticle'))} <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">{fun JZLANG('删除')}</a> {/if} {if(checkAction('Article/copyarticle'))} <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="copy">{fun JZLANG('复制')}</a> {/if} </script> <script type="text/html" id="toolbar"> <div class="layui-btn-container" style="font-size:15px;"> {if(checkAction('Article/deleteAll'))} <a class="layui-btn layui-btn-danger layui-btn-sm" title="{fun JZLANG('批量删除')}" onclick="delAll()">{fun JZLANG('批量删除')}</a> {/if} {if(checkAction('Article/copyAll'))} <a class="layui-btn layui-btn-warm layui-btn-sm" title="{fun JZLANG('批量复制')}" onclick="copyAll()">{fun JZLANG('批量复制')}</a> {/if} {if(checkAction('Article/addarticle'))} {if($tid)} <a class="layui-btn layui-btn-sm" title="{fun JZLANG('新增')}" onclick="x_admin_show('{fun JZLANG('新增')}','{fun U('Article/addarticle',['tid'=>$tid])}')">{fun JZLANG('新增')}</a> {else} <!-- <a class="layui-btn layui-btn-sm" title="{fun JZLANG('新增')}" onclick="x_admin_show('{fun JZLANG('新增')}','{fun U('Article/addarticle')}')">{fun JZLANG('新增')}</a> --> <a class="layui-btn layui-btn-sm" title="新增" onclick="addnew()">新增{$molds['name']}</a> {/if} {/if} {if(checkAction('Article/changeType'))} <div class="layui-input-inline" style="margin-right: 10px;margin-bottom: 10px;"> <select class="" id="change_tid" lay-search="" lay-filter="change_tid" > <option value="0">{fun JZLANG('批量修改栏目')}</option> {foreach $classtypes as $v} {if($v['molds']=='article')} {if($admin['classcontrol']==0 || $admin['isadmin']==1 || strpos($tids,','.$v['id'].',')!==false || $molds['iscontrol']==0)} <option value="{$v['id']}">{fun str_repeat('--', $v['level'])}{$v['classname']}</option> {/if} {/if} {/foreach} </select> </div> {/if} {if(checkAction('Article/changeAttribute'))} <div class="layui-input-inline" style="margin-right: 10px;margin-bottom: 10px;"> <select class="" id="change_tuijian" lay-filter="change_tuijian" > <option value="0">{fun JZLANG('修改推荐属性')}</option> {loop table="attr" isshow="1" as="v"} <option value="{$v['id']}">{$v['name']}</option> {/loop} </select> </div> {/if} {if(checkAction('Article/checkAll'))} <div class="layui-input-inline" style="margin-right: 10px;margin-bottom: 10px;width:150px;"> <select class="" id="change_isshow" lay-filter="change_isshow" > <option value="0">{fun JZLANG('批量审核')}</option> <option value="1">{fun JZLANG('审核')}</option> <option value="2">{fun JZLANG('未审')}</option> <option value="3">{fun JZLANG('退回')}</option> </select> </div> {/if} <a class="layui-btn layui-btn-warm layui-btn-sm" title="{fun JZLANG('设置')}" onclick="x_admin_show('{fun JZLANG('列表字段设置')}','{fun U('Fields/fieldsList',['molds'=>'article'])}')"><i class="iconfont"></i></a> </div> </script> <script type="text/html" id="tuijian"> {{# if(d.istop ==1){ }} <span class="layui-badge layui-bg-black">{fun JZLANG('顶')}}</span> {{# } }} {{# if(d.ishot==1){ }} <span class="layui-badge">{fun JZLANG('热')}}</span> {{# } }} {{# if(d.istuijian==1){ }} <span class="layui-badge layui-bg-green">{fun JZLANG('荐')}}</span> {{# } }} </script> <script type="text/html" id="isshow"> {{# if(d.isshow ==1){ }} <span class="layui-badge layui-bg-green">{fun JZLANG('已审')}}</span> {{# } else if(d.isshow ==2){ }} <span class="layui-badge layui-bg-black">{fun JZLANG('退回')}}</span> {{# } else{ }} <span class="layui-badge">{fun JZLANG('未审')}}</span> {{# } }} </script> <script> var urls = window.location.href+'?ajax=1' if(urls.includes('tid')){ urls = window.location.href+'&ajax=1' var tid = getUrlDate().tid; $('#cur-tid').text(tid) var dom = $('ul li').filter(function(i){ return $(this).data('tid') == tid; }) // console.log(dom); $(dom).addClass('on num1 down'); $(dom).parents('li').removeClass('on2').addClass('on3 down on').children('ul').show(); $(dom).parents('li').parents('li').removeClass('on2').addClass('on3 down on').children('ul').show(); } function getUrlDate() { let obj = {}; let str1 = location.search.slice(1); let arr; let is; arr = str1.split("#")[0]; is = arr.includes('&');//判断参数个数 if(is){ arr = arr[0].split('&'); for(let i = 0; i<arr.length; i++){ let arr2 = arr[i].split("="); for(let j = 0;j<arr2.length;j++){ if(j == arr2.length - 1){ continue }else{ let str2 = arr2[j]; let str3 = arr2[j+1]; obj[str2] = str3; } } } }else{ let arr2 = arr.split("="); for(let j = 0;j<arr2.length;j++){ if(j == arr2.length - 1){ continue }else{ let str2 = arr2[j]; let str3 = arr2[j+1]; obj[str2] = str3; } } } return obj; } layui.use(['laydate','form','element','laypage','layer','table'], function(){ $ = layui.jquery;//jquery var laydate = layui.laydate;//日期插件 var lement = layui.element;//面包导航 var layer = layui.layer;//弹出层 var form = layui.form; var table = layui.table; table.render({ elem: '#jizhi_table' ,height: 700 ,cellMinWidth: 80 ,url: urls //数据接口 ,page: true //开启分页 ,size:'lg' ,count:100 ,toolbar:"#toolbar" ,data:{} ,page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档 layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局 //,curr: 5 //设定初始在第 5 页 ,groups: 5 //只显示 1 个连续页码 ,first: true //显示首页 ,last: true //显示尾页 ,count:500 ,limit:10 ,first: '首页' //不显示首页 ,last: '尾页' //不显示尾页 } ,cols: [[ //表头 {field: 'id', title: 'ID', width:60} ,{type:'checkbox'} {foreach $fields_list as $v} ,{field: '{$v['field']}',width:{if(!$v['width'])}100{else}{$v['width']}{/if}, title: '{$v['fieldname']}' {if($v['fieldtype']==1 || $v['fieldtype']==2 || $v['fieldtype']==4 || $v['fieldtype']==14)},edit:'text'{/if} } {/foreach} {if(checkAction('Article/editarticle') || checkAction('Article/deletearticle') || checkAction('Article/copyarticle'))} ,{field: '', title: '{fun JZLANG('操作')}',width:240, toolbar: '#rightbar', fixed:'right'} {/if} ]] }); table.on('tool(jizhi_table)', function(obj){ var data = obj.data; //获得当前行数据 var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值) var tr = obj.tr; //获得当前行 tr 的DOM对象 switch(layEvent){ case 'edit': x_admin_show('{fun JZLANG('编辑')}',data.edit_url); break; case 'view': var a = $('<a href="'+data.view_url+'" target="_blank">{fun JZLANG('预览')}</a>').get(0); var e = document.createEvent('MouseEvents'); e.initEvent( 'click', true, true ); a.dispatchEvent(e); break; case 'delete': layer.confirm('{fun JZLANG('确认要删除吗?')}',function(index){ $.post("{fun U('Article/deletearticle')}",{id:data.id},function(r){ var r = JSON.parse(r); if(r.code==0){ //发异步删除数据 $(tr).remove(); layer.msg(r.msg,{icon: 1,time:1000},function(){ table.reload('jizhi_table', { url: urls ,where: {tid:tid} //设定异步数据接口的额外参数 }); }); }else{ layer.msg(r.msg,{icon: 5,time:1000}); } }) }); break; case 'copy': $.post("{fun U('Article/copyarticle')}",{id:data.id},function(r){ var r = JSON.parse(r); if(r.code==0){ layer.msg(r.msg,{icon: 1,time:1000},function(){ table.reload('jizhi_table', { url: urls ,where: {tid:tid} //设定异步数据接口的额外参数 }); }); }else{ layer.msg(r.msg,{icon: 5,time:1000}); } }) break; } }); table.on('checkbox(jizhi_table)', function(obj){ var checkStatus = table.checkStatus('jizhi_table'); //idTest 即为基础参数 id 对应的值 var len = checkStatus.data.length; var arr=[]; if(len>0){ for(var i=0;i<len;i++){ arr.push(checkStatus.data[i].id); } } $("#select_data").val(arr); }); table.on('edit(jizhi_table)', function(obj){ var id = obj.data.id; var value = obj.value; var field = obj.field; $.post("{fun U('Article/editArticleOrders')}",{'id':id,'value':value,'field':field},function(r){ var r = JSON.parse(r); if(r.code==0){ $("#select_data").val(''); table.reload('jizhi_table', { url: urls ,where: {} //设定异步数据接口的额外参数 }); }else{ layer.msg(r.info,{icon: 5,time:1000}); } }); }); form.on('submit(search)', function(data){ table.reload('jizhi_table', { url: urls ,where: data.field //设定异步数据接口的额外参数 }); return false; }); $('.snv li').click(function(){ tid = $(this).data('tid'); $(this).addClass('on').siblings('li').removeClass('on'); var str = urls ; // if(str.includes('tid')){ // table.reload('jizhi_table', { // url: urls2 +'&ajax=1' // ,where: {} //设定异步数据接口的额外参数 // }); // }else{ $('#cur-tid').text(tid) table.reload('jizhi_table', { url: '/index.php/admins/Article/articlelist.html?ajax=1' ,where: {tid:tid} //设定异步数据接口的额外参数 }); //} // console.log(urls ) }) form.on('select(change_tid)', function(data){ var datas = $("#select_data").val(); var tid = parseInt(data.value); if(tid==0){ alert('{fun JZLANG('请选择修改栏目!')}');return false; } if(datas==''){ alert('{fun JZLANG('请选择对象!')}');return false; } layer.confirm('{fun JZLANG('确认要批量修改内容分类吗?')}['+datas+']=>['+tid+']',function(index){ $.post("{fun U('Article/changeType')}",{tid:tid,data:datas},function(r){ var r = JSON.parse(r); if(r.code==0){ $("#select_data").val(''); layer.msg('{fun JZLANG('批量修改成功')}', {icon: 1,time:1000},function(){ table.reload('jizhi_table', { url: urls ,where: {} //设定异步数据接口的额外参数 }); }); }else{ layer.msg(r.msg,{icon: 5,time:1000}); } }) }); }); form.on('select(change_tuijian)', function(data){ var datas = $("#select_data").val(); var tj = parseInt(data.value); if(tj==0){ alert('{fun JZLANG('请选择修改属性!')}');return false; } if(datas==''){ alert('{fun JZLANG('请选择修改对象!')}');return false; } $.post("{fun U('Article/changeAttribute')}",{data:datas,tj:tj},function(r){ var r = JSON.parse(r); if(r.code==0){ $("#select_data").val(''); layer.msg('{fun JZLANG('批量修改成功')}', {icon: 1,time:1000},function(){ table.reload('jizhi_table', { url: urls ,where: {} //设定异步数据接口的额外参数 }); }); }else{ layer.msg(r.msg,{icon: 5,time:1000}); } }) }); form.on('select(change_isshow)', function(data){ var datas = $("#select_data").val(); var isshow = parseInt(data.value); if(isshow==0){ alert('{fun JZLANG('请选择审核选项!')}');return false; } if(datas==''){ alert('{fun JZLANG('请选择审核对象!')}');return false; } if(isshow==1){ var tip = '{fun JZLANG('显示')}'; }else if(isshow==2){ var tip = '{fun JZLANG('不显示')}'; }else{ var tip = '{fun JZLANG('退回')}'; } layer.confirm('{fun JZLANG('确认要批量处理吗?')}['+datas+']=>['+tip+']',function(index){ $.post("{fun U('Article/checkAll')}",{data:datas,isshow:isshow},function(r){ var r = JSON.parse(r); if(r.code==0){ $("#select_data").val(''); layer.msg('{fun JZLANG('批量审核成功')}', {icon: 1,time:1000},function(){ table.reload('jizhi_table', { url: urls ,where: {} //设定异步数据接口的额外参数 }); }); }else{ layer.msg(r.msg,{icon: 5,time:1000}); } }) }); }); }); function delAll () { var data = $("#select_data").val(); if(data==''){ alert('{fun JZLANG('请选择对象!')}');return false; } layer.confirm('{fun JZLANG('确认要删除吗?')}'+data,function(index){ $.post("{fun U('Article/deleteAll')}",{data:data},function(r){ var r = JSON.parse(r); if(r.code==0){ layer.msg('{fun JZLANG('批量删除成功')}', {icon: 1,time:1000},function(){ window.location.href = '/index.php/admins/Article/articlelist.html?tid=' + tid; }); }else{ layer.msg(r.msg,{icon: 5,time:1000}); } }) }); } function copyAll(){ var data = $("#select_data").val(); if(data==''){ alert('{fun JZLANG('请选择对象!')}');return false; } layer.confirm('{fun JZLANG('确认要复制吗?')}['+data+']',function(index){ $.post("{fun U('Article/copyAll')}",{data:data},function(r){ var r = JSON.parse(r); if(r.code==0){ layer.msg('{fun JZLANG('批量复制成功')}', {icon: 1,time:1000},function(){ window.location.href = '/index.php/admins/Article/articlelist.html?tid=' + tid; }); }else{ layer.msg(r.msg,{icon: 5,time:1000}); } }) }); } function addnew(){ // console.log(123) // tid = $('.snv .on').data('tid'); tid = $('.gcol ul li.num1').data('tid'); // console.log(tid) url = '/index.php/admins/Article/addarticle.html?tid='+tid; x_admin_show('新增{$molds['name']}',url); } // 栏目权限判断,如果没有这个栏目的权限,菜单会被删除 tids = "{$admin['tids']}" if(tids){ $('.snv > li').each(function(){ ti = $(this).data('tid'); ti = ','+ti+','; if (tids.includes(ti)) { }else{ $(this).remove() } }) } </script> </body> </html>
登录后可以留言提问!
微信扫码登录