configlist.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <fieldset class="layui-elem-field layui-field-title">
  5. <legend>{:lang('config')}{:lang('list')}</legend>
  6. <blockquote class="layui-elem-quote">
  7. <div class="LM-table">
  8. <div class="layui-inline">
  9. <input type="text" id='keys' name="keys" lay-verify="required" placeholder="{:lang('pleaseEnter')}" autocomplete="off" class="layui-input">
  10. </div>
  11. <a href="javascript:;" class="layui-btn data-add-btn layui-btn-sm" lay-submit="" lay-filter="search" id="search">{:lang('search')}</a>
  12. <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-warm" lay-filter="add" id="add">{:lang('add')}{:lang('config')}</a>
  13. <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger" lay-filter="group" id="group">{:lang('add')}{:lang('config group')}</a>
  14. <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-normal" lay-filter="grouplist" id="grouplist">{:lang('config group')}{:lang('list')}</a>
  15. </div>
  16. </blockquote>
  17. </fieldset>
  18. <table class="layui-table layui-hide" id="list" lay-filter="list"></table>
  19. </div>
  20. </div>
  21. <script type="text/html" id="action">
  22. <a class="layui-btn layui-btn-xs" lay-event="edit">{:lang('edit')}</a>
  23. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
  24. </script>
  25. <script type="text/html" id="status">
  26. <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
  27. </script>
  28. {include file="common/footer"/}
  29. <script>
  30. layui.use(['form', 'table'], function () {
  31. var $ = layui.jquery,
  32. form = layui.form,
  33. table = layui.table;
  34. var tableIn = table.render({
  35. elem: '#list',
  36. url: '{:url("configlist")}',
  37. method: 'post',
  38. cols: [[
  39. {checkbox: true, fixed: true},
  40. {field: 'id', title: 'ID', width: 80, sort: true},
  41. {field: 'code', title: '配置键', width: 120,sort: true},
  42. {field: 'value', title: '配置值', width: 250,sort: true},
  43. {field: 'type', title: '分组', width: 250,sort: true},
  44. {field: 'remark', title: '备注', width: 220,sort:true},
  45. {field: 'status', title: '状态', width: 180, templet:'#status'},
  46. {title:'操作',width:120, toolbar: '#action',align:"center"}
  47. ]],
  48. limits: [10, 15, 20, 25, 50, 100],
  49. limit: 15,
  50. page: true
  51. });
  52. table.on('tool(list)', function(obj){
  53. var data = obj.data;
  54. var id = data.id;
  55. if(obj.event === 'del'){
  56. layer.confirm('{:lang("Are you sure you want to delete it")}', function(index){
  57. loading =layer.load(1, {shade: [0.1,'#fff']});
  58. $.post("{:url('configDel')}",{id:data.id},function(res){
  59. layer.close(loading);
  60. if(res.code>0){
  61. layer.msg(res.msg,{time:1000,icon:1});
  62. obj.del();
  63. }else{
  64. layer.msg(res.msg,{time:1000,icon:2});
  65. }
  66. });
  67. });
  68. }else if(obj.event === 'edit'){
  69. var index = layer.open({
  70. type: 2,
  71. content: '{:url("configEdit")}?id='+id,
  72. area: ['600px', '800px'],
  73. maxmin: true
  74. });
  75. layer.full(index);
  76. }
  77. });
  78. form.on('switch(status)', function(data){
  79. loading =layer.load(1, {shade: [0.1,'#fff']});
  80. $.post("{:url('configState')}",{id:data.value},function(res){
  81. layer.close(loading);
  82. if(res.code>0){
  83. layer.msg(res.msg,{time:1000,icon:1});
  84. }else{
  85. layer.msg(res.msg,{time:1000,icon:2});
  86. }
  87. });
  88. });
  89. $('#search').click(function () {
  90. var $keys = $('#keys').val();
  91. if(!$keys){
  92. return layer.msg('请输入关键词');
  93. }
  94. tableIn.reload({ page: {page: 1},where: {keys: $keys}});
  95. })
  96. $('#add').click(function () {
  97. var index = layer.open({
  98. type: 2,
  99. content: '{:url("configAdd")}',
  100. area: ['600px', '800px'],
  101. maxmin: true
  102. });
  103. layer.full(index);
  104. })
  105. $('#group').click(function () {
  106. var index = layer.open({
  107. type: 2,
  108. content: '{:url("configGroupAdd")}',
  109. area: ['600px', '800px'],
  110. maxmin: true
  111. });
  112. layer.full(index);
  113. })
  114. $('#grouplist').click(function () {
  115. var index = layer.open({
  116. type: 2,
  117. content: '{:url("configGroup")}',
  118. area: ['600px', '800px'],
  119. maxmin: true
  120. });
  121. layer.full(index);
  122. })
  123. });
  124. </script>