index2.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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('add2')}" data-title="新增" 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('index2')}">
  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. </select>
  20. </div>
  21. <div class="input-group">
  22. <select name="type" class="form-control">
  23. <option value="">请选择分类</option>
  24. {foreach $typeList as $k=>$v}
  25. <option value="{$v.id}">{$v.name}</option>
  26. {/foreach}
  27. </select>
  28. </div>
  29. <div class="input-group">
  30. <span class="input-group-btn">
  31. <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
  32. </span> &nbsp;
  33. <span class="input-group-btn">
  34. <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  35. </span>
  36. </div>
  37. </form>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="ibox-content">
  42. <div class="jqGrid_wrapper">
  43. <table id="table" style="border-collapse: collapse"></table>
  44. <div id="pager"></div>
  45. </div>
  46. </div>
  47. </div>
  48. {/block}
  49. {block name="script"}
  50. <script>
  51. $(function () {
  52. $(window).bind("resize",function(){
  53. var width=$(".jqGrid_wrapper").width();
  54. $("#table").setGridWidth(width);
  55. });
  56. $.jgrid.defaults.styleUI="Bootstrap";
  57. $("#table").jqGrid({
  58. url:"{:url('index2')}",
  59. datatype: "json",
  60. colModel:[
  61. {label:'编号',name:'id',index:'id',width:100,editable: false,sortable: false,formatter:function (a,b,c){
  62. return '<span style="background-color: black;color: white" class="label">#'+a+'</span>'
  63. }},
  64. {label:'食品名',name:'name',index:'name',width:150,sortable: false},
  65. {label:'分类',name:'dinner_type_id',index:'dinner_type_id',width:100,editable: false,sortable: false,formatter:function (a,b,c){
  66. return '<span style="background-color: '+c.dinner_type.color+';color: white" class="label">'+c.dinner_type.name+'</span>'
  67. }},
  68. {label:'价格',name:'money',index:'money',width:100,editable: false,sortable: false,formatter:function (a,b,c){
  69. return '¥'+a+'';
  70. }},
  71. {label:'图片',name:'img',index:'img',width:80,editable: false,sortable: false,formatter: function (a, b, c) {
  72. return '<img src="'+a+'" width="40" onclick="open_img(this)"></img>';
  73. }},
  74. {label:'是否上架',name:'enable',index:'enable',width:120,editable: false,sortable: false,formatter:function (a,b,c){
  75. if(a == 0){
  76. var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
  77. return '<input type="checkbox" href="'+url+'" class="ajax-get label-danger" data-table="1">已下架';
  78. } else{
  79. var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
  80. return '<input type="checkbox" checked href="'+url+'" class="ajax-get label-primary" data-table="1">已上架';
  81. }
  82. }},
  83. {label:'菜品类型',name:'type',index:'type',width:120,editable: false,sortable: false,formatter:function (a,b,c){
  84. if(a == 0){
  85. return '普通';
  86. } else{
  87. return '流食或半流食';
  88. }
  89. }},
  90. {label:'排序',name:'sort',index:'sort',width:80,sortable: false},
  91. {label:'操作',width:80,sortable: false,formatter: function (a, b, c) {
  92. var editurl = "{:url('add2',[],'')}/id/"+c.id;
  93. var delurl = "{:url('del',[],'')}/id/"+c.id;
  94. btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  95. return btn;
  96. }},
  97. ],
  98. rowNum:10,
  99. rowList:[10,20,30,50,100],
  100. pager: '#pager',
  101. sortname: 'id',
  102. viewrecords: true,
  103. autowidth:true,
  104. autoScroll: false,
  105. shrinkToFit: true,
  106. mtype: 'post',
  107. height: 'auto',
  108. emptyrecords: "暂无数据",
  109. sortorder: "desc",
  110. caption:"特殊人群菜单",
  111. loadComplete: function (xhr) {
  112. if(xhr.code==0){
  113. layer.msg(xhr.msg);
  114. return false;
  115. }
  116. },
  117. });
  118. /*固定表头及侧边*/
  119. $("#table").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "auto" });
  120. $("#table").jqGrid('setFrozenColumns');
  121. });
  122. </script>
  123. {/block}