newrecords.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: 'newrecords/index' + location.search,
  8. add_url: 'newrecords/add',
  9. edit_url: 'newrecords/edit',
  10. del_url: 'newrecords/del',
  11. multi_url: 'newrecords/multi',
  12. import_url: 'newrecords/import',
  13. table: 'newrecords',
  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: 'username', title: '用户名', operate: 'LIKE'},
  29. {field: 'userId', title: '用户ID', operate: 'LIKE'},
  30. {field: 'rfid', title: '电子耳标号', operate: 'LIKE'},
  31. {field: 'category', title: "品类", operate: 'LIKE'},
  32. {field: 'gender', title:"性别", operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  33. {field: 'buildingName', title:'栋舍', operate: 'LIKE'},
  34. {field: 'roomName', title:'房间号', operate: 'LIKE'},
  35. {field: 'penNo', title:'栏位号', operate: 'LIKE'},
  36. // {field: 'birthDate', title:"出生日期", operate: 'LIKE'},
  37. {field: 'sys_rq', title: "创建日期", operate: 'LIKE'},
  38. // {field: 'dayage', title: "日龄", operate: 'LIKE'},
  39. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  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. });