crontab.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. Form.api.bindevent($("form[role=form]"));
  42. Controller.api.bindevent();
  43. },
  44. edit: function () {
  45. Form.api.bindevent($("form[role=form]"));
  46. Controller.api.bindevent();
  47. },
  48. api: {
  49. bindevent: function () {
  50. $(document).on("click", "#fieldlist .append", function () {
  51. });
  52. //拖拽排序
  53. require(['crontab'], function () {
  54. $('#schedulepicker').jqCron({
  55. lang: 'cn',
  56. default_value: '* * * * 0-2',
  57. multiple_dom: true,
  58. multiple_month: true,
  59. multiple_mins: true,
  60. multiple_dow: true,
  61. multiple_time_hours: true,
  62. multiple_time_minutes: true,
  63. no_reset_button: false,
  64. bind_to: $("#schedule")
  65. });
  66. });
  67. }
  68. }
  69. };
  70. return Controller;
  71. });