barracks.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area", ["800px", "540px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'barracks/index' + location.search,
  9. add_url: 'barracks/add',
  10. edit_url: 'barracks/edit',
  11. del_url: 'barracks/del',
  12. multi_url: 'barracks/multi',
  13. import_url: 'barracks/import',
  14. table: 'barracks',
  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: __('序号')},
  27. {field: 'number', title: __('Number'), operate: 'LIKE'},
  28. {field: 'number1', title: __('Number1'), operate: 'LIKE'},
  29. {field: 'name', title: __('Name'), operate: 'LIKE'},
  30. {field: 'behoof', title: __('Behoof'), operate: 'LIKE'},
  31. {field: 'status_quo', title: __('Status_quo'), operate: 'LIKE'},
  32. {field: 'period', title: __('Period'), operate: 'LIKE'},
  33. {field: 'area', title: __('Area'), operate: 'LIKE'},
  34. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  35. {field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. table.on('post-body.bs.table', function () {
  43. $(".btn-editone").data("area", ["800px", "540px"]);
  44. })
  45. },
  46. add: function () {
  47. Controller.api.bindevent();
  48. },
  49. edit: function () {
  50. Controller.api.bindevent();
  51. },
  52. api: {
  53. bindevent: function () {
  54. Form.api.bindevent($("form[role=form]"));
  55. }
  56. }
  57. };
  58. return Controller;
  59. });