@qxs-bns/components 0.0.24 → 0.0.26
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.js +1 -1
- package/es/src/subject-action/src/subject-action.vue.js +1 -1
- package/es/src/subject-action/src/subject-action.vue.js.map +1 -1
- package/es/src/subject-list/src/components/subject-scale.vue.js +1 -1
- package/es/src/subject-list/src/components/subject-scale.vue.js.map +1 -1
- package/es/src/subject-list/src/components/subject-single.vue.js +1 -1
- package/es/src/subject-list/src/components/subject-single.vue.js.map +1 -1
- package/es/src/subject-list/src/subject-list.vue.js +1 -1
- package/es/src/subject-list/src/subject-list.vue.js.map +1 -1
- package/lib/package.json.js +1 -1
- package/lib/src/subject-action/src/subject-action.vue.js +1 -1
- package/lib/src/subject-action/src/subject-action.vue.js.map +1 -1
- package/lib/src/subject-list/src/components/subject-scale.vue.js +1 -1
- package/lib/src/subject-list/src/components/subject-scale.vue.js.map +1 -1
- package/lib/src/subject-list/src/components/subject-single.vue.js +1 -1
- package/lib/src/subject-list/src/components/subject-single.vue.js.map +1 -1
- package/lib/src/subject-list/src/subject-list.vue.js +1 -1
- package/lib/src/subject-list/src/subject-list.vue.js.map +1 -1
- package/package.json +1 -1
- package/types/tsconfig.tsbuildinfo +1 -1
@@ -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.js"),s=require("../../../subject-layout/src/subject-layout.vue.js"),o=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.js");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.
|
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.js"),s=require("../../../subject-layout/src/subject-layout.vue.js"),o=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.js");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),modelModifiers:{trim:!0},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.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-scale.vue.js","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)))\nconst isKey = ref(false)\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 => 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":"81CAWA,MAAMA,EAAQC,EAcRC,EAAQC,EAERC,EAAQC,EAAAA,WAERC,EAAUC,EAAAA,IAEX,CAAC,CACJC,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,MAGHA,EAAQD,MAAI,IACZE,EAAWF,MAAI,IACfG,EAAWH,MAAI,IACfI,EAAeJ,OAAI,GACnBK,EAAWL,MAAI,IACfM,EAAoBN,EAAcA,IAAA,IAClCO,EAAOC,EAAAA,UAAS,IAAMC,KAAKC,KAAK,IAAMX,EAAQY,MAAMC,OAAS,MAEnE,SAASC,IACsB,IAAzBd,EAAQY,MAAMC,QAGlBb,EAAQY,MAAMG,KAAK,CACjBb,MAAO,IACR,CAUH,SAASc,IACPX,EAAaO,OAAQ,EACrBN,EAASM,MAAQ,EAAA,CAGnB,SAASK,IACH,IAACf,EAAMU,MAET,YADAM,EAAAA,UAAUC,MAAM,aAGlB,IAAIC,EAAM,GACVpB,EAAQY,MAAMS,SAAQ,CAACC,EAAGC,KACnBD,EAAEpB,QACLkB,GAAO,KAAKI,OAAOC,aAAa,GAAKF,SAAE,IAIvCH,EACFF,EAAAA,UAAUC,MAAMC,GAIbhB,EAASQ,OAKIL,EAAAK,MAAQR,EAASQ,MAAMc,MAAM,MAAMC,WAAYJ,IAEjE3B,EAAM,OAAQ,CACZM,MAAOA,EAAMU,MACbZ,QAASA,EAAQY,MACjBT,SAAUA,EAASS,MACnBL,kBAAmBA,EAAkBK,MACrCgB,oBAAqBvB,EAAaO,MAAQN,EAASM,MAAQ,MAX3DM,EAAAA,UAAUC,MAAM,WAYjB,CApDWlB,EAAAA,KAAI,GA8ElB4B,EAAAA,WAvBA,WACMnC,EAAMQ,QACRA,EAAMU,MAAQlB,EAAMQ,OAGlBR,EAAMoC,YAAcpC,EAAMoC,WAAWjB,SACvCb,EAAQY,MAAQlB,EAAMoC,YAGpBpC,EAAMS,WACRA,EAASS,MAAQlB,EAAMS,UAGrBT,EAAMa,oBACRA,EAAkBK,MAAQlB,EAAMa,kBAChCH,EAASQ,MAAQL,EAAkBK,MAAMmB,KAAK,OAE5CrC,EAAMkC,sBACRtB,EAASM,MAAQlB,EAAMkC,oBACvBvB,EAAaO,OAAQ,EACvB,IAII,MAAAoB,EAAKC,eAAa,0wHArExB,SAAsBC,GAChBlC,EAAQY,MAAMC,OAAS,GAGnBb,EAAAY,MAAMuB,OAAOD,EAAO,EAAC"}
|
1
|
+
{"version":3,"file":"subject-scale.vue.js","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":"81CAWA,MAAMA,EAAQC,EAcRC,EAAQC,EAERC,EAAQC,EAAAA,WAERC,EAAUC,EAAAA,IAEX,CAAC,CACJC,MAAO,IACN,CACDA,MAAO,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aO,OAAQ,EACvB,IAII,MAAAoB,EAAKC,eAAa,0wHArExB,SAAsBC,GAChBlC,EAAQY,MAAMC,OAAS,GAGnBb,EAAAY,MAAMuB,OAAOD,EAAO,EAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es"),t=require("vue"),l=require("@element-plus/icons-vue"),a=require("@qxs-bns/hooks"),r=require("../../../subject-action/src/subject-action.vue.js"),n=require("../../../subject-layout/src/subject-layout.vue.js"),o=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.js"),i=require("@qxs-bns/utils");const s={class:"preview"},d={class:"title"},u={key:0},c={key:1},m={key:0},p=["innerHTML"],f={class:"preview-answer"},v={class:"order"},y={class:"order"},x={style:{flex:"1"}},C={class:"margin-bottom flex flex-items-center"},V={class:"margin-bottom answer-list"},k={class:"order"},w={key:0,class:"margin-bottom flex flex-items-center"},h={style:{flex:"1"}},g={key:1,class:"flex"},E={style:{flex:"1"}},N={key:2,class:"margin-bottom flex"},B={style:{flex:"1"}},S={class:"flex flex-justify-end"};var b=t.defineComponent({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},id:{type:String,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(b,{emit:T}){const q=b,R=T,A=t.useAttrs(),_=t.ref(0),j=t.ref(!1),D=t.ref(2),I=t.ref([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),L=t.ref(),U=t.ref(""),M=t.ref(""),z=t.ref(!1),K=t.ref(""),$=t.ref(0),F=t.ref(!1),P=t.ref(""),G=t.computed((()=>"single"===q.type?"单选题":"multiple"===q.type?"多选题":"排序题")),O=t.ref([]),H=t.computed((()=>{const e=[];for(let t=I.value.length;t>1;t--)e.push({label:`至少选择${t}项`,value:t});return e.reverse()}));function Q(){q.isSave||I.value.push({title:"",isCorrect:!1,customAnswerId:i.setGuid()})}const J=q.id||i.setGuid();function W(){z.value=!1,K.value=""}function X(){if(!U.value)return void e.ElMessage.error("题目标题不能为空!");let t="",l=!1,a=null,r=0;if("multiple"===q.type||"single"===q.type?I.value.forEach(((e,n)=>{e.title||(t+=`选项${String.fromCharCode(65+n)}未填写。`),e.isCorrect&&(l=!0,r++),e.resultItem&&(a=1),e.answerRelations?.length&&(a=2)})):"sort"===q.type&&O.value.length&&(l=!0),t)return void e.ElMessage.error(t);if(new Set(I.value.map((e=>e.title))).size===I.value.length){if("multiple"===q.type){if(1===r)return void e.ElMessage.error("请至少设置两个正确答案");if(l&&r<L.value)return void e.ElMessage.error("至少选几项与正确答案数不符")}R("save",{title:U.value,answers:I.value.map(((e,t)=>({...e,orderIndex:t+1}))),examExpand:O.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:M.value,isSetCorrectAnswer:l,leastAnswerCount:L.value,examRichTextContent:z.value?K.value:"",examAnswerRelationType:a,isKey:j.value,answerCheckType:D.value})}else e.ElMessage.error("选项不能重复")}function Y(){F.value=!1,P.value=""}function Z(){F.value=!1}function ee(e){j.value=e}function te(e){D.value=e}function le(e,t){R("add",e,t?q.examAnswerRelationType:null)}t.watch((()=>q.isEdit),(()=>{q.isEdit&&($.value=(new Date).getTime())}));const ae=a.useNamespace("subject-single");return t.onMounted((function(){if(q.title&&(U.value=q.title),q.isKey&&(j.value=q.isKey),q.answerList&&q.answerList.length&&(I.value=q.answerList.map((e=>({...e,customAnswerId:e.examAnswerId||i.setGuid()})))),q.leastAnswerCount&&(L.value=q.leastAnswerCount),q.examExpand&&q.examExpand){const e=q.examExpand.split(",");O.value=e.map((e=>{const t=q.answerList.find((t=>t.answerId?.toString()===e));return t?String.fromCharCode(65+t.orderIndex-1):e})).filter(Boolean)}q.analysis&&(M.value=q.analysis),q.examRichTextContent&&(K.value=q.examRichTextContent,z.value=!0)})),(a,i)=>{const b=e.ElCheckbox,T=e.ElRadio,$=e.ElInput,P=e.ElOption,re=e.ElSelect,ne=e.ElIcon,oe=e.ElLink,ie=e.ElButton,se=e.ElDialog;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(t.unref(ae).e("single-exam"))},[t.createVNode(n.default,{"show-edit":a.isEdit},t.createSlots({preview:t.withCtx((()=>[t.createElementVNode("div",s,[t.createElementVNode("div",null,[t.createElementVNode("span",d,[t.createTextVNode(t.toDisplayString(a.orderIndex+1)+"."+t.toDisplayString(t.unref(U))+" ",1),"single"===a.type?(t.openBlock(),t.createElementBlock("span",u,"(单选题)")):["multiple","sort"].includes(a.type)?(t.openBlock(),t.createElementBlock("span",c," ("+t.toDisplayString(t.unref(G))+t.toDisplayString(t.unref(L)?`至少选${t.unref(L)}项${"sort"===a.type?"并排序":""}`:"")+") ",1)):t.createCommentVNode("v-if",!0)])]),t.unref(z)?(t.openBlock(),t.createElementBlock("div",m,[t.createElementVNode("div",{innerHTML:t.unref(K)},null,8,p)])):t.createCommentVNode("v-if",!0),t.createElementVNode("div",f,["sort"===a.type?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(t.unref(I),((e,l)=>(t.openBlock(),t.createBlock(b,{key:l,class:"radio",disabled:!0},{default:t.withCtx((()=>[t.createElementVNode("span",v,t.toDisplayString(String.fromCharCode(65+l))+". ",1),t.createTextVNode(" "+t.toDisplayString(e.title),1)])),_:2},1024)))),128)):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(t.unref(I),((e,l)=>(t.openBlock(),t.createBlock(T,{key:l,class:"radio",value:"disabled",disabled:""},{default:t.withCtx((()=>[t.createElementVNode("span",y,t.toDisplayString(String.fromCharCode(65+l))+". ",1),t.createTextVNode(" "+t.toDisplayString(e.title),1)])),_:2},1024)))),128))])])])),default:t.withCtx((()=>[a.showAction?(t.openBlock(),t.createBlock(r.default,{key:0,"is-edit":a.isEdit,"is-set":a.isSet,isKey:t.unref(j),examAnswerRelationType:q.examAnswerRelationType,answerCheckType:t.unref(D),onMoveUp:i[5]||(i[5]=e=>R("move","up")),onMoveDown:i[6]||(i[6]=e=>R("move","down")),onDelete:i[7]||(i[7]=e=>R("delete")),onSave:X,onEdit:i[8]||(i[8]=e=>R("edit")),onAdd:le,onOnShowRichText:i[9]||(i[9]=e=>z.value=!0),onSetKey:ee,onSetAnswerSetting:te},null,8,["is-edit","is-set","isKey","examAnswerRelationType","answerCheckType"])):t.createCommentVNode("v-if",!0)])),_:2},[a.isEdit?{name:"edit",fn:t.withCtx((()=>[t.createElementVNode("div",{class:t.normalizeClass(["flex",[{"margin-bottom":t.unref(z)}]])},[i[12]||(i[12]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"题目:")],-1)),t.createElementVNode("div",x,[t.createVNode($,{modelValue:t.unref(U),"onUpdate:modelValue":i[0]||(i[0]=e=>t.isRef(U)?U.value=e:null),type:"textarea",rows:2,placeholder:`【${t.unref(G)}】请输入问题`,disabled:a.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),t.createElementVNode("div",C,[i[13]||(i[13]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"设置:")],-1)),["multiple","sort"].includes(a.type)?(t.openBlock(),t.createBlock(re,{key:0,modelValue:t.unref(L),"onUpdate:modelValue":i[1]||(i[1]=e=>t.isRef(L)?L.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:a.isSave},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(H),(e=>(t.openBlock(),t.createBlock(P,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):t.createCommentVNode("v-if",!0)]),t.createElementVNode("div",V,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(I),((e,r)=>(t.openBlock(),t.createElementBlock("div",{key:r,class:"answer-item flex flex-items-center"},[t.createElementVNode("span",k,t.toDisplayString(String.fromCharCode(65+r))+".",1),t.createVNode($,{modelValue:e.title,"onUpdate:modelValue":t=>e.title=t,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+r)}`,disabled:a.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(a.type)?(t.openBlock(),t.createBlock(b,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":t=>e.isCorrect=t,class:t.normalizeClass([{"is-correct":e.isCorrect}]),disabled:a.isSave,style:{"margin-left":"10px"},onChange:t=>function(e,t){"single"===q.type?(t&&I.value.forEach((t=>{t!==e&&(t.isCorrect=!1)})),e.isCorrect=t):"multiple"===q.type&&(e.isCorrect=t)}(e,t)},{default:t.withCtx((()=>[...i[14]||(i[14]=[t.createTextVNode(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):t.createCommentVNode("v-if",!0),t.createVNode(ne,{class:"icon"},{default:t.withCtx((()=>[t.createVNode(t.unref(l.CirclePlus),{class:t.normalizeClass([{disabled:a.isSave}]),onClick:Q},null,8,["class"])])),_:1}),t.createVNode(ne,{class:"icon"},{default:t.withCtx((()=>[t.createVNode(t.unref(l.Remove),{class:t.normalizeClass([{disabled:t.unref(I).length<3||a.isSave}]),onClick:e=>function(e){I.value.length<3||q.isSave||I.value.splice(e,1)}(r)},null,8,["class","onClick"])])),_:2},1024),1===a.examAnswerRelationType?(t.openBlock(),t.createBlock(oe,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=r,_.value=t,void(F.value=!0);var t}},{default:t.withCtx((()=>[t.createTextVNode(t.toDisplayString(e.resultItem)+" ",1),t.createElementVNode("span",null,t.toDisplayString(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):t.createCommentVNode("v-if",!0),2===a.examAnswerRelationType?(t.openBlock(),t.createBlock(oe,{key:2,type:"primary",class:"margin-left-10",onClick:t=>function(e){R("setRelation",J,e)}(e)},{default:t.withCtx((()=>[t.createElementVNode("span",null,t.toDisplayString(e.answerRelations?.length?`关联了${e.answerRelations?.length}项`:"关联检查"),1)])),_:2},1032,["onClick"])):t.createCommentVNode("v-if",!0)])))),128))]),"sort"===a.type?(t.openBlock(),t.createElementBlock("div",w,[i[15]||(i[15]=t.createElementVNode("div",{class:"label flex flex-justify-end"},[t.createElementVNode("span",null,"排序答案:")],-1)),t.createElementVNode("div",h,[t.createVNode(re,{modelValue:t.unref(O),"onUpdate:modelValue":i[2]||(i[2]=e=>t.isRef(O)?O.value=e:null),mode:"multiple",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:t.withCtx((()=>[t.createCommentVNode(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(I),((e,l)=>(t.openBlock(),t.createBlock(P,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):t.createCommentVNode("v-if",!0),a.showAnalysis?(t.openBlock(),t.createElementBlock("div",g,[i[16]||(i[16]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"解析:")],-1)),t.createElementVNode("div",E,[t.createVNode($,{modelValue:t.unref(M),"onUpdate:modelValue":i[3]||(i[3]=e=>t.isRef(M)?M.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):t.createCommentVNode("v-if",!0),t.unref(z)?(t.openBlock(),t.createElementBlock("div",N,[i[18]||(i[18]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"富文本:")],-1)),t.createElementVNode("div",B,[t.createVNode(o.default,t.mergeProps({"model-value":t.unref(K),"onUpdate:modelValue":i[4]||(i[4]=e=>t.isRef(K)?K.value=e:null)},t.unref(A),{style:{width:"100%"}}),null,16,["model-value"]),t.createElementVNode("div",S,[t.createVNode(oe,{type:"danger",onClick:W},{default:t.withCtx((()=>i[17]||(i[17]=[t.createTextVNode(" 删除富文本 ")]))),_:1})])])])):t.createCommentVNode("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),t.createVNode(se,{modelValue:t.unref(F),"onUpdate:modelValue":i[11]||(i[11]=e=>t.isRef(F)?F.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:t.withCtx((()=>[t.createVNode(ie,{class:"customize-button",type:"primary",plain:"",onClick:Y},{default:t.withCtx((()=>i[19]||(i[19]=[t.createTextVNode(" 取消 ")]))),_:1}),t.createVNode(ie,{class:"customize-button",type:"primary",plain:"",onClick:Z},{default:t.withCtx((()=>i[20]||(i[20]=[t.createTextVNode(" 保存 ")]))),_:1})])),default:t.withCtx((()=>[(t.openBlock(),t.createBlock(o.default,t.mergeProps({key:t.unref(_),"model-value":t.unref(I)[t.unref(_)].resultItem,"onUpdate:modelValue":i[10]||(i[10]=e=>t.unref(I)[t.unref(_)].resultItem=e)},t.unref(A),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});exports.default=b;
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("element-plus/es"),t=require("vue"),l=require("@element-plus/icons-vue"),a=require("@qxs-bns/hooks"),r=require("../../../subject-action/src/subject-action.vue.js"),n=require("../../../subject-layout/src/subject-layout.vue.js"),o=require("../../../tiny-mce-editor/src/tiny-mce-editor.vue.js"),i=require("@qxs-bns/utils");const s={class:"preview"},u={class:"title"},d={key:0},c={key:1},m={key:0},p=["innerHTML"],f={class:"preview-answer"},v={class:"order"},y={class:"order"},x={style:{flex:"1"}},C={class:"margin-bottom flex flex-items-center"},k={class:"margin-bottom answer-list"},V={class:"order"},w={key:0,class:"margin-bottom flex flex-items-center"},h={style:{flex:"1"}},g={key:1,class:"flex"},E={style:{flex:"1"}},N={key:2,class:"margin-bottom flex"},B={style:{flex:"1"}},S={class:"flex flex-justify-end"};var b=t.defineComponent({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},customId:{type:Number,required:!1},examId:{type:Number,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(b,{emit:T}){const R=b,q=T,A=t.useAttrs(),I=t.ref(0),_=t.ref(R.isKey),j=t.ref(2),D=t.ref([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),L=t.ref(),U=t.ref(""),M=t.ref(""),z=t.ref(!1),$=t.ref(""),K=t.ref(0),F=t.ref(!1),P=t.ref(""),O=t.computed((()=>"single"===R.type?"单选题":"multiple"===R.type?"多选题":"排序题")),G=t.ref([]),H=t.computed((()=>{const e=[];for(let t=D.value.length;t>1;t--)e.push({label:`至少选择${t}项`,value:t});return e.reverse()}));function Q(){R.isSave||D.value.push({title:"",isCorrect:!1,customAnswerId:i.setGuid()})}function J(){z.value=!1,$.value=""}function W(){if(!U.value)return void e.ElMessage.error("题目标题不能为空!");let t="",l=!1,a=null,r=0;if("multiple"===R.type||"single"===R.type?D.value.forEach(((e,n)=>{e.title||(t+=`选项${String.fromCharCode(65+n)}未填写。`),e.isCorrect&&(l=!0,r++),e.resultItem&&(a=1),e.answerRelations?.length&&(a=2)})):"sort"===R.type&&G.value.length&&(l=!0),t)return void e.ElMessage.error(t);if(new Set(D.value.map((e=>e.title))).size===D.value.length){if("multiple"===R.type){if(1===r)return void e.ElMessage.error("请至少设置两个正确答案");if(l&&r<L.value)return void e.ElMessage.error("至少选几项与正确答案数不符")}q("save",{title:U.value,answers:D.value.map(((e,t)=>({...e,orderIndex:t+1}))),examExpand:G.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:M.value,isSetCorrectAnswer:l,leastAnswerCount:L.value,examRichTextContent:z.value?$.value:"",examAnswerRelationType:a,isKey:_.value,answerCheckType:j.value})}else e.ElMessage.error("选项不能重复")}function X(){F.value=!1,P.value=""}function Y(){F.value=!1}function Z(e){_.value=e}function ee(e){j.value=e}function te(e,t){q("add",e,t?R.examAnswerRelationType:null)}t.watch((()=>R.isEdit),(()=>{R.isEdit&&(K.value=(new Date).getTime())}));const le=a.useNamespace("subject-single");return t.onMounted((function(){if(R.title&&(U.value=R.title),R.answerCheckType&&(j.value=R.answerCheckType),R.answerList&&R.answerList.length&&(D.value=R.answerList.map((e=>({...e,customAnswerId:e.examAnswerId||i.setGuid()})))),R.leastAnswerCount&&(L.value=R.leastAnswerCount),R.examExpand&&R.examExpand){const e=R.examExpand.split(",");G.value=e.map((e=>{const t=R.answerList.find((t=>t.answerId?.toString()===e));return t?String.fromCharCode(65+t.orderIndex-1):e})).filter(Boolean)}R.analysis&&(M.value=R.analysis),R.examRichTextContent&&($.value=R.examRichTextContent,z.value=!0)})),(a,i)=>{const b=e.ElCheckbox,T=e.ElRadio,K=e.ElInput,P=e.ElOption,ae=e.ElSelect,re=e.ElIcon,ne=e.ElLink,oe=e.ElButton,ie=e.ElDialog;return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(t.unref(le).e("single-exam"))},[t.createVNode(n.default,{"show-edit":a.isEdit},t.createSlots({preview:t.withCtx((()=>[t.createElementVNode("div",s,[t.createElementVNode("div",null,[t.createElementVNode("span",u,[t.createTextVNode(t.toDisplayString(a.orderIndex+1)+"."+t.toDisplayString(t.unref(U))+" ",1),"single"===a.type?(t.openBlock(),t.createElementBlock("span",d,"(单选题)")):["multiple","sort"].includes(a.type)?(t.openBlock(),t.createElementBlock("span",c," ("+t.toDisplayString(t.unref(O))+t.toDisplayString(t.unref(L)?`至少选${t.unref(L)}项${"sort"===a.type?"并排序":""}`:"")+") ",1)):t.createCommentVNode("v-if",!0)])]),t.unref(z)?(t.openBlock(),t.createElementBlock("div",m,[t.createElementVNode("div",{innerHTML:t.unref($)},null,8,p)])):t.createCommentVNode("v-if",!0),t.createElementVNode("div",f,["sort"===a.type?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(t.unref(D),((e,l)=>(t.openBlock(),t.createBlock(b,{key:l,class:"radio",disabled:!0},{default:t.withCtx((()=>[t.createElementVNode("span",v,t.toDisplayString(String.fromCharCode(65+l))+". ",1),t.createTextVNode(" "+t.toDisplayString(e.title),1)])),_:2},1024)))),128)):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(t.unref(D),((e,l)=>(t.openBlock(),t.createBlock(T,{key:l,class:"radio",value:"disabled",disabled:""},{default:t.withCtx((()=>[t.createElementVNode("span",y,t.toDisplayString(String.fromCharCode(65+l))+". ",1),t.createTextVNode(" "+t.toDisplayString(e.title)+" "+t.toDisplayString(e.isCorrect?"(支持选项)":"")+" "+t.toDisplayString(e.resultItem&&1===a.examAnswerRelationType?"(已设置结果项)":"(未设置结果项)")+" "+t.toDisplayString(e.answerRelations?.length&&2===a.examAnswerRelationType?"(已设置关联)":"(未设置关联)"),1)])),_:2},1024)))),128))])])])),default:t.withCtx((()=>[a.showAction?(t.openBlock(),t.createBlock(r.default,{key:0,"is-edit":a.isEdit,"is-set":a.isSet,isKey:t.unref(_),examAnswerRelationType:R.examAnswerRelationType,answerCheckType:t.unref(j),onMoveUp:i[5]||(i[5]=e=>q("move","up")),onMoveDown:i[6]||(i[6]=e=>q("move","down")),onDelete:i[7]||(i[7]=e=>q("delete")),onSave:W,onEdit:i[8]||(i[8]=e=>q("edit")),onAdd:te,onOnShowRichText:i[9]||(i[9]=e=>z.value=!0),onSetKey:Z,onSetAnswerSetting:ee},null,8,["is-edit","is-set","isKey","examAnswerRelationType","answerCheckType"])):t.createCommentVNode("v-if",!0)])),_:2},[a.isEdit?{name:"edit",fn:t.withCtx((()=>[t.createElementVNode("div",{class:t.normalizeClass(["flex",[{"margin-bottom":t.unref(z)}]])},[i[12]||(i[12]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"题目:")],-1)),t.createElementVNode("div",x,[t.createVNode(K,{modelValue:t.unref(U),"onUpdate:modelValue":i[0]||(i[0]=e=>t.isRef(U)?U.value=e:null),type:"textarea",rows:2,placeholder:`【${t.unref(O)}】请输入问题`,disabled:a.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),t.createElementVNode("div",C,[i[13]||(i[13]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"设置:")],-1)),["multiple","sort"].includes(a.type)?(t.openBlock(),t.createBlock(ae,{key:0,modelValue:t.unref(L),"onUpdate:modelValue":i[1]||(i[1]=e=>t.isRef(L)?L.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:a.isSave},{default:t.withCtx((()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(H),(e=>(t.openBlock(),t.createBlock(P,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):t.createCommentVNode("v-if",!0)]),t.createElementVNode("div",k,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(D),((e,r)=>(t.openBlock(),t.createElementBlock("div",{key:r,class:"answer-item flex flex-items-center"},[t.createElementVNode("span",V,t.toDisplayString(String.fromCharCode(65+r))+".",1),t.createVNode(K,{modelValue:e.title,"onUpdate:modelValue":t=>e.title=t,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+r)}`,disabled:a.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(a.type)?(t.openBlock(),t.createBlock(b,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":t=>e.isCorrect=t,class:t.normalizeClass([{"is-correct":e.isCorrect}]),disabled:a.isSave,style:{"margin-left":"10px"},onChange:t=>function(e,t){"single"===R.type?(t&&D.value.forEach((t=>{t!==e&&(t.isCorrect=!1)})),e.isCorrect=t):"multiple"===R.type&&(e.isCorrect=t)}(e,t)},{default:t.withCtx((()=>[...i[14]||(i[14]=[t.createTextVNode(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):t.createCommentVNode("v-if",!0),t.createVNode(re,{class:"icon"},{default:t.withCtx((()=>[t.createVNode(t.unref(l.CirclePlus),{class:t.normalizeClass([{disabled:a.isSave}]),onClick:Q},null,8,["class"])])),_:1}),t.createVNode(re,{class:"icon"},{default:t.withCtx((()=>[t.createVNode(t.unref(l.Remove),{class:t.normalizeClass([{disabled:t.unref(D).length<3||a.isSave}]),onClick:e=>function(e){D.value.length<3||R.isSave||D.value.splice(e,1)}(r)},null,8,["class","onClick"])])),_:2},1024),1===a.examAnswerRelationType?(t.openBlock(),t.createBlock(ne,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=r,I.value=t,void(F.value=!0);var t}},{default:t.withCtx((()=>[t.createElementVNode("span",null,t.toDisplayString(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):t.createCommentVNode("v-if",!0),2===a.examAnswerRelationType?(t.openBlock(),t.createBlock(ne,{key:2,type:"primary",class:"margin-left-10",onClick:t=>function(e){q("setRelation",R.examId,R.customId,e)}(e)},{default:t.withCtx((()=>[t.createElementVNode("span",null,t.toDisplayString(e.answerRelations?.length?`关联了${e.answerRelations?.length}项`:"关联检查"),1)])),_:2},1032,["onClick"])):t.createCommentVNode("v-if",!0)])))),128))]),"sort"===a.type?(t.openBlock(),t.createElementBlock("div",w,[i[15]||(i[15]=t.createElementVNode("div",{class:"label flex flex-justify-end"},[t.createElementVNode("span",null,"排序答案:")],-1)),t.createElementVNode("div",h,[t.createVNode(ae,{modelValue:t.unref(G),"onUpdate:modelValue":i[2]||(i[2]=e=>t.isRef(G)?G.value=e:null),mode:"multiple",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:t.withCtx((()=>[t.createCommentVNode(' :options="[...Array(answers.length)].map((_, i) => ({ value: String.fromCharCode(65 + i) }))" '),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(D),((e,l)=>(t.openBlock(),t.createBlock(P,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):t.createCommentVNode("v-if",!0),a.showAnalysis?(t.openBlock(),t.createElementBlock("div",g,[i[16]||(i[16]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"解析:")],-1)),t.createElementVNode("div",E,[t.createVNode(K,{modelValue:t.unref(M),"onUpdate:modelValue":i[3]||(i[3]=e=>t.isRef(M)?M.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):t.createCommentVNode("v-if",!0),t.unref(z)?(t.openBlock(),t.createElementBlock("div",N,[i[18]||(i[18]=t.createElementVNode("div",{class:"label flex flex-justify-center"},[t.createElementVNode("span",null,"富文本:")],-1)),t.createElementVNode("div",B,[t.createVNode(o.default,t.mergeProps({"model-value":t.unref($),"onUpdate:modelValue":i[4]||(i[4]=e=>t.isRef($)?$.value=e:null)},t.unref(A),{style:{width:"100%"}}),null,16,["model-value"]),t.createElementVNode("div",S,[t.createVNode(ne,{type:"danger",onClick:J},{default:t.withCtx((()=>i[17]||(i[17]=[t.createTextVNode(" 删除富文本 ")]))),_:1})])])])):t.createCommentVNode("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),t.createVNode(ie,{modelValue:t.unref(F),"onUpdate:modelValue":i[11]||(i[11]=e=>t.isRef(F)?F.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:t.withCtx((()=>[t.createVNode(oe,{class:"customize-button",type:"primary",plain:"",onClick:X},{default:t.withCtx((()=>i[19]||(i[19]=[t.createTextVNode(" 取消 ")]))),_:1}),t.createVNode(oe,{class:"customize-button",type:"primary",plain:"",onClick:Y},{default:t.withCtx((()=>i[20]||(i[20]=[t.createTextVNode(" 保存 ")]))),_:1})])),default:t.withCtx((()=>[(t.openBlock(),t.createBlock(o.default,t.mergeProps({key:t.unref(I),"model-value":t.unref(D)[t.unref(I)].resultItem,"onUpdate:modelValue":i[10]||(i[10]=e=>t.unref(D)[t.unref(I)].resultItem=e)},t.unref(A),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});exports.default=b;
|
2
2
|
//# sourceMappingURL=subject-single.vue.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-single.vue.js","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 id?: string\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(false)\nconst answerCheckType = ref(2)\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 title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref()\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) => {\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}\nconst customId = props.id || setGuid()\nfunction setRelation(item: any) {\n emits('setRelation', 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) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n if (v.resultItem) {\n examAnswerRelationType = 1\n }\n if (v.answerRelations?.length) {\n examAnswerRelationType = 2\n }\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 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,\n isKey: isKey.value,\n answerCheckType: answerCheckType.value\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n if (props.isKey) {\n isKey.value = props.isKey\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList.map((item: any) => {\n return { ...item, customAnswerId: item.examAnswerId || setGuid() }\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}\n\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\n\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n // console.log(answers.value[i].resultItem, 1);\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}\n\nfunction setKey(key: boolean) {\n isKey.value = key\n}\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})\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 </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) => 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 {{ item.resultItem }}\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 ? `关联了${item.answerRelations?.length}项` : '关联检查' }}</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=\"(answers[answersIndex].resultItem as string)\" \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","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","customId","id","deleteRichText","save","ElMessage","error","msg","isSetCorrectAnswer","examAnswerRelationType","correctAnswerCount","forEach","v","i","String","fromCharCode","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onCloseResult","onSaveResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","ns","useNamespace","onMounted","answerList","examAnswerId","correctAnswerIdList","split","answer","find","answerId","toString","filter","Boolean","it","event","splice"],"mappings":"8oDAWA,MAAMA,EAAQC,EAmBRC,EAAQC,EAERC,EAAQC,EAAAA,WAERC,EAAeC,MAAI,GACnBC,EAAQD,OAAI,GACZE,EAAkBF,MAAI,GACtBG,EAAUH,EAAAA,IAaX,CAAC,CACJI,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,KAGPC,EAAmBN,EAAAA,MACnBI,EAAQJ,MAAI,IACZO,EAAWP,MAAI,IACfQ,EAAeR,OAAI,GACnBS,EAAWT,MAAI,IACfU,EAAYV,MAAI,GAChBW,EAAkBX,OAAI,GACtBY,EAAaZ,MAAY,IACzBa,EAAmBC,EAAAA,UAAS,IACb,WAAfrB,EAAMsB,KACD,MAEe,aAAftB,EAAMsB,KACN,MAGA,QAILC,EAAYhB,EAAcA,IAAA,IAE1BiB,EAAqBH,EAAAA,UAAS,KAClC,MAAMI,EAAQ,GAEd,IAAA,IAASC,EADMhB,EAAQiB,MAAMC,OACJF,EAAQ,EAAGA,IAClCD,EAAMI,KAAK,CACTC,MAAO,OAAOJ,KACdC,MAAOD,IAGX,OAAOD,EAAMM,SAAQ,IAEvB,SAASC,IACHhC,EAAMiC,QAGVvB,EAAQiB,MAAME,KAAK,CACjBlB,MAAO,GACPC,WAAW,EACXsB,eAAgBC,EAAQA,WACzB,CA0BG,MAAAC,EAAWpC,EAAMqC,IAAMF,YAK7B,SAASG,IACPvB,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AAfvF,EAAMsB,MAEJiE,GACM7E,EAAAiB,MAAMmB,SAASkC,IACjBA,IAAWM,IACbN,EAAOpE,WAAY,EAAA,IAIzB0E,EAAG1E,UAAY2E,GACS,aAAfvF,EAAMsB,OAEfgE,EAAG1E,UAAY2E,EACjB,6hBArBF,SAAsB/B,GAChB9C,EAAQiB,MAAMC,OAAS,GAAK5B,EAAMiC,QAG9BvB,EAAAiB,MAAM6D,OAAOhC,EAAO,EAAC,6KAkJTR,IACpB1C,EAAaqB,MAAQqB,OAGrB9B,EAAgBS,OAAQ,GAJ1B,IAAsBqB,wVA9HtB,SAAqBM,GACbpD,EAAA,cAAekC,EAAUkB,EAAI"}
|
1
|
+
{"version":3,"file":"subject-single.vue.js","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(2)\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 title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref()\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) => {\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 emits('setRelation', props.examId, 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) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n if (v.resultItem) {\n examAnswerRelationType = 1\n }\n if (v.answerRelations?.length) {\n examAnswerRelationType = 2\n }\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 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,\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\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList.map((item: any) => {\n return { ...item, customAnswerId: item.examAnswerId || setGuid() }\n })\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}\n\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\n\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n // console.log(answers.value[i].resultItem, 1);\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}\n\nfunction setKey(key: boolean) {\n isKey.value = key\n}\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})\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 {{ item.resultItem && examAnswerRelationType === 1? '(已设置结果项)' : '(未设置结果项)' }} \n {{ item.answerRelations?.length && examAnswerRelationType === 2 ? '(已设置关联)' : '(未设置关联)' }}\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 ? `关联了${item.answerRelations?.length}项` : '关联检查' }}</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=\"(answers[answersIndex].resultItem as string)\" \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","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","examAnswerRelationType","correctAnswerCount","forEach","v","i","String","fromCharCode","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onCloseResult","onSaveResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","ns","useNamespace","onMounted","answerList","examAnswerId","correctAnswerIdList","split","id","answer","find","answerId","toString","filter","Boolean","it","event","splice","examId","customId"],"mappings":"qrDAWA,MAAMA,EAAQC,EAoBRC,EAAQC,EAERC,EAAQC,EAAAA,WAERC,EAAeC,MAAI,GACnBC,EAAQD,EAAAA,IAAIP,EAAMQ,OAClBC,EAAkBF,MAAI,GACtBG,EAAUH,EAAAA,IAaX,CAAC,CACJI,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,KAGPC,EAAmBN,EAAAA,MACnBI,EAAQJ,MAAI,IACZO,EAAWP,MAAI,IACfQ,EAAeR,OAAI,GACnBS,EAAWT,MAAI,IACfU,EAAYV,MAAI,GAChBW,EAAkBX,OAAI,GACtBY,EAAaZ,MAAY,IACzBa,EAAmBC,EAAAA,UAAS,IACb,WAAfrB,EAAMsB,KACD,MAEe,aAAftB,EAAMsB,KACN,MAGA,QAILC,EAAYhB,EAAcA,IAAA,IAE1BiB,EAAqBH,EAAAA,UAAS,KAClC,MAAMI,EAAQ,GAEd,IAAA,IAASC,EADMhB,EAAQiB,MAAMC,OACJF,EAAQ,EAAGA,IAClCD,EAAMI,KAAK,CACTC,MAAO,OAAOJ,KACdC,MAAOD,IAGX,OAAOD,EAAMM,SAAQ,IAEvB,SAASC,IACHhC,EAAMiC,QAGVvB,EAAQiB,MAAME,KAAK,CACjBlB,MAAO,GACPC,WAAW,EACXsB,eAAgBC,EAAQA,WACzB,CA8BH,SAASC,IACPrB,EAAaY,OAAQ,EACrBX,EAASW,MAAQ,EAAA,CAGnB,SAASU,IACH,IAAC1B,EAAMgB,MAET,YADAW,EAAAA,UAAUC,MAAM,aAGlB,IAAIC,EAAM,GACNC,GAAqB,EAC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EAAGzE,UAAY0E,EACjB,6hBArBF,SAAsBhC,GAChB5C,EAAQiB,MAAMC,OAAS,GAAK5B,EAAMiC,QAG9BvB,EAAAiB,MAAM4D,OAAOjC,EAAO,EAAC,6KAoJTR,IACpBxC,EAAaqB,MAAQmB,OAGrB5B,EAAgBS,OAAQ,GAJ1B,IAAsBmB,+RAjItB,SAAqBM,GACnBlD,EAAM,cAAeF,EAAMwF,OAAQxF,EAAMyF,SAAUrC,EAAI"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("./components/subject-blank-fill.vue.js"),n=require("./components/subject-scale.vue.js"),s=require("./components/subject-single.vue.js"),i=require("./components/subject-text-fill.vue.js"),a=require("./components/SubjectRichText.vue.js"),o=require("./components/SubjectPageEnd.vue.js"),l=require("@qxs-bns/hooks"),r=require("@qxs-bns/utils"),c=require("element-plus/es");const d={class:"subject-list-wrapper"};var u=e.defineComponent({name:"QxsSubjectList",__name:"subject-list",props:{subjectList:{type:Array,required:!0},isPreview:{type:Boolean,required:!0}},emits:["setRelation"],setup(u,{expose:x,emit:p}){const m=u,w=e.ref([]),v=p,y=e.useAttrs();function h(){let e=0,t=!1;return w.value.map(((n,s,i)=>{"page_end"===n.answerType&&(e++,t=s===i.length-1)})),t?e:e+1}function f(e,t,n){console.log(t,"index"),t||0===t?w.value.splice(t+1,0,{customId:r.setGuid(),answerType:e,analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:n}):w.value.push({customId:r.setGuid(),answerType:e,analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:n})}function T(e,t){if("up"===t&&e>0){const[t]=w.value.splice(e,1);w.value.splice(e-1,0,t)}else if("down"===t&&e<w.value.length-1){const[t]=w.value.splice(e,1);w.value.splice(e+1,0,t)}}function E(e,t){for(let n=0;n<w.value.length;n++)e===n&&(w.value[e]={...w.value[e],...t,isEdit:!1})}function A(e){w.value.splice(e,1),c.ElMessage.success("删除成功")}function R(e,t){v("setRelation",e,t)}x({addSubject:f,currentList:w,uploadExcel:function(e){w.value=w.value.concat(e)},addExam:function(e){const t=[];e.answers?.map((e=>{t.push({...e,title:e.answer,answerId:e.examAnswerId,isCorrect:e.isCorrect})})),w.value.push({...e,customId:r.setGuid(),answerType:e.richTextContent?"rich_text":e.examTypeEnum,answers:t,isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1})},setAnswerRelation:function(e,t,n){console.log(e,t,n,111),console.log(w.value,222),e.length&&w.value.forEach((s=>{s.customId===t&&s.answer.forEach((t=>{t.customAnswerId===n&&(t.answerRelations=e)}))}))}}),e.watch((()=>m.subjectList),(e=>{e&&(w.value=[...e])}),{immediate:!0});const k=l.useNamespace("subject-list");return(l,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(k).e("list-exam"))},[e.createElementVNode("div",d,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),((r,c)=>(e.openBlock(),e.createElementBlock("div",{key:c+r.examId||r.title},[["single","multiple","sort"].includes(r.answerType)?(e.openBlock(),e.createBlock(s.default,e.mergeProps({key:0,ref_for:!0},e.unref(y),{"order-index":c,title:r.title,type:r.answerType,"exam-id":r.examId,isKey:r.isKey,"is-save":!r.isRealCanDel,customId:r.customId,"is-set":r.hasSet||!1,"answer-list":r.answers,analysis:r.analysis,"least-answer-count":r.leastAnswerCount,"is-edit":r.isEdit||!1,"show-action":!l.isPreview,"exam-expand":r.examExpand,answerCheckType:r.answerCheckType,"exam-rich-text-content":r.examRichTextContent,examAnswerRelationType:r.examAnswerRelationType,onSetRelation:R,onMove:e=>T(c,e),onDelete:e=>A(c),onSave:e=>E(c,e),onEdit:e=>r.isEdit=!0,onAdd:(e,t)=>f(e,c,t)}),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"===r.answerType?(e.openBlock(),e.createBlock(n.default,e.mergeProps({key:1,ref_for:!0},e.unref(y),{"order-index":c,title:r.title,"is-save":!r.isRealCanDel,"is-set":r.hasSet||!1,"answer-list":r.answers,analysis:r.analysis,"is-edit":r.isEdit||!1,"scale-question-list":r.scaleQuestionList,"show-action":!l.isPreview,"exam-rich-text-content":r.examRichTextContent,examAnswerRelationType:r.examAnswerRelationType,onMove:e=>T(c,e),onDelete:e=>A(c),onSave:e=>E(c,e),onEdit:e=>r.isEdit=!0,onAdd:e=>f(e,c,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"===r.answerType?(e.openBlock(),e.createBlock(t.default,e.mergeProps({key:2,ref_for:!0},e.unref(y),{"order-index":c,title:r.title,"is-save":!r.isRealCanDel,"is-set":r.hasSet||!1,"answer-list":r.answers,analysis:r.analysis,"show-action":!l.isPreview,"is-edit":r.isEdit||!1,"exam-answer-setting-v-o":r.examAnswerSettingVO||{},"exam-rich-text-content":r.examRichTextContent,examAnswerRelationType:r.examAnswerRelationType,onMove:e=>T(c,e),onDelete:e=>A(c),onSave:e=>E(c,e),onEdit:e=>r.isEdit=!0,onAdd:e=>f(e,c,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"===r.answerType?(e.openBlock(),e.createBlock(i.default,e.mergeProps({key:3,ref_for:!0},e.unref(y),{"order-index":c,title:r.title,"is-save":!r.isRealCanDel,"is-set":r.hasSet||!1,"answer-list":r.answers,analysis:r.analysis,"show-action":!l.isPreview,"is-edit":r.isEdit||!1,"exam-expand":r.examExpand,"exam-answer-setting-v-o":r.examAnswerSettingVO||{},examAnswerRelationType:r.examAnswerRelationType,"exam-rich-text-content":r.examRichTextContent,onMove:e=>T(c,e),onDelete:e=>A(c),onSave:e=>E(c,e),onEdit:e=>r.isEdit=!0,onAdd:e=>f(e,c,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"===r.answerType?(e.openBlock(),e.createBlock(a.default,e.mergeProps({key:4,ref_for:!0},e.unref(y),{"order-index":c,richTextContent:r.richTextContent,"is-set":r.hasSet||!1,"is-save":!r.isRealCanDel,"is-edit":r.isEdit||!1,"show-action":!l.isPreview,onMove:e=>T(c,e),onDelete:e=>A(c),examAnswerRelationType:r.examAnswerRelationType,onSave:e=>E(c,e),onEdit:e=>r.isEdit=!0,onAdd:e=>f(e,c,null)}),null,16,["order-index","richTextContent","is-set","is-save","is-edit","show-action","onMove","onDelete","examAnswerRelationType","onSave","onEdit","onAdd"])):"page_end"===r.answerType?(e.openBlock(),e.createBlock(o.default,{"total-page":h(),key:c,"current-page-index":(e=>{const t=w.value.filter((e=>"page_end"===e.answerType));let n=0;return t.forEach(((t,s)=>{e===t.id&&(n=s+1)})),n})(r.id),item:r,"order-index":c,"is-edit":r.isEdit||!1,"is-set":r.hasSet||!1,"is-save":!r.isRealCanDel,examAnswerRelationType:r.examAnswerRelationType,onMove:e=>T(c,e),onDelete:e=>A(c),onSave:e=>E(c,e),onEdit:e=>r.isEdit=!0,onAdd:e=>f(e,c,null)},null,8,["total-page","current-page-index","item","order-index","is-edit","is-set","is-save","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):e.createCommentVNode("v-if",!0)])))),128))])],2))}});exports.default=u;
|
2
2
|
//# sourceMappingURL=subject-list.vue.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-list.vue.js","sources":["../../../../../../packages/components/src/subject-list/src/subject-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// import isEqual from 'lodash/isEqual'\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'\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 let totalPageIndex = 0\n let isLastPageIndex = false\n currentList.value.map((v: any, i: number, arr: any) => {\n if (v.answerType === 'page_end') {\n totalPageIndex++\n isLastPageIndex = i === arr.length - 1\n }\n })\n // 假设最后是一个分页器认为是最后一页\n return isLastPageIndex ? totalPageIndex : totalPageIndex + 1\n}\n\nfunction currentPageIndex() {\n return (currentId: any) => {\n const currentPageList = currentList.value.filter(\n (v: any) => v.answerType === 'page_end'\n )\n let currentIndex = 0\n currentPageList.forEach((c: any, i: number) => {\n if (currentId === c.id) {\n currentIndex = i + 1\n }\n })\n return currentIndex\n }\n}\n\nfunction addSubject(type: string, index: number, examAnswerRelationType: number | null) {\n console.log(index, 'index')\n if (index || index === 0) {\n currentList.value.splice(index + 1, 0, {\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: examAnswerRelationType,\n })\n }\n else {\n currentList.value.push({\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: examAnswerRelationType,\n })\n }\n}\n\nfunction addExam(item: any) {\n const answerList: any[] = []\n item.answers?.map((v: any) => {\n answerList.push({\n ...v,\n title: v.answer,\n answerId: v.examAnswerId,\n isCorrect: v.isCorrect,\n })\n })\n currentList.value.push({\n ...item,\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}\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 }\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 for (let idx = 0; idx < currentList.value.length; idx++) {\n if (index === idx) {\n currentList.value[index] =\n {\n ...currentList.value[index],\n ...item,\n isEdit: false,\n }\n }\n }\n}\n\nfunction deleteSubject(index: number) {\n currentList.value.splice(index, 1)\n ElMessage.success('删除成功')\n}\n\nfunction setRelation(examId: string, examAnswers: any) {\n emits('setRelation', examId, examAnswers)\n}\n\nfunction setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string,) {\n // 给examId设置答案关联\n if (answerRelations.length) {\n currentList.value.forEach((c: any) => {\n if (c.customId === customId) {\n c.answer.forEach((c: any) => {\n if (c.customAnswerId === customAnswerId) {\n c.answerRelations = answerRelations\n }\n })\n }\n })\n }\n}\nwatch(() => props.subjectList, (newList: any) => {\n if (newList) {\n currentList.value = [...newList]\n }\n}, { immediate: true })\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=\"index + item.examId || item.title\">\n <template v-if=\"['single', 'multiple', 'sort'].includes(item.answerType)\">\n <SubjectSingle v-bind=\"attrs\" :order-index=\"index\" :title=\"item.title\" :type=\"item.answerType\"\n :isKey=\"item.isKey\" :is-save=\"!item.isRealCanDel\" :id=\"item.examId\" :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\" :analysis=\"item.analysis\" :least-answer-count=\"item.leastAnswerCount\"\n :is-edit=\"item.isEdit || false\" :show-action=\"!isPreview\" :exam-expand=\"item.examExpand\"\n :answerCheckType=\"item.answerCheckType\" :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\" @setRelation=\"setRelation\"\n @move=\"(type: 'up' | 'down') => move(index, type)\" @delete=\"deleteSubject(index)\"\n @save=\"item => saveSubject(index, item)\" @edit=\"item.isEdit = true\"\n @add=\"(type, examAnswerRelationType) => 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.id)\" :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","totalPageIndex","isLastPageIndex","value","map","v","i","arr","answerType","length","addSubject","type","index","examAnswerRelationType","console","log","splice","analysis","scaleQuestionList","isSave","isEdit","isRealCanDel","hasSet","push","move","item","saveSubject","idx","deleteSubject","ElMessage","success","setRelation","examId","examAnswers","__expose","uploadExcel","list","concat","addExam","answerList","answers","title","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","setAnswerRelation","answerRelations","customId","customAnswerId","forEach","c","watch","subjectList","newList","immediate","ns","useNamespace","currentId","currentPageList","filter","currentIndex","id"],"mappings":"wqBAaA,MAAMA,EAAQC,EAIRC,EAAcC,EAAIA,IAAA,IAClBC,EAAQC,EAERC,EAAQC,EAAAA,WAUd,SAASC,IACP,IAAIA,EAAiB,EACjBC,GAAkB,EAQf,OAPPP,EAAYQ,MAAMC,KAAI,CAACC,EAAQC,EAAWC,KACnB,aAAjBF,EAAEG,aACJP,IACkBC,EAAAI,IAAMC,EAAIE,OAAS,EAAA,IAIlCP,EAAkBD,EAAiBA,EAAiB,CAAA,CAkBpD,SAAAS,EAAWC,EAAcC,EAAeC,GACvCC,QAAAC,IAAIH,EAAO,SACfA,GAAmB,IAAVA,EACXjB,EAAYQ,MAAMa,OAAOJ,EAAQ,EAAG,EAAG,CACrCJ,WAAYG,EACZM,SAAU,GACVC,kBAAmB,GACnBC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRT,2BAIFlB,EAAYQ,MAAMoB,KAAK,CACrBf,WAAYG,EACZM,SAAU,GACVC,kBAAmB,GACnBC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRT,0BAEJ,CA2BO,SAAAW,EAAKZ,EAAeD,GACvB,GAAS,OAATA,GAAiBC,EAAQ,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EAAEF,iBAAmBA,IACvBE,EAAEJ,gBAAkBA,EAAA,GAEvB,GAGP,IAEFK,EAAAA,OAAM,IAAM7D,EAAM8D,cAAcC,IAC1BA,IACU7D,EAAAQ,MAAQ,IAAIqD,GAAO,GAEhC,CAAEC,WAAW,IACV,MAAAC,EAAKC,eAAa,qlIAtHf,CAACC,IACA,MAAAC,EAAkBlE,EAAYQ,MAAM2D,QACvCzD,GAA4B,aAAjBA,EAAEG,aAEhB,IAAIuD,EAAe,EAMZ,OALSF,EAAAT,SAAQ,CAACC,EAAQ/C,KAC3BsD,IAAcP,EAAEW,KAClBD,EAAezD,EAAI,EAAA,IAGhByD,CAAA"}
|
1
|
+
{"version":3,"file":"subject-list.vue.js","sources":["../../../../../../packages/components/src/subject-list/src/subject-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\n// import isEqual from 'lodash/isEqual'\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 let totalPageIndex = 0\n let isLastPageIndex = false\n currentList.value.map((v: any, i: number, arr: any) => {\n if (v.answerType === 'page_end') {\n totalPageIndex++\n isLastPageIndex = i === arr.length - 1\n }\n })\n // 假设最后是一个分页器认为是最后一页\n return isLastPageIndex ? totalPageIndex : totalPageIndex + 1\n}\n\nfunction currentPageIndex() {\n return (currentId: any) => {\n const currentPageList = currentList.value.filter(\n (v: any) => v.answerType === 'page_end'\n )\n let currentIndex = 0\n currentPageList.forEach((c: any, i: number) => {\n if (currentId === c.id) {\n currentIndex = i + 1\n }\n })\n return currentIndex\n }\n}\n\nfunction addSubject(type: string, index: number, examAnswerRelationType: number | null) {\n console.log(index, 'index')\n if (index || index === 0) {\n currentList.value.splice(index + 1, 0, {\n customId: setGuid(),\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: examAnswerRelationType,\n })\n }\n else {\n currentList.value.push({\n customId: setGuid(),\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: examAnswerRelationType,\n })\n }\n}\n\nfunction addExam(item: any) {\n const answerList: any[] = []\n item.answers?.map((v: any) => {\n answerList.push({\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}\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 }\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 for (let idx = 0; idx < currentList.value.length; idx++) {\n if (index === idx) {\n currentList.value[index] =\n {\n ...currentList.value[index],\n ...item,\n isEdit: false,\n }\n }\n }\n}\n\nfunction deleteSubject(index: number) {\n currentList.value.splice(index, 1)\n ElMessage.success('删除成功')\n}\n\nfunction setRelation(examId: string, examAnswers: any) {\n emits('setRelation', examId, examAnswers)\n}\n\nfunction setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string,) {\n // 给examId设置答案关联\n console.log(answerRelations, customId, customAnswerId, 111);\n console.log(currentList.value, 222);\n if (answerRelations.length) {\n currentList.value.forEach((c: any) => {\n if (c.customId === customId) {\n c.answer.forEach((c: any) => {\n if (c.customAnswerId === customAnswerId) {\n c.answerRelations = answerRelations\n }\n })\n }\n })\n }\n}\nwatch(() => props.subjectList, (newList: any) => {\n if (newList) {\n currentList.value = [...newList]\n }\n}, { immediate: true })\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=\"index + item.examId || item.title\">\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.id)\" :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","totalPageIndex","isLastPageIndex","value","map","v","i","arr","answerType","length","addSubject","type","index","examAnswerRelationType","console","log","splice","customId","setGuid","analysis","scaleQuestionList","isSave","isEdit","isRealCanDel","hasSet","push","move","item","saveSubject","idx","deleteSubject","ElMessage","success","setRelation","examId","examAnswers","__expose","uploadExcel","list","concat","addExam","answerList","answers","title","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","setAnswerRelation","answerRelations","customAnswerId","forEach","c","watch","subjectList","newList","immediate","ns","useNamespace","currentId","currentPageList","filter","currentIndex","id"],"mappings":"osBAeA,MAAMA,EAAQC,EAIRC,EAAcC,EAAIA,IAAA,IAClBC,EAAQC,EAERC,EAAQC,EAAAA,WAUd,SAASC,IACP,IAAIA,EAAiB,EACjBC,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