items.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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-12" style="text-align: right;">
  7. <form class="form-inline" id="form-search" action="{:url('items')}">
  8. <input type="hidden" name="id" value="{$id}">
  9. <input type="hidden" name="day" value="{$day}">
  10. <input type="hidden" name="typeId" value="{$typeId}">
  11. <div class="input-group">
  12. <input type="text" class="form-control" name="title" placeholder="名称">
  13. </div>
  14. <div class="input-group">
  15. <span class="input-group-btn">
  16. <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
  17. </span> &nbsp;
  18. <span class="input-group-btn">
  19. <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  20. </span>
  21. </div>
  22. </form>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="ibox-content">
  27. <div class="jqGrid_wrapper">
  28. <table id="table" style="border-collapse: collapse"></table>
  29. <div id="pager"></div>
  30. </div>
  31. </div>
  32. </div>
  33. {/block}
  34. {block name="script"}
  35. <script>
  36. $(function () {
  37. $(window).bind("resize",function(){
  38. var width=$(".jqGrid_wrapper").width();
  39. $("#table").setGridWidth(width);
  40. });
  41. $.jgrid.defaults.styleUI="Bootstrap";
  42. $("#table").jqGrid({
  43. url:"{:url('items',['id'=>$id,'typeId'=>$typeId,'day'=>$day])}",
  44. datatype: "json",
  45. colModel:[
  46. {label:'编号',name:'id',index:'id',width:100,editable: false,sortable: false,formatter:function (a,b,c){
  47. return '<span style="background-color: black;color: white" class="label">#'+a+'</span>'
  48. }},
  49. {label:'食品名',name:'name',index:'name',width:150,sortable: false},
  50. {label:'价格',name:'money',index:'money',width:100,editable: false,sortable: false,formatter:function (a,b,c){
  51. return '¥'+a+'';
  52. }},
  53. {label:'图片',name:'img',index:'img',width:80,editable: false,sortable: false,formatter: function (a, b, c) {
  54. return '<img src="'+a+'" width="40" onclick="open_img(this)" />';
  55. }},
  56. {label:'操作',width:120,sortable: false,formatter: function (a, b, c) {
  57. var editurl = "{:url('itemsave',['groupId'=>$id,'day'=>$day],'',false)}/id/"+c.id;
  58. var btn = '';
  59. btn += '<a href="'+editurl+'" class="confirm ajax-get" data-confirm="确定要选择此菜品吗?" data-table="1"><span class="label label-primary" title="选择">选择</span></a>';
  60. return btn;
  61. }},
  62. ],
  63. rowNum:10,
  64. rowList:[10,20,30,50,100],
  65. pager: '#pager',
  66. sortname: 'id',
  67. viewrecords: true,
  68. autowidth:true,
  69. mtype: 'post',
  70. height: 'auto',
  71. emptyrecords: "暂无数据",
  72. sortorder: "desc",
  73. caption:"菜品列表",
  74. loadComplete: function (xhr) {
  75. if(xhr.code==0){
  76. layer.msg(xhr.msg);
  77. return false;
  78. }
  79. },
  80. });
  81. });
  82. </script>
  83. {/block}