define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { $('ul.nav-tabs li').click(function(){ $(this).addClass('active').siblings().removeClass('active') }); var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'collectstatement/index', table: 'orders_collect' }, showToggle: false, showColumns: false, showExport: false, commonSearch: false, operate: false, search:false, onLoadSuccess: function (data) { $("[data-toggle='tooltip']").tooltip({trigger: 'focus hover',html : true }); } }); var table = $("#table"); table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'createdate', columns: [Controller.api.showColumns()] }); // 为表格绑定事件 Table.api.bindevent(table); }, api: { showColumns:function(){ var cols = new Array(); cols.push({field: 'createdate', title: __('日期'),formatter: Controller.api.formatter.createtime}); cols.push({field: 'pv', title: __('PV'),formatter:Controller.api.formatter.format_pv}); cols.push({field: 'uv', title: __('UV'),formatter:Controller.api.formatter.format_uv}); cols.push({field: 'recharge_money', title: __('总充值')}); cols.push({field: 'normal_recharge_money', title: __('普通充值'),formatter: Controller.api.formatter.normal_recharge_money}); cols.push({field: 'normal_recharge_orders_count', title: __('普通充值订单数'),formatter: Controller.api.formatter.normal_recharge_orders_count }); cols.push({field: 'vip_recharge_money', title: __('年度VIP会员'),formatter: Controller.api.formatter.vip_recharge_money}); cols.push({field: 'vip_recharge_orders_count', title: __('年度VIP会员订单数'),formatter: Controller.api.formatter.vip_recharge_orders_count}); return cols; }, bindevent: function () { Form.api.bindevent($("form[role=form]")); },formatter: { format_pv:function(value,row,index){ return parseInt(row.pv); }, format_uv:function(value,row,index){ return parseInt(row.uv); }, normal_recharge_orders: function (value, row, index) { return '¥'+((row.recharge_money-row.recharge_money_benefit)* 1.00).toFixed(2) + ''; }, normal_recharge_money:function (value, row, index) { var normal_recharge_str = '
¥'+row.normal_recharge_money+'
'; if(row.normal_recharge_orders>0){ var normal_recharge_str_avg = Number(row.normal_recharge_money/row.normal_recharge_orders) * 1.00; normal_recharge_str += '成功人次:'+row.normal_recharge_orders+'已支付:'+row.normal_recharge_orders+'笔
'; var wzf = row.normal_recharge_orders_count-row.normal_recharge_orders; if(row.normal_recharge_orders > 0){ if (row.kandian_recharge_orders_count >0) { var normal_recharge_str_order_avg = (row.kandian_recharge_orders*100/row.kandian_recharge_orders_count) * 1.00; } else { var normal_recharge_str_order_avg = (row.normal_recharge_orders*100/row.normal_recharge_orders_count) * 1.00; } normal_recharge_order_str += '未支付:'+wzf+'笔
'; normal_recharge_order_str += '完成率:'+ Math.floor(normal_recharge_str_order_avg)+'%'+'
'; }else{ normal_recharge_order_str += '未支付:'+wzf+'笔
'; normal_recharge_order_str += '完成率:0%'+'
'; } return normal_recharge_order_str; }, vip_recharge_money:function (value, row, index) { var vip_recharge_str = '¥'+row.vip_recharge_money+'
'; if(row.vip_recharge_orders > 0){ var vip_recharge_str_avg = Number(row.vip_recharge_money/row.vip_recharge_orders) * 1.00; vip_recharge_str += '成功人次:'+row.vip_recharge_orders+'已支付:'+row.vip_recharge_orders+'笔
'; var vipwzf = row.vip_recharge_orders_count-row.vip_recharge_orders; if(row.vip_recharge_orders > 0){ if(row.vip_recharge_orders_count){ var vip_recharge_str_order_avg = (row.vip_recharge_orders*100/row.vip_recharge_orders_count) * 1.00; }else{ var vip_recharge_str_order_avg = 0; } vip_recharge_order_str += '未支付:'+vipwzf+'笔
'; vip_recharge_order_str += '完成率:'+ Math.floor(vip_recharge_str_order_avg)+'%'+'
'; }else{ vip_recharge_order_str += '未支付:'+vipwzf+'笔
'; vip_recharge_order_str += '完成率:0%'+'
'; } return vip_recharge_order_str; }, total_benefit:function(value,row,index){ return '¥'+value; }, total_benefit_channel:function(value,row,index) { return '¥' + Number(value).toFixed(2) + ''; }, createtime:function(value,row,index){ return value.substring(0,4)+'-'+ value.substring(4,6)+'-'+value.substring(6,8); }, } } }; return Controller; });