supplier.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.columnDefaults.align = 'left';
  6. Table.api.init({
  7. extend: {
  8. index_url: 'equipment/supplier/index' + location.search,
  9. add_url: 'equipment/supplier/add',
  10. edit_url: 'equipment/supplier/edit',
  11. del_url: 'equipment/supplier/del',
  12. multi_url: 'equipment/supplier/multi',
  13. import_url: 'equipment/supplier/import',
  14. table: 'equipment_supplier',
  15. }
  16. });
  17. var table = $("#table");
  18. var relationshipList = [];
  19. $.ajax({
  20. url : "equipment/supplier/getRelationshipList",
  21. async : false,
  22. success : function (obj) {
  23. relationshipList = obj.data;
  24. }
  25. });
  26. // 初始化表格
  27. table.bootstrapTable({
  28. url: $.fn.bootstrapTable.defaults.extend.index_url,
  29. pk: 'id',
  30. sortName: 'id',
  31. columns: [
  32. [
  33. {checkbox: true, align: 'center'},
  34. {field: 'id', title: __('Id'), align: 'center', operate: false},
  35. {field: 'supplier_code', title: __('Supplier_code'), operate: 'LIKE'},
  36. {field: 'relationship', title: __('Relationship'), formatter: function(value){return relationshipList[value]}, searchList: relationshipList},
  37. {field: 'name', title: __('Name'), operate: 'LIKE'},
  38. {field: 'bank', title: __('Invoice'), formatter: function(value, row){return value + ',' + row.bank_account}, operate: false},
  39. {field: 'contact', title: __('Contact'), formatter: function(value, row){return value + ',' + row.contact_mobile}, operate: false},
  40. {field: 'remark', title: __('Remark'), operate: false},
  41. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  42. ]
  43. ],
  44. search: false
  45. });
  46. // 为表格绑定事件
  47. Table.api.bindevent(table);
  48. },
  49. recyclebin: function () {
  50. // 初始化表格参数配置
  51. Table.columnDefaults.align = 'left';
  52. Table.api.init({
  53. extend: {
  54. 'dragsort_url': ''
  55. }
  56. });
  57. var table = $("#table");
  58. // 初始化表格
  59. table.bootstrapTable({
  60. url: 'equipment/supplier/recyclebin' + location.search,
  61. pk: 'id',
  62. sortName: 'id',
  63. columns: [
  64. [
  65. {checkbox: true, align: 'center'},
  66. {field: 'id', title: __('Id'), align: 'center'},
  67. {field: 'supplier_code', title: __('Supplier_code')},
  68. {field: 'name', title: __('Name')},
  69. {
  70. field: 'deletetime',
  71. title: __('Deletetime'),
  72. operate: 'RANGE',
  73. addclass: 'datetimerange',
  74. formatter: Table.api.formatter.datetime
  75. },
  76. {
  77. field: 'operate',
  78. width: '130px',
  79. title: __('Operate'),
  80. table: table,
  81. events: Table.api.events.operate,
  82. buttons: [
  83. {
  84. name: 'Restore',
  85. text: __('Restore'),
  86. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  87. icon: 'fa fa-rotate-left',
  88. url: 'equipment/supplier/restore',
  89. refresh: true
  90. }
  91. ],
  92. formatter: Table.api.formatter.operate
  93. }
  94. ]
  95. ],
  96. search: false,
  97. showToggle: false,
  98. showColumns: false,
  99. showExport: false,
  100. commonSearch: false
  101. });
  102. // 为表格绑定事件
  103. Table.api.bindevent(table);
  104. },
  105. add: function () {
  106. Controller.api.bindevent();
  107. },
  108. edit: function () {
  109. Controller.api.bindevent();
  110. },
  111. api: {
  112. bindevent: function () {
  113. Form.api.bindevent($("form[role=form]"));
  114. }
  115. }
  116. };
  117. return Controller;
  118. });