moneylog.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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: 'moneylog/index' + location.search,
  8. add_url: 'moneylog/add',
  9. edit_url: 'moneylog/edit',
  10. del_url: 'moneylog/del',
  11. multi_url: 'moneylog/multi',
  12. import_url: 'moneylog/import',
  13. table: 'user_money_log',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'user_id', title: __('User_id')},
  27. {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  28. {field: 'user.nickname', title: __('昵称'), operate: 'LIKE'},
  29. {field: 'other_user_id', title: __('相关方用户ID')},
  30. {field: 'otheruser.username', title: __('相关方用户名'), operate: 'LIKE'},
  31. {field: 'otheruser.nickname', title: __('相关方昵称'), operate: 'LIKE'},
  32. {field: 'log_type', title: __('Log_type'),operate:'IN'},
  33. {field: 'log_type_text', title: __('Log_type'),operate:false},
  34. // {field: 'money_type', title: __('Money_type'), operate: 'LIKE'},
  35. {field: 'change_value', title: __('Change_value'), operate:'BETWEEN'},
  36. {field: 'remain', title: __('Remain'), operate:'BETWEEN'},
  37. // {field: 'table', title: __('Table'), operate: 'LIKE'},
  38. // {field: 'table_id', title: __('Table_id')},
  39. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  40. {field: 'call_minutes', title: __('通话时长'), operate: false},
  41. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  43. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  44. ]
  45. ]
  46. });
  47. //这里我们手动设置底部的值
  48. table.on('load-success.bs.table', function (e, data) {
  49. $("#sum_money").text(data.extend.sum_money);
  50. });
  51. // 为表格绑定事件
  52. Table.api.bindevent(table);
  53. },
  54. add: function () {
  55. Controller.api.bindevent();
  56. },
  57. edit: function () {
  58. Controller.api.bindevent();
  59. },
  60. api: {
  61. bindevent: function () {
  62. Form.api.bindevent($("form[role=form]"));
  63. }
  64. }
  65. };
  66. return Controller;
  67. });