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