select_goods.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <style>
  4. .cate-title{
  5. width: auto;
  6. background-color: #ecf5ff;
  7. border-color: #d9ecff;
  8. color: #409eff;
  9. display: inline-block;
  10. height: 32px;
  11. padding: 0 10px;
  12. line-height: 30px;
  13. font-size: 12px;
  14. color: #409eff;
  15. border-width: 1px;
  16. border-style: solid;
  17. border-radius: 4px;
  18. -webkit-box-sizing: border-box;
  19. box-sizing: border-box;
  20. white-space: nowrap;
  21. margin-bottom: 3px;
  22. }
  23. .el-tag__close{
  24. cursor: pointer;
  25. }
  26. </style>
  27. <div class="ibox">
  28. <div class="ibox-content">
  29. <div class="row">
  30. <div class="col-xs-3">
  31. <a href="javascript:;" class="btn btn-sm btn-primary" onclick="selectGoods(this)">确定选择</a>
  32. </div>
  33. <div class="col-xs-9" style="text-align: right;">
  34. <form class="form-inline" id="form-search" action="{:url('selectGoods')}?cateId={$cateId}">
  35. <div class="input-group">
  36. <input type="text" class="form-control" name="title" placeholder="名称/编号">
  37. </div>
  38. <div class="input-group">
  39. <select name="class_id" class="form-control">
  40. <option value="">选择类别</option>
  41. {volist name="class" id="v"}
  42. <option value="{$v.id}">{$v.title}</option>
  43. {/volist}
  44. </select>
  45. </div>
  46. <div class="input-group">
  47. <select name="add_id" class="form-control">
  48. <option value="">选择增加方式</option>
  49. {volist name="add" id="v"}
  50. <option value="{$v.id}">{$v.title}</option>
  51. {/volist}
  52. </select>
  53. </div>
  54. <!-- <div class="input-group">-->
  55. <!-- <select name="enable" class="form-control">-->
  56. <!-- <option value="">选择状态</option>-->
  57. <!-- <option value="1">在库</option>-->
  58. <!-- <option value="2">使用</option>-->
  59. <!-- <option value="4">维修</option>-->
  60. <!-- <option value="5">处置</option>-->
  61. <!-- </select>-->
  62. <!-- </div>-->
  63. <div class="input-group">
  64. <span class="input-group-btn">
  65. <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
  66. </span>
  67. <span class="input-group-btn">
  68. <button class="btn-sm btn-primary " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  69. </span>
  70. </div>
  71. </form>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="ibox-content" style="overflow: hidden">
  76. <div class="col-xs-2" style="overflow: hidden">
  77. {if condition="$tree"}
  78. {:widget_view('asset_receive/tree',['data'=>$tree,'depth'=>0])}
  79. {else /}
  80. <div style="margin-top: 30px;text-align: center">暂无数据</div>
  81. {/if}
  82. </div>
  83. <div class="col-xs-10">
  84. {if $cateTitle}
  85. <div class="cate-title">{$cateTitle} <i class="el-tag__close el-icon-close" onclick="clearClick()"></i></div>
  86. {/if}
  87. <div class="jqGrid_wrapper">
  88. <table id="table" style="border-collapse: collapse"></table>
  89. <div id="pager"></div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. {/block}
  95. {block name="script"}
  96. <script>
  97. var lists = localStorage.getItem("mateapply")?JSON.parse(localStorage.getItem("mateapply")):[];
  98. var ids = localStorage.getItem("mateapplyids")?JSON.parse(localStorage.getItem("mateapplyids")):[];
  99. $(function () {
  100. $(window).bind("resize",function(){
  101. var width=$(".jqGrid_wrapper").width();
  102. $("#table").setGridWidth(width);
  103. });
  104. $.jgrid.defaults.styleUI="Bootstrap";
  105. $("#table").jqGrid({
  106. url:"{:url('selectGoods')}?cateId={$cateId}",
  107. datatype: "json",
  108. colModel:[
  109. {label:'ID',name:'id',index:'id', width:100,editable: false, sortable: false,frozen:true},
  110. {label:'编号',name:'sn',index:'sn', width:100,editable: false, sortable: false,frozen:true},
  111. {label:'名称',name:'title',index:'title', width:100,sortable: false},
  112. {label:'规格',name:'spec',index:'spec', width:80,sortable: false},
  113. {label:'数量',name:'nums',index:'nums', width:50,sortable: false},
  114. {label:'状态',name:'statusTxt',index:'statusTxt', width:80,sortable: false},
  115. // {label:'使用部门',name:'depName',index:'depName', width:80,sortable: false},
  116. // {label:'使用人员',name:'userName',index:'userName', width:80,sortable: false},
  117. {label:'类型',name:'cateName',index:'cateName', width:80,sortable: false},
  118. {label:'类别',name:'className',index:'className', width:80,sortable: false},
  119. {label:'增加方式',name:'addName',index:'addName', width:80,sortable: false},
  120. {label:'品牌',name:'brand',index:'brand', width:80,sortable: false},
  121. {label:'原值',name:'price',index:'price', width:80,sortable: false},
  122. {label:'存放地点',name:'address',index:'address', width:80,sortable: false},
  123. {label:'资产用途',name:'used',index:'used', width:80,sortable: false},
  124. {label:'购买日期',name:'buy_time',index:'buy_time', width:80,sortable: false},
  125. {label:'是否打印标签',name:'print',index:'print', width:100,sortable: false},
  126. {label:'备注',name:'remark',index:'remark', width:80,sortable: false},
  127. ],
  128. rowNum:10,
  129. rowList:[10,20,30,50,100],
  130. pager: '#pager',
  131. sortname: 'id',
  132. viewrecords: true,
  133. autowidth:true,
  134. shrinkToFit: false,
  135. mtype: 'post',
  136. height: 'auto',
  137. emptyrecords: "暂无数据",
  138. sortorder: "desc",
  139. multiselect: true,//可多选
  140. caption:"资产列表",
  141. loadComplete: function (xhr) {
  142. if(xhr.code==0){
  143. layer.msg(xhr.msg);
  144. return false;
  145. }else{
  146. console.log('loadComplete');
  147. // let ss = jQuery("#table").jqGrid('getRowData');
  148. // console.log('ids',ids);
  149. ids.forEach((rid) => {
  150. jQuery("#table").setSelection(rid, true);
  151. });
  152. }
  153. },
  154. onSelectAll: function(){
  155. formatSelect();
  156. },
  157. beforeSelectRow: function(rowid, e){
  158. // console.log('beforeSelectRow',rowid, e,ids);
  159. },
  160. onPaging: function(){
  161. formatSelect();
  162. },
  163. });
  164. $("#table").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "auto" });
  165. $("#table").jqGrid('setFrozenColumns');
  166. });
  167. function formatSelect() {
  168. let objs = jQuery("#table").jqGrid('getRowData');
  169. let rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow');
  170. console.log('onPaging',ids,rowIds);
  171. objs.forEach((item) => {
  172. if(rowIds.includes(item.id)){
  173. if(!ids.includes(item.id)){
  174. ids.push(item.id);
  175. lists.push(item);
  176. }
  177. }else{
  178. if(ids.includes(item.id)){
  179. ids = ids.filter((item2) => {
  180. return item2 != item.id;
  181. });
  182. lists = lists.filter((item2) => {
  183. return item2.id != item.id;
  184. })
  185. }
  186. }
  187. });
  188. }
  189. function selectGoods(_self) {
  190. formatSelect();
  191. parent.layer.closeAll();
  192. parent.lists = lists;
  193. parent.formatList();
  194. }
  195. function clearClick(){
  196. var url = "{:url('selectGoods')}";
  197. window.location.href = url;
  198. }
  199. </script>
  200. {/block}