withdraw.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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: 'withdraw/index',
  8. export_url: '/admin/withdraw/export',
  9. add_url: 'withdraw/add',
  10. edit_url: 'withdraw/edit',
  11. multi_url: 'withdraw/multi',
  12. table: 'withdraw',
  13. }
  14. });
  15. //book_but
  16. $(document).on('click','.book_but',function () {
  17. Fast.api.open($(this).attr('href'), '数据列表', {});
  18. return false;
  19. });
  20. var table = $("#table");
  21. var group = Config.group;
  22. console.log(group);
  23. // 初始化表格
  24. if ([1, 2, 12].indexOf(group)) { //管理员
  25. var payer = Config.payer;
  26. if(typeof payer == "string"){
  27. payer = JSON.parse(payer);
  28. }
  29. table.bootstrapTable({
  30. url: $.fn.bootstrapTable.defaults.extend.index_url,
  31. search: true,
  32. showToggle:false,
  33. showColumns: false,
  34. showExport: false,
  35. searchFormVisible: true,
  36. columns: [
  37. [
  38. {checkbox: true},
  39. {field: 'admin_id',title:__('渠道商id'),operate:false},
  40. {field: 'admin_extend.admin_id', title: __('渠道商id'),visible:false, operate:"LIKE %...%"},
  41. {field: 'admin.nickname', title: __('渠道商'), operate:"LIKE %...%"},
  42. {field: 'withdraw.createtime', title: __('提现时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  43. {field: 'finishtime', title: __('划账日期'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  44. {field: 'money', title: __('Money'), operate:'BETWEEN'},
  45. {field: 'dkfs', title: __('打款方式'),operate:false,formatter: Controller.api.formatter.dkfs},
  46. {field: 'card_holder', title: __('开户人'),operate:false},
  47. {field: 'card_bank', title: __('银行'),operate:false},
  48. {field: 'card_num', title: __('卡号'),operate:false},
  49. {field: 'idcard_no', title: __('身份证号'),operate:false},
  50. {field: 'create_by', title: __('商务负责人'),operate:false},
  51. {field: 'benefit', title: __('分成比例'),operate:false},
  52. {field: 'name', title: __('付款方名称'),operate:false},
  53. {field: 'admin_extend.payerid',title:__('付款方'),visible:false,searchList: payer},
  54. {field: 'section',title:__('结算单时间区间'),operate:false},
  55. {field: 'state', title: __('State'), visible:false, searchList: {"1":__('State 1'),"2":__('State 2'),"3":__('State 3')}},
  56. {field: 'state_text', title: __('State'), operate:false,formatter: Controller.api.formatter.states_span},
  57. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  58. ]
  59. ],
  60. exportOptions: {
  61. type: 'excel',
  62. ignoreColumn: [17],
  63. onMsoNumberFormat: function(cell, row, col) {
  64. if(row > 0){
  65. if(col == 9 || col == 10){
  66. return '\\@';
  67. }else{
  68. return '';
  69. }
  70. }
  71. }},
  72. onLoadSuccess: function (data) {
  73. $('#state1').text(data.others.state1);
  74. $('#state2').text(data.others.state2);
  75. $('#state3').text(data.others.state3);
  76. }
  77. });
  78. }
  79. if(group == 3){ //渠道商
  80. table.bootstrapTable({
  81. url: $.fn.bootstrapTable.defaults.extend.index_url,
  82. search: true,
  83. showToggle:false,
  84. showColumns: false,
  85. showExport: false,
  86. searchFormVisible: true,
  87. columns: [
  88. [
  89. {checkbox: true},
  90. {field: 'admin.nickname', title: '代理商'},
  91. {field: 'withdraw.createtime', title: '提现时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  92. {field: 'finishtime', title: '划账日期', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  93. {field: 'money', title: __('Money'), operate:'BETWEEN',operate:false},
  94. {field: 'dkfs', title: '打款方式',operate:false,formatter: Controller.api.formatter.dkfs,operate:false},
  95. {field: 'card_holder', title: __('开户人'),operate:false},
  96. {field: 'card_bank', title: __('银行'),operate:false},
  97. {field: 'card_num', title: __('卡号'),operate:false},
  98. {field: 'idcard_no', title: __('身份证号'),operate:false},
  99. {field: 'state', title: __('State'), visible:false, searchList: {"1":__('State 1'),"2":__('State 2'),"3":__('State 3')}},
  100. {field: 'state_text', title: __('State'), operate:false,formatter: Controller.api.formatter.states_span},
  101. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  102. ]
  103. ],
  104. exportOptions: {
  105. type: 'excel',
  106. ignoreColumn: [10],
  107. onMsoNumberFormat: function(cell, row, col) {
  108. if(row > 0){
  109. if(col == 7 || col == 8){
  110. return '\\@';
  111. }else{
  112. return '';
  113. }
  114. }
  115. }},
  116. onLoadSuccess: function (data) {
  117. $('#state1').text(data.others.state1);
  118. $('#state2').text(data.others.state2);
  119. $('#state3').text(data.others.state3);
  120. }
  121. });
  122. }
  123. if(group == 4){ //代理商
  124. table.bootstrapTable({
  125. url: $.fn.bootstrapTable.defaults.extend.index_url,
  126. pk: 'id',
  127. sortName: 'id',
  128. columns: [
  129. [
  130. {field: 'withdraw.createtime', title: __('提现时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  131. {field: 'finishtime', title: __('划账日期'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  132. {field: 'money', title: __('Money'), operate:'BETWEEN'},
  133. {field: 'state', title: __('State'),operate:false,formatter: Controller.api.formatter.states},
  134. ]
  135. ]
  136. });
  137. }
  138. // 为表格绑定事件
  139. Table.api.bindevent(table);
  140. // console.log('test');
  141. // console.log(Config);
  142. // 弹窗绑定
  143. // $(document).on('click','.btn-success',function () {
  144. // $('#state1').text(Config.state1);
  145. // $('#state2').text(Config.state2);
  146. // $('#state3').text(Config.state3);
  147. //return false;
  148. // })
  149. },
  150. add: function () {
  151. Controller.api.bindevent();
  152. $(function () {
  153. $('input[name="type"]').click(function(){
  154. if ($(this).val() == 1) {
  155. $('.month').hide();
  156. $('.withdraw-month').hide();
  157. $('.withdraw-all').show();
  158. } else {
  159. $('.month').show();
  160. $('.withdraw-month').show();
  161. $('.withdraw-all').hide();
  162. }
  163. });
  164. });
  165. },
  166. edit: function () {
  167. Controller.api.bindevent();
  168. },
  169. mywithdraw:function () {
  170. // 初始化表格参数配置
  171. Table.api.init({
  172. extend: {
  173. index_url: 'withdraw/mywithdraw',
  174. add_url: 'withdraw/add',
  175. multi_url: 'withdraw/multi',
  176. table: 'withdraw',
  177. export_url:'mywithdrawexport',
  178. }
  179. });
  180. // 为表格绑定事件
  181. var table = $("#table");
  182. table.bootstrapTable({
  183. url: $.fn.bootstrapTable.defaults.extend.index_url,
  184. pk: 'id',
  185. sortName: 'id',
  186. columns: [
  187. [
  188. {field: 'createtime', title: __('提现时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  189. {field: 'range', title: __('提现周期'), operate:false, addclass:'datetimerange', formatter: function(value,row){
  190. if (!row.stime) {
  191. row.stime = '';
  192. }
  193. return row.stime+'-'+row.etime;
  194. }},
  195. {field: 'finishtime', title: __('划账日期'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  196. {field: 'money', title: __('Money'), operate:'BETWEEN'},
  197. {field: 'state', title: __('State'),operate:false,formatter: Controller.api.formatter.states},
  198. ]
  199. ]
  200. });
  201. Table.api.bindevent(table);
  202. },
  203. myhistorydraw: function () {
  204. // 初始化表格参数配置
  205. Table.api.init({
  206. extend: {
  207. index_url: 'withdraw/myhistorydraw',
  208. }
  209. });
  210. // 为表格绑定事件
  211. var table = $("#historytable");
  212. table.bootstrapTable({
  213. url: $.fn.bootstrapTable.defaults.extend.index_url,
  214. queryParams: queryParams,
  215. pk: 'id',
  216. sortName: 'id',
  217. columns: [
  218. [
  219. {
  220. field: 'createtime',
  221. title: __('提现时间'),
  222. operate: 'RANGE',
  223. addclass: 'datetimerange',
  224. formatter: Table.api.formatter.datetime
  225. },
  226. {
  227. field: 'finishtime',
  228. title: __('划账日期'),
  229. operate: 'RANGE',
  230. addclass: 'datetimerange',
  231. formatter: Table.api.formatter.datetime
  232. },
  233. {field: 'money', title: __('Money'), operate: 'BETWEEN'},
  234. {
  235. field: 'state',
  236. title: __('State'),
  237. operate: false,
  238. formatter: Controller.api.formatter.states
  239. },
  240. ]
  241. ]
  242. });
  243. Table.api.bindevent(table);
  244. },
  245. api: {
  246. bindevent: function () {
  247. Form.api.bindevent($("form[role=form]"));
  248. $('#c-money').keyup(function () {
  249. var money = parseInt($('#c-money').val());
  250. if(isNaN(money)){
  251. money = 0;
  252. }
  253. var service_recharge =0;
  254. // if(money <10 ){
  255. // money = 0;
  256. // service_recharge = 0;
  257. // }
  258. // if(money < 500 && money >=10 ){
  259. // money = money-5;
  260. // service_recharge = 5;
  261. // }
  262. // if(money <= 5000 && money >=500 ){
  263. // service_recharge = money*0.01;
  264. // money = money-money*0.01;
  265. // }
  266. // if(money > 5000 ){
  267. // money = money-50;
  268. // service_recharge = 50;
  269. // }
  270. if(money+service_recharge >Config.no_cash_money){
  271. money = '超出可提现金额';
  272. service_recharge = 0;
  273. }
  274. $('.money').val(money);
  275. // $('.ServiceCharge').val(service_recharge);
  276. });
  277. },
  278. formatter:{
  279. dkfs:function(value,row,index){
  280. if(value ==1){
  281. return '银行卡对公';
  282. }else if(value == 2){
  283. return '银行卡对私';
  284. }else if(value == 3){
  285. return '微信';
  286. }else{
  287. return '支付宝';
  288. }
  289. },
  290. states:function(value,row,index){
  291. if(value ==1){
  292. return '提现中';
  293. }else if(value == 2){
  294. return '打款中';
  295. }else if(value == 3){
  296. return '已打款';
  297. }
  298. },
  299. states_span:function(value,row,index){
  300. if(value =='提现中'){
  301. return '<span class="ord_red">提现中</span>';
  302. }else if(value == '打款中'){
  303. return '<span class="ord_yellow">打款中</span>';
  304. }else if(value == '已打款'){
  305. return '<span class="ord_green">已打款</span>';
  306. }
  307. }
  308. }
  309. }
  310. };
  311. return Controller;
  312. });
  313. function queryParams(params) {
  314. var temp = { //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
  315. admin_id: $("#admin_id").val(),
  316. };
  317. return temp;
  318. }