wxpayfufen.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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: 'wxpayfufen/index',
  8. table: 'wxpay',
  9. },
  10. search:false
  11. });
  12. var table = $("#table");
  13. // 初始化表格
  14. table.bootstrapTable({
  15. url: $.fn.bootstrapTable.defaults.extend.index_url + '?ids='+Config.data.fufenid,
  16. pk: 'id',
  17. sortName: 'id',
  18. columns: [
  19. [
  20. {checkbox: true},
  21. {field: 'id', title: __('Id')},
  22. {field: 'name', title: __('Name'),operate:'LIKE'},
  23. {field: 'pay_host', title: __('Pay_host'),operate:'LIKE'},
  24. {field: 'p_desc', title: '描述',operate:false},
  25. {field: 'mcid', title: '微信支付商户id'},
  26. {field: 'operate', title: __('Operate'), formatter: function (value, row) {
  27. return "<a href='javascript:;' class='batch_relation' data-wxpay_id='"+row.id+"'>关联</a>";
  28. }}
  29. ]
  30. ]
  31. });
  32. $(document).delegate('.batch_relation', 'click', function () {
  33. var ids = [];
  34. if ($(this).data('channel_id')) {
  35. ids.push($(this).data('channel_id'));
  36. } else {
  37. ids = Table.api.selectedids(table);
  38. }
  39. Controller.api.batchrelation(ids, 'add', table)
  40. });
  41. // 为表格绑定事件
  42. Table.api.bindevent(table);
  43. },
  44. show: function () {
  45. // 初始化表格参数配置
  46. Table.api.init({
  47. extend: {
  48. index_url: 'wxpayfufen/show',
  49. table: 'wxpay',
  50. },
  51. search:false
  52. });
  53. var table = $("#table");
  54. // 初始化表格
  55. table.bootstrapTable({
  56. url: $.fn.bootstrapTable.defaults.extend.index_url + '?ids='+Config.data.fufenid,
  57. pk: 'id',
  58. sortName: 'id',
  59. columns: [
  60. [
  61. {checkbox: true},
  62. {field: 'id', title: __('Id')},
  63. {field: 'name', title: __('Name'),operate:'LIKE'},
  64. {field: 'pay_host', title: __('Pay_host'),operate:'LIKE'},
  65. {field: 'p_desc', title: '描述',operate: false},
  66. {field: 'mcid', title: '微信支付商户id'},
  67. {field: 'operate', title: __('Operate'), formatter: function (value, row) {
  68. return "<a href='javascript:;' class='batch_relation' data-wxpay_id='"+row.id+"'>删除</a>";
  69. }}
  70. ]
  71. ]
  72. });
  73. $(document).delegate('.batch_relation', 'click', function () {
  74. var ids = [];
  75. if ($(this).data('channel_id')) {
  76. ids.push($(this).data('channel_id'));
  77. } else {
  78. ids = Table.api.selectedids(table);
  79. }
  80. Controller.api.batchrelation(ids, 'remove', table)
  81. });
  82. // 为表格绑定事件
  83. Table.api.bindevent(table);
  84. },
  85. add: function () {
  86. Controller.api.bindevent();
  87. },
  88. edit: function () {
  89. Controller.api.bindevent();
  90. },
  91. api: {
  92. bindevent: function () {
  93. Form.api.bindevent($("form[role=form]"));
  94. },
  95. batchrelation: function (ids, action, table) {
  96. Layer.confirm(
  97. __('已选中条数:%s', ids.length),
  98. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  99. function (index) {
  100. var url = 'wxpayfufen/batch_relation';
  101. var options = {url: url, data: { wxpay_ids: ids.join(","), fufen_id: Config.data.fufenid, action: action}};
  102. Fast.api.ajax(options, function (data, ret) {
  103. Layer.msg('处理成功!');
  104. table.bootstrapTable('refresh');
  105. parent.layer.close(this);
  106. }, function (data, ret) {
  107. });
  108. Layer.close(index);
  109. }
  110. );
  111. }
  112. }
  113. };
  114. return Controller;
  115. });