d47af8e80a184c31f65387cf45af984595569a89.svn-base 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  2. var real_name = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  3. var corp = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  4. var dept = top.com.sinosoft.lz.system.user.LoginInfo.getDept_id();
  5. var projectData = [];
  6. var excelData = [];
  7. question_import = function() {
  8. /**定义变量**/
  9. var _this = this;
  10. _this.grid = null;
  11. _this.tixi = null;
  12. /**私有方法**/
  13. function getColumns(){
  14. var columns = [];
  15. //{name : 'FD_OBJECTID880',hide : true},
  16. columns.push({name: 'FD_ID',align: 'center',hide : true});
  17. columns.push({display: '考试内容类别', name: 'QUESTION_CLASSIFY',align: 'center', width: "100"});
  18. columns.push({display: '考试内容来源', name: 'EXAMINATION_CONTENT',align: 'center', width: "150"});
  19. var childColumns = [];
  20. childColumns.push({display: 'Ⅰ类', name: 'APPLICABLE_OBJECT_1',align: 'center', width: "50"});
  21. childColumns.push({display: 'Ⅱ类', name: 'APPLICABLE_OBJECT_2',align: 'center', width: "50"});
  22. childColumns.push({display: 'Ⅲ类', name: 'APPLICABLE_OBJECT_3',align: 'center', width: "50"});
  23. childColumns.push({display: 'Ⅳ类', name: 'APPLICABLE_OBJECT_4',align: 'center', width: "50"});
  24. columns.push({display: '适用对象', columns:childColumns, width: (50*childColumns.length) });
  25. columns.push({display: '题型', name: 'QUESTION_TYPE',align: 'center', width: "80"});
  26. columns.push({display: '题干', name: 'QUESTION_NAME',align: 'center', width: "400"});
  27. columns.push({display: 'A', name: 'ANSWER_A',align: 'center', width: "100"});
  28. columns.push({display: 'B', name: 'ANSWER_B',align: 'center', width: "100"});
  29. columns.push({display: 'C', name: 'ANSWER_C',align: 'center', width: "100"});
  30. columns.push({display: 'D', name: 'ANSWER_D',align: 'center', width: "100"});
  31. columns.push({display: 'E', name: 'ANSWER_E',align: 'center', width: "100"});
  32. columns.push({display: 'F', name: 'ANSWER_F',align: 'center', width: "100"});
  33. columns.push({display: 'G', name: 'ANSWER_G',align: 'center', width: "100"});
  34. columns.push({display: '答案', name: 'QUESTION_ANSWER',align: 'center', width: "100"});
  35. return columns;
  36. }
  37. return {
  38. init:function(){
  39. $(".titleShow").text("题库导入");
  40. },
  41. initList : function(data) {
  42. //$("#maingrid").html("");
  43. var rowsdata = data[0].result;
  44. //console.log(rowsdata);
  45. var option = {
  46. rownumbers:true,
  47. columns:getColumns(),
  48. data:{rows:rowsdata},
  49. usePager:true,
  50. pageSize: 10,
  51. fixedCellHeight:false,
  52. //percentWidthMode : true,
  53. rownumbers:true,
  54. showPageSize:false,
  55. minColumnWidth:0,
  56. columnWidth:10,
  57. sortName: 'FD_ID',
  58. rownumbers:false,
  59. checkbox:false,
  60. height: 'auto',
  61. // width:"100%",
  62. isScroll:true,
  63. headerRowHeight:50,
  64. onToFirst:setPageHeight,
  65. onToLast:setPageHeight,
  66. onToNext:setPageHeight,
  67. onToPrev:setPageHeight
  68. };
  69. _this.grid = $("#maingrid").quiGrid(option);
  70. _this.grid.setScroller(null,"bottom",false);
  71. setPageHeight();
  72. }
  73. };
  74. }();
  75. function setPageHeight(){
  76. ////console.log(123456);
  77. setTimeout(function(){
  78. $(parent.document.body).find("#frmright").css("height",$(window.document.body).height()+30);
  79. },200);
  80. }
  81. $(function() {
  82. question_import.init();
  83. //Grade_inner_view.initList();
  84. $("#back").hover(function(){
  85. $(this).attr("src","/nwyj/images/temp/back_hover.png");
  86. },function(){
  87. $(this).attr("src","/nwyj/images/temp/back.png");
  88. });
  89. $('#back').bind('click',back);
  90. $("#import_btn").on("click",function(){
  91. $("body").eq(0).showLoading();
  92. var val = $("#import_eval").val();
  93. var end = val.substring(val.indexOf(".") + 1);
  94. if (end == "xls" || end == "xlsx") {
  95. $("#evalFileForm").ajaxSubmit({
  96. url : $.pathname() + "/ws/Examine/ExamineManagementService/getExcelToList?fileExt="+end,
  97. type : 'post',
  98. success : function(responseText, statusText, xhr, $form) {
  99. if(responseText.state=="false"){
  100. $("body").eq(0).hideLoading();
  101. top.Dialog.alert(responseText.message);
  102. return;
  103. }
  104. $("body").eq(0).hideLoading();
  105. $("#save_eval").show();
  106. //console.log(responseText);
  107. if(typeof responseText == 'string')
  108. responseText = eval('(' + responseText + ')');
  109. //console.log(responseText);
  110. excelData = responseText;
  111. question_import.initList(responseText);
  112. },error : function(e) {
  113. top.Dialog.alert("导入数据失败!");
  114. }
  115. });
  116. } else {
  117. $("body").eq(0).hideLoading();
  118. top.Dialog.alert("请导入正确的excel文件");
  119. return;
  120. }
  121. });
  122. $("#downloadModel").on("click",function(){
  123. window.open("/nwyj/excels/examineQuestion.xlsx");
  124. });
  125. $("#save_eval").on("click",function(){
  126. $("body").eq(0).showLoading();
  127. var saveData = excelData[0].result;
  128. var url = $.pathname() + '/ws/Examine/ExamineManagementService/saveQuestion';
  129. var params = {
  130. userName : real_name,
  131. userId : user_id,
  132. userUnit : corp,
  133. userDept : dept,
  134. versionId: versionId,
  135. data:JSON.stringify(saveData)
  136. };
  137. /*$.request.query(url,params,function(data){
  138. $("body").eq(0).hideLoading();
  139. if(data[0].questionResult == "true" && data[0].questionSubResult == "true"){
  140. top.Dialog.alert('提交成功!');
  141. back();
  142. }else{
  143. top.Dialog.alert('提交失败!');
  144. return;
  145. }
  146. });*/
  147. $.ajax({
  148. url : url,
  149. data : params,
  150. type : 'post',
  151. dataType : 'json',
  152. success : function(data) {
  153. $("body").eq(0).hideLoading();
  154. if(data[0].questionResult == "true" && data[0].questionSubResult == "true"){
  155. top.Dialog.alert('提交成功!');
  156. back();
  157. }else{
  158. top.Dialog.alert('提交失败!');
  159. return;
  160. }
  161. },error : function(e) {
  162. $("body").eq(0).hideLoading();
  163. top.Dialog.alert('网络异常!');
  164. return;
  165. }
  166. });
  167. });
  168. });
  169. function back(){
  170. $('#frmright',window.parent.document).attr('src',$.pathname()+"/page/business/exercise/examineManagement/questionBank.jsp");
  171. };