/* empty css */import{l as w,m as x,n as k,o as $,q as b,r as C,t as I,j as O}from"./questions.7b7a7919.js";import{A as N}from"./ActionBar.1725b1a3.js";/* empty css */import{n as p}from"./vueComponentNormalizer.9ef17bb1.js";/* empty css *//* empty css *//* empty css */import{Q as v,a as S}from"./QuestionDifficultyLevelSelector.b9a0d127.js";import{f as T,a as L}from"./questionInfoMapJsonTrans.58e126b5.js";import{r as E,u,w as A}from"./xlsx.db07aefa.js";import"./index.f5168bf8.js";/* empty css */var F=function(){var e=this,i=e.$createElement,t=e._self._c||i;return t("el-select",{attrs:{filterable:"","allow-create":"","default-first-option":"",clearable:"",placeholder:"\u9009\u62E9\u6216\u8F93\u5165\u6DFB\u52A0\u77E5\u8BC6\u70B9",loading:e.loading},on:{change:e.createKnowledges},model:{value:e.knowledgeId,callback:function(s){e.knowledgeId=s},expression:"knowledgeId"}},e._l(e.knowledgesOptions,function(s){return t("el-option",{key:s.id,attrs:{label:s.name,value:s.id}},[t("span",{staticStyle:{float:"left"}},[e._v(e._s(s.name))]),t("span",{staticClass:"el-icon-delete",staticStyle:{float:"right",color:"#8492a6","font-size":"13px",height:"100%",display:"flex","align-items":"center","justify-content":"center"},on:{click:function(a){return a.stopPropagation(),e.deleteKnowledge(s)}}})])}),1)},Q=[];const B={data:e=>({knowledgeId:null,knowledgesOptions:[],loading:!1}),mounted(){this.findAllKnowledges()},activated(){this.findAllKnowledges()},props:{value:{default:null}},watch:{value:{immediate:!0,deep:!0,handler(e){this.knowledgeId=e}},knowledgeId:{immediate:!1,deep:!0,handler(e){this.$emit("input",e)}}},methods:{findAllKnowledges(){this.loading=!0,w().then(({data:e})=>{this.knowledgesOptions=e}).finally(e=>{this.loading=!1})},deleteKnowledge(e){this.loading=!0,x(e.id).finally(i=>{this.loading=!1,this.findAllKnowledges(),this.knowledgeId===e.id&&(this.knowledgeId=null)})},createKnowledges(e){typeof e=="string"&&e!==""&&(this.loading=!0,k(e).then(i=>{this.knowledgesOptions.push(i.data),this.$nextTick(()=>{this.knowledgeId=i.data.id})}).finally(i=>{this.loading=!1}))}}},f={};var q=p(B,F,Q,!1,M,null,null,null);function M(e){for(let i in f)this[i]=f[i]}const j=function(){return q.exports}();var X=function(){var e=this,i=e.$createElement,t=e._self._c||i;return t("el-tabs",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],attrs:{type:"card"},model:{value:e.activeTagId,callback:function(s){e.activeTagId=s},expression:"activeTagId"}},e._l(e.options,function(s){return t("el-tab-pane",{key:s.id,attrs:{label:s.name,name:s.name}})}),1)},D=[];const J={data:e=>({difficultyLevel:null,activeTagId:null,loading:!1}),mounted(){this.initActive()},activated(){this.initActive()},props:{value:{default:null},options:{default:()=>[]}},watch:{value:{immediate:!0,deep:!0,handler(e){e&&Object.keys(e).includes("id")&&(this.activeTagId=e.name)}},activeTagId:{immediate:!1,deep:!0,handler(e){let i=null;this.options.length>0&&(i=this.getTypeById(e)),this.$emit("input",i),this.$emit("change",i)}}},methods:{initActive(){this.$nextTick(()=>{this.activeTagId=this.activeTagId!=null?this.activeTagId:this.options[0].name})},getTypeById(e){return this.options.find(i=>i.name===e)}}},h={};var K=p(J,X,D,!1,W,"6b1dc12a",null,null);function W(e){for(let i in h)this[i]=h[i]}const P=function(){return K.exports}();var R=function(){var e=this,i=e.$createElement,t=e._self._c||i;return t("div",{directives:[{name:"loading",rawName:"v-loading",value:e.is_uploading,expression:"is_uploading"}],staticClass:"gy-import-questions"},[t("div",{staticStyle:{display:"flex","justify-content":"space-between","flex-wrap":"wrap"}},[t("div",{staticClass:"gy-form inline",staticStyle:{"--fix":"80px"}},[t("div",{staticClass:"gy-form-item"},[t("div",{staticClass:"gy-label middle"},[e._v("\u8BD5\u9898\u5206\u7C7B\uFF1A")]),t("QuestionClassifySelector",{attrs:{mountedLoad:!0},model:{value:e.classifyId,callback:function(s){e.classifyId=s},expression:"classifyId"}})],1),t("div",{staticClass:"gy-form-item"},[t("el-button",{staticStyle:{padding:"0"},attrs:{round:"",type:"text"},on:{click:e.downloadModelFile}},[e._v("\u4E0B\u8F7D\u6A21\u677F")]),t("div",{staticClass:"gy-label middle",staticStyle:{height:"32px","white-space":"nowrap",color:"#ed0000"}},[e._v(" \uFF08\u4E0B\u8F7D\u6A21\u677F\u540E\u6309\u8981\u6C42\u5F55\u5165\u5185\u5BB9\uFF09 ")])],1)]),t("div",[t("el-button",{attrs:{round:"",type:"primary"},on:{click:e.uploadFile}},[e._v("\u5BFC\u5165")]),e.passList.length>0&&e.errorList.length>0?t("el-button",{attrs:{round:"",type:"primary"},on:{click:e.filterMistakeAndUpload}},[e._v("\u8FC7\u6EE4\u9519\u8BEF\u5E76\u4E0A\u4F20")]):e._e(),t("el-button",{attrs:{round:"",type:"primary",plain:""},on:{click:function(s){e.errorList=e.passList=[]}}},[e._v("\u6E05\u7406")]),t("input",{ref:"fileUploader",attrs:{type:"file",name:"fileUploader",id:"fileUploader",accept:".xlsx"},on:{change:e.getFileContent}})],1)]),e.errorList.length===0?t("div",[t("el-empty",{attrs:{description:"\u8BF7\u5148\u5BFC\u5165\u8BD5\u9898"}})],1):t("ul",{staticClass:"error-info-list"},[e._m(0),t("div",{staticStyle:{"overflow-y":"auto","max-height":"50vh"}},e._l(e.errorList,function(s,a){return t("li",{key:a,staticClass:"error-item"},[t("div",{staticClass:"column"},[e._v(e._s(s.question.sheetName))]),t("div",{staticClass:"column"},[e._v(e._s(s.question.rowNum))]),t("div",{staticClass:"column"},[e._v(e._s(s.question.title))]),t("ul",{staticClass:"column"},e._l(s.error,function(n,o){return t("li",{key:o},[e._v(" "+e._s(n)+" ")])}),0)])}),0)])])},z=[function(){var e=this,i=e.$createElement,t=e._self._c||i;return t("li",{staticClass:"error-item header"},[t("div",{staticClass:"column"},[e._v("\u8868\u540D")]),t("div",{staticClass:"column"},[e._v("\u884C\u53F7")]),t("div",{staticClass:"column"},[e._v("\u9898\u76EE")]),t("div",{staticClass:"column"},[e._v("\u9519\u8BEF\u4FE1\u606F")])])}];const U={components:{QuestionClassifySelector:v},data:()=>({errorList:[],passList:[],classifyId:null,is_uploading:!1}),methods:{uploadFile(){if(this.classifyId==null)return this.$message.error("\u8BF7\u5148\u9009\u62E9\u79D1\u76EE");this.$refs.fileUploader.click()},uploadToServer(){const e=this.passList,i=this.classifyId;this.is_uploading=!0,$(i,e).then(t=>{this.$message.success("\u5BFC\u5165\u6210\u529F"),this.passList=[],this.errorList=[],this.$router.go(-1)}).catch(t=>{console.info(t)}).finally(t=>{this.is_uploading=!1})},filterMistakeAndUpload(){this.$confirm(`\u6587\u4EF6\u4E2D\u5171\u5305\u542B ${this.errorList.length+this.passList.length} \u9053\u9898\uFF0C\u5176\u4E2D${this.errorList.length}\u9053\u9898\u4E0D\u7B26\u5408\u89C4\u5219\uFF0C\u672C\u6B21\u5C06\u5BFC\u5165 ${this.passList.length} \u9053\u9898\uFF0C\u786E\u8BA4\u5BFC\u5165\u5417\uFF1F`,"\u63D0\u793A",{type:"info"}).then(e=>{this.uploadToServer()}).catch(e=>{})},getFileContent(e){this._toJSON(e.target.files[0]).then(i=>{const{pass:t,errors:s}=this.checkFormat(i);this.passList=t,this.errorList=s,s.length===0&&this.$confirm(`\u672C\u6B21\u5C06\u5BFC\u5165 ${t.length} \u9053\u9898\uFF0C\u786E\u8BA4\u5BFC\u5165\u5417\uFF1F`,"\u63D0\u793A",{type:"info"}).then(a=>{this.uploadToServer()}).catch(a=>{}),e.target.value=""}).catch(i=>{this.$message.error(i.message)})},checkFormat(e){const i=[],t=[],s=["\u5355\u9009\u9898","\u591A\u9009\u9898","\u5224\u65AD\u9898","\u586B\u7A7A\u9898","\u7B80\u7B54\u9898"],a=["\u6613","\u8F83\u6613","\u4E2D\u7B49","\u8F83\u96BE","\u96BE"];return e.forEach(n=>{const o=[];let l,r;n.title.length>255&&o.push("\u9898\u76EE\u957F\u5EA6\u4E0D\u80FD\u8D85\u8FC7255\u4E2A\u5B57\u7B26"),n.title||o.push("\u9898\u76EE\u4E0D\u80FD\u4E3A\u7A7A"),n.type?s.includes(n.type)||o.push(`\u3010${n.type}\u3011\u4E0D\u662F\u6807\u51C6\u7684\u8BD5\u9898\u7C7B\u578B\uFF08${s.join(",")}\uFF09`):o.push("\u8BD5\u9898\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A"),n.difficulty?a.includes(n.difficulty)||o.push(`\u3010${n.difficulty}\u3011\u4E0D\u662F\u6807\u51C6\u7684\u96BE\u6613\u7A0B\u5EA6\uFF08${a.join(",")}\uFF09`):o.push("\u96BE\u6613\u7A0B\u5EA6\u4E0D\u80FD\u4E3A\u7A7A"),!this.isJSON(n.answer)||!n.answer?o.push("\u7B54\u6848\u683C\u5F0F\u4E0D\u7B26\u6216\u4E3A\u7A7A"):(r=JSON.parse(n.answer),Array.isArray(r)?r.length===0&&n.type!=="\u586B\u7A7A\u9898"&&o.push("\u6CA1\u6709\u7B54\u6848"):o.push("\u7B54\u6848\u5E94\u662F\u4E00\u4E2A\u6570\u7EC4"),["\u5355\u9009\u9898","\u5224\u65AD\u9898","\u7B80\u7B54\u9898"].includes(n.type)&&r.length>1&&o.push(`\u9898\u578B\u3010${n.type}\u3011\u53EA\u80FD\u6709\u4E00\u4E2A\u7B54\u6848`)),!this.isJSON(n.options)||!n.options?o.push("\u9009\u9879\u683C\u5F0F\u4E0D\u7B26\u6216\u4E3A\u7A7A"):(l=JSON.parse(n.options),Array.isArray(l)?!l.length===0&&o.push("\u6CA1\u6709\u9009\u9879"):o.push("\u9009\u9879\u5E94\u662F\u4E00\u4E2A\u6570\u7EC4")),["\u5355\u9009\u9898","\u5224\u65AD\u9898","\u591A\u9009\u9898"].includes(n.type)&&r&&l&&l.length0&&![0,1].includes(r[0])&&o.push("\u5224\u65AD\u9898\u7B54\u6848\u53EA\u80FD\u4E3A0-\u9519\u8BEF\u30011-\u6B63\u786E"),o.length>0?t.push({question:n,error:o}):i.push(n)}),{pass:i,errors:t}},_toJSON(e){return new Promise((i,t)=>{/^.+\.xlsx$/.test(e.name)||t(new Error("\u4E0D\u662FExcel\u8868\u683C\u6587\u4EF6"));const s=new FileReader;s.onload=a=>{const n=a.target.result,o=E(n,{type:"binary"});let l=[];o.SheetNames.forEach(function(r){let c=u.sheet_to_json(o.Sheets[r],{header:["title","difficulty","knowledge","options","answer","analysis"],defval:""});if(c.forEach((d,_)=>{d.sheetName=r,d.rowNum=_+1,d.type=r}),c.length>0){const d=Object.values(c[0]);d.includes("\u9898\u76EE")&&d.includes("\u77E5\u8BC6\u70B9")&&(c=c.slice(1))}l=l.concat(c)}),i(l)},s.readAsBinaryString(e)})},isJSON(e){try{const i=JSON.parse(e);return!!(typeof i=="object"&&i)}catch{return!1}},downloadModelFile(){const e=[{sheetName:"\u5355\u9009\u9898",data:[["\u9898\u76EE","\u96BE\u6613\u7A0B\u5EA6\uFF08\u6613\u3001\u8F83\u6613\u3001\u4E2D\u7B49\u3001\u8F83\u96BE\u3001\u96BE\uFF09","\u77E5\u8BC6\u70B9","\u9009\u9879","\u7B54\u6848\uFF08\u9009\u62E9\u9898\uFF1A\u5927\u5199A-Z\u5BF9\u5E94\u9009\u9879\uFF09","\u7B54\u6848\u89E3\u6790"],["\u5355\u9009\u9898\u4F8B\u5B50\uFF0C\u5BFC\u5165\u524D\u8BF7\u5148\u5220\u9664","\u8F83\u6613","\u8BED\u6587",'["\u9009\u98791","\u9009\u98792","\u9009\u98793"]','["A"]',"\u7B54\u6848\u89E3\u6790XXX"]]},{sheetName:"\u591A\u9009\u9898",data:[["\u9898\u76EE","\u96BE\u6613\u7A0B\u5EA6\uFF08\u6613\u3001\u8F83\u6613\u3001\u4E2D\u7B49\u3001\u8F83\u96BE\u3001\u96BE\uFF09","\u77E5\u8BC6\u70B9","\u9009\u9879","\u7B54\u6848\uFF08\u9009\u62E9\u9898\uFF1A\u5927\u5199A-Z\u5BF9\u5E94\u9009\u9879\uFF09","\u7B54\u6848\u89E3\u6790"],["\u591A\u9009\u9898\u4F8B\u5B50\uFF0C\u5BFC\u5165\u524D\u8BF7\u5148\u5220\u9664","\u6613","\u8BED\u6587",'["\u9009\u98791","\u9009\u98792","\u9009\u98793"]','["A","B","C"]',"\u7B54\u6848\u89E3\u6790XXX"]]},{sheetName:"\u5224\u65AD\u9898",data:[["\u9898\u76EE","\u96BE\u6613\u7A0B\u5EA6\uFF08\u6613\u3001\u8F83\u6613\u3001\u4E2D\u7B49\u3001\u8F83\u96BE\u3001\u96BE\uFF09","\u77E5\u8BC6\u70B9","\u9009\u9879","\u7B54\u6848\uFF08\u5224\u65AD\u9898\uFF1A1\u6B63\u786E0\u9519\u8BEF\uFF09","\u7B54\u6848\u89E3\u6790"],["\u5224\u65AD\u9898\u4F8B\u5B50\uFF0C\u5BFC\u5165\u524D\u8BF7\u5148\u5220\u9664","\u4E2D\u7B49","\u6570\u5B66",'["\u6B63\u786E","\u9519\u8BEF"]',"[1]","\u7B54\u6848\u89E3\u6790XXX"]]},{sheetName:"\u586B\u7A7A\u9898",data:[["\u9898\u76EE","\u96BE\u6613\u7A0B\u5EA6\uFF08\u6613\u3001\u8F83\u6613\u3001\u4E2D\u7B49\u3001\u8F83\u96BE\u3001\u96BE\uFF09","\u77E5\u8BC6\u70B9","\u9009\u9879","\u7B54\u6848\uFF08\u4FDD\u7559[],\u586B\u7A7A\u9898\u65E0\u9700\u586B\u5199\u7B54\u6848\uFF0C\u9009\u9879\u5373\u662F\u7B54\u6848\uFF09","\u7B54\u6848\u89E3\u6790"],["\u586B\u7A7A\u9898\u4F8B\u5B50\uFF0C\u5BFC\u5165\u524D\u8BF7\u5148\u5220\u9664","\u8F83\u96BE","\u82F1\u8BED",'["\u7A7A1\u7B54\u6848","\u7A7A2\u7B54\u6848","\u7A7A3\u7B54\u6848"]',"[]","\u7B54\u6848\u89E3\u6790XXX"]]},{sheetName:"\u7B80\u7B54\u9898",data:[["\u9898\u76EE","\u96BE\u6613\u7A0B\u5EA6\uFF08\u6613\u3001\u8F83\u6613\u3001\u4E2D\u7B49\u3001\u8F83\u96BE\u3001\u96BE\uFF09","\u77E5\u8BC6\u70B9","\u9009\u9879\uFF08\u4FDD\u7559[],\u65E0\u9700\u586B\u5199\u9009\u9879\uFF09","\u7B54\u6848","\u7B54\u6848\u89E3\u6790"],["\u7B80\u7B54\u9898\u4F8B\u5B50\uFF0C\u5BFC\u5165\u524D\u8BF7\u5148\u5220\u9664","\u96BE","\u6570\u5B66","[]",'["\u7B80\u7B54\u9898\u6807\u51C6\u7B54\u6848\u53EA\u6709\u7EAF\u6587\u672C"]',"\u7B54\u6848\u89E3\u6790XXX"]]}],i=[];e.forEach(s=>{const a=[],n=s.data;n.forEach((l,r)=>{l.forEach((c,d)=>{a[d]==null&&(a[d]=[]),a[d].push(this.getCellWidth(c))})});const o=u.aoa_to_sheet(n);o["!cols"]=[],a.forEach((l,r)=>{o["!cols"].push({wch:Math.max(...l)})}),i.push({name:s.sheetName,ws:o})});const t=u.book_new();i.forEach(s=>{u.book_append_sheet(t,s.ws,s.name)}),A(t,`\u8BD5\u9898\u5BFC\u5165\u6A21\u677F${new Date().format("yyyy-MM-dd hh-mm-ss")}.xlsx`)},getCellWidth(e){if(e==null)return 10;if(/.*[\u4e00-\u9fa5]+.*$/.test(e)){const i=e.match(/[\u4e00-\u9fa5]/g).length,t=e.length-i;return i*2.1+t*1.1}else return e.toString().length*1.1}}},m={};var H=p(U,R,z,!1,Z,"4bf1fe2e",null,null);function Z(e){for(let i in m)this[i]=m[i]}const V=function(){return H.exports}();var G=function(){var e=this,i=e.$createElement,t=e._self._c||i;return t("div",{staticClass:"v-page"},[t("div",{directives:[{name:"loading",rawName:"v-loading",value:e.page_is_loading,expression:"page_is_loading"}],staticClass:"v-ctx"},[t("QuestionTypeTabBar",{attrs:{options:e.questionTypeOptions},model:{value:e.activeName,callback:function(s){e.activeName=s},expression:"activeName"}}),e.activeName&&e.activeName.id!==-1?t("div",{staticClass:"gy-form inline",staticStyle:{"--fix":"80px","margin-bottom":"20px"}},[t("div",{staticClass:"gy-form-item mb"},[t("div",{staticClass:"gy-label middle"},[e._v("\u8BD5\u9898\u5206\u7C7B\uFF1A")]),t("QuestionClassifySelector",{attrs:{mountedLoad:!0},model:{value:e.form.classifyId,callback:function(s){e.$set(e.form,"classifyId",s)},expression:"form.classifyId"}})],1),t("div",{staticClass:"gy-form-item mb"},[t("div",{staticClass:"gy-label middle"},[e._v("\u77E5\u8BC6\u70B9\uFF1A")]),t("KnowledgeSelector",{attrs:{mountedLoad:!0},model:{value:e.form.knowledgeId,callback:function(s){e.$set(e.form,"knowledgeId",s)},expression:"form.knowledgeId"}})],1),t("div",{staticClass:"gy-form-item"},[t("div",{staticClass:"gy-label middle"},[e._v("\u96BE\u6613\u7A0B\u5EA6\uFF1A")]),t("QuestionDifficultyLevelSelector",{attrs:{mountedLoad:!0},model:{value:e.form.difficultyLevel,callback:function(s){e.$set(e.form,"difficultyLevel",s)},expression:"form.difficultyLevel"}})],1)]):e._e(),e.activeName&&e.activeName.id!==-1?t("div",{staticClass:"gy-question-editer"},[t("div",{staticClass:"gy-form",staticStyle:{"--fix":"80px"}},[t("div",{staticClass:"gy-form-item"},[t("div",{staticClass:"gy-label"},[e._v("\u9898\u76EE\uFF1A")]),t("el-input",{attrs:{type:"textarea"},model:{value:e.form.title,callback:function(s){e.$set(e.form,"title",s)},expression:"form.title"}})],1),t("div",{staticClass:"gy-form-item",staticStyle:{"margin-top":"16px"}},[["textarea"].includes(e.currentOptionElement)?e._e():t("div",{staticClass:"gy-label"},[e._v("\u9009\u9879\uFF1A")])]),t("div",{staticClass:"gy-unform-content",staticStyle:{"margin-top":"16px"}},[t("div",{staticClass:"options-list"},[["radio","checkbox","radio*2","input"].includes(e.currentOptionElement)?t("div",{class:{"radio-option":!0,"horizontal-option":["radio*2"].includes(e.currentOptionElement)}},e._l(e.form.options,function(s,a){return t("div",{key:a,staticClass:"option-item"},[["radio","checkbox","radio*2"].includes(e.currentOptionElement)?t("div",{staticStyle:{display:"flex","align-items":"center"}},[["radio","checkbox","input"].includes(e.currentOptionElement)?t("div",{staticStyle:{width:"30px","font-size":"14px",padding:"9px 0"}},[e._v(e._s(e.optionsWordList[a])+":")]):e._e(),t("el-checkbox-group",{model:{value:e.form.answer,callback:function(n){e.$set(e.form,"answer",n)},expression:"form.answer"}},[t("el-checkbox",{attrs:{label:e.optionsWordList[a]},on:{change:function(n){return e.selectedAnswer(e.optionsWordList[a])}}},[e._v(e._s(["radio","checkbox"].includes(e.currentOptionElement)?"\u7B54\u6848":e.form.options[a])+" ")])],1),["radio","checkbox","input"].includes(e.currentOptionElement)?t("el-button",{staticStyle:{color:"#ec0000","font-size":"14px","margin-left":"20px"},attrs:{type:"text",icon:"i-j-ksap-shanchu"},on:{click:function(n){return e.deleteOption(a)}}},[e._v("\u5220\u9664 ")]):e._e()],1):e._e(),["radio","checkbox"].includes(e.currentOptionElement)?t("el-input",{attrs:{placeholder:"\u8BF7\u8F93\u5165\u9009\u9879\u5185\u5BB9"},model:{value:e.form.options[a],callback:function(n){e.$set(e.form.options,a,n)},expression:"form.options[ind]"}}):e._e(),["input"].includes(e.currentOptionElement)?t("div",{staticStyle:{display:"flex","align-items":"center"}},[t("div",{staticStyle:{"min-width":"60px","font-size":"14px",padding:"15px 10px 15px 0"}},[e._v("\u586B\u7A7A"+e._s(a+1)+":")]),t("el-input",{staticStyle:{"flex-basis":"0","flex-grow":"1"},attrs:{placeholder:"\u8BF7\u8F93\u5165\u586B\u7A7A\u5185\u5BB9"},model:{value:e.form.options[a],callback:function(n){e.$set(e.form.options,a,n)},expression:"form.options[ind]"}}),t("el-button",{staticStyle:{color:"#ec0000","font-size":"14px",padding:"9px 10px"},attrs:{type:"text",icon:"i-j-ksap-shanchu"},on:{click:function(n){return e.deleteOption(a)}}},[e._v("\u5220\u9664")])],1):e._e()],1)}),0):e._e(),["radio","checkbox","input"].includes(e.currentOptionElement)?t("el-button",{staticClass:"addbtn-restyle mt",attrs:{type:"pramiry",plain:"",icon:"el-icon-plus"},on:{click:e.addOption}},[e._v("\u589E\u52A0\u9009\u9879 ")]):e._e()],1)]),["textarea"].includes(e.currentOptionElement)?t("div",{staticClass:"gy-form-item"},[t("div",{staticClass:"gy-label"},[e._v("\u89E3\u7B54\uFF1A")]),t("el-input",{attrs:{type:"textarea"},model:{value:e.form.answer[0],callback:function(s){e.$set(e.form.answer,0,s)},expression:"form.answer[0]"}})],1):e._e(),t("div",{staticClass:"gy-unform-content"},[e._m(0),t("div",{staticClass:"gy-form-item"},[t("el-input",{attrs:{type:"textarea",placeholder:"\u53EF\u4F9D\u636E\u9700\u6C42\u586B\u5199\u7B54\u6848\u89E3\u6790\u5185\u5BB9"},model:{value:e.form.analysis,callback:function(s){e.$set(e.form,"analysis",s)},expression:"form.analysis"}})],1)])])]):e._e(),e.activeName&&e.activeName.id===-1?t("ImportQuestions"):e._e(),e.activeName&&e.activeName.id!==-1?t("div",{staticStyle:{width:"100%","margin-top":"30px"}},[t("ActionBar",{attrs:{center:""},on:{onConfirm:e.confirmQuestion,onCancel:e.cancelQuestion}})],1):e._e()],1)])},Y=[function(){var e=this,i=e.$createElement,t=e._self._c||i;return t("div",{staticClass:"gy-form-item"},[t("div",{staticClass:"gy-label",staticStyle:{padding:"10px 0"}},[e._v("\u7B54\u6848\u89E3\u6790\uFF1A")])])}];const g=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],ee={components:{ActionBar:N,QuestionClassifySelector:v,KnowledgeSelector:j,QuestionDifficultyLevelSelector:S,QuestionTypeTabBar:P,ImportQuestions:V},data:()=>({page_is_loading:!1,activeName:null,questionTypeOptions:[],optionsWordList:g,modifyBackupForm:{},form:{type:null,difficultyLevel:null,title:"",options:[],answer:[],classifyId:null,knowledgeId:null,analysis:""}}),props:{questionId:{require:!1}},computed:{isModify(){return this.$route.params.questionId!=null},currentOptionElement(){return this.activeName?this.activeName.element:null}},watch:{activeName:{deep:!0,immediate:!0,handler(e){this.typeOnChangeHandler(e)}}},created(){this.formItems=[{prop:"classifyId",label:"\u79D1\u76EE"}]},activated(){this.findQuestionTypeOptions().then(()=>{this.getRouteParamsAndRequest()})},deactivated(){this.initFormData()},methods:{getRouteParamsAndRequest(){const{questionId:e}=this.$route.params,{activeTag:i}=this.$route.query;e&&this.getQuestionDetails(e),isNaN(parseInt(i))||this.changeQuestionTypeTag(i)},changeFormInitData(){var e,i;this.isModify?(this.form=JSON.parse(JSON.stringify(this.modifyBackupForm)),this.form.type=this.activeName.id):this.activeName!=null&&(this.form={type:this.activeName.id,difficultyLevel:null,title:"",options:[],answer:[],classifyId:null,knowledgeId:null,analysis:""}),this.modifyBackupForm&&this.activeName.id===this.modifyBackupForm.type&&(this.form.answer=[...this.modifyBackupForm.answer],this.form.options=[...this.modifyBackupForm.options]),this.form.answer&&["radio","checkbox"].includes(this.currentOptionElement)&&(this.form.answer.every(t=>typeof t=="number")&&(this.form.answer=[]),this.optionsWordList=g),["radio*2"].includes(this.currentOptionElement)&&(this.form.answer=((e=this.modifyBackupForm)==null?void 0:e.element)==="radio*2"&&((i=this.modifyBackupForm)==null?void 0:i.answer)?this.modifyBackupForm.answer:[1],this.form.options=["\u6B63\u786E","\u9519\u8BEF"],this.optionsWordList=[1,0]),["radio","x"].includes(this.currentOptionElement)&&this.form.answer&&this.form.answer.length>1&&this.form.answer.splice(1)},initFormData(){this.isModify&&(this.modifyBackupForm=null),this.activeName!=null&&(this.form={type:this.activeName.id,difficultyLevel:null,title:"",options:[],answer:[],classifyId:null,knowledgeId:null,analysis:""},["radio*2"].includes(this.currentOptionElement)&&(this.form.answer=[1],this.form.options=["\u6B63\u786E","\u9519\u8BEF"],this.optionsWordList=[1,0]))},cancelQuestion(){this.initFormData(),this.$router.replace({path:"/assessment-evaluation/question-bank-manage"})},deleteOption(e){this.form.options.splice(e,1)},addOption(){const e=this.form.options;if(["radio","checkbox"].includes(this.currentOptionElement)&&e.length>=this.optionsWordList.length)return this.$message.error("\u6700\u591A26\u4E2A\u9009\u9879");e.push("")},handleClick(e){},typeOnChangeHandler(e){e&&(this.form.type=e.id,this.isModify||this.initFormData(),this.changeFormInitData())},getQuestionDetails(e){this.page_is_loading=!0,b(e).then(i=>{const{data:t}=i,s=T(t);this.changeQuestionTypeTag(s.type).then(a=>{this.modifyBackupForm=s,this.form=JSON.parse(JSON.stringify(s))})}).finally(i=>{this.page_is_loading=!1})},changeQuestionTypeTag(e){const i=this;return new Promise((t,s)=>{let a=20;function n(o,l){if(l.questionTypeOptions.length>0){const r=l.questionTypeOptions.find(c=>parseInt(c.id)===parseInt(o));l.$nextTick(c=>{l.activeName=r}),t()}else a--,a>0?setTimeout(()=>{n(o,l)},100):s(new Error("\u8D85\u65F6\u8BF7\u6C42\u8BD5\u9898\u7C7B\u578B"))}n(e,i)})},selectedAnswer(e){(this.activeName.element==="radio"||this.activeName.element==="radio*2")&&(this.form.answer=[e])},confirmQuestion(){const e=this.form;if(e.classifyId==null)return this.$message.error("\u8BF7\u9009\u62E9\u79D1\u76EE");if(e.difficultyLevel==null)return this.$message.error("\u8BF7\u9009\u62E9\u96BE\u5EA6");if(e.title==="")return this.$message.error("\u8BF7\u586B\u5199\u9898\u76EE");if(!["textarea"].includes(this.currentOptionElement)&&e.options.length===0)return this.$message.error("\u8BF7\u6DFB\u52A0\u9009\u9879");if(["radio","checkbox","radio*2"].includes(this.currentOptionElement)&&e.answer.length===0)return this.$message.error("\u8BF7\u786E\u5B9A\u6B63\u786E\u7B54\u6848\u6216\u9009\u9879");if((this.activeName.element==="radio"||this.activeName.element==="radio*2")&&e.answer.length>1)return this.$message.error("\u9898\u578B\u53EA\u80FD\u9009\u62E9\u4E00\u4E2A\u6B63\u786E\u7B54\u6848");if(e.options.filter(t=>t===""||t===null).length>0)return this.$message.error("\u9009\u9879\u4E0D\u80FD\u4E3A\u7A7A");const i=L(this.form);(i.knowledgeId==="null"||i.knowledgeId==="")&&(i.knowledgeId=null),this.page_is_loading=!0,this.isModify?C(i).then(t=>{t.code===0&&(this.$message.success("\u4FEE\u6539\u6210\u529F"),this.cancelQuestion())}).catch(t=>{console.info(t)}).finally(t=>{this.page_is_loading=!1}):I(i).then(t=>{t.code===0&&(this.$message.success("\u6DFB\u52A0\u6210\u529F"),this.initFormData())}).catch(t=>{console.info(t)}).finally(t=>{this.page_is_loading=!1})},findQuestionTypeOptions(){return new Promise((e,i)=>{this.page_is_loading=!0,O().then(({data:t})=>{this.questionTypeOptions=t,this.isModify||this.questionTypeOptions.push({id:-1,name:"\u5BFC\u5165"}),this.activeName=this.activeName!=null?this.activeName:this.questionTypeOptions[0]}).catch(t=>{console.info(t)}).finally(t=>{this.page_is_loading=!1,e()})})}}},y={};var te=p(ee,G,Y,!1,ie,"a476c6b6",null,null);function ie(e){for(let i in y)this[i]=y[i]}const ge=function(){return te.exports}();export{ge as default};