index.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>layui</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
  10. <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all"/>
  11. <link rel="stylesheet" href="__CSS__/admin.css" media="all">
  12. </head>
  13. <style type="text/css">
  14. table {
  15. table-layout: fixed;
  16. width: 100%;
  17. }
  18. td {
  19. white-space: nowrap;
  20. overflow: hidden;
  21. text-overflow: ellipsis;
  22. }
  23. </style>
  24. <body style="padding:10px;">
  25. <div class="tplay-body-div">
  26. <div class="layui-tab">
  27. <ul class="layui-tab-title">
  28. <li class="layui-this">分类管理</li>
  29. <li><a href="{:url('admin/articlecate/publish')}" class="a_menu">新增分类</a></li>
  30. </ul>
  31. </div>
  32. <div id="toolbar" style="display: none">
  33. <button class="layui-btn layui-btn-sm layui-btn-primary" id="open-all"><i
  34. class="layui-icon layui-icon-triangle-d"></i>展开
  35. </button>
  36. <button class="layui-btn layui-btn-sm layui-btn-primary" id="close-all"><i
  37. class="layui-icon layui-icon-triangle-r"></i>收缩
  38. </button>
  39. <!--<button class="layui-btn layui-btn-sm" id="updateTreePath"><i class="layui-icon">&#xe609;</i>更新 tree_path</button>-->
  40. </div>
  41. <form class="layui-form" id="admin">
  42. <table class="layui-table layui-form" id="tree-table" lay-size="sm"></table>
  43. <button class="layui-btn layui-btn-sm" lay-submit lay-filter="admin" style="display: none" id="sort">更新排序</button>
  44. </form>
  45. {include file="public/foot"}
  46. <script type="text/javascript">
  47. layui.extend({
  48. treeTable: 'treeTable/js/treeTable'
  49. }).use(['treeTable', 'layer', 'form'], function () {
  50. var treeTable = layui.treeTable,
  51. form = layui.form,
  52. layer = layui.layer;
  53. //第一个实例
  54. var re = treeTable.render({
  55. elem: '#tree-table',
  56. url: '{:url("index")}', //数据接口
  57. icon_key: 'title',
  58. cols: [
  59. {
  60. key: 'sort', title: '排序', align: 'center', width: '40px', template: function (row) {
  61. return '<input type="text" name="sorts[]" value="' + row.sort + '" style="width: 20px;" class="sort"><input type="hidden" name="ids[]" value="' + row.id + '">';
  62. }
  63. },
  64. {key: 'id', title: 'ID', width: '40px'},
  65. {
  66. key: 'title', title: '分类名称', template: function (row) {
  67. return '<a href="./perview?id=' + row.id + '" target="_blank" title="单击预览">' + row.title + '</a>'
  68. }
  69. },
  70. {key: 'en_name', title: '分类别名'},
  71. {key: 'catalog', title: '关联的栏目'},
  72. {key: 'seo_title', title: 'SEO标题'},
  73. {key: 'seo_keyword', title: 'SEO关键词'},
  74. {key: 'seo_description', title: 'SEO描述'},
  75. {key: 'article_count', title: '文章数', width: '60px'},
  76. //{php}if(\think\App::$debug){{/php}
  77. {key: 'uri', title: 'URI'},
  78. {key: 'tree_path', title: 'TREE_PATH'},
  79. //{php}}{/php}
  80. {
  81. key: '状态', title: '审核', align: 'center', width: '60px', template: function (row) {
  82. 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>';
  83. }
  84. },
  85. {
  86. title: '操作', align: 'center', width: '100px',
  87. template: function (item) {
  88. var html = '<div class="layui-btn-group">';
  89. 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>';
  90. 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>';
  91. 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>';
  92. html += '</div>';
  93. return html;
  94. }
  95. }
  96. ],
  97. end: function (e) {
  98. form.render();
  99. if (e.data.length > 0) {
  100. $('#toolbar').show();
  101. $('#sort').show();
  102. }
  103. // 全部展开
  104. $('#open-all').click(function () {
  105. treeTable.openAll(re);
  106. })
  107. // 全部关闭
  108. $('#close-all').click(function () {
  109. treeTable.closeAll(re);
  110. })
  111. //审核
  112. switchStatus('.status',"{:url('status')}");
  113. //删除
  114. $('.delete').click(function () {
  115. var id = $(this).attr('id');
  116. layer.confirm('确定要删除?', function (index) {
  117. $.ajax({
  118. url: "{:url('delete')}",
  119. data: {id: id},
  120. dataType: 'json',
  121. type: 'post',
  122. success: function (res) {
  123. layer.msg(res.msg);
  124. if (res.code == 1) {
  125. setTimeout(function () {
  126. location.href = res.url;
  127. }, 1500)
  128. }
  129. }
  130. })
  131. })
  132. })
  133. },
  134. });
  135. });
  136. $("#updateTreePath").click(function () {
  137. var load = layer.load(1, {
  138. shade: [0.1, '#fff'] //0.1透明度的白色背景
  139. });
  140. $.ajax({
  141. url: "{:url('updateTreePath')}",
  142. data: {},
  143. type: 'post',
  144. dataType: 'json',
  145. success: function (res) {
  146. layer.alert(res.msg, function (index) {
  147. layer.msg(res.msg);
  148. })
  149. },
  150. complete: function () {
  151. layer.close(load);
  152. }
  153. })
  154. })
  155. </script>
  156. <script>
  157. // 排序
  158. layui.use(['layer', 'form'], function () {
  159. var layer = layui.layer,
  160. $ = layui.jquery,
  161. form = layui.form;
  162. $(window).on('load', function () {
  163. form.on('submit(admin)', function (data) {
  164. $.ajax({
  165. url: "{:url('sort')}",
  166. data: $('#admin').serialize(),
  167. type: 'post',
  168. async: false,
  169. success: function (res) {
  170. if (res.code == 1) {
  171. layer.alert(res.msg, function (index) {
  172. location.reload();
  173. })
  174. } else {
  175. layer.msg(res.msg);
  176. }
  177. }
  178. })
  179. return false;
  180. });
  181. });
  182. });
  183. </script>
  184. </div>
  185. </body>
  186. </html>