armament.js 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["1000px","370px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'armament/index' + location.search,
  9. add_url: 'armament/add',
  10. edit_url: 'armament/edit',
  11. del_url: 'armament/del',
  12. multi_url: 'armament/multi',
  13. import_url: 'armament/import',
  14. table: 'armament',
  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_id_text', title: __('Unit_id')},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'record_date', title: __('Record_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  30. {field: 'metering', title: __('Metering'), operate: 'LIKE'},
  31. {field: 'gist', title: __('Gist'), operate: 'LIKE'},
  32. {field: 'prepare_number', title: __('Prepare_number')},
  33. {field: 'sum', title: __('Sum')},
  34. {field: 'intact_number', title: __('Intact_number')},
  35. {field: 'repair_number', title: __('Repair_number')},
  36. {field: 'send_number', title: __('Send_number')},
  37. {field: 'standard', title: __('Standard'), operate: 'LIKE'},
  38. {field: 'existing', title: __('Existing'), operate: 'LIKE'},
  39. {field: 'flaw', title: __('Flaw'), operate: 'LIKE'},
  40. {field: 'people_id_text', title: __('People_id')},
  41. {field: 'people_id1_text', title: __('People_id1')},
  42. {field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  43. //{field: 'updatetime', title: __('Updatetime'), operate: 'LIKE'},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  45. {
  46. name: '查看',
  47. text: '查看',
  48. title: '查看',
  49. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  50. icon: 'fa fa-search',
  51. url: 'armament/details',
  52. extend: 'data-area=\'["1200px","80%"]\'',
  53. refresh: true
  54. }
  55. ], formatter: Table.api.formatter.operate}
  56. ]
  57. ]
  58. });
  59. // 为表格绑定事件
  60. Table.api.bindevent(table);
  61. table.on('post-body.bs.table',function(){
  62. $(".btn-editone").data("area",["1000px","370px"]);
  63. })
  64. },
  65. add: function () {
  66. Controller.api.bindevent();
  67. $("#c-people_id,#c-people_id1").data("params", function (obj) {
  68. var unit_id = $('#J_unitselect').val();
  69. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  70. });
  71. },
  72. edit: function () {
  73. Controller.api.bindevent();
  74. $("#c-people_id,#c-people_id1").data("params", function (obj) {
  75. var unit_id = $('#J_unitselect').val();
  76. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  77. });
  78. },
  79. api: {
  80. bindevent: function () {
  81. Form.api.bindevent($("form[role=form]"));
  82. }
  83. }
  84. };
  85. return Controller;
  86. });