risk_live.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["820px","480px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'risk_live/index' + location.search,
  9. add_url: 'risk_live/add',
  10. del_url: 'risk_live/del',
  11. import_url: 'risk_live/import',
  12. table: 'risk_live',
  13. }
  14. });
  15. var table = $("#table");
  16. var status = Config.status==1?true:false;
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'qstate', title: __('状态'),formatter:function(val,row){
  26. if(val == 1){
  27. return '<span class="fa fa-circle text-success"></span>'
  28. }else if(val == 2){
  29. return '<span class="fa fa-circle text-danger"></span>'
  30. }else if(val == 0){
  31. if(row.plan){
  32. return '<span class="fa fa-circle text-info"></span>'
  33. }else{
  34. return '<span class="fa fa-circle text-warning"></span>'
  35. }
  36. }
  37. },visible:status
  38. },
  39. {field: 'order_number', title: __('序号')},
  40. {field: 'people_id_text', title: __('负责人'), operate: 'LIKE',visible:false},
  41. {field: 'unit_id1_text', title: __('Unit_id1')},
  42. {field: 'type_text', title: __('Type'), operate: 'LIKE'},
  43. {field: 'examine_time', title: __('Examine_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  44. {field: 'address', title: __('Address'), operate: 'LIKE'},
  45. {field: 'unit_id_text', title: __('Unit_id')},
  46. {field: 'minus', title: __('分值'),formatter:function(value,row){
  47. if(row.mode =='inc'){
  48. return '<span class="text-success">'+value+'</span>';
  49. }else{
  50. return '<span class="text-danger">'+value+'</span>'
  51. }
  52. }},
  53. {field: 'question', title: __('事由')},
  54. {field: 'qstate', title: __('状态'),formatter:function(val,row){
  55. if(val == 1){
  56. return '<span class="fa text-success">已通过</span>'
  57. }else if(val == 2){
  58. return '<span class="fa text-danger">未通过</span>'
  59. }else if(val == 0){
  60. if(row.plan){
  61. return '<span class="fa text-info">待验收</span>'
  62. }else{
  63. return '<span class="fa text-warning">待处理</span>'
  64. }
  65. }
  66. },visible:status
  67. },
  68. {field: 'time_limit', title: __('整改时限'),visible:status},
  69. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  70. {
  71. name: '问题整改',
  72. text: '问题整改',
  73. title: '问题整改',
  74. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  75. icon: 'fa fa-search',
  76. url: 'risk_live/mend',
  77. extend: 'data-area=\'["810px","76%"]\'',
  78. visible: function (row) {
  79. if (row['state'] == 0 && row.mode == 'dec') {
  80. return true;
  81. } else {
  82. return false;
  83. }
  84. },
  85. refresh: true
  86. },
  87. {
  88. name: '查看及审批',
  89. text: '查看及审批',
  90. title: '查看及审批',
  91. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  92. icon: 'fa fa-search',
  93. url:function(row){
  94. return 'risk_live_question/index?ids='+row['id'];
  95. },
  96. visible: function (row) {
  97. if (row['state'] == 1) {
  98. return true;
  99. } else {
  100. return false;
  101. }
  102. },
  103. refresh: true
  104. }
  105. ], formatter: Table.api.formatter.operate}
  106. ]
  107. ]
  108. });
  109. $(document).on("mouseover mouseout",'.J_stips',function(){
  110. if(event.type == "mouseover"){
  111. //鼠标悬浮
  112. $(this).find('.stips').show();
  113. }else if(event.type == "mouseout"){
  114. //鼠标离开
  115. $(this).find('.stips').hide();
  116. }
  117. });
  118. // 为表格绑定事件
  119. Table.api.bindevent(table);
  120. table.on('post-body.bs.table',function(){
  121. $(".btn-editone").data("area",["820px","480px"]);
  122. })
  123. },
  124. add: function () {
  125. Controller.api.bindevent();
  126. $("#c-minus").on('change',function(){
  127. var max = 0;
  128. if($(this).val()<max){
  129. Toastr.error("分值不能为负数");
  130. $(this).val(max);
  131. }
  132. });
  133. },
  134. // edit: function () {
  135. // Controller.api.bindevent();
  136. // },
  137. addplus: function () {
  138. Controller.api.bindevent();
  139. $("#c-minus").on('change',function(){
  140. var max = 0;
  141. if($(this).val()<max){
  142. Toastr.error("分值不能为负数");
  143. $(this).val(max);
  144. }
  145. });
  146. $(document).on("fa.event.appendfieldlist", "#add-form .btn-append", function (e, obj) {
  147. Form.events.plupload(obj);
  148. Form.events.selectpage(obj);
  149. Form.events.selectpicker(obj);
  150. $("#faupload-readme_file").data("upload-success", function(data, ret){
  151. //这里进行后续操作
  152. $('#c-file_name').val(data.name);
  153. });
  154. });
  155. },
  156. mend: function () {
  157. Controller.api.bindevent();
  158. $(document).on("fa.event.appendfieldlist", "#edit-form .btn-append", function (e, obj) {
  159. Form.events.plupload(obj);
  160. Form.events.selectpage(obj);
  161. Form.events.selectpicker(obj);
  162. $(".wjfile").data("upload-success", function(data, ret){
  163. console.log(data.name)
  164. //这里进行后续操作
  165. $('#c-file_name'+$(this).data('id')).val(data.name);
  166. $('#c-file_name'+$(this).data('id')).trigger("change");
  167. // $('#c-file_name'+$(this).data('id'))
  168. });
  169. });
  170. },
  171. examine:function(){
  172. },
  173. api: {
  174. bindevent: function () {
  175. Form.api.bindevent($("form[role=form]"));
  176. }
  177. }
  178. };
  179. return Controller;
  180. });