123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>layui</title>
- <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">
- <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
- <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all"/>
- <link rel="stylesheet" href="__CSS__/admin.css" media="all">
- </head>
- <style type="text/css">
- table {
- table-layout: fixed;
- width: 100%;
- }
- td {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- </style>
- <body style="padding:10px;">
- <div class="tplay-body-div">
- <div class="layui-tab">
- <ul class="layui-tab-title">
- <li class="layui-this">分类管理</li>
- <li><a href="{:url('admin/articlecate/publish')}" class="a_menu">新增分类</a></li>
- </ul>
- </div>
- <div id="toolbar" style="display: none">
- <button class="layui-btn layui-btn-sm layui-btn-primary" id="open-all"><i
- class="layui-icon layui-icon-triangle-d"></i>展开
- </button>
- <button class="layui-btn layui-btn-sm layui-btn-primary" id="close-all"><i
- class="layui-icon layui-icon-triangle-r"></i>收缩
- </button>
- <!--<button class="layui-btn layui-btn-sm" id="updateTreePath"><i class="layui-icon"></i>更新 tree_path</button>-->
- </div>
- <form class="layui-form" id="admin">
- <table class="layui-table layui-form" id="tree-table" lay-size="sm"></table>
- <button class="layui-btn layui-btn-sm" lay-submit lay-filter="admin" style="display: none" id="sort">更新排序</button>
- </form>
- {include file="public/foot"}
- <script type="text/javascript">
- layui.extend({
- treeTable: 'treeTable/js/treeTable'
- }).use(['treeTable', 'layer', 'form'], function () {
- var treeTable = layui.treeTable,
- form = layui.form,
- layer = layui.layer;
- //第一个实例
- var re = treeTable.render({
- elem: '#tree-table',
- url: '{:url("index")}', //数据接口
- icon_key: 'title',
- cols: [
- {
- key: 'sort', title: '排序', align: 'center', width: '40px', template: function (row) {
- return '<input type="text" name="sorts[]" value="' + row.sort + '" style="width: 20px;" class="sort"><input type="hidden" name="ids[]" value="' + row.id + '">';
- }
- },
- {key: 'id', title: 'ID', width: '40px'},
- {
- key: 'title', title: '分类名称', template: function (row) {
- return '<a href="./perview?id=' + row.id + '" target="_blank" title="单击预览">' + row.title + '</a>'
- }
- },
- {key: 'en_name', title: '分类别名'},
- {key: 'catalog', title: '关联的栏目'},
- {key: 'seo_title', title: 'SEO标题'},
- {key: 'seo_keyword', title: 'SEO关键词'},
- {key: 'seo_description', title: 'SEO描述'},
- {key: 'article_count', title: '文章数', width: '60px'},
- //{php}if(\think\App::$debug){{/php}
- {key: 'uri', title: 'URI'},
- {key: 'tree_path', title: 'TREE_PATH'},
- //{php}}{/php}
- {
- key: '状态', title: '审核', align: 'center', width: '60px', template: function (row) {
- return '<a href="javascript:;" style="font-size:18px;" class="status" data-id="' + row.id + '" data-val="' + row.status + '">' + (row.status == 1 ? '<i class="fa fa-toggle-on"></i>' : '<i class="fa fa-toggle-off"></i>') + '</a>';
- }
- },
- {
- title: '操作', align: 'center', width: '100px',
- template: function (item) {
- var html = '<div class="layui-btn-group">';
- html += '<a href="publish?id=' + item.id + '" class="layui-btn layui-btn-xs a_menu layui-btn-primary" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>';
- html += '<a href="publish?pid=' + item.id + '" class="layui-btn layui-btn-xs a_menu layui-btn-primary" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>';
- html += '<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-primary delete" id="' + item.id + '" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>';
- html += '</div>';
- return html;
- }
- }
- ],
- end: function (e) {
- form.render();
- if (e.data.length > 0) {
- $('#toolbar').show();
- $('#sort').show();
- }
- // 全部展开
- $('#open-all').click(function () {
- treeTable.openAll(re);
- })
- // 全部关闭
- $('#close-all').click(function () {
- treeTable.closeAll(re);
- })
- //审核
- switchStatus('.status',"{:url('status')}");
- //删除
- $('.delete').click(function () {
- var id = $(this).attr('id');
- layer.confirm('确定要删除?', function (index) {
- $.ajax({
- url: "{:url('delete')}",
- data: {id: id},
- dataType: 'json',
- type: 'post',
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- setTimeout(function () {
- location.href = res.url;
- }, 1500)
- }
- }
- })
- })
- })
- },
- });
- });
- $("#updateTreePath").click(function () {
- var load = layer.load(1, {
- shade: [0.1, '#fff'] //0.1透明度的白色背景
- });
- $.ajax({
- url: "{:url('updateTreePath')}",
- data: {},
- type: 'post',
- dataType: 'json',
- success: function (res) {
- layer.alert(res.msg, function (index) {
- layer.msg(res.msg);
- })
- },
- complete: function () {
- layer.close(load);
- }
- })
- })
- </script>
- <script>
- // 排序
- layui.use(['layer', 'form'], function () {
- var layer = layui.layer,
- $ = layui.jquery,
- form = layui.form;
- $(window).on('load', function () {
- form.on('submit(admin)', function (data) {
- $.ajax({
- url: "{:url('sort')}",
- data: $('#admin').serialize(),
- type: 'post',
- async: false,
- success: function (res) {
- if (res.code == 1) {
- layer.alert(res.msg, function (index) {
- location.reload();
- })
- } else {
- layer.msg(res.msg);
- }
- }
- })
- return false;
- });
- });
- });
- </script>
- </div>
- </body>
- </html>
|