list.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <div class="layui-layout layui-layout-admin" style="padding-left: 20px;">
  2. <div class="layui-row" style="margin-top: 20px;">
  3. <div class="layui-col-xs6">
  4. <div class="layui-btn-group">
  5. <button class="layui-btn" id="add_api">增加</button>
  6. </div>
  7. <!-- <a class="layui-btn" data-type="tabAdd" href="/api/add">新增</a> -->
  8. <!-- <a href="javascript:;" id="add_api" class="layui-btn"> 新增接口 </a>
  9. <a href="javascript:;" id="add_audit" class="layui-btn layui-btn-primary"> 提交审核 </a> -->
  10. </div>
  11. <div class="layui-col-xs6 search_text">
  12. <form class="layui-form" action="" onsubmit="javascript:return false;">
  13. <div class="demoTable">
  14. <div class="layui-inline" style="width: 40%">
  15. <input class="layui-input" name="ApiPublicName" id="ApiPublicName" autocomplete="off" placeholder="文档名称" >
  16. </div>
  17. <button class="layui-btn" data-type="reload" id="reload">查询</button>
  18. </div>
  19. </form>
  20. </div>
  21. </div>
  22. <table class="layui-hide" id="table_list" lay-filter="table_filter">
  23. </table>
  24. <script type="text/html" id="bar">
  25. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  26. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  27. </script>
  28. </div>
  29. <script>
  30. layui.use(['table','form','element'], function(){
  31. var table = layui.table;
  32. var form = layui.form;
  33. var element = layui.element;
  34. //方法级渲染
  35. table.render({
  36. elem: '#table_list'
  37. ,url: '/apipublic/table'
  38. ,cols: [[
  39. // {checkbox: true, fixed: true},
  40. {field:'id', title: 'ID', align:'center',sort: true, width:50}
  41. ,{field:'api_public_name',title: '文档名称'}
  42. ,{field:'sort',title: '排序'}
  43. ,{field:'create_time', title: '创建时间'}
  44. ,{field:'update_time', title: '修改时间'}
  45. ,{fixed: 'right', width:160, align:'center', toolbar: '#bar'}
  46. ]]
  47. ,id: 'listReload'
  48. ,page: true
  49. ,height: "full-130"
  50. });
  51. var $ = layui.$, active = {
  52. reload: function(){
  53. table.reload('listReload', {
  54. where: {
  55. ApiPublicName: $('#ApiPublicName').val()
  56. }
  57. });
  58. }
  59. };
  60. $("#add_api").on("click",function() {
  61. window.location.href="/apipublic/add"
  62. })
  63. //监听工具条
  64. table.on('tool(table_filter)', function(obj){
  65. var data = obj.data;
  66. if(obj.event === 'edit'){
  67. window.location.href="/apipublic/edit?id="+data.id
  68. } else if(obj.event === 'del'){
  69. var msg = "确定要删除"+data.api_public_name+"吗?";
  70. layer.confirm(msg, function(){
  71. var del_data = {"id":data.id}
  72. $.post('{{urlfor "ApiPublicController.AjaxDel"}}', del_data, function (out) {
  73. if (out.status == 0) {
  74. layer.msg("操作成功",{icon: 1},function () {
  75. $("#reload").click();
  76. })
  77. } else {
  78. layer.msg(out.message)
  79. }
  80. }, "json");
  81. return false;
  82. });
  83. return false;
  84. }else{
  85. layer.msg('操作不存在');
  86. }
  87. });
  88. $('.demoTable .layui-btn').on('click', function(){
  89. var type = $(this).data('type');
  90. active[type] ? active[type].call(this) : '';
  91. });
  92. });
  93. </script>