import{a as P,r as Q,w as g,t as y,aj as i,c as u,o as a,S as c,K as f,b as r,R as k,a9 as C,J as h,M as S,P as F}from"./vue.D1BjjNmv.js";import{_ as T}from"./_plugin-vue_export-helper.DlAUqK2U.js";const j={class:"question-options-editor"},A={key:0},I={key:1},J={style:{width:"80px","text-align":"center"}},K={class:"option-actions"},R=P({__name:"QuestionOptionsEditor",props:{modelValue:{},questionForm:{}},emits:["update:modelValue"],setup(U,{emit:b}){const p=U,q=b,t=Q([...p.modelValue]),w=(e,o)=>e.length!==o.length?!1:e.every((l,m)=>{const d=o[m];return l.option_text===d.option_text&&l.is_correct===d.is_correct&&l.score===d.score&&l.sort===d.sort});let x=!1,_=!1;g(()=>t.value,e=>{!x&&!_&&(_=!0,y(()=>{q("update:modelValue",[...e]),_=!1}))},{deep:!0}),g(()=>p.modelValue,e=>{!_&&!w(e,t.value)&&(x=!0,y(()=>{t.value=[...e],x=!1}))},{deep:!0});const O=e=>{if(p.questionForm===1||p.questionForm===3){const o=t.value.map((l,m)=>({...l,is_correct:m===e}));t.value=o}},B=()=>{const e=t.value.length>0?Math.max(...t.value.map(l=>l.sort||0))+1:1,o=p.questionForm===4?{option_text:"",score:0,sort:e}:{option_text:"",is_correct:!1,sort:e};t.value=[...t.value,o]},E=()=>{t.value.length>2&&(t.value=t.value.slice(0,-1))};return(e,o)=>{const l=i("el-input"),m=i("el-input-number"),d=i("el-radio"),N=i("el-checkbox"),L=i("el-tooltip"),V=i("el-button"),M=i("el-card");return a(),u("div",j,[c(M,null,{default:f(()=>[e.questionForm===4?(a(),u("div",A,[o[0]||(o[0]=r("div",{class:"option-header"},[r("span",{style:{flex:"1"}},"选项内容"),r("span",{style:{width:"120px","text-align":"center"}},"分值")],-1)),(a(!0),u(k,null,C(t.value,(n,v)=>(a(),u("div",{key:v,class:"option-item"},[c(l,{modelValue:n.option_text,"onUpdate:modelValue":s=>n.option_text=s,placeholder:"请输入选项内容",style:{flex:"1","margin-right":"10px"}},null,8,["modelValue","onUpdate:modelValue"]),c(m,{modelValue:n.score,"onUpdate:modelValue":s=>n.score=s,min:0,max:10,style:{width:"120px"},placeholder:"分值"},null,8,["modelValue","onUpdate:modelValue"])]))),128))])):(a(),u("div",I,[o[1]||(o[1]=r("div",{class:"option-header"},[r("span",{style:{flex:"1"}},"选项内容"),r("span",{style:{width:"80px","text-align":"center"}},"是否正确")],-1)),(a(!0),u(k,null,C(t.value,(n,v)=>(a(),u("div",{key:v,class:"option-item"},[c(l,{modelValue:n.option_text,"onUpdate:modelValue":s=>n.option_text=s,placeholder:"请输入选项内容",style:{flex:"1","margin-right":"10px"}},null,8,["modelValue","onUpdate:modelValue"]),c(L,{content:"设置为正确答案",placement:"top",effect:"light"},{default:f(()=>[r("div",J,[e.questionForm===1||e.questionForm===3?(a(),h(d,{key:0,"model-value":n.is_correct,label:!0,onChange:s=>O(v)},null,8,["model-value","onChange"])):(a(),h(N,{key:1,modelValue:n.is_correct,"onUpdate:modelValue":s=>n.is_correct=s},null,8,["modelValue","onUpdate:modelValue"]))])]),_:2},1024)]))),128))])),r("div",K,[c(V,{type:"primary",onClick:B},{default:f(()=>o[2]||(o[2]=[F(" 添加选项 ")])),_:1}),t.value.length>2?(a(),h(V,{key:0,type:"danger",onClick:E},{default:f(()=>o[3]||(o[3]=[F(" 删除最后一项 ")])),_:1})):S("",!0)])]),_:1})])}}}),D=T(R,[["__scopeId","data-v-ae98b9c1"]]);export{D as default};
