define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'bootstrap-datetimepicker', 'bootstrap-daterangepicker','dateyearmonth'], function ($, undefined, Backend, Table, Form, Datetimepicker, Daterangepicker, dateyearmonth) { var index_url = 'auth/userrechargecount/index/ids/' + Config.id; var params_list = []; if(Config.rechargetype){ var type_arr = Config.rechargetype.split(','); for(var j = 0,len = type_arr.length; j < len; j++){ params_list.push('rechargetype[]='+type_arr[j]); } } if (Config.begin_time && Config.end_time) { params_list.push('createtime=' + Config.begin_time + ' - ' + Config.end_time); } if(params_list.length){ index_url = index_url+'?'+params_list.join('&'); } console.log(index_url); // $(document).delegate('#resetBtn', 'click', function () { $('.checki,.checkall').prop('checked', false); $('#day_sum').val(''); $('#submit').trigger('click'); return false; }); $(document).delegate('.checkall', 'click', function () { $('.checki').prop('checked', $('.checkall').prop('checked')); }); $(document).delegate('.checki', 'click', function () { if($('.checki:checked').length == $('.checki').length){ $('.checkall').prop('checked', true); }else { $('.checkall').prop('checked', false); } }); // $(document).on('change','.checkall',function(){ // var $this = $(this); // var $checki = $('.checki'); // if($this.is(":checked")){ // for(var i=0; i<$checki.length; i++) $checki.eq(i).get(0).checked = true; // }else{ // $checki.removeAttr('checked'); // } // }); // $(document).on('change','.checki',function(){ // var $checki = $('.checki'); // var $checkall = $('.checkall'); // for(var i=0; i<$checki.length; i++) { // if(!$checki.eq(i).is(":checked")){ // $checkall.get(0).checked = false; // return false; // } // } // $checkall.get(0).checked = true; // }); var Controller = { index: function () { Table.api.init({ extend: { index_url: index_url }, searchFormVisible: false, search: false, commonSearch: false, onLoadSuccess: function (data) { var startDate, endDate; if (data['begin_date']) { startDate = data['begin_date']; } else { startDate = Moment().subtract(1, 'day'); } if (data['end_date']) { endDate = data['end_date']; } else { endDate = Moment().subtract(1, 'day'); } var beginTimeStore = ''; var endTimeStore = ''; if(Config.begin_time && Config.end_time){ $('#day_sum').val(Config.begin_time +' - '+ Config.end_time); } $('#day_sum').daterangepicker({ autoUpdateInput:false, showDropdowns:true, maxDate: Moment(), autoApply:true, // minDate: Moment().subtract(12, 'month'), locale: { format: 'YYYY-MM-DD', applyLabel: '确认', cancelLabel: '取消', fromLabel: '从', toLabel: '到', weekLabel: 'W', customRangeLabel: '选择时间', daysOfWeek: ["日", "一", "二", "三", "四", "五", "六"], monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], } }, function(start, end, label) { beginTimeStore = start; endTimeStore = end; if(!this.startDate){ this.element.val(''); }else{ this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); } }); } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {field: 'type', title: __('充值类型'),operate: false}, {field: 'kandian', title: __('充值看点数'), operate: false}, {field: 'free_kandian', title: __('赠送看点数'), operate: false}, {field: 'free_endtime_text', title: __('赠送看点到期时间'), operate: false}, {field: 'day', title: __('VIP天数'), formatter: function (value, row, index) { if (row.hour != null) { return value+'天'+row.hour+'小时'; } return value + '天'; },operate: false}, {field: 'createtime', title: __('充值时间'), operate: false, width: '100px'}, {field: 'vip_createtime', title: __('VIP开始时间'), operate: false}, {field: 'vip_endtime', title: __('VIP结束时间'), operate: false}, {field: 'notes', title: __('备注'), operate: false} ] ] }); Table.api.bindevent(table); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); }, formatter: { /* IncomeLink: function (value, row, index) { return '进入'; }, createmonthtime: function (value, row, index) { return value.substring(0, 4) + '-' + value.substring(4, 6); },*/ } } }; return Controller; });