index.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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:;" onclick="batchSorts()" class="btn btn-sm btn-warning">保存排序</a>
  8. <a href="{:url('remove')}" class="btn ajax-get btn-sm btn-danger">清理缓存</a>
  9. </div>
  10. <div class="col-xs-9" style="text-align: right;">
  11. <form class="form-inline" id="form-search" action="{:url('index')}">
  12. <div class="input-group">
  13. <input type="text" class="form-control" name="title" placeholder="账号/姓名/手机号">
  14. </div>
  15. <div class="input-group" style="overflow: hidden;width: 120px;">
  16. {:widget_view('common/select',['name'=>'depId','lists' => $deps, 'value' => ''])}
  17. </div>
  18. <div class="input-group">
  19. <span class="input-group-btn">
  20. <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
  21. </span> &nbsp;
  22. <span class="input-group-btn">
  23. <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  24. </span>
  25. </div>
  26. </form>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="ibox-content">
  31. <div class="jqGrid_wrapper">
  32. <table id="table" style="border-collapse: collapse"></table>
  33. <div id="pager"></div>
  34. </div>
  35. </div>
  36. </div>
  37. {/block}
  38. {block name="script"}
  39. <script>
  40. $(function () {
  41. $(window).bind("resize",function(){
  42. var width=$(".jqGrid_wrapper").width();
  43. $("#table").setGridWidth(width);
  44. });
  45. $.jgrid.defaults.styleUI="Bootstrap";
  46. $("#table").jqGrid({
  47. url:"{:url('index')}",
  48. datatype: "json",
  49. colModel:[
  50. {label:'ID',name:'id',index:'id', width:60,sortable: false},
  51. {label:'排序(正序)',name:'sorts',index:'sorts',width:120,sortable: true,formatter: function (a, b, c) {
  52. return '<input type="number" class="form-control input-sm usersorts" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
  53. }},
  54. {label:'上一次排序',name:'old_sorts',index:'old_sorts',width:100,editable: false,sortable: false},
  55. {label:'是否是最后一次派单人',name:'is_last',index:'is_last',width:140,sortable: true,formatter: function (a, b, c) {
  56. if(a){
  57. return '<span style="color: #387aff">是</span>';
  58. }else {
  59. return '否';
  60. }
  61. }},
  62. {label:'状态',name:'enable_sorts',index:'enable_sorts',width:80,editable: false,sortable: false,formatter:function (a,b,c){
  63. if(a == 0){
  64. var url = "{:url('changeField',[],'')}/fn/enable_sorts/fv/1/id/"+c.id;
  65. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
  66. } else{
  67. var url = "{:url('changeField',[],'')}/fn/enable_sorts/fv/0/id/"+c.id;
  68. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
  69. }
  70. }},
  71. {label:'账号',name:'account',index:'account',width:100,editable: false,sortable: false},
  72. {label:'姓名',name:'real_name',index:'real_name',width:100,editable: false,sortable: false},
  73. {label:'手机号',name:'mobile',index:'mobile',width:150,editable: false,sortable: false},
  74. {label:'所在部门',name:'dep_name',index:'dep_name',width:100,editable: false,sortable: false},
  75. {label:'角色',name:'roles_name',index:'roles_name',width:100,editable: false,sortable: false},
  76. {label:'报修类型',name:'type_name',index:'type_name',width:100,editable: false,sortable: false},
  77. ],
  78. rowNum:10,
  79. rowList:[10,20,30,50,100],
  80. pager: '#pager',
  81. sortname: 'id',
  82. viewrecords: true,
  83. autowidth:true,
  84. autoScroll: false,
  85. shrinkToFit: true,
  86. mtype: 'post',
  87. height: 'auto',
  88. emptyrecords: "暂无数据",
  89. sortorder: "desc",
  90. caption:"人员排序列表",
  91. loadComplete: function (xhr) {
  92. if(xhr.code==0){
  93. layer.msg(xhr.msg);
  94. return false;
  95. }
  96. },
  97. });
  98. /*固定表头及侧边*/
  99. // $("#table").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "auto" });
  100. // $("#table").jqGrid('setFrozenColumns');
  101. });
  102. function batchSorts() {
  103. let data = [];
  104. $('.usersorts').each(function(){
  105. data.push({
  106. id: $(this).attr('data-id'),
  107. sort: $(this).val(),
  108. })
  109. });
  110. let url = "{:url('UserSorts/batchSorts')}";
  111. $.post(url,{data:JSON.stringify(data)},function (res) {
  112. if(res.code == 1){
  113. updateAlert('操作成功','alert-success');
  114. setTimeout(function(){
  115. $('#top-alert').find('button').click();
  116. },1500);
  117. $("#table").trigger("reloadGrid");
  118. }else{
  119. updateAlert(data.msg,'alert-danger');
  120. setTimeout(function(){
  121. $('#top-alert').find('button').click();
  122. },1500);
  123. }
  124. });
  125. }
  126. </script>
  127. {/block}