@qxs-bns/components 0.0.43 → 0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var r="0.0.43";export{r as version};
1
+ var r="0.0.44";export{r as version};
2
2
  //# sourceMappingURL=package.json.mjs.map
@@ -1,2 +1,2 @@
1
- import{ElCheckbox as e,ElRadio as l,ElInput as t,ElSelect as i,ElOption as n,ElIcon as s,ElLink as a,ElDialog as o,ElButton as r,ElMessage as d}from"element-plus/es";import{defineComponent as u,useAttrs as m,ref as c,computed as p,watch as f,onMounted as y,createElementBlock as v,openBlock as x,normalizeClass as b,unref as w,createVNode as g,createSlots as h,withCtx as k,createBlock as C,createCommentVNode as V,createElementVNode as S,createTextVNode as q,toDisplayString as _,Fragment as j,renderList as A,isRef as T,mergeProps as U}from"vue";import{CirclePlus as R,Remove as B}from"@element-plus/icons-vue";import{useNamespace as $}from"@qxs-bns/hooks";import N from"../../../subject-action/src/subject-action.vue.mjs";import I from"../../../subject-layout/src/subject-layout.vue.mjs";import K from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";import{setGuid as O}from"@qxs-bns/utils";const E={class:"preview"},M={class:"title"},z={key:0},D={key:1},L={key:0},H=["innerHTML"],Q={class:"preview-answer"},F={class:"order"},G={class:"order"},J={style:{flex:"1"}},P={class:"margin-bottom flex flex-items-center"},W={class:"margin-bottom answer-list"},X={class:"order"},Y={key:0,class:"margin-bottom flex flex-items-center"},Z={style:{flex:"1"}},ee={key:1,class:"flex"},le={style:{flex:"1"}},te={key:2,class:"margin-bottom flex"},ie={style:{flex:"1"}},ne={class:"flex flex-justify-end"};var se=u({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},customId:{type:Number,required:!1},examId:{type:Number,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(u,{emit:se}){const ae=u,oe=se,re=m(),de=c(0),ue=c(ae.isKey),me=c(1),ce=c(ae.examAnswerRelationType),pe=c([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),fe=c(2),ye=c(""),ve=c(""),xe=c(!1),be=c(""),we=c(0),ge=c(!1),he=c(""),ke=p((()=>"single"===ae.type?"单选题":"multiple"===ae.type?"多选题":"排序题")),Ce=c([]),Ve=p((()=>{const e=[];for(let l=pe.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function Se(){ae.isSave||pe.value.push({title:"",isCorrect:!1,customAnswerId:O()})}function qe(){xe.value=!1,be.value=""}function _e(){if(!ye.value)return void d.error("题目标题不能为空!");if(!me.value)return void d.error("请选择答题设置");let e="",l=!1,t=0;if("multiple"===ae.type||"single"===ae.type?pe.value.forEach(((i,n)=>{i.title?.trim()||(e+=`选项${String.fromCharCode(65+n)}未填写。`),i.isCorrect&&(l=!0,t++),i.relationType=i.resultItem?1:i.answerRelations?.length?2:null})):"sort"===ae.type&&Ce.value.length&&(l=!0),e)return void d.error(e);if(new Set(pe.value.map((e=>e.title))).size===pe.value.length){if("multiple"===ae.type){if(1===t)return void d.error("请至少设置两个支持选项");if(l&&t<fe.value)return void d.error("至少选几项与支持选项数不符")}2!==me.value&&3!==me.value||l?oe("save",{title:ye.value,answers:pe.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:Ce.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:ve.value,isSetCorrectAnswer:l,leastAnswerCount:fe.value,examRichTextContent:xe.value?be.value:"",examAnswerRelationType:ce.value,isKey:ue.value,answerCheckType:me.value}):d.error("请设置支持选项")}else d.error("选项不能重复")}function je(){pe.value[de.value].resultItem=he.value||"",ge.value=!1}function Ae(){ge.value=!1,he.value=""}function Te(e){ue.value=e}function Ue(e){me.value=e}function Re(e,l){oe("add",e,l?ae.examAnswerRelationType:null)}f((()=>ae.isEdit),(()=>{ae.isEdit&&(we.value=(new Date).getTime())}));const Be=p((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),$e=$("subject-single");return y((function(){if(ae.title&&(ye.value=ae.title),ae.answerCheckType&&(me.value=ae.answerCheckType),ae.isKey&&(ue.value=ae.isKey),ae.examAnswerRelationType&&(ce.value=ae.examAnswerRelationType),ae.answerList&&ae.answerList.length&&(pe.value=ae.answerList),ae.leastAnswerCount&&(fe.value=ae.leastAnswerCount),ae.examExpand&&ae.examExpand){const e=ae.examExpand.split(",");Ce.value=e.map((e=>{const l=ae.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}ae.analysis&&(ve.value=ae.analysis),ae.examRichTextContent&&(be.value=ae.examRichTextContent,xe.value=!0)})),(d,u)=>{const m=e,c=l,p=t,f=n,y=i,$=s,se=a,we=r,Ne=o;return x(),v("div",{class:b(w($e).e("single-exam"))},[g(I,{"show-edit":d.isEdit},h({preview:k((()=>[S("div",E,[S("div",null,[S("span",M,[q(_(d.orderIndex+1)+"."+_(w(ye))+" ",1),"single"===d.type?(x(),v("span",z,"(单选题)")):["multiple","sort"].includes(d.type)?(x(),v("span",D," ("+_(w(ke))+_(w(fe)?`至少选${w(fe)}项${"sort"===d.type?"并排序":""}`:"")+") ",1)):V("v-if",!0)])]),w(xe)?(x(),v("div",L,[S("div",{innerHTML:w(be)},null,8,H)])):V("v-if",!0),S("div",Q,["sort"===d.type?(x(!0),v(j,{key:0},A(w(pe),((e,l)=>(x(),C(m,{key:l,class:"radio",disabled:!0},{default:k((()=>[S("span",F,_(String.fromCharCode(65+l))+". ",1),q(" "+_(e.title),1)])),_:2},1024)))),128)):(x(!0),v(j,{key:1},A(w(pe),((e,l)=>(x(),C(c,{key:l,class:"radio",value:"disabled",disabled:""},{default:k((()=>[S("span",G,_(String.fromCharCode(65+l))+". ",1),q(" "+_(e.title)+" "+_(e.isCorrect?"(支持选项)":"")+" "+_(1===w(ce)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+_(2===w(ce)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:k((()=>[d.showAction?(x(),C(N,{key:0,"is-edit":d.isEdit,"is-set":d.isSet,isKey:w(ue),showOtherOption:"multiple"===ae.type||"single"===ae.type,examAnswerRelationType:ae.examAnswerRelationType,answerCheckType:w(me),onMoveUp:u[5]||(u[5]=e=>oe("move","up")),onMoveDown:u[6]||(u[6]=e=>oe("move","down")),onDelete:u[7]||(u[7]=e=>oe("delete")),onSave:_e,onEdit:u[8]||(u[8]=e=>oe("edit")),onAdd:Re,onOnShowRichText:u[9]||(u[9]=e=>xe.value=!0),onSetKey:Te,onSetAnswerSetting:Ue},null,8,["is-edit","is-set","isKey","showOtherOption","examAnswerRelationType","answerCheckType"])):V("v-if",!0)])),_:2},[d.isEdit?{name:"edit",fn:k((()=>[S("div",{class:b(["flex",[{"margin-bottom":w(xe)}]])},[u[12]||(u[12]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"题目:")],-1)),S("div",J,[g(p,{modelValue:w(ye),"onUpdate:modelValue":u[0]||(u[0]=e=>T(ye)?ye.value=e:null),type:"textarea",rows:2,placeholder:`【${w(ke)}】请输入问题`,disabled:d.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),S("div",P,[u[13]||(u[13]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"设置:")],-1)),["multiple","sort"].includes(d.type)?(x(),C(y,{key:0,modelValue:w(fe),"onUpdate:modelValue":u[1]||(u[1]=e=>T(fe)?fe.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:d.isSave},{default:k((()=>[(x(!0),v(j,null,A(w(Ve),(e=>(x(),C(f,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):V("v-if",!0)]),S("div",W,[(x(!0),v(j,null,A(w(pe),((e,l)=>(x(),v("div",{key:l,class:"answer-item flex flex-items-center"},[S("span",X,_(String.fromCharCode(65+l))+".",1),g(p,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+l)}`,disabled:d.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(d.type)?(x(),C(m,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:b([{"is-correct":e.isCorrect}]),disabled:d.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===ae.type?(l&&pe.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===ae.type&&(e.isCorrect=l)}(e,l)},{default:k((()=>[...u[14]||(u[14]=[q(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):V("v-if",!0),g($,{class:"icon"},{default:k((()=>[g(w(R),{class:b([{disabled:d.isSave}]),onClick:Se},null,8,["class"])])),_:1}),g($,{class:"icon"},{default:k((()=>[g(w(B),{class:b([{disabled:w(pe).length<3||d.isSave}]),onClick:e=>function(e){pe.value.length<3||ae.isSave||pe.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024),1===w(ce)&&"sort"!==d.type?(x(),C(se,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=l,de.value=t,he.value=pe.value[t].resultItem||"",void(ge.value=!0);var t}},{default:k((()=>[S("span",null,_(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):V("v-if",!0),2===w(ce)&&"sort"!==d.type?(x(),C(se,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||O(),oe("setRelation",ae.customId,e)}(e)},{default:k((()=>[S("span",null,_(e.answerRelations?.length?`关联了${w(Be)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):V("v-if",!0)])))),128))]),"sort"===d.type?(x(),v("div",Y,[u[15]||(u[15]=S("div",{class:"label flex flex-justify-end"},[S("span",null,"排序答案:")],-1)),S("div",Z,[g(y,{modelValue:w(Ce),"onUpdate:modelValue":u[2]||(u[2]=e=>T(Ce)?Ce.value=e:null),multiple:"",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:k((()=>[V(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(x(!0),v(j,null,A(w(pe),((e,l)=>(x(),C(f,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):V("v-if",!0),d.showAnalysis?(x(),v("div",ee,[u[16]||(u[16]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"解析:")],-1)),S("div",le,[g(p,{modelValue:w(ve),"onUpdate:modelValue":u[3]||(u[3]=e=>T(ve)?ve.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):V("v-if",!0),w(xe)?(x(),v("div",te,[u[18]||(u[18]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"富文本:")],-1)),S("div",ie,[g(K,U({"model-value":w(be),"onUpdate:modelValue":u[4]||(u[4]=e=>T(be)?be.value=e:null)},w(re),{style:{width:"100%"}}),null,16,["model-value"]),S("div",ne,[g(se,{type:"danger",onClick:qe},{default:k((()=>u[17]||(u[17]=[q(" 删除富文本 ")]))),_:1})])])])):V("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),g(Ne,{modelValue:w(ge),"onUpdate:modelValue":u[11]||(u[11]=e=>T(ge)?ge.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:k((()=>[g(we,{class:"customize-button",type:"primary",plain:"",onClick:Ae},{default:k((()=>u[19]||(u[19]=[q(" 取消 ")]))),_:1}),g(we,{class:"customize-button",type:"primary",plain:"",onClick:je},{default:k((()=>u[20]||(u[20]=[q(" 保存 ")]))),_:1})])),default:k((()=>[(x(),C(K,U({key:w(de),"model-value":w(he),"onUpdate:modelValue":u[10]||(u[10]=e=>T(he)?he.value=e:null)},w(re),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});export{se as default};
1
+ import{ElCheckbox as e,ElRadio as l,ElInput as t,ElSelect as i,ElOption as n,ElIcon as s,ElLink as a,ElDialog as o,ElButton as r,ElMessage as d}from"element-plus/es";import{defineComponent as u,useAttrs as m,ref as c,computed as p,watch as f,onMounted as y,createElementBlock as v,openBlock as x,normalizeClass as b,unref as w,createVNode as g,createSlots as h,withCtx as k,createBlock as C,createCommentVNode as V,createElementVNode as S,createTextVNode as q,toDisplayString as _,Fragment as j,renderList as A,isRef as T,mergeProps as U}from"vue";import{CirclePlus as R,Remove as B}from"@element-plus/icons-vue";import{useNamespace as $}from"@qxs-bns/hooks";import N from"../../../subject-action/src/subject-action.vue.mjs";import I from"../../../subject-layout/src/subject-layout.vue.mjs";import K from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";import{setGuid as O}from"@qxs-bns/utils";const E={class:"preview"},M={class:"title"},z={key:0},D={key:1},L={key:0},H=["innerHTML"],Q={class:"preview-answer"},F={class:"order"},G={class:"order"},J={style:{flex:"1"}},P={class:"margin-bottom flex flex-items-center"},W={class:"margin-bottom answer-list"},X={class:"order"},Y={key:0,class:"margin-bottom flex flex-items-center"},Z={style:{flex:"1"}},ee={key:1,class:"flex"},le={style:{flex:"1"}},te={key:2,class:"margin-bottom flex"},ie={style:{flex:"1"}},ne={class:"flex flex-justify-end"};var se=u({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},customId:{type:Number,required:!1},examId:{type:Number,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(u,{emit:se}){const ae=u,oe=se,re=m(),de=c(0),ue=c(ae.isKey),me=c(ae.answerCheckType),ce=c(ae.examAnswerRelationType),pe=c([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),fe=c(2),ye=c(""),ve=c(""),xe=c(!1),be=c(""),we=c(0),ge=c(!1),he=c(""),ke=p((()=>"single"===ae.type?"单选题":"multiple"===ae.type?"多选题":"排序题")),Ce=c([]),Ve=p((()=>{const e=[];for(let l=pe.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function Se(){ae.isSave||pe.value.push({title:"",isCorrect:!1,customAnswerId:O()})}function qe(){xe.value=!1,be.value=""}function _e(){if(!ye.value)return void d.error("题目标题不能为空!");if(!me.value)return void d.error("请选择答题设置");let e="",l=!1,t=0;if("multiple"===ae.type||"single"===ae.type?pe.value.forEach(((i,n)=>{i.title?.trim()||(e+=`选项${String.fromCharCode(65+n)}未填写。`),i.isCorrect&&(l=!0,t++),i.relationType=i.resultItem?1:i.answerRelations?.length?2:null})):"sort"===ae.type&&Ce.value.length&&(l=!0),e)return void d.error(e);if(new Set(pe.value.map((e=>e.title))).size===pe.value.length){if("multiple"===ae.type){if(1===t)return void d.error("请至少设置两个支持选项");if(l&&t<fe.value)return void d.error("至少选几项与支持选项数不符")}2!==me.value&&3!==me.value||l?oe("save",{title:ye.value,answers:pe.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:Ce.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:ve.value,isSetCorrectAnswer:l,leastAnswerCount:fe.value,examRichTextContent:xe.value?be.value:"",examAnswerRelationType:ce.value,isKey:ue.value,answerCheckType:me.value}):d.error("请设置支持选项")}else d.error("选项不能重复")}function je(){pe.value[de.value].resultItem=he.value||"",ge.value=!1}function Ae(){ge.value=!1,he.value=""}function Te(e){ue.value=e}function Ue(e){me.value=e}function Re(e,l){oe("add",e,l?ae.examAnswerRelationType:null)}f((()=>ae.isEdit),(()=>{ae.isEdit&&(we.value=(new Date).getTime())}));const Be=p((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),$e=$("subject-single");return y((function(){if(ae.title&&(ye.value=ae.title),ae.answerCheckType&&(me.value=ae.answerCheckType),ae.isKey&&(ue.value=ae.isKey),ae.examAnswerRelationType&&(ce.value=ae.examAnswerRelationType),ae.answerList&&ae.answerList.length&&(pe.value=ae.answerList),ae.leastAnswerCount&&(fe.value=ae.leastAnswerCount),ae.examExpand&&ae.examExpand){const e=ae.examExpand.split(",");Ce.value=e.map((e=>{const l=ae.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}ae.analysis&&(ve.value=ae.analysis),ae.examRichTextContent&&(be.value=ae.examRichTextContent,xe.value=!0)})),(d,u)=>{const m=e,c=l,p=t,f=n,y=i,$=s,se=a,we=r,Ne=o;return x(),v("div",{class:b(w($e).e("single-exam"))},[g(I,{"show-edit":d.isEdit},h({preview:k((()=>[S("div",E,[S("div",null,[S("span",M,[q(_(d.orderIndex+1)+"."+_(w(ye))+" ",1),"single"===d.type?(x(),v("span",z,"(单选题)")):["multiple","sort"].includes(d.type)?(x(),v("span",D," ("+_(w(ke))+_(w(fe)?`至少选${w(fe)}项${"sort"===d.type?"并排序":""}`:"")+") ",1)):V("v-if",!0)])]),w(xe)?(x(),v("div",L,[S("div",{innerHTML:w(be)},null,8,H)])):V("v-if",!0),S("div",Q,["sort"===d.type?(x(!0),v(j,{key:0},A(w(pe),((e,l)=>(x(),C(m,{key:l,class:"radio",disabled:!0},{default:k((()=>[S("span",F,_(String.fromCharCode(65+l))+". ",1),q(" "+_(e.title),1)])),_:2},1024)))),128)):(x(!0),v(j,{key:1},A(w(pe),((e,l)=>(x(),C(c,{key:l,class:"radio",value:"disabled",disabled:""},{default:k((()=>[S("span",G,_(String.fromCharCode(65+l))+". ",1),q(" "+_(e.title)+" "+_(e.isCorrect?"(支持选项)":"")+" "+_(1===w(ce)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+_(2===w(ce)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:k((()=>[d.showAction?(x(),C(N,{key:0,"is-edit":d.isEdit,"is-set":d.isSet,isKey:w(ue),showOtherOption:"multiple"===ae.type||"single"===ae.type,examAnswerRelationType:ae.examAnswerRelationType,answerCheckType:w(me),onMoveUp:u[5]||(u[5]=e=>oe("move","up")),onMoveDown:u[6]||(u[6]=e=>oe("move","down")),onDelete:u[7]||(u[7]=e=>oe("delete")),onSave:_e,onEdit:u[8]||(u[8]=e=>oe("edit")),onAdd:Re,onOnShowRichText:u[9]||(u[9]=e=>xe.value=!0),onSetKey:Te,onSetAnswerSetting:Ue},null,8,["is-edit","is-set","isKey","showOtherOption","examAnswerRelationType","answerCheckType"])):V("v-if",!0)])),_:2},[d.isEdit?{name:"edit",fn:k((()=>[S("div",{class:b(["flex",[{"margin-bottom":w(xe)}]])},[u[12]||(u[12]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"题目:")],-1)),S("div",J,[g(p,{modelValue:w(ye),"onUpdate:modelValue":u[0]||(u[0]=e=>T(ye)?ye.value=e:null),type:"textarea",rows:2,placeholder:`【${w(ke)}】请输入问题`,disabled:d.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),S("div",P,[u[13]||(u[13]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"设置:")],-1)),["multiple","sort"].includes(d.type)?(x(),C(y,{key:0,modelValue:w(fe),"onUpdate:modelValue":u[1]||(u[1]=e=>T(fe)?fe.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:d.isSave},{default:k((()=>[(x(!0),v(j,null,A(w(Ve),(e=>(x(),C(f,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):V("v-if",!0)]),S("div",W,[(x(!0),v(j,null,A(w(pe),((e,l)=>(x(),v("div",{key:l,class:"answer-item flex flex-items-center"},[S("span",X,_(String.fromCharCode(65+l))+".",1),g(p,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+l)}`,disabled:d.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(d.type)?(x(),C(m,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:b([{"is-correct":e.isCorrect}]),disabled:d.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===ae.type?(l&&pe.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===ae.type&&(e.isCorrect=l)}(e,l)},{default:k((()=>[...u[14]||(u[14]=[q(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):V("v-if",!0),g($,{class:"icon"},{default:k((()=>[g(w(R),{class:b([{disabled:d.isSave}]),onClick:Se},null,8,["class"])])),_:1}),g($,{class:"icon"},{default:k((()=>[g(w(B),{class:b([{disabled:w(pe).length<3||d.isSave}]),onClick:e=>function(e){pe.value.length<3||ae.isSave||pe.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024),1===w(ce)&&"sort"!==d.type?(x(),C(se,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=l,de.value=t,he.value=pe.value[t].resultItem||"",void(ge.value=!0);var t}},{default:k((()=>[S("span",null,_(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):V("v-if",!0),2===w(ce)&&"sort"!==d.type?(x(),C(se,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||O(),oe("setRelation",ae.customId,e)}(e)},{default:k((()=>[S("span",null,_(e.answerRelations?.length?`关联了${w(Be)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):V("v-if",!0)])))),128))]),"sort"===d.type?(x(),v("div",Y,[u[15]||(u[15]=S("div",{class:"label flex flex-justify-end"},[S("span",null,"排序答案:")],-1)),S("div",Z,[g(y,{modelValue:w(Ce),"onUpdate:modelValue":u[2]||(u[2]=e=>T(Ce)?Ce.value=e:null),multiple:"",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:k((()=>[V(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(x(!0),v(j,null,A(w(pe),((e,l)=>(x(),C(f,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):V("v-if",!0),d.showAnalysis?(x(),v("div",ee,[u[16]||(u[16]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"解析:")],-1)),S("div",le,[g(p,{modelValue:w(ve),"onUpdate:modelValue":u[3]||(u[3]=e=>T(ve)?ve.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):V("v-if",!0),w(xe)?(x(),v("div",te,[u[18]||(u[18]=S("div",{class:"label flex flex-justify-center"},[S("span",null,"富文本:")],-1)),S("div",ie,[g(K,U({"model-value":w(be),"onUpdate:modelValue":u[4]||(u[4]=e=>T(be)?be.value=e:null)},w(re),{style:{width:"100%"}}),null,16,["model-value"]),S("div",ne,[g(se,{type:"danger",onClick:qe},{default:k((()=>u[17]||(u[17]=[q(" 删除富文本 ")]))),_:1})])])])):V("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),g(Ne,{modelValue:w(ge),"onUpdate:modelValue":u[11]||(u[11]=e=>T(ge)?ge.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:k((()=>[g(we,{class:"customize-button",type:"primary",plain:"",onClick:Ae},{default:k((()=>u[19]||(u[19]=[q(" 取消 ")]))),_:1}),g(we,{class:"customize-button",type:"primary",plain:"",onClick:je},{default:k((()=>u[20]||(u[20]=[q(" 保存 ")]))),_:1})])),default:k((()=>[(x(),C(K,U({key:w(de),"model-value":w(he),"onUpdate:modelValue":u[10]||(u[10]=e=>T(he)?he.value=e:null)},w(re),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});export{se as default};
2
2
  //# sourceMappingURL=subject-single.vue.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"subject-single.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-single.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport SubjectAction from '../../../subject-action/src/subject-action.vue'\nimport SubjectLayout from '../../../subject-layout/src/subject-layout.vue'\nimport TinyMceEditor from '../../../tiny-mce-editor/src/tiny-mce-editor.vue'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectSingle',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n type: 'single' | 'multiple' | 'sort'\n isEdit: boolean\n isSet: boolean\n answerList?: any\n leastAnswerCount?: number\n analysis?: string\n examExpand?: string\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n customId?: number\n examId?: number\n isKey: boolean\n answerCheckType: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add', 'setRelation'])\n\nconst attrs = useAttrs()\n\nconst answersIndex = ref(0)\nconst isKey = ref(props.isKey)\nconst answerCheckType = ref(1)\nconst examAnswerRelationType = ref(props.examAnswerRelationType)\nconst answers = ref<{\n title: string\n isCorrect: boolean\n orderIndex?: number\n resultItem?: string\n customAnswerId?: string\n answerRelations?: {\n relationExamId: number\n relationAnswers: {\n relationAnswerId: number\n relationAnswerIndex: number\n }[]\n }[]\n}[]>([{\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref(2)\nconst title = ref('')\nconst analysis = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst startTime = ref(0)\nconst showRichContent = ref(false)\nconst resultItem = ref<string>('')\nconst titlePlaceholder = computed(() => {\n if (props.type === 'single') {\n return '单选题'\n }\n else if (props.type === 'multiple') {\n return '多选题'\n }\n else {\n return '排序题'\n }\n})\n\nconst orderList = ref<string[]>([])\n\nconst leastAnswerOptions = computed(() => {\n const items = []\n const length = answers.value.length\n for (let count = length; count > 1; count--) {\n items.push({\n label: `至少选择${count}项`,\n value: count,\n })\n }\n return items.reverse()\n})\nfunction addAnswer() {\n if (props.isSave) {\n return\n }\n answers.value.push({\n title: '',\n isCorrect: false,\n customAnswerId: setGuid()\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3 || props.isSave) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction setCorrect(it: any, event: any) {\n if (props.type === 'single') {\n // 单选题:确保只有一个支持选项\n if (event) {\n answers.value.forEach((answer: any) => {\n if (answer !== it) {\n answer.isCorrect = false\n }\n })\n }\n it.isCorrect = event\n } else if (props.type === 'multiple') {\n // 多选题:可以有多个支持选项\n it.isCorrect = event\n }\n}\nfunction setRelation(item: any) {\n item.customAnswerId = item.examAnswerId || setGuid()\n emits('setRelation', props.customId, item)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n // 答题设置必选\n if(!answerCheckType.value) {\n ElMessage.error('请选择答题设置')\n return\n }\n let msg = ''\n let isSetCorrectAnswer = false\n let correctAnswerCount = 0\n if (props.type === 'multiple' || props.type === 'single') {\n answers.value.forEach((v: any, i: number) => {\n if (!v.title?.trim()) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n v.relationType = v.resultItem ? 1 : (v.answerRelations?.length ? 2 : null)\n })\n }\n else if (props.type === 'sort') {\n // 如果设置了支持选项\n if (orderList.value.length) {\n isSetCorrectAnswer = true\n }\n }\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n const uniqueAnswer = new Set(answers.value.map((item: any) => item.title))\n\n if (uniqueAnswer.size !== answers.value.length) {\n ElMessage.error('选项不能重复')\n return\n }\n\n if (props.type === 'multiple') {\n if (correctAnswerCount === 1) {\n ElMessage.error('请至少设置两个支持选项')\n return\n }\n\n if (isSetCorrectAnswer && correctAnswerCount < leastAnswerCount.value) {\n ElMessage.error('至少选几项与支持选项数不符')\n return\n }\n } \n\n if(answerCheckType.value === 2 || answerCheckType.value === 3) {\n // 必须有设置支持选项\n if (!isSetCorrectAnswer) {\n ElMessage.error('请设置支持选项')\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.map((item: any, index: number) => {\n return { ...item, orderIndex: index + 1 }\n }),\n examExpand: orderList.value.map((i: string) => i.charCodeAt(0) - 65 + 1).join(','),\n analysis: analysis.value,\n isSetCorrectAnswer,\n leastAnswerCount: leastAnswerCount.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n examAnswerRelationType: examAnswerRelationType.value,\n isKey: isKey.value,\n answerCheckType: answerCheckType.value\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\n }\n\n if (props.isKey) {\n isKey.value = props.isKey\n }\n\n if (props.examAnswerRelationType) {\n examAnswerRelationType.value = props.examAnswerRelationType\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.leastAnswerCount) {\n leastAnswerCount.value = props.leastAnswerCount\n }\n\n if (props.examExpand) {\n // 设置支持选项 props.examExpand里是答案id\n if (props.examExpand) {\n const correctAnswerIdList = props.examExpand.split(',')\n\n // 遍历 correctAnswerIdList,直接在 props.answerList 中查找对应的 orderIndex 并转换成字母\n orderList.value = correctAnswerIdList.map((id: string) => {\n const answer = props.answerList.find((item: any) => item.answerId?.toString() === id)\n return answer ? String.fromCharCode(65 + answer.orderIndex - 1) : id\n }).filter(Boolean) // 过滤掉任何可能的空字符串\n }\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n resultItem.value = answers.value[i].resultItem || ''\n showRichContent.value = true\n}\n\nfunction onSaveResult() {\n answers.value[answersIndex.value].resultItem = resultItem.value || ''\n showRichContent.value = false\n}\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\nfunction setKey(key: boolean) {\n isKey.value = key\n}\nfunction setAnswerSetting(type: number) {\n answerCheckType.value = type\n}\n\nfunction add(type: string, canSet: boolean) {\n emits('add', type, canSet? props.examAnswerRelationType: null)\n}\n// 监听isEdit\nwatch(() => props.isEdit, () => {\n if (props.isEdit) {\n startTime.value = new Date().getTime()\n }\n})\n\nconst relationLength = computed(() => {\n return (v: any) => {\n let count = 0\n v.forEach((item: any) => {\n if (item.relationAnswers) {\n count += item.relationAnswers.length\n }\n })\n return count\n }\n})\n\nconst ns = useNamespace('subject-single')\n\nonMounted(init)\n</script>\n\n<template>\n <div :class=\"ns.e('single-exam')\">\n <SubjectLayout\n :show-edit=\"isEdit\"\n >\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">\n {{ orderIndex + 1 }}.{{ title }}\n <span v-if=\"type === 'single'\">(单选题)</span>\n <span v-else-if=\"['multiple', 'sort'].includes(type)\">\n ({{ titlePlaceholder }}{{ leastAnswerCount ? `至少选${leastAnswerCount}项${type === 'sort' ? '并排序' : ''}` : '' }})\n </span>\n </span>\n </div>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" />\n </div>\n <div class=\"preview-answer\">\n <template v-if=\"type === 'sort'\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }}\n </el-checkbox>\n </template>\n <template v-else>\n <el-radio\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n value=\"disabled\"\n disabled\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }} \n {{ item.isCorrect ? '(支持选项)' : '' }} \n {{ examAnswerRelationType === 1 ? (item.resultItem? '(已设置结果项)' : '(未设置结果项)' ) : ''}} \n {{ examAnswerRelationType === 2 ? (item.answerRelations?.length? '(已设置关联)' : '(未设置关联)') : '' }}\n </el-radio>\n </template>\n </div>\n </div>\n </template>\n <template v-if=\"isEdit\" #edit>\n <div class=\"flex\" :class=\"[{ 'margin-bottom': showRichText }]\">\n <div class=\"label flex flex-justify-center\">\n <span>题目:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n :placeholder=\"`【${titlePlaceholder}】请输入问题`\"\n :disabled=\"isSave\"\n show-word-limit\n maxlength=\"200\"\n class=\"margin-bottom\"\n />\n </div>\n </div>\n <div class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-center\">\n <span>设置:</span>\n </div>\n <el-select\n v-if=\"['multiple', 'sort'].includes(type)\"\n v-model=\"leastAnswerCount\"\n style=\"width: 150px;\"\n placeholder=\"至少选择几项\"\n :disabled=\"isSave\"\n >\n <el-option\n v-for=\"item in leastAnswerOptions\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n >\n </el-option>\n </el-select>\n </div>\n <div class=\"margin-bottom answer-list\">\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <span class=\"order\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n maxlength=\"100\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <el-checkbox\n v-if=\"['single', 'multiple'].includes(type)\"\n v-model=\"item.isCorrect\"\n :class=\"[{ 'is-correct': item.isCorrect }]\"\n :disabled=\"isSave\"\n style=\"margin-left: 10px;\"\n @change=\"(event: any) => setCorrect(item, event)\"\n >\n 支持选项 \n </el-checkbox>\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: isSave }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n <el-link\n v-if=\"examAnswerRelationType === 1 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"onOpenResult(index)\"\n >\n <span>{{ item.resultItem ? '编辑结果' : '添加结果' }}</span>\n </el-link>\n <el-link\n v-if=\"examAnswerRelationType === 2 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"setRelation(item)\"\n >\n <span>{{ item.answerRelations?.length ? `关联了${relationLength(item.answerRelations)}项` : '关联检查' }}</span>\n </el-link>\n </div>\n </div>\n <div v-if=\"type === 'sort'\" class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-end\">\n <span>排序答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-select\n v-model=\"orderList\"\n multiple\n style=\"width: 360px;\"\n placeholder=\"请按顺序选择排序答案\"\n :show-arrow=\"true\"\n >\n <!-- :options=\"[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))\" -->\n <el-option\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n :label=\"item.title\"\n :value=\"String.fromCharCode(65 + index)\"\n />\n </el-select>\n </div>\n </div>\n <div\n v-if=\"showAnalysis\"\n class=\"flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>解析:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"analysis\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入题目解析\"\n />\n </div>\n </div>\n <div v-if=\"showRichText\" class=\"margin-bottom flex\">\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor v-model:model-value=\"richText\" v-bind=\"attrs\" style=\"width: 100%;\" />\n <div class=\"flex flex-justify-end\">\n <el-link\n type=\"danger\"\n @click=\"deleteRichText\"\n >\n 删除富文本\n </el-link>\n </div>\n </div>\n </div>\n </template>\n <SubjectAction\n v-if=\"showAction\"\n :is-edit=\"isEdit\"\n :is-set=\"isSet\"\n :isKey=\"isKey\"\n :showOtherOption=\"props.type === 'multiple' || props.type === 'single'\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\n :answerCheckType=\"answerCheckType\"\n @move-up=\"emits('move', 'up')\"\n @move-down=\"emits('move', 'down')\"\n @delete=\"emits('delete')\"\n @save=\"save\"\n @edit=\"emits('edit')\"\n @add=\"add\"\n @onShowRichText=\"showRichText = true\"\n @setKey=\"setKey\"\n @setAnswerSetting=\"setAnswerSetting\"\n />\n </SubjectLayout>\n <el-dialog\n v-model=\"showRichContent\"\n title=\"添加结果\"\n class=\"customize-dialog\"\n >\n <TinyMceEditor\n :key=\"answersIndex\"\n v-model:model-value=\"resultItem\" \n v-bind=\"attrs\"\n style=\"width: 100%;\" />\n <template #footer>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onCloseResult\"\n >\n 取消\n </el-button>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onSaveResult\"\n >\n 保存\n </el-button>\n </template>\n </el-dialog>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answersIndex","ref","isKey","answerCheckType","examAnswerRelationType","answers","title","isCorrect","leastAnswerCount","analysis","showRichText","richText","startTime","showRichContent","resultItem","titlePlaceholder","computed","type","orderList","leastAnswerOptions","items","count","value","length","push","label","reverse","addAnswer","isSave","customAnswerId","setGuid","deleteRichText","save","ElMessage","error","msg","isSetCorrectAnswer","correctAnswerCount","forEach","v","i","trim","String","fromCharCode","relationType","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onSaveResult","onCloseResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","relationLength","relationAnswers","ns","useNamespace","onMounted","answerList","correctAnswerIdList","split","id","answer","find","answerId","toString","filter","Boolean","it","event","splice","examAnswerId","customId"],"mappings":"8pEAWA,MAAMA,GAAQC,EAoBRC,GAAQC,GAERC,GAAQC,IAERC,GAAeC,EAAI,GACnBC,GAAQD,EAAIP,GAAMQ,OAClBC,GAAkBF,EAAI,GACtBG,GAAyBH,EAAIP,GAAMU,wBACnCC,GAAUJ,EAaX,CAAC,CACJK,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,KAGPC,GAAmBP,EAAI,GACvBK,GAAQL,EAAI,IACZQ,GAAWR,EAAI,IACfS,GAAeT,GAAI,GACnBU,GAAWV,EAAI,IACfW,GAAYX,EAAI,GAChBY,GAAkBZ,GAAI,GACtBa,GAAab,EAAY,IACzBc,GAAmBC,GAAS,IACb,WAAftB,GAAMuB,KACD,MAEe,aAAfvB,GAAMuB,KACN,M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s","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-single.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport SubjectAction from '../../../subject-action/src/subject-action.vue'\nimport SubjectLayout from '../../../subject-layout/src/subject-layout.vue'\nimport TinyMceEditor from '../../../tiny-mce-editor/src/tiny-mce-editor.vue'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectSingle',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n type: 'single' | 'multiple' | 'sort'\n isEdit: boolean\n isSet: boolean\n answerList?: any\n leastAnswerCount?: number\n analysis?: string\n examExpand?: string\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n customId?: number\n examId?: number\n isKey: boolean\n answerCheckType: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add', 'setRelation'])\n\nconst attrs = useAttrs()\n\nconst answersIndex = ref(0)\nconst isKey = ref(props.isKey)\nconst answerCheckType = ref(props.answerCheckType)\nconst examAnswerRelationType = ref(props.examAnswerRelationType)\nconst answers = ref<{\n title: string\n isCorrect: boolean\n orderIndex?: number\n resultItem?: string\n customAnswerId?: string\n answerRelations?: {\n relationExamId: number\n relationAnswers: {\n relationAnswerId: number\n relationAnswerIndex: number\n }[]\n }[]\n}[]>([{\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref(2)\nconst title = ref('')\nconst analysis = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst startTime = ref(0)\nconst showRichContent = ref(false)\nconst resultItem = ref<string>('')\nconst titlePlaceholder = computed(() => {\n if (props.type === 'single') {\n return '单选题'\n }\n else if (props.type === 'multiple') {\n return '多选题'\n }\n else {\n return '排序题'\n }\n})\n\nconst orderList = ref<string[]>([])\n\nconst leastAnswerOptions = computed(() => {\n const items = []\n const length = answers.value.length\n for (let count = length; count > 1; count--) {\n items.push({\n label: `至少选择${count}项`,\n value: count,\n })\n }\n return items.reverse()\n})\nfunction addAnswer() {\n if (props.isSave) {\n return\n }\n answers.value.push({\n title: '',\n isCorrect: false,\n customAnswerId: setGuid()\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3 || props.isSave) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction setCorrect(it: any, event: any) {\n if (props.type === 'single') {\n // 单选题:确保只有一个支持选项\n if (event) {\n answers.value.forEach((answer: any) => {\n if (answer !== it) {\n answer.isCorrect = false\n }\n })\n }\n it.isCorrect = event\n } else if (props.type === 'multiple') {\n // 多选题:可以有多个支持选项\n it.isCorrect = event\n }\n}\nfunction setRelation(item: any) {\n item.customAnswerId = item.examAnswerId || setGuid()\n emits('setRelation', props.customId, item)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n // 答题设置必选\n if(!answerCheckType.value) {\n ElMessage.error('请选择答题设置')\n return\n }\n let msg = ''\n let isSetCorrectAnswer = false\n let correctAnswerCount = 0\n if (props.type === 'multiple' || props.type === 'single') {\n answers.value.forEach((v: any, i: number) => {\n if (!v.title?.trim()) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n v.relationType = v.resultItem ? 1 : (v.answerRelations?.length ? 2 : null)\n })\n }\n else if (props.type === 'sort') {\n // 如果设置了支持选项\n if (orderList.value.length) {\n isSetCorrectAnswer = true\n }\n }\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n const uniqueAnswer = new Set(answers.value.map((item: any) => item.title))\n\n if (uniqueAnswer.size !== answers.value.length) {\n ElMessage.error('选项不能重复')\n return\n }\n\n if (props.type === 'multiple') {\n if (correctAnswerCount === 1) {\n ElMessage.error('请至少设置两个支持选项')\n return\n }\n\n if (isSetCorrectAnswer && correctAnswerCount < leastAnswerCount.value) {\n ElMessage.error('至少选几项与支持选项数不符')\n return\n }\n } \n\n if(answerCheckType.value === 2 || answerCheckType.value === 3) {\n // 必须有设置支持选项\n if (!isSetCorrectAnswer) {\n ElMessage.error('请设置支持选项')\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.map((item: any, index: number) => {\n return { ...item, orderIndex: index + 1 }\n }),\n examExpand: orderList.value.map((i: string) => i.charCodeAt(0) - 65 + 1).join(','),\n analysis: analysis.value,\n isSetCorrectAnswer,\n leastAnswerCount: leastAnswerCount.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n examAnswerRelationType: examAnswerRelationType.value,\n isKey: isKey.value,\n answerCheckType: answerCheckType.value\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\n }\n\n if (props.isKey) {\n isKey.value = props.isKey\n }\n\n if (props.examAnswerRelationType) {\n examAnswerRelationType.value = props.examAnswerRelationType\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.leastAnswerCount) {\n leastAnswerCount.value = props.leastAnswerCount\n }\n\n if (props.examExpand) {\n // 设置支持选项 props.examExpand里是答案id\n if (props.examExpand) {\n const correctAnswerIdList = props.examExpand.split(',')\n\n // 遍历 correctAnswerIdList,直接在 props.answerList 中查找对应的 orderIndex 并转换成字母\n orderList.value = correctAnswerIdList.map((id: string) => {\n const answer = props.answerList.find((item: any) => item.answerId?.toString() === id)\n return answer ? String.fromCharCode(65 + answer.orderIndex - 1) : id\n }).filter(Boolean) // 过滤掉任何可能的空字符串\n }\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n resultItem.value = answers.value[i].resultItem || ''\n showRichContent.value = true\n}\n\nfunction onSaveResult() {\n answers.value[answersIndex.value].resultItem = resultItem.value || ''\n showRichContent.value = false\n}\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\nfunction setKey(key: boolean) {\n isKey.value = key\n}\nfunction setAnswerSetting(type: number) {\n answerCheckType.value = type\n}\n\nfunction add(type: string, canSet: boolean) {\n emits('add', type, canSet? props.examAnswerRelationType: null)\n}\n// 监听isEdit\nwatch(() => props.isEdit, () => {\n if (props.isEdit) {\n startTime.value = new Date().getTime()\n }\n})\n\nconst relationLength = computed(() => {\n return (v: any) => {\n let count = 0\n v.forEach((item: any) => {\n if (item.relationAnswers) {\n count += item.relationAnswers.length\n }\n })\n return count\n }\n})\n\nconst ns = useNamespace('subject-single')\n\nonMounted(init)\n</script>\n\n<template>\n <div :class=\"ns.e('single-exam')\">\n <SubjectLayout\n :show-edit=\"isEdit\"\n >\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">\n {{ orderIndex + 1 }}.{{ title }}\n <span v-if=\"type === 'single'\">(单选题)</span>\n <span v-else-if=\"['multiple', 'sort'].includes(type)\">\n ({{ titlePlaceholder }}{{ leastAnswerCount ? `至少选${leastAnswerCount}项${type === 'sort' ? '并排序' : ''}` : '' }})\n </span>\n </span>\n </div>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" />\n </div>\n <div class=\"preview-answer\">\n <template v-if=\"type === 'sort'\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }}\n </el-checkbox>\n </template>\n <template v-else>\n <el-radio\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n value=\"disabled\"\n disabled\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }} \n {{ item.isCorrect ? '(支持选项)' : '' }} \n {{ examAnswerRelationType === 1 ? (item.resultItem? '(已设置结果项)' : '(未设置结果项)' ) : ''}} \n {{ examAnswerRelationType === 2 ? (item.answerRelations?.length? '(已设置关联)' : '(未设置关联)') : '' }}\n </el-radio>\n </template>\n </div>\n </div>\n </template>\n <template v-if=\"isEdit\" #edit>\n <div class=\"flex\" :class=\"[{ 'margin-bottom': showRichText }]\">\n <div class=\"label flex flex-justify-center\">\n <span>题目:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n :placeholder=\"`【${titlePlaceholder}】请输入问题`\"\n :disabled=\"isSave\"\n show-word-limit\n maxlength=\"200\"\n class=\"margin-bottom\"\n />\n </div>\n </div>\n <div class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-center\">\n <span>设置:</span>\n </div>\n <el-select\n v-if=\"['multiple', 'sort'].includes(type)\"\n v-model=\"leastAnswerCount\"\n style=\"width: 150px;\"\n placeholder=\"至少选择几项\"\n :disabled=\"isSave\"\n >\n <el-option\n v-for=\"item in leastAnswerOptions\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n >\n </el-option>\n </el-select>\n </div>\n <div class=\"margin-bottom answer-list\">\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <span class=\"order\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n maxlength=\"100\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <el-checkbox\n v-if=\"['single', 'multiple'].includes(type)\"\n v-model=\"item.isCorrect\"\n :class=\"[{ 'is-correct': item.isCorrect }]\"\n :disabled=\"isSave\"\n style=\"margin-left: 10px;\"\n @change=\"(event: any) => setCorrect(item, event)\"\n >\n 支持选项 \n </el-checkbox>\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: isSave }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n <el-link\n v-if=\"examAnswerRelationType === 1 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"onOpenResult(index)\"\n >\n <span>{{ item.resultItem ? '编辑结果' : '添加结果' }}</span>\n </el-link>\n <el-link\n v-if=\"examAnswerRelationType === 2 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"setRelation(item)\"\n >\n <span>{{ item.answerRelations?.length ? `关联了${relationLength(item.answerRelations)}项` : '关联检查' }}</span>\n </el-link>\n </div>\n </div>\n <div v-if=\"type === 'sort'\" class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-end\">\n <span>排序答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-select\n v-model=\"orderList\"\n multiple\n style=\"width: 360px;\"\n placeholder=\"请按顺序选择排序答案\"\n :show-arrow=\"true\"\n >\n <!-- :options=\"[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))\" -->\n <el-option\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n :label=\"item.title\"\n :value=\"String.fromCharCode(65 + index)\"\n />\n </el-select>\n </div>\n </div>\n <div\n v-if=\"showAnalysis\"\n class=\"flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>解析:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"analysis\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入题目解析\"\n />\n </div>\n </div>\n <div v-if=\"showRichText\" class=\"margin-bottom flex\">\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor v-model:model-value=\"richText\" v-bind=\"attrs\" style=\"width: 100%;\" />\n <div class=\"flex flex-justify-end\">\n <el-link\n type=\"danger\"\n @click=\"deleteRichText\"\n >\n 删除富文本\n </el-link>\n </div>\n </div>\n </div>\n </template>\n <SubjectAction\n v-if=\"showAction\"\n :is-edit=\"isEdit\"\n :is-set=\"isSet\"\n :isKey=\"isKey\"\n :showOtherOption=\"props.type === 'multiple' || props.type === 'single'\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\n :answerCheckType=\"answerCheckType\"\n @move-up=\"emits('move', 'up')\"\n @move-down=\"emits('move', 'down')\"\n @delete=\"emits('delete')\"\n @save=\"save\"\n @edit=\"emits('edit')\"\n @add=\"add\"\n @onShowRichText=\"showRichText = true\"\n @setKey=\"setKey\"\n @setAnswerSetting=\"setAnswerSetting\"\n />\n </SubjectLayout>\n <el-dialog\n v-model=\"showRichContent\"\n title=\"添加结果\"\n class=\"customize-dialog\"\n >\n <TinyMceEditor\n :key=\"answersIndex\"\n v-model:model-value=\"resultItem\" \n v-bind=\"attrs\"\n style=\"width: 100%;\" />\n <template #footer>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onCloseResult\"\n >\n 取消\n </el-button>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onSaveResult\"\n >\n 保存\n </el-button>\n </template>\n </el-dialog>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answersIndex","ref","isKey","answerCheckType","examAnswerRelationType","answers","title","isCorrect","leastAnswerCount","analysis","showRichText","richText","startTime","showRichContent","resultItem","titlePlaceholder","computed","type","orderList","leastAnswerOptions","items","count","value","length","push","label","reverse","addAnswer","isSave","customAnswerId","setGuid","deleteRichText","save","ElMessage","error","msg","isSetCorrectAnswer","correctAnswerCount","forEach","v","i","trim","String","fromCharCode","relationType","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onSaveResult","onCloseResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","relationLength","relationAnswers","ns","useNamespace","onMounted","answerList","correctAnswerIdList","split","id","answer","find","answerId","toString","filter","Boolean","it","event","splice","examAnswerId","customId"],"mappings":"8pEAWA,MAAMA,GAAQC,EAoBRC,GAAQC,GAERC,GAAQC,IAERC,GAAeC,EAAI,GACnBC,GAAQD,EAAIP,GAAMQ,OAClBC,GAAkBF,EAAIP,GAAMS,iBAC5BC,GAAyBH,EAAIP,GAAMU,wBACnCC,GAAUJ,EAaX,CAAC,CACJK,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,KAGPC,GAAmBP,EAAI,GACvBK,GAAQL,EAAI,IACZQ,GAAWR,EAAI,IACfS,GAAeT,GAAI,GACnBU,GAAWV,EAAI,IACfW,GAAYX,EAAI,GAChBY,GAAkBZ,GAAI,GACtBa,GAAab,EAAY,IACzBc,GAAmBC,GAAS,IACb,WAAftB,GAAMuB,KACD,MAEe,aAAfvB,GAAMuB,KACN,MAGA,QAILC,GAAYjB,EAAc,IAE1BkB,GAAqBH,GAAS,KAClC,MAAMI,EAAQ,GAEd,IAAA,IAASC,EADMhB,GAAQiB,MAAMC,OACJF,EAAQ,EAAGA,IAClCD,EAAMI,KAAK,CACTC,MAAO,OAAOJ,KACdC,MAAOD,IAGX,OAAOD,EAAMM,SAAQ,IAEvB,SAASC,KACHjC,GAAMkC,QAGVvB,GAAQiB,MAAME,KAAK,CACjBlB,MAAO,GACPC,WAAW,EACXsB,eAAgBC,KACjB,CA+BH,SAASC,KACPrB,GAAaY,OAAQ,EACrBX,GAASW,MAAQ,EAAA,CAGnB,SAASU,KACH,IAAC1B,GAAMgB,MAET,YADAW,EAAUC,MAAM,aAIf,IAAC/B,GAAgBmB,MAElB,YADAW,EAAUC,MAAM,WAGlB,IAAIC,EAAM,GACNC,GAAqB,EACrBC,EAAqB,EAmBzB,GAlBmB,aAAf3C,GAAMuB,MAAsC,WAAfvB,GAAMuB,KACrCZ,GAAQiB,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,GAAM6D,oBACvB7C,GAAaY,OAAQ,EACvB,qpGAtJO,SAAW4D,EAASC,GACR,WAAfzF,GAAMuB,MAEJkE,GACM9E,GAAAiB,MAAMgB,SAASsC,IACjBA,IAAWM,IACbN,EAAOrE,WAAY,EAAA,IAIzB2E,EAAG3E,UAAY4E,GACS,aAAfzF,GAAMuB,OAEfiE,EAAG3E,UAAY4E,EACjB,gXArBF,SAAsBjC,GAChB7C,GAAQiB,MAAMC,OAAS,GAAK7B,GAAMkC,QAG9BvB,GAAAiB,MAAM8D,OAAOlC,EAAO,EAAC,qJA2JTV,IACpBxC,GAAasB,MAAQkB,EACrB1B,GAAWQ,MAAQjB,GAAQiB,MAAMkB,GAAG1B,YAAc,QAClDD,GAAgBS,OAAQ,GAH1B,IAAsBkB,yMAxItB,SAAqBQ,GACdA,EAAAnB,eAAiBmB,EAAKqC,cAAgBvD,IACrClC,GAAA,cAAeF,GAAM4F,SAAUtC,EAAI"}
@@ -1,2 +1,2 @@
1
- "use strict";exports.version="0.0.43";
1
+ "use strict";exports.version="0.0.44";
2
2
  //# sourceMappingURL=package.json.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es"),l=require("vue"),t=require("@element-plus/icons-vue"),i=require("@qxs-bns/hooks"),s=require("../../../subject-action/src/subject-action.vue.cjs"),n=require("../../../subject-layout/src/subject-layout.vue.cjs"),a=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.cjs"),r=require("@qxs-bns/utils");const o={class:"preview"},u={class:"title"},d={key:0},c={key:1},p={key:0},m=["innerHTML"],y={class:"preview-answer"},f={class:"order"},v={class:"order"},x={style:{flex:"1"}},b={class:"margin-bottom flex flex-items-center"},w={class:"margin-bottom answer-list"},g={class:"order"},h={key:0,class:"margin-bottom flex flex-items-center"},k={style:{flex:"1"}},q={key:1,class:"flex"},C={style:{flex:"1"}},V={key:2,class:"margin-bottom flex"},S={style:{flex:"1"}},_={class:"flex flex-justify-end"};var j=l.defineComponent({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},customId:{type:Number,required:!1},examId:{type:Number,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(j,{emit:A}){const T=j,U=A,R=l.useAttrs(),B=l.ref(0),$=l.ref(T.isKey),N=l.ref(1),O=l.ref(T.examAnswerRelationType),I=l.ref([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),K=l.ref(2),M=l.ref(""),E=l.ref(""),z=l.ref(!1),D=l.ref(""),L=l.ref(0),H=l.ref(!1),Q=l.ref(""),F=l.computed((()=>"single"===T.type?"单选题":"multiple"===T.type?"多选题":"排序题")),G=l.ref([]),J=l.computed((()=>{const e=[];for(let l=I.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function P(){T.isSave||I.value.push({title:"",isCorrect:!1,customAnswerId:r.setGuid()})}function W(){z.value=!1,D.value=""}function X(){if(!M.value)return void e.ElMessage.error("题目标题不能为空!");if(!N.value)return void e.ElMessage.error("请选择答题设置");let l="",t=!1,i=0;if("multiple"===T.type||"single"===T.type?I.value.forEach(((e,s)=>{e.title?.trim()||(l+=`选项${String.fromCharCode(65+s)}未填写。`),e.isCorrect&&(t=!0,i++),e.relationType=e.resultItem?1:e.answerRelations?.length?2:null})):"sort"===T.type&&G.value.length&&(t=!0),l)return void e.ElMessage.error(l);if(new Set(I.value.map((e=>e.title))).size===I.value.length){if("multiple"===T.type){if(1===i)return void e.ElMessage.error("请至少设置两个支持选项");if(t&&i<K.value)return void e.ElMessage.error("至少选几项与支持选项数不符")}2!==N.value&&3!==N.value||t?U("save",{title:M.value,answers:I.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:G.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:E.value,isSetCorrectAnswer:t,leastAnswerCount:K.value,examRichTextContent:z.value?D.value:"",examAnswerRelationType:O.value,isKey:$.value,answerCheckType:N.value}):e.ElMessage.error("请设置支持选项")}else e.ElMessage.error("选项不能重复")}function Y(){I.value[B.value].resultItem=Q.value||"",H.value=!1}function Z(){H.value=!1,Q.value=""}function ee(e){$.value=e}function le(e){N.value=e}function te(e,l){U("add",e,l?T.examAnswerRelationType:null)}l.watch((()=>T.isEdit),(()=>{T.isEdit&&(L.value=(new Date).getTime())}));const ie=l.computed((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),se=i.useNamespace("subject-single");return l.onMounted((function(){if(T.title&&(M.value=T.title),T.answerCheckType&&(N.value=T.answerCheckType),T.isKey&&($.value=T.isKey),T.examAnswerRelationType&&(O.value=T.examAnswerRelationType),T.answerList&&T.answerList.length&&(I.value=T.answerList),T.leastAnswerCount&&(K.value=T.leastAnswerCount),T.examExpand&&T.examExpand){const e=T.examExpand.split(",");G.value=e.map((e=>{const l=T.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}T.analysis&&(E.value=T.analysis),T.examRichTextContent&&(D.value=T.examRichTextContent,z.value=!0)})),(i,j)=>{const A=e.ElCheckbox,L=e.ElRadio,ne=e.ElInput,ae=e.ElOption,re=e.ElSelect,oe=e.ElIcon,ue=e.ElLink,de=e.ElButton,ce=e.ElDialog;return l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(l.unref(se).e("single-exam"))},[l.createVNode(n.default,{"show-edit":i.isEdit},l.createSlots({preview:l.withCtx((()=>[l.createElementVNode("div",o,[l.createElementVNode("div",null,[l.createElementVNode("span",u,[l.createTextVNode(l.toDisplayString(i.orderIndex+1)+"."+l.toDisplayString(l.unref(M))+" ",1),"single"===i.type?(l.openBlock(),l.createElementBlock("span",d,"(单选题)")):["multiple","sort"].includes(i.type)?(l.openBlock(),l.createElementBlock("span",c," ("+l.toDisplayString(l.unref(F))+l.toDisplayString(l.unref(K)?`至少选${l.unref(K)}项${"sort"===i.type?"并排序":""}`:"")+") ",1)):l.createCommentVNode("v-if",!0)])]),l.unref(z)?(l.openBlock(),l.createElementBlock("div",p,[l.createElementVNode("div",{innerHTML:l.unref(D)},null,8,m)])):l.createCommentVNode("v-if",!0),l.createElementVNode("div",y,["sort"===i.type?(l.openBlock(!0),l.createElementBlock(l.Fragment,{key:0},l.renderList(l.unref(I),((e,t)=>(l.openBlock(),l.createBlock(A,{key:t,class:"radio",disabled:!0},{default:l.withCtx((()=>[l.createElementVNode("span",f,l.toDisplayString(String.fromCharCode(65+t))+". ",1),l.createTextVNode(" "+l.toDisplayString(e.title),1)])),_:2},1024)))),128)):(l.openBlock(!0),l.createElementBlock(l.Fragment,{key:1},l.renderList(l.unref(I),((e,t)=>(l.openBlock(),l.createBlock(L,{key:t,class:"radio",value:"disabled",disabled:""},{default:l.withCtx((()=>[l.createElementVNode("span",v,l.toDisplayString(String.fromCharCode(65+t))+". ",1),l.createTextVNode(" "+l.toDisplayString(e.title)+" "+l.toDisplayString(e.isCorrect?"(支持选项)":"")+" "+l.toDisplayString(1===l.unref(O)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+l.toDisplayString(2===l.unref(O)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:l.withCtx((()=>[i.showAction?(l.openBlock(),l.createBlock(s.default,{key:0,"is-edit":i.isEdit,"is-set":i.isSet,isKey:l.unref($),showOtherOption:"multiple"===T.type||"single"===T.type,examAnswerRelationType:T.examAnswerRelationType,answerCheckType:l.unref(N),onMoveUp:j[5]||(j[5]=e=>U("move","up")),onMoveDown:j[6]||(j[6]=e=>U("move","down")),onDelete:j[7]||(j[7]=e=>U("delete")),onSave:X,onEdit:j[8]||(j[8]=e=>U("edit")),onAdd:te,onOnShowRichText:j[9]||(j[9]=e=>z.value=!0),onSetKey:ee,onSetAnswerSetting:le},null,8,["is-edit","is-set","isKey","showOtherOption","examAnswerRelationType","answerCheckType"])):l.createCommentVNode("v-if",!0)])),_:2},[i.isEdit?{name:"edit",fn:l.withCtx((()=>[l.createElementVNode("div",{class:l.normalizeClass(["flex",[{"margin-bottom":l.unref(z)}]])},[j[12]||(j[12]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"题目:")],-1)),l.createElementVNode("div",x,[l.createVNode(ne,{modelValue:l.unref(M),"onUpdate:modelValue":j[0]||(j[0]=e=>l.isRef(M)?M.value=e:null),type:"textarea",rows:2,placeholder:`【${l.unref(F)}】请输入问题`,disabled:i.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),l.createElementVNode("div",b,[j[13]||(j[13]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"设置:")],-1)),["multiple","sort"].includes(i.type)?(l.openBlock(),l.createBlock(re,{key:0,modelValue:l.unref(K),"onUpdate:modelValue":j[1]||(j[1]=e=>l.isRef(K)?K.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:i.isSave},{default:l.withCtx((()=>[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(J),(e=>(l.openBlock(),l.createBlock(ae,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):l.createCommentVNode("v-if",!0)]),l.createElementVNode("div",w,[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(I),((e,s)=>(l.openBlock(),l.createElementBlock("div",{key:s,class:"answer-item flex flex-items-center"},[l.createElementVNode("span",g,l.toDisplayString(String.fromCharCode(65+s))+".",1),l.createVNode(ne,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+s)}`,disabled:i.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(i.type)?(l.openBlock(),l.createBlock(A,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:l.normalizeClass([{"is-correct":e.isCorrect}]),disabled:i.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===T.type?(l&&I.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===T.type&&(e.isCorrect=l)}(e,l)},{default:l.withCtx((()=>[...j[14]||(j[14]=[l.createTextVNode(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):l.createCommentVNode("v-if",!0),l.createVNode(oe,{class:"icon"},{default:l.withCtx((()=>[l.createVNode(l.unref(t.CirclePlus),{class:l.normalizeClass([{disabled:i.isSave}]),onClick:P},null,8,["class"])])),_:1}),l.createVNode(oe,{class:"icon"},{default:l.withCtx((()=>[l.createVNode(l.unref(t.Remove),{class:l.normalizeClass([{disabled:l.unref(I).length<3||i.isSave}]),onClick:e=>function(e){I.value.length<3||T.isSave||I.value.splice(e,1)}(s)},null,8,["class","onClick"])])),_:2},1024),1===l.unref(O)&&"sort"!==i.type?(l.openBlock(),l.createBlock(ue,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return l=s,B.value=l,Q.value=I.value[l].resultItem||"",void(H.value=!0);var l}},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):l.createCommentVNode("v-if",!0),2===l.unref(O)&&"sort"!==i.type?(l.openBlock(),l.createBlock(ue,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||r.setGuid(),U("setRelation",T.customId,e)}(e)},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e.answerRelations?.length?`关联了${l.unref(ie)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):l.createCommentVNode("v-if",!0)])))),128))]),"sort"===i.type?(l.openBlock(),l.createElementBlock("div",h,[j[15]||(j[15]=l.createElementVNode("div",{class:"label flex flex-justify-end"},[l.createElementVNode("span",null,"排序答案:")],-1)),l.createElementVNode("div",k,[l.createVNode(re,{modelValue:l.unref(G),"onUpdate:modelValue":j[2]||(j[2]=e=>l.isRef(G)?G.value=e:null),multiple:"",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:l.withCtx((()=>[l.createCommentVNode(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(I),((e,t)=>(l.openBlock(),l.createBlock(ae,{key:t,label:e.title,value:String.fromCharCode(65+t)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):l.createCommentVNode("v-if",!0),i.showAnalysis?(l.openBlock(),l.createElementBlock("div",q,[j[16]||(j[16]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"解析:")],-1)),l.createElementVNode("div",C,[l.createVNode(ne,{modelValue:l.unref(E),"onUpdate:modelValue":j[3]||(j[3]=e=>l.isRef(E)?E.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):l.createCommentVNode("v-if",!0),l.unref(z)?(l.openBlock(),l.createElementBlock("div",V,[j[18]||(j[18]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"富文本:")],-1)),l.createElementVNode("div",S,[l.createVNode(a.default,l.mergeProps({"model-value":l.unref(D),"onUpdate:modelValue":j[4]||(j[4]=e=>l.isRef(D)?D.value=e:null)},l.unref(R),{style:{width:"100%"}}),null,16,["model-value"]),l.createElementVNode("div",_,[l.createVNode(ue,{type:"danger",onClick:W},{default:l.withCtx((()=>j[17]||(j[17]=[l.createTextVNode(" 删除富文本 ")]))),_:1})])])])):l.createCommentVNode("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),l.createVNode(ce,{modelValue:l.unref(H),"onUpdate:modelValue":j[11]||(j[11]=e=>l.isRef(H)?H.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:l.withCtx((()=>[l.createVNode(de,{class:"customize-button",type:"primary",plain:"",onClick:Z},{default:l.withCtx((()=>j[19]||(j[19]=[l.createTextVNode(" 取消 ")]))),_:1}),l.createVNode(de,{class:"customize-button",type:"primary",plain:"",onClick:Y},{default:l.withCtx((()=>j[20]||(j[20]=[l.createTextVNode(" 保存 ")]))),_:1})])),default:l.withCtx((()=>[(l.openBlock(),l.createBlock(a.default,l.mergeProps({key:l.unref(B),"model-value":l.unref(Q),"onUpdate:modelValue":j[10]||(j[10]=e=>l.isRef(Q)?Q.value=e:null)},l.unref(R),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});exports.default=j;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es"),l=require("vue"),t=require("@element-plus/icons-vue"),i=require("@qxs-bns/hooks"),s=require("../../../subject-action/src/subject-action.vue.cjs"),n=require("../../../subject-layout/src/subject-layout.vue.cjs"),a=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.cjs"),r=require("@qxs-bns/utils");const o={class:"preview"},u={class:"title"},d={key:0},c={key:1},p={key:0},m=["innerHTML"],y={class:"preview-answer"},f={class:"order"},v={class:"order"},x={style:{flex:"1"}},b={class:"margin-bottom flex flex-items-center"},w={class:"margin-bottom answer-list"},g={class:"order"},h={key:0,class:"margin-bottom flex flex-items-center"},k={style:{flex:"1"}},q={key:1,class:"flex"},C={style:{flex:"1"}},V={key:2,class:"margin-bottom flex"},S={style:{flex:"1"}},_={class:"flex flex-justify-end"};var j=l.defineComponent({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},customId:{type:Number,required:!1},examId:{type:Number,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(j,{emit:A}){const T=j,U=A,R=l.useAttrs(),B=l.ref(0),$=l.ref(T.isKey),N=l.ref(T.answerCheckType),O=l.ref(T.examAnswerRelationType),I=l.ref([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),K=l.ref(2),M=l.ref(""),E=l.ref(""),z=l.ref(!1),D=l.ref(""),L=l.ref(0),H=l.ref(!1),Q=l.ref(""),F=l.computed((()=>"single"===T.type?"单选题":"multiple"===T.type?"多选题":"排序题")),G=l.ref([]),J=l.computed((()=>{const e=[];for(let l=I.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function P(){T.isSave||I.value.push({title:"",isCorrect:!1,customAnswerId:r.setGuid()})}function W(){z.value=!1,D.value=""}function X(){if(!M.value)return void e.ElMessage.error("题目标题不能为空!");if(!N.value)return void e.ElMessage.error("请选择答题设置");let l="",t=!1,i=0;if("multiple"===T.type||"single"===T.type?I.value.forEach(((e,s)=>{e.title?.trim()||(l+=`选项${String.fromCharCode(65+s)}未填写。`),e.isCorrect&&(t=!0,i++),e.relationType=e.resultItem?1:e.answerRelations?.length?2:null})):"sort"===T.type&&G.value.length&&(t=!0),l)return void e.ElMessage.error(l);if(new Set(I.value.map((e=>e.title))).size===I.value.length){if("multiple"===T.type){if(1===i)return void e.ElMessage.error("请至少设置两个支持选项");if(t&&i<K.value)return void e.ElMessage.error("至少选几项与支持选项数不符")}2!==N.value&&3!==N.value||t?U("save",{title:M.value,answers:I.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:G.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:E.value,isSetCorrectAnswer:t,leastAnswerCount:K.value,examRichTextContent:z.value?D.value:"",examAnswerRelationType:O.value,isKey:$.value,answerCheckType:N.value}):e.ElMessage.error("请设置支持选项")}else e.ElMessage.error("选项不能重复")}function Y(){I.value[B.value].resultItem=Q.value||"",H.value=!1}function Z(){H.value=!1,Q.value=""}function ee(e){$.value=e}function le(e){N.value=e}function te(e,l){U("add",e,l?T.examAnswerRelationType:null)}l.watch((()=>T.isEdit),(()=>{T.isEdit&&(L.value=(new Date).getTime())}));const ie=l.computed((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),se=i.useNamespace("subject-single");return l.onMounted((function(){if(T.title&&(M.value=T.title),T.answerCheckType&&(N.value=T.answerCheckType),T.isKey&&($.value=T.isKey),T.examAnswerRelationType&&(O.value=T.examAnswerRelationType),T.answerList&&T.answerList.length&&(I.value=T.answerList),T.leastAnswerCount&&(K.value=T.leastAnswerCount),T.examExpand&&T.examExpand){const e=T.examExpand.split(",");G.value=e.map((e=>{const l=T.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}T.analysis&&(E.value=T.analysis),T.examRichTextContent&&(D.value=T.examRichTextContent,z.value=!0)})),(i,j)=>{const A=e.ElCheckbox,L=e.ElRadio,ne=e.ElInput,ae=e.ElOption,re=e.ElSelect,oe=e.ElIcon,ue=e.ElLink,de=e.ElButton,ce=e.ElDialog;return l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(l.unref(se).e("single-exam"))},[l.createVNode(n.default,{"show-edit":i.isEdit},l.createSlots({preview:l.withCtx((()=>[l.createElementVNode("div",o,[l.createElementVNode("div",null,[l.createElementVNode("span",u,[l.createTextVNode(l.toDisplayString(i.orderIndex+1)+"."+l.toDisplayString(l.unref(M))+" ",1),"single"===i.type?(l.openBlock(),l.createElementBlock("span",d,"(单选题)")):["multiple","sort"].includes(i.type)?(l.openBlock(),l.createElementBlock("span",c," ("+l.toDisplayString(l.unref(F))+l.toDisplayString(l.unref(K)?`至少选${l.unref(K)}项${"sort"===i.type?"并排序":""}`:"")+") ",1)):l.createCommentVNode("v-if",!0)])]),l.unref(z)?(l.openBlock(),l.createElementBlock("div",p,[l.createElementVNode("div",{innerHTML:l.unref(D)},null,8,m)])):l.createCommentVNode("v-if",!0),l.createElementVNode("div",y,["sort"===i.type?(l.openBlock(!0),l.createElementBlock(l.Fragment,{key:0},l.renderList(l.unref(I),((e,t)=>(l.openBlock(),l.createBlock(A,{key:t,class:"radio",disabled:!0},{default:l.withCtx((()=>[l.createElementVNode("span",f,l.toDisplayString(String.fromCharCode(65+t))+". ",1),l.createTextVNode(" "+l.toDisplayString(e.title),1)])),_:2},1024)))),128)):(l.openBlock(!0),l.createElementBlock(l.Fragment,{key:1},l.renderList(l.unref(I),((e,t)=>(l.openBlock(),l.createBlock(L,{key:t,class:"radio",value:"disabled",disabled:""},{default:l.withCtx((()=>[l.createElementVNode("span",v,l.toDisplayString(String.fromCharCode(65+t))+". ",1),l.createTextVNode(" "+l.toDisplayString(e.title)+" "+l.toDisplayString(e.isCorrect?"(支持选项)":"")+" "+l.toDisplayString(1===l.unref(O)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+l.toDisplayString(2===l.unref(O)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:l.withCtx((()=>[i.showAction?(l.openBlock(),l.createBlock(s.default,{key:0,"is-edit":i.isEdit,"is-set":i.isSet,isKey:l.unref($),showOtherOption:"multiple"===T.type||"single"===T.type,examAnswerRelationType:T.examAnswerRelationType,answerCheckType:l.unref(N),onMoveUp:j[5]||(j[5]=e=>U("move","up")),onMoveDown:j[6]||(j[6]=e=>U("move","down")),onDelete:j[7]||(j[7]=e=>U("delete")),onSave:X,onEdit:j[8]||(j[8]=e=>U("edit")),onAdd:te,onOnShowRichText:j[9]||(j[9]=e=>z.value=!0),onSetKey:ee,onSetAnswerSetting:le},null,8,["is-edit","is-set","isKey","showOtherOption","examAnswerRelationType","answerCheckType"])):l.createCommentVNode("v-if",!0)])),_:2},[i.isEdit?{name:"edit",fn:l.withCtx((()=>[l.createElementVNode("div",{class:l.normalizeClass(["flex",[{"margin-bottom":l.unref(z)}]])},[j[12]||(j[12]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"题目:")],-1)),l.createElementVNode("div",x,[l.createVNode(ne,{modelValue:l.unref(M),"onUpdate:modelValue":j[0]||(j[0]=e=>l.isRef(M)?M.value=e:null),type:"textarea",rows:2,placeholder:`【${l.unref(F)}】请输入问题`,disabled:i.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),l.createElementVNode("div",b,[j[13]||(j[13]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"设置:")],-1)),["multiple","sort"].includes(i.type)?(l.openBlock(),l.createBlock(re,{key:0,modelValue:l.unref(K),"onUpdate:modelValue":j[1]||(j[1]=e=>l.isRef(K)?K.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:i.isSave},{default:l.withCtx((()=>[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(J),(e=>(l.openBlock(),l.createBlock(ae,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):l.createCommentVNode("v-if",!0)]),l.createElementVNode("div",w,[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(I),((e,s)=>(l.openBlock(),l.createElementBlock("div",{key:s,class:"answer-item flex flex-items-center"},[l.createElementVNode("span",g,l.toDisplayString(String.fromCharCode(65+s))+".",1),l.createVNode(ne,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+s)}`,disabled:i.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(i.type)?(l.openBlock(),l.createBlock(A,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:l.normalizeClass([{"is-correct":e.isCorrect}]),disabled:i.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===T.type?(l&&I.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===T.type&&(e.isCorrect=l)}(e,l)},{default:l.withCtx((()=>[...j[14]||(j[14]=[l.createTextVNode(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):l.createCommentVNode("v-if",!0),l.createVNode(oe,{class:"icon"},{default:l.withCtx((()=>[l.createVNode(l.unref(t.CirclePlus),{class:l.normalizeClass([{disabled:i.isSave}]),onClick:P},null,8,["class"])])),_:1}),l.createVNode(oe,{class:"icon"},{default:l.withCtx((()=>[l.createVNode(l.unref(t.Remove),{class:l.normalizeClass([{disabled:l.unref(I).length<3||i.isSave}]),onClick:e=>function(e){I.value.length<3||T.isSave||I.value.splice(e,1)}(s)},null,8,["class","onClick"])])),_:2},1024),1===l.unref(O)&&"sort"!==i.type?(l.openBlock(),l.createBlock(ue,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return l=s,B.value=l,Q.value=I.value[l].resultItem||"",void(H.value=!0);var l}},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):l.createCommentVNode("v-if",!0),2===l.unref(O)&&"sort"!==i.type?(l.openBlock(),l.createBlock(ue,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||r.setGuid(),U("setRelation",T.customId,e)}(e)},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e.answerRelations?.length?`关联了${l.unref(ie)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):l.createCommentVNode("v-if",!0)])))),128))]),"sort"===i.type?(l.openBlock(),l.createElementBlock("div",h,[j[15]||(j[15]=l.createElementVNode("div",{class:"label flex flex-justify-end"},[l.createElementVNode("span",null,"排序答案:")],-1)),l.createElementVNode("div",k,[l.createVNode(re,{modelValue:l.unref(G),"onUpdate:modelValue":j[2]||(j[2]=e=>l.isRef(G)?G.value=e:null),multiple:"",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:l.withCtx((()=>[l.createCommentVNode(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(I),((e,t)=>(l.openBlock(),l.createBlock(ae,{key:t,label:e.title,value:String.fromCharCode(65+t)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):l.createCommentVNode("v-if",!0),i.showAnalysis?(l.openBlock(),l.createElementBlock("div",q,[j[16]||(j[16]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"解析:")],-1)),l.createElementVNode("div",C,[l.createVNode(ne,{modelValue:l.unref(E),"onUpdate:modelValue":j[3]||(j[3]=e=>l.isRef(E)?E.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):l.createCommentVNode("v-if",!0),l.unref(z)?(l.openBlock(),l.createElementBlock("div",V,[j[18]||(j[18]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"富文本:")],-1)),l.createElementVNode("div",S,[l.createVNode(a.default,l.mergeProps({"model-value":l.unref(D),"onUpdate:modelValue":j[4]||(j[4]=e=>l.isRef(D)?D.value=e:null)},l.unref(R),{style:{width:"100%"}}),null,16,["model-value"]),l.createElementVNode("div",_,[l.createVNode(ue,{type:"danger",onClick:W},{default:l.withCtx((()=>j[17]||(j[17]=[l.createTextVNode(" 删除富文本 ")]))),_:1})])])])):l.createCommentVNode("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),l.createVNode(ce,{modelValue:l.unref(H),"onUpdate:modelValue":j[11]||(j[11]=e=>l.isRef(H)?H.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:l.withCtx((()=>[l.createVNode(de,{class:"customize-button",type:"primary",plain:"",onClick:Z},{default:l.withCtx((()=>j[19]||(j[19]=[l.createTextVNode(" 取消 ")]))),_:1}),l.createVNode(de,{class:"customize-button",type:"primary",plain:"",onClick:Y},{default:l.withCtx((()=>j[20]||(j[20]=[l.createTextVNode(" 保存 ")]))),_:1})])),default:l.withCtx((()=>[(l.openBlock(),l.createBlock(a.default,l.mergeProps({key:l.unref(B),"model-value":l.unref(Q),"onUpdate:modelValue":j[10]||(j[10]=e=>l.isRef(Q)?Q.value=e:null)},l.unref(R),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});exports.default=j;
2
2
  //# sourceMappingURL=subject-single.vue.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"subject-single.vue.cjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-single.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport SubjectAction from '../../../subject-action/src/subject-action.vue'\nimport SubjectLayout from '../../../subject-layout/src/subject-layout.vue'\nimport TinyMceEditor from '../../../tiny-mce-editor/src/tiny-mce-editor.vue'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectSingle',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n type: 'single' | 'multiple' | 'sort'\n isEdit: boolean\n isSet: boolean\n answerList?: any\n leastAnswerCount?: number\n analysis?: string\n examExpand?: string\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n customId?: number\n examId?: number\n isKey: boolean\n answerCheckType: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add', 'setRelation'])\n\nconst attrs = useAttrs()\n\nconst answersIndex = ref(0)\nconst isKey = ref(props.isKey)\nconst answerCheckType = ref(1)\nconst examAnswerRelationType = ref(props.examAnswerRelationType)\nconst answers = ref<{\n title: string\n isCorrect: boolean\n orderIndex?: number\n resultItem?: string\n customAnswerId?: string\n answerRelations?: {\n relationExamId: number\n relationAnswers: {\n relationAnswerId: number\n relationAnswerIndex: number\n }[]\n }[]\n}[]>([{\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref(2)\nconst title = ref('')\nconst analysis = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst startTime = ref(0)\nconst showRichContent = ref(false)\nconst resultItem = ref<string>('')\nconst titlePlaceholder = computed(() => {\n if (props.type === 'single') {\n return '单选题'\n }\n else if (props.type === 'multiple') {\n return '多选题'\n }\n else {\n return '排序题'\n }\n})\n\nconst orderList = ref<string[]>([])\n\nconst leastAnswerOptions = computed(() => {\n const items = []\n const length = answers.value.length\n for (let count = length; count > 1; count--) {\n items.push({\n label: `至少选择${count}项`,\n value: count,\n })\n }\n return items.reverse()\n})\nfunction addAnswer() {\n if (props.isSave) {\n return\n }\n answers.value.push({\n title: '',\n isCorrect: false,\n customAnswerId: setGuid()\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3 || props.isSave) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction setCorrect(it: any, event: any) {\n if (props.type === 'single') {\n // 单选题:确保只有一个支持选项\n if (event) {\n answers.value.forEach((answer: any) => {\n if (answer !== it) {\n answer.isCorrect = false\n }\n })\n }\n it.isCorrect = event\n } else if (props.type === 'multiple') {\n // 多选题:可以有多个支持选项\n it.isCorrect = event\n }\n}\nfunction setRelation(item: any) {\n item.customAnswerId = item.examAnswerId || setGuid()\n emits('setRelation', props.customId, item)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n // 答题设置必选\n if(!answerCheckType.value) {\n ElMessage.error('请选择答题设置')\n return\n }\n let msg = ''\n let isSetCorrectAnswer = false\n let correctAnswerCount = 0\n if (props.type === 'multiple' || props.type === 'single') {\n answers.value.forEach((v: any, i: number) => {\n if (!v.title?.trim()) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n v.relationType = v.resultItem ? 1 : (v.answerRelations?.length ? 2 : null)\n })\n }\n else if (props.type === 'sort') {\n // 如果设置了支持选项\n if (orderList.value.length) {\n isSetCorrectAnswer = true\n }\n }\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n const uniqueAnswer = new Set(answers.value.map((item: any) => item.title))\n\n if (uniqueAnswer.size !== answers.value.length) {\n ElMessage.error('选项不能重复')\n return\n }\n\n if (props.type === 'multiple') {\n if (correctAnswerCount === 1) {\n ElMessage.error('请至少设置两个支持选项')\n return\n }\n\n if (isSetCorrectAnswer && correctAnswerCount < leastAnswerCount.value) {\n ElMessage.error('至少选几项与支持选项数不符')\n return\n }\n } \n\n if(answerCheckType.value === 2 || answerCheckType.value === 3) {\n // 必须有设置支持选项\n if (!isSetCorrectAnswer) {\n ElMessage.error('请设置支持选项')\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.map((item: any, index: number) => {\n return { ...item, orderIndex: index + 1 }\n }),\n examExpand: orderList.value.map((i: string) => i.charCodeAt(0) - 65 + 1).join(','),\n analysis: analysis.value,\n isSetCorrectAnswer,\n leastAnswerCount: leastAnswerCount.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n examAnswerRelationType: examAnswerRelationType.value,\n isKey: isKey.value,\n answerCheckType: answerCheckType.value\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\n }\n\n if (props.isKey) {\n isKey.value = props.isKey\n }\n\n if (props.examAnswerRelationType) {\n examAnswerRelationType.value = props.examAnswerRelationType\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.leastAnswerCount) {\n leastAnswerCount.value = props.leastAnswerCount\n }\n\n if (props.examExpand) {\n // 设置支持选项 props.examExpand里是答案id\n if (props.examExpand) {\n const correctAnswerIdList = props.examExpand.split(',')\n\n // 遍历 correctAnswerIdList,直接在 props.answerList 中查找对应的 orderIndex 并转换成字母\n orderList.value = correctAnswerIdList.map((id: string) => {\n const answer = props.answerList.find((item: any) => item.answerId?.toString() === id)\n return answer ? String.fromCharCode(65 + answer.orderIndex - 1) : id\n }).filter(Boolean) // 过滤掉任何可能的空字符串\n }\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n resultItem.value = answers.value[i].resultItem || ''\n showRichContent.value = true\n}\n\nfunction onSaveResult() {\n answers.value[answersIndex.value].resultItem = resultItem.value || ''\n showRichContent.value = false\n}\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\nfunction setKey(key: boolean) {\n isKey.value = key\n}\nfunction setAnswerSetting(type: number) {\n answerCheckType.value = type\n}\n\nfunction add(type: string, canSet: boolean) {\n emits('add', type, canSet? props.examAnswerRelationType: null)\n}\n// 监听isEdit\nwatch(() => props.isEdit, () => {\n if (props.isEdit) {\n startTime.value = new Date().getTime()\n }\n})\n\nconst relationLength = computed(() => {\n return (v: any) => {\n let count = 0\n v.forEach((item: any) => {\n if (item.relationAnswers) {\n count += item.relationAnswers.length\n }\n })\n return count\n }\n})\n\nconst ns = useNamespace('subject-single')\n\nonMounted(init)\n</script>\n\n<template>\n <div :class=\"ns.e('single-exam')\">\n <SubjectLayout\n :show-edit=\"isEdit\"\n >\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">\n {{ orderIndex + 1 }}.{{ title }}\n <span v-if=\"type === 'single'\">(单选题)</span>\n <span v-else-if=\"['multiple', 'sort'].includes(type)\">\n ({{ titlePlaceholder }}{{ leastAnswerCount ? `至少选${leastAnswerCount}项${type === 'sort' ? '并排序' : ''}` : '' }})\n </span>\n </span>\n </div>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" />\n </div>\n <div class=\"preview-answer\">\n <template v-if=\"type === 'sort'\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }}\n </el-checkbox>\n </template>\n <template v-else>\n <el-radio\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n value=\"disabled\"\n disabled\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }} \n {{ item.isCorrect ? '(支持选项)' : '' }} \n {{ examAnswerRelationType === 1 ? (item.resultItem? '(已设置结果项)' : '(未设置结果项)' ) : ''}} \n {{ examAnswerRelationType === 2 ? (item.answerRelations?.length? '(已设置关联)' : '(未设置关联)') : '' }}\n </el-radio>\n </template>\n </div>\n </div>\n </template>\n <template v-if=\"isEdit\" #edit>\n <div class=\"flex\" :class=\"[{ 'margin-bottom': showRichText }]\">\n <div class=\"label flex flex-justify-center\">\n <span>题目:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n :placeholder=\"`【${titlePlaceholder}】请输入问题`\"\n :disabled=\"isSave\"\n show-word-limit\n maxlength=\"200\"\n class=\"margin-bottom\"\n />\n </div>\n </div>\n <div class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-center\">\n <span>设置:</span>\n </div>\n <el-select\n v-if=\"['multiple', 'sort'].includes(type)\"\n v-model=\"leastAnswerCount\"\n style=\"width: 150px;\"\n placeholder=\"至少选择几项\"\n :disabled=\"isSave\"\n >\n <el-option\n v-for=\"item in leastAnswerOptions\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n >\n </el-option>\n </el-select>\n </div>\n <div class=\"margin-bottom answer-list\">\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <span class=\"order\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n maxlength=\"100\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <el-checkbox\n v-if=\"['single', 'multiple'].includes(type)\"\n v-model=\"item.isCorrect\"\n :class=\"[{ 'is-correct': item.isCorrect }]\"\n :disabled=\"isSave\"\n style=\"margin-left: 10px;\"\n @change=\"(event: any) => setCorrect(item, event)\"\n >\n 支持选项 \n </el-checkbox>\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: isSave }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n <el-link\n v-if=\"examAnswerRelationType === 1 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"onOpenResult(index)\"\n >\n <span>{{ item.resultItem ? '编辑结果' : '添加结果' }}</span>\n </el-link>\n <el-link\n v-if=\"examAnswerRelationType === 2 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"setRelation(item)\"\n >\n <span>{{ item.answerRelations?.length ? `关联了${relationLength(item.answerRelations)}项` : '关联检查' }}</span>\n </el-link>\n </div>\n </div>\n <div v-if=\"type === 'sort'\" class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-end\">\n <span>排序答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-select\n v-model=\"orderList\"\n multiple\n style=\"width: 360px;\"\n placeholder=\"请按顺序选择排序答案\"\n :show-arrow=\"true\"\n >\n <!-- :options=\"[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))\" -->\n <el-option\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n :label=\"item.title\"\n :value=\"String.fromCharCode(65 + index)\"\n />\n </el-select>\n </div>\n </div>\n <div\n v-if=\"showAnalysis\"\n class=\"flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>解析:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"analysis\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入题目解析\"\n />\n </div>\n </div>\n <div v-if=\"showRichText\" class=\"margin-bottom flex\">\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor v-model:model-value=\"richText\" v-bind=\"attrs\" style=\"width: 100%;\" />\n <div class=\"flex flex-justify-end\">\n <el-link\n type=\"danger\"\n @click=\"deleteRichText\"\n >\n 删除富文本\n </el-link>\n </div>\n </div>\n </div>\n </template>\n <SubjectAction\n v-if=\"showAction\"\n :is-edit=\"isEdit\"\n :is-set=\"isSet\"\n :isKey=\"isKey\"\n :showOtherOption=\"props.type === 'multiple' || props.type === 'single'\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\n :answerCheckType=\"answerCheckType\"\n @move-up=\"emits('move', 'up')\"\n @move-down=\"emits('move', 'down')\"\n @delete=\"emits('delete')\"\n @save=\"save\"\n @edit=\"emits('edit')\"\n @add=\"add\"\n @onShowRichText=\"showRichText = true\"\n @setKey=\"setKey\"\n @setAnswerSetting=\"setAnswerSetting\"\n />\n </SubjectLayout>\n <el-dialog\n v-model=\"showRichContent\"\n title=\"添加结果\"\n class=\"customize-dialog\"\n >\n <TinyMceEditor\n :key=\"answersIndex\"\n v-model:model-value=\"resultItem\" \n v-bind=\"attrs\"\n style=\"width: 100%;\" />\n <template #footer>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onCloseResult\"\n >\n 取消\n </el-button>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onSaveResult\"\n >\n 保存\n </el-button>\n </template>\n </el-dialog>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answersIndex","ref","isKey","answerCheckType","examAnswerRelationType","answers","title","isCorrect","leastAnswerCount","analysis","showRichText","richText","startTime","showRichContent","resultItem","titlePlaceholder","computed","type","orderList","leastAnswerOptions","items","count","value","length","push","label","reverse","addAnswer","isSave","customAnswerId","setGuid","deleteRichText","save","ElMessage","error","msg","isSetCorrectAnswer","correctAnswerCount","forEach","v","i","trim","String","fromCharCode","relationType","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onSaveResult","onCloseResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","relationLength","relationAnswers","ns","useNamespace","onMounted","answerList","correctAnswerIdList","split","id","answer","find","answerId","toString","filter","Boolean","it","event","splice","examAnswerId","customId"],"mappings":"wrDAWA,MAAMA,EAAQC,EAoBRC,EAAQC,EAERC,EAAQC,EAAAA,WAERC,EAAeC,MAAI,GACnBC,EAAQD,EAAAA,IAAIP,EAAMQ,OAClBC,EAAkBF,MAAI,GACtBG,EAAyBH,EAAAA,IAAIP,EAAMU,wBACnCC,EAAUJ,EAAAA,IAaX,CAAC,CACJK,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,KAGPC,EAAmBP,MAAI,GACvBK,EAA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EAAAiB,MAAM8D,OAAOlC,EAAO,EAAC,gLA2JTV,IACpBxC,EAAasB,MAAQkB,EACrB1B,EAAWQ,MAAQjB,EAAQiB,MAAMkB,GAAG1B,YAAc,QAClDD,EAAgBS,OAAQ,GAH1B,IAAsBkB,kSAxItB,SAAqBQ,GACdA,EAAAnB,eAAiBmB,EAAKqC,cAAgBvD,EAAAA,UACrClC,EAAA,cAAeF,EAAM4F,SAAUtC,EAAI"}
1
+ {"version":3,"file":"subject-single.vue.cjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-single.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport SubjectAction from '../../../subject-action/src/subject-action.vue'\nimport SubjectLayout from '../../../subject-layout/src/subject-layout.vue'\nimport TinyMceEditor from '../../../tiny-mce-editor/src/tiny-mce-editor.vue'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectSingle',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n type: 'single' | 'multiple' | 'sort'\n isEdit: boolean\n isSet: boolean\n answerList?: any\n leastAnswerCount?: number\n analysis?: string\n examExpand?: string\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n customId?: number\n examId?: number\n isKey: boolean\n answerCheckType: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add', 'setRelation'])\n\nconst attrs = useAttrs()\n\nconst answersIndex = ref(0)\nconst isKey = ref(props.isKey)\nconst answerCheckType = ref(props.answerCheckType)\nconst examAnswerRelationType = ref(props.examAnswerRelationType)\nconst answers = ref<{\n title: string\n isCorrect: boolean\n orderIndex?: number\n resultItem?: string\n customAnswerId?: string\n answerRelations?: {\n relationExamId: number\n relationAnswers: {\n relationAnswerId: number\n relationAnswerIndex: number\n }[]\n }[]\n}[]>([{\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref(2)\nconst title = ref('')\nconst analysis = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst startTime = ref(0)\nconst showRichContent = ref(false)\nconst resultItem = ref<string>('')\nconst titlePlaceholder = computed(() => {\n if (props.type === 'single') {\n return '单选题'\n }\n else if (props.type === 'multiple') {\n return '多选题'\n }\n else {\n return '排序题'\n }\n})\n\nconst orderList = ref<string[]>([])\n\nconst leastAnswerOptions = computed(() => {\n const items = []\n const length = answers.value.length\n for (let count = length; count > 1; count--) {\n items.push({\n label: `至少选择${count}项`,\n value: count,\n })\n }\n return items.reverse()\n})\nfunction addAnswer() {\n if (props.isSave) {\n return\n }\n answers.value.push({\n title: '',\n isCorrect: false,\n customAnswerId: setGuid()\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3 || props.isSave) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction setCorrect(it: any, event: any) {\n if (props.type === 'single') {\n // 单选题:确保只有一个支持选项\n if (event) {\n answers.value.forEach((answer: any) => {\n if (answer !== it) {\n answer.isCorrect = false\n }\n })\n }\n it.isCorrect = event\n } else if (props.type === 'multiple') {\n // 多选题:可以有多个支持选项\n it.isCorrect = event\n }\n}\nfunction setRelation(item: any) {\n item.customAnswerId = item.examAnswerId || setGuid()\n emits('setRelation', props.customId, item)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n // 答题设置必选\n if(!answerCheckType.value) {\n ElMessage.error('请选择答题设置')\n return\n }\n let msg = ''\n let isSetCorrectAnswer = false\n let correctAnswerCount = 0\n if (props.type === 'multiple' || props.type === 'single') {\n answers.value.forEach((v: any, i: number) => {\n if (!v.title?.trim()) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n v.relationType = v.resultItem ? 1 : (v.answerRelations?.length ? 2 : null)\n })\n }\n else if (props.type === 'sort') {\n // 如果设置了支持选项\n if (orderList.value.length) {\n isSetCorrectAnswer = true\n }\n }\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n const uniqueAnswer = new Set(answers.value.map((item: any) => item.title))\n\n if (uniqueAnswer.size !== answers.value.length) {\n ElMessage.error('选项不能重复')\n return\n }\n\n if (props.type === 'multiple') {\n if (correctAnswerCount === 1) {\n ElMessage.error('请至少设置两个支持选项')\n return\n }\n\n if (isSetCorrectAnswer && correctAnswerCount < leastAnswerCount.value) {\n ElMessage.error('至少选几项与支持选项数不符')\n return\n }\n } \n\n if(answerCheckType.value === 2 || answerCheckType.value === 3) {\n // 必须有设置支持选项\n if (!isSetCorrectAnswer) {\n ElMessage.error('请设置支持选项')\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.map((item: any, index: number) => {\n return { ...item, orderIndex: index + 1 }\n }),\n examExpand: orderList.value.map((i: string) => i.charCodeAt(0) - 65 + 1).join(','),\n analysis: analysis.value,\n isSetCorrectAnswer,\n leastAnswerCount: leastAnswerCount.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n examAnswerRelationType: examAnswerRelationType.value,\n isKey: isKey.value,\n answerCheckType: answerCheckType.value\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\n }\n\n if (props.isKey) {\n isKey.value = props.isKey\n }\n\n if (props.examAnswerRelationType) {\n examAnswerRelationType.value = props.examAnswerRelationType\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.leastAnswerCount) {\n leastAnswerCount.value = props.leastAnswerCount\n }\n\n if (props.examExpand) {\n // 设置支持选项 props.examExpand里是答案id\n if (props.examExpand) {\n const correctAnswerIdList = props.examExpand.split(',')\n\n // 遍历 correctAnswerIdList,直接在 props.answerList 中查找对应的 orderIndex 并转换成字母\n orderList.value = correctAnswerIdList.map((id: string) => {\n const answer = props.answerList.find((item: any) => item.answerId?.toString() === id)\n return answer ? String.fromCharCode(65 + answer.orderIndex - 1) : id\n }).filter(Boolean) // 过滤掉任何可能的空字符串\n }\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n resultItem.value = answers.value[i].resultItem || ''\n showRichContent.value = true\n}\n\nfunction onSaveResult() {\n answers.value[answersIndex.value].resultItem = resultItem.value || ''\n showRichContent.value = false\n}\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\nfunction setKey(key: boolean) {\n isKey.value = key\n}\nfunction setAnswerSetting(type: number) {\n answerCheckType.value = type\n}\n\nfunction add(type: string, canSet: boolean) {\n emits('add', type, canSet? props.examAnswerRelationType: null)\n}\n// 监听isEdit\nwatch(() => props.isEdit, () => {\n if (props.isEdit) {\n startTime.value = new Date().getTime()\n }\n})\n\nconst relationLength = computed(() => {\n return (v: any) => {\n let count = 0\n v.forEach((item: any) => {\n if (item.relationAnswers) {\n count += item.relationAnswers.length\n }\n })\n return count\n }\n})\n\nconst ns = useNamespace('subject-single')\n\nonMounted(init)\n</script>\n\n<template>\n <div :class=\"ns.e('single-exam')\">\n <SubjectLayout\n :show-edit=\"isEdit\"\n >\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">\n {{ orderIndex + 1 }}.{{ title }}\n <span v-if=\"type === 'single'\">(单选题)</span>\n <span v-else-if=\"['multiple', 'sort'].includes(type)\">\n ({{ titlePlaceholder }}{{ leastAnswerCount ? `至少选${leastAnswerCount}项${type === 'sort' ? '并排序' : ''}` : '' }})\n </span>\n </span>\n </div>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" />\n </div>\n <div class=\"preview-answer\">\n <template v-if=\"type === 'sort'\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }}\n </el-checkbox>\n </template>\n <template v-else>\n <el-radio\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n value=\"disabled\"\n disabled\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }} \n {{ item.isCorrect ? '(支持选项)' : '' }} \n {{ examAnswerRelationType === 1 ? (item.resultItem? '(已设置结果项)' : '(未设置结果项)' ) : ''}} \n {{ examAnswerRelationType === 2 ? (item.answerRelations?.length? '(已设置关联)' : '(未设置关联)') : '' }}\n </el-radio>\n </template>\n </div>\n </div>\n </template>\n <template v-if=\"isEdit\" #edit>\n <div class=\"flex\" :class=\"[{ 'margin-bottom': showRichText }]\">\n <div class=\"label flex flex-justify-center\">\n <span>题目:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n :placeholder=\"`【${titlePlaceholder}】请输入问题`\"\n :disabled=\"isSave\"\n show-word-limit\n maxlength=\"200\"\n class=\"margin-bottom\"\n />\n </div>\n </div>\n <div class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-center\">\n <span>设置:</span>\n </div>\n <el-select\n v-if=\"['multiple', 'sort'].includes(type)\"\n v-model=\"leastAnswerCount\"\n style=\"width: 150px;\"\n placeholder=\"至少选择几项\"\n :disabled=\"isSave\"\n >\n <el-option\n v-for=\"item in leastAnswerOptions\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n >\n </el-option>\n </el-select>\n </div>\n <div class=\"margin-bottom answer-list\">\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <span class=\"order\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n maxlength=\"100\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <el-checkbox\n v-if=\"['single', 'multiple'].includes(type)\"\n v-model=\"item.isCorrect\"\n :class=\"[{ 'is-correct': item.isCorrect }]\"\n :disabled=\"isSave\"\n style=\"margin-left: 10px;\"\n @change=\"(event: any) => setCorrect(item, event)\"\n >\n 支持选项 \n </el-checkbox>\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: isSave }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n <el-link\n v-if=\"examAnswerRelationType === 1 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"onOpenResult(index)\"\n >\n <span>{{ item.resultItem ? '编辑结果' : '添加结果' }}</span>\n </el-link>\n <el-link\n v-if=\"examAnswerRelationType === 2 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"setRelation(item)\"\n >\n <span>{{ item.answerRelations?.length ? `关联了${relationLength(item.answerRelations)}项` : '关联检查' }}</span>\n </el-link>\n </div>\n </div>\n <div v-if=\"type === 'sort'\" class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-end\">\n <span>排序答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-select\n v-model=\"orderList\"\n multiple\n style=\"width: 360px;\"\n placeholder=\"请按顺序选择排序答案\"\n :show-arrow=\"true\"\n >\n <!-- :options=\"[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))\" -->\n <el-option\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n :label=\"item.title\"\n :value=\"String.fromCharCode(65 + index)\"\n />\n </el-select>\n </div>\n </div>\n <div\n v-if=\"showAnalysis\"\n class=\"flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>解析:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"analysis\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入题目解析\"\n />\n </div>\n </div>\n <div v-if=\"showRichText\" class=\"margin-bottom flex\">\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor v-model:model-value=\"richText\" v-bind=\"attrs\" style=\"width: 100%;\" />\n <div class=\"flex flex-justify-end\">\n <el-link\n type=\"danger\"\n @click=\"deleteRichText\"\n >\n 删除富文本\n </el-link>\n </div>\n </div>\n </div>\n </template>\n <SubjectAction\n v-if=\"showAction\"\n :is-edit=\"isEdit\"\n :is-set=\"isSet\"\n :isKey=\"isKey\"\n :showOtherOption=\"props.type === 'multiple' || props.type === 'single'\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\n :answerCheckType=\"answerCheckType\"\n @move-up=\"emits('move', 'up')\"\n @move-down=\"emits('move', 'down')\"\n @delete=\"emits('delete')\"\n @save=\"save\"\n @edit=\"emits('edit')\"\n @add=\"add\"\n @onShowRichText=\"showRichText = true\"\n @setKey=\"setKey\"\n @setAnswerSetting=\"setAnswerSetting\"\n />\n </SubjectLayout>\n <el-dialog\n v-model=\"showRichContent\"\n title=\"添加结果\"\n class=\"customize-dialog\"\n >\n <TinyMceEditor\n :key=\"answersIndex\"\n v-model:model-value=\"resultItem\" \n v-bind=\"attrs\"\n style=\"width: 100%;\" />\n <template #footer>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onCloseResult\"\n >\n 取消\n </el-button>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onSaveResult\"\n >\n 保存\n </el-button>\n </template>\n </el-dialog>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answersIndex","ref","isKey","answerCheckType","examAnswerRelationType","answers","title","isCorrect","leastAnswerCount","analysis","showRichText","richText","startTime","showRichContent","resultItem","titlePlaceholder","computed","type","orderList","leastAnswerOptions","items","count","value","length","push","label","reverse","addAnswer","isSave","customAnswerId","setGuid","deleteRichText","save","ElMessage","error","msg","isSetCorrectAnswer","correctAnswerCount","forEach","v","i","trim","String","fromCharCode","relationType","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onSaveResult","onCloseResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","relationLength","relationAnswers","ns","useNamespace","onMounted","answerList","correctAnswerIdList","split","id","answer","find","answerId","toString","filter","Boolean","it","event","splice","examAnswerId","customId"],"mappings":"wrDAWA,MAAMA,EAAQC,EAoBRC,EAAQC,EAERC,EAAQC,EAAAA,WAERC,EAAeC,MAAI,GACnBC,EAAQD,EAAAA,IAAIP,EAAMQ,OAClBC,EAAkBF,EAAAA,IAAIP,EAAMS,iBAC5BC,EAAyBH,EAAAA,IAAIP,EAAMU,wBACnCC,EAAUJ,EAAAA,IAaX,CAAC,CACJK,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,KAGPC,EAAmBP,MAAI,GACvBK,EAAQL,MAAI,IACZQ,EAAWR,MAAI,IACfS,EAAeT,OAAI,GACnBU,EAAWV,MAAI,IACfW,EAAYX,MAAI,GAChBY,EAAkBZ,OAAI,GACtBa,EAAab,MAAY,IACzBc,EAAmBC,EAAAA,UAAS,IACb,WAAftB,EAAMuB,KACD,MAEe,aAAfvB,EAAMuB,KACN,MAGA,QAILC,EAAYjB,EAAcA,IAAA,IAE1BkB,EAAqBH,EAAAA,UAAS,KAClC,MAAMI,EAAQ,GAEd,IAAA,IAASC,EADMhB,EAAQiB,MAAMC,OACJF,EAAQ,EAAGA,IAClCD,EAAMI,KAAK,CACTC,MAAO,OAAOJ,KACdC,MAAOD,IAGX,OAAOD,EAAMM,SAAQ,IAEvB,SAASC,IACHjC,EAAMkC,QA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8E,YAGpB9E,EAAMc,mBACRA,EAAiBc,MAAQ5B,EAAMc,kBAG7Bd,EAAM0D,YAEJ1D,EAAM0D,WAAY,CACpB,MAAMqB,EAAsB/E,EAAM0D,WAAWsB,MAAM,KAGnDxD,EAAUI,MAAQmD,EAAoB1B,KAAK4B,IACnC,MAAAC,EAASlF,EAAM8E,WAAWK,MAAM7B,GAAcA,EAAK8B,UAAUC,aAAeJ,IAClF,OAAOC,EAASlC,OAAOC,aAAa,GAAKiC,EAAOzB,WAAa,GAAKwB,CAAA,IACjEK,OAAOC,QAAO,CAIjBvF,EAAMe,WACRA,EAASa,MAAQ5B,EAAMe,UAGrBf,EAAM6D,sBACR5C,EAASW,MAAQ5B,EAAM6D,oBACvB7C,EAAaY,OAAQ,EACvB,2iJAtJO,SAAW4D,EAASC,GACR,WAAfzF,EAAMuB,MAEJkE,GACM9E,EAAAiB,MAAMgB,SAASsC,IACjBA,IAAWM,IACbN,EAAOrE,WAAY,EAAA,IAIzB2E,EAAG3E,UAAY4E,GACS,aAAfzF,EAAMuB,OAEfiE,EAAG3E,UAAY4E,EACjB,6hBArBF,SAAsBjC,GAChB7C,EAAQiB,MAAMC,OAAS,GAAK7B,EAAMkC,QAG9BvB,EAAAiB,MAAM8D,OAAOlC,EAAO,EAAC,gLA2JTV,IACpBxC,EAAasB,MAAQkB,EACrB1B,EAAWQ,MAAQjB,EAAQiB,MAAMkB,GAAG1B,YAAc,QAClDD,EAAgBS,OAAQ,GAH1B,IAAsBkB,kSAxItB,SAAqBQ,GACdA,EAAAnB,eAAiBmB,EAAKqC,cAAgBvD,EAAAA,UACrClC,EAAA,cAAeF,EAAM4F,SAAUtC,EAAI"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qxs-bns/components",
3
3
  "type": "module",
4
- "version": "0.0.43",
4
+ "version": "0.0.44",
5
5
  "description": "Vue 3 Component Library",
6
6
  "license": "MIT",
7
7
  "homepage": "https://trry-hub.github.io/qxs-bns/",