index.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <div class="ibox">
  4. <div class="ibox-content">
  5. <div class="row">
  6. <div class="col-xs-3">
  7. <a href="javascript:;" url="{:url('add')}" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
  8. </div>
  9. </div>
  10. </div>
  11. <div class="ibox-content">
  12. <div class="jqGrid_wrapper">
  13. <table id="table" style="border-collapse: collapse"></table>
  14. <div id="pager"></div>
  15. </div>
  16. </div>
  17. </div>
  18. {/block}
  19. {block name="script"}
  20. <script>
  21. $(function () {
  22. $(window).bind("resize",function(){
  23. var width=$(".jqGrid_wrapper").width();
  24. $("#table").setGridWidth(width);
  25. });
  26. $.jgrid.defaults.styleUI="Bootstrap";
  27. $("#table").jqGrid({
  28. url:"{:url('index')}",
  29. datatype: "json",
  30. colModel:[
  31. {label:'编号',name:'id',index:'id', width:40,sortable: false},
  32. {label:'名称',name:'title',index:'title', width:70,sortable: false},
  33. {label:'创建时间',name:'create_time',index:'create_time',width:80,editable: false,sortable: false},
  34. {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
  35. var editurl = "{:url('add',[],'')}/id/"+c.id;
  36. var delurl = "{:url('del',[],'')}/id/"+c.id;
  37. var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  38. btn += '<a {if !btnAuth(session("user_auth.id"),"NewsCate/del")} style="display:none"{/if} href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
  39. return btn;
  40. }},
  41. ],
  42. rowNum:10,
  43. rowList:[10,20,30,50,100],
  44. pager: '#pager',
  45. sortname: 'sort',
  46. viewrecords: true,
  47. autowidth:true,
  48. mtype: 'post',
  49. height: 'auto',
  50. emptyrecords: "暂无数据",
  51. sortorder: "asc",
  52. caption:"新闻分类",
  53. loadComplete: function (xhr) {
  54. if(xhr.code==0){
  55. layer.msg(xhr.msg);
  56. return false;
  57. }
  58. },
  59. });
  60. });
  61. </script>
  62. {/block}