task.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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: 'number', title: __('Number'), operate: 'LIKE'},
  31. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  32. {field: 'fid', title: __('Fid')},
  33. {field: 'create', title: __('Create'), operate: 'LIKE'},
  34. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  35. {field: 'operate', title: '操作', buttons:[{
  36. name:'task',
  37. text:'查看',
  38. title:'查看',
  39. icon:'fa fa-add',
  40. extend: 'data-area=["100%","100%"]',
  41. classname:'btn btn-xs btn-info btn-fields btn-dialog task',
  42. url:'task/show',
  43. }],
  44. table: table,
  45. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  46. },
  47. ]
  48. ]
  49. });
  50. $("#button").on("click",function(){
  51. var temp=table.bootstrapTable('getSelections');//获取复选框id中信息
  52. var ids = '';
  53. for (i=0;i<temp.length;i++){
  54. ids += temp[i].id+',';
  55. }
  56. if (ids == ''){return false;}
  57. Fast.config.openArea = ['100%','100%'];
  58. Fast.api.open("task/taskadd?ids="+ids, "生成领料单", {//将id传控制器
  59. });
  60. });
  61. // 为表格绑定事件
  62. Table.api.bindevent(table);
  63. },
  64. add: function () {
  65. Controller.api.bindevent();
  66. },
  67. edit: function () {
  68. Controller.api.bindevent();
  69. },
  70. taskadd: function () {
  71. Controller.api.bindevent();
  72. },
  73. api: {
  74. bindevent: function () {
  75. Form.api.bindevent($("form[role=form]"));
  76. }
  77. }
  78. };
  79. return Controller;
  80. });