task.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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: 'task/index' + location.search,
  8. add_url: 'task/add',
  9. edit_url: 'task/edit',
  10. del_url: 'task/del',
  11. multi_url: 'task/multi',
  12. import_url: 'task/import',
  13. table: 'task',
  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. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'name', title: __('Name'), operate: 'LIKE'},
  27. {field: 'bach', title: __('Bach'), operate: 'LIKE'},
  28. {field: 'drawer_name', title: __('Drawer_name'), operate: 'LIKE'},
  29. {field: 'examine_name', title: __('Examine_name'), operate: 'LIKE'},
  30. {field: 'machine', title: __('Machine'), operate: 'LIKE'},
  31. {field: 'number', title: __('Number'), operate: 'LIKE'},
  32. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  33. {field: 'fid', title: __('Fid')},
  34. {field: 'create', title: __('Create'), operate: 'LIKE'},
  35. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},
  36. {field: 'operate', title: '操作', buttons:[{
  37. name:'task',
  38. text:'查看',
  39. title:'查看',
  40. icon:'fa fa-add',
  41. extend: 'data-area=["100%","100%"]',
  42. classname:'btn btn-xs btn-info btn-fields btn-dialog task',
  43. url:'task/show',
  44. }],
  45. table: table,
  46. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  47. },
  48. ]
  49. ]
  50. });
  51. table.on('post-body.bs.table',function(){
  52. $(".btn-editone").data("area",["100%","100%"]);
  53. });
  54. $("#button").on("click",function(){
  55. var temp=table.bootstrapTable('getSelections');//获取复选框id中信息
  56. var ids = '';
  57. for (i=0;i<temp.length;i++){
  58. ids += temp[i].id+',';
  59. }
  60. if (ids == ''){return false;}
  61. Fast.config.openArea = ['100%','100%'];
  62. Fast.api.open("task/taskadd?ids="+ids, "生成领料单", {//将id传控制器
  63. });
  64. });
  65. // 为表格绑定事件
  66. Table.api.bindevent(table);
  67. },
  68. add: function () {
  69. Controller.api.bindevent();
  70. },
  71. edit: function () {
  72. Controller.api.bindevent();
  73. },
  74. taskadd: function () {
  75. Controller.api.bindevent();
  76. },
  77. api: {
  78. bindevent: function () {
  79. Form.api.bindevent($("form[role=form]"));
  80. }
  81. }
  82. };
  83. return Controller;
  84. });