article.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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('article_add',['id'=>$id])}" 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. <a href="{:url('index')}" class="btn btn-sm btn-primary">返回上一页</a>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="ibox-content">
  15. <div class="jqGrid_wrapper">
  16. <table id="table" style="border-collapse: collapse"></table>
  17. <div id="pager"></div>
  18. </div>
  19. </div>
  20. </div>
  21. {/block}
  22. {block name="script"}
  23. <script>
  24. $(function () {
  25. $(window).bind("resize",function(){
  26. var width=$(".jqGrid_wrapper").width();
  27. $("#table").setGridWidth(width);
  28. });
  29. $.jgrid.defaults.styleUI="Bootstrap";
  30. $("#table").jqGrid({
  31. url:"{:url('article',['id'=>$id])}",
  32. datatype: "json",
  33. colModel:[
  34. {label:'ID',name:'id',index:'id', width:30,sortable: false},
  35. {label:'题干',name:'title',index:'title',width:80,editable: false,sortable: false},
  36. {label:'分值',name:'score',index:'score',width:60,sortable: true},
  37. {label:'类型',name:'type',index:'type',width:30,editable: false,sortable: false,formatter:function (a,b,c){
  38. if(a == 1){
  39. return '多选';
  40. }else {
  41. return '单选';
  42. }
  43. }},
  44. {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
  45. var info_url = "{:url('edit_question',[],'')}/id/"+c.id;
  46. var del_url = "{:url('del_question',[],'')}/id/"+c.id;
  47. var btn = '<a url="'+info_url+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  48. btn += '<a href="'+del_url+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
  49. return btn;
  50. }},
  51. ],
  52. rowNum:10,
  53. rowList:[10,20,30,50,100],
  54. pager: '#pager',
  55. sortname: 'id',
  56. viewrecords: true,
  57. autowidth:true,
  58. mtype: 'post',
  59. height: 'auto',
  60. emptyrecords: "暂无数据",
  61. sortorder: "asc",
  62. caption:"{$m_name}",
  63. loadComplete: function (xhr) {
  64. if(xhr.code==0){
  65. layer.msg(xhr.msg);
  66. return false;
  67. }
  68. },
  69. });
  70. });
  71. </script>
  72. {/block}