people_recall.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["800px","400px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'people_recall/index' + location.search,
  9. add_url: 'people_recall/add',
  10. edit_url: 'people_recall/edit',
  11. del_url: 'people_recall/del',
  12. multi_url: 'people_recall/multi',
  13. import_url: 'people_recall/import',
  14. audit_url: 'people_recall/audit',
  15. table: 'people_recall',
  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_id', title: __('People_id')},
  29. {field: 'c_name', title: __('C_name'), operate: 'LIKE'},
  30. {field: 'duty', title: __('部职别')},
  31. {field: 'unit', title: __('单位')},
  32. {field: 'post', title: __('职务')},
  33. {field: 'grade', title: __('职务等级')},
  34. {field: 'job', title: __('工作岗位')},
  35. {field: 'skill', title: __('技术职务')},
  36. {field: 'level', title: __('技术等级')},
  37. {field: 'rank', title: __('军衔')},
  38. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  40. {
  41. name: 'audit',
  42. text: __('审核'),
  43. title: __('审核'),
  44. classname: 'btn btn-xs btn-primary btn-dialog',
  45. icon: 'fa fa-list',
  46. url: 'people_recall/audit',
  47. callback: function (data) {
  48. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  49. },
  50. visible: function (row) {
  51. //返回true时按钮显示,返回false隐藏
  52. return true;
  53. }
  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",["800px","500px"]);
  63. })
  64. },
  65. add: function () {
  66. Controller.api.bindevent();
  67. $("#c-people_id").data("eSelect", function(){
  68. Controller.api.events.getPeople();
  69. });
  70. },
  71. edit: function () {
  72. Controller.api.bindevent();
  73. Controller.api.events.getPeople();
  74. $("#c-people_id").data("eSelect", function(){
  75. Controller.api.events.getPeople();
  76. //后续操作
  77. });
  78. },
  79. audit: function () {
  80. Controller.api.bindevent();
  81. $('.J-audit').click(function(){
  82. $('#myModal').modal('show');
  83. $('#type').val($(this).data('type'));
  84. });
  85. $('#J_modal_submit').click(function(){
  86. var data = $('#modalForm').serializeArray();
  87. $.get('',data,function(res){
  88. if (res.code == 1){
  89. $('#myModal').modal('hide')
  90. Toastr.success(res.msg,function () {
  91. setTimeout(function(){
  92. window.location.reload();
  93. },1500);
  94. });
  95. }else{
  96. Toastr.error(res.msg);
  97. }
  98. });
  99. });
  100. },
  101. api: {
  102. bindevent: function () {
  103. Form.api.bindevent($("form[role=form]"));
  104. },
  105. events:{
  106. getPeople:function(){
  107. $.get('People/huoq',{id:$("#c-people_id").val()},function(res){
  108. for (var i in res.data){
  109. $('#d-'+i).val(res.data[i]);
  110. $('#d-'+i).selectPageRefresh();
  111. }
  112. });
  113. }
  114. }
  115. }
  116. };
  117. return Controller;
  118. });