jishuguifan.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: 'jishuguifan/index' + location.search,
  8. add_url: 'jishuguifan/add',
  9. edit_url: 'jishuguifan/edit',
  10. del_url: 'jishuguifan/del',
  11. multi_url: 'jishuguifan/multi',
  12. import_url: 'jishuguifan/import',
  13. table: 'jishuguifan',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'company_id', title: __('Company_id')},
  29. {field: 'company.companyname', title: __('Company.companyname'), operate: 'LIKE'},
  30. {field: 'pid', title: __('Pid')},
  31. {field: 'tid', title: __('Tid')},
  32. {field: 'ismenu', title: __('Ismenu'), searchList: {"1":__('Ismenu 1'),"0":__('Ismenu 0')}, formatter: Table.api.formatter.normal},
  33. {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  34. // {field: 'file', title: __('File'), operate: false, formatter: Table.api.formatter.file},
  35. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  38. ]
  39. ]
  40. });
  41. // 为表格绑定事件
  42. Table.api.bindevent(table);
  43. },
  44. add: function () {
  45. Controller.api.bindevent();
  46. },
  47. edit: function () {
  48. Controller.api.bindevent();
  49. },
  50. api: {
  51. bindevent: function () {
  52. Form.api.bindevent($("form[role=form]"));
  53. }
  54. }
  55. };
  56. return Controller;
  57. });