scorelog.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/scorelog/index',
  8. add_url: 'user/scorelog/add',
  9. edit_url: 'user/scorelog/edit',
  10. del_url: 'user/scorelog/del',
  11. multi_url: 'user/scorelog/multi',
  12. table: 'user_score_log',
  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: 'user_id', title: __('User_id'), formatter: Table.api.formatter.search},
  26. {field: 'score', title: __('Score'), formatter: Table.api.formatter.search},
  27. {field: 'before', title: __('Before'), formatter: Table.api.formatter.search},
  28. {field: 'after', title: __('After'), formatter: Table.api.formatter.search},
  29. {field: 'memo', title: __('Memo'), formatter: Table.api.formatter.search},
  30. {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  31. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  32. ]
  33. ]
  34. });
  35. // 为表格绑定事件
  36. Table.api.bindevent(table);
  37. },
  38. add: function () {
  39. $(document).on("change", "select[name=template]", function () {
  40. $("#c-score").val($(this).val());
  41. $("#c-memo").val($("option:selected", this).data("memo"));
  42. });
  43. Controller.api.bindevent();
  44. },
  45. edit: function () {
  46. Controller.api.bindevent();
  47. },
  48. api: {
  49. bindevent: function () {
  50. Form.api.bindevent($("form[role=form]"));
  51. }
  52. }
  53. };
  54. return Controller;
  55. });