lst.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!--加载公共头部文件-->
  2. {include file='Base/top'}
  3. <!--加载公共左侧文件-->
  4. {include file='Base/left'}
  5. <!--加载公共底部文件-->
  6. {include file='Base/fotter'}
  7. <!-- 内容主体区域 -->
  8. <div class="layui-body">
  9. <!--面包屑导航-->
  10. <blockquote class="layui-elem-quote">
  11. <span class="layui-breadcrumb" style="visibility: visible;">
  12. <a >栏目管理</a>
  13. <span lay-separator="">/</span>
  14. <a href="{:url('Column/lst')}">
  15. <cite>栏目列表</cite>
  16. </a>
  17. </span>
  18. </blockquote>
  19. <!--面包屑导航 结束-->
  20. <div >
  21. <button class="layui-btn layui-btn-normal layui-btn-xs" id="add">
  22. <i class="layui-icon">&#xe654;</i>添加
  23. </button>
  24. <button class="layui-btn layui-btn-normal layui-btn-xs" id="up">
  25. <i class="layui-icon">&#xe62f;</i> 更新排序
  26. </button>
  27. </div>
  28. <form class="layui-form" action="{:url('Column/sort')}" method="post" id="vo_form">
  29. <table class="layui-table" id="deleteds">
  30. <thead>
  31. <tr width="100">
  32. <th width="6%" style="text-align: center;">栏目ID</th>
  33. <th width="10%" style="text-align: center;">栏目名称</th>
  34. <th width="10%" style="text-align: center;">权重</th>
  35. <th width="30">操作</th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. {volist name='list' id='vo'}
  40. <tr>
  41. <td align="center">{$vo.id}</td>
  42. <td align="center">{$vo.catename}</td>
  43. <td>
  44. <input type="text" class="layui-input x-sort" name="sort[{$vo['id']}]" value="{$vo.sort}">
  45. </td>
  46. <td>
  47. <div class="layui-btn-group">
  48. <a class="layui-btn layui-btn-xs" onclick="edit({$vo['id']})" >
  49. <i class="layui-icon">&#xe642;</i>编辑
  50. </a>
  51. <a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs delete" id="{$vo.id}" style="margin-right: 0;font-size:12px;">
  52. <i class="layui-icon">&#xe640;</i>删除
  53. </a>
  54. </div>
  55. </td>
  56. </tr>
  57. {/volist}
  58. </tbody>
  59. </table>
  60. <!-- 分页 -->
  61. <div class="pages" style="text-align:center;">
  62. <div class="plist" >{$list->render()}</div>
  63. </div>
  64. </form>
  65. </div>
  66. <!-- 内容主体区域 结束-->
  67. <script>
  68. layui.use(['table','layer','laypage','jquery'], function(){
  69. var table = layui.table,
  70. layer = layui.layer,
  71. laypage = layui.laypage,
  72. $ = layui.jquery;
  73. //点击添加
  74. $("#add").click(function () {
  75. layer.open({
  76. type: 2, //open类型
  77. title: false, //新开窗口标题 无
  78. offset: 'auto', //上下左右居中
  79. area: ['800px','700px'], //新开add页面窗口大小
  80. content: '{:url("column/add")}', //这里content是一个URL,如果你不想让iframe出现滚动条,你还可以content: ['http://sentsin.com', 'no']
  81. end: function () {
  82. location.reload();
  83. }
  84. });
  85. });
  86. //更新排序
  87. $("#up").click(function () {
  88. $.ajax({
  89. type:'post',
  90. url:'{:url("sort")}',
  91. data: $('#vo_form').serialize(), //获取表单提交的所有数据
  92. success: function(data) {
  93. layer.msg('规则排序成功!',{time:1000,icon: 1},function () {
  94. location.reload(true);//刷新当前页面
  95. });
  96. },
  97. error: function(err) {
  98. layer.msg(err, {time:1000,icon: 2},function () {
  99. location.reload(true);//刷新当前页面
  100. });
  101. }
  102. });
  103. })
  104. //删除
  105. $('.delete').click(function(){
  106. var id = $(this).attr('id');
  107. layer.confirm('确定要删除?',{icon: 5}, function(index) {
  108. $.ajax({
  109. url:"{:url('admin/Column/del')}?id="+id,
  110. data:{id:id},
  111. success:function(res) {
  112. layer.msg(res.msg);
  113. if(res.data == 200) {
  114. setTimeout(function(){
  115. window.location.reload();
  116. },1000)
  117. }
  118. }
  119. })
  120. })
  121. })
  122. });
  123. </script>
  124. <script type="text/javascript">
  125. //点击编辑
  126. function edit($id) {
  127. layer.open({
  128. type: 2, //open类型
  129. title: false, //新开窗口标题 无
  130. offset: 'auto', //上下左右居中
  131. area: ['800px','700px'], //新开add页面窗口大小
  132. content: '{:url("edit")}?id='+$id, //这里content是一个URL,传递要编辑的参数
  133. end: function () {
  134. location.reload();
  135. }
  136. });
  137. };
  138. </script>