practice.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $('.btn-add').data('area',['85%','85%']);
  5. $('.btn-edit').data('area',['85%','85%']);
  6. // 初始化表格参数配置
  7. Table.api.init({
  8. extend: {
  9. index_url: 'teacher/practice/index' + location.search,
  10. add_url: 'teacher/practice/add',
  11. edit_url: 'teacher/practice/edit',
  12. del_url: 'teacher/practice/del',
  13. multi_url: 'teacher/practice/multi',
  14. import_url: 'teacher/practice/import',
  15. table: 'teacher_collection',
  16. }
  17. });
  18. var table = $("#table");
  19. // 初始化表格
  20. table.bootstrapTable({
  21. url: $.fn.bootstrapTable.defaults.extend.index_url,
  22. pk: 'exam_collection_id',
  23. sortName: 'exam_collection_id',
  24. fixedColumns: true,
  25. fixedRightNumber: 1,
  26. searchFormVisible:true,
  27. columns: [
  28. [
  29. {checkbox: true},
  30. {field: 'exam_collection_id', title: __('编号')},
  31. {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
  32. {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
  33. {field: 'exam_collection_type', title: __('Exam_collection_type'),operate: false,formatter: function (value, row, index) {
  34. return '练习';
  35. }
  36. },
  37. {
  38. field: 'exam_collection_state',searchList:{"2":"打开","3":"关闭"},
  39. title: __('Exam_collection_state'),
  40. align: 'center',
  41. table: table,
  42. formatter: Table.api.formatter.collectonstate
  43. },
  44. {field: 'exam_collection_name', title: __('Exam_collection_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  45. // {field: 'task_id', title: __('Task_id')},
  46. {field: 'limit_duration', title: __('Limit_duration')},
  47. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  48. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  49. // {field: 'create_user_id', title: __('Create_user_id')},
  50. {field: 'create_by', title: __('Create_by'), operate: 'LIKE'},
  51. {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter: Table.api.formatter.datetime},
  52. // {field: 'update_by', title: __('Update_by'), operate: 'LIKE'},
  53. // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  54. // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  55. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
  56. // formatter: Table.api.formatter.operate
  57. formatter: Table.api.formatter.buttons,
  58. buttons: [
  59. {
  60. name: 'dispatch',
  61. text: '',
  62. icon: 'fa fa-pencil',
  63. title: '编辑',
  64. classname: 'btn btn-success btn-xs btn-magic btn-dialog',
  65. extend: 'data-area=\'["85%","85%"]\'',
  66. url: 'teacher/practice/edit',
  67. },{
  68. name: 'dispatch',
  69. text: '',
  70. icon: 'fa fa-trash',
  71. title: '删除',
  72. classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
  73. url: 'teacher/practice/del',
  74. confirm: '确定要删除吗?',
  75. success: function (data, ret) {
  76. $(".btn-refresh").trigger("click");
  77. },
  78. error: function (data, ret) {
  79. Layer.alert(ret.msg);
  80. return false;
  81. }
  82. }
  83. ],
  84. }
  85. ]
  86. ]
  87. });
  88. // 为表格绑定事件
  89. Table.api.bindevent(table);
  90. },
  91. persent: function () {
  92. Table.api.init({
  93. extend: {
  94. index_url: 'teacher/practice/persent' + location.search,
  95. indexed_url: 'teacher/practice/index' + location.search,
  96. table: 'teacher_exams',
  97. }
  98. });
  99. var table = $("#table");
  100. // 初始化表格
  101. table.bootstrapTable({
  102. url: $.fn.bootstrapTable.defaults.extend.index_url,
  103. pk: 'exam_id',
  104. sortName: 'exam_id',
  105. toolbar: '#toolbar',
  106. fixedColumns: true,
  107. fixedRightNumber: 1,
  108. searchFormVisible:false,
  109. columns: [
  110. [
  111. // {checkbox: true},
  112. {field: '', title: __('更换件')},
  113. {field: '', title: __('学员姓名')},
  114. {field: '', title: __('状态')},
  115. {field: 'endtime', title: __('申请时间'), formatter: Table.api.formatter.datetime, operate: false, addclass: 'datetimerange', sortable: true},
  116. {field: 'operate', title: __('Operate'), table: table,
  117. events: Table.api.events.operate,
  118. // formatter: Table.api.formatter.operate
  119. formatter: Table.api.formatter.buttons,
  120. buttons: [
  121. // {
  122. // name: 'dispatch',
  123. // text: '',
  124. // icon: 'fa fa-pencil',
  125. // title: '编辑',
  126. // classname: 'btn btn-success btn-xs btn-magic btn-dialog',
  127. // extend: 'data-area=\'["55%","95%"]\'',
  128. // url: 'teacher/exams/edit',
  129. // }
  130. ],
  131. }
  132. ]
  133. ]
  134. });
  135. // 为表格绑定事件
  136. Table.api.bindevent(table);
  137. var table1 = $("#table1");
  138. // 初始化表格
  139. table1.bootstrapTable({
  140. url: $.fn.bootstrapTable.defaults.extend.indexed_url,
  141. pk: 'exam_collection_id',
  142. sortName: 'exam_collection_id',
  143. toolbar: '#toolbar1',
  144. fixedColumns: true,
  145. fixedRightNumber: 1,
  146. searchFormVisible:false,
  147. columns: [
  148. [
  149. // {checkbox: true},
  150. {field: '', title: __('座号')},
  151. {field: '', title: __('模拟器状态')},
  152. {field: '', title: __('学员学号')},
  153. {field: '', title: __('学员姓名')},
  154. {field: '', title: __('考试状态')},
  155. {field: '', title: __('考试成绩')},
  156. {field: '', title: __('故障现象')},
  157. {field: '', title: __('故障部位')},
  158. {field: '', title: __('排除方法')},
  159. {field: 'operate', title: __('Operate'), table: table1,
  160. events: Table.api.events.operate,
  161. // formatter: Table.api.formatter.operate
  162. formatter: Table.api.formatter.buttons,
  163. buttons: [
  164. // {
  165. // name: 'dispatch',
  166. // text: '',
  167. // icon: 'fa fa-pencil',
  168. // title: '编辑',
  169. // classname: 'btn btn-success btn-xs btn-magic btn-dialog',
  170. // extend: 'data-area=\'["55%","95%"]\'',
  171. // url: 'teacher/exams/edit',
  172. // }
  173. ],
  174. }
  175. ]
  176. ]
  177. });
  178. // 为表格绑定事件
  179. Table.api.bindevent(table1);
  180. },
  181. add: function () {
  182. Controller.api.bindevent();
  183. },
  184. edit: function () {
  185. Controller.api.bindevent();
  186. },
  187. api: {
  188. bindevent: function () {
  189. Table.api.init({
  190. extend: {
  191. index_url: 'department/admin/departadmintotal' + location.search,
  192. }
  193. });
  194. var table = $("#table1");
  195. // 初始化表格
  196. table.bootstrapTable({
  197. url: $.fn.bootstrapTable.defaults.extend.index_url,
  198. pk: 'id',
  199. sortName: 'id',
  200. fixedColumns: true,
  201. fixedRightNumber: 1,
  202. searchFormVisible:false,
  203. Search:false,
  204. columns: [
  205. [
  206. {checkbox: true},
  207. {field: 'department_name', title: __('区队名称'), operate: false,width: '400px', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  208. {field: 'department_admin_count', title: __('全部人员数量'),operate: false},
  209. ]
  210. ]
  211. });
  212. // 为表格绑定事件
  213. Table.api.bindevent(table);
  214. $("input[name='btSelectAll']").click(function () {
  215. var ids = Table.api.selectedids(table);
  216. console.log(ids);
  217. $(".depart_ids").val(ids);
  218. });
  219. Form.api.bindevent($("form[role=form]"));
  220. }
  221. }
  222. };
  223. return Controller;
  224. });