supplier.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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: 'stock/supplier/index',
  8. add_url: 'stock/supplier/add',
  9. edit_url: 'stock/supplier/edit',
  10. del_url: 'stock/supplier/del',
  11. multi_url: 'stock/supplier/multi',
  12. table: 'stock_supplier',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {
  25. field: 'id',
  26. title: __('Id'),
  27. },
  28. {field: 'name', title: __('Name')},
  29. {field: 'shortname', title: __('Shortname')},
  30. {field: 'code', title: __('Code')},
  31. {field: 'shipaddress', title: __('Shipaddress')},
  32. {field: 'address', title: __('Address')},
  33. {field: 'contacts', title: __('Contacts')},
  34. {field: 'telphone', title: __('Telphone')},
  35. {field: 'remark', title: '备注'},
  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. },
  43. add: function () {
  44. Controller.api.bindevent();
  45. },
  46. edit: function () {
  47. Controller.api.bindevent();
  48. },
  49. api: {
  50. bindevent: function () {
  51. Form.api.bindevent($("form[role=form]"));
  52. }
  53. }
  54. };
  55. return Controller;
  56. });