submitNew.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. /**序列化表单,多个value用数组存放**/
  2. $.fn.serializeObject = function() {
  3. var o = {};
  4. var arr = this.serializeArray();
  5. $.each(arr,function(){
  6. if (o[this.name]) { //返回json中有该属性
  7. if (!o[this.name].push) { //将已存在的属性值改成数组
  8. o[this.name] = [ o[this.name] ];
  9. }
  10. o[this.name].push(this.value || ''); //将值存放到数组中
  11. } else { //返回json中没有有该属性
  12. o[this.name] = this.value || ''; //直接将属性和值放入返回json中
  13. }
  14. });
  15. return o;
  16. }
  17. String.prototype.substitute = function(data) {
  18. if (data && typeof data == 'object') {
  19. return this.replace(/\{([^{}]+)\}/g, function(match, key) {
  20. var value = data[key]
  21. return value !== undefined ? '' + value : ''
  22. })
  23. } else {
  24. return this.toString()
  25. }
  26. }
  27. var isProduction = ~location.href.indexOf('zhixinhuixue')
  28. var newBuildBaseUrl = '';
  29. var newBuildBaseUrlObj = {
  30. testing:'http://zsyas2nx.testing.xueping.com',
  31. dev:'http://zsyas2nx.dev.xueping.com',
  32. production:'http://zsyas2nx.zhixinhuixue.com',
  33. }
  34. if(~location.href.indexOf('zhixinhuixue')){
  35. newBuildBaseUrl = newBuildBaseUrlObj.production
  36. }else if(~location.href.indexOf('testing')){
  37. newBuildBaseUrl = newBuildBaseUrlObj.testing
  38. }else{
  39. newBuildBaseUrl = newBuildBaseUrlObj.dev
  40. }
  41. function tplNameReplace(num){
  42. var str=num.value;
  43. var value=str.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\.]/g,'');
  44. num.value=value;
  45. }
  46. $(function(){
  47. $("body").delegate("#btnSubmit[active='true']", "click", function(e) {
  48. var classIds = '';
  49. $(".sel-classes[status=1]").children("span").each(function(){
  50. classIds += $(this).attr('classid')+",";
  51. });
  52. $('input[name="classIds"]').val(classIds);
  53. var classIds = $('input[name=classIds]').val();
  54. var teacherId = $('input[name="teacherId"]').val();
  55. var subjectId = $('input[name=subjectId]').val();
  56. var tpl_title = $('input[name=tpl_title]').val();
  57. if(tpl_title == "" || tpl_title == null){
  58. layer.msg('没有指定模板名称!');return false;
  59. }
  60. if(subjectId == 0 || subjectId == null){
  61. layer.msg('没有指定题源!');return false;
  62. }
  63. if(teacherId == '0' || teacherId == null){
  64. $('#choose-error').html('请指定阅卷老师');
  65. layer.msg('没有指定阅卷老师!');return false;
  66. }else{
  67. $('#choose-error').html('');
  68. if(classIds == "" || classIds == null){
  69. $('#classIds-error').html('请指定考试班级');
  70. layer.msg('没有指定考试班级!');return false;
  71. }else{
  72. $('#classIds-error').html('');
  73. }
  74. }
  75. if (!$(".ques-type-control label input").is(':checked')) {
  76. layer.msg('请选择题型!');return false;
  77. }
  78. var flag = 0;
  79. for(i = 0 ; i<TopicType.length;i++)
  80. {
  81. if(TopicType[i].length>0){
  82. flag = 1;
  83. if( i==4 &&!TopicType[4][0][0]){
  84. layer.msg('选做题设置有误,题型不能为空!');
  85. return false;
  86. }
  87. for (j = 0;j<TopicType[i].length;j++){
  88. if(TopicType[i][j][1]=='' || TopicType[i][j][1]==0)
  89. {
  90. layer.msg('题号不能为空!');
  91. return false;
  92. }
  93. }
  94. }
  95. }
  96. if(flag == 0){
  97. layer.msg('题号不能为空!');
  98. return false;
  99. }
  100. var data={
  101. tpl_title:tpl_title,
  102. teacherId:teacherId,
  103. classIds:classIds,
  104. subjectId:subjectId,
  105. textbookId:0,
  106. topic:JSON.stringify(TopicType),
  107. layout:$("input[name=layout]:checked").val(),
  108. select_card_type:$("input[name=select_card_type]:checked").val()
  109. };
  110. $.post("<?php echo Yii::app()->createUrl('third/createThirdTpl')?>",data,function (data) {
  111. var m = JSON.parse(data);
  112. if(m.status==1)
  113. { //$('#btnSubmit').attr('active','false');
  114. // layer.msg(m.msg);
  115. $(".template-box").prepend('<li class="_tpl" showmsg="1" third_tpl_id="'+m.result.third_tpl_id+'"><a href="#"><div class="card-type"><span class="size">'+m.result.layout+'</span><span class="type">'+m.result.select_card_type+'</span><i class="icon-delete"></i></div> <p class="card-name">'+m.result.title+'</p></a></li>');
  116. $("input[name=third_tpl_id]").val(m.result.third_tpl_id);
  117. $("._tpl.active").removeClass('active');
  118. $("._tpl").eq(0).addClass('active');
  119. $("#btnCover").removeClass('dn');
  120. layer.msg('保存成功!',{
  121. icon: 1
  122. });
  123. $(".ttd").hide();
  124. $(".bnt_width").addClass('c_bnt_width');
  125. return false;
  126. }else{
  127. layer.msg('保存失败',{
  128. icon: 5
  129. }, function(){
  130. $(".ttd").fadeOut();
  131. });
  132. return false;
  133. }
  134. });
  135. });
  136. $("body").delegate("#btnCover[active='true']", "click", function(e) {
  137. var classIds='';
  138. $(".sel-classes[status=1]").children("span").each(function(){
  139. classIds += $(this).attr('classid')+",";
  140. });
  141. $('input[name="classIds"]').val(classIds);
  142. var classIds = $('input[name=classIds]').val();
  143. var teacherId = $('input[name="teacherId"]').val();
  144. var subjectId = $('input[name=subjectId]').val();
  145. var tpl_title = $('input[name=tpl_title]').val();
  146. if(tpl_title == "" || tpl_title == null){
  147. layer.msg('没有指定模板名称!');return false;
  148. }
  149. if(subjectId == 0 || subjectId == null){
  150. layer.msg('没有指定题源!');return false;
  151. }
  152. if(teacherId == '0' || teacherId == null){
  153. $('#choose-error').html('请指定阅卷老师');
  154. layer.msg('没有指定阅卷老师!');return false;
  155. }else{
  156. $('#choose-error').html('');
  157. if(classIds == "" || classIds == null){
  158. $('#classIds-error').html('请指定考试班级');
  159. layer.msg('没有指定考试班级!');return false;
  160. }else{
  161. $('#classIds-error').html('');
  162. }
  163. }
  164. if (!$(".ques-type-control label input").is(':checked')) {
  165. layer.msg('请选择题型!');return false;
  166. }
  167. var flag = 0;
  168. for(i = 0 ; i<TopicType.length;i++)
  169. {
  170. if(TopicType[i].length>0){
  171. flag = 1;
  172. if( i==4 &&!TopicType[4][0][0]){
  173. layer.msg('选做题设置有误,题型不能为空!');
  174. return false;
  175. }
  176. for (j = 0;j<TopicType[i].length;j++){
  177. if(TopicType[i][j][1]=='' || TopicType[i][j][1]==0)
  178. {
  179. layer.msg('题号不能为空!');
  180. return false;
  181. }
  182. }
  183. }
  184. }
  185. if(flag == 0){
  186. layer.msg('题号不能为空!');
  187. return false;
  188. }
  189. var data={
  190. tpl_title:tpl_title,
  191. third_tpl_id:$("._tpl.active").attr('third_tpl_id'),
  192. teacherId:teacherId,
  193. classIds:classIds,
  194. subjectId:subjectId,
  195. textbookId:0,
  196. topic:JSON.stringify(TopicType),
  197. layout:$("input[name=layout]:checked").val(),
  198. select_card_type:$("input[name=select_card_type]:checked").val()
  199. };
  200. $.post("<?php echo Yii::app()->createUrl('third/updateThirdTpl')?>",data,function (data) {
  201. var m = JSON.parse(data);
  202. if(m.status==1)
  203. {
  204. $("._tpl.active").children().find('.size').html(m.result.layout);
  205. $("._tpl.active").children().find('.type').html(m.result.select_card_type);
  206. $("._tpl.active").children().find('.card-name').html(m.result.title);
  207. $("._tpl.active").removeClass('active');
  208. $("._tpl").eq(0).addClass('active');
  209. layer.msg('保存成功!',{
  210. icon: 1
  211. });
  212. $(".ttd").fadeOut();
  213. $("#btnCover").removeClass('dn');
  214. $(".bnt_width").addClass('c_bnt_width');
  215. return false;
  216. }else{
  217. layer.msg('保存失败',{
  218. icon: 5
  219. }, function(){
  220. $(".ttd").fadeOut();
  221. });
  222. return false;
  223. }
  224. });
  225. });
  226. //模版系列
  227. var hgc_DtkTplModule = {
  228. tpls:{
  229. tplItemTPl:'<div class="tplItem">\
  230. <div class="top itemModule">\
  231. <h3>\
  232. <strong>{title}</strong>\
  233. <div class="menu">\
  234. <strong><b></b><b></b><b></b></strong>\
  235. <i class="triangle"></i>\
  236. <div class="menuList">\
  237. <span class="use" data-id="{third_tpl_id}">使用</span>\
  238. <span class="preview" data-id="{third_tpl_id}">预览</span>\
  239. <span class="del" data-id="{third_tpl_id}">删除</span>\
  240. </div>\
  241. </div>\
  242. </h3>\
  243. <span>总分:{total_score}分</span>\
  244. <span>题量:{total_topics}小题</span>\
  245. </div>\
  246. <div class="bottom itemModule">\
  247. <h3>其他信息</h3>\
  248. <span>版式:{format}</span>\
  249. <span>考号:{examFields}</span>\
  250. </div>\
  251. </div>',
  252. dtkBaseInfoTpl:'<p>\
  253. <span>板式:{format}</span>\
  254. <span>考号:{examFields}</span>\
  255. <span>装订线:{hasBindline}</span>\
  256. <span>总分:{total_score}分</span>\
  257. <span>题量:{total_topics}</span>\
  258. </p>',
  259. dtkSubjectInfoTpl:'<p>\
  260. <span><strong>{bigTitle}</strong><i>{bigTitle}</i></span>\
  261. <span>{subjectType}</span>\
  262. <span>{questionLength}题</span>\
  263. <span>共{questionScore}分</span>\
  264. </p>',
  265. dtkSubjectInfoXZTpl:'<p>\
  266. <span><strong>{bigTitle}</strong><i>{bigTitle}</i></span>\
  267. <span>{subjectType}</span>\
  268. <span>{questionLength}</span>\
  269. <span>共{questionScore}分</span>\
  270. </p>'
  271. },
  272. init:function(){
  273. //判断[新创建]是数学还是其他学科(其他学科)
  274. this.isMathForNew = !~location.href.indexOf('third/thirdview_duo')
  275. //存放模版列表信息
  276. this.tplList = []
  277. this.dtkPosition = {}
  278. this.examGroupId = $('input[name="examGroupId"]').val();
  279. this.formatMap = {
  280. horizontal:'横版',
  281. vertical:'竖版',
  282. 1:'一栏',
  283. 2:'两栏',
  284. 3:'三栏'
  285. }
  286. this.questionTypes = {
  287. 1:'单选',
  288. 2:'多选',
  289. 11:'不定项选择',
  290. 5:'填空',
  291. 7:'解答',
  292. 17:'选做',
  293. '7c':'作文'
  294. }
  295. this.savePrintInfo = localStorage.getItem('savePrintInfo')!=undefined? JSON.parse(localStorage.getItem('savePrintInfo')):{}
  296. let _this = this;
  297. this.thirdOnlineUrl = '/index.php/online/third';
  298. let isCardReturn = window.location.href.indexOf('isCardReturn');
  299. // let isCardReturn = document.referrer.indexOf('vue');
  300. if(isCardReturn>-1){
  301. let resData = JSON.parse(localStorage.getItem('upDataThreeCard'));
  302. // let resData = JSON.parse(upDataThreeCard);
  303. if(resData.savePrintInfo){
  304. localStorage.setItem('savePrintInfo',JSON.stringify(resData.savePrintInfo));
  305. _this.savePrintInfo = resData.savePrintInfo;
  306. }
  307. // $.post('/print/getOnlineCardTempData',{
  308. // examGroupId:saveFormData.examGroupId,
  309. // },function(res){
  310. // res = JSON.parse(res);
  311. // let resData = JSON.parse(res.data);
  312. // if(resData.savePrintInfo){
  313. // localStorage.setItem('savePrintInfo',JSON.stringify(resData.savePrintInfo));
  314. // _this.savePrintInfo = resData.savePrintInfo;
  315. // _this.initDom()
  316. // _this.initPage()
  317. // _this.getDtkInfo()
  318. // }
  319. // })
  320. }
  321. //提供下载pdf 的唯一标识符
  322. this.downloadPdfIdentifier = ''
  323. this.initDom()
  324. this.bindEvent()
  325. this.initPage()
  326. this.getDtkInfo()
  327. this.getTplList();
  328. },
  329. initDom:function(){
  330. this.$dtkContentInfo = $('.hgc_leftContent .contentInfo')
  331. this.$dtkContentNoInfo = $('.hgc_leftContent .contentNoInfo')
  332. },
  333. initPage:function(){
  334. this.initConnectDtkStatus()
  335. },
  336. initConnectDtkStatus:function(){
  337. var self = this;
  338. //如果不是在线答题卡编辑页面跳转过来,直接清空storage
  339. // if(!~document.referrer.indexOf('vue')){
  340. // self.clearStorage()
  341. // self.savePrintInfo = {}
  342. // }
  343. //判断是否有题目信息
  344. var hasSubjectInfo = Object.keys(self.savePrintInfo).length;
  345. self.setContentInfoStatus(hasSubjectInfo)
  346. //如果进入该页面是关联答题卡页面,直接显示
  347. if(localStorage.getItem('isConnect') === 'block'){
  348. $(".template-flag").trigger('click')
  349. }
  350. },
  351. setContentInfoStatus:function(hasSubjectInfo){
  352. var self = this;
  353. self.$dtkContentInfo[hasSubjectInfo?'show':'hide']()
  354. self.$dtkContentNoInfo.css('display',hasSubjectInfo?'none':'flex')
  355. },
  356. // setConnectStatus:function(status){
  357. // $('.hgc_leftContent').css('display',status)
  358. // localStorage.setItem('isConnect',status)
  359. // },
  360. getConnectStatus:function(){
  361. return localStorage.getItem('isConnect')
  362. },
  363. //获取当前答题卡信息
  364. getDtkInfo:function(){
  365. var self = this;
  366. var dtkInfo = null;
  367. //如果有记录的答题卡信息就使用记录的答题卡信息
  368. var storageInfo = self.savePrintInfo;
  369. var hasDtkInfo = Object.keys(storageInfo).length
  370. //考试id 存在就是编辑考试
  371. if(self.examGroupId && !hasDtkInfo &&hasOnlineCard==1){
  372. $.post('/third/getTemplateByExamGroupId',{examGroupId:self.examGroupId},function(res){
  373. var savePrintInfoObj = {}
  374. if(!JSON.parse(res).success){
  375. // self.setConnectStatus('none')
  376. self.setContentInfoStatus(false)
  377. return;
  378. }
  379. dtkInfo = JSON.parse(res).data;
  380. // dtkInfo = JSON.parse(res).data.position ? JSON.parse(JSON.parse(res).data.position) :{};
  381. // dtkInfo.position = JSON.parse(JSON.stringify(dtkInfo));
  382. self.dtkPosition = dtkInfo;
  383. //判断是否是老版在线答题卡
  384. if(!JSON.parse(dtkInfo.position).bigTopicArr){
  385. self.setContentInfoStatus(false)
  386. return;
  387. }
  388. // let timu = {
  389. // KeGuanTi:dtkInfo.ke_topic_num,
  390. // TianKongTi:dtkInfo.tian_topic_num,
  391. // ZhuGuanTi:dtkInfo.zu_topic_num,
  392. // XuanZuoTi:dtkInfo.xuan_topic_num
  393. // }
  394. // let question_info={
  395. // content:[]
  396. // }
  397. let question_info={
  398. content:dtkInfo.questions
  399. }
  400. // jQuery.each( dtkInfo.buildQuestions, function( i, val ) {
  401. // question_info.content = question_info.content.concat(val.questions)
  402. // });
  403. // dtkInfo.buildQuestions
  404. savePrintInfoObj = {
  405. position:JSON.parse(dtkInfo.position),
  406. sheet_answer:dtkInfo.sheet_answer,
  407. sheet_score:dtkInfo.sheet_score,
  408. timu:dtkInfo.timu,
  409. title:dtkInfo.name,
  410. question_info:question_info,
  411. pdf_url:dtkInfo.online_card_pdf
  412. }
  413. self.verificationDtkInfo(savePrintInfoObj,dtkInfo.questions)
  414. self.savePrintInfo = savePrintInfoObj
  415. localStorage.setItem('savePrintInfo',JSON.stringify(savePrintInfoObj))
  416. self.renderDtkInfo(savePrintInfoObj)
  417. // self.setConnectStatus('block')
  418. self.setContentInfoStatus(true)
  419. })
  420. }else{
  421. if(hasDtkInfo){
  422. dtkInfo = storageInfo;
  423. self.dtkPosition = dtkInfo.position;
  424. //直接把dtkInfo存到
  425. self.renderDtkInfo(dtkInfo)
  426. // self.setConnectStatus('block')
  427. self.setContentInfoStatus(true)
  428. }else{
  429. // self.setConnectStatus('none')
  430. self.setContentInfoStatus(false)
  431. }
  432. }
  433. },
  434. verificationDtkInfo:function(data,resData){
  435. var self = this;
  436. let topicAll = JSON.parse(JSON.stringify(resData));
  437. // let topicMod = JSON.parse(JSON.stringify(data.position.buildQuestions));
  438. // jQuery.each(topicMod,function (modI,topicModItem){
  439. // topicAll = topicAll.concat(topicModItem.questions)
  440. // })
  441. jQuery.each(resData,function (i,item){
  442. jQuery.each(data.question_info.content,function (j,topic){
  443. if(topic.questionNum==item.questionNum){
  444. let isEdit = false;
  445. if(topic.fullScore!=item.fullScore){
  446. isEdit = true
  447. topic.fullScore=item.fullScore
  448. }
  449. if(item.questionTypeId == 2){
  450. if(item.ruleScoreHalf != topic.halfScore){
  451. isEdit = true
  452. topic.halfScore = item.ruleScoreHalf
  453. }
  454. }
  455. if(isEdit){
  456. self.editDtkInfo(topicAll,topic.topicNo,item)
  457. }
  458. }
  459. })
  460. })
  461. },
  462. editDtkInfo:function(topicAll,topicNo,resDataTtem){
  463. jQuery.each(topicAll,function (idx,topic){
  464. if(topic.topicNo==topicNo){
  465. topic.fullScore=resDataTtem.fullScore
  466. if(resDataTtem.questionTypeId == 2){
  467. if(resDataTtem.ruleScoreHalf != topic.halfScore){
  468. topic.halfScore = resDataTtem.ruleScoreHalf
  469. }
  470. }
  471. }
  472. })
  473. },
  474. renderDtkInfo:function(dtkInfo){
  475. var self = this;
  476. self.downloadPdfIdentifier = dtkInfo.position.identifier
  477. self.renderDtkBaseInfo(dtkInfo)
  478. self.renderDtkSubjectInfo(dtkInfo.position.bigTopicArr)
  479. },
  480. renderDtkBaseInfo:function(dtkInfo){
  481. var self = this;
  482. var tpl_data = dtkInfo.position
  483. var dtkbaseInfo = self.getOtherInfo(tpl_data)
  484. var paperScoreAll = self.getScoreAll(dtkInfo.question_info.content)
  485. var calcScoreTimu = self.calcScoreTimu(paperScoreAll,dtkInfo.timu)
  486. calcScoreTimu.total_score = tpl_data.cardSetting.examInfoConfig[1].text;
  487. var baseInfoHtmls = self.tpls.dtkBaseInfoTpl.substitute({
  488. ...dtkbaseInfo,
  489. total_score:calcScoreTimu.total_score,
  490. total_topics:calcScoreTimu.total_topics,
  491. hasBindline:tpl_data.cardSetting.hasBindingLine?'有':'无'
  492. })
  493. $('.hgc_leftContent .module').eq(0).find('.infoItem').eq(0).children('.info').html(baseInfoHtmls)
  494. },
  495. getScoreAll:function (data) {
  496. let scoreArr = [];
  497. let pId = 0;
  498. for (let i = 0; i < data.length; i++) {
  499. if(data[i].questionTypeId==17){
  500. if(data[i].topicNo!=pId){
  501. scoreArr.push(Number(data[i].fullScore))
  502. pId = data[i].topicNo
  503. }
  504. }else{
  505. scoreArr.push(Number(data[i].fullScore))
  506. }
  507. }
  508. return scoreArr
  509. },
  510. renderDtkSubjectInfo:function(buildQuestions){
  511. var self = this;
  512. var subjectInfoHtml = '';
  513. for(var modelId in buildQuestions){
  514. var buildQuestionItem = buildQuestions[modelId];
  515. var subjectType = '';
  516. if(buildQuestionItem.questionTypeId===77){
  517. subjectType = self.questionTypes['7c'];
  518. }else {
  519. subjectType = self.questionTypes[buildQuestionItem.questionTypeId];
  520. }
  521. var questionLength = buildQuestionItem.questions.length
  522. if(buildQuestionItem.questionTypeId ==17){
  523. questionLength = buildQuestionItem.topicConfigureData.topicTypeArr[0].chooseOption+'选1'
  524. }
  525. var questionScore = buildQuestionItem.questions.reduce(function(totalScore,cur){
  526. // totalScore+=cur.fullScore;
  527. totalScore = Number(totalScore)+Number(cur.fullScore)
  528. return totalScore
  529. },0)
  530. if(buildQuestionItem.questionTypeId===17){
  531. questionScore = buildQuestionItem.questions[0].fullScore
  532. subjectInfoHtml+=self.tpls.dtkSubjectInfoXZTpl.substitute({
  533. subjectType,
  534. questionLength,
  535. questionScore,
  536. bigTitle:buildQuestionItem.bigTitle
  537. })
  538. } else{
  539. subjectInfoHtml+=self.tpls.dtkSubjectInfoTpl.substitute({
  540. subjectType,
  541. questionLength,
  542. questionScore,
  543. bigTitle:buildQuestionItem.bigTitle
  544. })
  545. }
  546. }
  547. $('.hgc_leftContent .module').eq(0).find('.infoItem').eq(1).children('.info').html(subjectInfoHtml)
  548. },
  549. //获取模版
  550. getTplList:function(){
  551. var self = this
  552. $.get('/index.php/third/tplList',function(res){
  553. var result = JSON.parse(res);
  554. if(result.success === 1 && result.thisTpls){
  555. self.tplList = []
  556. jQuery.each(result.thisTpls, function (i, item){
  557. let tpl_data = JSON.parse(item.tpl_data)
  558. if(tpl_data.position){
  559. if(tpl_data.position.bigTopicArr){
  560. self.tplList.push(item)
  561. }
  562. } else {
  563. // let errTplMsg = '在线答题卡模板:'+item.title+'(id:'+item.third_tpl_id+')'+'缺少数据,是否删除模板?'
  564. // layer.confirm(errTplMsg, {title:'提示'}, function(index){
  565. // self.delTpl(item.third_tpl_id)
  566. // layer.close(index);
  567. // });
  568. }
  569. })
  570. if(self.tplList.length>0){
  571. $('#tplListMsg').hide();
  572. } else{
  573. $('#tplListMsg').show()
  574. }
  575. self.renderTplList(self.tplList)
  576. }
  577. })
  578. },
  579. //format examFields
  580. getOtherInfo:function(tpl_data){
  581. var self = this;
  582. let papers = ['','A3','A4','16K','8Ks','8Kb'];
  583. let direction = tpl_data.cardSetting.direction==1?'horizontal':'vertical';
  584. var format = papers[tpl_data.cardSetting.paperSize]+'-'+self.formatMap[direction]+'-'+self.formatMap[tpl_data.cardSetting.column]
  585. var examFields = ''
  586. if(tpl_data.cardSetting.examinationNumberType.indexOf(1)){
  587. examFields+='条形码'
  588. }
  589. if(tpl_data.cardSetting.examinationNumberType.indexOf(2)){
  590. examFields+=' 填涂'
  591. }
  592. return {
  593. format:format,
  594. examFields:examFields
  595. }
  596. },
  597. calcScoreTimu:function(sheet_score,timu){
  598. var self = this;
  599. var total_topics = 0;
  600. var total_score = 0
  601. for(var key in sheet_score){
  602. total_score+=Number(sheet_score[key])
  603. }
  604. for(var type in timu){
  605. total_topics+=Number(timu[type])
  606. }
  607. if(timu==undefined){
  608. total_topics = sheet_score.length
  609. }
  610. return {
  611. total_topics:total_topics,
  612. total_score:total_score
  613. }
  614. },
  615. renderTplList:function(tpls){
  616. var self = this;
  617. // if(!tpls.length)alert('数据不存在');
  618. var htmls = tpls.reduce( function(str,item){
  619. var tpl_data = JSON.parse(item.tpl_data)
  620. var otherInfo = self.getOtherInfo(tpl_data.position)
  621. item.format = otherInfo.format
  622. item.examFields = otherInfo.examFields
  623. str += self.tpls.tplItemTPl.substitute(item)
  624. return str
  625. },'')
  626. $('.tplList').html(htmls)
  627. $('#tplLength').text(tpls.length)
  628. },
  629. bindEvent:function(){
  630. var self = this;
  631. // $(".template-flag").click(function(){
  632. // var $rightContent = $(".hgc_leftContent");
  633. // $(".hgc_leftContent").toggle();
  634. // self.setConnectStatus($rightContent.css('display'))
  635. // });
  636. $('body').on('click','.menu',function(e){
  637. e.stopPropagation()
  638. $(this).children('.triangle').css('display','flex')
  639. $(this).children('.menuList').css('display','flex')
  640. })
  641. $(document).click(function(){
  642. $('.menu').children('.triangle').css('display','none')
  643. $('.menu').children('.menuList').css('display','none')
  644. })
  645. $('body').on('click','.menuList span',function(e){
  646. var $this = $(this);
  647. var type = $(this).attr('class');
  648. var tplId = $(this).attr('data-id')
  649. switch(type){
  650. case 'del':
  651. self.delTpl(tplId,$this)
  652. break;
  653. case 'preview':
  654. self.previewTpl(tplId);
  655. break;
  656. case 'use':
  657. self.useTpl(tplId);
  658. break;
  659. }
  660. })
  661. //修改答题卡
  662. $('#editMyTpl').click(function(e){
  663. // localStorage.setItem('position',JSON.stringify(self.dtkPosition))
  664. // localStorage.setItem('buildQuestions',JSON.stringify(self.dtkPosition.buildQuestions))
  665. // 修改答题卡
  666. // self.goOnlineCard()
  667. if(examStatus){
  668. localStorage.setItem('examStatus',JSON.stringify(examStatus))
  669. }
  670. location.href = self.thirdOnlineUrl+'/isEdit=true';
  671. })
  672. //修改新版答题卡
  673. $('#editNewMyTpl').click(function(e){
  674. self.goEditAnswerSheet();
  675. })
  676. //保存模版
  677. $('#saveMyTpl').click(function(){
  678. var tplTitle = ''
  679. var {sheet_score,timu,position,question_info} = self.savePrintInfo;
  680. var total_topics = 0;
  681. var total_score = position.cardSetting.examInfoConfig[1].text;
  682. // if(typeof(sheet_score) === 'string'){
  683. // sheet_score = JSON.parse(sheet_score);
  684. // }
  685. // for(var key in sheet_score){
  686. // total_score+=+sheet_score[key]
  687. // }
  688. for(var type in timu){
  689. total_topics+=Number(timu[type])
  690. }
  691. if(timu==undefined){
  692. total_topics = question_info.content.length
  693. }
  694. layer.confirm('<div class="hgc_inputItem">\
  695. <p><em>模版名称:</em><input type="text" id="tplName" maxlength="20" onkeyup="tplNameReplace(this)" /></p>\
  696. <p class="error">模版名称不能为空</p>\
  697. </div>', function(index){
  698. //do something
  699. tplTitle = $('#tplName').val();
  700. $('.hgc_inputItem .error')[tplTitle?'hide':'show']()
  701. if(tplTitle){
  702. $.ajax({
  703. url: '/third/saveTemplateByOnline',
  704. method: 'POST',
  705. data:{
  706. title:tplTitle,
  707. total_score,
  708. total_topics,
  709. tpl_data:JSON.stringify(self.savePrintInfo)
  710. },
  711. success: function (data) {
  712. if(JSON.parse(data).success === 1){
  713. layer.msg('保存答题卡成功');
  714. self.getTplList()
  715. } else {
  716. layer.msg(JSON.parse(data).message);
  717. }
  718. }
  719. })
  720. }
  721. tplTitle && layer.close(index);
  722. });
  723. })
  724. var $tplListEl = $('.hgc_leftContent .tplList');
  725. $('.hgc_leftContent .btnItem').click(function(){
  726. var stepNum = $(this).hasClass('leftBtn')?225:-225;
  727. var curLeft =Math.abs($tplListEl.position().left);
  728. if(stepNum<0 && curLeft<220){
  729. return false
  730. }
  731. var listW = Math.abs($tplListEl.width());
  732. var boxW = Math.abs($('.relation-answer-card .tplBox').width());
  733. if((curLeft + boxW +stepNum -240)==listW || (curLeft + boxW +stepNum -240)>listW){
  734. return false
  735. }
  736. $tplListEl.animate({left:-(curLeft+stepNum)},100)
  737. })
  738. $('.contentNoInfo .hbtn').click(function(){
  739. self.goOnlineCard()
  740. })
  741. $('#goAnswerSheet').click(function(){
  742. self.goNewAnswerSheet()
  743. })
  744. //下载pdf
  745. $('#downLoadPdfBtn').click(function () {
  746. var newTestFormData = JSON.parse(localStorage.getItem('testFormData')) || {};
  747. //isProduction
  748. // var host = isProduction?'//zsyapi.zhixinhuixue.com':'//192.168.1.60:8001'
  749. // location.href = host+'/download/'+self.downloadPdfIdentifier
  750. // location.href = self.savePrintInfo.pdf_url;
  751. location.href = '/third/download?url=' + self.savePrintInfo.pdf_url + '&title=pdf-'+self.savePrintInfo.title+newTestFormData.examGroupId+'.pdf'
  752. })
  753. if(!self.examGroupId){
  754. if(self.isMathForNew){
  755. self.createSubmitForMath()
  756. }else{
  757. self.createSubmit()
  758. }
  759. }else{
  760. self.editSubmit()
  761. }
  762. },
  763. clearStorage:function(){
  764. //清空storage
  765. localStorage.removeItem('position')
  766. localStorage.removeItem('buildQuestions')
  767. localStorage.removeItem('savePrintInfo')
  768. localStorage.removeItem('testFormData')
  769. localStorage.removeItem('isCardReturn')
  770. },
  771. useTpl:function(tplId){
  772. var self = this;
  773. var tpl = self.tplList.find(v=>v.third_tpl_id === tplId);
  774. var tpl_data = JSON.parse(tpl.tpl_data);
  775. var tplTestFormData = JSON.parse(localStorage.getItem('testFormData')) || {};
  776. tpl_data.examGroupId = tplTestFormData.examGroupId;
  777. // localStorage.setItem('position',tpl.tpl_data)
  778. // localStorage.setItem('buildQuestions',JSON.stringify(JSON.parse(tpl.tpl_data).buildQuestions))
  779. localStorage.setItem('savePrintInfo',JSON.stringify(tpl_data));
  780. this.savePrintInfo = tpl_data;
  781. // this.savePrintInfo = JSON.parse(tpl.tpl_data)
  782. // self.goOnlineCard()
  783. // hgc_DtkTplModule.getDtkInfo()
  784. // location.href = self.thirdOnlineUrl;
  785. self.goEditAnswerSheet();
  786. },
  787. previewTpl:function(tplId){
  788. var self = this;
  789. var tpl = self.tplList.find(v=>v.third_tpl_id === tplId);
  790. // localStorage.setItem('previewPosition',tpl.tpl_data);
  791. // localStorage.setItem('previewBuildQuestions',JSON.stringify(JSON.parse(tpl.tpl_data).position.buildQuestions))
  792. // // self.goOnlineCard()
  793. // localStorage.setItem('grade',grade);
  794. // location.href = self.thirdOnlineUrl+'/isPreview=true';
  795. var newTestFormData = JSON.parse(localStorage.getItem('testFormData')) || {};
  796. newTestFormData.editType = 1;
  797. //保存第三方临时数据
  798. let upData={
  799. testFormData:newTestFormData,
  800. savePrintInfo:tpl.tpl_data
  801. }
  802. localStorage.setItem('previewPosition',JSON.stringify(upData));
  803. // $.post('/print/saveOnlineCardTempData',{
  804. // examGroupId:newTestFormData.examGroupId,
  805. // text:JSON.stringify(upData)
  806. // },function(res){
  807. // console.log(res)
  808. // })
  809. // location.href = newBuildBaseUrl+'/#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  810. location.href = '/vue/index.html#/AnswerSheetPreview?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  811. },
  812. goOnlineCard:function(){
  813. var self = this;
  814. self.isOldTpl();
  815. },
  816. isOldTpl:function (isPreview) {
  817. var self = this;
  818. var addGrade = 0
  819. $('.grade-sel ul li').each(function(){
  820. if($(this).hasClass('active')){
  821. addGrade = $(this).attr('grade')
  822. }
  823. })
  824. if(addGrade!=undefined&&addGrade!==0){
  825. var grade = addGrade
  826. } else {
  827. var grade = $("input[name='grade']").val();
  828. }
  829. // var grade = 1;
  830. // modifyThirdExam
  831. var isEdit = ~location.href.indexOf('modifyThirdExam');
  832. if(isEdit){
  833. if(hasThirdCard==1&&hasOnlineCard==0){
  834. layer.confirm('<div class="hgc_inputItem">\
  835. <p>当前考试存在制作模板数据,如果继续使用并保存【在线答题卡】,则会清空制作模板数据,请确认!</p>\
  836. </div>', function(index){
  837. // $.ajax({
  838. // url: 'index.php/third/clearExamTpl',
  839. // method: 'POST',
  840. // data:{
  841. // examGroupId:self.examGroupId,
  842. // },
  843. // success: function (data) {
  844. // if(data.success === 1){
  845. // $('.grade-sel ul li').each(function(){
  846. // if($(this).hasClass('active')){
  847. // grade = $(this).attr('grade')
  848. // }
  849. // })
  850. localStorage.setItem('grade',grade)
  851. location.href = self.thirdOnlineUrl
  852. // }else{
  853. // layer.msg(data.info)
  854. // }
  855. // }
  856. // })
  857. });
  858. }else{
  859. // $('.grade-sel ul li').each(function(){
  860. // if($(this).hasClass('active')){
  861. // grade = $(this).attr('grade')
  862. // }
  863. // })
  864. localStorage.setItem('grade',grade)
  865. location.href = self.thirdOnlineUrl
  866. }
  867. }else{
  868. // $('.grade-sel ul li').each(function(){
  869. // if($(this).hasClass('active')){
  870. // grade = $(this).attr('grade')
  871. // }
  872. // })
  873. localStorage.setItem('grade',grade)
  874. location.href = self.thirdOnlineUrl
  875. }
  876. },
  877. goNewAnswerSheet:function () {
  878. var self = this;
  879. var newTestFormData = JSON.parse(localStorage.getItem('testFormData')) || {};
  880. var hasThirdCard = newTestFormData.hasThirdCard?newTestFormData.hasThirdCard:0;
  881. var hasOnlineCard = newTestFormData.hasOnlineCard?newTestFormData.hasOnlineCard:0;
  882. newTestFormData.referrerUrl = window.location.href;
  883. // var addGrade = 0;
  884. // $('.grade-sel ul li').each(function(){
  885. // if($(this).hasClass('active')){
  886. // addGrade = $(this).attr('grade')
  887. // }
  888. // })
  889. // if(addGrade!=undefined&&addGrade!==0){
  890. // var grade = addGrade
  891. // } else {
  892. // var grade = $("input[name='grade']").val();
  893. // }
  894. // newTestFormData.grade = grade;
  895. // 答题卡编辑状态,0新建答题卡,1编辑已保存答题卡
  896. newTestFormData.editType = 0;
  897. //保存第三方临时数据
  898. let upData={
  899. testFormData:newTestFormData
  900. }
  901. localStorage.setItem('upDataThreeCard',JSON.stringify(upData));
  902. // $.post('/print/saveOnlineCardTempData',{
  903. // examGroupId:newTestFormData.examGroupId,
  904. // text:JSON.stringify(upData)
  905. // },function(res){
  906. // console.log(res)
  907. // })
  908. var isEdit = ~location.href.indexOf('modifyThirdExam');
  909. if(isEdit){
  910. if(hasThirdCard==1&&hasOnlineCard==0){
  911. layer.confirm('<div class="hgc_inputItem">\
  912. <p>当前考试存在制作模板数据,如果继续使用并保存【在线答题卡】,则会清空制作模板数据,请确认!</p>\
  913. </div>', function(index){
  914. // location.href = newBuildBaseUrl+'/#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  915. location.href = '/vue/index.html#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  916. });
  917. }else{
  918. // location.href = newBuildBaseUrl+'/#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  919. location.href = '/vue/index.html#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  920. }
  921. }else{
  922. // card_type 答题卡类型 0第三方,1知心慧学
  923. // location.href = newBuildBaseUrl+'/#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  924. location.href = '/vue/index.html#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  925. }
  926. },
  927. goEditAnswerSheet:function () {
  928. var newTestFormData = JSON.parse(localStorage.getItem('testFormData')) || {};
  929. var editPrintInfo = JSON.parse(localStorage.getItem('savePrintInfo')) || {};
  930. newTestFormData.editType = 1;
  931. newTestFormData.pdf_url = editPrintInfo.pdf_url?editPrintInfo.pdf_url:'';
  932. newTestFormData.referrerUrl = window.location.href;
  933. newTestFormData.referrerUrl = window.location.href;
  934. //保存第三方临时数据
  935. let upData={
  936. testFormData:newTestFormData,
  937. savePrintInfo:editPrintInfo
  938. }
  939. localStorage.setItem('upDataThreeCard',JSON.stringify(upData));
  940. // $.post('/print/saveOnlineCardTempData',{
  941. // examGroupId:newTestFormData.examGroupId,
  942. // text:JSON.stringify(upData)
  943. // },function(res){
  944. // console.log(res)
  945. // })
  946. // location.href = newBuildBaseUrl+'/#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  947. location.href = '/vue/index.html#/AnswerSheet?exam_group_id='+newTestFormData.examGroupId+'&card_type=0';
  948. },
  949. delTpl:function(tplId,$this){
  950. $.post('/third/delTpl',{third_tpl_id:tplId},function(res){
  951. var result = JSON.parse(res);
  952. if(result.success === 1 && $this){
  953. $this.closest('.tplItem').remove()
  954. $('#tplLength').text(Number($('#tplLength').text() -1))
  955. if(Number($('#tplLength').text())==1){
  956. $('#tplListMsg').hide()
  957. } else{
  958. $('#tplListMsg').show()
  959. }
  960. }
  961. })
  962. },
  963. createSubmit:function(){
  964. var self = this;
  965. //创建试卷
  966. $("body").delegate("#createThirdCard[active='true']", "click", function(e) {
  967. e.preventDefault();
  968. if(localStorage.upDataThreeCard==undefined||localStorage.upDataThreeCard==null){
  969. location.href = '/index.php/third/index'
  970. return false
  971. }
  972. var error=[];
  973. if(error.length == 0){
  974. $("#createThirdCard").attr('active','false');
  975. var data = JSON.parse(localStorage.getItem('testFormData')) || {};
  976. //如果选择关联答题卡的时候
  977. if($('.hgc_leftContent').css('display') === 'block'){
  978. var tplInfo = self.savePrintInfo;
  979. for(var key in tplInfo){
  980. var keyInfo = tplInfo[key];
  981. if(typeof keyInfo === 'object'){
  982. if(key === 'pdfTemplate')continue;
  983. data[key] = JSON.stringify(keyInfo)
  984. }else{
  985. if(key === 'pdfHtml'){
  986. keyInfo = new Blob([keyInfo], {
  987. type: 'text/plain;charset=utf-8'
  988. })
  989. key = 'pdfTemplate'
  990. }
  991. data[key] = keyInfo
  992. }
  993. }
  994. }
  995. var formData = new FormData()
  996. for(var k in data){
  997. if(k === 'pdfTemplate'){
  998. formData.append(k,data[k],'pdfTepmlate.txt')
  999. }else{
  1000. formData.append(k,data[k])
  1001. }
  1002. }
  1003. $.ajax({
  1004. //'//192.168.1.51/index.php/print/saveCardOnline' + loginStatus,
  1005. url:"/index.php/third/insertThirdSheet",
  1006. method: 'POST',
  1007. processData: false,
  1008. contentType: false,
  1009. dataType: 'json',
  1010. data: formData,
  1011. success: function (data) {
  1012. if(data.success === 1){
  1013. self.clearStorage()
  1014. // location.href = data.result;
  1015. location.href = '/index.php/third/index'
  1016. }else {
  1017. layer.msg(data.message);
  1018. self.clearStorage()
  1019. setTimeout(function () {
  1020. location.href = '/index.php/third/index'
  1021. },3000)
  1022. }
  1023. }
  1024. })
  1025. }else{
  1026. layer.msg(error.join(','));
  1027. $("#createThirdCard").attr('active','true');
  1028. }
  1029. });
  1030. },
  1031. editSubmit:function(){
  1032. var self = this;
  1033. $("body").delegate("#createThirdCard[active='true']", "click", function(e) {
  1034. e.preventDefault();
  1035. if(localStorage.upDataThreeCard==undefined||localStorage.upDataThreeCard==null){
  1036. location.href = '/index.php/third/index'
  1037. return false
  1038. }
  1039. var error = [];
  1040. if(error.length == 0){
  1041. $(this).attr("active","false");
  1042. var data = JSON.parse(localStorage.getItem('testFormData')) || {};
  1043. if($('.hgc_leftContent').css('display') === 'block'){
  1044. var tplInfo = self.savePrintInfo;
  1045. for(var key in tplInfo){
  1046. var keyInfo = tplInfo[key];
  1047. if(typeof keyInfo === 'object'){
  1048. if(key === 'pdfTemplate')continue;
  1049. data[key] = JSON.stringify(keyInfo)
  1050. }else{
  1051. if(key === 'pdfHtml'){
  1052. keyInfo = new Blob([keyInfo], {
  1053. type: 'text/plain;charset=utf-8'
  1054. })
  1055. key = 'pdfTemplate'
  1056. }
  1057. data[key] = keyInfo
  1058. }
  1059. }
  1060. }
  1061. var formData = new FormData()
  1062. for(var k in data){
  1063. if(k === 'pdfTemplate'){
  1064. formData.append(k,data[k],'pdfTepmlate.txt')
  1065. }else{
  1066. formData.append(k,data[k])
  1067. }
  1068. }
  1069. $.ajax({
  1070. url:"/index.php/third/insertThirdSheet",
  1071. method: 'POST',
  1072. processData: false,
  1073. contentType: false,
  1074. dataType: 'json',
  1075. data: formData,
  1076. success: function (data) {
  1077. if(data.success === 1){
  1078. // location.href = document.referrer
  1079. location.href = '/index.php/third/index'
  1080. } else {
  1081. layer.msg(data.message);
  1082. setTimeout(function () {
  1083. location.href = '/index.php/third/index'
  1084. },3000)
  1085. }
  1086. }
  1087. })
  1088. }
  1089. });
  1090. },
  1091. createSubmitForMath:function(){
  1092. var self = this;
  1093. $("body").delegate("#createThirdCard[active='true']", "click", function(e) {
  1094. e.preventDefault();
  1095. if(localStorage.upDataThreeCard==undefined||localStorage.upDataThreeCard==null){
  1096. location.href = '/index.php/third/index'
  1097. return false
  1098. }
  1099. var error = [];
  1100. if(error.length == 0){
  1101. $(this).attr("active","false");
  1102. var data = JSON.parse(localStorage.getItem('testFormData')) || {};
  1103. if($('.hgc_leftContent').css('display') === 'block'){
  1104. var tplInfo = self.savePrintInfo;
  1105. for(var key in tplInfo){
  1106. var keyInfo = tplInfo[key];
  1107. if(typeof keyInfo === 'object'){
  1108. if(key === 'pdfTemplate')continue;
  1109. data[key] = JSON.stringify(keyInfo)
  1110. }else{
  1111. if(key === 'pdfHtml'){
  1112. keyInfo = new Blob([keyInfo], {
  1113. type: 'text/plain;charset=utf-8'
  1114. })
  1115. key = 'pdfTemplate'
  1116. }
  1117. data[key] = keyInfo
  1118. }
  1119. }
  1120. }
  1121. // var saveFormData = JSON.parse(localStorage.getItem('testFormData'));
  1122. var formData = new FormData()
  1123. for(var k in data){
  1124. if(k === 'pdfTemplate'){
  1125. formData.append(k,data[k],'pdfTepmlate.txt')
  1126. }else{
  1127. formData.append(k,data[k])
  1128. }
  1129. }
  1130. $.ajax({
  1131. url:"/index.php/third/insertThirdSheet",
  1132. method: 'POST',
  1133. processData: false,
  1134. contentType: false,
  1135. dataType: 'json',
  1136. data: formData,
  1137. success: function (data) {
  1138. if(data.success === 1){
  1139. location.href = '/index.php/third/index'
  1140. // alert('试卷创建成')
  1141. //location.href = document.referrer
  1142. }else {
  1143. layer.msg(data.message);
  1144. setTimeout(function () {
  1145. location.href = '/index.php/third/index'
  1146. },3000)
  1147. }
  1148. }
  1149. })
  1150. }
  1151. });
  1152. },
  1153. }
  1154. hgc_DtkTplModule.init()
  1155. })