index.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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="cate_id" class="form-control">
  16. <option value="">选择分类</option>
  17. {foreach $cate as $k=>$v}
  18. <option value="{$v.id}">{$v.title}</option>
  19. {/foreach}
  20. </select>
  21. </div>
  22. <div class="input-group">
  23. <select name="enable" class="form-control">
  24. <option value="">选择状态</option>
  25. <option value="0">禁用</option>
  26. <option value="1">正常</option>
  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-primary " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  35. </span>
  36. &nbsp;
  37. <span class="input-group-btn">
  38. <button class="btn-sm btn-primary" type="button" url="{:url('import')}" data-title="批量导入" onclick="layer_open(this,1)">批量导入</button>
  39. </span>
  40. </div>
  41. </form>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="ibox-content">
  46. <div class="jqGrid_wrapper">
  47. <table id="table" style="border-collapse: collapse"></table>
  48. <div id="pager"></div>
  49. </div>
  50. </div>
  51. </div>
  52. {/block}
  53. {block name="script"}
  54. <script>
  55. $(function () {
  56. $(window).bind("resize",function(){
  57. var width=$(".jqGrid_wrapper").width();
  58. $("#table").setGridWidth(width);
  59. });
  60. $.jgrid.defaults.styleUI="Bootstrap";
  61. $("#table").jqGrid({
  62. url:"{:url('index')}",
  63. datatype: "json",
  64. colModel:[
  65. {label:'编号',name:'id',index:'id', width:40,sortable: false},
  66. {label:'名称',name:'title',index:'title', width:60,sortable: false},
  67. {label:'分类',name:'cate_name',index:'cate_name', width:60,sortable: false},
  68. {label:'品牌',name:'brand',index:'brand', width:40,sortable: false},
  69. {label:'规格',name:'spec',index:'spec', width:40,sortable: false},
  70. {label:'价格',name:'price',index:'price', width:40,sortable: false},
  71. {label:'剩余数量',name:'nums',index:'nums',width:50,editable: false,sortable: false,formatter:function (a,b,c){
  72. return c.nums+c.unit;
  73. }},
  74. {label:'类型',name:'type',index:'type',width:50,editable: false,sortable: false,formatter:function (a,b,c){
  75. if(a == 1){
  76. return '固定资产';
  77. } else{
  78. return '耗材';
  79. }
  80. }},
  81. {label:'状态',name:'enable',index:'enable',width:50,editable: false,sortable: false,formatter:function (a,b,c){
  82. if(a == 0){
  83. var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
  84. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
  85. } else{
  86. var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
  87. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
  88. }
  89. }},
  90. {label:'操作',width:80,sortable: false,formatter: function (a, b, c) {
  91. var editurl = "{:url('add',[],'')}/id/"+c.id;
  92. var delurl = "{:url('del',[],'')}/id/"+c.id;
  93. var option_url = "{:url('option',[],'')}/id/"+c.id;
  94. var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  95. //var btn = '<a href="'+editurl+'"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  96. btn+= '<a url="'+option_url+'" href="javascript:;" data-title="处置商品" onclick="layer_open(this,1)"><span class="label label-success" title="处置商品">处置</span></a>&nbsp;';
  97. btn += '<a {if !btnAuth(session("user_auth.id"),"CompanyGoods/del")} style="display:none"{/if} href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
  98. return btn;
  99. }},
  100. ],
  101. rowNum:10,
  102. rowList:[10,20,30,50,100],
  103. pager: '#pager',
  104. sortname: 'id',
  105. viewrecords: true,
  106. autowidth:true,
  107. mtype: 'post',
  108. height: 'auto',
  109. emptyrecords: "暂无数据",
  110. sortorder: "desc",
  111. caption:"{$meta_title}",
  112. loadComplete: function (xhr) {
  113. if(xhr.code==0){
  114. layer.msg(xhr.msg);
  115. return false;
  116. }
  117. },
  118. });
  119. });
  120. </script>
  121. {/block}