myd-wjbj.js 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691
  1. var session = null;
  2. var SubjectId = 0;
  3. var SubjectTitle = '';
  4. var BeginIntro = '';
  5. var EndingIntro = '';
  6. var maxItem = 2;
  7. var QuestionOption = null;
  8. var dataArr = new Array();
  9. $(function(){
  10. SubjectId = QueryString('SubjectId');
  11. if(isEmpty(SubjectId)){
  12. // ComWbj.alertIconNo('提示:','未知问卷ID','warning');
  13. ComWbj.artTips("提示","warning","未知问卷ID",1.5,null);
  14. history.go(-1);
  15. }
  16. init();
  17. $("i[name='ep']").each(function(i){
  18. $(this).click(function(event) {
  19. event.stopPropagation();
  20. });
  21. });
  22. });
  23. function showModel(){//预览
  24. window.location.href = 'myd-wjyl.html?SubjectId='+SubjectId;
  25. }
  26. function nextEdit(){//收集
  27. if(QuestionOption.length < 1){
  28. // ComWbj.alertIconNo('提示:','请先设计问卷题目','warning');
  29. ComWbj.artTips("提示","warning","请先设计问卷题目",1.5,null);
  30. }else
  31. window.location.href = 'myd-wjsj.html?SubjectId='+SubjectId;
  32. }
  33. function QueryString(val) {
  34. var uri = window.location.search;
  35. var re = new RegExp("" +val+ "\=([^\&\?]*)", "ig");
  36. return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
  37. }
  38. //初始化
  39. function init(){
  40. $('#setting3').prev('.mask').hide().end().fadeOut();
  41. $('#setting2').prev('.mask').hide().end().fadeOut();
  42. $('#setting1').prev('.mask').hide().end().fadeOut();
  43. getWJData();
  44. }
  45. function add_dxt(){
  46. $('#areaDiv').html(dxt_ul);
  47. $('#dxt_ul').html(dxt_li);
  48. }
  49. //获取问卷数据
  50. function getWJData(){
  51. var Api = 'survey.SurveyApiImpl.querySubjectById';
  52. var param = {};
  53. param.SubjectId = SubjectId;
  54. var _d = _ajax('../survey/wtbj_querySubjectById.action',param,false);
  55. SubjectTitle = _d.SubjectTitle;
  56. BeginIntro = _d.BeginIntro;
  57. EndingIntro = _d.EndingIntro;
  58. $('#EndingIntro').text(EndingIntro);
  59. $('#BeginIntro').text(BeginIntro);
  60. $('#SubjectTitle').text(SubjectTitle);
  61. initQuestionCount(_d);
  62. initHtml(_d);
  63. }
  64. function updateEndingIntro(o){
  65. if(isLengthTooLong($(o).text(),250,1)){
  66. ComWbj.artTips("提示","warning","结束语字数在1~250之间",1.5,null);
  67. // ComWbj.alertIconNo('提示:','结束语字数在1~250之间','warning');
  68. }else{
  69. o.focus();
  70. var param = {};
  71. param.SubjectId = SubjectId;
  72. param.EndingIntro = $(o).text();
  73. param.OperatorId="10011";
  74. param.OperatorName="admin";
  75. var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false);
  76. $(o).parent().removeClass('editable');
  77. $(o).removeAttr('contenteditable');
  78. }
  79. }
  80. function updateSubjectTitle(o){
  81. if(isLengthTooLong($(o).text(),25,1)){
  82. ComWbj.artTips("提示","warning","标题字数在1~25之间",1.5,null);
  83. // ComWbj.alertIconNo('提示:','标题字数在1~25之间','warning');
  84. }else{
  85. o.focus();
  86. var param = {};
  87. param.SubjectId = SubjectId;
  88. param.SubjectTitle = $(o).text();
  89. param.OperatorId="10011";
  90. param.OperatorName="admin";
  91. var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false);
  92. $(o).parent().removeClass('editable');
  93. $(o).removeAttr('contenteditable');
  94. }
  95. }
  96. function updateBeginIntro(o){
  97. if(isLengthTooLong($(o).text(),250,1)){
  98. ComWbj.artTips("提示","warning","开头语字数在1~250之间",1.5,null);
  99. // ComWbj.alertIconNo('提示:','开头语字数在1~250之间','warning');
  100. }else{
  101. o.focus();
  102. var param = {};
  103. param.SubjectId = SubjectId;
  104. param.BeginIntro = $(o).text();
  105. param.OperatorId="10011";
  106. param.OperatorName="admin";
  107. var _d = _ajax('../survey/wtbj_updateSubjectbegin.action',param,false);
  108. $(o).parent().removeClass('editable');
  109. $(o).removeAttr('contenteditable');
  110. }
  111. }
  112. function add_tx(type){//添加体型
  113. var Api = 'survey.SurveyApiImpl.addDetailQuestion';
  114. var params = {};
  115. params.ContentType = 13;//通用
  116. params.ObjType = 5;//通用
  117. params.QuestType = type;
  118. params.SubjectId = SubjectId;
  119. params.OperatorID = "10011";
  120. params.OperatorName = "admin";
  121. var url = '../survey/wtbj_addDetailQuestion.action';
  122. _ajax(url,params,false);
  123. getWJData();
  124. //location.href="#maodian";
  125. $("html,body").animate({scrollTop: $("#maodian").offset().top}, 1000);
  126. }
  127. function initQuestionCount(d){
  128. QuestionOption = new Array();
  129. dataArr = d.Result;
  130. var _d = dataArr;
  131. var size = _d.length;
  132. if(size > 0){
  133. $('#areaDiv').css('height','auto');
  134. for(var i = 0; i < size; i++){
  135. var p = {};
  136. p.id = _d[i].QuestId;
  137. p.text = _d[i].Question;
  138. QuestionOption.push(p);
  139. }
  140. }
  141. }
  142. function initHtml(d){//初始化页面选题
  143. $('#areaDiv').empty();
  144. dataArr = d.Result;
  145. var _d = dataArr;
  146. var size = _d.length;
  147. if(size > 0){
  148. $('#areaDiv').css('height','auto');
  149. for(var i = 0; i < size; i++){
  150. if(_d[i].QuestType == 1)
  151. {
  152. $('#areaDiv').append(xzt(_d[i],i,1));
  153. }
  154. if(_d[i].QuestType == 2)
  155. {
  156. $('#areaDiv').append(xzt(_d[i],i,2));
  157. }
  158. if(_d[i].QuestType == 3)
  159. {
  160. $('#areaDiv').append(tkt(_d[i],i));
  161. }
  162. if(_d[i].QuestType == 4)
  163. {
  164. $('#areaDiv').append(jzdx(_d[i],i,4));
  165. }
  166. if(_d[i].QuestType == 5)
  167. {
  168. $('#areaDiv').append(jzdx(_d[i],i,5));
  169. }
  170. }
  171. }else{
  172. $('#areaDiv').css('height',300);
  173. }
  174. }
  175. function jzdx(d,index,type){//矩阵单选
  176. var html = '<div QuestId="'+d.QuestId+'" id="div'+d.QuestId+'" class="qa-item-wrap juzhen"><div class="q-tit">';
  177. html += '<span class="q-num">Q'+(index+1)+'</span>'
  178. html += '<div class="q-tit-txt" onblur="updateQuestion(this,'+d.QuestId+')">'+d.Question+'</div>';
  179. if(d.Mustquest == 1){
  180. html += '<span class="f12" style="color:red;">(选填)</span>';
  181. }
  182. // --show---------------------------
  183. html += '</div><div class="a-wrap" id="jzshow'+d.QuestId+'"><div class="mt15 mb25" style="margin-left:31px;">'
  184. html += jz_table(d,type);
  185. html += '</div></div>'
  186. // --edit---------------------------
  187. html += '<div class="a-wrap" id="jzedit'+d.QuestId+'" style="display:none">';
  188. html += initJZQuestionHtml(d,type);
  189. html += initJZQuestionItemHtml(d,type);
  190. html += '</div><div class="qa-edit-tools">';
  191. html += '<i id="i'+d.QuestId+'" class="icon icon-edit mr25" onclick="jzEditPanel('+d.QuestId+')"></i>';
  192. if(type == 4){
  193. html += '<i id="iedit'+d.QuestId+'" class="icon icon-setting mr25" onclick="openEditQuestionPanel2('+d.QuestId+',\''+d.Mustquest+'\')"></i>';
  194. }else
  195. html += '<i id="iedit'+d.QuestId+'" class="icon icon-setting mr25" onclick="openEditQuestionPanel3('+d.QuestId+',\''+d.Mustquest+'\',\''+d.Maxoption+'\',\''+d.Minoption+'\')"></i>';
  196. html += '<i id="iup'+d.QuestId+'" class="icon icon-up mr25" onclick="setJZQuestionUp(this)"></i>';
  197. html += '<i id="idown'+d.QuestId+'" class="icon icon-down mr25" onclick="setJZQuestionDown(this)"></i>';
  198. html += '<i id="idel'+d.QuestId+'" class="icon icon-trash" onclick="matdeleteQuestion('+d.QuestId+')"></i>';
  199. html += '</div></div>';
  200. return html ;
  201. }
  202. function matdeleteQuestion(id){//矩阵删除方法
  203. art.dialog({
  204. id: 'testID',
  205. width: '245px',
  206. height: '109px',
  207. content: '确认要删除?',
  208. lock: true,
  209. button: [{
  210. name: '确定',
  211. callback: function () {
  212. var Api = 'survey.SurveyApiImpl.matdeleteQuestion';
  213. var params = {};
  214. params.QuestId = id;
  215. params.OperatorId="10011";
  216. params.OperatorName="admin";
  217. var url = ' ../survey/wtbj_matdeleteQuestion.action';
  218. var _d = _ajax(url,params,false);
  219. if(_d.Code == 10000){
  220. ComWbj.artTips("提示","warning",_d.Message,1.5,null);
  221. // ComWbj.alertIconNo('提示:',_d.Message,'warning');
  222. getWJData();
  223. return true;
  224. }else{
  225. ComWbj.artTips("提示","warning","添加异常",1.5,null);
  226. // ComWbj.alertIconNo('提示:','添加异常','warning');
  227. return false;
  228. }
  229. }
  230. },{
  231. name: '取消'
  232. }]
  233. });
  234. }
  235. function initJZQuestionHtml(d,type){
  236. var html = '<dl class="juzhen-wrap"><dt>矩阵型</dt><div id="jzdiv'+d.QuestId+'">';
  237. var _d = d.ChildrenMatrixQuestion;
  238. if(_d.length > 0){
  239. for(var i = 0;i<_d.length;i++){
  240. html += '<dd QuestId="'+_d[i].QuestId+'" class="juzhen-opt" id="ddq'+_d[i].QuestId+'">';
  241. html += '<input onblur="updateJZQuestion(this,'+_d[i].QuestId+')" type="text" class="input-text input-text-w500 mr20" value="'+_d[i].Question+'" />';
  242. html += '<i id="'+_d[i].QuestId+'" class="icon icon-top mr15" onclick="setJZChildrenQuestionUp(this)"></i>';
  243. html += '<i id="'+_d[i].QuestId+'" class="icon icon-bottom mr15" onclick="setJZChildrenQuestionDwon(this)"></i>';
  244. html += '<i class="icon icon-del" onclick="delJZQuestionByID('+_d[i].QuestId+')"></i></dd>';
  245. }
  246. }
  247. html += '</div><dd><a href="javascript:;" class="btn btn-w-auto" onclick="addJZQuestion('+d.QuestId+','+type+')">';
  248. html += '<i class="icon icon-add-w"></i>添加</a></dd></dl>';
  249. return html;
  250. }
  251. //添加矩阵问题
  252. function addJZQuestion(id,type){
  253. var name = '矩阵';
  254. var param = {};
  255. param.SubjectId = SubjectId;
  256. param.Question = name;
  257. param.ObjType = 5;
  258. param.MatrixQuestId = id;
  259. param.ContentType = 13;
  260. param.QuestType = type;
  261. param.OperatorId = "10011";
  262. param.OperatorName = "admin";
  263. var url = '../survey/wtbj_addQuestion.action';
  264. var _d = _ajax(url,param,false);
  265. if(!_d.Code == 10000){
  266. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  267. // ComWbj.alertIconNo('提示:','操作异常','warning');
  268. }else{
  269. $('#jzdiv'+id).append(addJZQuestionHtml(_d.QuestId,name));
  270. //加选项
  271. $('input[name="jzitem'+id+'"]').each(function(i){
  272. addJZQuestionItem(_d.QuestId,$(this).val());
  273. });
  274. getWJData();
  275. $('#i'+id).click();
  276. }
  277. }
  278. //添加选项
  279. function addJZQuestionItem(id,name){
  280. var param = {};
  281. param.QuestId = id;
  282. param.ItemCont = name;
  283. param.OperatorId = "10011";
  284. param.OperatorName = "admin";
  285. var url = '../survey/wtbj_addItem.action';
  286. var _d = _ajax(url,param,false);
  287. if(!_d.Code == 10000){
  288. // ComWbj.artTips("提示","warning","操作异常",1.5,null);
  289. // ComWbj.alertIconNo('提示:','操作异常','warning');
  290. }
  291. }
  292. function addJZQuestionHtml(id,name){
  293. var html = '';
  294. html += '<dd QuestId="'+id+'" class="juzhen-opt" id="ddq'+id+'">';
  295. html += '<input onblur="updateJZQuestion(this,'+id+')" type="text" class="input-text input-text-w500 mr20" value="'+name+'" />';
  296. html += '<i id="'+id+'" class="icon icon-top mr15" onclick="setJZChildrenQuestionUp(this)"></i>';
  297. html += '<i id="'+id+'" class="icon icon-bottom mr15" onclick="setJZChildrenQuestionDwon(this)"></i>';
  298. html += '<i class="icon icon-del" onclick="delJZQuestionByID('+id+')"></i></dd>';
  299. return html;
  300. }
  301. //删除问题
  302. function delJZQuestionByID(id){
  303. if($('#ddq'+id).parent().children().length <= 1){
  304. ComWbj.artTips("提示","warning","矩阵选项不能全部删除",1.5,null);
  305. // ComWbj.alertIconNo('提示:','矩阵选项不能全部删除','warning');
  306. return ;
  307. }else{
  308. var Api = 'survey.SurveyApiImpl.deleteQuestion';
  309. var params = {};
  310. params.QuestId = id;
  311. var url = '../survey/wtbj_deleteQuestion.action';
  312. var _d = _ajax(url,params,false);
  313. if(_d.Code != 10000){
  314. ComWbj.artTips("提示","warning","添加异常",1.5,null);
  315. // ComWbj.alertIconNo('提示:','添加异常','warning');
  316. return false;
  317. }else{
  318. $("#ddq"+id).remove();
  319. }
  320. }
  321. }
  322. //修改选题
  323. function updateJZQuestion(o,id){
  324. if(!isLengthTooLong(o.value,50,1)){
  325. var params={};
  326. params.QuestId = id;
  327. params.Question = o.value;
  328. params.OperatorId = "10011";
  329. params.OperatorName = "admin";
  330. var url = '../survey/wtbj_updateQuest.action';
  331. var _d = _ajax(url,params,false);
  332. if(!_d.Code == 10000){
  333. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  334. // ComWbj.alertIconNo('提示:','操作异常','warning');
  335. }
  336. }else{
  337. ComWbj.artTips("提示","warning","矩阵题目字数在1~50之间",1.5,null);
  338. // ComWbj.alertIconNo('提示:','矩阵题目字数在1~50之间','warning');
  339. }
  340. }
  341. //选项上移
  342. function setJZChildrenQuestionUp(o){
  343. var id = o.id;
  344. var p_id = $(o).parent().prev().attr('QuestId');
  345. if(p_id == undefined){
  346. ComWbj.artTips("提示","warning","已经是第一题",1.5,null);
  347. // ComWbj.alertIconNo('提示:','已经是第一题','warning');
  348. return ;
  349. }
  350. var param={};
  351. param.QuestId1 = id;
  352. param.QuestId2 = p_id;
  353. param.OperatorId = "10011";
  354. param.OperatorName = "admin";
  355. var url = '../survey/wtbj_exchangeQuestionSort.action';
  356. var _d = _ajax(url,param,false);
  357. $("#ddq"+id).insertBefore("#ddq"+p_id);
  358. if(!_d.Code == 10000){
  359. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  360. // ComWbj.alertIconNo('提示:','操作异常','warning');
  361. }
  362. }
  363. //选项上移
  364. function setJZChildrenQuestionDwon(o){
  365. var id = o.id;
  366. var n_id = $(o).parent().next().attr('QuestId');
  367. if(n_id == undefined){
  368. ComWbj.artTips("提示","warning","已经是最后一题",1.5,null);
  369. // ComWbj.alertIconNo('提示:','已经是最后一题','warning');
  370. return ;
  371. }
  372. var param={};
  373. param.QuestId1 = id;
  374. param.QuestId2 = n_id;
  375. param.OperatorId = "10011";
  376. param.OperatorName = "admin";
  377. var url = '../survey/wtbj_exchangeQuestionSort.action';
  378. var _d = _ajax(url,param,false);
  379. $("#ddq"+n_id).insertBefore("#ddq"+id);
  380. if(!_d.Code == 10000){
  381. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  382. // ComWbj.alertIconNo('提示:','操作异常','warning');
  383. }
  384. }
  385. //选项上移
  386. function setJZQuestionItemUp(o){
  387. var id = o.id;
  388. var p_id = $(o).parent().prev().attr('QuestId');
  389. if(p_id == undefined){
  390. ComWbj.artTips("提示","warning","已经是第一个选项",1.5,null);
  391. // ComWbj.alertIconNo('提示:','已经是第一个选项','warning');
  392. return ;
  393. }
  394. var param={};
  395. param.ItemId1 = id;
  396. param.ItemId2 = p_id;
  397. param.OperatorId = "10011";
  398. param.OperatorName = "admin";
  399. var url = '../survey/wtbj_exchangeQuestionItemSort.action';
  400. $("#"+id).insertBefore("#"+p_id);
  401. var _d = _ajax(url,param,false);
  402. if(!_d.Code == 10000){
  403. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  404. // ComWbj.alertIconNo('提示:','操作异常','warning');
  405. }
  406. }
  407. //选项下移
  408. function setJZQuestionItemDown(o){
  409. var id = $(o).parent().parent().parent().attr('id');
  410. var n_id = $(o).parent().parent().parent().next().attr('id');
  411. if(n_id == undefined){
  412. ComWbj.artTips("提示","warning","已经是最后一个选项",1.5,null);
  413. // ComWbj.alertIconNo('提示:','已经是最后一个选项','warning');
  414. return ;
  415. }
  416. //var p_id = $(o).parent().parent().parent().prev().attr('id');
  417. $("#"+n_id).insertBefore("#"+id);
  418. var param={};
  419. param.ItemId1 = id;
  420. param.ItemId2 = n_id;
  421. param.OperatorId = "10011";
  422. param.OperatorName = "admin";
  423. var url = '../survey/wtbj_exchangeQuestionItemSort.action';
  424. var _d = _ajax(url,param,false);
  425. if(!_d.Code == 10000){
  426. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  427. // ComWbj.alertIconNo('提示:','操作异常','warning');
  428. }
  429. }
  430. function initJZQuestionItemHtml(d){
  431. var html = '<dl class="juzhen-wrap"><dt>选项</dt><div id="jzitemdiv'+d.QuestId+'">';
  432. var _d = d.ChildrenMatrixQuestion;
  433. var ids = '';
  434. var size = 0;
  435. if(_d.length > 0){
  436. var data = _d[0].MatrixQuestItems;
  437. for(var i = 0;i<data.length;i++){
  438. size ++;
  439. }
  440. }
  441. if(size > 0){
  442. for(var j = 0;j<size;j++){
  443. var ids = '';
  444. for(var i = 0;i<_d.length;i++){
  445. var data = _d[i].MatrixQuestItems[j];
  446. if(isEmpty(data)){
  447. data = {};
  448. data.ItemId = 0;
  449. }
  450. if(i == 0){
  451. ids = data.ItemId;
  452. }else ids += ','+data.ItemId;
  453. }
  454. var ids1 = replaceAll(ids,',','-');
  455. html += '<dd ids="'+ids1+'" class="juzhen-opt" id="ddi'+ids1+'" >';
  456. html += '<input onblur="updateJZQuestionItem(this,\''+ids+'\')" name="jzitem'+d.QuestId+'" type="text" class="input-text input-text-w500 mr20" value="'+_d[0].MatrixQuestItems[j].ItemCont+'" />';
  457. html += '<i id="'+ids1+'" class="icon icon-top mr15" onclick="setJZChildrenQuestionItemUp(this)"></i>';
  458. html += '<i id="'+ids1+'" class="icon icon-bottom mr15" onclick="setJZChildrenQuestionItemDwon(this)"></i>';
  459. html += '<i class="icon icon-del" onclick="deleteQuestionItems(this,\''+ids+'\')"></i></dd>';
  460. }
  461. }
  462. html += '</div><dd><a href="javascript:;" class="btn btn-w-auto" onclick="addJZQuestionItemHtml(\''+d.QuestId+'\')">';
  463. html += '<i class="icon icon-add-w"></i>添加</a><a href="javascript:;" class="btn absolute" style="right:15px;bottom:17px" onclick="endEditPanel('+d.QuestId+')">保存</a></dd></dl>';
  464. return html;
  465. }
  466. function setJZChildrenQuestionItemUp(o){//矩阵选项位移
  467. var id = o.id;
  468. var p_id = $(o).parent().prev().attr('ids');
  469. if(p_id == undefined){
  470. ComWbj.artTips("提示","warning","已经是第一个选项",1.5,null);
  471. // ComWbj.alertIconNo('提示:','已经是第一个选项','warning');
  472. return ;
  473. }
  474. var param={};
  475. param.ItemIds1 = replaceAll(id,'-',',');
  476. param.ItemIds2 = replaceAll(p_id,'-',',');
  477. param.OperatorId = "10011";
  478. param.OperatorName = "admin";
  479. var url = '../survey/wtbj_exchangeMatQuestionItemSorts.action';
  480. var _d = _ajax(url,param,false);
  481. $("#ddi"+id).insertBefore("#ddi"+p_id);
  482. if(!_d.Code == 10000){
  483. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  484. // ComWbj.alertIconNo('提示:','操作异常','warning');
  485. }
  486. }
  487. function setJZChildrenQuestionItemDwon(o){//矩阵选项位移
  488. var id = o.id;
  489. var n_id = $(o).parent().next().attr('ids');
  490. if(n_id == undefined) {
  491. ComWbj.artTips("提示","warning","已经是最后一个选项",1.5,null);
  492. // ComWbj.alertIconNo('提示:','已经是最后一个选项','warning');
  493. return ;
  494. }
  495. var param={};
  496. param.ItemIds1 = replaceAll(id,'-',',');
  497. param.ItemIds2 = replaceAll(n_id,'-',',');
  498. param.OperatorId = "10011";
  499. param.OperatorName = "admin";
  500. var url = '../survey/wtbj_exchangeMatQuestionItemSorts.action';
  501. var _d = _ajax(url,param,false);
  502. $("#ddi"+n_id).insertBefore("#ddi"+id);
  503. if(!_d.Code == 10000){
  504. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  505. // ComWbj.alertIconNo('提示:','操作异常','warning');
  506. }
  507. }
  508. function addJZQuestionItemHtml(id){//新增矩阵选项
  509. var name = '选项';
  510. //新增多个矩阵
  511. var d = $('#jzdiv'+id).children();
  512. if(d.length < 1){
  513. ComWbj.artTips("提示","warning","请先添加矩阵问题,后再添加选项",1.5,null);
  514. // ComWbj.alertIconNo('提示:','请先添加矩阵问题,后再添加选项','warning');
  515. return ;
  516. }else{
  517. d.each(function(){
  518. addJZQuestionItem($(this).attr('QuestId'),name);
  519. });
  520. getWJData();
  521. $('#i'+id).click();
  522. }
  523. }
  524. //修改选题
  525. function updateJZQuestionItem(o,ids){
  526. if(!isLengthTooLong(o.value,50,1)){
  527. var arr_ids = ids.split(',');
  528. if(arr_ids.length > 0 ){
  529. for(var i = 0;i<arr_ids.length;i++){
  530. updateJZQuestionItemTile(arr_ids[i],o.value);
  531. }
  532. }
  533. }else{
  534. ComWbj.artTips("提示","warning","矩阵选项字数在1~50之间",1.5,null);
  535. // ComWbj.alertIconNo('提示:','矩阵选项字数在1~50之间','warning');
  536. }
  537. }
  538. //修改选项
  539. function updateJZQuestionItemTile(id,name){
  540. var param={};
  541. param.ItemCont = name;
  542. param.OperatorId = "10011";
  543. param.OperatorName = "admin";
  544. param.ItemId = id;
  545. var url = '../survey/wtbj_upateItem.action';
  546. var _d = _ajax(url,param,false);
  547. if(!_d.Code == 10000){
  548. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  549. // ComWbj.alertIconNo('提示:','操作异常','warning');
  550. }
  551. }
  552. function deleteQuestionItems(o,ids){//删除多项选项
  553. var ids1 = replaceAll(ids,',','-');
  554. if($('#ddi'+ids1).parent().children().length <=1){
  555. ComWbj.artTips("提示","warning","矩阵选项不能全部被删除",1.5,null);
  556. // ComWbj.alertIconNo('提示:','矩阵选项不能全部被删除','warning');
  557. return ;
  558. }else{
  559. var params={};
  560. params.ItemIds = ids;
  561. params.OperatorId = "10011";
  562. params.OperatorName = "admin";
  563. var url = '../survey/wtbj_deleteQuestionItems.action';
  564. var _d = _ajax(url,params,false);
  565. if(_d.Code != 10000){
  566. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  567. // ComWbj.alertIconNo('提示:','操作异常','warning');
  568. return true;
  569. }else{
  570. $(o).parent().remove();
  571. }
  572. }
  573. }
  574. function jz_table(d,type){
  575. var table = '<table class="tb tb-border">';
  576. var _d = d.ChildrenMatrixQuestion;
  577. for(var i = 0 ;i<_d.length;i++){
  578. if(i == 0){
  579. table +='<tr><th width="125" ></th>';
  580. for(var j = 0 ;j<_d[i].MatrixQuestItems.length;j++){
  581. table +='<th width="220" name="th'+d.QuestId+'">'+_d[i].MatrixQuestItems[j].ItemCont+'</th>';
  582. }
  583. table +='</tr>';
  584. table +='<tr><th width="125">'+_d[i].Question+'</th>';
  585. for(var j = 0 ;j<_d[i].MatrixQuestItems.length;j++){
  586. if(type == 4){
  587. table +='<td><input type="radio" name="checkbox1" value="" /></td>';
  588. }else
  589. table +='<td><input type="checkbox" name="checkbox1" value="" /></td>';
  590. }
  591. table +='</tr>';
  592. }else{
  593. table +='<tr><th width="125">'+_d[i].Question+'</th>';
  594. for(var j = 0 ;j<_d[i].MatrixQuestItems.length;j++){
  595. if(type == 4){
  596. table +='<td><input type="radio" name="checkbox1" value="" /></td>';
  597. }else
  598. table +='<td><input type="checkbox" name="checkbox1" value="" /></td>';
  599. }
  600. table +='</tr>';
  601. }
  602. }
  603. return table+='</table>';
  604. }
  605. function tkt(d,index){//填空题
  606. var html = '<div QuestId="'+d.QuestId+'" id="div'+d.QuestId+'" class="qa-item-wrap"><div class="q-tit">';
  607. html += '<span class="q-num">Q'+(index+1)+'</span>';
  608. html += '<div class="q-tit-txt" onblur="updateQuestion(this,'+d.QuestId+')">'+d.Question+'</div>';
  609. if(d.Mustquest == 1){
  610. html += '<span class="f12" style="color:red;">(选填)</span>';
  611. }
  612. html += '</div><div class="a-wrap"><div class="mt15" style="margin-left:31px;">';
  613. html += '<textarea name="" id="" class="textarea textarea-w600"></textarea>';
  614. html += '</div><div class="ml30 mt20" id="btn'+d.QuestId+'" style="display:none">';
  615. html += '<a href="javascript:;" class="btn absolute" style="right:15px;bottom:17px" onclick="endEditPanel('+d.QuestId+')">保存</a>';
  616. html += '</div></div>';
  617. html += '<div class="qa-edit-tools"><i id="i'+d.QuestId+'" class="icon icon-edit mr25" onclick="editPanel('+d.QuestId+')"></i>';
  618. html += '<i id="iedit'+d.QuestId+'" class="icon icon-setting mr25" onclick="openEditQuestionPanel2('+d.QuestId+',\''+d.Mustquest+'\')"></i>';
  619. html += '<i id="iup'+d.QuestId+'" class="icon icon-up mr25" onclick="setQuestionUp(this)"></i>';
  620. html += '<i id="idown'+d.QuestId+'" class="icon icon-down mr25" onclick="setQuestionDown(this)"></i>';
  621. html += '<i id="idel'+d.QuestId+'" class="icon icon-trash" onclick="delQuestionByID('+d.QuestId+')"></i>';
  622. html += '</div></div>';
  623. return html ;
  624. }
  625. //选择题
  626. function xzt(d,index,type){
  627. var _d = d.SvQuestionItems;
  628. var li = getDxtLis(_d,type);
  629. var ul = getDxtUL(d,index,li,type);
  630. return ul;
  631. }
  632. //删除问题
  633. function delQuestionByID(id){
  634. art.dialog({
  635. id: 'testID',
  636. width: '245px',
  637. height: '109px',
  638. //content: '您要删除问卷“'+name+'”吗?注意:删除后无法恢复',
  639. content: '您要删除该问题吗?注意:删除后无法恢复',
  640. lock: true,
  641. button: [{
  642. name: '确定',
  643. callback: function () {
  644. var Api = 'survey.SurveyApiImpl.deleteQuestion';
  645. var params = {};
  646. params.QuestId = id;
  647. params.OperatorId="10011";
  648. params.OperatorName="admin";
  649. var url = '../survey/wtbj_deleteQuestion.action';
  650. var _d = _ajax(url,params,false);
  651. if(_d.Code == 10000){
  652. ComWbj.artTips("提示","succeed",_d.Message,1.5,null);
  653. // ComWbj.alertIconNo('提示:',_d.Message,'warning');
  654. getWJData();
  655. return true;
  656. }else{
  657. ComWbj.artTips("提示","warning","添加异常",1.5,null);
  658. // ComWbj.alertIconNo('提示:','添加异常','warning');
  659. return false;
  660. }
  661. }
  662. },{
  663. name: '取消'
  664. }]
  665. });
  666. // art.dialog({
  667. // id: 'testID',
  668. // width: '245px',
  669. // height: '109px',
  670. // content: '确认要删除?',
  671. // lock: true,
  672. // button: [{
  673. // name: '确定',
  674. // callback: function () {
  675. // var Api = 'survey.SurveyApiImpl.deleteQuestion';
  676. // var params = {};
  677. // params.QuestId = id;
  678. // var url = '../survey/wtbj_deleteQuestion.action';
  679. // var _d = _ajax(url,params,false);
  680. // if(_d.Code == 10000){
  681. // ComWbj.artTips("提示","warning","_d.Message",1.5,null);
  682. //// ComWbj.alertIconNo('提示:',_d.Message,'warning');
  683. // getWJData();
  684. // return true;
  685. // }else{
  686. // ComWbj.artTips("提示","warning","添加异常",1.5,null);
  687. //// ComWbj.alertIconNo('提示:','添加异常','warning');
  688. // return false;
  689. // }
  690. // }
  691. // },{
  692. // name: '取消'
  693. // }]
  694. // });
  695. }
  696. function getDxtUL(d,index,li,type){
  697. var dxt_ul = '<div class="qa-item-wrap" QuestId="'+d.QuestId+'" id="div'+d.QuestId+'">';
  698. dxt_ul += '<div class="q-tit"><span class="q-num" id="queueno">Q'+(index+1)+'</span>';
  699. dxt_ul += '<div class="q-tit-txt" onblur="updateQuestion(this,'+d.QuestId+')">'+d.Question+'</div>';
  700. if(d.Mustquest == 1){
  701. dxt_ul += '<span class="f12" style="color:red;">(选填)</span>';
  702. }
  703. dxt_ul += '</div><div class="a-wrap"><ul class="radio-options" id="ul'+d.QuestId+'">'+li+'</ul>';
  704. dxt_ul += '<div class="ml30 mt20" id="btn'+d.QuestId+'" style="display:none">';
  705. dxt_ul += '<a href="javascript:;" class="btn btn-w-auto" onclick="addQuestionItem('+d.QuestId+','+d.QuestType+')"> ';
  706. dxt_ul += '<i class="icon icon-add-w"></i>添加</a> ';
  707. dxt_ul += '<a href="javascript:;" class="btn absolute" style="right:15px;bottom:17px" onclick="endEditPanel('+d.QuestId+')">保存</a>';
  708. dxt_ul += '</div></div><div class="qa-edit-tools">';
  709. dxt_ul += '<i id="i'+d.QuestId+'" class="icon icon-edit mr25" onclick="editPanel('+d.QuestId+')"></i>';
  710. if(type == 1){
  711. dxt_ul += '<i id="iedit'+d.QuestId+'" class="icon icon-setting mr25" onclick="openEditQuestionPanel('+d.QuestId+',\''+d.Mustquest+'\')"></i>';
  712. }else
  713. dxt_ul += '<i id="iedit'+d.QuestId+'" class="icon icon-setting mr25" onclick="openEditQuestionPanel1('+d.QuestId+',\''+d.Mustquest+'\',\''+d.Maxoption+'\',\''+d.Minoption+'\')"></i>';
  714. dxt_ul += '<i id="iup'+d.QuestId+'" class="icon icon-up mr25" onclick="setQuestionUp(this)"></i>';
  715. dxt_ul += '<i id="idown'+d.QuestId+'" class="icon icon-down mr25" onclick="setQuestionDown(this)"></i>';
  716. dxt_ul += '<i id="idel'+d.QuestId+'" class="icon icon-trash" onclick="delQuestionByID('+d.QuestId+')"></i>';
  717. dxt_ul += '</div></div>';
  718. return dxt_ul;
  719. }
  720. //编辑单选题
  721. function openEditQuestionPanel(id,mid){
  722. $('#setting3').prev('.mask').show().end().fadeIn();
  723. $('#dxtFlowDiv').children().eq(0).nextAll().remove();
  724. initSelectModelDate(id);
  725. $('#setting3_questionID').val(id);
  726. setPopAlign('setting3');
  727. if(isEmpty(mid) || mid == 0){
  728. $('#setting3_dxt_noAnswer').removeAttr('checked');
  729. }else $('#setting3_dxt_noAnswer').attr('checked','checked');
  730. initCurrentItemFolw(id);
  731. }
  732. //编辑多选题
  733. function openEditQuestionPanel1(id,mid,mor,les){
  734. $('#setting2').prev('.mask').show().end().fadeIn();
  735. $('#setting2_questionID').val(id);
  736. $('#setting2_count').val($('#ul'+id+' li').length);
  737. if(parseInt(mor) > 0){
  738. $('#setting2_mor').val(mor);
  739. }else $('#setting2_mor').val('');
  740. if(parseInt(les) > 0){
  741. $('#setting2_les').val(les);
  742. }else $('#setting2_les').val('');
  743. setPopAlign('setting2');
  744. if(isEmpty(mid) || mid == 0){
  745. $('#setting2_dxt_noAnswer').removeAttr('checked');
  746. }else $('#setting2_dxt_noAnswer').attr('checked','checked');
  747. }
  748. //编辑矩阵多选题
  749. function openEditQuestionPanel3(id,mid,mor,les){
  750. $('#setting2').prev('.mask').show().end().fadeIn();
  751. $('#setting2_questionID').val(id);
  752. $('#setting2_count').val($('th[name="th'+id+'"]').length);
  753. if(parseInt(mor) > 0){
  754. $('#setting2_les').val(les);
  755. }else $('#setting2_les').val('');
  756. if(parseInt(les) > 0){
  757. $('#setting2_mor').val(mor);
  758. }else $('#setting2_mor').val('');
  759. setPopAlign('setting2');
  760. if(isEmpty(mid) || mid == 0){
  761. $('#setting2_dxt_noAnswer').removeAttr('checked');
  762. }else $('#setting2_dxt_noAnswer').attr('checked','checked');
  763. }
  764. function openEditQuestionPanel2(id,mid){//编辑
  765. $('#setting1').prev('.mask').show().end().fadeIn();
  766. $('#setting1_questionID').val(id);
  767. setPopAlign('setting1');
  768. if(isEmpty(mid) || mid == 0){
  769. $('#setting1_dxt_noAnswer').removeAttr('checked');
  770. }else $('#setting1_dxt_noAnswer').attr('checked','checked');
  771. }
  772. function saveNoAnswerSet(){
  773. var type = 0;
  774. if($('#setting1_dxt_noAnswer').attr('checked') == 'checked'){
  775. type = 1;
  776. }
  777. var id = $('#setting1_questionID').val();
  778. var param={};
  779. param.QuestId = id;
  780. param.Mustquest = type;
  781. param.OperatorId = "10011";
  782. param.OperatorName = "admin";
  783. var url = '../survey/wtbj_updateQuest.action';
  784. var _d = _ajax(url,param,false);
  785. if(!_d.Code == 10000){
  786. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  787. // ComWbj.alertIconNo('提示:','操作异常','warning');
  788. }else {
  789. ComWbj.artTips("提示","succeed",_d.Message,1.5,null);
  790. // ComWbj.alertIconNo('提示:',_d.Message,'succeed');
  791. $('#setting1').prev('.mask').hide().end().fadeOut();
  792. getWJData();
  793. }
  794. }
  795. function saveMoreAnswerSet(){//保存多选题设置
  796. // var les = parseInt($('#setting2_les').val());
  797. // var mor = parseInt($('#setting2_mor').val());
  798. // var num = parseInt($('#setting2_count').val());
  799. var les = $('#setting2_les').val();
  800. var mor = $('#setting2_mor').val();
  801. var num = $('#setting2_count').val();
  802. var f = false;
  803. var type = 0;
  804. if($('#setting2_dxt_noAnswer').attr('checked') == 'checked'){
  805. type = 1;
  806. }
  807. if (type!=1) {
  808. if(!isEmpty(les)){
  809. if(les > num || les < 1){
  810. ComWbj.artTips("提示","warning","最少选择数量必须小于选项数,最少为“1”",1.5,null);
  811. // ComWbj.alertIconNo('提示:','最少选择数量必须小于题数,最少为“1”','warning');
  812. return ;
  813. }
  814. f = true;
  815. }else if(les == 0){
  816. ComWbj.artTips("提示","warning","最少选择数量必须小于选项数,最少为“1”",1.5,null);
  817. // ComWbj.alertIconNo('提示:','最少选择数量必须小于题数,最少为“1”','warning');
  818. return ;
  819. }
  820. if(!isEmpty(mor)){
  821. if(mor > num || mor < 1){
  822. ComWbj.artTips("提示","warning","最多选择数量不能超过选项数,最少为“1”",1.5,null);
  823. // ComWbj.alertIconNo('提示:','最多选择数量不能超过题数,最少为“1”','warning');
  824. return ;
  825. }
  826. }else if(les == 0){
  827. ComWbj.artTips("提示","warning","最多选择数量不能超过选项数,最少为“1”",1.5,null);
  828. // ComWbj.alertIconNo('提示:','最多选择数量不能超过题数,最少为“1”','warning');
  829. return ;
  830. }
  831. if(f){
  832. if(les > mor){
  833. ComWbj.artTips("提示","warning","最多选择数量不能少于最少选择数量",1.5,null);
  834. // ComWbj.alertIconNo('提示:','最多选择数量不能少于最少选择数量','warning');
  835. return ;
  836. }
  837. }
  838. }
  839. var id = $('#setting2_questionID').val();
  840. setQuestionMustquest(id,type);
  841. setMMoption(les,mor,id);
  842. }
  843. function setMMoption(Minoption,Maxoption,id){//设置选项数量
  844. var params={};
  845. params.Minoption = Minoption;
  846. params.Maxoption = Maxoption;
  847. params.QuestId = id;
  848. params.OperatorId = "10011";
  849. params.OperatorName = "admin";
  850. var url = '../survey/wtbj_updateQuest.action';
  851. var _d = _ajax(url,params,false);
  852. if(!_d.Code == 10000){
  853. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  854. // ComWbj.alertIconNo('提示:','操作异常','warning');
  855. }else {
  856. ComWbj.artTips("提示","warning",_d.Message,1.5,null);
  857. // ComWbj.alertIconNo('提示:',_d.Message,'succeed');
  858. $('#setting2').prev('.mask').hide().end().fadeOut();
  859. getWJData();
  860. }
  861. }
  862. function initSelectModelDate(id){
  863. var options = '<option value="0">-请选择-</option>';
  864. var num = 0;
  865. $.each(dataArr,function(i,it){
  866. if(it.QuestId == id){
  867. for(var j=0;j<it.SvQuestionItems.length;j++){
  868. num++;
  869. options += '<option value="'+it.SvQuestionItems[j].ItemId+'">'
  870. +it.SvQuestionItems[j].ItemCont+'</option>';
  871. }
  872. }
  873. })
  874. $('#setting3_itemCount').val(num);
  875. $('#selectModel').children().eq(0).empty().append(options);
  876. options = '<option value="0">-请选择-</option>';
  877. var num = 0;
  878. $.each(QuestionOption,function(i,it){
  879. if(id == it.id){
  880. num = i;
  881. }
  882. })
  883. $.each(QuestionOption,function(i,it){
  884. if(id != it.id){
  885. if(i > num){
  886. options += '<option value="'+it.id+'">Q'+(i+1)+'</option>';
  887. }
  888. }
  889. })
  890. options += '<option value="10">结束(计入结果)</option>';
  891. options += '<option value="11">结束(不计入结果)</option>';
  892. $('#selectModel').children().eq(1).empty().append(options);
  893. }
  894. function initCurrentItemFolw(id){//初始化 流向选项信息
  895. var ids = '';
  896. var obj = null;
  897. $.each(dataArr,function(i,o){
  898. if(o.QuestId == id){
  899. obj = o.SvQuestionItems;
  900. }
  901. });
  902. for(var i = 0;i<obj.length;i++){
  903. if(!isEmpty(obj[i].JumpQuest)){
  904. initSelectHtml(id,obj[i].JumpQuest,obj[i].ItemId);
  905. if(ids == ''){
  906. ids += obj[i].ItemId;
  907. }else ids += ','+obj[i].ItemId;
  908. }
  909. }
  910. $('#setting3_allFlowsItemIds').val(ids);
  911. }
  912. function initSelectHtml(id,v,v1){
  913. var html = '<div class="f12 mt15">';
  914. html += '如果本题选项中<select name="dxtSelect" id="" class="inp-sel ml10 mr10" style="width:120px;">';
  915. html += initQuestionItemOption(id,v1);
  916. html += '</select>则跳转到';
  917. html += '<select name="dxtSelectLink" id="" class="inp-sel ml10 mr10" style="width:120px;">';
  918. html += initQuestionOption(id,v);
  919. html += '</select><i class="icon icon-del" onclick="delDxtSelect(this)"></i></div>';
  920. $("#dxtFlowDiv").append(html);
  921. }
  922. function initQuestionOption(id,v){//初始化选题下拉
  923. options = '<option value="0">-请选择-</option>';
  924. var num = 0;
  925. $.each(QuestionOption,function(i,it){
  926. if(id == it.id){
  927. num = i;
  928. }
  929. })
  930. $.each(QuestionOption,function(i,it){
  931. if(id != it.id){
  932. if(v && v == it.id){
  933. options += '<option selected="selected" value="'+it.id+'">Q'+(i+1)+'</option>';
  934. }else{
  935. if(i > num){
  936. options += '<option value="'+it.id+'">Q'+(i+1)+'</option>';
  937. }
  938. }
  939. }
  940. })
  941. if(v == 10){
  942. options += '<option selected="selected" value="10">结束(计入结果)</option>';
  943. options += '<option value="11">结束(不计入结果)</option>';
  944. }else if(v == 11){
  945. options += '<option value="10">结束(计入结果)</option>';
  946. options += '<option selected="selected" value="11">结束(不计入结果)</option>';
  947. }else{
  948. options += '<option value="10">结束(计入结果)</option>';
  949. options += '<option value="11">结束(不计入结果)</option>';
  950. }
  951. return options;
  952. }
  953. function initQuestionItemOption(id,v){//初始化选项下拉
  954. var options = '<option value="0">-请选择-</option>';
  955. var num = 0;
  956. $.each(dataArr,function(i,it){
  957. if(it.QuestId == id){
  958. for(var j=0;j<it.SvQuestionItems.length;j++){
  959. num++;
  960. if(v && v == it.SvQuestionItems[j].ItemId){
  961. options += '<option selected="selected" value="'+it.SvQuestionItems[j].ItemId+'">'
  962. +it.SvQuestionItems[j].ItemCont+'</option>';
  963. }else
  964. options += '<option value="'+it.SvQuestionItems[j].ItemId+'">'
  965. +it.SvQuestionItems[j].ItemCont+'</option>';
  966. }
  967. }
  968. })
  969. return options;
  970. }
  971. function addDxtQuestionFlowSelect(){//添加单选题流向
  972. var num = $('#setting3_itemCount').val();
  973. if($("#dxtFlowDiv").children().length >= (parseInt(num)+1)){
  974. ComWbj.artTips("提示","warning","跳转设置数量不能超过答案选项总数",1.5,null);
  975. // ComWbj.alertIconNo('提示:','跳转设置数量不能超过答案选项总数','warning');
  976. return;
  977. }else{
  978. var html = $('#selectModel').html();
  979. $("#dxtFlowDiv").append('<div class="f12 mt15">'+html+'</div>');
  980. }
  981. }
  982. function replaceAll(s,s1,s2){//替换全部
  983. s = s.replace(s1,s2);
  984. if(s == s.replace(s1,s2)){
  985. return s;
  986. }else return replaceAll(s,s1,s2);
  987. }
  988. function addQuestionFlow(sl1,sl2){//添加答案逻辑流向
  989. var param={};
  990. param.ItemId = id;
  991. param.NextQuestId = id;
  992. param.OperatorId = "10011";
  993. param.OperatorName = "admin";
  994. var del_id = obj.attr('id');
  995. var url = '../survey/wtbj_addQuestionFlow.action';
  996. var _d = _ajax(url,param,false);
  997. $("#"+del_id).remove();
  998. if(!_d.Code == 10000){
  999. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1000. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1001. }
  1002. }
  1003. //选项上移
  1004. function setQuestionUp(o){
  1005. var id = $(o).parent().parent().attr('QuestId');
  1006. var p_id = $(o).parent().parent().prev().attr('QuestId');
  1007. if(p_id == undefined){
  1008. ComWbj.artTips("提示","warning","已经是第一题",1.5,null);
  1009. // ComWbj.alertIconNo('提示:','已经是第一题','warning');
  1010. return ;
  1011. }
  1012. var param={};
  1013. param.QuestId1 = id;
  1014. param.QuestId2 = p_id;
  1015. param.OperatorId = "10011";
  1016. param.OperatorName = "admin";
  1017. var url = '../survey/wtbj_exchangeQuestionSort.action';
  1018. var _d = _ajax(url,param,false);
  1019. $("#div"+id).insertBefore("#div"+p_id);
  1020. if(!_d.Code == 10000){
  1021. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1022. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1023. }
  1024. getWJData();
  1025. }
  1026. //选项上移
  1027. function setJZQuestionUp(o){
  1028. var id = $(o).parent().parent().attr('QuestId');
  1029. var p_id = $(o).parent().parent().prev().attr('QuestId');
  1030. if(p_id == undefined){
  1031. ComWbj.artTips("提示","warning","已经是第一题",1.5,null);
  1032. // ComWbj.alertIconNo('提示:','已经是第一题','warning');
  1033. return ;
  1034. }
  1035. var param={};
  1036. param.QuestId1 = id;
  1037. param.QuestId2 = p_id;
  1038. param.OperatorId = "10011";
  1039. param.OperatorName = "admin";
  1040. var url = '../survey/wtbj_exchangeQuestionSort.action';
  1041. var _d = _ajax(url,param,false);
  1042. $("#div"+id).insertBefore("#div"+p_id);
  1043. if(!_d.Code == 10000){
  1044. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1045. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1046. }
  1047. }
  1048. //选项下移
  1049. function setJZQuestionDown(o){
  1050. var id = $(o).parent().parent().attr('QuestId');
  1051. var n_id = $(o).parent().parent().next().attr('QuestId');
  1052. if(n_id == undefined){
  1053. ComWbj.artTips("提示","warning","已经是最后一题",1.5,null);
  1054. // ComWbj.alertIconNo('提示:','已经是最后一题','warning');
  1055. return ;
  1056. }
  1057. var param={};
  1058. param.QuestId1 = id;
  1059. param.QuestId2 = n_id;
  1060. param.OperatorId = "10011";
  1061. param.OperatorName = "admin";
  1062. var url = '../survey/wtbj_exchangeQuestionSort.action';
  1063. var _d = _ajax(url,param,false);
  1064. $("#div"+n_id).insertBefore("#div"+id);
  1065. if(!_d.Code == 10000){
  1066. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1067. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1068. }
  1069. }
  1070. //选项下移
  1071. function setQuestionDown(o){
  1072. var id = $(o).parent().parent().attr('QuestId');
  1073. var n_id = $(o).parent().parent().next().attr('QuestId');
  1074. if(n_id == undefined){
  1075. ComWbj.artTips("提示","warning","已经是最后一题",1.5,null);
  1076. // ComWbj.alertIconNo('提示:','已经是最后一题','warning');
  1077. return ;
  1078. }
  1079. var param={};
  1080. param.QuestId1 = id;
  1081. param.QuestId2 = n_id;
  1082. param.OperatorId = "10011";
  1083. param.OperatorName = "admin";
  1084. var url = '../survey/wtbj_exchangeQuestionSort.action';
  1085. var _d = _ajax(url,param,false);
  1086. $("#div"+n_id).insertBefore("#div"+id);
  1087. if(!_d.Code == 10000){
  1088. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1089. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1090. }
  1091. getWJData();
  1092. }
  1093. //class="radio-opt-txt" style="overflow: hidden;white-space: nowrap;" style="overflow: hidden;white-space: nowrap;"
  1094. function getDxtLis(d,type){
  1095. var size = d.length;
  1096. var dxt_li = '';
  1097. if(size > 0){
  1098. for(var i = 0; i < size; i++){//d.IfAddblank IfAllowNull
  1099. dxt_li += '<li id="'+d[i].ItemId+'"><div class="valign-m"><div class="valign-m-chk mr20">';
  1100. if(type == 1){
  1101. dxt_li += '<input type="radio" name="radio1" ></input>';
  1102. }else dxt_li += '<input type="checkbox" name="radio1" ></input>';
  1103. dxt_li += '<span class="radio-opt-txt" style="overflow: hidden;white-space: nowrap;"';
  1104. dxt_li += ' onblur="updateQuestionItemTile(this,'+d[i].ItemId+')" >'+d[i].ItemCont+'</span>'+getJumpQuest(d[i]);
  1105. if(type == 1){
  1106. if(d[i].IfAddblank == 1){
  1107. dxt_li += '<input name="xztkk'+d[i].QuestId+'" ></input>';
  1108. }else dxt_li += '<input name="xztkk'+d[i].QuestId+'" style="display:none" ></input>';
  1109. }
  1110. dxt_li += '</div><span name="span'+d[i].QuestId+'" style="display:none" class=""> <label class="valign-m-chk mr20">';
  1111. if(type == 1){
  1112. if(d[i].IfAddblank == 1){
  1113. dxt_li += '<input class="radio-opt-txt" contenteditable="true" style="width:190px;display:none"></input>';
  1114. dxt_li += '<input type="checkbox" checked=checked onclick="setItemBlankPanel(this,'+d[i].ItemId+')" ></input>';
  1115. dxt_li += '<span>选项后增加填空框</span></label>';
  1116. dxt_li += '<label class="valign-m-chk mr20" id="bt'+d[i].ItemId+'" >';
  1117. if(d[i].IfAllowNull == 1){
  1118. dxt_li += '<input checked=checked type="checkbox" onclick="setItemBlank(this,'+d[i].ItemId+')" ></input>';
  1119. }else dxt_li += '<input type="checkbox" onclick="setItemBlank(this,'+d[i].ItemId+')" ></input>';
  1120. dxt_li += '<span>该空可不填</span></label>';
  1121. }else{
  1122. dxt_li += '<input class="radio-opt-txt" contenteditable="true" style="width:190px;display:none"></input>';
  1123. dxt_li += '<input type="checkbox" onclick="setItemBlankPanel(this,'+d[i].ItemId+')" ></input>';
  1124. dxt_li += '<span>选项后增加填空框</span></label><label class="valign-m-chk mr20">';
  1125. dxt_li += '<label class="valign-m-chk mr20" style="display:none" id="bt'+d[i].ItemId+'" >';
  1126. if(d[i].IfAllowNull == 1){
  1127. dxt_li += '<input checked=checked type="checkbox" onclick="setItemBlank(this,'+d[i].ItemId+')" ></input>';
  1128. }else dxt_li += '<input type="checkbox" onclick="setItemBlank(this,'+d[i].ItemId+')" ></input>';
  1129. dxt_li += '<span>该空可不填</span></label>';
  1130. }
  1131. }
  1132. dxt_li += '<i name="ep" class="icon icon-top mr15" onclick="setQuestionItemUp(this,'+type+','+d[i].ItemId+')"></i>';
  1133. dxt_li += '<i name="ep" class="icon icon-bottom mr15" onclick="setQuestionItemDown(this,'+type+','+d[i].ItemId+')"></i>';
  1134. dxt_li += '<i name="ep" class="icon icon-del mr15" onclick="delQuestionItem(this,'+d[i].ItemId+','+type+','+d[i].QuestId+')"></i></span></div> </li>';
  1135. }
  1136. }
  1137. //console.log("-----------> "+dxt_li);
  1138. return dxt_li;
  1139. }
  1140. function getJumpQuest(d){
  1141. if(isEmpty(d.JumpQuest)){
  1142. return '';
  1143. }else{
  1144. for(var i = 0;i<QuestionOption.length;i++){
  1145. if(QuestionOption[i].id == d.JumpQuest){
  1146. return "<span style='color:red'>(该题跳转至Q"+(i+1)+")</span>";
  1147. }
  1148. }
  1149. }
  1150. return '';
  1151. }
  1152. function getDxtLi(id,title,pid,type){
  1153. var dxt_li = '';
  1154. dxt_li += '<li id="'+id+'"><div class="valign-m"><div class="valign-m-chk mr20">';
  1155. if(type == 1){
  1156. dxt_li += '<input type="radio" name="radio1" />';
  1157. }else{
  1158. dxt_li += '<input type="checkbox" name="radio1" />';
  1159. }
  1160. dxt_li += '<span class="radio-opt-txt" style="overflow: hidden;white-space: nowrap;" onblur="updateQuestionItemTile(this,'+id+')" >'+title+'</span></div>';
  1161. // dxt_li += '<span class="radio-opt-txt" style="overflow: hidden;white-space: nowrap;" contenteditable="true" style="display:none"></span>&nbsp;&nbsp;';
  1162. dxt_li += '<span name="span'+pid+'" style="display:none" class=""> <label class="valign-m-chk mr20">';
  1163. if(type == 1){
  1164. dxt_li += '<input class="radio-opt-txt" contenteditable="true" style="width:190px;display:none">';
  1165. dxt_li += '<input type="checkbox" onclick="setItemBlankPanel(this,'+id+')" />';
  1166. dxt_li += '<span>选项后增加填空框</span></label><label style="display:none" id="bt'+id+'" class="valign-m-chk mr20">';
  1167. dxt_li += '<input type="checkbox" onclick="setItemBlank(this,'+id+')" />';
  1168. dxt_li += '<span>该空可不填</span></label>';
  1169. }
  1170. dxt_li += '<i name="ep" class="icon icon-top mr15" onclick="setQuestionItemUp(this,'+type+','+id+')"></i>';
  1171. dxt_li += '<i name="ep" class="icon icon-bottom mr15" onclick="setQuestionItemDown(this,'+type+','+id+')"></i>';
  1172. dxt_li += '<i name="ep" class="icon icon-del mr15" onclick="delQuestionItem(this,'+id+','+type+','+pid+')"></i></span></div> </li>';
  1173. return dxt_li;
  1174. }
  1175. //Item_blank
  1176. function setItemBlankPanel(o,id){
  1177. var type = 0;
  1178. if(o.checked == true){
  1179. type = 1;
  1180. // $(o).prev().show();
  1181. $('#bt'+id).show();
  1182. }else{
  1183. // $(o).prev().hide();
  1184. $('#bt'+id).hide();
  1185. type = 0;
  1186. }
  1187. $('#bt'+id).children().removeAttr('checked');
  1188. var param={};
  1189. param.OperatorId = "10011";
  1190. param.OperatorName = "admin";
  1191. param.ItemId = id;
  1192. param.IfAddblank = type // 是否添加空白填空 1是 0不是
  1193. var url = '../survey/wtbj_upateItem.action';
  1194. var _d = _ajax(url,param,false);
  1195. if(!_d.Code == 10000){
  1196. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1197. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1198. }else{
  1199. setItemBlank1(id,0);
  1200. }
  1201. }
  1202. function jzEditPanel(id){
  1203. $('#div'+id).attr('class','qa-item-wrap editable');
  1204. $('#jzedit'+id).show();
  1205. $('#jzshow'+id).hide();
  1206. $('#iedit'+id).hide();
  1207. $('#i'+id).hide();
  1208. $('#iup'+id).hide();
  1209. $('#idown'+id).hide();
  1210. $('#idel'+id).hide();
  1211. }
  1212. //Item_blank
  1213. function setItemBlank1(id,type){
  1214. var param={};
  1215. param.OperatorId = "10011";
  1216. param.OperatorName = "admin";
  1217. param.ItemId = id;
  1218. param.IfAllowNull = type // 是否该空可不填 0是 1否
  1219. var url = '../survey/wtbj_upateItem.action';
  1220. var _d = _ajax(url,param,false);
  1221. }
  1222. function setItemBlank(o,id){
  1223. var type = 0;
  1224. if(o.checked == true) type = 1;
  1225. else type = 0;
  1226. var param={};
  1227. param.OperatorId = "10011";
  1228. param.OperatorName = "admin";
  1229. param.ItemId = id;
  1230. param.IfAllowNull = type // 是否该空可不填 0是 1否
  1231. var url = '../survey/wtbj_upateItem.action';
  1232. var _d = _ajax(url,param,false);
  1233. if(!_d.Code == 10000){
  1234. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1235. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1236. }
  1237. }
  1238. function delDxtSelect(o){
  1239. var obj = $(o).parent();
  1240. if($(o).parent().attr('id') == 'selectModel'){
  1241. $('#selectModel').hide();
  1242. }else obj.remove();
  1243. }
  1244. function saveDxtFlow(){//保存单选题流向设置
  1245. var type = 0;
  1246. if($('#setting3_dxt_noAnswer').attr('checked') == 'checked'){
  1247. type = 1;
  1248. }
  1249. var sl1 = new Array();
  1250. var sl3 = new Array();
  1251. var sl2 = new Array();
  1252. $('select[name="dxtSelect"]').each(function(i){
  1253. if($(this).parent().css('display') != 'none'){
  1254. sl1.push($(this).val());
  1255. sl3.push($(this).val());
  1256. }
  1257. })
  1258. if(sl1.length > 0){
  1259. $('select[name="dxtSelectLink"]').each(function(i){
  1260. if($(this).parent().css('display') != 'none'){
  1261. sl2.push($(this).val());
  1262. }
  1263. })
  1264. if(sl1.length > 0){
  1265. for(var i = 0;i<sl1.length;i++){
  1266. if(sl1[i] == 0 || sl2[i] == 0){
  1267. ComWbj.artTips("提示","warning","请选择跳转条件",1.5,null);
  1268. // ComWbj.alertIconNo('提示:','请选择跳转条件','warning');
  1269. return false;
  1270. }
  1271. }
  1272. sl1.sort();
  1273. for(var i = 0;i<sl1.length;i++){
  1274. if (sl1[i] == sl1[i+1]){
  1275. ComWbj.artTips("提示","warning","同个选项不能进行多次跳转设置",1.5,null);
  1276. // ComWbj.alertIconNo('提示:','同个选项不能进行多次跳转设置','warning');
  1277. return ;
  1278. }
  1279. }
  1280. }
  1281. }
  1282. var f = delAllItemFlow(sl1);
  1283. if(f){
  1284. setQuestionMustquest($('#setting3_questionID').val(),type);
  1285. addQuestionFlows(sl3,sl2);
  1286. }
  1287. }
  1288. function delAllItemFlow(){//删除所有流向
  1289. var param={};
  1290. param.ItemIds = $('#setting3_allFlowsItemIds').val();;
  1291. var url = '../survey/wtbj_delAllQuestionFlow.action';
  1292. var _d = _ajax(url,param,false);
  1293. if(!_d.Code == 10000){
  1294. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1295. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1296. return false;
  1297. }
  1298. return true;
  1299. }
  1300. function addQuestionFlows(sl1,sl2){//添加答案逻辑流向
  1301. var ItemIds = '';
  1302. var NextQuestIds = '';
  1303. if(sl1.length > 0 && sl1.length == sl2.length){
  1304. for(var i = 0;i < sl1.length;i++){
  1305. if(i == 0){
  1306. ItemIds = sl1[i];
  1307. NextQuestIds = sl2[i];
  1308. }else{
  1309. ItemIds += ','+sl1[i];
  1310. NextQuestIds += ','+sl2[i];
  1311. }
  1312. }
  1313. var param={};
  1314. param.ItemIds = ItemIds;
  1315. param.NextQuestIds = NextQuestIds;
  1316. param.OperatorId = "10011";
  1317. param.OperatorName = "admin";
  1318. var url = '../survey/wtbj_addQuestionFlows.action';
  1319. var _d = _ajax(url,param,false);
  1320. if(!_d.Code == 10000){
  1321. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1322. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1323. }else{
  1324. ComWbj.artTips("提示","succeed",_d.Message,1.5,null);
  1325. // ComWbj.alertIconNo('提示:',_d.Message,'succeed');
  1326. $('#setting3').prev('.mask').hide().end().fadeOut();
  1327. getWJData();
  1328. }
  1329. }else{
  1330. ComWbj.artTips("提示","succeed","完成",1.5,null);
  1331. // ComWbj.alertIconNo('提示:','完成','succeed');
  1332. $('#setting3').prev('.mask').hide().end().fadeOut();
  1333. getWJData();
  1334. }
  1335. }
  1336. function setQuestionMustquest(id,type){//设置非必答
  1337. var param={};
  1338. param.QuestId = id;
  1339. param.Mustquest = type;
  1340. param.OperatorId = "10011";
  1341. param.OperatorName = "admin";
  1342. var url = '../survey/wtbj_updateQuest.action';
  1343. var _d = _ajax(url,param,false);
  1344. if(!_d.Code == 10000){
  1345. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1346. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1347. }
  1348. }
  1349. //删除选项
  1350. function delQuestionItem(o,id,type,pid){
  1351. if($('#ul'+pid).children().length <= 1){
  1352. ComWbj.artTips("提示","warning","至少存在一个答题项",1.5,null);
  1353. // ComWbj.alertIconNo('提示:','至少存在一个答题项','warning');
  1354. return;
  1355. }else{
  1356. var param={};
  1357. param.ItemId = id;
  1358. param.OperatorId = "10011";
  1359. param.OperatorName = "admin";
  1360. var url = '../survey/wtbj_deleteQuestionItem.action';
  1361. var _d = _ajax(url,param,false);
  1362. $("#"+id).remove();
  1363. if(!_d.Code == 10000){
  1364. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1365. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1366. }
  1367. }
  1368. }
  1369. //选项上移
  1370. function setQuestionItemUp(o,type,id){
  1371. var p_id = null;
  1372. p_id = $('#'+id).prev().attr('id');
  1373. if(p_id == undefined){
  1374. ComWbj.artTips("提示","warning","已经是第一个选项",1.5,null);
  1375. // ComWbj.alertIconNo('提示:','已经是第一个选项','warning');
  1376. return ;
  1377. }
  1378. var param={};
  1379. param.ItemId1 = id;
  1380. param.ItemId2 = p_id;
  1381. param.OperatorId = "10011";
  1382. param.OperatorName = "admin";
  1383. var url = '../survey/wtbj_exchangeQuestionItemSort.action';
  1384. $("#"+id).insertBefore("#"+p_id);
  1385. var _d = _ajax(url,param,false);
  1386. if(!_d.Code == 10000){
  1387. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1388. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1389. }
  1390. }
  1391. //选项下移
  1392. function setQuestionItemDown(o,type,id){
  1393. var n_id = null;
  1394. if(type == 1){
  1395. n_id = $('#'+id).next().attr('id');
  1396. }else{
  1397. n_id = $('#'+id).next().attr('id');
  1398. }
  1399. if(n_id == undefined){
  1400. ComWbj.artTips("提示","warning","已经是最后一个选项",1.5,null);
  1401. // ComWbj.alertIconNo('提示:','已经是最后一个选项','warning');
  1402. return ;
  1403. }
  1404. $("#"+n_id).insertBefore("#"+id);
  1405. var param={};
  1406. param.ItemId1 = id;
  1407. param.ItemId2 = n_id;
  1408. param.OperatorId = "10011";
  1409. param.OperatorName = "admin";
  1410. var url = '../survey/wtbj_exchangeQuestionItemSort.action';
  1411. var _d = _ajax(url,param,false);
  1412. if(!_d.Code == 10000){
  1413. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1414. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1415. }
  1416. }
  1417. //添加选项
  1418. function addQuestionItem(id,type){
  1419. var param = {};
  1420. param.QuestId = id;
  1421. param.ItemCont = '请编辑选项内容';
  1422. param.OperatorId = "10011";
  1423. param.OperatorName = "admin";
  1424. var url = '../survey/wtbj_addItem.action';
  1425. var _d = _ajax(url,param,false);
  1426. if(!_d.Code == 10000){
  1427. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1428. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1429. }else{
  1430. $('#ul'+id).append(getDxtLi(_d.ItemId,param.ItemCont,id,type));
  1431. $('#i'+id).click();
  1432. }
  1433. }
  1434. //完成编辑
  1435. function endEditPanel(id){
  1436. if($('#div'+id).attr('class') == 'qa-item-wrap editable'){
  1437. $('#div'+id).removeClass('editable');
  1438. $('#btn'+id).hide();
  1439. $('#iedit'+id).show();
  1440. $('#iup'+id).show();
  1441. $('#idown'+id).show();
  1442. $('#idel'+id).show();
  1443. }
  1444. $('span[name="span'+id+'"]').each(function(i){
  1445. $(this).hide();
  1446. });
  1447. getWJData();
  1448. }
  1449. //完成编辑
  1450. function jzEndEditPanel(id){
  1451. if($('#div'+id).attr('class') == 'qa-item-wrap editable'){
  1452. $('#div'+id).removeClass('editable');
  1453. $('#jzedit').hide();
  1454. $('#jzshow').show();
  1455. $('#iedit'+id).show();
  1456. $('#iup'+id).show();
  1457. $('#idown'+id).show();
  1458. $('#idel'+id).show();
  1459. }
  1460. getWJData();
  1461. }
  1462. function editPanel(id){
  1463. $('span[name="span'+id+'"]').each(function(i){
  1464. $(this).show();
  1465. });
  1466. $('input[name="xztkk'+id+'"]').each(function(i){
  1467. $(this).hide();
  1468. });
  1469. $('#i'+id).hide();
  1470. $('#btn'+id).show();
  1471. $('#iedit'+id).hide();
  1472. $('#iup'+id).hide();
  1473. $('#idown'+id).hide();
  1474. $('#idel'+id).hide();
  1475. }
  1476. //修改选题
  1477. function updateQuestion(o,id){
  1478. if($(o).attr('contenteditable') == 'true'){
  1479. //alert(id+"--"+$(o).text());
  1480. if(!isLengthTooLong($(o).text(),50,1)){
  1481. var params={};
  1482. params.QuestId = id;
  1483. params.Question = ComWbj.trimStr($(o).text());
  1484. params.OperatorId = "10011";
  1485. params.OperatorName = "admin";
  1486. var url = '../survey/wtbj_updateQuest.action';
  1487. var _d = _ajax(url,params,false);
  1488. if(!_d.Code == 10000){
  1489. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1490. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1491. }
  1492. }else{
  1493. ComWbj.artTips("提示","warning","题目字数在1~50个之间",1.5,null);
  1494. // ComWbj.alertIconNo('提示:','题目字数在1~50个之间','warning');
  1495. }
  1496. }
  1497. }
  1498. //修改选项
  1499. function updateQuestionItemTile(o,id){
  1500. if($(o).attr('contenteditable') == 'true'){
  1501. if(!isLengthTooLong($(o).text(),50,1)){
  1502. var param={};
  1503. param.ItemCont = ComWbj.trimStr($(o).text())
  1504. param.OperatorId = "10011";
  1505. param.OperatorName = "admin";
  1506. param.ItemId = id;
  1507. // IfAddblank // 是否添加空白填空 1是 0不是
  1508. // IfAllowNull // 是否该空可不填 0是 1否
  1509. var url = '../survey/wtbj_upateItem.action';
  1510. var _d = _ajax(url,param,false);
  1511. if(!_d.Code == 10000){
  1512. ComWbj.artTips("提示","warning","操作异常",1.5,null);
  1513. // ComWbj.alertIconNo('提示:','操作异常','warning');
  1514. }
  1515. }else{
  1516. ComWbj.artTips("提示","warning","选项字数在1~50之间",1.5,null);
  1517. // ComWbj.alertIconNo('提示:','选项字数在1~50之间','warning');
  1518. }
  1519. }
  1520. }
  1521. //填空题 250个字符
  1522. function isLengthTooLong(s,max,min){
  1523. if(isEmpty(s)){
  1524. return true;
  1525. }else{
  1526. s = ComWbj.trimStr(s);
  1527. if(s.length > max)return true;
  1528. if(s.length < min)return true;
  1529. }
  1530. return false;
  1531. }
  1532. function _ajax(url,param,flag){
  1533. var obj = null;
  1534. try{
  1535. $.ajax({
  1536. type: 'POST',
  1537. url: url,
  1538. data: param,
  1539. async: flag,
  1540. timeout : 8000,
  1541. dataType: 'json',
  1542. success: function(data){
  1543. obj = data;
  1544. }
  1545. });
  1546. }catch(err){
  1547. ComWbj.alertIconNo('提示:',err,'error');
  1548. }
  1549. if(!flag) return obj;
  1550. }
  1551. function isEmpty(s){
  1552. if(s == undefined){
  1553. return true;
  1554. }else{
  1555. if(s == null || s == '' ||
  1556. s == 'null' || s.length < 1){
  1557. return true;
  1558. }
  1559. }
  1560. return false;
  1561. }