define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { if(Config.orderType==1){ //KL订单 var Controller = { klorder: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'orders/klorder', multi_url: 'orders/multi', table: 'orders', }, // pageSize: 10, // pageList: [10, 10, 10, 30], showToggle: false, showColumns: false, visible: false, searchFormVisible: true, search:false, showExport:true }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ clickToSelect: true, url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {field: 'out_trade_no', title: __('商户单号'),operate: 'LIKE %...%'}, {field: 'transaction_id', title: __('交易单号'),operate: 'LIKE %...%'}, {field: 'user.nickname', title: __('用户'),operate:false,formatter: Controller.api.formatter.user}, {field: 'user.createtime', title: __('用户注册时间'),operate:false,formatter: Table.api.formatter.datetime}, {field: 'orders.type', title: __('Type'), visible:false, searchList: {"1":__('书币充值'),"2":__('VIP充值')}}, {field: 'type_text', title: __('Type'), operate:false}, {field: 'money', title: __('充值金额'),operate:'='}, {field: 'orders.state', title: __('支付状态'),formatter: Controller.api.formatter.states, searchList: {"0":__('未支付'),"1":__('已支付')}}, {field: 'finishtime', title: __('完成时间'), formatter: Table.api.formatter.datetime, operate: false, addclass: 'datetimerange', options: {dateLimit:{days : 30}}}, {field: 'cnickname', title:__('渠道商'),operate:false}, { field: 'business_line', title: __('订单来源'), operate: '=', searchList: {"0":__('微信'),"1":__('APP')}, formatter: function (value, row, index) { if (value == '0') { return '微信'; } else { return 'APP'; } } }, {field: 'resource_id', title: __('资源id')}, ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); },formatter:{ user:function(value,row,index){ if(row.user){ return ' '+row.user.nickname+' (id:'+row.user.id+')'; } }, states:function(value,row,index){ if (row.state=='0'){ return '未支付'; }else{ return '已支付'; } }, } } }; }else{ var Controller = { index: function () { console.log('AAA'); console.log(Config.orderpath); console.log('BBB'); // 初始化表格参数配置 Table.api.init({ extend: { index_url: Config.orderpath, multi_url: 'orders/multi', table: 'orders', export_url: Config.exportpath, }, pageSize: 10, pageList: [10], showToggle: false, showColumns: false, visible: false, searchFormVisible: Config.searchFormVisibleStatus, search:false, showExport:false, commonSearch: Config.searchFormVisibleStatus, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [Controller.api.showColumns()], exportOptions: { type: 'excel', onMsoNumberFormat: function(cell, row, col) { return (row > 0 && col == 1) ? '\\@' : ''; }} }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); },formatter:{ user:function(value,row,index){ return ' '+row.user.nickname+' (id:'+row.user.id+')'; }, states:function(value,row,index){ if (value==0){ return '未支付'; }else{ return '已支付'; } }, qrimage:function(value,row,index){ if(value){ return ''; }else{ return '无'; } } }, showColumns: function () { var cols = new Array(); cols.push({field: 'out_trade_no', title: __('商户单号')}); cols.push({field: 'transaction_id', title: __('交易单号')}); cols.push({field: 'user.nickname', title: __('用户'),operate:false,formatter: Controller.api.formatter.user}); cols.push({field: 'user.createtime', title: __('用户注册时间'),operate:false,formatter: Table.api.formatter.datetime}); cols.push({field: 'type', title: __('Type'), visible:false, searchList: {"type 1":__('Type 1'),"type 2":__('Type 2')},operate:false}); cols.push({field: 'type_text', title: __('Type'), operate:false}); cols.push({field: 'orders.money', title: __('充值金额'),operate:'=',visible:false}); cols.push({field: 'money', title: __('充值金额'),operate:false}); cols.push({field: 'orders.state', title: __('支付状态'),formatter: Controller.api.formatter.states,visible:false, searchList: {"0":__('未支付'),"1":__('已支付')}}); cols.push({field: 'state', title: __('支付状态'),formatter: Controller.api.formatter.states, searchList: {"0":__('未支付'),"1":__('已支付')},operate:false}); cols.push({field: 'orders.createtime', title: __('下单时间'), formatter: Table.api.formatter.datetime,operate: 'RANGE', visible:false,addclass:'datetimerange', options: {dateLimit:{days : 30}}}); cols.push({field: 'createtime', title: __('下单时间'), formatter: Table.api.formatter.datetime,operate:false, addclass:'datetimerange'}); cols.push({field: 'finishtime', title: __('完成时间'), formatter: Table.api.formatter.datetime,operate: false, addclass:'datetimerange'}); cols.push({field: 'referral_id', title: __('推广链接id'),operate:false, formatter: function (value, row) { if (value == 0) { return row.referral_id_permanent; } else { return value; } }}); cols.push({field: 'pdqd', title: __('推广链接渠道'),operate:false}); cols.push({field: 'bookname', title: __('书名'),operate:false,visible:([1,2,12].indexOf(Config.group))}); cols.push({field: 'user.agent_id', title: __('代理商昵称'),visible:([1,2,3,5,12].indexOf(Config.group)), operate:false}); cols.push({field: 'user.channel_id', title: __('渠道商昵称'),visible:([1,2,5,12].indexOf(Config.group)), operate:false}); cols.push({field: 'user.cchannelid', title: __('渠道商Id'),visible:([1,2,5,12].indexOf(Config.group)), operate:false}); cols.push({field: 'user.cusername', title: __('渠道商用户名'),visible:([1,2,5,12].indexOf(Config.group)), operate:false}); if (Config.isShowBusinessLine == true) { cols.push({ field: 'business_line', title: __('订单来源'), operate: '=', searchList: {"0":__('分销站'),"1":__('客户端')}, formatter: function (value, row, index) { if (value == '0') { return '分销站'; } else { return '客户端'; } } }); } cols.push({field: 'user.qrimage',title:__('渠道商二维码(点击查看大图)'),visible:([1,2,5,12].indexOf(Config.group)), operate:false,formatter: Controller.api.formatter.qrimage}); return cols; } } }; } return Controller; });