var info, code, sendAmount; mui.init(); mui.plusReady(function(){ var self = plus.webview.currentWebview(); info = self.info; code = self.code; sendAmount = self.amount; fillInfo(); bindEvents(); sqlite.open('MyData','1.0','My Database', 1024*100); createTemplateTable(); createTable(); console.log(info) }); function fillInfo(){ var summary = info.summary_info, questions = info.question_info, survey_target = info.surveyTarget; $("#sendAmount").text(sendAmount); $(".sex").text(survey_target.sexText); $(".disease").text(survey_target.diseaseText); $(".service").text(survey_target.serviceText); $(".health").text(survey_target.healthText); $(".survey_title").text(summary.name); $(".comment").text(summary.comment); var labelTmp = template("label_tmp", {list: summary.label}); $("#label_panel").append(labelTmp); var question_list = _.map(questions, function(o){ if(!o.optionArr){ o.optionArr = o.options; } return o; }); var questionTmp = template("question_tmp", {list: question_list}); $("#question_panel").append(questionTmp); } template.helper("setType", function(str){ var value = ""; switch(str){ case 0 : value = "单选"; break; case 1 : value = "多选"; break; case 2: value = "填空"; break; } return value; }); function bindEvents(){ $("#submit_btn").on('click', function(){ dialog({ content: "是否确认将编辑的问卷发送给选定的"+sendAmount+"人?发送后无法修改", okValue: "立即发送", ok: function(){ sendRequest(); }, cancelValue: "我再看看", cancel: function(){} }).showModal(); }); } function sendRequest(){ plus.nativeUI.showWaiting(); var questions = []; for(i=0; i=0){ nextCode = op.nextQuestion; } obj.options.push({ content: op.content, haveComment: op.haveComment, isRequired: op.isRequired, nextQuestion: nextCode, sort: j+1, optCode: op.optCode }); } } questions.push(obj); } var label = []; for(i=0; i 10 ? (parseInt(res.data.number)+1) : "0"+(parseInt(res.data.number)+1); var newTitle = info.summary_info.name + (new Date().format("ddMMyy"))+num; dialog({ title: '模板标题重复,请重新填写标题', content: '', okValue: "确定", ok: function(){ var title = $("#newTitle").val(); if($.trim(title).length == 0){ dialog({ content: "请输入标题", contentType: "tipsbox", skin: 'bk-popup', closeTime: 2000 }).show(); }else{ saveAsTemplate(surveyCode, title); } } }).showModal(); }else{ mui.toast(res.msg); } } plus.nativeUI.closeWaiting(); }, true); } function clearTableData(){ var tables = ["template", "questions2"]; sqlite.db.transaction(function(tx){ for(i=0; i