index.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 url="{:url('add',['pid'=>$pid])}" href="javascript:;" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
  8. <a href="javascript:;" onclick="batchSorts()" class="btn btn-sm btn-warning">保存排序</a>
  9. {if condition="$pid"}<a href="{:url('index')}" class="btn btn-sm btn-primary">返回上一页</a>{/if}
  10. </div>
  11. </div>
  12. </div>
  13. <div class="ibox-content">
  14. <div class="jqGrid_wrapper">
  15. <table id="table" style="border-collapse: collapse"></table>
  16. <div id="pager"></div>
  17. </div>
  18. </div>
  19. </div>
  20. {/block}
  21. {block name="script"}
  22. <script>
  23. $(function () {
  24. $(window).bind("resize",function(){
  25. var width=$(".jqGrid_wrapper").width();
  26. $("#table").setGridWidth(width);
  27. });
  28. $.jgrid.defaults.styleUI="Bootstrap";
  29. $("#table").jqGrid({
  30. url:"{:url('index',array('pid'=>$pid))}",
  31. datatype: "json",
  32. colModel:[
  33. {label:'名称',name:'name',index:'name',width:60,editable: false,sortable: false,formatter: function (a, b, c) {
  34. return '<a href="{:url("index",[],"")}/pid/'+c.id+'">'+c.name+'</a>';
  35. }},
  36. {label:'MODE',name:'mode',index:'mode',width:50,editable: false,sortable: false},
  37. {if($pid < 1)}
  38. {label:'图标',name:'path',index:'path',width:60,editable: false,sortable: false,formatter: function (a, b, c) {
  39. return '<img src="'+a+'" width="40" onclick="open_img(this)"></img>';
  40. }},
  41. {label:'备注',name:'des',index:'des',width:50,editable: false,sortable: false},
  42. {label:'排序',name:'sort',index:'sort',width:40,sortable: true,formatter: function (a, b, c) {
  43. return '<input type="number" data-url="{:url('changeSort')}" class="form-control input-sm usersorts" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
  44. }},
  45. {label:'类型',name:'type',status:'type',width:50,editable: false,sortable: false,formatter:function (a,b,c){
  46. if(a == 0){
  47. return '<span title="首页">首页</span>';
  48. }else{
  49. return '<span title="统计">统计</span>';
  50. }
  51. }},
  52. {/if}
  53. {label:'状态',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
  54. if(a == 0){
  55. var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
  56. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
  57. } else{
  58. var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
  59. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
  60. }
  61. }},
  62. {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
  63. var editurl = "{:url('add',[],'')}/id/"+c.id+"/pid/"+c.pid;
  64. var delurl = "{:url('del',[],'')}/id/"+c.id;
  65. var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  66. // var btn = '<a href="'+editurl+'"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  67. btn += '<a {if !btnAuth(session("user_auth.id"),"AppIcon/del")} style="display:none" {/if} href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
  68. return btn;
  69. }},
  70. ],
  71. rowNum:10,
  72. rowList:[10,20,30,50,100],
  73. pager: '#pager',
  74. sortname: 'id',
  75. viewrecords: true,
  76. autowidth:true,
  77. mtype: 'post',
  78. height: 'auto',
  79. emptyrecords: "暂无数据",
  80. sortorder: "desc",
  81. caption:"{$meta_title}",
  82. loadComplete: function (xhr) {
  83. if(xhr.code==0){
  84. layer.msg(xhr.msg);
  85. return false;
  86. }
  87. },
  88. });
  89. });
  90. function batchSorts() {
  91. let data = [];
  92. $('.usersorts').each(function(){
  93. data.push({
  94. id: $(this).attr('data-id'),
  95. sort: $(this).val(),
  96. })
  97. });
  98. let url = "{:url('AppIcon/batchSort')}";
  99. $.post(url,{data:JSON.stringify(data)},function (res) {
  100. if(res.code == 1){
  101. updateAlert('操作成功','alert-success');
  102. setTimeout(function(){
  103. $('#top-alert').find('button').click();
  104. },1500);
  105. $("#table").trigger("reloadGrid");
  106. }else{
  107. updateAlert(data.msg,'alert-danger');
  108. setTimeout(function(){
  109. $('#top-alert').find('button').click();
  110. },1500);
  111. }
  112. });
  113. }
  114. </script>
  115. {/block}