equip.js 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["1000px","480px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'equip/index' + location.search,
  9. add_url: 'equip/add',
  10. edit_url: 'equip/edit',
  11. del_url: 'equip/del',
  12. multi_url: 'equip/multi',
  13. import_url: 'equip/import',
  14. table: 'equip',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'order_number', title: __('Id')},
  27. {field: 'unit_id1_text', title: __('Unit_id1')},
  28. {field: 'type', title: __('Type'), searchList: {"教材":__('教材'),"训练器材":__('训练器材')}, formatter: Table.api.formatter.normal},
  29. {field: 'title', title: __('Title'), operate: 'LIKE'},
  30. {field: 'unit_id_text', title: __('Unit_id')},
  31. {field: 'granttime', title: __('Granttime'), operate: 'LIKE'},
  32. {field: 'grantnum', title: __('Grantnum')},
  33. {field: 'ownnum', title: __('Ownnum')},
  34. {field: 'stocknum', title: __('Stocknum')},
  35. {field: 'intime', title: __('Intime'), operate: 'LIKE'},
  36. {field: 'innum', title: __('Innum')},
  37. {field: 'people_id_text', title: __('People_id')},
  38. {field: 'outtime', title: __('Outtime'), operate: 'LIKE'},
  39. {field: 'outnum', title: __('Outnum')},
  40. {field: 'people_id1_text', title: __('People_id1'), operate: 'LIKE'},
  41. {field: 'quality', title: __('Quality'), operate: 'LIKE'},
  42. //{field: 'info', title: __('Info'), operate: 'LIKE'},
  43. //{field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  44. {field: 'admin_id_text', title: __('Admin_id')},
  45. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  46. {
  47. name: '查看',
  48. text: '查看',
  49. title: '查看',
  50. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  51. icon: 'fa fa-search',
  52. extend: 'data-area=\'["1200px","80%"]\'',
  53. url: 'equip/details',
  54. refresh: true
  55. }
  56. ], formatter: Table.api.formatter.operate}
  57. ]
  58. ]
  59. });
  60. // 为表格绑定事件
  61. Table.api.bindevent(table);
  62. table.on('post-body.bs.table',function(){
  63. $(".btn-editone").data("area",["1000px","480px"]);
  64. })
  65. },
  66. add: function () {
  67. Controller.api.bindevent();
  68. $("#c-people_id,#c-people_id1").data("params", function (obj) {
  69. var unit_id = $('#J_unitselect').val();
  70. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  71. });
  72. },
  73. edit: function () {
  74. Controller.api.bindevent();
  75. $("#c-people_id,#c-people_id1").data("params", function (obj) {
  76. var unit_id = $('#J_unitselect').val();
  77. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  78. });
  79. },
  80. api: {
  81. bindevent: function () {
  82. Form.api.bindevent($("form[role=form]"));
  83. }
  84. }
  85. };
  86. return Controller;
  87. });