work_task.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["1000px","680px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'work_task/index' + location.search,
  9. add_url: 'work_task/add',
  10. edit_url: 'work_task/edit',
  11. del_url: 'work_task/del',
  12. entering_url:'work_task/entering',
  13. multi_url: 'work_task/multi',
  14. import_url: 'work_task/import',
  15. table: 'work_task',
  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. search:true,
  25. escape: false,
  26. columns: [
  27. [
  28. {checkbox: true},
  29. {field: 'order_number', title: __('Id')},
  30. {field: 'name', title: __('Name')},
  31. {field: 'number', title: __('Number')},
  32. {field: 'type', title: __('Type'), operate: '='},
  33. {field: 'people_id_text', title: '执行人'},
  34. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  36. {field: 'unit_name', title: '发布单位', operate: false},
  37. {field: 'contents', title: '描述', operate: false},
  38. {field: 'remark', title: '备注', operate: false},
  39. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  41. {
  42. name: '进度录入',
  43. text: '进度录入',
  44. title: '进度录入',
  45. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  46. icon: 'fa fa-calendar-check-o',
  47. url: 'work_progress/add',
  48. visible:function(row){
  49. return row.is_jindu;
  50. },
  51. refresh: true
  52. },
  53. {
  54. name: '查看',
  55. text: '查看',
  56. title: '查看',
  57. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  58. icon: 'fa fa-search',
  59. url: 'work_task/details',
  60. refresh: true
  61. }
  62. ], formatter: Table.api.formatter.operate}
  63. ]
  64. ]
  65. });
  66. //绑定事件
  67. // $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  68. // var panel = $(this).attr("href");
  69. // console.log(panel)
  70. // //移除绑定的事件
  71. // // $(this).unbind('shown.bs.tab');
  72. // });
  73. $('.J_list').click(function(){
  74. var container = $("#table").data("bootstrap.table").$container;
  75. var options = $("#table").bootstrapTable('getOptions');
  76. //这里我们手动将数据填充到表单然后提交
  77. $("form.form-commonsearch [name='type']", container).val($(this).data('type'));
  78. $("form.form-commonsearch [name='start_time']", container).val($(this).data('time'));
  79. $("form.form-commonsearch [name='end_time']", container).val($(this).data('time'));
  80. $("form.form-commonsearch", container).trigger('submit');
  81. });
  82. // 为表格绑定事件
  83. Table.api.bindevent(table);
  84. table.on('post-body.bs.table',function(){
  85. $(".btn-editone").data("area",["1000px","800px"]);
  86. })
  87. },
  88. add: function () {
  89. $("#c-people_id").data("params", function (obj) {
  90. var unit_id = $('#J_unitselect').val();
  91. return {"custom[unit_id][0]":"find_in_set","custom[unit_id][1]":unit_id};
  92. // return {custom: {unit_id: $("#J_unitselect").val()}};
  93. });
  94. $("#faupload-file").data("upload-success", function(data, ret){
  95. //这里进行后续操作
  96. $('#c-file_name').val(data.name);
  97. });
  98. Controller.api.bindevent();
  99. },
  100. edit: function () {
  101. $("#c-people_id").data("params", function (obj) {
  102. var unit_id = $('#J_unitselect').val();
  103. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  104. });
  105. $("#faupload-file").data("upload-success", function(data, ret){
  106. //这里进行后续操作
  107. $('#c-file_name').val(data.name);
  108. });
  109. Controller.api.bindevent();
  110. },
  111. api: {
  112. bindevent: function () {
  113. Form.api.bindevent($("form[role=form]"));
  114. }
  115. }
  116. };
  117. return Controller;
  118. });