TemplateClass.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!DOCTYPE html>
  2. <html class="x-admin-sm">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="renderer" content="webkit">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  8. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
  9. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
  10. <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  11. <script src="https://osscold.baozhida.cn/lib/layui/layui.js" charset="utf-8"></script>
  12. <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
  13. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  14. <!--[if lt IE 9]>
  15. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  16. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  17. <![endif]-->
  18. </head>
  19. <body>
  20. <div class="x-nav">
  21. <span class="layui-breadcrumb">
  22. <a href="">首页</a>
  23. <a><cite>宝智达</cite></a>
  24. </span>
  25. <a class="layui-btn layui-btn-normal " style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
  26. <i class="layui-icon layui-icon-normal" style="line-height:30px"></i>
  27. </a>
  28. </div>
  29. <div class="layui-fluid">
  30. <div class="layui-row layui-col-space15">
  31. <div class="layui-col-md12">
  32. <div class="layui-card">
  33. <!-- <div class="layui-card-body ">-->
  34. <!-- <hr>-->
  35. <!--&lt;!&ndash; <blockquote class="layui-elem-quote">每个tr 上有两个属性 cate-id='1' 当前分类id fid='0' 父级id ,顶级分类为 0,有子分类的前面加收缩图标<i class="layui-icon x-show" status='true'>&#xe623;</i></blockquote>&ndash;&gt;-->
  36. <!-- </div>-->
  37. <div class="layui-card-header">
  38. <button class="layui-btn layui-btn-normal layui-btn-xs" onclick="xadmin.open('添加','Class_?id=0',400,400)" ><i class="layui-icon">&#xe61f;</i>添加分类</button>
  39. </div>
  40. <div class="layui-card-body ">
  41. <table class="layui-table layui-form" >
  42. <thead>
  43. <tr>
  44. <!-- <th width="20">-->
  45. <!-- <input type="checkbox" name="" lay-skin="primary">-->
  46. <!-- </th>-->
  47. <!-- <th width="70">ID</th>-->
  48. <th width="250">栏目名</th>
  49. <!-- <th width="50">排序</th>-->
  50. <!-- <th width="80">状态</th>-->
  51. <th >操作</th>
  52. </thead>
  53. <tbody class="x-cate">
  54. {{range $index, $elem := .List}}
  55. <tr cate-id='{{$elem.Id}}' fid='0' >
  56. <td>
  57. <i class="layui-icon ">&#xe65b;</i>
  58. {{$elem.T_name}}
  59. </td>
  60. <td class="td-manage">
  61. <button class="layui-btn layui-btn layui-btn-xs" onclick="xadmin.open('编辑','Class_?id={{$elem.Id}}',400,400)" ><i class="layui-icon">&#xe642;</i>编辑</button>
  62. <button class="layui-btn-danger layui-btn layui-btn-xs" onclick="member_del(this,'{{$elem.Id}}')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
  63. </td>
  64. </tr>
  65. {{end}}
  66. </tbody>
  67. </table>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <script>
  74. layui.use(['form'], function(){
  75. form = layui.form;
  76. });
  77. /*用户-删除*/
  78. function member_del(obj,id){
  79. layer.confirm('确认要删除吗?',function(index){
  80. //发异步删除数据
  81. $(obj).parents("tr").remove();
  82. $.ajax({
  83. type: 'POST',
  84. url: 'Class_Del',//发送请求
  85. data: {Id:id},
  86. success: function(result) {
  87. console.log(result)
  88. if (result.Code == 200 ){
  89. layer.msg('已删除!', {
  90. icon: 1,
  91. time: 2000
  92. });
  93. window.location.reload();
  94. }else {
  95. layer.msg('删除失败!', {
  96. time: 2000
  97. });
  98. }
  99. }
  100. });
  101. });
  102. }
  103. // 分类展开收起的分类的逻辑
  104. //
  105. $(function(){
  106. $("tbody.x-cate tr[fid!='0']").hide();
  107. // 栏目多级显示效果
  108. $('.x-show').click(function () {
  109. if($(this).attr('status')=='true'){
  110. $(this).html('&#xe625;');
  111. $(this).attr('status','false');
  112. cateId = $(this).parents('tr').attr('cate-id');
  113. $("tbody tr[fid="+cateId+"]").show();
  114. }else{
  115. cateIds = [];
  116. $(this).html('&#xe623;');
  117. $(this).attr('status','true');
  118. cateId = $(this).parents('tr').attr('cate-id');
  119. getCateId(cateId);
  120. for (var i in cateIds) {
  121. $("tbody tr[cate-id="+cateIds[i]+"]").hide().find('.x-show').html('&#xe623;').attr('status','true');
  122. }
  123. }
  124. })
  125. })
  126. var cateIds = [];
  127. function getCateId(cateId) {
  128. $("tbody tr[fid="+cateId+"]").each(function(index, el) {
  129. id = $(el).attr('cate-id');
  130. cateIds.push(id);
  131. getCateId(id);
  132. });
  133. }
  134. </script>
  135. </body>
  136. </html>