help.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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: 'help/help/index' + location.search,
  8. add_url: 'help/help/add',
  9. edit_url: 'help/help/edit',
  10. del_url: 'help/help/del',
  11. multi_url: 'help/help/multi',
  12. import_url: 'help/help/import',
  13. table: 'help',
  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: 'cid', title: __('Cid')},
  27. {field: 'category_id', title: __('Category_id')},
  28. {field: 'user_id', title: __('User_id')},
  29. {field: 'full_name', title: __('Full_name'), operate: 'LIKE'},
  30. {field: 'contact', title: __('Contact'), operate: 'LIKE'},
  31. {field: 'id_card', title: __('Id_card'), operate: 'LIKE'},
  32. {field: 'title', title: __('Title'), operate: 'LIKE'},
  33. {field: 'userimage', title: __('Userimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. {field: 'userimages', title: __('Userimages'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  35. {field: 'isrec', title: __('Isrec'), searchList: {"0":__('Isrec 0'),"1":__('Isrec 1')}, formatter: Table.api.formatter.normal},
  36. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  37. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  38. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4')}, formatter: Table.api.formatter.status},
  41. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  42. ]
  43. ]
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. },
  48. recyclebin: function () {
  49. // 初始化表格参数配置
  50. Table.api.init({
  51. extend: {
  52. 'dragsort_url': ''
  53. }
  54. });
  55. var table = $("#table");
  56. // 初始化表格
  57. table.bootstrapTable({
  58. url: 'help/help/recyclebin' + location.search,
  59. pk: 'id',
  60. sortName: 'id',
  61. columns: [
  62. [
  63. {checkbox: true},
  64. {field: 'id', title: __('Id')},
  65. {field: 'title', title: __('Title'), align: 'left'},
  66. {
  67. field: 'deletetime',
  68. title: __('Deletetime'),
  69. operate: 'RANGE',
  70. addclass: 'datetimerange',
  71. formatter: Table.api.formatter.datetime
  72. },
  73. {
  74. field: 'operate',
  75. width: '130px',
  76. title: __('Operate'),
  77. table: table,
  78. events: Table.api.events.operate,
  79. buttons: [
  80. {
  81. name: 'Restore',
  82. text: __('Restore'),
  83. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  84. icon: 'fa fa-rotate-left',
  85. url: 'help/help/restore',
  86. refresh: true
  87. },
  88. {
  89. name: 'Destroy',
  90. text: __('Destroy'),
  91. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  92. icon: 'fa fa-times',
  93. url: 'help/help/destroy',
  94. refresh: true
  95. }
  96. ],
  97. formatter: Table.api.formatter.operate
  98. }
  99. ]
  100. ]
  101. });
  102. // 为表格绑定事件
  103. Table.api.bindevent(table);
  104. },
  105. add: function () {
  106. $("#c-user_id").data("params", function (obj) {
  107. return {custom: {cid: $("#c-cid").val()}};
  108. });
  109. Controller.api.bindevent();
  110. },
  111. edit: function () {
  112. $("#c-user_id").data("params", function (obj) {
  113. return {custom: {cid: $("#c-cid").val()}};
  114. });
  115. Controller.api.bindevent();
  116. },
  117. api: {
  118. bindevent: function () {
  119. Form.api.bindevent($("form[role=form]"));
  120. }
  121. }
  122. };
  123. return Controller;
  124. });