import{Q as d}from"./QuestionItem.1944680c.js";import{n as c}from"./vueComponentNormalizer.9ef17bb1.js";var f=function(){var s,t=this,n=t.$createElement,e=t._self._c||n;return e("div",[t.paperStyle==0?e("div",t._l((s=t.questionList)===null||s===void 0?void 0:s.classify,function(i,r){return e("div",{key:r},[e("p",{staticStyle:{padding:"10px 0 20px 0","font-weight":"bold","font-size":"14px"}},[t._v(" \u7B2C"+t._s(["\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D","\u4E03","\u516B","\u4E5D","\u5341"][r])+"\u90E8\u5206\uFF1A "+t._s(i.title)+" "),e("span",{staticStyle:{"font-size":"12px","font-weight":"normal",display:"inline-block","margin-left":"10px",color:"#999"}},[t._v(" (\u5171"+t._s(t.questionList.questions[i.title].length)+"\u9898"),i.score?e("span",[t._v("\uFF0C\u6BCF\u9898"+t._s(i.score)+"\u5206")]):t._e(),t._v(") ")])]),t._l(t.questionList.questions[i.title],function(o,l){return e("div",{key:o.id,style:{"margin-bottom":"10px"}},[e("QuestionItem",{attrs:{random:t.random,questionInfo:o,serial:l+1,isFlag:t.flagList.includes(o.id),mode:t.mode},on:{answerChanged:function(a){return t.userAnswerOnChange(a,o)},flag:t.toggleFlagList,eval:t.questionItemHasEval}})],1)})],2)}),0):t._e(),t.paperStyle==1?e("div",[e("div",[e("p",{staticStyle:{padding:"10px 0 20px 0","font-weight":"bold","font-size":"14px"}},[t._v(t._s(t.questions[t.currentQuestionInd].type)+" "),e("span",{staticStyle:{"font-size":"12px","font-weight":"normal",display:"inline-block","margin-left":"10px",color:"#999"}},[t._v(" (\u5171"+t._s(t.questionList.questions[t.questions[t.currentQuestionInd].type].length)+"\u9898\uFF0C"),t.questions[t.currentQuestionInd].score?e("span",[t._v("\u6BCF\u9898"+t._s(t.questions[t.currentQuestionInd].score)+"\u5206")]):t._e(),t._v(") ")])]),e("QuestionItem",{key:t.questions[t.currentQuestionInd].id,attrs:{questionInfo:t.questions[t.currentQuestionInd],serial:t.currentQuestionInd+1,isFlag:t.flagList.includes(t.questions[t.currentQuestionInd].id),mode:t.mode,answer:t.getAnswer(t.questions[t.currentQuestionInd].id)},on:{answerChanged:function(i){return t.userAnswerOnChange(i,t.questions[t.currentQuestionInd])},flag:t.toggleFlagList}})],1),e("div",{staticClass:"changer-btns"},[e("div",[e("el-button",{attrs:{size:"medium",icon:"el-icon-arrow-left",type:"primary",circle:"",disabled:t.currentQuestionInd==0},on:{click:function(i){return t.changeQuestion(-1)}}}),e("p",[t._v("\u4E0A\u4E00\u9898")])],1),e("div",[e("el-button",{style:{color:t.flagList.includes(t.questions[t.currentQuestionInd].id)?"#ee0000":"#333333"},attrs:{size:"medium",icon:t.flagList.includes(t.questions[t.currentQuestionInd].id)?"el-icon-star-on":"el-icon-star-off",circle:""},on:{click:function(i){t.toggleFlagList({isFlag:!t.flagList.includes(t.questions[t.currentQuestionInd].id),question:t.questions[t.currentQuestionInd]})}}}),e("p",[t._v("\u6807\u8BB0")])],1),e("div",[e("el-button",{attrs:{size:"medium",icon:"el-icon-arrow-right",type:"primary",circle:"",disabled:t.currentQuestionInd==t.questions.length-1},on:{click:function(i){return t.changeQuestion(1)}}}),e("p",[t._v("\u4E0B\u4E00\u9898")])],1)])]):t._e()])},p=[];const h={components:{QuestionItem:d},props:{questions:{},mode:{default:0,type:Number},paperStyle:{default:0,type:Number},random:{default:()=>[0,0],type:Array}},data:()=>({flagList:[],answerList:[],questionList:null,currentQuestionInd:0,evalList:[]}),watch:{questions:{deep:!0,immediate:!0,handler(s){s&&(this.questionList=this.formatQuestions(s))}}},activated(){this.flagList=[],this.answerList=[],this.evalList=[],this.currentQuestionInd=0},methods:{questionItemHasEval(s){const t=this.evalList.findIndex(n=>n.id===s.id);t!==-1&&this.evalList.splice(t,1),Object.keys(s).includes("score")&&this.evalList.push(s),this.$emit("evalChanged",this.evalList)},changeIndById(s){const t=this.questions.findIndex(n=>n.id===s);this.currentQuestionInd=t},changeQuestion(s){this.currentQuestionInd+=s},getAnswer(s){const t=this.answerList.findIndex(n=>n.questionId===s);return t===-1?null:this.answerList[t].answer},userAnswerOnChange(s,t){const n=this.answerList.findIndex(e=>e.questionId===t.id);if(n!==-1&&this.answerList.splice(n,1),s.length>0){const e={questionId:t.id,answer:s};this.mode===5&&(e.resultId=t.resultId),this.answerList.push(e),this.$emit("answers",this.answerList)}},toggleFlagList({isFlag:s,question:t}){if(s===!0)this.flagList.push(t.id);else{const n=this.flagList.indexOf(t.id);this.flagList.splice(n,1)}this.$emit("flag",this.flagList)},formatQuestions(s){return s.reduce((n,e)=>(n.classify.findIndex(i=>i.title===e.type)===-1&&n.classify.push({title:e.type,score:e.score}),Object.keys(n.questions).includes(e.type)?n.questions[e.type].push(e):n.questions[e.type]=[e],n),{classify:[],questions:{}})}}},u={};var g=c(h,f,p,!1,_,"167c10ce",null,null);function _(s){for(let t in u)this[t]=u[t]}const I=function(){return g.exports}();export{I as Q};
