template.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  24. </script>
  25. <script>
  26. layui.use(['table','form'], function () {
  27. var table = layui.table;
  28. var form = layui.form;
  29. table.render({
  30. elem: '#list-box'
  31. , url: '{:createUrl("template")}'
  32. , toolbar: '#list-toolbar'
  33. , defaultToolbar: []
  34. , title: '数据表'
  35. , cols: [[
  36. {type: 'checkbox'}
  37. , {field: 'sign', title: '标识',width:160,align: "center"}
  38. , {field: 'sign_name', title: '签名名称',width:160,align: "center"}
  39. , {field: 'template_code', title: '模版CODE',width:160,align: "center"}
  40. , {field: 'template_name', title: '模板名称',align: "center"}
  41. , {field: 'template_param', title: '模板变量',width:250}
  42. , {fixed: 'right', align: 'center', title: '操作', toolbar: '#list-bar', width: 80}
  43. ]]
  44. , text: {
  45. none: '<div><i class="layui-icon">&#xe702;</i>暂无相关数据</div>'
  46. }
  47. , page: true
  48. , height: 'full-200'
  49. // ,limit:30
  50. });
  51. //头工具栏事件
  52. table.on('toolbar(list-box)', function (obj) {
  53. switch (obj.event) {
  54. case 'refresh':
  55. window.location.reload();
  56. break;
  57. }
  58. });
  59. //监听行工具事件
  60. table.on('tool(list-box)', function (obj) {
  61. var data = obj.data;
  62. if (obj.event === 'edit') {
  63. window.location.href = '{:createUrl("template_editor")}?id='+data.id;
  64. }
  65. });
  66. //监听锁定操作
  67. form.on('checkbox(status-filter)', function(obj){
  68. var that = this;
  69. $.get('{:createUrl("field")}',{
  70. name : that.name,
  71. value : (obj.elem.checked ? 0 : 1),
  72. id : that.value
  73. },function (result){
  74. if(!result.code){
  75. layer.msg(result.msg,{ icon : 2 });
  76. }
  77. },"json");
  78. });
  79. });
  80. </script>