import{a as g,r as x,f as V,w as u,aj as p,c,o as m,S as _,K as h,b as s,R as b,a9 as k,Q as B}from"./vue.D1BjjNmv.js";import{_ as N}from"./_plugin-vue_export-helper.DlAUqK2U.js";const S={class:"blank-answer-editor"},J={style:{width:"80px"}},O=g({__name:"BlankAnswerEditor",props:{modelValue:{},question:{},readonly:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(y,{emit:v}){const t=y,w=v,e=x([...t.modelValue]);return V(()=>(t.question||"").split("___").length-1),u(()=>e.value,l=>{t.readonly||JSON.stringify(l)!==JSON.stringify(t.modelValue)&&w("update:modelValue",l)},{deep:!0}),u(()=>t.modelValue,l=>{JSON.stringify(e.value)!==JSON.stringify(l)&&(e.value=[...l])},{deep:!0}),u(()=>t.question,l=>{if(t.readonly)return;const a=(l||"").split("___").length-1;if(a>0&&e.value.length!==a){const r=Array.from({length:a},(f,o)=>{var n,d;return{blank_index:o+1,correct_answer:((n=e.value[o])==null?void 0:n.correct_answer)||"",score:((d=e.value[o])==null?void 0:d.score)||5}});JSON.stringify(r)!==JSON.stringify(e.value)&&(e.value=r)}}),!t.readonly&&e.value.length===0&&(e.value=[{blank_index:1,correct_answer:"",score:5}]),(l,a)=>{const r=p("el-input"),f=p("el-input-number"),o=p("el-card");return m(),c("div",S,[_(o,null,{default:h(()=>[a[0]||(a[0]=s("div",{class:"blank-header"},[s("span",{style:{width:"80px"}},"填空序号"),s("span",{style:{flex:"1"}},"正确答案"),s("span",{style:{width:"120px","text-align":"center"}},"分值")],-1)),(m(!0),c(b,null,k(e.value,(n,d)=>(m(),c("div",{key:d,class:"blank-item"},[s("span",J,B(n.blank_index),1),_(r,{modelValue:n.correct_answer,"onUpdate:modelValue":i=>n.correct_answer=i,placeholder:"请输入正确答案",disabled:l.readonly,style:{flex:"1",margin:"0 10px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),_(f,{modelValue:n.score,"onUpdate:modelValue":i=>n.score=i,min:0,max:100,step:1,precision:0,controls:!1,disabled:l.readonly,style:{width:"120px"},placeholder:"分值"},null,8,["modelValue","onUpdate:modelValue","disabled"])]))),128)),a[1]||(a[1]=s("div",{class:"blank-tip"},' 提示：在题目中使用"___"（三个下划线）表示填空位置，系统会自动识别填空数量 ',-1))]),_:1})])}}}),U=N(O,[["__scopeId","data-v-9e19f4ea"]]);export{U as default};
