admin.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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: 'auth/admin/index',
  8. add_url: 'auth/admin/add',
  9. edit_url: 'auth/admin/edit',
  10. multi_url: 'auth/admin/multi',
  11. }
  12. });
  13. var table = $("#table");
  14. //在表格内容渲染完成后回调的事件
  15. table.on('post-body.bs.table', function (e, json) {
  16. $("tbody tr[data-index]", this).each(function () {
  17. if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
  18. $("input[type=checkbox]", this).prop("disabled", true);
  19. }
  20. });
  21. });
  22. // 初始化表格
  23. table.bootstrapTable({
  24. url: $.fn.bootstrapTable.defaults.extend.index_url,
  25. columns: [
  26. [
  27. {field: 'state', checkbox: true,},
  28. {field: 'id', title: 'ID'},
  29. {field: 'username', title: __('Username')},
  30. {field: 'nickname', title: __('Nickname')},
  31. {
  32. field: 'status',
  33. title: __("Status"),
  34. searchList: {"normal": __('Normal'), "hidden": __('Hidden')},
  35. formatter: Table.api.formatter.status
  36. },
  37. {
  38. field: 'groups_text',
  39. title: __('Group'),
  40. operate: false,
  41. formatter: Table.api.formatter.label
  42. },
  43. {field: 'profit_amount', title: __('账户余额')},
  44. {field: 'mobile', title: __('Mobile')},
  45. {field: 'description', title: "描述"},
  46. {
  47. field: 'operate',
  48. title: __('Operate'),
  49. table: table,
  50. buttons: [
  51. {
  52. name: 'detail',
  53. text: '流水',
  54. title: '流水',
  55. icon: 'fa fa-list',
  56. classname: 'btn btn-xs btn-primary btn-dialog',
  57. visible: function (row) {
  58. return "1" == row["id"] || "agency" == row["type"];
  59. },
  60. url: 'profit/bill/details?identity_type={type}&target_id={id}&profit_rate={profit_rate}&profit_amount={profit_amount}'
  61. },
  62. // {
  63. // name: 'info',
  64. // text: '代理商资料',
  65. // title: '代理商资料',
  66. // icon: 'fa fa-list',
  67. // classname: 'btn btn-xs btn-primary btn-dialog',
  68. // visible: function (row) {
  69. // return "agency" == row["type"];
  70. // },
  71. // url: 'agency/info?admin_id={id}'
  72. // }
  73. ],
  74. events: Table.api.events.operate,
  75. formatter: function (value, row, index) {
  76. return Table.api.formatter.operate.call(this, value, row, index);
  77. }
  78. }
  79. ]
  80. ]
  81. });
  82. // 为表格绑定事件
  83. Table.api.bindevent(table);
  84. },
  85. add: function () {
  86. $("input[value='platform']").click(function () {
  87. $("#area_ids").css("display", "none");
  88. $("#profit_rate").css("display", "none");
  89. $("#store_id").css("display", "none");
  90. });
  91. $("input[value='agency']").click(function () {
  92. $("#area_ids").css("display", "block");
  93. $("#profit_rate").css("display", "block");
  94. $("#store_id").css("display", "none");
  95. });
  96. $("input[value='store']").click(function () {
  97. $("#area_ids").css("display", "none");
  98. $("#profit_rate").css("display", "none");
  99. $("#store_id").css("display", "block");
  100. });
  101. Form.api.bindevent($("form[role=form]"));
  102. },
  103. edit: function () {
  104. $("input[value='platform']").click(function () {
  105. $("#area_ids").css("display", "none");
  106. $("#profit_rate").css("display", "none");
  107. $("#store_id").css("display", "none");
  108. });
  109. $("input[value='agency']").click(function () {
  110. $("#area_ids").css("display", "block");
  111. $("#profit_rate").css("display", "block");
  112. $("#store_id").css("display", "none");
  113. });
  114. $("input[value='store']").click(function () {
  115. $("#area_ids").css("display", "none");
  116. $("#profit_rate").css("display", "none");
  117. $("#store_id").css("display", "block");
  118. });
  119. Form.api.bindevent($("form[role=form]"));
  120. }
  121. };
  122. return Controller;
  123. });