risk_examine.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["710px","360px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'risk_examine/index' + location.search,
  9. add_url: 'risk_examine/add',
  10. del_url: 'risk_examine/del',
  11. import_url: 'risk_examine/import',
  12. table: 'risk_examine',
  13. }
  14. });
  15. var table = $("#table");
  16. var status = Config.status==1?true:false;
  17. function stringToEntity(str,radix){
  18. let arr=str.split('')
  19. radix=radix||0
  20. let tmp=arr.map(item=>
  21. `&#${(radix?'x'+item.charCodeAt(0).toString(16):item.charCodeAt(0))};`).join('')
  22. console.log(`'${str}' 转实体为 '${tmp}'`)
  23. return tmp
  24. }
  25. function entityToString(entity){
  26. let entities=entity.split(';')
  27. entities.pop()
  28. let tmp=entities.map(item=>String.fromCharCode(
  29. item[2]==='x'?parseInt(item.slice(3),16):parseInt(item.slice(2)))).join('')
  30. console.log(`'${entity}' 转字符串为 '${tmp}'`)
  31. return tmp
  32. }
  33. // 初始化表格
  34. table.bootstrapTable({
  35. url: $.fn.bootstrapTable.defaults.extend.index_url,
  36. pk: 'id',
  37. sortName: 'id',
  38. onLoadSuccess:function(data){
  39. },
  40. columns: [
  41. [
  42. {checkbox: true},
  43. {field: 'qstate', title: __('状态'),formatter:function(val,row){
  44. if(val == 1){
  45. return '<span class="fa fa-circle text-success"></span>'
  46. }else if(val == 2){
  47. return '<span class="fa fa-circle text-danger"></span>'
  48. }else if(val == 0){
  49. if(row.plan){
  50. return '<span class="fa fa-circle text-info"></span>'
  51. }else{
  52. return '<span class="fa fa-circle text-warning"></span>'
  53. }
  54. }
  55. },visible:status
  56. },
  57. {field: 'order_number', title: __('序号')},
  58. // {field: 'st', title: __('状态'),operate:false,formatter:function(index,row){
  59. // if(val == 1){
  60. // return '<span class="text-success"></span>'
  61. // }else if(val == 2){
  62. // return '<span class="text-danger"></span>'
  63. // }else if(val == 0){
  64. // if(row.plan){
  65. // return '<span class="text-info"></span>'
  66. // }else{
  67. // return '<span class="text-warning"></span>'
  68. // }
  69. // }
  70. // }},
  71. // {field: 'name', title: __('Name'), operate: 'LIKE'},
  72. // {field: 'inspection_team_name', title: __('Inspection_team'), operate: 'LIKE'},
  73. {field: 'unit_id_text', title: __('Unit_id')},
  74. {field: 'people_id_text', title: __('People_id'),visible:status},
  75. {field: 'examine_time', title: __('Examine_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  76. //{field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  77. //{field: 'plus', title: __('加分')},
  78. {field: 'minus', title: __('分值'),formatter:function(value,row){
  79. if(row.mode =='inc'){
  80. return '<span class="text-success">'+value+'</span>';
  81. }else{
  82. return '<span class="text-danger">'+value+'</span>'
  83. }
  84. }},
  85. {field: 'question', title: __('事由')},
  86. {field: 'qstate', title: __('状态'),formatter:function(val,row){
  87. if(val == 1){
  88. return '<span class="fa text-success">已通过</span>'
  89. }else if(val == 2){
  90. return '<span class="fa text-danger">未通过</span>'
  91. }else if(val == 0){
  92. if(row.plan){
  93. return '<span class="fa text-info">待验收</span>'
  94. }else{
  95. return '<span class="fa text-warning">待处理</span>'
  96. }
  97. }
  98. },visible:status
  99. },
  100. {field: 'time_frame', title: __('整改时限'),visible:status},
  101. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  102. {
  103. name: '问题整改',
  104. text: '问题整改',
  105. title: '问题整改',
  106. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  107. icon: 'fa fa-search',
  108. url: 'risk_examine/mend',
  109. //extend: 'data-area=\'["1000px","80%"]\'',
  110. visible: function (row) {
  111. if (row['state'] == 0 && row.mode == 'dec') {
  112. return true;
  113. } else {
  114. return false;
  115. }
  116. },
  117. refresh: true
  118. },
  119. {
  120. name: '审批',
  121. text: '审批',
  122. title: '审批',
  123. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  124. icon: 'fa fa-search',
  125. //url: 'risk_examine_question/examine',
  126. url:function(row){
  127. return 'risk_examine_question/index?ids='+row['id'];
  128. },
  129. //extend: 'data-area=\'["1000px","80%"]\'',
  130. visible: function (row) {
  131. if (row['state'] == 1) {
  132. return true;
  133. } else {
  134. return false;
  135. }
  136. },
  137. refresh: true
  138. }
  139. ], formatter: Table.api.formatter.operate}
  140. ]
  141. ]
  142. });
  143. $(document).on("mouseover mouseout",'.J_stips',function(){
  144. if(event.type == "mouseover"){
  145. //鼠标悬浮
  146. $(this).find('.stips').show();
  147. }else if(event.type == "mouseout"){
  148. //鼠标离开
  149. $(this).find('.stips').hide();
  150. }
  151. });
  152. // 为表格绑定事件
  153. Table.api.bindevent(table);
  154. table.on('post-body.bs.table',function(){
  155. $(".btn-editone").data("area",["750px","480px"]);
  156. })
  157. },
  158. add: function () {
  159. Controller.api.bindevent();
  160. $(document).on("fa.event.appendfieldlist", "#add-form .btn-append", function (e, obj) {
  161. Form.events.plupload(obj);
  162. Form.events.selectpage(obj);
  163. Form.events.selectpicker(obj);
  164. $("#faupload-readme_file").data("upload-success", function(data, ret){
  165. //这里进行后续操作
  166. $('#c-file_name').val(data.name);
  167. });
  168. });
  169. $("#c-minus").on('change',function(){
  170. var max = 0;
  171. if($(this).val()<max){
  172. Toastr.error("分值不能为负数");
  173. $(this).val(max);
  174. }
  175. });
  176. },
  177. addplus: function () {
  178. Controller.api.bindevent();
  179. $(document).on("fa.event.appendfieldlist", "#add-form .btn-append", function (e, obj) {
  180. Form.events.plupload(obj);
  181. Form.events.selectpage(obj);
  182. Form.events.selectpicker(obj);
  183. $("#faupload-readme_file").data("upload-success", function(data, ret){
  184. //这里进行后续操作
  185. $('#c-file_name').val(data.name);
  186. });
  187. });
  188. $("#c-minus").on('change',function(){
  189. var max = 0;
  190. if($(this).val()<max){
  191. Toastr.error("分值不能为负数");
  192. $(this).val(max);
  193. }
  194. });
  195. },
  196. // edit: function () {
  197. // Controller.api.bindevent();
  198. // $(document).on("fa.event.appendfieldlist", "#edit-form .btn-append", function (e, obj) {
  199. // Form.events.plupload(obj);
  200. // Form.events.selectpage(obj);
  201. // Form.events.selectpicker(obj);
  202. // $("#faupload-readme_file").data("upload-success", function(data, ret){
  203. // //这里进行后续操作
  204. // $('#c-file_name').val(data.name);
  205. // });
  206. // });
  207. // },
  208. mend: function () {
  209. Controller.api.bindevent();
  210. $(document).on("fa.event.appendfieldlist", "#mend-form .btn-append", function (e, obj) {
  211. Form.events.plupload(obj);
  212. Form.events.selectpage(obj);
  213. Form.events.selectpicker(obj);
  214. $(".wjfile").data("upload-success", function(data, ret){
  215. console.log(data.name)
  216. //这里进行后续操作
  217. $('#c-file_name'+$(this).data('id')).val(data.name);
  218. $('#c-file_name'+$(this).data('id')).trigger("change");
  219. // $('#c-file_name'+$(this).data('id'))
  220. });
  221. });
  222. },
  223. examine: function () {
  224. Controller.api.bindevent();
  225. $(document).on("fa.event.appendfieldlist", "#examine-form .btn-append", function (e, obj) {
  226. Form.events.plupload(obj);
  227. Form.events.selectpage(obj);
  228. Form.events.selectpicker(obj);
  229. $(".wjfile").data("upload-success", function(data, ret){
  230. console.log(data.name)
  231. //这里进行后续操作
  232. $('#c-file_name'+$(this).data('id')).val(data.name);
  233. // $('#c-file_name'+$(this).data('id'))
  234. });
  235. });
  236. },
  237. api: {
  238. bindevent: function () {
  239. Form.api.bindevent($("form[role=form]"));
  240. }
  241. }
  242. };
  243. return Controller;
  244. });