commit.js 3.0 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: 'dynamic/commit/index' + location.search,
  8. // add_url: 'dynamic/commit/add',
  9. edit_url: 'dynamic/commit/edit',
  10. del_url: 'dynamic/commit/del',
  11. // multi_url: 'dynamic/commit/multi',
  12. // import_url: 'dynamic/commit/import',
  13. table: 'dynamic_commit',
  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. {field: 'dynamic_id', title: __('Dynamic_id')},
  27. {field: 'user.u_id', title: __('User.u_id')},
  28. {field: 'user.nickname', title: __('User.nickname')},
  29. {
  30. field: 'content',
  31. title: __('Content'),
  32. operate: 'LIKE',
  33. formatter: function (value, row, index, field) {
  34. return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + row.content + "'>" + value + "</span>";
  35. },
  36. cellStyle: function (value, row, index, field) {
  37. return {
  38. css: {
  39. "white-space": "nowrap",
  40. "text-overflow": "ellipsis",
  41. "overflow": "hidden",
  42. "max-width": "250px"
  43. }
  44. };
  45. }
  46. },
  47. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  48. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  49. ]
  50. ]
  51. });
  52. // 为表格绑定事件
  53. Table.api.bindevent(table);
  54. },
  55. add: function () {
  56. Controller.api.bindevent();
  57. },
  58. edit: function () {
  59. Controller.api.bindevent();
  60. },
  61. api: {
  62. bindevent: function () {
  63. Form.api.bindevent($("form[role=form]"));
  64. }
  65. }
  66. };
  67. return Controller;
  68. });