index.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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="/static/public/layui/css/layui.css" media="all">
  10. <link rel="stylesheet" href="/static/public/font-awesome/css/font-awesome.min.css" media="all"/>
  11. <link rel="stylesheet" href="/static/admin/css/admin.css" media="all">
  12. <style type="text/css">
  13. /* tooltip */
  14. #tooltip {
  15. position: absolute;
  16. border: 1px solid #ccc;
  17. background: #333;
  18. padding: 2px;
  19. display: none;
  20. color: #fff;
  21. }
  22. .tooltip > img {
  23. width: 20px;
  24. height: 20px;
  25. }
  26. </style>
  27. </head>
  28. <body style="padding:10px;">
  29. <div class="tplay-body-div">
  30. <div class="layui-tab">
  31. <ul class="layui-tab-title">
  32. <li class="layui-this">列表</li>
  33. <li><a href="{:url('publish')}" class="a_menu">新增</a></li>
  34. </ul>
  35. </div>
  36. <script type="text/html" id="toolbarDemo">
  37. <div class="layui-btn-container">
  38. <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deletes">批量删除</button>
  39. </div>
  40. </script>
  41. <form class="layui-form serch" action="index" method="post">
  42. <div class="layui-form-item" style="float: left;">
  43. <div class="layui-input-inline">
  44. <input type="text" name="ids" autocomplete="off" placeholder="请输入ID,多个id逗号分隔"
  45. class="layui-input layui-btn-sm">
  46. </div>
  47. <div class="layui-input-inline">
  48. <input type="text" name="title" autocomplete="off" placeholder="标题(模糊搜索)"
  49. class="layui-input layui-btn-sm">
  50. </div>
  51. <div class="layui-input-inline" style="width:100px">
  52. <input type="number" name="admin_id" autocomplete="off" placeholder="发布人"
  53. class="layui-input layui-btn-sm">
  54. </div>
  55. <div class="layui-input-inline">
  56. <input type="text" class="layui-input time_range" id="time_range_create_time" autocomplete="off"
  57. placeholder="日期" name="create_time">
  58. </div>
  59. <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
  60. </div>
  61. </form>
  62. <script type="text/html" id="barDemo">
  63. <div class="layui-btn-group">
  64. <button class="layui-btn layui-btn-xs a_menu" lay-event="edit"><i class="layui-icon"
  65. style="margin-right: 0;"></i></button>
  66. <button class="layui-btn layui-btn-xs delete" lay-event="del"><i class="layui-icon"
  67. style="margin-right: 0;"></i></button>
  68. </div>
  69. </script>
  70. <table class="layui-table" id="table" lay-filter="table"></table>
  71. {include file="public/foot"}
  72. <script type="text/javascript">
  73. layui.use(['table', 'layer', 'form', 'laydate'], function () {
  74. var table = layui.table,
  75. form = layui.form,
  76. layer = layui.layer;
  77. var laydate = layui.laydate;
  78. //第一个实例
  79. table.render({
  80. id: 'table'
  81. , elem: '#table'
  82. , size: 'sm' //小尺寸的表格
  83. , toolbar: '#toolbarDemo'
  84. , limit: 15
  85. , limits: [15, 20, 30, 40, 50, 100]
  86. , url: "{:url('index')}" //数据接口
  87. , page: true //开启分页
  88. , cols: [[ //表头
  89. {type: 'checkbox'},
  90. {field: 'id', title: 'ID', width: 60},
  91. {field: "title", title: '标题'},
  92. {field: "admin_id", title: '发布人'},
  93. {field: "create_time", title: '日期'},
  94. {field: 'action', title: '操作', toolbar: '#barDemo', fixed: 'right'}
  95. ]],
  96. done: function () {
  97. if (isExitsFunction('showThumb')) {
  98. showThumb()
  99. }
  100. }
  101. });
  102. laydate.render({
  103. elem: '#time_range_create_time'
  104. , type: 'datetime'
  105. , range: true
  106. , max: 0 //最大值0天后
  107. , theme: 'molv'
  108. , calendar: true
  109. , done: function (value, date, endDate) {
  110. if (endDate.hours == 0 && endDate.minutes == 0 && endDate.seconds == 0) {
  111. setTimeout(function () {
  112. $('#time_range_create_time').val(value.replace(/00:00:00$/, '23:59:59'))
  113. }, 100)
  114. }
  115. }
  116. });
  117. form.on('submit(serch)', function (data) {
  118. table.reload('table', {
  119. where: data.field
  120. , page: {
  121. curr: 1 //重新从第 1 页开始
  122. }
  123. });
  124. return false;
  125. });
  126. table.on('tool(table)', function (obj) {
  127. if (obj.event == 'edit') {
  128. window.parent.tab.tabAdd({
  129. icon: "fa-bookmark",
  130. id: "tplay_announcement" + obj.data.id,
  131. title: obj.data.title == null ? "公告表" + obj.data.id : obj.data.title,
  132. url: "/admin/announcement/publish?id=" + obj.data.id
  133. });
  134. }
  135. else if (obj.event == 'del') {
  136. layer.confirm('确定要删除?', function (index) {
  137. $.ajax({
  138. url: "{:url('delete')}",
  139. dataType: 'json',
  140. data: {id: obj.data.id},
  141. success: function (res) {
  142. layer.msg(res.msg);
  143. if (res.code == 1) {
  144. table.reload('table');
  145. }
  146. }
  147. })
  148. })
  149. }
  150. });
  151. //监听事件
  152. table.on('toolbar(table)', function (obj) {
  153. if (obj.event == 'deletes') {
  154. var checkStatus = table.checkStatus(obj.config.id);//获取选中的数据
  155. var data = checkStatus.data;
  156. if (data.length > 0) {
  157. var ids = [];//数组
  158. data.forEach(function (item, key) {
  159. ids[key] = item.id;
  160. })
  161. layer.confirm('是否删除?', function (index, layero) {
  162. $.ajax({
  163. url: "{:url('deletes')}",
  164. dataType: 'json',
  165. data: {"ids": ids},
  166. type: 'post',
  167. success: function (res) {
  168. layer.msg(res.msg);
  169. if (res.code == 1) {
  170. table.reload('table');
  171. }
  172. }
  173. })
  174. layer.close(index)
  175. });
  176. } else {
  177. layer.msg('请先勾选需要操作的记录');
  178. }
  179. }
  180. });
  181. });
  182. </script>
  183. </div>
  184. </body>
  185. </html>