airdrop.js 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.zh_name', 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: 'rwa_product.zh_name', title: __('持有产品'), operate: 'LIKE'},
  31. {field: 'amount', title: __('指定区域消费金'), operate: false, formatter: function (value, row, index, field) {
  32. return (row.amount > 0)? row.area_txt+ "-"+ row.amount: "";
  33. }},
  34. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  35. { field: 'status', title: __('Status'), searchList: { "1": __('已发放'), "0": __('待发放') }, formatter: Table.api.formatter.status },
  36. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. add: function () {
  46. Form.api.bindevent($("form[role=form]"), function () {
  47. }, function () {
  48. }, function (success, error) {
  49. layer.confirm('请先仔细检查后操作!!', {
  50. btn: ['确定', '取消'] //按钮
  51. }, function (index) {
  52. Form.api.submit($("form[role=form]"), function (data, ret) {
  53. //如果我们需要在提交表单成功后做跳转,可以在此使用location.href="链接";进行跳转
  54. setTimeout(function () {
  55. parent.Layer.close(parent.Layer.getFrameIndex(window.name));
  56. //刷新页面
  57. window.parent.location.reload();
  58. }, 1000);
  59. });
  60. Layer.close(index);
  61. }, function () {
  62. });
  63. return false;
  64. });
  65. },
  66. edit: function () {
  67. Controller.api.bindevent();
  68. },
  69. api: {
  70. bindevent: function () {
  71. Form.api.bindevent($("form[role=form]"));
  72. //地区选择
  73. $(document).on('change','.form-inline select',function(){
  74. let txt = $(this).find("option:selected").text();
  75. let obj = $(this).parents('.form-inline').find('input')
  76. if(txt != '请选择') obj.val(txt)
  77. });
  78. }
  79. }
  80. };
  81. return Controller;
  82. });