userrechargecount.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-datetimepicker', 'bootstrap-daterangepicker','dateyearmonth'], function ($, undefined, Backend, Table, Form, Datetimepicker, Daterangepicker, dateyearmonth) {
  2. var index_url = 'auth/userrechargecount/index/ids/' + Config.id;
  3. var params_list = [];
  4. if(Config.rechargetype){
  5. var type_arr = Config.rechargetype.split(',');
  6. for(var j = 0,len = type_arr.length; j < len; j++){
  7. params_list.push('rechargetype[]='+type_arr[j]);
  8. }
  9. }
  10. if (Config.begin_time && Config.end_time) {
  11. params_list.push('createtime=' + Config.begin_time + ' - ' + Config.end_time);
  12. }
  13. if(params_list.length){
  14. index_url = index_url+'?'+params_list.join('&');
  15. }
  16. console.log(index_url);
  17. //
  18. $(document).delegate('#resetBtn', 'click', function () {
  19. $('.checki,.checkall').prop('checked', false);
  20. $('#day_sum').val('');
  21. $('#submit').trigger('click');
  22. return false;
  23. });
  24. $(document).delegate('.checkall', 'click', function () {
  25. $('.checki').prop('checked', $('.checkall').prop('checked'));
  26. });
  27. $(document).delegate('.checki', 'click', function () {
  28. if($('.checki:checked').length == $('.checki').length){
  29. $('.checkall').prop('checked', true);
  30. }else {
  31. $('.checkall').prop('checked', false);
  32. }
  33. });
  34. // $(document).on('change','.checkall',function(){
  35. // var $this = $(this);
  36. // var $checki = $('.checki');
  37. // if($this.is(":checked")){
  38. // for(var i=0; i<$checki.length; i++) $checki.eq(i).get(0).checked = true;
  39. // }else{
  40. // $checki.removeAttr('checked');
  41. // }
  42. // });
  43. // $(document).on('change','.checki',function(){
  44. // var $checki = $('.checki');
  45. // var $checkall = $('.checkall');
  46. // for(var i=0; i<$checki.length; i++) {
  47. // if(!$checki.eq(i).is(":checked")){
  48. // $checkall.get(0).checked = false;
  49. // return false;
  50. // }
  51. // }
  52. // $checkall.get(0).checked = true;
  53. // });
  54. var Controller = {
  55. index: function () {
  56. Table.api.init({
  57. extend: {
  58. index_url: index_url
  59. },
  60. searchFormVisible: false,
  61. search: false,
  62. commonSearch: false,
  63. onLoadSuccess: function (data) {
  64. var startDate, endDate;
  65. if (data['begin_date']) {
  66. startDate = data['begin_date'];
  67. } else {
  68. startDate = Moment().subtract(1, 'day');
  69. }
  70. if (data['end_date']) {
  71. endDate = data['end_date'];
  72. } else {
  73. endDate = Moment().subtract(1, 'day');
  74. }
  75. var beginTimeStore = '';
  76. var endTimeStore = '';
  77. if(Config.begin_time && Config.end_time){
  78. $('#day_sum').val(Config.begin_time +' - '+ Config.end_time);
  79. }
  80. $('#day_sum').daterangepicker({
  81. autoUpdateInput:false,
  82. showDropdowns:true,
  83. maxDate: Moment(),
  84. autoApply:true,
  85. // minDate: Moment().subtract(12, 'month'),
  86. locale: {
  87. format: 'YYYY-MM-DD',
  88. applyLabel: '确认',
  89. cancelLabel: '取消',
  90. fromLabel: '从',
  91. toLabel: '到',
  92. weekLabel: 'W',
  93. customRangeLabel: '选择时间',
  94. daysOfWeek: ["日", "一", "二", "三", "四", "五", "六"],
  95. monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
  96. }
  97. },
  98. function(start, end, label) {
  99. beginTimeStore = start;
  100. endTimeStore = end;
  101. if(!this.startDate){
  102. this.element.val('');
  103. }else{
  104. this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
  105. }
  106. });
  107. }
  108. });
  109. var table = $("#table");
  110. // 初始化表格
  111. table.bootstrapTable({
  112. url: $.fn.bootstrapTable.defaults.extend.index_url,
  113. pk: 'id',
  114. sortName: 'id',
  115. columns: [
  116. [
  117. {field: 'type', title: __('充值类型'),operate: false},
  118. {field: 'kandian', title: __('充值看点数'), operate: false},
  119. {field: 'free_kandian', title: __('赠送看点数'), operate: false},
  120. {field: 'free_endtime_text', title: __('赠送看点到期时间'), operate: false},
  121. {field: 'day', title: __('VIP天数'), formatter: function (value, row, index) {
  122. if (row.hour != null) {
  123. return value+'天'+row.hour+'小时';
  124. }
  125. return value + '天';
  126. },operate: false},
  127. {field: 'createtime', title: __('充值时间'), operate: false, width: '100px'},
  128. {field: 'vip_createtime', title: __('VIP开始时间'), operate: false},
  129. {field: 'vip_endtime', title: __('VIP结束时间'), operate: false},
  130. {field: 'notes', title: __('备注'), operate: false}
  131. ]
  132. ]
  133. });
  134. Table.api.bindevent(table);
  135. },
  136. api: {
  137. bindevent: function () {
  138. Form.api.bindevent($("form[role=form]"));
  139. },
  140. formatter: {
  141. /* IncomeLink: function (value, row, index) {
  142. return '<a target="_blank" href="' + row['inComeUrl'] + '">进入</a>';
  143. },
  144. createmonthtime: function (value, row, index) {
  145. return value.substring(0, 4) + '-' + value.substring(4, 6);
  146. },*/
  147. }
  148. }
  149. };
  150. return Controller;
  151. });