index.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <div class="row content-nav">
  2. <div class="col-xs-12">
  3. <ul>
  4. <li><a href="javascript:;"><i></i>&nbsp;支付管理</a></li>
  5. <li><a href="javascript:;">支付列表</a></li>
  6. </ul>
  7. </div>
  8. </div>
  9. <section class="content clearfix">
  10. <div class="layui-list-box">
  11. <table class="layui-hide" id="list-box" lay-filter="list-box"></table>
  12. </div>
  13. </section>
  14. <script type="text/html" id="list-toolbar">
  15. <div class="layui-btn-container">
  16. <button lay-event="refresh" type="button" class="layui-btn layui-btn-sm layui-bg-red"><i class="layui-icon">&#xe9aa;</i> 刷新</button>
  17. </div>
  18. </script>
  19. <script type="text/html" id="checkboxTpl">
  20. <input type="checkbox" name="status" value="{{d.id}}" title="开启" lay-filter="status-filter" {{ d.status == 0 ? 'checked' : '' }}>
  21. </script>
  22. <script type="text/html" id="list-bar">
  23. {{# if(d.id != 1){ }}
  24. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  25. {{# } }}
  26. </script>
  27. <script>
  28. layui.use(['table','form'], function () {
  29. var table = layui.table;
  30. var form = layui.form;
  31. table.render({
  32. elem: '#list-box'
  33. , url: '{:createUrl("index")}'
  34. , toolbar: '#list-toolbar'
  35. , defaultToolbar: []
  36. , title: '数据表'
  37. , cols: [[
  38. {type: 'checkbox'}
  39. , {field: 'id', title: 'ID', width: 80, unresize: true, sort: true,align:"center"}
  40. , {field: 'name', title: '用户名'}
  41. , {field: 'sort', title: '排序', edit:true, width: 100, align:"center"}
  42. , {field:'status', title:'状态', width:120,align:"center",templet: '#checkboxTpl'}
  43. , {fixed: 'right', align: 'center', title: '操作', toolbar: '#list-bar', width: 130}
  44. ]]
  45. , text: {
  46. none: '<div><i class="layui-icon">&#xe702;</i>暂无相关数据</div>'
  47. }
  48. , page: true
  49. , height: 'full-200'
  50. // ,limit:30
  51. });
  52. //头工具栏事件
  53. table.on('toolbar(list-box)', function (obj) {
  54. switch (obj.event) {
  55. case 'refresh':
  56. window.location.reload();
  57. break;
  58. }
  59. });
  60. //监听行工具事件
  61. table.on('tool(list-box)', function (obj) {
  62. var data = obj.data;
  63. if (obj.event != 'edit') {
  64. return ;
  65. //window.location.href = '{:createUrl("editor")}?id='+data.id;
  66. }
  67. switch(data.code) {
  68. case "wechat-mp":
  69. case "wechat-h5":
  70. case "wechat-qrcode":
  71. window.location.href = '{:createUrl("wechat.index/pay")}';
  72. break;
  73. case "wechat-app":
  74. window.location.href = '{:createUrl("editor")}?id='+data.id;
  75. break;
  76. case "wechat-mini":
  77. window.location.href = '{:createUrl("wechat.mini/pay")}';
  78. break;
  79. case "alipay-app":
  80. case "alipay-web":
  81. case "alipay-wap":
  82. window.location.href = '{:createUrl("editor")}?id='+data.id;
  83. break;
  84. }
  85. });
  86. //监听单元格编辑
  87. table.on('edit(list-box)', function(obj){
  88. $.get('{:createUrl("field")}',{
  89. name : obj.field,
  90. value : obj.value,
  91. id : obj.data.id
  92. },function (result){
  93. if(!result.code){
  94. layer.msg(result.msg,{ icon : 2 });
  95. }
  96. },"json");
  97. });
  98. //监听锁定操作
  99. form.on('checkbox(status-filter)', function(obj){
  100. var that = this;
  101. $.get('{:createUrl("field")}',{
  102. name : that.name,
  103. value : (obj.elem.checked ? 0 : 1),
  104. id : that.value
  105. },function (result){
  106. if(!result.code){
  107. layer.msg(result.msg,{ icon : 2 });
  108. }
  109. },"json");
  110. });
  111. });
  112. </script>