task.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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: 'task/task/index' + location.search,
  8. add_url: 'task/task/add',
  9. edit_url: 'task/task/edit',
  10. del_url: 'task/task/del',
  11. multi_url: 'task/task/multi',
  12. import_url: 'task/task/import',
  13. table: 'task',
  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. {
  27. field: 'name',
  28. title: __('Name'),
  29. operate: 'LIKE',
  30. table: table,
  31. class: 'autocontent',
  32. formatter: Table.api.formatter.content
  33. },
  34. {
  35. field: 'createtime',
  36. title: __('Createtime'),
  37. operate: 'RANGE',
  38. addclass: 'datetimerange',
  39. autocomplete: false,
  40. formatter: Table.api.formatter.datetime
  41. },
  42. {
  43. field: 'updatetime',
  44. title: __('Updatetime'),
  45. operate: 'RANGE',
  46. addclass: 'datetimerange',
  47. autocomplete: false,
  48. formatter: Table.api.formatter.datetime
  49. },
  50. {
  51. field: 'status',
  52. title: __('Status'),
  53. searchList: {"30": __('Status 30')},
  54. formatter: Table.api.formatter.status
  55. },
  56. {
  57. field: 'operate',
  58. title: __('Operate'),
  59. table: table,
  60. events: Table.api.events.operate,
  61. formatter: Table.api.formatter.operate,
  62. buttons: [{
  63. name: 'detail',
  64. text: '详情',
  65. title: '详情',
  66. classname: 'btn btn-xs btn-primary btn-info',
  67. icon: 'fa fa-list',
  68. url: function (data) {
  69. return 'steps?task_id=' + data.id;
  70. },
  71. callback: function (data) {
  72. Layer.alert(data.title);
  73. }
  74. }, {
  75. name: 'edit',
  76. text: '编辑',
  77. title: '编辑',
  78. classname: 'btn btn-xs btn-success btn-editone',
  79. icon: 'fa fa-pencil',
  80. url: 'task/task/edit',
  81. callback: function (data) {
  82. Layer.alert(data.title);
  83. }
  84. }, {
  85. name: 'del',
  86. text: '删除',
  87. title: '删除',
  88. classname: 'btn btn-xs btn-danger btn-delone',
  89. icon: 'fa fa-trash',
  90. url: 'task/task/del',
  91. callback: function (data) {
  92. Layer.alert(data.title);
  93. }
  94. }]
  95. }
  96. ]
  97. ]
  98. });
  99. // 为表格绑定事件
  100. Table.api.bindevent(table);
  101. },
  102. add: function () {
  103. Controller.api.bindevent();
  104. },
  105. edit: function () {
  106. Controller.api.bindevent();
  107. },
  108. api: {
  109. bindevent: function () {
  110. Form.api.bindevent($("form[role=form]"));
  111. }
  112. }
  113. };
  114. return Controller;
  115. });