crontab.js 2.9 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: 'general/crontab/index',
  8. add_url: 'general/crontab/add',
  9. edit_url: 'general/crontab/edit',
  10. del_url: 'general/crontab/del',
  11. multi_url: 'general/crontab/multi',
  12. table: 'crontab'
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. sortName: 'weigh',
  20. columns: [
  21. [
  22. {field: 'state', checkbox: true, },
  23. {field: 'id', title: 'ID'},
  24. {field: 'type', title: __('Type')},
  25. {field: 'title', title: __('Title')},
  26. {field: 'maximums', title: __('Maximums')},
  27. {field: 'executes', title: __('Executes')},
  28. {field: 'begintime', title: __('Begin time'), formatter: Table.api.formatter.datetime},
  29. {field: 'endtime', title: __('End time'), formatter: Table.api.formatter.datetime},
  30. {field: 'executetime', title: __('Execute time'), formatter: Table.api.formatter.datetime},
  31. {field: 'weigh', title: __('Weigh')},
  32. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
  33. {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  34. ]
  35. ]
  36. });
  37. // 为表格绑定事件
  38. Table.api.bindevent(table);
  39. },
  40. add: function () {
  41. Controller.api.bindevent();
  42. },
  43. edit: function () {
  44. Controller.api.bindevent();
  45. },
  46. api: {
  47. bindevent: function () {
  48. Form.api.bindevent($("form[role=form]"));
  49. //拖拽排序
  50. require(['crontab'], function () {
  51. $('#schedulepicker').jqCron({
  52. lang: 'cn',
  53. default_value: '* * * * 0-2',
  54. multiple_dom: true,
  55. multiple_month: true,
  56. multiple_mins: true,
  57. multiple_dow: true,
  58. multiple_time_hours: true,
  59. multiple_time_minutes: true,
  60. no_reset_button: false,
  61. bind_to: $("#schedule")
  62. });
  63. });
  64. }
  65. }
  66. };
  67. return Controller;
  68. });