@qxs-bns/components 0.0.36 → 0.0.38
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.
- package/es/package.json.mjs +1 -1
- package/es/src/subject-list/src/components/subject-scale.vue.mjs +1 -1
- package/es/src/subject-list/src/components/subject-scale.vue.mjs.map +1 -1
- package/es/src/subject-list/src/components/subject-single.vue.mjs +1 -1
- package/es/src/subject-list/src/components/subject-single.vue.mjs.map +1 -1
- package/es/src/subject-list/src/subject-list.vue.mjs +1 -1
- package/es/src/subject-list/src/subject-list.vue.mjs.map +1 -1
- package/es/src/tiny-mce-editor/src/tiny-mce-editor.vue.mjs +1 -1
- package/es/src/tiny-mce-editor/src/tiny-mce-editor.vue.mjs.map +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/src/subject-list/src/components/subject-scale.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/subject-scale.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/components/subject-single.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/subject-single.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/subject-list.vue.cjs +1 -1
- package/lib/src/subject-list/src/subject-list.vue.cjs.map +1 -1
- package/lib/src/tiny-mce-editor/src/tiny-mce-editor.vue.cjs +1 -1
- package/lib/src/tiny-mce-editor/src/tiny-mce-editor.vue.cjs.map +1 -1
- package/package.json +1 -1
- package/types/src/data-chart/src/components/card.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/radar.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/scatter-simple.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/scatter.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/table.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/data-chart.vue.d.ts.map +1 -1
- package/types/src/file-upload/src/file-upload.vue.d.ts.map +1 -1
- package/types/src/image-upload/src/image-upload.vue.d.ts.map +1 -1
- package/types/src/photo-crop-tool/src/photo-crop-tool.vue.d.ts.map +1 -1
- package/types/src/subject-layout/src/subject-layout.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/subject-scale.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/subject-single.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/subject-list.vue.d.ts.map +1 -1
- package/types/src/tiny-mce-editor/index.d.ts.map +1 -1
- package/types/src/tiny-mce-editor/src/tiny-mce-editor.vue.d.ts.map +1 -1
- package/types/tsconfig.tsbuildinfo +1 -0
package/es/package.json.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var r="0.0.
|
1
|
+
var r="0.0.38";export{r as version};
|
2
2
|
//# sourceMappingURL=package.json.mjs.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{ElInput as e,ElIcon as l,ElLink as t,ElRow as a,ElCol as s,ElRadio as n}from"element-plus/es";import{defineComponent as i,useAttrs as o,ref as u,computed as r,onMounted as d,createElementBlock as c,openBlock as p,normalizeClass as v,unref as m,createVNode as f,withCtx as x,createBlock as y,createCommentVNode as h,createElementVNode as w,isRef as b,Fragment as g,renderList as j,toDisplayString as C,mergeProps as S,createTextVNode as k}from"vue";import{CirclePlus as V,Remove as q}from"@element-plus/icons-vue";import{useNamespace as T}from"@qxs-bns/hooks";import{ElMessage as _}from"element-plus";import L from"../../../subject-action/src/subject-action.vue.mjs";import A from"../../../subject-layout/src/subject-layout.vue.mjs";import R from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";const
|
1
|
+
import{ElInput as e,ElIcon as l,ElLink as t,ElRow as a,ElCol as s,ElRadio as n}from"element-plus/es";import{defineComponent as i,useAttrs as o,ref as u,computed as r,onMounted as d,createElementBlock as c,openBlock as p,normalizeClass as v,unref as m,createVNode as f,withCtx as x,createBlock as y,createCommentVNode as h,createElementVNode as w,isRef as b,Fragment as g,renderList as j,toDisplayString as C,mergeProps as S,createTextVNode as k}from"vue";import{CirclePlus as V,Remove as q}from"@element-plus/icons-vue";import{useNamespace as T}from"@qxs-bns/hooks";import{ElMessage as _}from"element-plus";import L from"../../../subject-action/src/subject-action.vue.mjs";import A from"../../../subject-layout/src/subject-layout.vue.mjs";import R from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";const U={class:"preview"},M={class:"title"},E={key:0},O=["innerHTML"],Q={class:"answer-radio flex flex-col"},B={style:{flex:"1"}},D={class:"answer flex"},H={class:"flex"},I={class:"answer-list flex-col"},N={class:"order"},$={class:"flex",style:{"margin-bottom":"20px"}},P={style:{flex:"1"}},z={key:0,class:"margin-bottom flex"},F={style:{flex:"1"}},G={class:"flex flex-justify-end"};var J=i({name:"QxsSubjectScale",__name:"subject-scale",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},answerList:{type:null,required:!1},analysis:{type:String,required:!1},rowTitle:{type:String,required:!1},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},scaleQuestionList:{type:null,required:!1},examRichTextContent:{type:String,required:!1},examAnswerRelationType:{type:Number,required:!1}},emits:["move","save","delete","edit","add"],setup(i,{emit:J}){const K=i,W=J,X=o(),Y=u([{title:""},{title:""},{title:""},{title:""},{title:""}]),Z=u(""),ee=u(""),le=u(""),te=u(!1),ae=u(""),se=u([]),ne=r((()=>Math.ceil(24/(Y.value.length+1))));function ie(){5!==Y.value.length&&Y.value.push({title:""})}function oe(){te.value=!1,ae.value=""}function ue(){if(!Z.value)return void _.error("题目标题不能为空!");let e="";Y.value.forEach(((l,t)=>{l.title||(e+=`选项${String.fromCharCode(65+t)}未填写。`)})),e?_.error(e):le.value?(se.value=le.value.split("\n").filter((e=>e)),W("save",{title:Z.value,answers:Y.value,analysis:ee.value,scaleQuestionList:se.value,examRichTextContent:te.value?ae.value:""})):_.error("行标题不能为空!")}d((function(){K.title&&(Z.value=K.title),K.answerList&&K.answerList.length&&(Y.value=K.answerList),K.analysis&&(ee.value=K.analysis),K.scaleQuestionList&&(se.value=K.scaleQuestionList,le.value=se.value.join("\n")),K.examRichTextContent&&(ae.value=K.examRichTextContent,te.value=!0)}));const re=T("subject-scale");return(i,o)=>{const u=s,r=a,d=n,T=e,_=l,J=t;return p(),c("div",{class:v(m(re).e("scale-exam"))},[f(A,{"show-edit":i.isEdit},{preview:x((()=>[w("div",U,[w("div",null,[w("span",M,C(i.orderIndex+1)+"."+C(m(Z))+"(量表题)",1),m(te)?(p(),c("div",E,[w("div",{innerHTML:m(ae)},null,8,O)])):h("v-if",!0)]),w("div",Q,[f(r,{style:{padding:"10px 0"}},{default:x((()=>[f(u,{span:m(ne)},null,8,["span"]),(p(!0),c(g,null,j(m(Y),(e=>(p(),y(u,{key:e.title,class:"flex flex-center",span:m(ne)},{default:x((()=>[w("span",null,C(e.title),1)])),_:2},1032,["span"])))),128))])),_:1}),(p(!0),c(g,null,j(m(se),(e=>(p(),y(r,{key:e,style:{padding:"10px 0"}},{default:x((()=>[f(u,{span:m(ne),class:"flex flex-center"},{default:x((()=>[w("span",null,C(e),1)])),_:2},1032,["span"]),(p(!0),c(g,null,j(m(Y).length,(e=>(p(),y(u,{key:e,class:"radio-item flex flex-center",span:m(ne)},{default:x((()=>[f(d,{disabled:!0})])),_:2},1032,["span"])))),128))])),_:2},1024)))),128))])])])),edit:x((()=>[w("div",{class:v(["flex",[{"margin-bottom":m(te)}]])},[o[10]||(o[10]=w("div",{class:"label flex flex-justify-center"},[w("span",null,"题目:")],-1)),w("div",B,[f(T,{modelValue:m(Z),"onUpdate:modelValue":o[0]||(o[0]=e=>b(Z)?Z.value=e:null),type:"textarea",rows:2,placeholder:"【量表题】请输入问题",disabled:i.isSave},null,8,["modelValue","disabled"])])],2),w("div",D,[o[11]||(o[11]=w("div",{class:"label flex flex-justify-center"},[w("span",null,"行标题:")],-1)),w("div",H,[f(T,{modelValue:m(le),"onUpdate:modelValue":o[1]||(o[1]=e=>b(le)?le.value=e:null),type:"textarea",placeholder:"请输入行标题",style:{width:"160px"},rows:10},null,8,["modelValue"]),w("div",I,[(p(!0),c(g,null,j(m(Y),((e,l)=>(p(),c("div",{key:l,class:"answer-item flex flex-items-center"},[w("span",N,C(String.fromCharCode(65+l))+".",1),f(T,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:10,placeholder:`选项${String.fromCharCode(65+l)}`,disabled:i.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),h(' <PlusCircleOutlined\n class="icon"\n :class="[{ disabled: answers.length === 5 }]"\n @click="addAnswer"\n />\n <MinusCircleOutlined\n class="icon"\n :class="[{ disabled: answers.length < 3 }]"\n @click="deleteAnswer(index)"\n /> '),f(_,{class:"icon"},{default:x((()=>[f(m(V),{class:v([{disabled:5===m(Y).length}]),onClick:ie},null,8,["class"])])),_:1}),f(_,{class:"icon"},{default:x((()=>[f(m(q),{class:v([{disabled:m(Y).length<3}]),onClick:e=>function(e){Y.value.length<3||Y.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024)])))),128))])])]),w("div",$,[o[12]||(o[12]=w("div",{class:"label flex flex-justify-center"},[w("span",null,"解析:")],-1)),w("div",P,[f(T,{modelValue:m(ee),"onUpdate:modelValue":o[2]||(o[2]=e=>b(ee)?ee.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])]),m(te)?(p(),c("div",z,[o[14]||(o[14]=w("div",{class:"label flex flex-justify-center"},[w("span",null,"富文本:")],-1)),w("div",F,[f(R,S({"model-value":m(ae),"onUpdate:modelValue":o[3]||(o[3]=e=>b(ae)?ae.value=e:null)},m(X),{style:{width:"100%"}}),null,16,["model-value"]),w("div",G,[f(J,{type:"danger",onClick:oe},{default:x((()=>o[13]||(o[13]=[k(" 删除富文本 ")]))),_:1})])])])):h("v-if",!0)])),default:x((()=>[i.showAction?(p(),y(L,{key:0,"is-edit":i.isEdit,"is-set":i.isSet,showOtherOption:!1,examAnswerRelationType:K.examAnswerRelationType,onMoveUp:o[4]||(o[4]=e=>W("move","up")),onMoveDown:o[5]||(o[5]=e=>W("move","down")),onDelete:o[6]||(o[6]=e=>W("delete")),onSave:ue,onEdit:o[7]||(o[7]=e=>W("edit")),onAdd:o[8]||(o[8]=e=>W("add",e)),onOnShowRichText:o[9]||(o[9]=e=>te.value=!0)},null,8,["is-edit","is-set","examAnswerRelationType"])):h("v-if",!0)])),_:1},8,["show-edit"])],2)}}});export{J as default};
|
2
2
|
//# sourceMappingURL=subject-scale.vue.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-scale.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-scale.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { ElMessage } from 'element-plus'\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'\n\ndefineOptions({\n name: 'QxsSubjectScale',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n answerList?: any\n analysis?: string\n rowTitle?: string\n isEdit: boolean\n isSet: boolean\n scaleQuestionList?: any\n examRichTextContent?: string\n examAnswerRelationType?: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add'])\n\nconst attrs = useAttrs()\n\nconst answers = ref<{\n title: string\n}[]>([{\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}])\n\nconst title = ref('')\nconst analysis = ref('')\nconst rowTitle = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst scaleQuestionList = ref<string[]>([])\nconst span = computed(() => Math.ceil(24 / (answers.value.length + 1)))\nfunction addAnswer() {\n if (answers.value.length === 5) {\n return\n }\n answers.value.push({\n title: '',\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3) {\n return\n }\n answers.value.splice(index, 1)\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 let msg = ''\n answers.value.forEach((v, i) => {\n if (!v.title) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n })\n\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n if (!rowTitle.value) {\n ElMessage.error('行标题不能为空!')\n return\n }\n\n scaleQuestionList.value = rowTitle.value.split('\\n').filter(i => i)\n\n emits('save', {\n title: title.value,\n answers: answers.value,\n analysis: analysis.value,\n scaleQuestionList: scaleQuestionList.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.scaleQuestionList) {\n scaleQuestionList.value = props.scaleQuestionList\n rowTitle.value = scaleQuestionList.value.join('\\n')\n }\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\n\nonMounted(init)\nconst ns = useNamespace('subject-scale')\n</script>\n\n<template>\n <div :class=\"ns.e('scale-exam')\">\n <SubjectLayout :show-edit=\"isEdit\">\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">{{ orderIndex + 1 }}.{{ title }}(量表题)</span>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" />\n </div>\n </div>\n <div class=\"answer-radio flex flex-col\">\n <el-row style=\"padding: 10px 0;\">\n <el-col :span=\"span\" />\n <el-col\n v-for=\"item in answers\"\n :key=\"item.title\"\n class=\"flex flex-center\"\n :span=\"span\"\n >\n <span>{{ item.title }}</span>\n </el-col>\n </el-row>\n <el-row\n v-for=\"item in scaleQuestionList\"\n :key=\"item\"\n style=\"padding: 10px 0;\"\n >\n <el-col :span=\"span\" class=\"flex flex-center\">\n <span>{{ item }}</span>\n </el-col>\n <el-col\n v-for=\"i in answers.length\"\n :key=\"i\"\n class=\"radio-item flex flex-center\"\n :span=\"span\"\n >\n <el-radio :disabled=\"true\" />\n </el-col>\n </el-row>\n </div>\n </div>\n </template>\n <template #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=\"【量表题】请输入问题\"\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"answer flex\">\n <div class=\"label flex flex-justify-center\">\n <span>行标题:</span>\n </div>\n <div class=\"flex\">\n <el-input\n v-model.trim=\"rowTitle\"\n type=\"textarea\"\n placeholder=\"请输入行标题\"\n style=\"width: 160px;\"\n :rows=\"10\"\n />\n <div class=\"answer-list flex-col\">\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=\"10\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <!-- <PlusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n <MinusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n /> -->\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n </div>\n </div>\n </div>\n </div>\n <div class=\"flex\" style=\"margin-bottom: 20px;\">\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 :showOtherOption=\"false\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\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=\"(type: any) => emits('add', type)\"\n @onShowRichText=\"showRichText = true\"\n />\n </SubjectLayout>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answers","ref","title","analysis","rowTitle","showRichText","richText","scaleQuestionList","span","computed","Math","ceil","value","length","addAnswer","push","deleteRichText","save","ElMessage","error","msg","forEach","v","i","String","fromCharCode","split","filter","examRichTextContent","onMounted","answerList","join","ns","useNamespace","index","splice"],"mappings":"quDAWA,MAAMA,EAAQC,EAcRC,EAAQC,EAERC,EAAQC,IAERC,EAAUC,EAEX,CAAC,CACJC,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,MAGHA,EAAQD,EAAI,IACZE,GAAWF,EAAI,IACfG,GAAWH,EAAI,IACfI,GAAeJ,GAAI,GACnBK,GAAWL,EAAI,IACfM,GAAoBN,EAAc,IAClCO,GAAOC,GAAS,IAAMC,KAAKC,KAAK,IAAMX,EAAQY,MAAMC,OAAS,MACnE,SAASC,KACsB,IAAzBd,EAAQY,MAAMC,QAGlBb,EAAQY,MAAMG,KAAK,CACjBb,MAAO,IACR,CAUH,SAASc,KACPX,GAAaO,OAAQ,EACrBN,GAASM,MAAQ,EAAA,CAGnB,SAASK,KACH,IAACf,EAAMU,MAET,YADAM,EAAUC,MAAM,aAGlB,IAAIC,EAAM,GACVpB,EAAQY,MAAMS,SAAQ,CAACC,EAAGC,KACnBD,EAAEpB,QACLkB,GAAO,KAAKI,OAAOC,aAAa,GAAKF,SAAE,IAIvCH,EACFF,EAAUC,MAAMC,GAIbhB,GAASQ,OAKIL,GAAAK,MAAQR,GAASQ,MAAMc,MAAM,MAAMC,WAAYJ,IAEjE3B,EAAM,OAAQ,CACZM,MAAOA,EAAMU,MACbZ,QAASA,EAAQY,MACjBT,SAAUA,GAASS,MACnBL,kBAAmBA,GAAkBK,MACrCgB,oBAAqBvB,GAAaO,MAAQN,GAASM,MAAQ,MAX3DM,EAAUC,MAAM,WAYjB,CA0BHU,GAvBA,WACMnC,EAAMQ,QACRA,EAAMU,MAAQlB,EAAMQ,OAGlBR,EAAMoC,YAAcpC,EAAMoC,WAAWjB,SACvCb,EAAQY,MAAQlB,EAAMoC,YAGpBpC,EAAMS,WACRA,GAASS,MAAQlB,EAAMS,UAGrBT,EAAMa,oBACRA,GAAkBK,MAAQlB,EAAMa,kBAChCH,GAASQ,MAAQL,GAAkBK,MAAMmB,KAAK,OAE5CrC,EAAMkC,sBACRtB,GAASM,MAAQlB,EAAMkC,oBACvBvB,GAAaO,OAAQ,EACvB,IAII,MAAAoB,GAAKC,EAAa,2iFArExB,SAAsBC,GAChBlC,EAAQY,MAAMC,OAAS,GAGnBb,EAAAY,MAAMuB,OAAOD,EAAO,EAAC"}
|
1
|
+
{"version":3,"file":"subject-scale.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-scale.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { ElMessage } from 'element-plus'\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'\n\ndefineOptions({\n name: 'QxsSubjectScale',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n answerList?: any\n analysis?: string\n rowTitle?: string\n isEdit: boolean\n isSet: boolean\n scaleQuestionList?: any\n examRichTextContent?: string\n examAnswerRelationType?: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add'])\n\nconst attrs = useAttrs()\n\nconst answers = ref<{\n title: string\n}[]>([{\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}])\n\nconst title = ref('')\nconst analysis = ref('')\nconst rowTitle = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst scaleQuestionList = ref<string[]>([])\nconst span = computed(() => Math.ceil(24 / (answers.value.length + 1)))\nfunction addAnswer() {\n if (answers.value.length === 5) {\n return\n }\n answers.value.push({\n title: '',\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3) {\n return\n }\n answers.value.splice(index, 1)\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 let msg = ''\n answers.value.forEach((v, i) => {\n if (!v.title) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n })\n\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n if (!rowTitle.value) {\n ElMessage.error('行标题不能为空!')\n return\n }\n\n scaleQuestionList.value = rowTitle.value.split('\\n').filter(i => i)\n\n emits('save', {\n title: title.value,\n answers: answers.value,\n analysis: analysis.value,\n scaleQuestionList: scaleQuestionList.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.scaleQuestionList) {\n scaleQuestionList.value = props.scaleQuestionList\n rowTitle.value = scaleQuestionList.value.join('\\n')\n }\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\n\nonMounted(init)\nconst ns = useNamespace('subject-scale')\n</script>\n\n<template>\n <div :class=\"ns.e('scale-exam')\">\n <SubjectLayout :show-edit=\"isEdit\">\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">{{ orderIndex + 1 }}.{{ title }}(量表题)</span>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" />\n </div>\n </div>\n <div class=\"answer-radio flex flex-col\">\n <el-row style=\"padding: 10px 0;\">\n <el-col :span=\"span\" />\n <el-col\n v-for=\"item in answers\"\n :key=\"item.title\"\n class=\"flex flex-center\"\n :span=\"span\"\n >\n <span>{{ item.title }}</span>\n </el-col>\n </el-row>\n <el-row\n v-for=\"item in scaleQuestionList\"\n :key=\"item\"\n style=\"padding: 10px 0;\"\n >\n <el-col :span=\"span\" class=\"flex flex-center\">\n <span>{{ item }}</span>\n </el-col>\n <el-col\n v-for=\"i in answers.length\"\n :key=\"i\"\n class=\"radio-item flex flex-center\"\n :span=\"span\"\n >\n <el-radio :disabled=\"true\" />\n </el-col>\n </el-row>\n </div>\n </div>\n </template>\n <template #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=\"【量表题】请输入问题\"\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"answer flex\">\n <div class=\"label flex flex-justify-center\">\n <span>行标题:</span>\n </div>\n <div class=\"flex\">\n <el-input\n v-model=\"rowTitle\"\n type=\"textarea\"\n placeholder=\"请输入行标题\"\n style=\"width: 160px;\"\n :rows=\"10\"\n />\n <div class=\"answer-list flex-col\">\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=\"10\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <!-- <PlusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n <MinusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n /> -->\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n </div>\n </div>\n </div>\n </div>\n <div class=\"flex\" style=\"margin-bottom: 20px;\">\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 :showOtherOption=\"false\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\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=\"(type: any) => emits('add', type)\"\n @onShowRichText=\"showRichText = true\"\n />\n </SubjectLayout>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answers","ref","title","analysis","rowTitle","showRichText","richText","scaleQuestionList","span","computed","Math","ceil","value","length","addAnswer","push","deleteRichText","save","ElMessage","error","msg","forEach","v","i","String","fromCharCode","split","filter","examRichTextContent","onMounted","answerList","join","ns","useNamespace","index","splice"],"mappings":"quDAWA,MAAMA,EAAQC,EAcRC,EAAQC,EAERC,EAAQC,IAERC,EAAUC,EAEX,CAAC,CACJC,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,MAGHA,EAAQD,EAAI,IACZE,GAAWF,EAAI,IACfG,GAAWH,EAAI,IACfI,GAAeJ,GAAI,GACnBK,GAAWL,EAAI,IACfM,GAAoBN,EAAc,IAClCO,GAAOC,GAAS,IAAMC,KAAKC,KAAK,IAAMX,EAAQY,MAAMC,OAAS,MACnE,SAASC,KACsB,IAAzBd,EAAQY,MAAMC,QAGlBb,EAAQY,MAAMG,KAAK,CACjBb,MAAO,IACR,CAUH,SAASc,KACPX,GAAaO,OAAQ,EACrBN,GAASM,MAAQ,EAAA,CAGnB,SAASK,KACH,IAACf,EAAMU,MAET,YADAM,EAAUC,MAAM,aAGlB,IAAIC,EAAM,GACVpB,EAAQY,MAAMS,SAAQ,CAACC,EAAGC,KACnBD,EAAEpB,QACLkB,GAAO,KAAKI,OAAOC,aAAa,GAAKF,SAAE,IAIvCH,EACFF,EAAUC,MAAMC,GAIbhB,GAASQ,OAKIL,GAAAK,MAAQR,GAASQ,MAAMc,MAAM,MAAMC,WAAYJ,IAEjE3B,EAAM,OAAQ,CACZM,MAAOA,EAAMU,MACbZ,QAASA,EAAQY,MACjBT,SAAUA,GAASS,MACnBL,kBAAmBA,GAAkBK,MACrCgB,oBAAqBvB,GAAaO,MAAQN,GAASM,MAAQ,MAX3DM,EAAUC,MAAM,WAYjB,CA0BHU,GAvBA,WACMnC,EAAMQ,QACRA,EAAMU,MAAQlB,EAAMQ,OAGlBR,EAAMoC,YAAcpC,EAAMoC,WAAWjB,SACvCb,EAAQY,MAAQlB,EAAMoC,YAGpBpC,EAAMS,WACRA,GAASS,MAAQlB,EAAMS,UAGrBT,EAAMa,oBACRA,GAAkBK,MAAQlB,EAAMa,kBAChCH,GAASQ,MAAQL,GAAkBK,MAAMmB,KAAK,OAE5CrC,EAAMkC,sBACRtB,GAASM,MAAQlB,EAAMkC,oBACvBvB,GAAaO,OAAQ,EACvB,IAII,MAAAoB,GAAKC,EAAa,khFArExB,SAAsBC,GAChBlC,EAAQY,MAAMC,OAAS,GAGnBb,EAAAY,MAAMuB,OAAOD,EAAO,EAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{ElCheckbox as e,ElRadio as l,ElInput as t,ElSelect as a,ElOption as i,ElIcon as s,ElLink as n,ElDialog as r,ElButton as o,ElMessage as u}from"element-plus/es";import{defineComponent as d,useAttrs as m,ref as c,computed as p,watch as v,onMounted as y,createElementBlock as f,openBlock as x,normalizeClass as w,unref as h,createVNode as C,createSlots as g,withCtx as b,createBlock as k,createCommentVNode as S,createElementVNode as A,createTextVNode as V,toDisplayString as T,Fragment as q,renderList as R,isRef as j,mergeProps as _}from"vue";import{CirclePlus as I,Remove as E}from"@element-plus/icons-vue";import{useNamespace as U}from"@qxs-bns/hooks";import B from"../../../subject-action/src/subject-action.vue.mjs";import L from"../../../subject-layout/src/subject-layout.vue.mjs";import $ from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";import{setGuid as K}from"@qxs-bns/utils";const N={class:"preview"},z={class:"title"},M={key:0},D={key:1},H={key:0},O=["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"},ae={style:{flex:"1"}},ie={class:"flex flex-justify-end"};var se=d({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(d,{emit:se}){const ne=d,re=se,oe=m(),ue=c(0),de=c(ne.isKey),me=c(1),ce=c(1),pe=c([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),ve=c(2),ye=c(""),fe=c(""),xe=c(!1),we=c(""),he=c(0),Ce=c(!1),ge=c(""),be=p((()=>"single"===ne.type?"单选题":"multiple"===ne.type?"多选题":"排序题")),ke=c([]),Se=p((()=>{const e=[];for(let l=pe.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function Ae(){ne.isSave||pe.value.push({title:"",isCorrect:!1,customAnswerId:K()})}function Ve(){xe.value=!1,we.value=""}function Te(){if(!ye.value)return void u.error("题目标题不能为空!");let e="",l=!1,t=0;if("multiple"===ne.type||"single"===ne.type?pe.value.forEach(((a,i)=>{a.title?.trim()||(e+=`选项${String.fromCharCode(65+i)}未填写。`),a.isCorrect&&(l=!0,t++),a.relationType=a.resultItem?1:a.answerRelations?.length?2:null})):"sort"===ne.type&&ke.value.length&&(l=!0),e)return void u.error(e);if(new Set(pe.value.map((e=>e.title))).size===pe.value.length){if("multiple"===ne.type){if(1===t)return void u.error("请至少设置两个支持选项");if(l&&t<ve.value)return void u.error("至少选几项与支持选项数不符")}2!==me.value&&3!==me.value||l?re("save",{title:ye.value,answers:pe.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:ke.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:fe.value,isSetCorrectAnswer:l,leastAnswerCount:ve.value,examRichTextContent:xe.value?we.value:"",examAnswerRelationType:ce.value,isKey:de.value,answerCheckType:me.value}):u.error("请设置支持选项")}else u.error("选项不能重复")}function qe(){pe.value[ue.value].resultItem=ge.value||"",Ce.value=!1}function Re(){Ce.value=!1,ge.value=""}function je(e){de.value=e}function _e(e){me.value=e}function Ie(e,l){re("add",e,l?ne.examAnswerRelationType:null)}v((()=>ne.isEdit),(()=>{ne.isEdit&&(he.value=(new Date).getTime())}));const Ee=p((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),Ue=U("subject-single");return y((function(){if(ne.title&&(ye.value=ne.title),ne.answerCheckType&&(me.value=ne.answerCheckType),ne.examAnswerRelationType&&(ce.value=ne.examAnswerRelationType),ne.answerList&&ne.answerList.length&&(pe.value=ne.answerList),ne.leastAnswerCount&&(ve.value=ne.leastAnswerCount),ne.examExpand&&ne.examExpand){const e=ne.examExpand.split(",");ke.value=e.map((e=>{const l=ne.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}ne.analysis&&(fe.value=ne.analysis),ne.examRichTextContent&&(we.value=ne.examRichTextContent,xe.value=!0)})),(u,d)=>{const m=e,c=l,p=t,v=i,y=a,U=s,se=n,he=o,Be=r;return x(),f("div",{class:w(h(Ue).e("single-exam"))},[C(L,{"show-edit":u.isEdit},g({preview:b((()=>[A("div",N,[A("div",null,[A("span",z,[V(T(u.orderIndex+1)+"."+T(h(ye))+" ",1),"single"===u.type?(x(),f("span",M,"(单选题)")):["multiple","sort"].includes(u.type)?(x(),f("span",D," ("+T(h(be))+T(h(ve)?`至少选${h(ve)}项${"sort"===u.type?"并排序":""}`:"")+") ",1)):S("v-if",!0)])]),h(xe)?(x(),f("div",H,[A("div",{innerHTML:h(we)},null,8,O)])):S("v-if",!0),A("div",Q,["sort"===u.type?(x(!0),f(q,{key:0},R(h(pe),((e,l)=>(x(),k(m,{key:l,class:"radio",disabled:!0},{default:b((()=>[A("span",F,T(String.fromCharCode(65+l))+". ",1),V(" "+T(e.title),1)])),_:2},1024)))),128)):(x(!0),f(q,{key:1},R(h(pe),((e,l)=>(x(),k(c,{key:l,class:"radio",value:"disabled",disabled:""},{default:b((()=>[A("span",G,T(String.fromCharCode(65+l))+". ",1),V(" "+T(e.title)+" "+T(e.isCorrect?"(支持选项)":"")+" "+T(1===h(ce)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+T(2===h(ce)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:b((()=>[u.showAction?(x(),k(B,{key:0,"is-edit":u.isEdit,"is-set":u.isSet,isKey:h(de),examAnswerRelationType:ne.examAnswerRelationType,answerCheckType:h(me),onMoveUp:d[5]||(d[5]=e=>re("move","up")),onMoveDown:d[6]||(d[6]=e=>re("move","down")),onDelete:d[7]||(d[7]=e=>re("delete")),onSave:Te,onEdit:d[8]||(d[8]=e=>re("edit")),onAdd:Ie,onOnShowRichText:d[9]||(d[9]=e=>xe.value=!0),onSetKey:je,onSetAnswerSetting:_e},null,8,["is-edit","is-set","isKey","examAnswerRelationType","answerCheckType"])):S("v-if",!0)])),_:2},[u.isEdit?{name:"edit",fn:b((()=>[A("div",{class:w(["flex",[{"margin-bottom":h(xe)}]])},[d[12]||(d[12]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"题目:")],-1)),A("div",J,[C(p,{modelValue:h(ye),"onUpdate:modelValue":d[0]||(d[0]=e=>j(ye)?ye.value=e:null),type:"textarea",rows:2,placeholder:`【${h(be)}】请输入问题`,disabled:u.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),A("div",P,[d[13]||(d[13]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"设置:")],-1)),["multiple","sort"].includes(u.type)?(x(),k(y,{key:0,modelValue:h(ve),"onUpdate:modelValue":d[1]||(d[1]=e=>j(ve)?ve.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:u.isSave},{default:b((()=>[(x(!0),f(q,null,R(h(Se),(e=>(x(),k(v,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):S("v-if",!0)]),A("div",W,[(x(!0),f(q,null,R(h(pe),((e,l)=>(x(),f("div",{key:l,class:"answer-item flex flex-items-center"},[A("span",X,T(String.fromCharCode(65+l))+".",1),C(p,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+l)}`,disabled:u.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(u.type)?(x(),k(m,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:w([{"is-correct":e.isCorrect}]),disabled:u.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===ne.type?(l&&pe.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===ne.type&&(e.isCorrect=l)}(e,l)},{default:b((()=>[...d[14]||(d[14]=[V(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):S("v-if",!0),C(U,{class:"icon"},{default:b((()=>[C(h(I),{class:w([{disabled:u.isSave}]),onClick:Ae},null,8,["class"])])),_:1}),C(U,{class:"icon"},{default:b((()=>[C(h(E),{class:w([{disabled:h(pe).length<3||u.isSave}]),onClick:e=>function(e){pe.value.length<3||ne.isSave||pe.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024),1===h(ce)?(x(),k(se,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=l,ue.value=t,ge.value=pe.value[t].resultItem||"",void(Ce.value=!0);var t}},{default:b((()=>[A("span",null,T(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):S("v-if",!0),2===h(ce)?(x(),k(se,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||K(),re("setRelation",ne.customId,e)}(e)},{default:b((()=>[A("span",null,T(e.answerRelations?.length?`关联了${h(Ee)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):S("v-if",!0)])))),128))]),"sort"===u.type?(x(),f("div",Y,[d[15]||(d[15]=A("div",{class:"label flex flex-justify-end"},[A("span",null,"排序答案:")],-1)),A("div",Z,[C(y,{modelValue:h(ke),"onUpdate:modelValue":d[2]||(d[2]=e=>j(ke)?ke.value=e:null),mode:"multiple",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:b((()=>[S(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(x(!0),f(q,null,R(h(pe),((e,l)=>(x(),k(v,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):S("v-if",!0),u.showAnalysis?(x(),f("div",ee,[d[16]||(d[16]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"解析:")],-1)),A("div",le,[C(p,{modelValue:h(fe),"onUpdate:modelValue":d[3]||(d[3]=e=>j(fe)?fe.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):S("v-if",!0),h(xe)?(x(),f("div",te,[d[18]||(d[18]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"富文本:")],-1)),A("div",ae,[C($,_({"model-value":h(we),"onUpdate:modelValue":d[4]||(d[4]=e=>j(we)?we.value=e:null)},h(oe),{style:{width:"100%"}}),null,16,["model-value"]),A("div",ie,[C(se,{type:"danger",onClick:Ve},{default:b((()=>d[17]||(d[17]=[V(" 删除富文本 ")]))),_:1})])])])):S("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),C(Be,{modelValue:h(Ce),"onUpdate:modelValue":d[11]||(d[11]=e=>j(Ce)?Ce.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:b((()=>[C(he,{class:"customize-button",type:"primary",plain:"",onClick:Re},{default:b((()=>d[19]||(d[19]=[V(" 取消 ")]))),_:1}),C(he,{class:"customize-button",type:"primary",plain:"",onClick:qe},{default:b((()=>d[20]||(d[20]=[V(" 保存 ")]))),_:1})])),default:b((()=>[(x(),k($,_({key:h(ue),"model-value":h(ge),"onUpdate:modelValue":d[10]||(d[10]=e=>j(ge)?ge.value=e:null)},h(oe),{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 a,ElOption as i,ElIcon as s,ElLink as n,ElDialog as r,ElButton as o,ElMessage as u}from"element-plus/es";import{defineComponent as d,useAttrs as m,ref as p,computed as c,watch as v,onMounted as y,createElementBlock as f,openBlock as x,normalizeClass as w,unref as h,createVNode as C,createSlots as g,withCtx as b,createBlock as k,createCommentVNode as S,createElementVNode as A,createTextVNode as V,toDisplayString as T,Fragment as q,renderList as R,isRef as j,mergeProps as _}from"vue";import{CirclePlus as I,Remove as E}from"@element-plus/icons-vue";import{useNamespace as U}from"@qxs-bns/hooks";import B from"../../../subject-action/src/subject-action.vue.mjs";import L from"../../../subject-layout/src/subject-layout.vue.mjs";import $ from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";import{setGuid as K}from"@qxs-bns/utils";const N={class:"preview"},O={class:"title"},z={key:0},M={key:1},D={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"},ae={style:{flex:"1"}},ie={class:"flex flex-justify-end"};var se=d({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(d,{emit:se}){const ne=d,re=se,oe=m(),ue=p(0),de=p(ne.isKey),me=p(1),pe=p(1),ce=p([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),ve=p(2),ye=p(""),fe=p(""),xe=p(!1),we=p(""),he=p(0),Ce=p(!1),ge=p(""),be=c((()=>"single"===ne.type?"单选题":"multiple"===ne.type?"多选题":"排序题")),ke=p([]),Se=c((()=>{const e=[];for(let l=ce.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function Ae(){ne.isSave||ce.value.push({title:"",isCorrect:!1,customAnswerId:K()})}function Ve(){xe.value=!1,we.value=""}function Te(){if(!ye.value)return void u.error("题目标题不能为空!");let e="",l=!1,t=0;if("multiple"===ne.type||"single"===ne.type?ce.value.forEach(((a,i)=>{a.title?.trim()||(e+=`选项${String.fromCharCode(65+i)}未填写。`),a.isCorrect&&(l=!0,t++),a.relationType=a.resultItem?1:a.answerRelations?.length?2:null})):"sort"===ne.type&&ke.value.length&&(l=!0),e)return void u.error(e);if(new Set(ce.value.map((e=>e.title))).size===ce.value.length){if("multiple"===ne.type){if(1===t)return void u.error("请至少设置两个支持选项");if(l&&t<ve.value)return void u.error("至少选几项与支持选项数不符")}2!==me.value&&3!==me.value||l?re("save",{title:ye.value,answers:ce.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:ke.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:fe.value,isSetCorrectAnswer:l,leastAnswerCount:ve.value,examRichTextContent:xe.value?we.value:"",examAnswerRelationType:pe.value,isKey:de.value,answerCheckType:me.value}):u.error("请设置支持选项")}else u.error("选项不能重复")}function qe(){ce.value[ue.value].resultItem=ge.value||"",Ce.value=!1}function Re(){Ce.value=!1,ge.value=""}function je(e){de.value=e}function _e(e){me.value=e}function Ie(e,l){re("add",e,l?ne.examAnswerRelationType:null)}v((()=>ne.isEdit),(()=>{ne.isEdit&&(he.value=(new Date).getTime())}));const Ee=c((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),Ue=U("subject-single");return y((function(){if(ne.title&&(ye.value=ne.title),ne.answerCheckType&&(me.value=ne.answerCheckType),ne.examAnswerRelationType&&(pe.value=ne.examAnswerRelationType),ne.answerList&&ne.answerList.length&&(ce.value=ne.answerList),ne.leastAnswerCount&&(ve.value=ne.leastAnswerCount),ne.examExpand&&ne.examExpand){const e=ne.examExpand.split(",");ke.value=e.map((e=>{const l=ne.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}ne.analysis&&(fe.value=ne.analysis),ne.examRichTextContent&&(we.value=ne.examRichTextContent,xe.value=!0)})),(u,d)=>{const m=e,p=l,c=t,v=i,y=a,U=s,se=n,he=o,Be=r;return x(),f("div",{class:w(h(Ue).e("single-exam"))},[C(L,{"show-edit":u.isEdit},g({preview:b((()=>[A("div",N,[A("div",null,[A("span",O,[V(T(u.orderIndex+1)+"."+T(h(ye))+" ",1),"single"===u.type?(x(),f("span",z,"(单选题)")):["multiple","sort"].includes(u.type)?(x(),f("span",M," ("+T(h(be))+T(h(ve)?`至少选${h(ve)}项${"sort"===u.type?"并排序":""}`:"")+") ",1)):S("v-if",!0)])]),h(xe)?(x(),f("div",D,[A("div",{innerHTML:h(we)},null,8,H)])):S("v-if",!0),A("div",Q,["sort"===u.type?(x(!0),f(q,{key:0},R(h(ce),((e,l)=>(x(),k(m,{key:l,class:"radio",disabled:!0},{default:b((()=>[A("span",F,T(String.fromCharCode(65+l))+". ",1),V(" "+T(e.title),1)])),_:2},1024)))),128)):(x(!0),f(q,{key:1},R(h(ce),((e,l)=>(x(),k(p,{key:l,class:"radio",value:"disabled",disabled:""},{default:b((()=>[A("span",G,T(String.fromCharCode(65+l))+". ",1),V(" "+T(e.title)+" "+T(e.isCorrect?"(支持选项)":"")+" "+T(1===h(pe)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+T(2===h(pe)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:b((()=>[u.showAction?(x(),k(B,{key:0,"is-edit":u.isEdit,"is-set":u.isSet,isKey:h(de),showOtherOption:"multiple"===ne.type||"single"===ne.type,examAnswerRelationType:ne.examAnswerRelationType,answerCheckType:h(me),onMoveUp:d[5]||(d[5]=e=>re("move","up")),onMoveDown:d[6]||(d[6]=e=>re("move","down")),onDelete:d[7]||(d[7]=e=>re("delete")),onSave:Te,onEdit:d[8]||(d[8]=e=>re("edit")),onAdd:Ie,onOnShowRichText:d[9]||(d[9]=e=>xe.value=!0),onSetKey:je,onSetAnswerSetting:_e},null,8,["is-edit","is-set","isKey","showOtherOption","examAnswerRelationType","answerCheckType"])):S("v-if",!0)])),_:2},[u.isEdit?{name:"edit",fn:b((()=>[A("div",{class:w(["flex",[{"margin-bottom":h(xe)}]])},[d[12]||(d[12]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"题目:")],-1)),A("div",J,[C(c,{modelValue:h(ye),"onUpdate:modelValue":d[0]||(d[0]=e=>j(ye)?ye.value=e:null),type:"textarea",rows:2,placeholder:`【${h(be)}】请输入问题`,disabled:u.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),A("div",P,[d[13]||(d[13]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"设置:")],-1)),["multiple","sort"].includes(u.type)?(x(),k(y,{key:0,modelValue:h(ve),"onUpdate:modelValue":d[1]||(d[1]=e=>j(ve)?ve.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:u.isSave},{default:b((()=>[(x(!0),f(q,null,R(h(Se),(e=>(x(),k(v,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):S("v-if",!0)]),A("div",W,[(x(!0),f(q,null,R(h(ce),((e,l)=>(x(),f("div",{key:l,class:"answer-item flex flex-items-center"},[A("span",X,T(String.fromCharCode(65+l))+".",1),C(c,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+l)}`,disabled:u.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(u.type)?(x(),k(m,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:w([{"is-correct":e.isCorrect}]),disabled:u.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===ne.type?(l&&ce.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===ne.type&&(e.isCorrect=l)}(e,l)},{default:b((()=>[...d[14]||(d[14]=[V(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):S("v-if",!0),C(U,{class:"icon"},{default:b((()=>[C(h(I),{class:w([{disabled:u.isSave}]),onClick:Ae},null,8,["class"])])),_:1}),C(U,{class:"icon"},{default:b((()=>[C(h(E),{class:w([{disabled:h(ce).length<3||u.isSave}]),onClick:e=>function(e){ce.value.length<3||ne.isSave||ce.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024),1===h(pe)&&"sort"!==u.type?(x(),k(se,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=l,ue.value=t,ge.value=ce.value[t].resultItem||"",void(Ce.value=!0);var t}},{default:b((()=>[A("span",null,T(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):S("v-if",!0),2===h(pe)&&"sort"!==u.type?(x(),k(se,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||K(),re("setRelation",ne.customId,e)}(e)},{default:b((()=>[A("span",null,T(e.answerRelations?.length?`关联了${h(Ee)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):S("v-if",!0)])))),128))]),"sort"===u.type?(x(),f("div",Y,[d[15]||(d[15]=A("div",{class:"label flex flex-justify-end"},[A("span",null,"排序答案:")],-1)),A("div",Z,[C(y,{modelValue:h(ke),"onUpdate:modelValue":d[2]||(d[2]=e=>j(ke)?ke.value=e:null),multiple:"",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:b((()=>[S(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(x(!0),f(q,null,R(h(ce),((e,l)=>(x(),k(v,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):S("v-if",!0),u.showAnalysis?(x(),f("div",ee,[d[16]||(d[16]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"解析:")],-1)),A("div",le,[C(c,{modelValue:h(fe),"onUpdate:modelValue":d[3]||(d[3]=e=>j(fe)?fe.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):S("v-if",!0),h(xe)?(x(),f("div",te,[d[18]||(d[18]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"富文本:")],-1)),A("div",ae,[C($,_({"model-value":h(we),"onUpdate:modelValue":d[4]||(d[4]=e=>j(we)?we.value=e:null)},h(oe),{style:{width:"100%"}}),null,16,["model-value"]),A("div",ie,[C(se,{type:"danger",onClick:Ve},{default:b((()=>d[17]||(d[17]=[V(" 删除富文本 ")]))),_:1})])])])):S("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),C(Be,{modelValue:h(Ce),"onUpdate:modelValue":d[11]||(d[11]=e=>j(Ce)?Ce.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:b((()=>[C(he,{class:"customize-button",type:"primary",plain:"",onClick:Re},{default:b((()=>d[19]||(d[19]=[V(" 取消 ")]))),_:1}),C(he,{class:"customize-button",type:"primary",plain:"",onClick:qe},{default:b((()=>d[20]||(d[20]=[V(" 保存 ")]))),_:1})])),default:b((()=>[(x(),k($,_({key:h(ue),"model-value":h(ge),"onUpdate:modelValue":d[10]||(d[10]=e=>j(ge)?ge.value=e:null)},h(oe),{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(1)\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 let msg = ''\n let isSetCorrectAnswer = false\n // let examAnswerRelationType = null\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 // const customId = props.id || setGuid()\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\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\"\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\"\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 mode=\"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 :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":"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"}
|
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(1)\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 let msg = ''\n let isSetCorrectAnswer = false\n // let examAnswerRelationType = null\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 // const customId = props.id || setGuid()\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\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":"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"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{defineComponent as e,ref as s,useAttrs as t,
|
1
|
+
import{defineComponent as e,ref as s,useAttrs as t,computed as n,watch as i,createElementBlock as a,openBlock as o,normalizeClass as l,unref as r,createElementVNode as d,Fragment as c,renderList as m,createBlock as u,createCommentVNode as x,mergeProps as p}from"vue";import w from"./components/subject-blank-fill.vue.mjs";import v from"./components/subject-scale.vue.mjs";import y from"./components/subject-single.vue.mjs";import h from"./components/subject-text-fill.vue.mjs";import T from"./components/SubjectRichText.vue.mjs";import f from"./components/SubjectPageEnd.vue.mjs";import{useNamespace as A}from"@qxs-bns/hooks";import{setGuid as R}from"@qxs-bns/utils";import{ElMessage as E}from"element-plus/es";const S={class:"subject-list-wrapper"};var C=e({name:"QxsSubjectList",__name:"subject-list",props:{subjectList:{type:Array,required:!0},isPreview:{type:Boolean,required:!0}},emits:["setRelation"],setup(e,{expose:C,emit:D}){const g=e,j=s([]),b=D,I=t();C({addSubject:M,currentList:j,uploadExcel:function(e){j.value=j.value.concat(e)},addExam:function(e){let s=1;const t=e.answers?.map((e=>({...e,title:e.answer,answerId:e.examAnswerId,isCorrect:e.isCorrect})))||[],n={...e,customId:R(),answerType:e.richTextContent?"rich_text":e.examTypeEnum,answers:t,isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1};j.value.push(n),e.pageIndex-s==1&&(k(),s++);s>1&&k()},setAnswerRelation:function(e,s,t){const n=j.value.find((e=>e.customId===s));if(n){const s=n.answers?.find((e=>e.customAnswerId===t));s&&(s.answerRelations=e)}}});const _=n((()=>{const e=j.value.filter((e=>"page_end"===e.answerType));return s=>{const t=e.findIndex((e=>e.customId===s));return-1!==t?t+1:0}}));function k(){j.value.push({customId:R(),answerType:"page_end",analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:0})}function M(e,s=null,t=null){const n={customId:R(),answerType:e,analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:t};null!==s?j.value.splice(s+1,0,n):j.value.push(n)}function L(e,s){if("up"===s&&e>0){const[s]=j.value.splice(e,1);j.value.splice(e-1,0,s)}else if("down"===s&&e<j.value.length-1){const[s]=j.value.splice(e,1);j.value.splice(e+1,0,s)}}function P(e,s){j.value[e]={...j.value[e],...s,isEdit:!1,examAnswerRelationType:s.examAnswerRelationType}}function q(e){j.value.splice(e,1),E.success("删除成功")}function Q(e,s){b("setRelation",e,s)}i((()=>g.subjectList),(e=>{e&&(j.value=[...e])}),{immediate:!0});const K=A("subject-list");return(e,s)=>(o(),a("div",{class:l(r(K).e("list-exam"))},[d("div",S,[(o(!0),a(c,null,m(r(j),((s,t)=>(o(),a("div",{key:s.customId,class:"subject-item"},[["single","multiple","sort"].includes(s.answerType)?(o(),u(y,p({key:0,ref_for:!0},r(I),{"order-index":t,title:s.title,type:s.answerType,"exam-id":s.examId,isKey:s.isKey,"is-save":!s.isRealCanDel,customId:s.customId,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"least-answer-count":s.leastAnswerCount,"is-edit":s.isEdit||!1,"show-action":!e.isPreview,"exam-expand":s.examExpand,answerCheckType:s.answerCheckType,"exam-rich-text-content":s.examRichTextContent,examAnswerRelationType:s.examAnswerRelationType,onSetRelation:Q,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:(e,s)=>M(e,t,s)}),null,16,["order-index","title","type","exam-id","isKey","is-save","customId","is-set","answer-list","analysis","least-answer-count","is-edit","show-action","exam-expand","answerCheckType","exam-rich-text-content","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):"scale"===s.answerType?(o(),u(v,p({key:1,ref_for:!0},r(I),{"order-index":t,title:s.title,"is-save":!s.isRealCanDel,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"is-edit":s.isEdit||!1,"scale-question-list":s.scaleQuestionList,"show-action":!e.isPreview,"exam-rich-text-content":s.examRichTextContent,examAnswerRelationType:s.examAnswerRelationType,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","is-edit","scale-question-list","show-action","exam-rich-text-content","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):"blank_fill"===s.answerType?(o(),u(w,p({key:2,ref_for:!0},r(I),{"order-index":t,title:s.title,"is-save":!s.isRealCanDel,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"show-action":!e.isPreview,"is-edit":s.isEdit||!1,"exam-answer-setting-v-o":s.examAnswerSettingVO||{},"exam-rich-text-content":s.examRichTextContent,examAnswerRelationType:s.examAnswerRelationType,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","show-action","is-edit","exam-answer-setting-v-o","exam-rich-text-content","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):"text_fill"===s.answerType?(o(),u(h,p({key:3,ref_for:!0},r(I),{"order-index":t,title:s.title,"is-save":!s.isRealCanDel,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"show-action":!e.isPreview,"is-edit":s.isEdit||!1,"exam-expand":s.examExpand,"exam-answer-setting-v-o":s.examAnswerSettingVO||{},examAnswerRelationType:s.examAnswerRelationType,"exam-rich-text-content":s.examRichTextContent,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","show-action","is-edit","exam-expand","exam-answer-setting-v-o","examAnswerRelationType","exam-rich-text-content","onMove","onDelete","onSave","onEdit","onAdd"])):"rich_text"===s.answerType?(o(),u(T,p({key:4,ref_for:!0},r(I),{"order-index":t,richTextContent:s.richTextContent,"is-set":s.hasSet||!1,"is-save":!s.isRealCanDel,"is-edit":s.isEdit||!1,"show-action":!e.isPreview,onMove:e=>L(t,e),onDelete:e=>q(t),examAnswerRelationType:s.examAnswerRelationType,onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","richTextContent","is-set","is-save","is-edit","show-action","onMove","onDelete","examAnswerRelationType","onSave","onEdit","onAdd"])):"page_end"===s.answerType?(o(),u(f,{"total-page":j.value.filter((e=>"page_end"===e.answerType)).length,key:t,"current-page-index":r(_)(s.customId),item:s,"order-index":t,"is-edit":s.isEdit||!1,"is-set":s.hasSet||!1,"is-save":!s.isRealCanDel,examAnswerRelationType:s.examAnswerRelationType,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)},null,8,["total-page","current-page-index","item","order-index","is-edit","is-set","is-save","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):x("v-if",!0)])))),128))])],2))}});export{C as default};
|
2
2
|
//# sourceMappingURL=subject-list.vue.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-list.vue.mjs","sources":["../../../../../../packages/components/src/subject-list/src/subject-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport SubjectBlankFill from './components/subject-blank-fill.vue'\nimport SubjectScale from './components/subject-scale.vue'\nimport SubjectSingle from './components/subject-single.vue'\nimport SubjectTextFill from './components/subject-text-fill.vue'\nimport SubjectRichText from './components/SubjectRichText.vue'\nimport SubjectPageEnd from './components/SubjectPageEnd.vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectList',\n})\n\nconst props = defineProps<{\n subjectList: any[]\n isPreview: boolean\n}>()\nconst currentList = ref([] as any)\nconst emits = defineEmits(['setRelation'])\n\nconst attrs = useAttrs()\n\ndefineExpose({\n addSubject,\n currentList,\n uploadExcel,\n addExam,\n setAnswerRelation,\n})\n\nfunction totalPageIndex() {\n return currentList.value.filter((v: any) => v.answerType === 'page_end').length\n}\n\nfunction currentPageIndex(currentId: any) {\n const currentPageList = currentList.value.filter((v: any) => v.answerType === 'page_end')\n const currentIndex = currentPageList.findIndex((c: any) => c.customId === currentId)\n return currentIndex + 1\n}\n\nfunction addPageEnd() {\n currentList.value.push({\n customId: setGuid(),\n answerType: 'page_end',\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: 0,\n })\n}\n\nfunction addSubject(type: string, index: number | null = null, examAnswerRelationType: number | null = null) {\n const newSubject = {\n customId: setGuid(),\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType,\n }\n\n if (index !== null) {\n currentList.value.splice(index + 1, 0, newSubject)\n } else {\n currentList.value.push(newSubject)\n }\n}\n\nfunction addExam(item: any) {\n const answerList = item.answers?.map((v: any) => ({\n ...v,\n title: v.answer,\n answerId: v.examAnswerId,\n isCorrect: v.isCorrect,\n })) || []\n\n currentList.value.push({\n ...item,\n customId: setGuid(),\n answerType: item.richTextContent ? 'rich_text' : item.examTypeEnum,\n answers: answerList,\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n })\n\n if (item.pageIndex - currentPageIndex(item.customId) === 1) {\n addPageEnd()\n }\n\n if (currentPageIndex(item.customId) > 1) {\n addPageEnd()\n }\n}\n\nfunction uploadExcel(list: any[]) {\n currentList.value = currentList.value.concat(list)\n}\n\nfunction move(index: number, type: 'up' | 'down') {\n if (type === 'up' && index > 0) {\n const [item] = currentList.value.splice(index, 1)\n currentList.value.splice(index - 1, 0, item)\n } else if (type === 'down' && index < currentList.value.length - 1) {\n const [item] = currentList.value.splice(index, 1)\n currentList.value.splice(index + 1, 0, item)\n }\n}\n\nfunction saveSubject(index: number, item: any) {\n currentList.value[index] = {\n ...currentList.value[index],\n ...item,\n isEdit: false,\n examAnswerRelationType: item.examAnswerRelationType,\n }\n}\n\nfunction deleteSubject(index: number) {\n currentList.value.splice(index, 1)\n ElMessage.success('删除成功')\n}\n\nfunction setRelation(customId: number, examAnswers: any) {\n emits('setRelation', customId, examAnswers)\n}\n\nfunction setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n if (answerRelations.length) {\n const targetItem = currentList.value.find((v: any) => v.customId === customId)\n if (targetItem) {\n const targetAnswer = targetItem.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (targetAnswer) {\n targetAnswer.answerRelations = answerRelations\n }\n }\n }\n}\n\nwatch(() => props.subjectList, (newList: any) => {\n if (newList) {\n currentList.value = [...newList]\n }\n}, { immediate: true })\n\nconst ns = useNamespace('subject-list')\n</script>\n\n<template>\n <div :class=\"ns.e('list-exam')\">\n <div class=\"subject-list-wrapper\">\n <div v-for=\"(item, index) in currentList\" :key=\"item.customId\" class=\"subject-item\">\n <template v-if=\"['single', 'multiple', 'sort'].includes(item.answerType)\">\n <SubjectSingle \n v-bind=\"attrs\" \n :order-index=\"index\" \n :title=\"item.title\" \n :type=\"item.answerType\"\n :exam-id=\"item.examId\"\n :isKey=\"item.isKey\" \n :is-save=\"!item.isRealCanDel\" \n :customId=\"item.customId\" \n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\" \n :analysis=\"item.analysis\" \n :least-answer-count=\"item.leastAnswerCount\"\n :is-edit=\"item.isEdit || false\" \n :show-action=\"!isPreview\" \n :exam-expand=\"item.examExpand\"\n :answerCheckType=\"item.answerCheckType\" \n :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\"\n @setRelation=\"setRelation\"\n @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\"\n @save=\"(item: any) => saveSubject(index, item)\"\n @edit=\"item.isEdit = true\"\n @add=\"(type: string, examAnswerRelationType: number) => addSubject(type, index, examAnswerRelationType)\" />\n </template>\n <SubjectScale v-bind=\"attrs\" v-else-if=\"item.answerType === 'scale'\" :order-index=\"index\" :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\" :is-set=\"item.hasSet || false\" :answer-list=\"item.answers\"\n :analysis=\"item.analysis\" :is-edit=\"item.isEdit || false\" :scale-question-list=\"item.scaleQuestionList\"\n :show-action=\"!isPreview\" :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectBlankFill v-bind=\"attrs\" v-else-if=\"item.answerType === 'blank_fill'\" :order-index=\"index\"\n :title=\"item.title\" :is-save=\"!item.isRealCanDel\" :is-set=\"item.hasSet || false\" :answer-list=\"item.answers\"\n :analysis=\"item.analysis\" :show-action=\"!isPreview\" :is-edit=\"item.isEdit || false\"\n :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\" :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectTextFill v-bind=\"attrs\" v-else-if=\"item.answerType === 'text_fill'\" :order-index=\"index\"\n :title=\"item.title\" :is-save=\"!item.isRealCanDel\" :is-set=\"item.hasSet || false\" :answer-list=\"item.answers\"\n :analysis=\"item.analysis\" :show-action=\"!isPreview\" :is-edit=\"item.isEdit || false\"\n :exam-expand=\"item.examExpand\" :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" :exam-rich-text-content=\"item.examRichTextContent\"\n @move=\"(type: 'up' | 'down') => move(index, type)\" @delete=\"deleteSubject(index)\"\n @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectRichText v-bind=\"attrs\" v-else-if=\"item.answerType === 'rich_text'\" :order-index=\"index\"\n :richTextContent=\"item.richTextContent\" :is-set=\"item.hasSet || false\" :is-save=\"!item.isRealCanDel\"\n :is-edit=\"item.isEdit || false\" :show-action=\"!isPreview\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" :examAnswerRelationType=\"item.examAnswerRelationType\"\n @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectPageEnd v-else-if=\"item.answerType === 'page_end'\" :total-page=\"totalPageIndex()\" :key=\"index\"\n :current-page-index=\"currentPageIndex(item.customId)\" :item=\"item\" :order-index=\"index\"\n :is-edit=\"item.isEdit || false\" :is-set=\"item.hasSet || false\" :is-save=\"!item.isRealCanDel\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n </div>\n </div>\n </div>\n</template>\n"],"names":["props","__props","currentList","ref","emits","__emit","attrs","useAttrs","currentPageIndex","currentId","value","filter","v","answerType","findIndex","c","customId","addPageEnd","push","setGuid","analysis","scaleQuestionList","isSave","isEdit","isRealCanDel","hasSet","examAnswerRelationType","addSubject","type","index","newSubject","splice","move","item","length","saveSubject","deleteSubject","ElMessage","success","setRelation","examAnswers","__expose","uploadExcel","list","concat","addExam","answerList","answers","map","title","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","pageIndex","setAnswerRelation","answerRelations","customAnswerId","targetItem","find","targetAnswer","watch","subjectList","newList","immediate","ns","useNamespace"],"mappings":"w5BAcA,MAAMA,EAAQC,EAIRC,EAAcC,EAAI,IAClBC,EAAQC,EAERC,EAAQC,IAcd,SAASC,EAAiBC,GAGxB,OAFwBP,EAAYQ,MAAMC,QAAQC,GAA4B,aAAjBA,EAAEC,aAC1BC,WAAWC,GAAWA,EAAEC,WAAaP,IACpD,CAAA,CAGxB,SAASQ,IACPf,EAAYQ,MAAMQ,KAAK,CACrBF,SAAUG,IACVN,WAAY,WACZO,SAAU,GACVC,kBAAmB,GACnBC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRC,uBAAwB,GACzB,CAGH,SAASC,EAAWC,EAAcC,EAAuB,KAAMH,EAAwC,MACrG,MAAMI,EAAa,CACjBd,SAAUG,IACVN,WAAYe,EACZR,SAAU,GACVC,kBAAmB,GACnBC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRC,0BAGY,OAAVG,EACF3B,EAAYQ,MAAMqB,OAAOF,EAAQ,EAAG,EAAGC,GAE3B5B,EAAAQ,MAAMQ,KAAKY,EACzB,CAmCO,SAAAE,EAAKH,EAAeD,GACvB,GAAS,OAATA,GAAiBC,EAAQ,EAAG,CAC9B,MAAOI,GAAQ/B,EAAYQ,MAAMqB,OAAOF,EAAO,GAC/C3B,EAAYQ,MAAMqB,OAAOF,EAAQ,EAAG,EAAGI,EAAI,SACzB,SAATL,GAAmBC,EAAQ3B,EAAYQ,MAAMwB,OAAS,EAAG,CAClE,MAAOD,GAAQ/B,EAAYQ,MAAMqB,OAAOF,EAAO,GAC/C3B,EAAYQ,MAAMqB,OAAOF,EAAQ,EAAG,EAAGI,EAAI,CAC7C,CAGO,SAAAE,EAAYN,EAAeI,GACtB/B,EAAAQ,MAAMmB,GAAS,IACtB3B,EAAYQ,MAAMmB,MAClBI,EACHV,QAAQ,EACRG,uBAAwBO,EAAKP,uBAC/B,CAGF,SAASU,EAAcP,GACT3B,EAAAQ,MAAMqB,OAAOF,EAAO,GAChCQ,EAAUC,QAAQ,OAAM,CAGjB,SAAAC,EAAYvB,EAAkBwB,GAC/BpC,EAAA,cAAeY,EAAUwB,EAAW,CA7G/BC,EAAA,CACXd,aACAzB,cACAwC,YA6EF,SAAqBC,GACnBzC,EAAYQ,MAAQR,EAAYQ,MAAMkC,OAAOD,EAAI,EA7EjDE,QAgDF,SAAiBZ,GACf,MAAMa,EAAab,EAAKc,SAASC,KAAKpC,IAAY,IAC7CA,EACHqC,MAAOrC,EAAEsC,OACTC,SAAUvC,EAAEwC,aACZC,UAAWzC,EAAEyC,eACR,GAEPnD,EAAYQ,MAAMQ,KAAK,IAClBe,EACHjB,SAAUG,IACVN,WAAYoB,EAAKqB,gBAAkB,YAAcrB,EAAKsB,aACtDR,QAASD,EACTxB,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,QAAQ,IAGNQ,EAAKuB,UAAYhD,EAAiByB,EAAKjB,WAAc,GAC5CC,IAGTT,EAAiByB,EAAKjB,UAAY,GACzBC,GACb,EAxEAwC,kBA2GO,SAAkBC,EAAsB1C,EAAkB2C,GACjE,GAAID,EAAgBxB,OAAQ,CACpB,MAAA0B,EAAa1D,EAAYQ,MAAMmD,MAAMjD,GAAWA,EAAEI,WAAaA,IACrE,GAAI4C,EAAY,CACR,MAAAE,EAAeF,EAAWb,SAASc,MAAM9C,GAAWA,EAAE4C,iBAAmBA,IAC3EG,IACFA,EAAaJ,gBAAkBA,EACjC,CACF,CACF,IAGFK,GAAM,IAAM/D,EAAMgE,cAAcC,IAC1BA,IACU/D,EAAAQ,MAAQ,IAAIuD,GAAO,GAEhC,CAAEC,WAAW,IAEV,MAAAC,EAAKC,EAAa,2sHAzHflE,EAAYQ,MAAMC,QAAQC,GAA4B,aAAjBA,EAAEC,aAA2BqB"}
|
1
|
+
{"version":3,"file":"subject-list.vue.mjs","sources":["../../../../../../packages/components/src/subject-list/src/subject-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport SubjectBlankFill from './components/subject-blank-fill.vue'\nimport SubjectScale from './components/subject-scale.vue'\nimport SubjectSingle from './components/subject-single.vue'\nimport SubjectTextFill from './components/subject-text-fill.vue'\nimport SubjectRichText from './components/SubjectRichText.vue'\nimport SubjectPageEnd from './components/SubjectPageEnd.vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectList',\n})\n\nconst props = defineProps<{\n subjectList: any[]\n isPreview: boolean\n}>()\nconst currentList = ref([] as any)\nconst emits = defineEmits(['setRelation'])\n\nconst attrs = useAttrs()\n\ndefineExpose({\n addSubject,\n currentList,\n uploadExcel,\n addExam,\n setAnswerRelation,\n})\n\nfunction totalPageIndex() {\n return currentList.value.filter((v: any) => v.answerType === 'page_end').length\n}\nconst currentPageIndex = computed(() => {\n const currentPageList = currentList.value.filter((v: any) => v.answerType === 'page_end')\n return (currentId: string) => {\n const currentIndex = currentPageList.findIndex((c: any) => c.customId === currentId)\n return currentIndex !== -1 ? currentIndex + 1 : 0\n }\n})\nfunction addPageEnd() {\n currentList.value.push({\n customId: setGuid(),\n answerType: 'page_end',\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: 0,\n })\n}\n\nfunction addSubject(type: string, index: number | null = null, examAnswerRelationType: number | null = null) {\n const newSubject = {\n customId: setGuid(),\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType,\n }\n\n if (index !== null) {\n currentList.value.splice(index + 1, 0, newSubject)\n } else {\n currentList.value.push(newSubject)\n }\n}\n\nfunction addExam(item: any) {\n let currentPageIndex = 1\n const answerList = item.answers?.map((v: any) => ({\n ...v,\n title: v.answer,\n answerId: v.examAnswerId,\n isCorrect: v.isCorrect,\n })) || []\n\n // 创建新的题目对象\n const newItem = {\n ...item,\n customId: setGuid(),\n answerType: item.richTextContent ? 'rich_text' : item.examTypeEnum,\n answers: answerList,\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n }\n\n // 将新题目添加到 currentList\n currentList.value.push(newItem)\n\n\n // 判断是否需要添加 page_end \n if (item.pageIndex - currentPageIndex === 1) {\n addPageEnd()\n currentPageIndex++\n }\n\n if (currentPageIndex > 1) {\n addPageEnd()\n }\n}\n\nfunction uploadExcel(list: any[]) {\n currentList.value = currentList.value.concat(list)\n}\n\nfunction move(index: number, type: 'up' | 'down') {\n if (type === 'up' && index > 0) {\n const [item] = currentList.value.splice(index, 1)\n currentList.value.splice(index - 1, 0, item)\n } else if (type === 'down' && index < currentList.value.length - 1) {\n const [item] = currentList.value.splice(index, 1)\n currentList.value.splice(index + 1, 0, item)\n }\n}\n\nfunction saveSubject(index: number, item: any) {\n currentList.value[index] = {\n ...currentList.value[index],\n ...item,\n isEdit: false,\n examAnswerRelationType: item.examAnswerRelationType,\n }\n}\n\nfunction deleteSubject(index: number) {\n currentList.value.splice(index, 1)\n ElMessage.success('删除成功')\n}\n\nfunction setRelation(customId: number, examAnswers: any) {\n emits('setRelation', customId, examAnswers)\n}\n\nfunction setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const targetItem = currentList.value.find((v: any) => v.customId === customId)\n if (targetItem) {\n const targetAnswer = targetItem.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (targetAnswer) {\n targetAnswer.answerRelations = answerRelations\n }\n }\n}\n\nwatch(() => props.subjectList, (newList: any) => {\n if (newList) {\n currentList.value = [...newList]\n }\n}, { immediate: true })\n\nconst ns = useNamespace('subject-list')\n</script>\n\n<template>\n <div :class=\"ns.e('list-exam')\">\n <div class=\"subject-list-wrapper\">\n <div v-for=\"(item, index) in currentList\" :key=\"item.customId\" class=\"subject-item\">\n <template v-if=\"['single', 'multiple', 'sort'].includes(item.answerType)\">\n <SubjectSingle \n v-bind=\"attrs\" \n :order-index=\"index\" \n :title=\"item.title\" \n :type=\"item.answerType\"\n :exam-id=\"item.examId\"\n :isKey=\"item.isKey\" \n :is-save=\"!item.isRealCanDel\" \n :customId=\"item.customId\" \n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\" \n :analysis=\"item.analysis\" \n :least-answer-count=\"item.leastAnswerCount\"\n :is-edit=\"item.isEdit || false\" \n :show-action=\"!isPreview\" \n :exam-expand=\"item.examExpand\"\n :answerCheckType=\"item.answerCheckType\" \n :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\"\n @setRelation=\"setRelation\"\n @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\"\n @save=\"(item: any) => saveSubject(index, item)\"\n @edit=\"item.isEdit = true\"\n @add=\"(type: string, examAnswerRelationType: number) => addSubject(type, index, examAnswerRelationType)\" />\n </template>\n <SubjectScale v-bind=\"attrs\" v-else-if=\"item.answerType === 'scale'\" :order-index=\"index\" :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\" :is-set=\"item.hasSet || false\" :answer-list=\"item.answers\"\n :analysis=\"item.analysis\" :is-edit=\"item.isEdit || false\" :scale-question-list=\"item.scaleQuestionList\"\n :show-action=\"!isPreview\" :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectBlankFill v-bind=\"attrs\" v-else-if=\"item.answerType === 'blank_fill'\" :order-index=\"index\"\n :title=\"item.title\" :is-save=\"!item.isRealCanDel\" :is-set=\"item.hasSet || false\" :answer-list=\"item.answers\"\n :analysis=\"item.analysis\" :show-action=\"!isPreview\" :is-edit=\"item.isEdit || false\"\n :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\" :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectTextFill v-bind=\"attrs\" v-else-if=\"item.answerType === 'text_fill'\" :order-index=\"index\"\n :title=\"item.title\" :is-save=\"!item.isRealCanDel\" :is-set=\"item.hasSet || false\" :answer-list=\"item.answers\"\n :analysis=\"item.analysis\" :show-action=\"!isPreview\" :is-edit=\"item.isEdit || false\"\n :exam-expand=\"item.examExpand\" :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" :exam-rich-text-content=\"item.examRichTextContent\"\n @move=\"(type: 'up' | 'down') => move(index, type)\" @delete=\"deleteSubject(index)\"\n @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectRichText v-bind=\"attrs\" v-else-if=\"item.answerType === 'rich_text'\" :order-index=\"index\"\n :richTextContent=\"item.richTextContent\" :is-set=\"item.hasSet || false\" :is-save=\"!item.isRealCanDel\"\n :is-edit=\"item.isEdit || false\" :show-action=\"!isPreview\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" :examAnswerRelationType=\"item.examAnswerRelationType\"\n @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n <SubjectPageEnd v-else-if=\"item.answerType === 'page_end'\" :total-page=\"totalPageIndex()\" :key=\"index\"\n :current-page-index=\"currentPageIndex(item.customId)\" :item=\"item\" :order-index=\"index\"\n :is-edit=\"item.isEdit || false\" :is-set=\"item.hasSet || false\" :is-save=\"!item.isRealCanDel\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\" @save=\"(item: any) => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\" />\n </div>\n </div>\n </div>\n</template>\n"],"names":["props","__props","currentList","ref","emits","__emit","attrs","useAttrs","__expose","addSubject","uploadExcel","list","value","concat","addExam","item","currentPageIndex","answerList","answers","map","v","title","answer","answerId","examAnswerId","isCorrect","newItem","customId","setGuid","answerType","richTextContent","examTypeEnum","isSave","isEdit","isRealCanDel","hasSet","push","pageIndex","addPageEnd","setAnswerRelation","answerRelations","customAnswerId","targetItem","find","targetAnswer","c","computed","currentPageList","filter","currentId","currentIndex","findIndex","analysis","scaleQuestionList","examAnswerRelationType","type","index","newSubject","splice","move","length","saveSubject","deleteSubject","ElMessage","success","setRelation","examAnswers","watch","subjectList","newList","immediate","ns","useNamespace"],"mappings":"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"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{defineComponent as e,computed as i,ref as t,onMounted as n,createElementBlock as o,openBlock as
|
1
|
+
import{defineComponent as e,computed as i,ref as t,onMounted as n,createElementBlock as o,openBlock as a,normalizeClass as r,unref as l,createCommentVNode as s,withDirectives as m,createElementVNode as u,isRef as p,vModelText as c}from"vue";import{useNamespace as d}from"@qxs-bns/hooks";import{merge as g}from"lodash-es";import y from"tinymce/tinymce";import"tinymce/themes/silver/theme";import"tinymce/icons/default/icons";import"tinymce/models/dom";import"tinymce/plugins/autolink";import"tinymce/plugins/autoresize";import"tinymce/plugins/fullscreen";import"tinymce/plugins/image";import"tinymce/plugins/insertdatetime";import"tinymce/plugins/link";import"tinymce/plugins/lists";import"tinymce/plugins/media";import"tinymce/plugins/preview";import"tinymce/plugins/table";import"tinymce/plugins/wordcount";import"tinymce/plugins/code";import"tinymce/plugins/searchreplace";import"tinymce/plugins/nonbreaking";const f=["id","name"];var h=e({name:"QxsTinyMceEditor",__name:"tiny-mce-editor",props:{modelValue:{type:String,required:!0,default:""},config:{type:Object,required:!1,default:()=>({})},assetsBasePath:{type:String,required:!1,default:""}},emits:["update:modelValue"],setup(e,{emit:h}){const b=h,k=d("file-upload"),_=i({get:()=>e.modelValue,set(e){b("update:modelValue",e)}}),v=t(`tiny-mce-textarea-${Date.now()}-${Math.random().toString(36).substr(2,9)}`),x=e.assetsBasePath||"node_modules/",w={selector:`textarea#${v.value}`,promotion:!1,license_key:"gpl",elementpath:!1,language:"zh-Hans",language_url:`${x}tinymce/langs/zh-Hans.js`,skin_url:`${x}tinymce/skins/ui/oxide`,content_css:`${x}tinymce/skins/content/default/content.min.css`,min_height:250,max_height:600,plugins:"autolink autoresize fullscreen image insertdatetime link lists media preview table wordcount code searchreplace nonbreaking",toolbar:"undo redo | bold italic underline strikethrough | blocks | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | forecolor backcolor removeformat | link image media table insertdatetime searchreplace | preview code",branding:!1,autoresize:!0,menubar:!1,nonbreaking_force_tab:!0,toolbar_mode:"sliding",insertdatetime_formats:["%Y年%m月%d日","%H点%M分%S秒","%Y-%m-%d","%H:%M:%S"],setup:i=>{i.on("input change undo redo",(()=>{_.value=i.getContent()})),i.on("init",(()=>{i.setContent(_.value)})),e.config?.expandSetup?.(i)}},S=i((()=>{const i=w;return e.config.images_upload_handler||("string"==typeof i.plugins?i.plugins=i.plugins.replace("image",""):Array.isArray(i.plugins)&&(i.plugins=i.plugins.filter((e=>"image"!==e)))),g(i,e.config)}));return n((async()=>{"undefined"!=typeof window&&y.init(S.value)})),(e,i)=>(a(),o("div",{class:r(l(k).e("tiny-mce"))},[s(" 使用动态生成的 id "),m(u("textarea",{id:l(v),"onUpdate:modelValue":i[0]||(i[0]=e=>p(_)?_.value=e:null),name:l(v)},null,8,f),[[c,l(_)]])],2))}});export{h as default};
|
2
2
|
//# sourceMappingURL=tiny-mce-editor.vue.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tiny-mce-editor.vue.mjs","sources":["../../../../../../packages/components/src/tiny-mce-editor/src/tiny-mce-editor.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Editor, RawEditorOptions } from \"tinymce/tinymce\";\nimport { useNamespace } from \"@qxs-bns/hooks\";\nimport { merge } from \"lodash-es\";\nimport tinymce from \"tinymce/tinymce\";\n\n// 导入核心功能\nimport \"tinymce/themes/silver/theme\";\nimport \"tinymce/icons/default/icons\";\nimport \"tinymce/models/dom\";\n\nimport \"tinymce/plugins/autolink\";\nimport \"tinymce/plugins/autoresize\";\nimport \"tinymce/plugins/fullscreen\";\nimport \"tinymce/plugins/image\";\nimport \"tinymce/plugins/insertdatetime\";\nimport \"tinymce/plugins/link\";\nimport \"tinymce/plugins/lists\";\nimport \"tinymce/plugins/media\";\nimport \"tinymce/plugins/preview\";\nimport \"tinymce/plugins/table\";\nimport \"tinymce/plugins/wordcount\";\nimport \"tinymce/plugins/code\";\nimport \"tinymce/plugins/searchreplace\";\nimport \"tinymce/plugins/nonbreaking\";\n\ndefineOptions({\n name: \"QxsTinyMceEditor\",\n});\n\nconst {\n modelValue = \"\",\n config = {},\n assetsBasePath = \"\",\n} = defineProps<{\n modelValue: string;\n config?: RawEditorOptions & {\n expandSetup?: RawEditorOptions[\"setup\"];\n };\n assetsBasePath?: string;\n}>();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst ns = useNamespace(\"file-upload\");\n\nconst colorScheme = \"light\";\n\nconst content = computed({\n get() {\n return modelValue;\n },\n set(val) {\n emit(\"update:modelValue\", val);\n },\n});\n\n// 生成唯一的 id\nconst uniqueId = ref(\n `tiny-mce-textarea-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`\n);\n\nconst basePath
|
1
|
+
{"version":3,"file":"tiny-mce-editor.vue.mjs","sources":["../../../../../../packages/components/src/tiny-mce-editor/src/tiny-mce-editor.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Editor, RawEditorOptions } from \"tinymce/tinymce\";\nimport { useNamespace } from \"@qxs-bns/hooks\";\nimport { merge } from \"lodash-es\";\nimport tinymce from \"tinymce/tinymce\";\n\n// 导入核心功能\nimport \"tinymce/themes/silver/theme\";\nimport \"tinymce/icons/default/icons\";\nimport \"tinymce/models/dom\";\n\nimport \"tinymce/plugins/autolink\";\nimport \"tinymce/plugins/autoresize\";\nimport \"tinymce/plugins/fullscreen\";\nimport \"tinymce/plugins/image\";\nimport \"tinymce/plugins/insertdatetime\";\nimport \"tinymce/plugins/link\";\nimport \"tinymce/plugins/lists\";\nimport \"tinymce/plugins/media\";\nimport \"tinymce/plugins/preview\";\nimport \"tinymce/plugins/table\";\nimport \"tinymce/plugins/wordcount\";\nimport \"tinymce/plugins/code\";\nimport \"tinymce/plugins/searchreplace\";\nimport \"tinymce/plugins/nonbreaking\";\n// 导入语言包\n\ndefineOptions({\n name: \"QxsTinyMceEditor\",\n});\n\nconst {\n modelValue = \"\",\n config = {},\n assetsBasePath = \"\",\n} = defineProps<{\n modelValue: string;\n config?: RawEditorOptions & {\n expandSetup?: RawEditorOptions[\"setup\"];\n };\n assetsBasePath?: string;\n}>();\n\nconst emit = defineEmits([\"update:modelValue\"]);\n\nconst ns = useNamespace(\"file-upload\");\n\nconst colorScheme = \"light\";\n\nconst content = computed({\n get() {\n return modelValue;\n },\n set(val) {\n emit(\"update:modelValue\", val);\n },\n});\n\n// 生成唯一的 id\nconst uniqueId = ref(\n `tiny-mce-textarea-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`\n);\n\nconst basePath = assetsBasePath || \"node_modules/\";\nconst defaultSetting: RawEditorOptions = {\n // 使用动态生成的 id\n selector: `textarea#${uniqueId.value}`,\n promotion: false, // 禁用推广信息\n license_key: \"gpl\",\n elementpath: false,\n language: \"zh-Hans\",\n\n language_url: `${basePath}tinymce/langs/zh-Hans.js`,\n skin_url: `${basePath}${\n colorScheme === \"light\" ? \"tinymce/skins/ui/oxide\" : \"tinymce/skins/ui/oxide-dark\"\n }`,\n content_css: `${basePath}${\n colorScheme === \"light\"\n ? \"tinymce/skins/content/default/content.min.css\"\n : \"tinymce/skins/content/dark/content.min.css\"\n }`,\n min_height: 250,\n max_height: 600,\n plugins:\n \"autolink autoresize fullscreen image insertdatetime link lists media preview table wordcount code searchreplace nonbreaking\",\n toolbar:\n \"undo redo | bold italic underline strikethrough | blocks | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | forecolor backcolor removeformat | link image media table insertdatetime searchreplace | preview code\",\n branding: false,\n autoresize: true,\n menubar: false,\n nonbreaking_force_tab: true,\n toolbar_mode: \"sliding\",\n insertdatetime_formats: [\n \"%Y年%m月%d日\",\n \"%H点%M分%S秒\",\n \"%Y-%m-%d\",\n \"%H:%M:%S\",\n ],\n // https://www.tiny.cloud/docs/tinymce/6/file-image-upload/#images_upload_handler\n // images_upload_handler: async (blobInfo: any, progress: any) => {\n // // blobInfo, succFun, failFun, progress\n // const files = blobInfo.blob()\n // const formData = new FormData()\n // formData.append('image', files)\n\n // const { res, error } = await useApi({\n // // ...commonUrls.uploadImage,\n // params: {\n // bucketType: classify,\n // },\n // data: formData,\n // onUploadProgress: (e: any) => {\n // progress((e.loaded / e.total) * 100)\n // },\n // })\n // if (res) {\n // const { normal } = res\n // console.log('normal: ', res)\n // return normal\n // }\n // if (error) {\n // console.log(error.message)\n // return Promise.reject(error.message)\n // }\n // },\n setup: (editor: Editor) => {\n // 监听编辑器内容变化\n editor.on(\"input change undo redo\", () => {\n content.value = editor.getContent();\n });\n\n // 编辑器初始化完成后设置内容\n editor.on(\"init\", () => {\n editor.setContent(content.value);\n });\n\n config?.expandSetup?.(editor);\n },\n};\n\nconst initSetting = computed(() => {\n const dealDefaultSetting = defaultSetting;\n if (!config.images_upload_handler) {\n // 删除 image 图片 plugin\n if (typeof dealDefaultSetting.plugins === \"string\") {\n dealDefaultSetting.plugins = dealDefaultSetting.plugins.replace(\n \"image\",\n \"\"\n );\n } else if (Array.isArray(dealDefaultSetting.plugins)) {\n dealDefaultSetting.plugins = dealDefaultSetting.plugins.filter(\n (plugin) => plugin !== \"image\"\n );\n }\n }\n return merge(dealDefaultSetting, config);\n});\n\nonMounted(async () => {\n if (typeof window !== \"undefined\") {\n tinymce.init(initSetting.value);\n }\n});\n</script>\n\n<template>\n <div :class=\"ns.e('tiny-mce')\">\n <!-- 使用动态生成的 id -->\n <textarea :id=\"uniqueId\" v-model=\"content\" :name=\"uniqueId\" />\n </div>\n</template>\n"],"names":["emit","__emit","ns","useNamespace","content","computed","get","__props","modelValue","set","val","uniqueId","ref","Date","now","Math","random","toString","substr","basePath","assetsBasePath","defaultSetting","selector","value","promotion","license_key","elementpath","language","language_url","skin_url","content_css","min_height","max_height","plugins","toolbar","branding","autoresize","menubar","nonbreaking_force_tab","toolbar_mode","insertdatetime_formats","setup","editor","on","getContent","setContent","config","expandSetup","initSetting","dealDefaultSetting","images_upload_handler","replace","Array","isArray","filter","plugin","merge","onMounted","async","window","tinymce","init"],"mappings":"2qCA2CA,MAAMA,EAAOC,EAEPC,EAAKC,EAAa,eAIlBC,EAAUC,EAAS,CACvBC,IAAM,IACGC,EAAUC,WAEnB,GAAAC,CAAIC,GACFV,EAAK,oBAAqBU,EAAG,IAK3BC,EAAWC,EACf,qBAAqBC,KAAKC,SAASC,KAAKC,SAASC,SAAS,IAAIC,OAAO,EAAG,MAGpEC,EAAWZ,EAAAa,gBAAkB,gBAC7BC,EAAmC,CAEvCC,SAAU,YAAYX,EAASY,QAC/BC,WAAW,EACXC,YAAa,MACbC,aAAa,EACbC,SAAU,UAEVC,aAAc,GAAGT,4BACjBU,SAAU,GAAGV,0BAGbW,YAAa,GAAGX,iDAKhBY,WAAY,IACZC,WAAY,IACZC,QACE,8HACFC,QACE,oPACFC,UAAU,EACVC,YAAY,EACZC,SAAS,EACTC,uBAAuB,EACvBC,aAAc,UACdC,uBAAwB,CACtB,YACA,YACA,WACA,YA6BFC,MAAQC,IAECA,EAAAC,GAAG,0BAA0B,KAC1BvC,EAAAmB,MAAQmB,EAAOE,YAAW,IAI7BF,EAAAC,GAAG,QAAQ,KACTD,EAAAG,WAAWzC,EAAQmB,MAAK,IAG3BhB,EAAAuC,QAAEC,cAAcL,EAAM,GAI1BM,EAAc3C,GAAS,KAC3B,MAAM4C,EAAqB5B,EAcpB,OAbFd,EAAMuC,OAACI,wBAEgC,iBAA/BD,EAAmBhB,QACTgB,EAAAhB,QAAUgB,EAAmBhB,QAAQkB,QACtD,QACA,IAEOC,MAAMC,QAAQJ,EAAmBhB,WACvBgB,EAAAhB,QAAUgB,EAAmBhB,QAAQqB,QACrDC,GAAsB,UAAXA,MAIXC,EAAMP,EAAoB1C,SAAM,WAGzCkD,GAAUC,UACc,oBAAXC,QACDC,EAAAC,KAAKb,EAAYzB,MAAK"}
|
package/lib/package.json.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";exports.version="0.0.
|
1
|
+
"use strict";exports.version="0.0.38";
|
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"),a=require("@qxs-bns/hooks"),n=require("element-plus"),r=require("../../../subject-action/src/subject-action.vue.cjs"),s=require("../../../subject-layout/src/subject-layout.vue.cjs"),o=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.cjs");const i={class:"preview"},d={class:"title"},c={key:0},u=["innerHTML"],m={class:"answer-radio flex flex-col"},f={style:{flex:"1"}},p={class:"answer flex"},v={class:"flex"},x={class:"answer-list flex-col"},V={class:"order"},y={class:"flex",style:{"margin-bottom":"20px"}},h={style:{flex:"1"}},N={key:0,class:"margin-bottom flex"},w={style:{flex:"1"}},E={class:"flex flex-justify-end"};var k=l.defineComponent({name:"QxsSubjectScale",__name:"subject-scale",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},answerList:{type:null,required:!1},analysis:{type:String,required:!1},rowTitle:{type:String,required:!1},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},scaleQuestionList:{type:null,required:!1},examRichTextContent:{type:String,required:!1},examAnswerRelationType:{type:Number,required:!1}},emits:["move","save","delete","edit","add"],setup(k,{emit:C}){const g=k,B=C,b=l.useAttrs(),q=l.ref([{title:""},{title:""},{title:""},{title:""},{title:""}]),S=l.ref(""),j=l.ref(""),R=l.ref(""),L=l.ref(!1),T=l.ref(""),_=l.ref([]),M=l.computed((()=>Math.ceil(24/(q.value.length+1))));function A(){5!==q.value.length&&q.value.push({title:""})}function D(){L.value=!1,T.value=""}function U(){if(!S.value)return void n.ElMessage.error("题目标题不能为空!");let e="";q.value.forEach(((l,t)=>{l.title||(e+=`选项${String.fromCharCode(65+t)}未填写。`)})),e?n.ElMessage.error(e):R.value?(_.value=R.value.split("\n").filter((e=>e)),B("save",{title:S.value,answers:q.value,analysis:j.value,scaleQuestionList:_.value,examRichTextContent:L.value?T.value:""})):n.ElMessage.error("行标题不能为空!")}l.onMounted((function(){g.title&&(S.value=g.title),g.answerList&&g.answerList.length&&(q.value=g.answerList),g.analysis&&(j.value=g.analysis),g.scaleQuestionList&&(_.value=g.scaleQuestionList,R.value=_.value.join("\n")),g.examRichTextContent&&(T.value=g.examRichTextContent,L.value=!0)}));const O=a.useNamespace("subject-scale");return(a,n)=>{const k=e.ElCol,C=e.ElRow,Q=e.ElRadio,z=e.ElInput,F=e.ElIcon,I=e.ElLink;return l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(l.unref(O).e("scale-exam"))},[l.createVNode(s.default,{"show-edit":a.isEdit},{preview:l.withCtx((()=>[l.createElementVNode("div",i,[l.createElementVNode("div",null,[l.createElementVNode("span",d,l.toDisplayString(a.orderIndex+1)+"."+l.toDisplayString(l.unref(S))+"(量表题)",1),l.unref(L)?(l.openBlock(),l.createElementBlock("div",c,[l.createElementVNode("div",{innerHTML:l.unref(T)},null,8,u)])):l.createCommentVNode("v-if",!0)]),l.createElementVNode("div",m,[l.createVNode(C,{style:{padding:"10px 0"}},{default:l.withCtx((()=>[l.createVNode(k,{span:l.unref(M)},null,8,["span"]),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(q),(e=>(l.openBlock(),l.createBlock(k,{key:e.title,class:"flex flex-center",span:l.unref(M)},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e.title),1)])),_:2},1032,["span"])))),128))])),_:1}),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(_),(e=>(l.openBlock(),l.createBlock(C,{key:e,style:{padding:"10px 0"}},{default:l.withCtx((()=>[l.createVNode(k,{span:l.unref(M),class:"flex flex-center"},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e),1)])),_:2},1032,["span"]),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(q).length,(e=>(l.openBlock(),l.createBlock(k,{key:e,class:"radio-item flex flex-center",span:l.unref(M)},{default:l.withCtx((()=>[l.createVNode(Q,{disabled:!0})])),_:2},1032,["span"])))),128))])),_:2},1024)))),128))])])])),edit:l.withCtx((()=>[l.createElementVNode("div",{class:l.normalizeClass(["flex",[{"margin-bottom":l.unref(L)}]])},[n[10]||(n[10]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"题目:")],-1)),l.createElementVNode("div",f,[l.createVNode(z,{modelValue:l.unref(S),"onUpdate:modelValue":n[0]||(n[0]=e=>l.isRef(S)?S.value=e:null),type:"textarea",rows:2,placeholder:"【量表题】请输入问题",disabled:a.isSave},null,8,["modelValue","disabled"])])],2),l.createElementVNode("div",p,[n[11]||(n[11]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"行标题:")],-1)),l.createElementVNode("div",v,[l.createVNode(z,{modelValue:l.unref(R),"onUpdate:modelValue":n[1]||(n[1]=e=>l.isRef(R)?R.value=e:null),
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es"),l=require("vue"),t=require("@element-plus/icons-vue"),a=require("@qxs-bns/hooks"),n=require("element-plus"),r=require("../../../subject-action/src/subject-action.vue.cjs"),s=require("../../../subject-layout/src/subject-layout.vue.cjs"),o=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.cjs");const i={class:"preview"},d={class:"title"},c={key:0},u=["innerHTML"],m={class:"answer-radio flex flex-col"},f={style:{flex:"1"}},p={class:"answer flex"},v={class:"flex"},x={class:"answer-list flex-col"},V={class:"order"},y={class:"flex",style:{"margin-bottom":"20px"}},h={style:{flex:"1"}},N={key:0,class:"margin-bottom flex"},w={style:{flex:"1"}},E={class:"flex flex-justify-end"};var k=l.defineComponent({name:"QxsSubjectScale",__name:"subject-scale",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},answerList:{type:null,required:!1},analysis:{type:String,required:!1},rowTitle:{type:String,required:!1},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},scaleQuestionList:{type:null,required:!1},examRichTextContent:{type:String,required:!1},examAnswerRelationType:{type:Number,required:!1}},emits:["move","save","delete","edit","add"],setup(k,{emit:C}){const g=k,B=C,b=l.useAttrs(),q=l.ref([{title:""},{title:""},{title:""},{title:""},{title:""}]),S=l.ref(""),j=l.ref(""),R=l.ref(""),L=l.ref(!1),T=l.ref(""),_=l.ref([]),M=l.computed((()=>Math.ceil(24/(q.value.length+1))));function A(){5!==q.value.length&&q.value.push({title:""})}function D(){L.value=!1,T.value=""}function U(){if(!S.value)return void n.ElMessage.error("题目标题不能为空!");let e="";q.value.forEach(((l,t)=>{l.title||(e+=`选项${String.fromCharCode(65+t)}未填写。`)})),e?n.ElMessage.error(e):R.value?(_.value=R.value.split("\n").filter((e=>e)),B("save",{title:S.value,answers:q.value,analysis:j.value,scaleQuestionList:_.value,examRichTextContent:L.value?T.value:""})):n.ElMessage.error("行标题不能为空!")}l.onMounted((function(){g.title&&(S.value=g.title),g.answerList&&g.answerList.length&&(q.value=g.answerList),g.analysis&&(j.value=g.analysis),g.scaleQuestionList&&(_.value=g.scaleQuestionList,R.value=_.value.join("\n")),g.examRichTextContent&&(T.value=g.examRichTextContent,L.value=!0)}));const O=a.useNamespace("subject-scale");return(a,n)=>{const k=e.ElCol,C=e.ElRow,Q=e.ElRadio,z=e.ElInput,F=e.ElIcon,I=e.ElLink;return l.openBlock(),l.createElementBlock("div",{class:l.normalizeClass(l.unref(O).e("scale-exam"))},[l.createVNode(s.default,{"show-edit":a.isEdit},{preview:l.withCtx((()=>[l.createElementVNode("div",i,[l.createElementVNode("div",null,[l.createElementVNode("span",d,l.toDisplayString(a.orderIndex+1)+"."+l.toDisplayString(l.unref(S))+"(量表题)",1),l.unref(L)?(l.openBlock(),l.createElementBlock("div",c,[l.createElementVNode("div",{innerHTML:l.unref(T)},null,8,u)])):l.createCommentVNode("v-if",!0)]),l.createElementVNode("div",m,[l.createVNode(C,{style:{padding:"10px 0"}},{default:l.withCtx((()=>[l.createVNode(k,{span:l.unref(M)},null,8,["span"]),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(q),(e=>(l.openBlock(),l.createBlock(k,{key:e.title,class:"flex flex-center",span:l.unref(M)},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e.title),1)])),_:2},1032,["span"])))),128))])),_:1}),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(_),(e=>(l.openBlock(),l.createBlock(C,{key:e,style:{padding:"10px 0"}},{default:l.withCtx((()=>[l.createVNode(k,{span:l.unref(M),class:"flex flex-center"},{default:l.withCtx((()=>[l.createElementVNode("span",null,l.toDisplayString(e),1)])),_:2},1032,["span"]),(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(q).length,(e=>(l.openBlock(),l.createBlock(k,{key:e,class:"radio-item flex flex-center",span:l.unref(M)},{default:l.withCtx((()=>[l.createVNode(Q,{disabled:!0})])),_:2},1032,["span"])))),128))])),_:2},1024)))),128))])])])),edit:l.withCtx((()=>[l.createElementVNode("div",{class:l.normalizeClass(["flex",[{"margin-bottom":l.unref(L)}]])},[n[10]||(n[10]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"题目:")],-1)),l.createElementVNode("div",f,[l.createVNode(z,{modelValue:l.unref(S),"onUpdate:modelValue":n[0]||(n[0]=e=>l.isRef(S)?S.value=e:null),type:"textarea",rows:2,placeholder:"【量表题】请输入问题",disabled:a.isSave},null,8,["modelValue","disabled"])])],2),l.createElementVNode("div",p,[n[11]||(n[11]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"行标题:")],-1)),l.createElementVNode("div",v,[l.createVNode(z,{modelValue:l.unref(R),"onUpdate:modelValue":n[1]||(n[1]=e=>l.isRef(R)?R.value=e:null),type:"textarea",placeholder:"请输入行标题",style:{width:"160px"},rows:10},null,8,["modelValue"]),l.createElementVNode("div",x,[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(q),((e,n)=>(l.openBlock(),l.createElementBlock("div",{key:n,class:"answer-item flex flex-items-center"},[l.createElementVNode("span",V,l.toDisplayString(String.fromCharCode(65+n))+".",1),l.createVNode(z,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:10,placeholder:`选项${String.fromCharCode(65+n)}`,disabled:a.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),l.createCommentVNode(' <PlusCircleOutlined\n class="icon"\n :class="[{ disabled: answers.length === 5 }]"\n @click="addAnswer"\n />\n <MinusCircleOutlined\n class="icon"\n :class="[{ disabled: answers.length < 3 }]"\n @click="deleteAnswer(index)"\n /> '),l.createVNode(F,{class:"icon"},{default:l.withCtx((()=>[l.createVNode(l.unref(t.CirclePlus),{class:l.normalizeClass([{disabled:5===l.unref(q).length}]),onClick:A},null,8,["class"])])),_:1}),l.createVNode(F,{class:"icon"},{default:l.withCtx((()=>[l.createVNode(l.unref(t.Remove),{class:l.normalizeClass([{disabled:l.unref(q).length<3}]),onClick:e=>function(e){q.value.length<3||q.value.splice(e,1)}(n)},null,8,["class","onClick"])])),_:2},1024)])))),128))])])]),l.createElementVNode("div",y,[n[12]||(n[12]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"解析:")],-1)),l.createElementVNode("div",h,[l.createVNode(z,{modelValue:l.unref(j),"onUpdate:modelValue":n[2]||(n[2]=e=>l.isRef(j)?j.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])]),l.unref(L)?(l.openBlock(),l.createElementBlock("div",N,[n[14]||(n[14]=l.createElementVNode("div",{class:"label flex flex-justify-center"},[l.createElementVNode("span",null,"富文本:")],-1)),l.createElementVNode("div",w,[l.createVNode(o.default,l.mergeProps({"model-value":l.unref(T),"onUpdate:modelValue":n[3]||(n[3]=e=>l.isRef(T)?T.value=e:null)},l.unref(b),{style:{width:"100%"}}),null,16,["model-value"]),l.createElementVNode("div",E,[l.createVNode(I,{type:"danger",onClick:D},{default:l.withCtx((()=>n[13]||(n[13]=[l.createTextVNode(" 删除富文本 ")]))),_:1})])])])):l.createCommentVNode("v-if",!0)])),default:l.withCtx((()=>[a.showAction?(l.openBlock(),l.createBlock(r.default,{key:0,"is-edit":a.isEdit,"is-set":a.isSet,showOtherOption:!1,examAnswerRelationType:g.examAnswerRelationType,onMoveUp:n[4]||(n[4]=e=>B("move","up")),onMoveDown:n[5]||(n[5]=e=>B("move","down")),onDelete:n[6]||(n[6]=e=>B("delete")),onSave:U,onEdit:n[7]||(n[7]=e=>B("edit")),onAdd:n[8]||(n[8]=e=>B("add",e)),onOnShowRichText:n[9]||(n[9]=e=>L.value=!0)},null,8,["is-edit","is-set","examAnswerRelationType"])):l.createCommentVNode("v-if",!0)])),_:1},8,["show-edit"])],2)}}});exports.default=k;
|
2
2
|
//# sourceMappingURL=subject-scale.vue.cjs.map
|