get_second.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {__NOLAYOUT__}
  2. <table id="tagGroupTable" lay-filter="tagGroupTable"></table>
  3. <script>
  4. var ids = {};
  5. var table_data=new Array();
  6. layui.use(['form','table'], function(){
  7. layui.table.render({
  8. elem: '#tagGroupTable',
  9. height: '420',
  10. page: 'true',
  11. limit:'10',
  12. url: '{:createUrl("promotion.second/index")}',
  13. id:'tagGroupTable',
  14. cols: [[
  15. {type: 'checkbox'}
  16. , {field: 'id', title: 'ID', width: 80, unresize: true, sort: true,align:"center"}
  17. , {field:'photo', title:'封面', width:60,templet: function(res){
  18. return '<img src="'+ res.photo +'" style="max-width:30px; max-height:30px;">';
  19. }}
  20. , {field: 'title', title: '商品名称',align: "center"}
  21. , {field: 'regiment_price', title: '销售价格', width: 160,align: "center"}
  22. , {field: 'create_time', title: '创建时间',width: 160,align: "center"}
  23. ]],
  24. , text: {
  25. none: '<div><i class="layui-icon">&#xe702;</i>暂无相关数据</div>'
  26. }
  27. done: function(res, curr, count){
  28. table_data=res.data;
  29. for(var i=0;i< res.data.length;i++){
  30. if(ids[res.data[i].id]){
  31. res.data[i]["LAY_CHECKED"]='true';
  32. var index= res.data[i]['LAY_TABLE_INDEX'];
  33. $('#tagGroupTable + div .layui-table-body tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
  34. $('#tagGroupTable + div .layui-table-body tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
  35. }
  36. }
  37. var checkStatus = layui.table.checkStatus('tagGroupTable');
  38. if(checkStatus.isAll){
  39. $('#tagGroupTable + div .layui-table-header th[data-field="0"] input[type="checkbox"]').prop('checked', true);
  40. $('#tagGroupTable + div .layui-table-header th[data-field="0"] input[type="checkbox"]').next().addClass('layui-form-checked');
  41. }
  42. }
  43. });
  44. layui.table.on('checkbox(tagGroupTable)', function(obj){
  45. if(obj.checked){
  46. if(obj.type=='one'){
  47. ids[obj.data.id] = obj.data;
  48. }else{
  49. for(var i=0;i<table_data.length;i++){
  50. ids[table_data[i].id] = table_data[i];
  51. }
  52. }
  53. }else{
  54. if(obj.type=='one'){
  55. delete ids[obj.data.id];
  56. }else{
  57. for(var i=0;i<table_data.length;i++){
  58. delete ids[table_data[i].id];
  59. }
  60. }
  61. }
  62. });
  63. });
  64. </script>