airdrop.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: 'user/airdrop/index' + location.search,
  8. add_url: 'user/airdrop/add',
  9. del_url: 'user/airdrop/del',
  10. multi_url: 'user/airdrop/multi',
  11. import_url: 'user/airdrop/import',
  12. table: 'user_airdrop',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. { field: 'type_id', title: __('投放类型'), searchList: { "0": __('指定账号'), "1": __('超过Rwa数用户'),"2": __('指定区域消费金')}, formatter: Table.api.formatter.label },
  26. {field: 'product_id', title: __('Product_id'), operate: 'LIKE'},
  27. {field: 'num', title: __('Num'), operate: false},
  28. {field: 'address', title: __('Address'), operate: 'LIKE'},
  29. {field: 'rwa_num', title: __('Rwa_num'), operate: false},
  30. {field: 'amount', title: __('指定区域消费金'), operate: false, formatter: function (value, row, index, field) {
  31. return (row.amount > 0)? row.area_txt+ "-"+ row.amount: "";
  32. }},
  33. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  34. { field: 'status', title: __('Status'), searchList: { "1": __('已发放'), "0": __('待发放') }, formatter: Table.api.formatter.status },
  35. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  38. ]
  39. ]
  40. });
  41. // 为表格绑定事件
  42. Table.api.bindevent(table);
  43. },
  44. add: function () {
  45. Controller.api.bindevent();
  46. },
  47. edit: function () {
  48. Controller.api.bindevent();
  49. },
  50. api: {
  51. bindevent: function () {
  52. Form.api.bindevent($("form[role=form]"));
  53. //地区选择
  54. $(document).on('change','.form-inline select',function(){
  55. let txt = $(this).find("option:selected").text();
  56. let obj = $(this).parents('.form-inline').find('input')
  57. if(txt != '请选择') obj.val(txt)
  58. });
  59. }
  60. }
  61. };
  62. return Controller;
  63. });