{extend name="common/common2" /} {block name="main"} <style> .cate-title{ width: auto; background-color: #ecf5ff; border-color: #d9ecff; color: #409eff; display: inline-block; height: 32px; padding: 0 10px; line-height: 30px; font-size: 12px; color: #409eff; border-width: 1px; border-style: solid; border-radius: 4px; -webkit-box-sizing: border-box; box-sizing: border-box; white-space: nowrap; margin-bottom: 3px; } .el-tag__close{ cursor: pointer; } </style> <div class="ibox"> <div class="ibox-content"> <div class="row"> <div class="col-xs-3"> <a href="javascript:;" class="btn btn-sm btn-primary" onclick="selectGoods(this)">确定选择</a> </div> <div class="col-xs-9" style="text-align: right;"> <form class="form-inline" id="form-search" action="{:url('selectGoods')}?cateId={$cateId}"> <div class="input-group"> <input type="text" class="form-control" name="title" placeholder="名称/编号"> </div> <div class="input-group"> <select name="class_id" class="form-control"> <option value="">选择类别</option> {volist name="class" id="v"} <option value="{$v.id}">{$v.title}</option> {/volist} </select> </div> <div class="input-group"> <select name="add_id" class="form-control"> <option value="">选择增加方式</option> {volist name="add" id="v"} <option value="{$v.id}">{$v.title}</option> {/volist} </select> </div> <!-- <div class="input-group">--> <!-- <select name="enable" class="form-control">--> <!-- <option value="">选择状态</option>--> <!-- <option value="1">在库</option>--> <!-- <option value="2">使用</option>--> <!-- <option value="4">维修</option>--> <!-- <option value="5">处置</option>--> <!-- </select>--> <!-- </div>--> <div class="input-group"> <span class="input-group-btn"> <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button> </span> <span class="input-group-btn"> <button class="btn-sm btn-primary " type="button" id="search-clear"><i class="fa fa-undo"></i></button> </span> </div> </form> </div> </div> </div> <div class="ibox-content" style="overflow: hidden"> <div class="col-xs-2" style="overflow: hidden"> {if condition="$tree"} {:widget_view('asset_disposal/tree',['data'=>$tree,'depth'=>0])} {else /} <div style="margin-top: 30px;text-align: center">暂无数据</div> {/if} </div> <div class="col-xs-10"> {if $cateTitle} <div class="cate-title">{$cateTitle} <i class="el-tag__close el-icon-close" onclick="clearClick()"></i></div> {/if} <div class="jqGrid_wrapper"> <table id="table" style="border-collapse: collapse"></table> <div id="pager"></div> </div> </div> </div> </div> {/block} {block name="script"} <script> var lists = localStorage.getItem("mateapply")?JSON.parse(localStorage.getItem("mateapply")):[]; var ids = localStorage.getItem("mateapplyids")?JSON.parse(localStorage.getItem("mateapplyids")):[]; $(function () { $(window).bind("resize",function(){ var width=$(".jqGrid_wrapper").width(); $("#table").setGridWidth(width); }); $.jgrid.defaults.styleUI="Bootstrap"; $("#table").jqGrid({ url:"{:url('selectGoods')}?cateId={$cateId}", datatype: "json", colModel:[ {label:'ID',name:'id',index:'id', width:100,editable: false, sortable: false,frozen:true}, {label:'编号',name:'sn',index:'sn', width:100,editable: false, sortable: false,frozen:true}, {label:'名称',name:'title',index:'title', width:100,sortable: false}, {label:'规格',name:'spec',index:'spec', width:80,sortable: false}, {label:'数量',name:'nums',index:'nums', width:50,sortable: false}, {label:'状态',name:'statusTxt',index:'statusTxt', width:80,sortable: false}, // {label:'使用部门',name:'depName',index:'depName', width:80,sortable: false}, // {label:'使用人员',name:'userName',index:'userName', width:80,sortable: false}, {label:'类型',name:'cateName',index:'cateName', width:80,sortable: false}, {label:'类别',name:'className',index:'className', width:80,sortable: false}, {label:'增加方式',name:'addName',index:'addName', width:80,sortable: false}, {label:'品牌',name:'brand',index:'brand', width:80,sortable: false}, {label:'原值',name:'price',index:'price', width:80,sortable: false}, {label:'存放地点',name:'address',index:'address', width:80,sortable: false}, {label:'资产用途',name:'used',index:'used', width:80,sortable: false}, {label:'购买日期',name:'buy_time',index:'buy_time', width:80,sortable: false}, {label:'是否打印标签',name:'print',index:'print', width:100,sortable: false}, {label:'备注',name:'remark',index:'remark', width:80,sortable: false}, ], rowNum:10, rowList:[10,20,30,50,100], pager: '#pager', sortname: 'id', viewrecords: true, autowidth:true, shrinkToFit: false, mtype: 'post', height: 'auto', emptyrecords: "暂无数据", sortorder: "desc", multiselect: true,//可多选 caption:"资产列表", loadComplete: function (xhr) { if(xhr.code==0){ layer.msg(xhr.msg); return false; }else{ console.log('loadComplete'); // let ss = jQuery("#table").jqGrid('getRowData'); // console.log('ids',ids); ids.forEach((rid) => { jQuery("#table").setSelection(rid, true); }); } }, onSelectAll: function(){ formatSelect(); }, beforeSelectRow: function(rowid, e){ // console.log('beforeSelectRow',rowid, e,ids); }, onPaging: function(){ formatSelect(); }, }); $("#table").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "auto" }); $("#table").jqGrid('setFrozenColumns'); }); function formatSelect() { let objs = jQuery("#table").jqGrid('getRowData'); let rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow'); console.log('onPaging',ids,rowIds); objs.forEach((item) => { if(rowIds.includes(item.id)){ if(!ids.includes(item.id)){ ids.push(item.id); lists.push(item); } }else{ if(ids.includes(item.id)){ ids = ids.filter((item2) => { return item2 != item.id; }); lists = lists.filter((item2) => { return item2.id != item.id; }) } } }); } function selectGoods(_self) { formatSelect(); parent.layer.closeAll(); parent.lists = lists; parent.formatList(); } function clearClick(){ var url = "{:url('selectGoods')}"; window.location.href = url; } </script> {/block}