index.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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="新增{$m_name}" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
  8. </div>
  9. <div class="col-xs-9" style="text-align: right;">
  10. <form class="form-inline" id="form-search" action="{:url('index')}">
  11. <div class="input-group">
  12. <input type="text" class="form-control" name="title" placeholder="名称">
  13. </div>
  14. <div class="input-group">
  15. <select name="enable" class="form-control">
  16. <option value="">选择类型</option>
  17. <option value="0">草稿</option>
  18. <option value="1">已发布</option>
  19. <option value="2">未发布</option>
  20. </select>
  21. </div>
  22. <div class="input-group">
  23. <span class="input-group-btn">
  24. <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
  25. </span> &nbsp;
  26. <span class="input-group-btn">
  27. <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  28. </span>
  29. </div>
  30. </form>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="ibox-content">
  35. <div class="jqGrid_wrapper">
  36. <table id="table" style="border-collapse: collapse"></table>
  37. <div id="pager"></div>
  38. </div>
  39. </div>
  40. </div>
  41. {/block}
  42. {block name="script"}
  43. <script>
  44. $(function () {
  45. $(window).bind("resize",function(){
  46. var width=$(".jqGrid_wrapper").width();
  47. $("#table").setGridWidth(width);
  48. });
  49. $.jgrid.defaults.styleUI="Bootstrap";
  50. $("#table").jqGrid({
  51. url:"{:url('index')}",
  52. datatype: "json",
  53. colModel:[
  54. {label:'ID',name:'id',index:'id', width:30,sortable: false},
  55. {label:'名称',name:'title',index:'title',width:50,editable: false,sortable: false},
  56. {label:'关联文章',name:'article_title',index:'article_title',width:50,editable: false,sortable: false},
  57. {label:'考试次数',name:'limits',index:'limits',width:30,editable: false,sortable: false},
  58. {label:'状态',name:'status',index:'status',width:30,editable: false,sortable: false,formatter:function (a,b,c){
  59. if(a == 1){
  60. return '暂停';
  61. }else if(a==0){
  62. return '草稿';
  63. }else {
  64. return '已发布';
  65. }
  66. }},
  67. {label:'操作',width:100,sortable: false,formatter: function (a, b, c) {
  68. var fb_url = "{:url('fb',[],'')}/id/"+c.id+"/status/"+c.status;
  69. var edit_url = "{:url('add',[],'')}/id/"+c.id;
  70. var del_url = "{:url('del',[],'')}/id/"+c.id;
  71. var article_url = "{:url('article',[],'')}/id/"+c.id;
  72. var article_rank_url = "{:url('article_rank',[],'')}/id/"+c.id;
  73. var article_log_url = "{:url('article_log',[],'')}/id/"+c.id;
  74. var btn = '<a url="'+edit_url+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  75. if(c.status==2){
  76. btn += '<a href="'+fb_url+'" class="confirm ajax-get" data-confirm="确定要暂停此记录吗?" data-table="1"><span class="label label-primary" title="暂停">暂停</span></a>&nbsp;';
  77. }
  78. if(c.status==0 ||c.status==1 ){
  79. btn += '<a href="'+fb_url+'" class="confirm ajax-get" data-confirm="确定要发布此记录吗?" data-table="1"><span class="label label-primary" title="发布">发布</span></a>&nbsp;';
  80. }
  81. btn += '<a {if !btnAuth(session("user_auth.id"),"ArticlePaper/del")} style="display:none" {/if} href="'+del_url+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>&nbsp;';
  82. btn += '<a href="'+article_url+'" ><span class="label label-primary" title="试题管理">试题管理</span></a>&nbsp;';
  83. btn += '<a url="'+article_rank_url+'" href="javascript:;" data-title="考试排名" onclick="layer_open(this,1)"><span class="label label-primary" title="考试排名">考试排名</span></a>&nbsp;';
  84. btn += '<a href="'+article_log_url+'" ><span class="label label-primary" title="考试记录">考试记录</span></a>';
  85. return btn;
  86. }},
  87. ],
  88. rowNum:10,
  89. rowList:[10,20,30,50,100],
  90. pager: '#pager',
  91. sortname: 'id',
  92. viewrecords: true,
  93. autowidth:true,
  94. mtype: 'post',
  95. height: 'auto',
  96. emptyrecords: "暂无数据",
  97. sortorder: "desc",
  98. caption:"{$m_name}列表",
  99. loadComplete: function (xhr) {
  100. if(xhr.code==0){
  101. layer.msg(xhr.msg);
  102. return false;
  103. }
  104. },
  105. });
  106. });
  107. </script>
  108. {/block}