0
0

buslist.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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:;" class="btn btn-sm btn-primary" onclick="saveSelect()">确定选择</a>
  8. </div>
  9. <div class="col-xs-9" style="text-align: right;">
  10. <form class="form-inline" id="form-search" action="{:url('buslist',['type'=>$type])}">
  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. var idx = {$idx};
  37. var lists = [];
  38. var ids = localStorage.getItem("selectids")?JSON.parse(localStorage.getItem("selectids")):[];
  39. $(function () {
  40. $(window).bind("resize",function(){
  41. var width=$(".jqGrid_wrapper").width();
  42. $("#table").setGridWidth(width);
  43. });
  44. $.jgrid.defaults.styleUI="Bootstrap";
  45. $("#table").jqGrid({
  46. url:"{:url('buslist',['type'=>$type])}",
  47. datatype: "json",
  48. colModel:[
  49. {label:'ID',name:'id',index:'id', width:30,sortable: false,hidden:true},
  50. {label:'名称',name:'title',index:'title',width:80,editable: false,sortable: false},
  51. {label:'时间',name:'create_time',index:'create_time',width:80,sortable: true},
  52. ],
  53. rowNum:10,
  54. rowList:[10,20,30,50,100],
  55. pager: '#pager',
  56. sortname: 'id',
  57. viewrecords: true,
  58. autowidth:true,
  59. mtype: 'post',
  60. height: 'auto',
  61. emptyrecords: "暂无数据",
  62. sortorder: "asc",
  63. caption:"{$meta_title}",
  64. multiselect: true,//可多选
  65. loadComplete: function (xhr) {
  66. if(xhr.code==0){
  67. layer.msg(xhr.msg);
  68. return false;
  69. }
  70. ids.forEach((rid) => {
  71. jQuery("#table").setSelection(rid, true);
  72. });
  73. },
  74. onSelectRow: function(){
  75. formatSelect();
  76. },
  77. onSelectAll: function(){
  78. formatSelect();
  79. },
  80. });
  81. });
  82. function formatSelect() {
  83. let objs = jQuery("#table").jqGrid('getRowData');
  84. let rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow');
  85. console.log('onSelectRow',objs,rowIds);
  86. lists = [];
  87. ids = rowIds?rowIds:[];
  88. objs.forEach((item) => {
  89. if(rowIds.includes(item.id.toString())){
  90. lists.push({
  91. id: item.id.toString(),
  92. title: item.title,
  93. });
  94. }
  95. });
  96. }
  97. function saveSelect() {
  98. parent.layer.closeAll();
  99. parent.vm.selectBuss(idx,lists);
  100. }
  101. </script>
  102. {/block}