ink_book.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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: 'ink_book/index' + location.search,
  8. add_url: 'ink_book/read',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'id',
  16. sortName: 'id',
  17. columns: [
  18. [
  19. {field: 'id', title: 'ID'},
  20. {field: 'order_number', title: '工单编号'},
  21. {field: 'product_name', title: '产品名称'},
  22. {field: 'number', title: '工单数量(万张)'},
  23. {field: 'big_number', title:'已打大盒数量(万张)'},
  24. {field: 'small_number', title:'已打小盒数量(万张)'},
  25. {field: 'update', title:'更新时间'},
  26. {field: 'operate', title: __('Operate'), table: table,
  27. buttons:[{
  28. name:'add',
  29. text:'详情',
  30. title:'详情',
  31. icon:'fa fa-add',
  32. classname:'btn btn-xs btn-info btn-fields ',
  33. url:'ink_book/read/id/{id}',
  34. callback:function(data){
  35. }
  36. }],
  37. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  38. }
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. read: function () {
  46. // 初始化表格参数配置
  47. Table.api.init({
  48. extend: {
  49. index_url: 'ink_book/read' + location.search,
  50. add_url: 'ink_book/detail',
  51. }
  52. });
  53. var table = $("#table");
  54. // 初始化表格
  55. table.bootstrapTable({
  56. url: $.fn.bootstrapTable.defaults.extend.index_url,
  57. pk: 'id',
  58. sortName: 'id',
  59. columns: [
  60. [
  61. // {checkbox: true},
  62. {field: 'id', title: 'ID'},
  63. {field: 'create', title: '生成日期'},
  64. {field: 'formula', title: '配方名称'},
  65. {field: 'big_number', title:'大盒数量(万张)'},
  66. {field: 'small_number', title:'小盒数量(万张)'},
  67. {field: 'operate', title: __('Operate'), table: table,
  68. buttons:[{
  69. name:'add',text:'查看',title:'查看',icon:'fa fa-add',classname:'btn btn-xs btn-info btn-fields btn-dialog',url:'ink_book/detail'
  70. }],
  71. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  72. }
  73. ]
  74. ]
  75. });
  76. // 为表格绑定事件
  77. Table.api.bindevent(table);
  78. },
  79. add: function(){
  80. Controller.api.bindevent();
  81. },
  82. edit: function () {
  83. Controller.api.bindevent();
  84. },
  85. api: {
  86. bindevent: function () {
  87. Form.api.bindevent($("form[role=form]"));
  88. }
  89. }
  90. };
  91. return Controller;
  92. });