index.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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="新增" 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. </select>
  20. </div>
  21. <div class="input-group">
  22. <select name="is_tj" class="form-control">
  23. <option value="">是否推荐</option>
  24. <option value="0">否</option>
  25. <option value="1">是</option>
  26. </select>
  27. </div>
  28. <div class="input-group">
  29. <select name="cate_id" class="form-control">
  30. <option value="">选择分类</option>
  31. {foreach $cateList as $k=>$v}
  32. <option value="{$v.id}">{$v['title']}</option>
  33. {/foreach}
  34. </select>
  35. </div>
  36. <div class="input-group">
  37. <span class="input-group-btn">
  38. <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
  39. </span>
  40. <span class="input-group-btn">
  41. <button class="btn-sm btn-primary " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  42. </span>
  43. </div>
  44. </form>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="ibox-content">
  49. <div class="jqGrid_wrapper">
  50. <table id="table" style="border-collapse: collapse"></table>
  51. <div id="pager"></div>
  52. </div>
  53. </div>
  54. </div>
  55. {/block}
  56. {block name="script"}
  57. <script>
  58. $(function () {
  59. $(window).bind("resize",function(){
  60. var width=$(".jqGrid_wrapper").width();
  61. $("#table").setGridWidth(width);
  62. });
  63. $.jgrid.defaults.styleUI="Bootstrap";
  64. $("#table").jqGrid({
  65. url:"{:url('index')}",
  66. datatype: "json",
  67. colModel:[
  68. {label:'商品名称',name:'title',index:'title', width:80,sortable: false},
  69. {label:'商品价格',name:'price',index:'price', width:40,sortable: false},
  70. {label:'商品分类',name:'cate_name',index:'cate_name', width:80,sortable: false},
  71. {label:'封面图',name:'img',index:'img',width:80,editable: false,sortable: false,formatter: function (a, b, c) {
  72. return '<img src="'+a+'" width="60" onclick="open_img(this)"></img>';
  73. }},
  74. {label:'标签',name:'label_name',index:'label_name',width:40,editable: false,sortable: false},
  75. // {label:'库存',name:'stock',index:'stock',width:40,editable: false,sortable: false},
  76. {label:'销量',name:'sale',index:'sale',width:40,editable: false,sortable: false},
  77. {label:'排序',name:'sort',index:'sort',width:40,sortable: true,formatter: function (a, b, c) {
  78. return '<input type="number" onchange="updateSort(this)" data-url="{:url('changeSort')}" class="form-control input-sm" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
  79. }},
  80. {label:'是否推荐',name:'is_tj',index:'is_tj',width:50,editable: false,sortable: false,formatter:function (a,b,c){
  81. if(a == 0){
  82. var url = "{:url('changeField',[],'')}/fn/is_tj/fv/1/id/"+c.id;
  83. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="否">否</span></a>';
  84. } else{
  85. var url = "{:url('changeField',[],'')}/fn/is_tj/fv/0/id/"+c.id;
  86. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="是">是</span></a>';
  87. }
  88. }},
  89. {label:'状态',name:'enable',index:'enable',width:50,editable: false,sortable: false,formatter:function (a,b,c){
  90. if(a == 0){
  91. var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
  92. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="下架">下架</span></a>';
  93. } else{
  94. var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
  95. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="上架">上架</span></a>';
  96. }
  97. }},
  98. {label:'操作',width:80,sortable: false,formatter: function (a, b, c) {
  99. var editurl = "{:url('add',[],'')}/id/"+c.id;
  100. var delurl = "{:url('del',[],'')}/id/"+c.id;
  101. var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  102. btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
  103. return btn;
  104. }},
  105. ],
  106. rowNum:10,
  107. rowList:[10,20,30,50,100],
  108. pager: '#pager',
  109. sortname: 'sort',
  110. viewrecords: true,
  111. autowidth:true,
  112. mtype: 'post',
  113. height: 'auto',
  114. emptyrecords: "暂无数据",
  115. sortorder: "asc",
  116. caption:"{$meta_title}",
  117. loadComplete: function (xhr) {
  118. if(xhr.code==0){
  119. layer.msg(xhr.msg);
  120. return false;
  121. }
  122. },
  123. });
  124. });
  125. </script>
  126. {/block}