index.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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逗号分隔" class="layui-input layui-btn-sm">
  45. </div><div class="layui-input-inline">
  46. <input type="text" name="name" autocomplete="off" placeholder="名字(模糊搜索)" class="layui-input layui-btn-sm">
  47. </div><div class="layui-input-inline">
  48. <input type="text" name="head_pic" autocomplete="off" placeholder="头像(模糊搜索)" class="layui-input layui-btn-sm">
  49. </div><div class="layui-input-inline" style="width:100px">
  50. <input type="number" name="sex" autocomplete="off" placeholder="性别" class="layui-input layui-btn-sm">
  51. </div><div class="layui-input-inline">
  52. <input type="text" name="desc" autocomplete="off" placeholder="简介(模糊搜索)" class="layui-input layui-btn-sm">
  53. </div><div class="layui-input-inline">
  54. <input type="text" name="consultation_direction" autocomplete="off" placeholder="咨询方向(模糊搜索)" class="layui-input layui-btn-sm">
  55. </div><div class="layui-input-inline" style="width:100px">
  56. <input type="number" name="address_id" autocomplete="off" placeholder="地址" class="layui-input layui-btn-sm">
  57. </div>
  58. <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
  59. </div>
  60. </form>
  61. <script type="text/html" id="barDemo">
  62. <div class="layui-btn-group">
  63. <button class="layui-btn layui-btn-xs a_menu" lay-event="edit"><i class="layui-icon" style="margin-right: 0;"></i></button>
  64. <button class="layui-btn layui-btn-xs delete" lay-event="del"><i class="layui-icon" style="margin-right: 0;"></i></button>
  65. </div>
  66. </script>
  67. <table class="layui-table" id="table" lay-filter="table"></table>
  68. {include file="public/foot"}
  69. <script type="text/javascript">
  70. layui.use(['table', 'layer', 'form','laydate'], function () {
  71. var table = layui.table,
  72. form = layui.form,
  73. layer = layui.layer;
  74. var laydate = layui.laydate;
  75. //第一个实例
  76. table.render({
  77. id: 'table'
  78. , elem: '#table'
  79. , size: 'sm' //小尺寸的表格
  80. , toolbar: '#toolbarDemo'
  81. , limit: 15
  82. , limits: [15, 20, 30, 40, 50, 100]
  83. , url: "{:url('index')}" //数据接口
  84. , page: true //开启分页
  85. , cols: [[ //表头
  86. {type: 'checkbox'},
  87. {field: 'id', title: 'ID', width: 60},
  88. {field: "name", title: '名字'},
  89. {field: "head_pic", title: '头像'},
  90. {field: "sex", title: '性别'},
  91. {field: "desc", title: '简介'},
  92. {field: "consultation_direction", title: '咨询方向'},
  93. {field: "address_id", title: '地址'},
  94. {field: 'action', title: '操作', toolbar: '#barDemo', fixed: 'right'}
  95. ]],
  96. done: function () {
  97. if (isExitsFunction('showThumb')) {
  98. showThumb()
  99. }
  100. }
  101. });
  102. form.on('submit(serch)', function (data) {
  103. table.reload('table', {
  104. where: data.field
  105. , page: {
  106. curr: 1 //重新从第 1 页开始
  107. }
  108. });
  109. return false;
  110. });
  111. table.on('tool(table)', function (obj) {
  112. if (obj.event == 'edit') {
  113. window.parent.tab.tabAdd({
  114. icon: "fa-bookmark",
  115. id: "tplay_specialist" + obj.data.id,
  116. title: obj.data.title == null ? "专家" + obj.data.id : obj.data.title,
  117. url: "/admin/specialist/publish?id=" + obj.data.id
  118. });
  119. }
  120. else if (obj.event == 'del') {
  121. layer.confirm('确定要删除?', function (index) {
  122. $.ajax({
  123. url: "{:url('delete')}",
  124. dataType: 'json',
  125. data: {id: obj.data.id},
  126. success: function (res) {
  127. layer.msg(res.msg);
  128. if (res.code == 1) {
  129. table.reload('table');
  130. }
  131. }
  132. })
  133. })
  134. }
  135. });
  136. //监听事件
  137. table.on('toolbar(table)', function (obj) {
  138. if (obj.event == 'deletes') {
  139. var checkStatus = table.checkStatus(obj.config.id);//获取选中的数据
  140. var data = checkStatus.data;
  141. if (data.length > 0) {
  142. var ids = [];//数组
  143. data.forEach(function (item, key) {
  144. ids[key] = item.id;
  145. })
  146. layer.confirm('是否删除?', function (index, layero) {
  147. $.ajax({
  148. url: "{:url('deletes')}",
  149. dataType: 'json',
  150. data: {"ids": ids},
  151. type: 'post',
  152. success: function (res) {
  153. layer.msg(res.msg);
  154. if (res.code == 1) {
  155. table.reload('table');
  156. }
  157. }
  158. })
  159. layer.close(index)
  160. });
  161. } else {
  162. layer.msg('请先勾选需要操作的记录');
  163. }
  164. }
  165. });
  166. });
  167. </script>
  168. </div>
  169. </body>
  170. </html>