people_leave.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["700px","450px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'people_leave/index' + location.search,
  9. add_url: 'people_leave/add',
  10. edit_url: 'people_leave/edit',
  11. del_url: 'people_leave/del',
  12. auth_url: 'people_leave/auth',
  13. multi_url: 'people_leave/multi',
  14. import_url: 'people_leave/import',
  15. table: 'people_leave',
  16. }
  17. });
  18. var table = $("#table");
  19. // 初始化表格
  20. table.bootstrapTable({
  21. url: $.fn.bootstrapTable.defaults.extend.index_url,
  22. pk: 'id',
  23. sortName: 'id',
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'order_number', title: __('Id')},
  28. {field: 'people_name', title: __('People_name'), operate: 'LIKE'},
  29. //{field: 'people_id', title: __('People_id')},
  30. {field: 'leave_id_text', title: __('Leave_id'), formatter: Table.api.formatter.normal},
  31. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  32. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  33. {field: 'duration', title: __('Duration'), operate: 'LIKE'},
  34. {field: 'reason', title: __('Reason'), operate: 'LIKE'},
  35. //{field: 'people_id1', title: __('People_id1')},
  36. {field: 'people_name1', title: __('People_name1'), operate: 'LIKE'},
  37. {field: 'file_name', title: __('File'), operate: false,formatter: Controller.api.formatter.link},
  38. {field: 'address', title: __('Address'), operate: 'LIKE'},
  39. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  42. {
  43. name: '审批通过',
  44. text: '审批通过',
  45. title: '审批通过',
  46. confirm: '确定审核通过吗?',
  47. classname: 'btn btn-xs btn-info btn-view btn-ajax',
  48. icon: 'fa fa-check',
  49. url: 'people_leave/auth',
  50. visible: function (row) {
  51. if (row['auth'] === 0) {
  52. return true;
  53. } else {
  54. return false;
  55. }
  56. },
  57. refresh: true
  58. },
  59. {
  60. name: '审批已通过',
  61. text: '审批已通过',
  62. title: '审批已通过',
  63. classname: 'btn btn-xs btn-warning',
  64. icon: 'fa fa-check',
  65. visible: function (row) {
  66. if (row['auth'] == 1) {
  67. return true;
  68. } else {
  69. return false;
  70. }
  71. },
  72. refresh: true
  73. }
  74. ], formatter: Table.api.formatter.operate}
  75. ]
  76. ]
  77. });
  78. // 为表格绑定事件
  79. Table.api.bindevent(table);
  80. table.on('post-body.bs.table',function(){
  81. $(".btn-editone").data("area",["700px","450px"]);
  82. })
  83. },
  84. add: function () {
  85. Controller.api.bindevent();
  86. $("#c-leave_id").data("eSelect", function(){
  87. $.get('people_leave/huoq',{leave_id:$("#c-leave_id_text").val()},function(res){
  88. if(res.data.name == '休假'){
  89. $('#c-address').parent().parent().hide();
  90. }else{
  91. $('#c-address').parent().parent().show();
  92. }
  93. console.log(res);
  94. });
  95. //后续操作
  96. });
  97. $("#faupload-file").data("upload-success", function(data, ret){
  98. //这里进行后续操作
  99. $('#c-file_name').val(data.name);
  100. });
  101. },
  102. edit: function () {
  103. Controller.api.bindevent();
  104. $("#faupload-file").data("upload-success", function(data, ret){
  105. //这里进行后续操作
  106. $('#c-file_name').val(data.name);
  107. });
  108. },
  109. auth: function () {
  110. Controller.api.bindevent();
  111. },
  112. api: {
  113. bindevent: function () {
  114. Form.api.bindevent($("form[role=form]"));
  115. },
  116. formatter: {
  117. thumb: function (value, row, index) {
  118. return '<a href="' + value + '" target="_blank"><img src="' + value + '" alt="" style="max-height:90px;max-width:120px"></a>';
  119. },
  120. url: function (value, row, index) {
  121. return '<a href="' + row.fullurl + '" target="_blank" class="label bg-green">' + row.url + '</a>';
  122. },
  123. link: function (value, row, index) {
  124. return '<a href="' + row.file + '" target="_blank" class="label bg-green">' + row.file_name + '</a>';
  125. },
  126. filename: function (value, row, index) {
  127. return '<div style="width:180px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
  128. },
  129. }
  130. }
  131. };
  132. return Controller;
  133. });