csrkpi.js 3.3 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: 'kefu/csrkpi/index' + location.search,
  8. add_url: 'kefu/csrkpi/add',
  9. edit_url: 'kefu/csrkpi/edit',
  10. del_url: 'kefu/csrkpi/del',
  11. multi_url: 'kefu/csrkpi/multi',
  12. table: 'kefu_csr_config',
  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: 'admin.nickname', title: __('Admin_id')},
  26. {field: 'ceiling', title: __('Ceiling'), sortable: true},
  27. {field: 'reception_count', title: __('Reception_count'), sortable: true},
  28. {field: 'sum_message_count', title: __('sum_message_count')},
  29. {field: 'sum_reception_count', title: __('sum_reception_count')},
  30. {
  31. field: 'last_reception_time',
  32. title: __('Last_reception_time'),
  33. operate: 'RANGE',
  34. addclass: 'datetimerange',
  35. formatter: Table.api.formatter.datetime,
  36. sortable: true
  37. },
  38. {
  39. field: 'keep_alive',
  40. title: __('Keep Alive'),
  41. searchList: {"0": __('关'), "1": __('开')},
  42. formatter: Table.api.formatter.status
  43. },
  44. {
  45. field: 'status',
  46. title: __('Status'),
  47. searchList: {
  48. "0": __('Status 0'),
  49. "1": __('Status 1'),
  50. "2": __('Status 2'),
  51. "3": __('Status 3')
  52. },
  53. formatter: Table.api.formatter.status
  54. },
  55. {
  56. field: 'operate',
  57. title: __('Operate'),
  58. table: table,
  59. events: Table.api.events.operate,
  60. formatter: Table.api.formatter.operate
  61. }
  62. ]
  63. ]
  64. });
  65. // 为表格绑定事件
  66. Table.api.bindevent(table);
  67. },
  68. add: function () {
  69. Controller.api.bindevent();
  70. },
  71. edit: function () {
  72. Controller.api.bindevent();
  73. },
  74. api: {
  75. bindevent: function () {
  76. Form.api.bindevent($("form[role=form]"));
  77. }
  78. }
  79. };
  80. return Controller;
  81. });