trainactive.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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: 'trainactive/index' + location.search,
  8. add_url: 'trainactive/add',
  9. edit_url: 'trainactive/edit',
  10. del_url: 'trainactive/del',
  11. multi_url: 'trainactive/multi',
  12. import_url: 'trainactive/import',
  13. table: 'train_active',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  29. {field: 'logo_image', title: __('Logo_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  30. {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  31. {field: 'number', title: __('Number'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  32. {field: 'version', title: __('Version'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  33. {field: 'bianzhiren', title: __('Bianzhiren'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  34. {field: 'pizhunren', title: __('Pizhunren'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  35. {field: 'shenheren', title: __('Shenheren'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. {field: 'kongzhiren', title: __('Kongzhiren'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  37. {field: 'department', title: __('Department'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  38. {field: 'wenjianstatus', title: __('Wenjianstatus'), operate: 'LIKE', formatter: Table.api.formatter.status},
  39. {field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  40. // {field: 'cate_id', title: __('Cate_id')},
  41. {field: 'cate.name', title: __('Cate.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  42. // {field: 'level_id', title: __('Level_id')},
  43. {field: 'level.name', title: __('Level.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  44. {field: 'fangshi', title: __('Fangshi'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  45. {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  46. {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  47. {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  48. {field: 'zhuchiren', title: __('Zhuchiren'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  49. {field: 'zhujiangren', title: __('Zhujiangren'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  50. // {field: 'type_id', title: __('Type_id')},
  51. {field: 'type.name', title: __('Type.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  52. {field: 'info', title: __('Info'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  53. {field: 'files', title: __('Files'), operate: false, formatter: Table.api.formatter.files},
  54. {field: 'pingjia_image', title: __('Pingjia_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  55. {field: 'pingjia_time', title: __('Pingjia_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  56. {field: 'pingjia_uid', title: __('Pingjia_uid')},
  57. {field: 'sign_endtime', title: __('Sign_endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  58. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  59. {field: 'usercount', title: __('Usercount')},
  60. {field: 'userauth_status', title: __('Userauth_status'), searchList: {"0":__('Userauth_status 0'),"1":__('Userauth_status 1')}, formatter: Table.api.formatter.status},
  61. {field: 'operate', title: __('Operate'), table: table,
  62. buttons:[
  63. {
  64. name:'qrcode',
  65. text:'二维码',
  66. title:'二维码',
  67. icon:'fa fa-exclamation-circle',
  68. classname:'btn btn-xs btn-info btn-dialog',
  69. url:'trainactive/qrcode/id/{ids}?dialog=1',
  70. target:'_self',
  71. },
  72. {
  73. name:'showinfo',
  74. text:'打印',
  75. title:'打印',
  76. icon:'fa fa-exclamation-circle',
  77. classname:'btn btn-xs btn-info btn-addtabs',
  78. url:'trainactive/showinfo/id/{ids}',
  79. target:'_blank',
  80. },
  81. {
  82. name:'nograde',
  83. text:'未到',
  84. title:'未到',
  85. icon:'fa fa-exclamation-circle',
  86. classname:'btn btn-xs btn-info btn-dialog btn-nograde',
  87. url:'trainactive/nograde/id/{ids}',
  88. target:'_self',
  89. }
  90. ],
  91. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  92. ]
  93. ]
  94. });
  95. // 为表格绑定事件
  96. Table.api.bindevent(table);
  97. },
  98. recyclebin: function () {
  99. // 初始化表格参数配置
  100. Table.api.init({
  101. extend: {
  102. 'dragsort_url': ''
  103. }
  104. });
  105. var table = $("#table");
  106. // 初始化表格
  107. table.bootstrapTable({
  108. url: 'trainactive/recyclebin' + location.search,
  109. pk: 'id',
  110. sortName: 'id',
  111. columns: [
  112. [
  113. {checkbox: true},
  114. {field: 'id', title: __('Id')},
  115. {field: 'title', title: __('Title'), align: 'left'},
  116. {
  117. field: 'deletetime',
  118. title: __('Deletetime'),
  119. operate: 'RANGE',
  120. addclass: 'datetimerange',
  121. formatter: Table.api.formatter.datetime
  122. },
  123. {
  124. field: 'operate',
  125. width: '140px',
  126. title: __('Operate'),
  127. table: table,
  128. events: Table.api.events.operate,
  129. buttons: [
  130. {
  131. name: 'Restore',
  132. text: __('Restore'),
  133. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  134. icon: 'fa fa-rotate-left',
  135. url: 'trainactive/restore',
  136. refresh: true
  137. },
  138. {
  139. name: 'Destroy',
  140. text: __('Destroy'),
  141. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  142. icon: 'fa fa-times',
  143. url: 'trainactive/destroy',
  144. refresh: true
  145. }
  146. ],
  147. formatter: Table.api.formatter.operate
  148. }
  149. ]
  150. ]
  151. });
  152. // 为表格绑定事件
  153. Table.api.bindevent(table);
  154. },
  155. add: function () {
  156. Controller.api.bindevent();
  157. },
  158. qrcode: function () {
  159. Controller.api.bindevent();
  160. },
  161. edit: function () {
  162. Controller.api.bindevent();
  163. },
  164. showinfo: function () {
  165. Controller.api.bindevent();
  166. },
  167. api: {
  168. bindevent: function () {
  169. Form.api.bindevent($("form[role=form]"));
  170. }
  171. }
  172. };
  173. return Controller;
  174. });
  175. //打印切换
  176. $('#left').click(function(){
  177. $('#left_table').show();
  178. $('#right_table').hide();
  179. })
  180. $('#right').click(function(){
  181. $('#left_table').hide();
  182. $('#right_table').show();
  183. })
  184. //打印下载
  185. function jump(url){
  186. console.log(url);
  187. window.location.href = url;
  188. }
  189. //打印ctrl+P
  190. function printPage() {
  191. window.print();
  192. }