duty_test.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area", ["768px", "410px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'duty_test/index' + location.search,
  9. add_url: 'duty_test/add',
  10. edit_url: 'duty_test/edit',
  11. del_url: 'duty_test/del',
  12. multi_url: 'duty_test/multi',
  13. import_url: 'duty_test/import',
  14. table: 'duty_test',
  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: 'phone', title: __('Phone'), operate: 'LIKE'},
  30. {field: 'people_ids_text', title: __('People_ids'), operate: 'LIKE'},
  31. {field: 'site', title: __('Site'), operate: 'LIKE'},
  32. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  33. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  34. {field: 'admin_id_text', title: __('Admin_id')},
  35. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. table.on('post-body.bs.table', function () {
  43. $(".btn-editone").data("area", ["768px", "410px"]);
  44. })
  45. },
  46. add: function () {
  47. Controller.api.bindevent();
  48. $("#c-people_id,#c-people_ids").data("params", function (obj) {
  49. var unit_id = $('#J_unitselect').val();
  50. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  51. });
  52. $("#c-people_id").data("eSelect", function(){
  53. $.get('duty_test/huoq',{id:$("#c-people_id").val()},function(res){
  54. $('#c-phone').val(res.data.phone);
  55. });
  56. });
  57. },
  58. edit: function () {
  59. Controller.api.bindevent();
  60. $("#c-people_id,#c-people_ids").data("params", function (obj) {
  61. var unit_id = $('#J_unitselect').val();
  62. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  63. });
  64. $("#c-people_id").data("eSelect", function(){
  65. $.get('duty_test/huoq',{id:$("#c-people_id").val()},function(res){
  66. $('#c-phone').val(res.data.phone);
  67. });
  68. });
  69. },
  70. api: {
  71. bindevent: function () {
  72. Form.api.bindevent($("form[role=form]"));
  73. }
  74. }
  75. };
  76. return Controller;
  77. });