flats.js 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area", ["800px", "500px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'flats/index' + location.search,
  9. add_url: 'flats/add',
  10. edit_url: 'flats/edit',
  11. del_url: 'flats/del',
  12. multi_url: 'flats/multi',
  13. import_url: 'flats/import',
  14. table: 'flats',
  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: __('序号')},
  27. {field: 'unit_id_text', title: __('Unit_id')},
  28. {field: 'people_id_text', title: __('People_id')},
  29. {field: 'duty', title: __('Duty'), operate: 'LIKE'},
  30. {field: 'whether', title: __('Whether'), searchList: {"否":__('否'),"是":__('是')}, formatter: Table.api.formatter.normal},
  31. {field: 'grade', title: __('Grade'), operate: 'LIKE'},
  32. {field: 'house_type', title: __('House_type'), operate: 'LIKE'},
  33. {field: 'birth_date', title: __('Birth_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  34. {field: 'enlist_date', title: __('Enlist_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. {field: 'job_time', title: __('Job_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  36. {field: 'entrance_date', title: __('Entrance_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  37. {field: 'job_date', title: __('Job_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  38. {field: 'jobs_date', title: __('Jobs_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  39. {field: 'whethers', title: __('Whethers'), searchList: {"否":__('否'),"是":__('是')}, formatter: Table.api.formatter.normal},
  40. {field: 'rank_id_text', title: __('Rank_id')},
  41. {field: 'rank_date', title: __('Rank_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  42. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  43. {field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  45. ]
  46. ]
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. },
  51. add: function () {
  52. Controller.api.bindevent();
  53. $("#c-people_id").data("params", function (obj) {
  54. var unit_id = $('#J_unitselect').val();
  55. return {
  56. "custom[unit_id][0]": "in",
  57. "custom[unit_id][1]": unit_id
  58. };
  59. });
  60. $("#c-people_id").data("eSelect", function(){
  61. $.get('People/huoq',{id:$("#c-people_id").val()},function(res){
  62. $('#c-rank_id').val(res.data.rank_id);
  63. $('#c-rank_id').selectPageRefresh();
  64. $('#c-duty').val(res.data.duty);
  65. $('#c-rank_date').val(res.data.rank_date);
  66. $('#c-enlist_date').val(res.data.enlist_date);
  67. $('#c-birth_date').val(res.data.birth_date);
  68. $('#c-job_time').val(res.data.job_time);
  69. });
  70. //后续操作
  71. });
  72. },
  73. edit: function () {
  74. Controller.api.bindevent();
  75. $("#c-people_id").data("params", function (obj) {
  76. var unit_id = $('#J_unitselect').val();
  77. return {
  78. "custom[unit_id][0]": "in",
  79. "custom[unit_id][1]": unit_id
  80. };
  81. });
  82. },
  83. api: {
  84. bindevent: function () {
  85. Form.api.bindevent($("form[role=form]"));
  86. }
  87. }
  88. };
  89. return Controller;
  90. });