practice.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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: 'exam_collection_name', title: __('Exam_collection_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  32. {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
  33. {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
  34. {field: 'exam_collection_type', title: __('Exam_collection_type'),operate: false,formatter: function (value, row, index) {
  35. return '练习';
  36. }
  37. },
  38. {
  39. field: 'exam_collection_state',searchList:{"2":"打开","3":"关闭"},
  40. title: __('Exam_collection_state'),
  41. align: 'center',
  42. table: table,
  43. formatter: Table.api.formatter.collectonstate
  44. },
  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. // {
  69. // name: 'dispatch',
  70. // text: '',
  71. // icon: 'fa fa-trash',
  72. // title: '删除',
  73. // classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
  74. // url: 'teacher/practice/del',
  75. // confirm: '确定要删除吗?',
  76. // success: function (data, ret) {
  77. // $(".btn-refresh").trigger("click");
  78. // },
  79. // error: function (data, ret) {
  80. // Layer.alert(ret.msg);
  81. // return false;
  82. // }
  83. // }
  84. ],
  85. }
  86. ]
  87. ]
  88. });
  89. // 为表格绑定事件
  90. Table.api.bindevent(table);
  91. },
  92. persent: function () {
  93. Table.api.init({
  94. extend: {
  95. index_url: 'teacher/practice/persent' + location.search,
  96. indexed_url: 'teacher/practice/examing' + location.search,
  97. table: 'teacher_exams',
  98. }
  99. });
  100. var table = $("#table");
  101. // 初始化表格
  102. table.bootstrapTable({
  103. url: $.fn.bootstrapTable.defaults.extend.index_url,
  104. pk: 'exam_id',
  105. sortName: 'exam_id',
  106. toolbar: '#toolbar',
  107. fixedColumns: true,
  108. fixedRightNumber: 1,
  109. searchFormVisible:false,
  110. showExport:false,
  111. search:false,
  112. columns: [
  113. [
  114. // {checkbox: true},
  115. {field: 'fault_name', title: __('更换件')},
  116. {field: 'create_by', title: __('学员姓名')},
  117. {field: 'request_status', title: __('状态'),
  118. formatter: function(value, row,index) {
  119. if(value==1){
  120. return '<span class="text-warning">待处理</span>';
  121. }else if(value==2){
  122. return '<span class="text-success">已送</span>';
  123. }else if(value==3){
  124. return '<span class="text-danger">已驳回</span>';
  125. }
  126. }
  127. },
  128. {field: 'createtime', title: __('申请时间'), formatter: Table.api.formatter.datetime, operate: false, addclass: 'datetimerange', sortable: true},
  129. {field: 'operate', title: __('Operate'), table: table,
  130. events: Table.api.events.operate,
  131. // formatter: Table.api.formatter.operate
  132. formatter: Table.api.formatter.buttons,
  133. buttons: [
  134. {
  135. name: 'dispatch',
  136. text: '',
  137. icon: 'fa fa-check',
  138. title: '已送',
  139. classname: 'btn btn-success btn-xs btn-magic btn-ajax',
  140. url: 'teacher/exams/handle/type/1',
  141. visible: function (rr) {
  142. if(rr.request_status == 1 || rr.request_status == 0){
  143. return true;
  144. }
  145. return false;
  146. },
  147. success: function (data, ret) {
  148. table.bootstrapTable("refresh");
  149. },
  150. },{
  151. name: 'dispatch',
  152. text: '',
  153. icon: 'fa fa-reply-all',
  154. title: '驳回',
  155. classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
  156. url: 'teacher/exams/handle/type/2',
  157. visible: function (rr) {
  158. if(rr.request_status == 1 || rr.request_status == 0){
  159. return true;
  160. }
  161. return false;
  162. },
  163. success: function (data, ret) {
  164. table.bootstrapTable("refresh");
  165. },
  166. }
  167. ],
  168. }
  169. ]
  170. ]
  171. });
  172. // 为表格绑定事件
  173. Table.api.bindevent(table);
  174. var table1 = $("#table1");
  175. // 初始化表格
  176. table1.bootstrapTable({
  177. url: $.fn.bootstrapTable.defaults.extend.indexed_url,
  178. pk: 'exam_collection_id',
  179. sortName: 'exam_collection_id',
  180. toolbar: '#toolbar1',
  181. fixedColumns: true,
  182. fixedRightNumber: 1,
  183. searchFormVisible:false,
  184. columns: [
  185. [
  186. // {checkbox: true},
  187. {field: 'seat_id', title: __('座号')},
  188. {field: '', title: __('模拟器状态'),
  189. formatter: function(value, row,index) {
  190. return '<span class="text-success">就绪</span>';
  191. }
  192. },
  193. {field: 'user_username', title: __('学员学号')},
  194. {field: 'user_nickname', title: __('学员姓名')},
  195. {field: '', title: __('状态'),
  196. formatter: function(value, row,index) {
  197. return '<span class="text-success">已交卷</span>';
  198. }
  199. },
  200. {field: 'total_score', title: __('模拟成绩')},
  201. ]
  202. ]
  203. });
  204. // 为表格绑定事件
  205. Table.api.bindevent(table1);
  206. },
  207. add: function () {
  208. Controller.api.bindevent();
  209. },
  210. edit: function () {
  211. Controller.api.bindevent();
  212. },
  213. api: {
  214. bindevent: function () {
  215. var rel_Ids = [];
  216. Table.api.init({
  217. extend: {
  218. index_url: 'department/admin/departadmintotal' + location.search,
  219. }
  220. });
  221. var table = $("#table1");
  222. // 初始化表格
  223. table.bootstrapTable({
  224. url: $.fn.bootstrapTable.defaults.extend.index_url,
  225. pk: 'id',
  226. sortName: 'id',
  227. fixedColumns: true,
  228. fixedRightNumber: 1,
  229. searchFormVisible:false,
  230. Search:false,
  231. columns: [
  232. [
  233. {checkbox: true,
  234. formatter: function(value,row,index){
  235. // console.log(row.id+'####'+Config.row_info.depart_ids)
  236. if(Config.row_info != undefined && Config.row_info.depart_ids.indexOf(row.id)>-1){
  237. rel_Ids.push(row.id);
  238. return true;
  239. }
  240. return false;
  241. }
  242. },
  243. {field: 'department_name', title: __('区队名称'), operate: false,width: '400px', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  244. {field: 'department_admin_count', title: __('全部人员数量'),operate: false},
  245. ]
  246. ]
  247. });
  248. // 为表格绑定事件
  249. Table.api.bindevent(table);
  250. table.on('click-row.bs.table', function (e, row, element) {
  251. console.log(rel_Ids)
  252. // console.log('row')
  253. if(!$.inArray(row.id,rel_Ids)){
  254. arr = $.grep(rel_Ids, function(value) {
  255. return value != row["id"];
  256. });
  257. rel_Ids = arr;
  258. }else if(rel_Ids.indexOf(row.id)>-1){
  259. var index = rel_Ids.indexOf(row.id);
  260. if (index > -1) {
  261. rel_Ids.splice(index, 1);
  262. }
  263. }else{
  264. rel_Ids.push(row.id);
  265. }
  266. $(".depart_ids").val(rel_Ids.join());
  267. });
  268. $(document).on('change', '#c-question_setting_method', function () {
  269. if($(this).val()==1){
  270. $(".btn-sm,.btn-task").css('display','none');
  271. }else if($(this).val()==2){
  272. $(".btn-sm").css('display','block');
  273. $(".btn-task").css('display','none');
  274. }else if($(this).val()==3){
  275. $(".btn-sm").css('display','none');
  276. $(".btn-task").css('display','block');
  277. }
  278. $(".question_ids").val(0);
  279. });
  280. //考题
  281. $(document).on('click', '.btn-sm', function () {
  282. var simtype = $("#c-sim_type").val();
  283. if(!simtype){
  284. Layer.alert('请选择模拟器类型');
  285. return false
  286. }
  287. var title = '选择考题';
  288. Fast.api.open(Fast.api.fixurl("teacher/collection/faults/type/"+simtype), title, {
  289. area: ["85%", "85%"],
  290. maxmin: true,
  291. moveOut: false,
  292. offset: ['40px'],
  293. callback: function(value) {
  294. console.log(value)
  295. if (value.task_id) {
  296. $(".question_ids").val(value.task_id);
  297. }
  298. }
  299. });
  300. });
  301. //任务
  302. $(document).on('click', '.btn-task', function () {
  303. var simtype = $("#c-sim_type").val();
  304. if(!simtype){
  305. Layer.alert('请选择模拟器类型');
  306. return false;
  307. }
  308. var title = '选择任务';
  309. parent.Fast.api.open(Fast.api.fixurl("teacher/collection/task/type/"+simtype), title, {
  310. area: ["85%", "85%"],
  311. maxmin: true,
  312. moveOut: false,
  313. offset: ['40px'],
  314. callback: function(value) {
  315. if (value.task_id) {
  316. $(".question_ids").val(value.task_id);
  317. }
  318. }
  319. });
  320. });
  321. // $("input[name='btSelectAll']").click(function () {
  322. // var ids = Table.api.selectedids(table);
  323. // console.log(ids);
  324. // $(".depart_ids").val(ids);
  325. // });
  326. $("input[name='btSelectAll']").css('display','none');
  327. Form.api.bindevent($("form[role=form]"));
  328. }
  329. }
  330. };
  331. return Controller;
  332. });