thebus_themplate.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area",["1000px","350px"]);
  6. Table.api.init({
  7. extend: {
  8. index_url: 'thebus_themplate/index' + location.search,
  9. add_url: 'thebus_themplate/add',
  10. edit_url: 'thebus_themplate/edit',
  11. del_url: 'thebus_themplate/del',
  12. multi_url: 'thebus_themplate/multi',
  13. import_url: 'thebus_themplate/import',
  14. table: 'thebus_themplate',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'order_number', title: __('Id')},
  27. {field: 'name', title: __('Name'), operate: 'LIKE'},
  28. {field: 'people1_id', title: __('People1_id'),visible:false},
  29. {field: 'people1_id_text', title: __('People1_id')},
  30. {field: 'people2_id', title: __('People2_id'),visible:false},
  31. {field: 'people2_id_text', title: __('People2_id')},
  32. {field: 'people3_id', title: __('People3_id'),visible:false},
  33. {field: 'people3_id_text', title: __('People3_id')},
  34. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ]
  38. });
  39. // 为表格绑定事件
  40. Table.api.bindevent(table);
  41. table.on('post-body.bs.table', function () {
  42. $(".btn-editone").data("area", ["660px", "360px"]);
  43. })
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. $(document).on("fa.event.appendfieldlist", "#add-form .btn-append", function (e, obj) {
  48. Form.events.selectpage(obj);
  49. Form.events.datetimepicker(obj);
  50. });
  51. },
  52. edit: function () {
  53. Controller.api.bindevent();
  54. $("#c-people1_id,#c-people2_id,#c-people3_id").data("params", function (obj) {
  55. var custom = {};
  56. custom['custom'] = {};
  57. custom['custom']['id'] = [];
  58. custom['custom']['id'][0] = 'not in';
  59. custom['custom']['id'][1] = '1';
  60. return custom;
  61. });
  62. },
  63. api: {
  64. bindevent: function () {
  65. Form.api.bindevent($("form[role=form]"));
  66. }
  67. }
  68. };
  69. return Controller;
  70. });