risk_live_question.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'risk_live_question/index' + location.search,
  8. // add_url: 'risk_live_question/add',
  9. // edit_url: 'risk_live_question/edit',
  10. // del_url: 'risk_live_question/del',
  11. // multi_url: 'risk_live_question/multi',
  12. // import_url: 'risk_live_question/import',
  13. table: 'risk_live_question',
  14. }
  15. });
  16. var table = $("#table");
  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: 'order_number', title: __('Id')},
  26. //{field: 'risk_live_id', title: __('Risk_live_id')},
  27. {field: 'question', title: __('问题')},
  28. {field: 'plan', title: __('措施')},
  29. //{field: 'status', title: __('Status'), searchList: {"未完成":__('未完成'),"已完成":__('已完成')}, formatter: Table.api.formatter.status},
  30. // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  31. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  32. //{field: 'file', title: __('File'), formatter: Controller.api.formatter.thumb, operate: false},
  33. {field: 'picture', title: __('图片'), formatter: Controller.api.formatter.thumb, operate: false},
  34. {field: 'file_name', title: __('文件'), operate: 'LIKE',formatter: Controller.api.formatter.link},
  35. {field: 'time_limit', title: __('整改时限')},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  37. {
  38. name: '审批',
  39. text: '审批',
  40. title: '审批',
  41. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  42. icon: 'fa fa-search',
  43. url: 'risk_live_question/examine',
  44. extend: 'data-area=\'["450px","70%"]\'',
  45. visible: function (row) {
  46. if (row['state'] == 0) {
  47. return true;
  48. } else {
  49. return false;
  50. }
  51. },
  52. refresh: true
  53. },
  54. {
  55. name: '审批已通过',
  56. text: '审批已通过',
  57. title: '审批已通过',
  58. classname: 'btn btn-xs btn-info btn-view',
  59. icon: 'fa',
  60. //url: 'risk_live_question/examine',
  61. //extend: 'data-area=\'["1000px","80%"]\'',
  62. visible: function (row) {
  63. if (row['state'] == 1) {
  64. return true;
  65. } else {
  66. return false;
  67. }
  68. },
  69. refresh: true
  70. },
  71. {
  72. name: '审批不通过',
  73. text: '审批不通过',
  74. title: '审批不通过',
  75. classname: 'btn btn-xs btn-info btn-view',
  76. icon: 'fa',
  77. //url: 'risk_live_question/examine',
  78. //extend: 'data-area=\'["1000px","80%"]\'',
  79. visible: function (row) {
  80. if (row['state'] == 2) {
  81. return true;
  82. } else {
  83. return false;
  84. }
  85. },
  86. refresh: true
  87. },{
  88. name: '重新整改',
  89. text: '重新整改',
  90. title: '重新整改',
  91. classname: 'btn btn-xs btn-info btn-dialog',
  92. icon: 'fa',
  93. //url: 'risk_live_question/examine1',
  94. url:function(row){
  95. return 'risk_live_question/examine1?ids='+row['id'];
  96. },
  97. //extend: 'data-area=\'["1000px","80%"]\'',
  98. visible: function (row) {
  99. if (row['state'] == 2) {
  100. return true;
  101. } else {
  102. return false;
  103. }
  104. },
  105. refresh: true
  106. }
  107. ], formatter: Table.api.formatter.operate}
  108. ]
  109. ]
  110. });
  111. // 为表格绑定事件
  112. Table.api.bindevent(table);
  113. },
  114. add: function () {
  115. Controller.api.bindevent();
  116. },
  117. edit: function () {
  118. Controller.api.bindevent();
  119. },
  120. examine: function () {
  121. Controller.api.bindevent();
  122. },
  123. api: {
  124. bindevent: function () {
  125. Form.api.bindevent($("form[role=form]"));
  126. },
  127. formatter: {
  128. thumb: function (value, row, index) {
  129. return '<a href="' + value + '" class="btn-dialog"><img src="' + value + '" alt="" style="max-height:90px;max-width:120px"></a>';
  130. },
  131. url: function (value, row, index) {
  132. return '<a href="' + row.fullurl + '" target="_blank" class="label bg-green">' + row.url + '</a>';
  133. },
  134. link: function (value, row, index) {
  135. return '<a href="' + row.file + '" target="_blank" class="label bg-green">' + row.file_name + '</a>';
  136. },
  137. filename: function (value, row, index) {
  138. return '<div style="width:180px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
  139. },
  140. }
  141. }
  142. };
  143. return Controller;
  144. });