orders.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. if(Config.orderType==1){
  3. var Controller = {
  4. klorder: function () {
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'orders/klorder',
  9. multi_url: 'orders/multi',
  10. table: 'orders',
  11. },
  12. showToggle: false,
  13. showColumns: false,
  14. visible: false,
  15. searchFormVisible: true,
  16. search:false,
  17. showExport:true
  18. });
  19. var table = $("#table");
  20. // 初始化表格
  21. table.bootstrapTable({
  22. url: $.fn.bootstrapTable.defaults.extend.index_url,
  23. pk: 'id',
  24. sortName: 'id',
  25. columns: [
  26. [
  27. {field: 'out_trade_no', title: __('商户单号'),operate: 'LIKE %...%'},
  28. {field: 'transaction_id', title: __('交易单号'),operate: 'LIKE %...%'},
  29. {field: 'user.nickname', title: __('用户'),operate:false,formatter: Controller.api.formatter.user},
  30. {field: 'orders.type', title: __('Type'), visible:false, searchList: {"1":__('书币充值'),"2":__('VIP充值')}},
  31. {field: 'type_text', title: __('Type'), operate:false},
  32. {field: 'money', title: __('充值金额'),operate:'='},
  33. {field: 'orders.state', title: __('支付状态'),formatter: Controller.api.formatter.states, searchList: {"0":__('未支付'),"1":__('已支付')}},
  34. {field: 'finishtime', title: __('完成时间'), formatter: Table.api.formatter.datetime,operate: 'RANGE', addclass:'datetimerange'},
  35. {field: 'cnickname', title:__('渠道商'),operate:false},
  36. {field: 'resource_id', title: __('资源id')},
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. },
  43. add: function () {
  44. Controller.api.bindevent();
  45. },
  46. edit: function () {
  47. Controller.api.bindevent();
  48. },
  49. api: {
  50. bindevent: function () {
  51. Form.api.bindevent($("form[role=form]"));
  52. },formatter:{
  53. user:function(value,row,index){
  54. if(row.user){
  55. return '<img style="width:20px;" src="'+row.user.avatar+'" /> '+row.user.nickname+' (id:'+row.user.id+')';
  56. }
  57. },
  58. states:function(value,row,index){
  59. if (row.state=='0'){
  60. return '<span class="ord_red">未支付</span>';
  61. }else{
  62. return '<span class="ord_green">已支付</span>';
  63. }
  64. },
  65. }
  66. }
  67. };
  68. }else{
  69. var Controller = {
  70. index: function () {
  71. // 初始化表格参数配置
  72. Table.api.init({
  73. extend: {
  74. index_url: Config.orderpath,
  75. multi_url: 'orders/multi',
  76. table: 'orders',
  77. },
  78. showToggle: false,
  79. showColumns: false,
  80. visible: false,
  81. searchFormVisible: Config.searchFormVisibleStatus,
  82. search:false,
  83. showExport:true,
  84. commonSearch: Config.searchFormVisibleStatus,
  85. });
  86. var table = $("#table");
  87. // 初始化表格
  88. table.bootstrapTable({
  89. url: $.fn.bootstrapTable.defaults.extend.index_url,
  90. pk: 'id',
  91. sortName: 'id',
  92. columns: [
  93. [
  94. {field: 'out_trade_no', title: __('商户单号'),operate: 'LIKE %...%'},
  95. {field: 'transaction_id', title: __('交易单号'),operate: 'LIKE %...%'},
  96. {field: 'user.nickname', title: __('用户'),operate:false,formatter: Controller.api.formatter.user},
  97. {field: 'type', title: __('Type'), visible:false, searchList: {"type 1":__('Type 1'),"type 2":__('Type 2')},operate:false},
  98. {field: 'type_text', title: __('Type'), operate:false},
  99. {field: 'money', title: __('充值金额'),operate:'='},
  100. {field: 'state', title: __('支付状态'),formatter: Controller.api.formatter.states, searchList: {"0":__('未支付'),"1":__('已支付')}},
  101. {field: 'createtime', title: __('下单时间'), formatter: Table.api.formatter.datetime,operate: 'RANGE', addclass:'datetimerange'},
  102. {field: 'finishtime', title: __('完成时间'), formatter: Table.api.formatter.datetime,operate: 'RANGE', addclass:'datetimerange'},
  103. {field: 'referral_id', title: __('推广链接id'),operate:false},
  104. {field: 'pdqd', title: __('推广链接渠道'),operate:false},
  105. {field: 'bookname', title: __('书名'),operate:false,visible:(Config.group<=2)},
  106. {field: 'user.agent_id', title: __('代理商'),visible:(Config.group<4 || Config.group==5), operate:false},
  107. {field: 'user.channel_id', title: __('渠道商'),visible:(Config.group<3 || Config.group==5), operate:false},
  108. {field: 'user.cchannelid', title: __('渠道商Id'),visible:(Config.group<3 || Config.group==5), operate:false},
  109. {field: 'user.cusername', title: __('渠道商用户名'),visible:(Config.group<3 || Config.group==5), operate:false},
  110. {field: 'user.qrimage',title:__('渠道商二维码(点击查看大图)'),visible:(Config.group<3 || Config.group==5), operate:false,formatter: Controller.api.formatter.qrimage}
  111. ]
  112. ],
  113. exportOptions: {
  114. type: 'excel',
  115. onMsoNumberFormat: function(cell, row, col) {
  116. return (row > 0 && col == 1) ? '\\@' : '';
  117. }}
  118. });
  119. // 为表格绑定事件
  120. Table.api.bindevent(table);
  121. },
  122. add: function () {
  123. Controller.api.bindevent();
  124. },
  125. edit: function () {
  126. Controller.api.bindevent();
  127. },
  128. api: {
  129. bindevent: function () {
  130. Form.api.bindevent($("form[role=form]"));
  131. },formatter:{
  132. user:function(value,row,index){
  133. return '<img style="width:20px;" src="'+row.user.avatar+'" /> '+row.user.nickname+' (id:'+row.user.id+')';
  134. },
  135. states:function(value,row,index){
  136. if (value==0){
  137. return '<span class="ord_red">未支付</span>';
  138. }else{
  139. return '<span class="ord_green">已支付</span>';
  140. }
  141. },
  142. qrimage:function(value,row,index){
  143. if(value){
  144. return '<a href="'+value+'" target="_blank"><img style="width:20px;" src="'+value+'"></a>';
  145. }else{
  146. return '无';
  147. }
  148. }
  149. }
  150. }
  151. };
  152. }
  153. return Controller;
  154. });