diff --git a/app/BaseController.php b/app/BaseController.php index c6cb3a7..68f0cd5 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -470,7 +470,7 @@ abstract class BaseController $uploads = new Uploads(); switch ($type){ case 'image': - $upRes = $uploads->put('file','article_pic',1024,'image'); + $upRes = $uploads->put('file','article_pic',2048,'image'); break; case 'zip': $upRes = $uploads->put('file','article_zip',1024,'application|image'); @@ -482,7 +482,7 @@ abstract class BaseController $upRes = $uploads->put('file','article_audio',102400,'audio'); break; default: - $upRes = $uploads->put('file','article_file',1024,'image'); + $upRes = $uploads->put('file','article_file',2048,'image'); break; } return $upRes; diff --git a/app/admin/controller/Forum.php b/app/admin/controller/Forum.php index 6176219..8a32864 100644 --- a/app/admin/controller/Forum.php +++ b/app/admin/controller/Forum.php @@ -145,7 +145,7 @@ class Forum extends AdminController $res['count']= count($list); $res['data'] = []; foreach($list as $k=>$v){ - $res['data'][] = ['sort'=>$v['sort'],'id' => $v['id'],'tags'=>$v['catename'],'ename'=>$v['ename'],'detpl'=>$v['detpl'],'icon'=>$v['icon'],'is_hot'=>$v['is_hot'],'desc'=>$v['desc']]; + $res['data'][] = ['sort'=>$v['sort'],'id' => $v['id'],'pid'=>$v['pid'],'tags'=>$v['catename'],'ename'=>$v['ename'],'detpl'=>$v['detpl'],'icon'=>$v['icon'],'is_hot'=>$v['is_hot'],'desc'=>$v['desc']]; } } return json($res); @@ -162,9 +162,9 @@ class Forum extends AdminController { $addOrEdit = !is_null(input('id'));//true是编辑false新增 $msg = $addOrEdit ? lang('edit') : lang('add'); - if(Request::isAjax()){ - $data = Request::param(); - $list = Db::name('cate')->cache('catename')->save($data); + if(Request::isAjax()) { + $data = Request::param(); + $list = Db::name('cate')->cache('catename')->save($data); if($list){ return json(['code'=>0,'msg'=> $msg.'分类成功']); @@ -172,11 +172,12 @@ class Forum extends AdminController return json(['code'=>-1,'msg'=> $msg.'分类失败']); } } - $tplname = $addOrEdit ? Db::name('cate')->where('id',input('id'))->value('detpl') : ''; //详情模板 $sys = $this->getSystem(); $template = Files::getDirName('../view/'.$sys['template'].'/index/article/'); - View::assign(['template'=>$template,'tplname'=>$tplname]); + // 如果是新增,pid=0,detpl默认第一个子模块,如果是编辑,查询出cate + $cate = $addOrEdit ? Db::name('cate')->field('detpl,pid')->find((int) input('id')) : ['pid'=>0,'detpl'=>$template[0]]; + View::assign(['template'=>$template,'cate'=>$cate]); return View::fetch(); } @@ -544,6 +545,49 @@ class Forum extends AdminController return $this->uploadFiles($type); } + public function getCateTree() + { + // + $cate = Db::name('cate')->order(['id' => 'ASC','sort' => 'ASC'])->where(['delete_time'=>0])->select()->toArray(); + + $cateTree = array2tree($cate); + + $count = count($cateTree); + $tree = []; + if($cateTree){ + $tree = ['code'=>0,'msg'=>'','count'=>$count]; + + $res = []; //auth_rule储存数据表中的表结构 + foreach($cateTree as $k => $v){ + //第一层子权限 + $children = []; + if(isset($v['children'])){ + + foreach($v['children'] as $m => $j){ + //第二层子权限 + $chichi = []; + if(isset($j['children'])){ + //第三层子权限 + foreach($j as $s){ + if(isset($s['children'])){ + $chichi[] = ['id'=>$s['id'],'catename'=>$s['catename'],'pid'=>$s['pid']]; //子数据的子数据 + } + } + } + + //if($j['level'] < 3){} + $children[] = ['id'=>$j['id'],'catename'=>$j['catename'],'pid'=>$j['pid'],'children'=>$chichi]; //子数据 + } + } + $data[] = ['id'=>$v['id'],'catename'=>$v['catename'],'pid'=>$v['pid'],'children'=>$children]; + } + + //构造一个顶级菜单pid=0的数组。把权限放入顶级菜单下子权限中 + $tree['data'][] = ['id'=>0,'catename'=>'顶级','pid'=>0,'children'=>$data]; + } + return json($tree); + } + } diff --git a/app/admin/view/auth_rule/add.html b/app/admin/view/auth_rule/add.html index 4e917ec..8ffb5d4 100644 --- a/app/admin/view/auth_rule/add.html +++ b/app/admin/view/auth_rule/add.html @@ -7,7 +7,7 @@
'} - ,{field: 'is_hot', title: '热门', align: 'center',width: 50, templet: '#buttonHot'} - ,{field: 'desc', title: '描述', minWidth: 200} - ,{title: '操作', width: 100, align: 'center', toolbar: '#layuiadmin-app-cont-tagsbar'} - ]] - ,text: '对不起,加载出现异常!' - }); + // 渲染分类表格 + var insTb = treeTable.render({ + elem: '#Article-cate-list', + url: forumTags, + //toolbar: 'default', + //height: 'full-200', + tree: { + iconIndex: 2, + isPidData: true, + idName: 'id', + pidName: 'pid' + }, + defaultToolbar: ['filter', 'print', 'exports'], + cols: [ + [ + {type: 'numbers'}, + {type: 'checkbox'} + ,{field: 'tags', title: '分类名', minWidth: 200} + ,{field: 'ename', title: 'EN别名', width: 100} + ,{field: 'detpl',title: '模板', align: 'center',width: 100,templet: '#inputSel'} + ,{title: '图标', align: 'center',width: 50,templet: '
'} + ,{field: 'is_hot', title: '热门', align: 'center',width: 50, templet: '#buttonHot'} + ,{field: 'desc', title: '描述', minWidth: 200} + ,{field: 'id', title: 'ID',width: 60} + ,{field: 'sort', title: '排序', width: 80, sort: true} + ,{title: '操作', width: 120, align: 'center', toolbar: '#layuiadmin-app-cont-tagsbar'} + ] + ], + style: 'margin-top:0;' + }); //监听工具条 - table.on('tool(LAY-app-content-tags)', function(obj){ + treeTable.on('tool(Article-cate-list)', function(obj){ var data = obj.data; if(obj.event === 'del'){ layer.confirm('确定删除此分类?', function(index){ @@ -249,6 +263,7 @@ var forms = table.render({ ,yes: function(index, layero){ //获取iframe元素的值 var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags") + ,pid = othis.find('input[name="pid"]').val() ,sort = othis.find('input[name="sort"]').val() ,tags = othis.find('input[name="tags"]').val() ,ename = othis.find('input[name="ename"]').val() @@ -261,7 +276,7 @@ var forms = table.render({ $.ajax({ type:"post", url:forumTagsForm, - data:{"id":data.id,"sort":sort,"catename":tags,"ename":ename,"detpl":detpl,"icon":icon,"desc":desc}, + data:{"id":data.id,"pid":pid,"sort":sort,"catename":tags,"ename":ename,"detpl":detpl,"icon":icon,"desc":desc}, daType:"json", success:function (data){ if (data.code == 0) { @@ -288,15 +303,17 @@ var forms = table.render({ ,sort: sort }); */ + treeTable.reload('Article-cate-list'); //数据刷新 layer.close(index); } ,success: function(layero, index){ //给iframe元素赋值 var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags").click(); - othis.find('input[name="sort"]').val(data.sort) + othis.find('input[name="pid"]').val(data.pid) + ,othis.find('input[name="sort"]').val(data.sort) ,othis.find('input[name="tags"]').val(data.tags) ,othis.find('input[name="ename"]').val(data.ename) - ,othis.find('input[name="icon"]').val(data.icon) + ,othis.find('input[name="icon"]').val(data.icon) ,othis.find('input[name="desc"]').val(data.desc); } }); diff --git a/public/static/res/css/global.css b/public/static/res/css/global.css index d7efc18..4fc6319 100644 --- a/public/static/res/css/global.css +++ b/public/static/res/css/global.css @@ -195,12 +195,12 @@ pre{position: relative; margin: 10px 0; padding: 15px; line-height: 20px; border .fly-nav-msg:hover{color:#fff;} .fly-header .layui-nav{padding: 0; background: none;} -.fly-header .fly-nav a{padding: 0 25px 0 60px;} +.fly-header .fly-nav a{padding: 0 25px 0 40px;} .fly-header .fly-nav-user li a{padding: 0 10px;} .fly-header .fly-nav-user li .fly-nav-avatar{padding-right: 0;} .fly-header .fly-nav-user a.iconfont{color: #A9B7B7;} .fly-header>.layui-nav-item a{color: rgba(255,255,255,0.5);} -.fly-header .layui-this a{color: #fff;} +.fly-header .layui-this>a{color: #00AF83;} .fly-header .layui-nav .layui-this:after, .fly-header .layui-nav .layui-nav-bar, .fly-header .fly-nav-user .layui-nav-more{display: none !important;} @@ -536,7 +536,7 @@ body .layui-edit-face .layui-layer-content{padding:0; background-color:#fff; co /*标题颜色展示方式*/ .layui-colorpicker.layui-colorpicker-xs {width: 30px;height: 20px;line-height: 16px;border: 0px solid #e6e6e6;padding: 0;vertical-align: top;border-radius: 0;} .layui-colorpicker-trigger-span {display: block;height: 100%;box-sizing: border-box;border: 1px solid rgba(2, 0, 0, 0.24);border-radius: 2px;text-align: center;} -.layui-icon-down:before {font-size: 12px;content: "高亮";} +/* .layui-icon-down:before {font-size: 12px;content: "高亮";} */ /*扫码阅读*/ .detail_qrcode{position: absolute;top: 7px;right: 7px;width: 30px;height: 30px;background: url("/static/res/images/detail_qrcode.png") no-repeat;background-size: 30px 30px;} diff --git a/view/taoler/index/article/add.html b/view/taoler/index/article/add.html index d636374..6edaae6 100644 --- a/view/taoler/index/article/add.html +++ b/view/taoler/index/article/add.html @@ -18,12 +18,7 @@