orders.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. if(Config.orderType==1){ //KL订单
  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. // pageSize: 10,
  13. // pageList: [10, 10, 10, 30],
  14. showToggle: false,
  15. showColumns: false,
  16. visible: false,
  17. searchFormVisible: true,
  18. search:false,
  19. showExport:true
  20. });
  21. var table = $("#table");
  22. // 初始化表格
  23. table.bootstrapTable({
  24. clickToSelect: true,
  25. url: $.fn.bootstrapTable.defaults.extend.index_url,
  26. pk: 'id',
  27. sortName: 'id',
  28. columns: [
  29. [
  30. {field: 'out_trade_no', title: __('商户单号'),operate: 'LIKE %...%'},
  31. {field: 'transaction_id', title: __('交易单号'),operate: 'LIKE %...%'},
  32. {field: 'user.nickname', title: __('用户'),operate:false,formatter: Controller.api.formatter.user},
  33. {field: 'user.createtime', title: __('用户注册时间'),operate:false,formatter: Table.api.formatter.datetime},
  34. {field: 'orders.type', title: __('Type'), visible:false, searchList: {"1":__('书币充值'),"2":__('VIP充值')}},
  35. {field: 'type_text', title: __('Type'), operate:false},
  36. {field: 'money', title: __('充值金额'),operate:'='},
  37. {field: 'orders.state', title: __('支付状态'),formatter: Controller.api.formatter.states, searchList: {"0":__('未支付'),"1":__('已支付')}},
  38. {field: 'finishtime', title: __('完成时间'), formatter: Table.api.formatter.datetime, operate: false, addclass: 'datetimerange', options: {dateLimit:{days : 30}}},
  39. {field: 'cnickname', title:__('渠道商'),operate:false},
  40. {
  41. field: 'business_line',
  42. title: __('订单来源'),
  43. operate: '=',
  44. searchList: {"0":__('微信'),"1":__('APP')},
  45. formatter: function (value, row, index) {
  46. if (value == '0') {
  47. return '微信';
  48. } else {
  49. return 'APP';
  50. }
  51. }
  52. },
  53. {field: 'resource_id', title: __('资源id')},
  54. ]
  55. ]
  56. });
  57. // 为表格绑定事件
  58. Table.api.bindevent(table);
  59. },
  60. add: function () {
  61. Controller.api.bindevent();
  62. },
  63. edit: function () {
  64. Controller.api.bindevent();
  65. },
  66. api: {
  67. bindevent: function () {
  68. Form.api.bindevent($("form[role=form]"));
  69. },formatter:{
  70. user:function(value,row,index){
  71. if(row.user){
  72. return '<img style="width:20px;" src="'+row.user.avatar+'" /> '+row.user.nickname+' (id:'+row.user.id+')';
  73. }
  74. },
  75. states:function(value,row,index){
  76. if (row.state=='0'){
  77. return '<span class="ord_red">未支付</span>';
  78. }else{
  79. return '<span class="ord_green">已支付</span>';
  80. }
  81. },
  82. }
  83. }
  84. };
  85. }else{
  86. var Controller = {
  87. index: function () {
  88. console.log('AAA');
  89. console.log(Config.orderpath);
  90. console.log('BBB');
  91. // 初始化表格参数配置
  92. Table.api.init({
  93. extend: {
  94. index_url: Config.orderpath,
  95. multi_url: 'orders/multi',
  96. table: 'orders',
  97. export_url: Config.exportpath,
  98. },
  99. pageSize: 10,
  100. pageList: [10],
  101. showToggle: false,
  102. showColumns: false,
  103. visible: false,
  104. searchFormVisible: Config.searchFormVisibleStatus,
  105. search:false,
  106. showExport:false,
  107. commonSearch: Config.searchFormVisibleStatus,
  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: [Controller.api.showColumns()],
  116. exportOptions: {
  117. type: 'excel',
  118. onMsoNumberFormat: function(cell, row, col) {
  119. return (row > 0 && col == 1) ? '\\@' : '';
  120. }}
  121. });
  122. // 为表格绑定事件
  123. Table.api.bindevent(table);
  124. },
  125. add: function () {
  126. Controller.api.bindevent();
  127. },
  128. edit: function () {
  129. Controller.api.bindevent();
  130. },
  131. api: {
  132. bindevent: function () {
  133. Form.api.bindevent($("form[role=form]"));
  134. },formatter:{
  135. user:function(value,row,index){
  136. return '<img style="width:20px;" src="'+row.user.avatar+'" /> '+row.user.nickname+' (id:'+row.user.id+')';
  137. },
  138. states:function(value,row,index){
  139. if (value==0){
  140. return '<span class="ord_red">未支付</span>';
  141. }else{
  142. return '<span class="ord_green">已支付</span>';
  143. }
  144. },
  145. qrimage:function(value,row,index){
  146. if(value){
  147. return '<a href="'+value+'" target="_blank"><img style="width:20px;" src="'+value+'"></a>';
  148. }else{
  149. return '无';
  150. }
  151. }
  152. },
  153. showColumns: function () {
  154. var cols = new Array();
  155. cols.push({field: 'out_trade_no', title: __('商户单号')});
  156. cols.push({field: 'transaction_id', title: __('交易单号')});
  157. cols.push({field: 'user.nickname', title: __('用户'),operate:false,formatter: Controller.api.formatter.user});
  158. cols.push({field: 'user.createtime', title: __('用户注册时间'),operate:false,formatter: Table.api.formatter.datetime});
  159. cols.push({field: 'type', title: __('Type'), visible:false, searchList: {"type 1":__('Type 1'),"type 2":__('Type 2')},operate:false});
  160. cols.push({field: 'type_text', title: __('Type'), operate:false});
  161. cols.push({field: 'orders.money', title: __('充值金额'),operate:'=',visible:false});
  162. cols.push({field: 'money', title: __('充值金额'),operate:false});
  163. cols.push({field: 'orders.state', title: __('支付状态'),formatter: Controller.api.formatter.states,visible:false, searchList: {"0":__('未支付'),"1":__('已支付')}});
  164. cols.push({field: 'state', title: __('支付状态'),formatter: Controller.api.formatter.states, searchList: {"0":__('未支付'),"1":__('已支付')},operate:false});
  165. cols.push({field: 'orders.createtime', title: __('下单时间'), formatter: Table.api.formatter.datetime,operate: 'RANGE', visible:false,addclass:'datetimerange', options: {dateLimit:{days : 30}}});
  166. cols.push({field: 'createtime', title: __('下单时间'), formatter: Table.api.formatter.datetime,operate:false, addclass:'datetimerange'});
  167. cols.push({field: 'finishtime', title: __('完成时间'), formatter: Table.api.formatter.datetime,operate: false, addclass:'datetimerange'});
  168. cols.push({field: 'referral_id', title: __('推广链接id'),operate:false, formatter: function (value, row) {
  169. if (value == 0) {
  170. return row.referral_id_permanent;
  171. } else {
  172. return value;
  173. }
  174. }});
  175. cols.push({field: 'pdqd', title: __('推广链接渠道'),operate:false});
  176. cols.push({field: 'bookname', title: __('书名'),operate:false,visible:([1,2,12].indexOf(Config.group))});
  177. cols.push({field: 'user.agent_id', title: __('代理商昵称'),visible:([1,2,3,5,12].indexOf(Config.group)), operate:false});
  178. cols.push({field: 'user.channel_id', title: __('渠道商昵称'),visible:([1,2,5,12].indexOf(Config.group)), operate:false});
  179. cols.push({field: 'user.cchannelid', title: __('渠道商Id'),visible:([1,2,5,12].indexOf(Config.group)), operate:false});
  180. cols.push({field: 'user.cusername', title: __('渠道商用户名'),visible:([1,2,5,12].indexOf(Config.group)), operate:false});
  181. if (Config.isShowBusinessLine == true) {
  182. cols.push({
  183. field: 'business_line',
  184. title: __('订单来源'),
  185. operate: '=',
  186. searchList: {"0":__('分销站'),"1":__('客户端')},
  187. formatter: function (value, row, index) {
  188. if (value == '0') {
  189. return '分销站';
  190. } else {
  191. return '客户端';
  192. }
  193. }
  194. });
  195. }
  196. cols.push({field: 'user.qrimage',title:__('渠道商二维码(点击查看大图)'),visible:([1,2,5,12].indexOf(Config.group)), operate:false,formatter: Controller.api.formatter.qrimage});
  197. return cols;
  198. }
  199. }
  200. };
  201. }
  202. return Controller;
  203. });