collect.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'book/collect/index',
  8. table: 'book_collect',
  9. },
  10. showToggle: false,
  11. showColumns: false,
  12. operate: false,
  13. commonSearch: true,
  14. searchFormVisible: true,
  15. search:false,
  16. onLoadSuccess: function (data) {
  17. $("[data-toggle='tooltip']").tooltip({trigger: 'focus hover'});
  18. }
  19. });
  20. var table = $("#table");
  21. if(Config.groupId<3){
  22. // 初始化表格
  23. table.bootstrapTable({
  24. url: $.fn.bootstrapTable.defaults.extend.index_url,
  25. pk: 'id',
  26. sortName: 'recharge_money',
  27. columns: [
  28. [
  29. {field: 'book_id', title: __('小说ID'),operate:false},
  30. {field: 'id', title: __('小说ID'),visible: false,operate:'LIKE %...%'},
  31. {field: 'name', title: __('小说名称'),operate:'LIKE %...%'},
  32. {field: 'sex', title: __('频道'), operate:false},
  33. {field: 'book_category', title: __('分类'), operate:false},
  34. {field: 'uv', title: __('阅读人次'), operate:false},
  35. {field: 'pv', title: __('阅读次数'), operate:false},
  36. {field: 'today_recharge_money', title: __('今日充值'), operate:false,formatter: Controller.api.formatter.today_recharge_money},
  37. {field: 'yesterday_recharge_money', title: __('昨日充值'), operate:false,formatter: Controller.api.formatter.yesterday_recharge_money},
  38. {field: 'recharge_money', title: __('总充值(不含当日)'), operate:false,formatter: Controller.api.formatter.recharge_money},
  39. {field: 'today_spending_count_kandian', title: __('今日消费'), operate:false,formatter: Controller.api.formatter.today_spending_count_kandian},
  40. {field: 'yesterday_spending_count_kandian', title: __('昨日消费'), operate:false,formatter: Controller.api.formatter.yesterday_spending_count_kandian},
  41. {field: 'spending_count_kandian', title: __('总消费(不含当日)'), operate:false,formatter: Controller.api.formatter.spending_count_kandian},
  42. {field: 'book_id', title: __('查看详情'),formatter: Controller.api.formatter.book_id,operate:false},
  43. ]
  44. ]
  45. });
  46. }else{
  47. // 初始化表格
  48. table.bootstrapTable({
  49. url: $.fn.bootstrapTable.defaults.extend.index_url,
  50. pk: 'id',
  51. sortName: 'recharge_money',
  52. columns: [
  53. [
  54. {field: 'book_id', title: __('小说ID'),operate:false},
  55. {field: 'id', title: __('小说ID'),visible: false,operate:'LIKE %...%'},
  56. {field: 'name', title: __('小说名称'),operate:'LIKE %...%'},
  57. {field: 'sex', title: __('频道'), operate:false},
  58. {field: 'book_category', title: __('分类'), operate:false},
  59. {field: 'today_recharge_money', title: __('今日充值'), operate:false,formatter: Controller.api.formatter.today_recharge_money},
  60. {field: 'yesterday_recharge_money', title: __('昨日充值'), operate:false,formatter: Controller.api.formatter.yesterday_recharge_money},
  61. {field: 'recharge_money', title: __('总充值(不含当日)'), operate:false,formatter: Controller.api.formatter.recharge_money},
  62. ]
  63. ]
  64. });
  65. }
  66. // 为表格绑定事件
  67. Table.api.bindevent(table);
  68. },
  69. detail: function () {
  70. // 初始化表格参数配置
  71. Table.api.init({
  72. showToggle: false,
  73. showColumns: false,
  74. operate: false,
  75. search:false,
  76. searchFormVisible: false,
  77. commonSearch: false
  78. });
  79. var table = $("#table");
  80. // 初始化表格
  81. table.bootstrapTable({
  82. url: Config.detailUrl,
  83. pk: 'id',
  84. sortName: 'createdate',
  85. columns: [
  86. [
  87. {field: 'name', title: __('小说'),operate:false},
  88. {field: 'createdate', title: __('日期'),operate:false},
  89. {field: 'pv', title: __('阅读数'),operate:false},
  90. {field: 'uv', title: __('阅读人次'),operate:false},
  91. {field: 'recharge_num', title: __('充值笔数'),operate:false},
  92. {field: 'recharge_users', title: __('充值人数'),operate:false},
  93. {field: 'recharge_money', title: __('充值金额(不含当日)'),operate:false,formatter: Controller.api.formatter.addfuhao},
  94. {field: 'spending_num', title: __('消费笔数'),operate:false},
  95. {field: 'spending_users', title: __('消费人数'),operate:false},
  96. {field: 'spending_count_kandian', title: __('消费金额'),operate:false,formatter: Controller.api.formatter.addfspending},
  97. {field: 'spending_recharge_kandian', title: __('消费充值书币'),operate:false,formatter: Controller.api.formatter.addfspending},
  98. {field: 'spending_free_kandian', title: __('消费赠送书币'),operate:false,formatter: Controller.api.formatter.addfspending}
  99. ]
  100. ]
  101. });
  102. // 为表格绑定事件
  103. Table.api.bindevent(table);
  104. },
  105. api: {
  106. bindevent: function () {
  107. Form.api.bindevent($("form[role=form]"));
  108. },formatter: {
  109. recharge_money: function (value, row, index) {
  110. return '<div style="color:#6495ed" >¥' + Number(value).toFixed(2) + '</div><div>' + row.recharge_num + '笔</div>';
  111. },
  112. spending_count_kandian: function (value, row, index) {
  113. return '<div style="color:#6495ed">¥' + Number(value).toFixed(2) + '</div><div>消费充值:¥' + Number(row.spending_recharge_kandian).toFixed(2) + '</div><div>消费赠送:¥' + Number(row.spending_free_kandian).toFixed(2) + '</div>';
  114. },
  115. today_recharge_money:function (value, row, index) {
  116. return '<div style="color:#6495ed" >¥' + Number(value).toFixed(2) + '</div><div>' + row.today_recharge_num + '笔</div>';
  117. },
  118. yesterday_recharge_money:function (value, row, index) {
  119. return '<div style="color:#6495ed" >¥' + Number(value).toFixed(2) + '</div><div>' + row.yesterday_recharge_num + '笔</div>';
  120. },
  121. today_spending_count_kandian:function (value, row, index) {
  122. return '<div style="color:#6495ed">¥' + Number(value).toFixed(2) + '</div><div>消费充值:¥' + row.today_spending_recharge_kandian.toFixed(2) + '</div><div>消费赠送:¥' + row.today_spending_free_kandian.toFixed(2) + '</div>';
  123. },
  124. yesterday_spending_count_kandian:function (value, row, index) {
  125. return '<div style="color:#6495ed">¥' + Number(value).toFixed(2) + '</div><div>消费充值:¥' + row.yesterday_spending_recharge_kandian.toFixed(2) + '</div><div>消费赠送:¥' + row.yesterday_spending_free_kandian.toFixed(2) + '</div>';
  126. },
  127. book_id:function (value, row, index) {
  128. return '<a href="/admin/book/collect/detail?book_id='+row.book_id+'">查看详情(不含当日)</a>';
  129. },
  130. addfuhao:function(value, row, index) {
  131. return '¥'+value;
  132. },
  133. addfspending:function(value, row, index) {
  134. return '¥'+value/100;
  135. }
  136. }
  137. }
  138. };
  139. return Controller;
  140. });