index.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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="{:url('add')}" 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:20,sortable: false},
  32. {label:'名称',name:'title',index:'title', width:70,sortable: false},
  33. {label:'创建时间',name:'create_time',index:'create_time', width:70,sortable: false},
  34. {label:'备注',name:'remark',index:'remark', width:70,sortable: false},
  35. {label:'状态',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
  36. if(a == 0){
  37. var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
  38. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
  39. } else{
  40. var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
  41. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
  42. }
  43. }},
  44. {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
  45. var editurl = "{:url('add',[],'')}/id/"+c.id;
  46. var delurl = "{:url('del',[],'')}/id/"+c.id;
  47. var recordurl = "{:url('record',[],'')}/id/"+c.id;
  48. var btn = '<a href="'+editurl+'"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  49. btn += '<a href="'+recordurl+'"><span class="label label-success" title="记录">记录</span></a>&nbsp;';
  50. btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
  51. return btn;
  52. }},
  53. ],
  54. rowNum:10,
  55. rowList:[10,20,30,50,100],
  56. pager: '#pager',
  57. sortname: 'sort',
  58. viewrecords: true,
  59. autowidth:true,
  60. mtype: 'post',
  61. height: 'auto',
  62. emptyrecords: "暂无数据",
  63. sortorder: "asc",
  64. caption:"品质督查列表",
  65. loadComplete: function (xhr) {
  66. if(xhr.code==0){
  67. layer.msg(xhr.msg);
  68. return false;
  69. }
  70. },
  71. });
  72. });
  73. </script>
  74. {/block}