unit.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["540px","450px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'unit/index' + location.search,
  9. add_url: 'unit/add',
  10. edit_url: 'unit/edit',
  11. del_url: 'unit/del',
  12. multi_url: 'unit/multi',
  13. import_url: 'unit/import',
  14. table: 'unit',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'weigh',
  23. search:false,
  24. commonSearch:false,
  25. cardView:false,
  26. pagination:false,
  27. columns: [
  28. [
  29. {checkbox: true},
  30. {field: 'order_number', title: '序号'},
  31. {field: 'number', title: __('Number'), operate: 'LIKE'},
  32. {field: 'pnumber', title: __('Pnumber'), operate: 'LIKE'},
  33. {field: 'name', title: __('Name'), operate: 'LIKE',align:'left',formatter:function (value, row, index) {
  34. return value.toString().replace(/(&|&)nbsp;/g, ' ');
  35. }},
  36. {field: 'weigh', title: __('Weigh'), operate: false,visible:false},
  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. table.on('post-body.bs.table',function(){
  44. $(".btn-editone").data("area",["540px","450px"]);
  45. })
  46. },
  47. add: function () {
  48. Controller.api.bindevent();
  49. },
  50. edit: function () {
  51. Controller.api.bindevent();
  52. },
  53. api: {
  54. bindevent: function () {
  55. Form.api.bindevent($("form[role=form]"));
  56. },
  57. formatter: {
  58. title: function (value, row, index) {
  59. value = value.toString().replace(/(&|&)nbsp;/g, ' ');
  60. return !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
  61. }
  62. }
  63. }
  64. };
  65. return Controller;
  66. });