截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lists.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <div class="layui-card-body">
  5. <!--搜索条件-->
  6. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  7. <div class="layui-form-item">
  8. <div class="layui-inline">
  9. <label class="layui-form-label">账号</label>
  10. <div class="layui-input-block">
  11. <input type="text" name="account" id="account" placeholder="请输入" autocomplete="off" class="layui-input">
  12. </div>
  13. </div>
  14. <div class="layui-inline">
  15. <label class="layui-form-label">名称</label>
  16. <div class="layui-input-block">
  17. <input type="text" name="name" id="name" placeholder="请输入" autocomplete="off" class="layui-input">
  18. </div>
  19. </div>
  20. <div class="layui-inline">
  21. <label class="layui-form-label">角色</label>
  22. <div class="layui-input-block">
  23. <select name="role_id" id="role_id">
  24. <option value="">所有</option>
  25. {volist name="role_lists" id="vo"}
  26. <option value="{$vo.id}">{$vo.name}</option>
  27. {/volist}
  28. </select>
  29. </div>
  30. </div>
  31. <div class="layui-inline">
  32. <button class="layui-btn layui-btn-sm layuiadmin-btn-admin {$view_theme_color}" lay-submit lay-filter="LAY-user-back-search">
  33. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  34. </button>
  35. <button class="layui-btn layui-btn-sm layui-btn-primary " lay-submit lay-filter="table-clear-search">
  36. 清空查询
  37. </button>
  38. </div>
  39. </div>
  40. </div>
  41. <!--添加按钮-->
  42. <div style="padding-bottom: 10px;">
  43. <button class="layui-btn layui-btn-sm layuiadmin-btn-admin {$view_theme_color} like-auth" auth-uri="admin/add" data-type="add">添加</button>
  44. </div>
  45. <!--表格-->
  46. <table id="admin-lists" lay-filter="admin-lists"></table>
  47. <!--js模板-->
  48. <script type="text/html" id="login-state">
  49. {{# if(d.login_state == 1){ }}
  50. <button class="layui-btn layui-btn-xs {$view_theme_button}">在线</button>
  51. {{# } else { }}
  52. <button class="layui-btn layui-btn-xs layui-btn-primary">下线</button>
  53. {{# } }}
  54. </script>
  55. <script type="text/html" id="buttonTpl">
  56. {{# if(d.disable == 1){ }}
  57. <button class="layui-btn layui-btn-danger layui-btn-xs layui-bg-red">禁用</button>
  58. {{# } else { }}
  59. <button class="layui-btn layui-btn-xs layui-btn-primary">启用</button>
  60. {{# } }}
  61. </script>
  62. <script type="text/html" id="admin-operation">
  63. {{# if(d.root == 1){ }}
  64. <a class="layui-btn layui-btn-disabled layui-btn-xs"><i class="layui-icon layui-icon-edit like-auth" auth-uri="admin/edit"></i>编辑</a>
  65. <a class="layui-btn layui-btn-disabled layui-btn-xs"><i class="layui-icon layui-icon-delete"></i>删除</a>
  66. {{# } else { }}
  67. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  68. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  69. {{# } }}
  70. </script>
  71. </div>
  72. </div>
  73. </div>
  74. <script>
  75. layui.use(['table'], function(){
  76. var form = layui.form
  77. ,table = layui.table;
  78. //监听搜索
  79. form.on('submit(LAY-user-back-search)', function(data){
  80. var field = data.field;
  81. //执行重载
  82. table.reload('admin-lists', {
  83. where: field,
  84. page: {curr: 1},
  85. });
  86. });
  87. //清空查询
  88. form.on('submit(table-clear-search)', function () {
  89. $('#account').val('');
  90. $('#name').val('');
  91. $('#role_id').val('');
  92. form.render('select');
  93. //刷新列表
  94. table.reload('admin-lists', {
  95. where: [],
  96. page: {curr: 1},
  97. });
  98. });
  99. //事件
  100. var active = {
  101. add: function(){
  102. layer.open({
  103. type: 2
  104. ,title: '添加管理员'
  105. ,content: '{:url("admin/add")}'
  106. ,area: ['90%', '90%']
  107. ,btn: ['确定', '取消']
  108. ,yes: function(index, layero){
  109. var iframeWindow = window['layui-layer-iframe'+ index]
  110. ,submitID = 'admin-submit'
  111. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  112. //监听提交
  113. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  114. var field = data.field;
  115. like.ajax({
  116. url:'{:url("admin/add")}',
  117. data:field,
  118. type:"post",
  119. success:function(res)
  120. {
  121. if(res.code == 1) {
  122. layui.layer.msg(res.msg, {
  123. offset: '15px'
  124. , icon: 1
  125. , time: 1000
  126. });
  127. layer.close(index); //关闭弹层
  128. table.reload('admin-lists'); //数据刷新
  129. }
  130. }
  131. });
  132. });
  133. submit.trigger('click');
  134. }
  135. });
  136. }
  137. };
  138. $('.layui-btn.layuiadmin-btn-admin').on('click', function(){
  139. var type = $(this).data('type');
  140. active[type] ? active[type].call(this) : '';
  141. });
  142. like.tableLists('#admin-lists', '{:url("admin/lists")}', [
  143. {field: 'id', width: 60, title: 'ID', sort: true}
  144. ,{field: 'account',width:100, title: '账号'}
  145. ,{field: 'name',width:100, title: '名称'}
  146. ,{field: 'role', width:120,title: '角色'}
  147. ,{field: 'create_time',width:170, title: '创建时间', sort: true}
  148. ,{field: 'login_time', width:170,title: '最后登录时间', sort: true}
  149. ,{field: 'login_ip', width:140,title: '最后登录ip',}
  150. // ,{field: 'login_state',width:90, title:'登录状态', templet: '#login-state', minWidth: 40, align: 'center'}
  151. ,{field: 'disable', width:70,title:'状态', templet: '#buttonTpl', minWidth: 40, align: 'center'}
  152. ,{title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#admin-operation'}
  153. ]);
  154. //监听工具条
  155. table.on('tool(admin-lists)', function(obj){
  156. if(obj.event === 'del'){
  157. var id = obj.data.id;
  158. layer.prompt({
  159. formType: 1
  160. ,title: '删除操作,请输ok继续操作'
  161. }, function(value, index){
  162. if(value!='ok'){
  163. layer.close(index);
  164. layer.msg('口令输入错误');
  165. return;
  166. }
  167. layer.close(index);
  168. layer.confirm('确定删除此管理员?', function(index){
  169. like.ajax({
  170. url:'{:url("admin/del")}',
  171. data:{'admin_id':id},
  172. type:"post",
  173. success:function(res)
  174. {
  175. if(res.code == 1) {
  176. obj.del();
  177. layui.layer.msg(res.msg, {
  178. offset: '15px'
  179. , icon: 1
  180. , time: 1000
  181. });
  182. layer.close(index);
  183. }
  184. }
  185. });
  186. });
  187. });
  188. }else if(obj.event === 'edit'){
  189. var id = obj.data.id;
  190. layer.open({
  191. type: 2
  192. ,title: '编辑管理员'
  193. ,content: '{:url("admin/edit")}?admin_id='+id
  194. ,area: ['90%', '90%']
  195. ,btn: ['确定', '取消']
  196. ,yes: function(index, layero){
  197. var iframeWindow = window['layui-layer-iframe'+ index]
  198. ,submitID = 'admin-submit-edit'
  199. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  200. //监听提交
  201. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  202. var field = data.field;
  203. like.ajax({
  204. url:'{:url("admin/edit")}',
  205. data:field,
  206. type:"post",
  207. success:function(res)
  208. {
  209. if(res.code == 1) {
  210. layui.layer.msg(res.msg, {
  211. offset: '15px'
  212. , icon: 1
  213. , time: 1000
  214. });
  215. layer.close(index); //关闭弹层
  216. table.reload('admin-lists'); //数据刷新
  217. }
  218. }
  219. });
  220. });
  221. submit.trigger('click');
  222. }
  223. })
  224. }
  225. });
  226. });
  227. </script>