@qxs-bns/components 0.0.48 → 0.0.50
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/index.mjs +1 -1
- package/es/index.mjs.map +1 -1
- package/es/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs +2 -0
- package/es/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs.map +1 -0
- package/es/package.json.mjs +1 -1
- package/es/src/components.mjs +1 -1
- package/es/src/data-chart/index.mjs +1 -1
- package/es/src/data-chart/index.mjs.map +1 -1
- package/es/src/data-chart/src/analyze.mjs +2 -0
- package/es/src/data-chart/src/analyze.mjs.map +1 -0
- package/es/src/data-chart/src/components/area.vue.mjs +1 -1
- package/es/src/data-chart/src/components/area.vue2.mjs.map +1 -1
- package/es/src/data-chart/src/components/area.vue3.mjs +2 -0
- package/es/src/data-chart/src/components/area.vue3.mjs.map +1 -0
- package/es/src/data-chart/src/components/bar.vue.mjs +1 -1
- package/es/src/data-chart/src/components/bar.vue.mjs.map +1 -1
- package/es/src/data-chart/src/components/card.vue.mjs +1 -1
- package/es/src/data-chart/src/components/card.vue2.mjs +1 -1
- package/es/src/data-chart/src/components/card.vue2.mjs.map +1 -1
- package/es/src/data-chart/src/components/card.vue3.mjs +2 -0
- package/es/src/data-chart/src/components/card.vue3.mjs.map +1 -0
- package/es/src/data-chart/src/components/data-chart-card-bg-left.svg.mjs +2 -0
- package/es/src/data-chart/src/components/data-chart-card-bg-left.svg.mjs.map +1 -0
- package/es/src/data-chart/src/components/data-chart-card-bg-right.svg.mjs +2 -0
- package/es/src/data-chart/src/components/data-chart-card-bg-right.svg.mjs.map +1 -0
- package/es/src/data-chart/src/components/empty.svg.mjs +1 -1
- package/es/src/data-chart/src/components/empty.svg.mjs.map +1 -1
- package/es/src/data-chart/src/components/empty.vue.mjs +1 -1
- package/es/src/data-chart/src/components/empty.vue.mjs.map +1 -1
- package/es/src/data-chart/src/components/funnel.vue.mjs +1 -1
- package/es/src/data-chart/src/components/funnel.vue.mjs.map +1 -1
- package/es/src/data-chart/src/components/line.vue.mjs +1 -1
- package/es/src/data-chart/src/components/line.vue2.mjs +1 -1
- package/es/src/data-chart/src/components/line.vue2.mjs.map +1 -1
- package/es/src/data-chart/src/components/line.vue3.mjs +2 -0
- package/es/src/data-chart/src/components/line.vue3.mjs.map +1 -0
- package/es/src/data-chart/src/components/pie.vue.mjs +1 -1
- package/es/src/data-chart/src/components/pie.vue.mjs.map +1 -1
- package/es/src/data-chart/src/components/radar.vue.mjs +1 -1
- package/es/src/data-chart/src/components/radar.vue.mjs.map +1 -1
- package/es/src/data-chart/src/components/scatter-simple.vue.mjs +1 -1
- package/es/src/data-chart/src/components/scatter-simple.vue.mjs.map +1 -1
- package/es/src/data-chart/src/components/scatter.vue.mjs +1 -1
- package/es/src/data-chart/src/components/scatter.vue.mjs.map +1 -1
- package/es/src/data-chart/src/components/table.vue.mjs +1 -1
- package/es/src/data-chart/src/components/table.vue.mjs.map +1 -1
- package/es/src/data-chart/src/data-chart.vue.mjs +1 -1
- package/es/src/data-chart/src/data-chart.vue.mjs.map +1 -1
- package/es/src/data-chart/src/utils/config.mjs +1 -1
- package/es/src/data-chart/src/utils/config.mjs.map +1 -1
- package/es/src/data-chart/src/utils/safe-eval.mjs +2 -0
- package/es/src/data-chart/src/utils/safe-eval.mjs.map +1 -0
- package/es/src/data-chart/src/utils/useCharts.mjs +1 -1
- package/es/src/data-chart/src/utils/useCharts.mjs.map +1 -1
- package/es/src/file-upload/src/file-upload.vue.mjs +1 -1
- package/es/src/file-upload/src/file-upload.vue.mjs.map +1 -1
- package/es/src/fixed-action-bar/src/fixed-action-bar.vue.mjs +1 -1
- package/es/src/fixed-action-bar/src/fixed-action-bar.vue.mjs.map +1 -1
- package/es/src/image-upload/src/image-upload.vue.mjs +1 -1
- package/es/src/image-upload/src/image-upload.vue.mjs.map +1 -1
- package/es/src/photo-crop-tool/src/photo-crop-tool.vue.mjs.map +1 -1
- package/es/src/subject-action/index.mjs.map +1 -1
- package/es/src/subject-action/src/subject-action.vue.mjs +1 -1
- package/es/src/subject-action/src/subject-action.vue.mjs.map +1 -1
- package/es/src/subject-layout/index.mjs.map +1 -1
- package/es/src/subject-layout/src/subject-layout.vue.mjs.map +1 -1
- package/es/src/subject-list/src/components/SubjectPageEnd.vue.mjs +1 -1
- package/es/src/subject-list/src/components/SubjectPageEnd.vue.mjs.map +1 -1
- package/es/src/subject-list/src/components/SubjectRichText.vue.mjs +1 -1
- package/es/src/subject-list/src/components/SubjectRichText.vue.mjs.map +1 -1
- package/es/src/subject-list/src/components/subject-blank-fill.vue.mjs +1 -1
- package/es/src/subject-list/src/components/subject-blank-fill.vue.mjs.map +1 -1
- package/es/src/subject-list/src/components/subject-scale.vue.mjs +1 -1
- package/es/src/subject-list/src/components/subject-scale.vue.mjs.map +1 -1
- package/es/src/subject-list/src/components/subject-single.vue.mjs +1 -1
- package/es/src/subject-list/src/components/subject-single.vue.mjs.map +1 -1
- package/es/src/subject-list/src/components/subject-text-fill.vue.mjs +1 -1
- package/es/src/subject-list/src/components/subject-text-fill.vue.mjs.map +1 -1
- package/es/src/subject-list/src/subject-list.vue.mjs +1 -1
- package/es/src/subject-list/src/subject-list.vue.mjs.map +1 -1
- package/es/src/subject-type/index.mjs.map +1 -1
- package/es/src/subject-type/src/subject-type.vue.mjs.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.cjs +2 -0
- package/lib/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.cjs.map +1 -0
- package/lib/package.json.cjs +1 -1
- package/lib/src/components.cjs +1 -1
- package/lib/src/data-chart/index.cjs +1 -1
- package/lib/src/data-chart/index.cjs.map +1 -1
- package/lib/src/data-chart/src/analyze.cjs +2 -0
- package/lib/src/data-chart/src/analyze.cjs.map +1 -0
- package/lib/src/data-chart/src/components/area.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/area.vue2.cjs.map +1 -1
- package/lib/src/data-chart/src/components/area.vue3.cjs +2 -0
- package/lib/src/data-chart/src/components/area.vue3.cjs.map +1 -0
- package/lib/src/data-chart/src/components/bar.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/bar.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/components/card.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/card.vue2.cjs +1 -1
- package/lib/src/data-chart/src/components/card.vue2.cjs.map +1 -1
- package/lib/src/data-chart/src/components/card.vue3.cjs +2 -0
- package/lib/src/data-chart/src/components/card.vue3.cjs.map +1 -0
- package/lib/src/data-chart/src/components/data-chart-card-bg-left.svg.cjs +2 -0
- package/lib/src/data-chart/src/components/data-chart-card-bg-left.svg.cjs.map +1 -0
- package/lib/src/data-chart/src/components/data-chart-card-bg-right.svg.cjs +2 -0
- package/lib/src/data-chart/src/components/data-chart-card-bg-right.svg.cjs.map +1 -0
- package/lib/src/data-chart/src/components/empty.svg.cjs +1 -1
- package/lib/src/data-chart/src/components/empty.svg.cjs.map +1 -1
- package/lib/src/data-chart/src/components/empty.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/empty.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/components/funnel.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/funnel.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/components/line.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/line.vue2.cjs +1 -1
- package/lib/src/data-chart/src/components/line.vue2.cjs.map +1 -1
- package/lib/src/data-chart/src/components/line.vue3.cjs +2 -0
- package/lib/src/data-chart/src/components/line.vue3.cjs.map +1 -0
- package/lib/src/data-chart/src/components/pie.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/pie.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/components/radar.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/radar.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/components/scatter-simple.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/scatter-simple.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/components/scatter.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/scatter.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/components/table.vue.cjs +1 -1
- package/lib/src/data-chart/src/components/table.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/data-chart.vue.cjs +1 -1
- package/lib/src/data-chart/src/data-chart.vue.cjs.map +1 -1
- package/lib/src/data-chart/src/utils/config.cjs +1 -1
- package/lib/src/data-chart/src/utils/config.cjs.map +1 -1
- package/lib/src/data-chart/src/utils/safe-eval.cjs +2 -0
- package/lib/src/data-chart/src/utils/safe-eval.cjs.map +1 -0
- package/lib/src/data-chart/src/utils/useCharts.cjs +1 -1
- package/lib/src/data-chart/src/utils/useCharts.cjs.map +1 -1
- package/lib/src/file-upload/src/file-upload.vue.cjs +1 -1
- package/lib/src/file-upload/src/file-upload.vue.cjs.map +1 -1
- package/lib/src/fixed-action-bar/src/fixed-action-bar.vue.cjs +1 -1
- package/lib/src/fixed-action-bar/src/fixed-action-bar.vue.cjs.map +1 -1
- package/lib/src/image-upload/src/image-upload.vue.cjs +1 -1
- package/lib/src/image-upload/src/image-upload.vue.cjs.map +1 -1
- package/lib/src/photo-crop-tool/src/photo-crop-tool.vue.cjs.map +1 -1
- package/lib/src/subject-action/index.cjs.map +1 -1
- package/lib/src/subject-action/src/subject-action.vue.cjs +1 -1
- package/lib/src/subject-action/src/subject-action.vue.cjs.map +1 -1
- package/lib/src/subject-layout/index.cjs.map +1 -1
- package/lib/src/subject-layout/src/subject-layout.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/components/SubjectPageEnd.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/SubjectPageEnd.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/components/SubjectRichText.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/SubjectRichText.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/components/subject-blank-fill.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/subject-blank-fill.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/components/subject-scale.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/subject-scale.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/components/subject-single.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/subject-single.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/components/subject-text-fill.vue.cjs +1 -1
- package/lib/src/subject-list/src/components/subject-text-fill.vue.cjs.map +1 -1
- package/lib/src/subject-list/src/subject-list.vue.cjs +1 -1
- package/lib/src/subject-list/src/subject-list.vue.cjs.map +1 -1
- package/lib/src/subject-type/index.cjs.map +1 -1
- package/lib/src/subject-type/src/subject-type.vue.cjs.map +1 -1
- package/package.json +3 -10
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/base.scss +2 -2
- package/theme-chalk/src/common/element-plus.css +1 -1
- package/theme-chalk/src/common/element-plus.scss +1 -1
- package/theme-chalk/src/data-chart/empty.css +1 -1
- package/theme-chalk/src/data-chart/empty.scss +3 -3
- package/theme-chalk/src/data-chart/index.css +1 -1
- package/theme-chalk/src/data-chart/table.css +1 -1
- package/theme-chalk/src/data-chart/table.scss +8 -4
- package/theme-chalk/src/fixed-action-bar.css +1 -1
- package/theme-chalk/src/fixed-action-bar.scss +1 -1
- package/theme-chalk/src/image-upload.css +1 -1
- package/theme-chalk/src/image-upload.scss +3 -1
- package/theme-chalk/src/subject-action.css +1 -1
- package/theme-chalk/src/subject-action.scss +3 -2
- package/theme-chalk/src/subject-layout.scss +19 -19
- package/theme-chalk/src/subject-list.css +1 -1
- package/theme-chalk/src/subject-list.scss +15 -14
- package/theme-chalk/src/tiny-mce-editor.scss +4 -2
- package/types/src/data-chart/index.d.ts +7 -4
- package/types/src/data-chart/index.d.ts.map +1 -1
- package/types/src/data-chart/src/analyze.d.ts +1 -1
- package/types/src/data-chart/src/analyze.d.ts.map +1 -1
- package/types/src/data-chart/src/components/area.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/area.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/bar.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/bar.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/card.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/card.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/empty.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/funnel.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/funnel.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/line.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/line.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/pie.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/pie.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/radar.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/radar.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/scatter-simple.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/scatter-simple.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/scatter.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/scatter.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/components/table.vue.d.ts +1 -1
- package/types/src/data-chart/src/components/table.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/data-chart.vue.d.ts +2 -2
- package/types/src/data-chart/src/data-chart.vue.d.ts.map +1 -1
- package/types/src/data-chart/src/utils/config.d.ts +1 -1
- package/types/src/data-chart/src/utils/config.d.ts.map +1 -1
- package/types/src/data-chart/src/utils/safe-eval.d.ts +9 -0
- package/types/src/data-chart/src/utils/safe-eval.d.ts.map +1 -0
- package/types/src/data-chart/src/utils/types.d.ts +68 -0
- package/types/src/data-chart/src/utils/types.d.ts.map +1 -0
- package/types/src/data-chart/src/utils/useCharts.d.ts +5 -5
- package/types/src/data-chart/src/utils/useCharts.d.ts.map +1 -1
- package/types/src/file-upload/src/file-upload.vue.d.ts +5 -5
- package/types/src/file-upload/src/file-upload.vue.d.ts.map +1 -1
- package/types/src/fixed-action-bar/index.d.ts +3 -3
- package/types/src/fixed-action-bar/src/fixed-action-bar.vue.d.ts +1 -1
- package/types/src/fixed-action-bar/src/fixed-action-bar.vue.d.ts.map +1 -1
- package/types/src/image-upload/src/image-upload.vue.d.ts +6 -6
- package/types/src/image-upload/src/image-upload.vue.d.ts.map +1 -1
- package/types/src/photo-crop-tool/src/photo-crop-tool.vue.d.ts.map +1 -1
- package/types/src/subject-action/index.d.ts +11 -11
- package/types/src/subject-action/index.d.ts.map +1 -1
- package/types/src/subject-action/src/subject-action.vue.d.ts +10 -10
- package/types/src/subject-action/src/subject-action.vue.d.ts.map +1 -1
- package/types/src/subject-layout/index.d.ts +1 -1
- package/types/src/subject-layout/index.d.ts.map +1 -1
- package/types/src/subject-layout/src/subject-layout.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/SubjectPageEnd.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/SubjectRichText.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/subject-blank-fill.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/subject-scale.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/subject-single.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/components/subject-text-fill.vue.d.ts.map +1 -1
- package/types/src/subject-list/src/subject-list.vue.d.ts.map +1 -1
- package/types/src/subject-type/index.d.ts +1 -1
- package/types/src/subject-type/index.d.ts.map +1 -1
- package/types/src/subject-type/src/subject-type.vue.d.ts.map +1 -1
- package/types/tsconfig.tsbuildinfo +1 -1
- package/es/index.css +0 -83
- package/lib/index.css +0 -83
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-scale.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-scale.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { ElMessage } from 'element-plus'\nimport SubjectAction from '../../../subject-action/src/subject-action.vue'\nimport SubjectLayout from '../../../subject-layout/src/subject-layout.vue'\nimport TinyMceEditor from '../../../tiny-mce-editor/src/tiny-mce-editor.vue'\n\ndefineOptions({\n name: 'QxsSubjectScale',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n answerList?: any\n analysis?: string\n rowTitle?: string\n isEdit: boolean\n isSet: boolean\n scaleQuestionList?: any\n examRichTextContent?: string\n examAnswerRelationType?: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add'])\n\nconst attrs = useAttrs()\n\nconst answers = ref<{\n title: string\n}[]>([{\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}])\n\nconst title = ref('')\nconst analysis = ref('')\nconst rowTitle = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst scaleQuestionList = ref<string[]>([])\nconst span = computed(() => Math.ceil(24 / (answers.value.length + 1)))\nfunction addAnswer() {\n if (answers.value.length === 5) {\n return\n }\n answers.value.push({\n title: '',\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n let msg = ''\n answers.value.forEach((v, i) => {\n if (!v.title) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n })\n\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n if (!rowTitle.value) {\n ElMessage.error('行标题不能为空!')\n return\n }\n\n scaleQuestionList.value = rowTitle.value.split('\\n').filter(i => i)\n\n emits('save', {\n title: title.value,\n answers: answers.value,\n analysis: analysis.value,\n scaleQuestionList: scaleQuestionList.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.scaleQuestionList) {\n scaleQuestionList.value = props.scaleQuestionList\n rowTitle.value = scaleQuestionList.value.join('\\n')\n }\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\n\nonMounted(init)\nconst ns = useNamespace('subject-scale')\n</script>\n\n<template>\n <div :class=\"ns.e('scale-exam')\">\n <SubjectLayout :show-edit=\"isEdit\">\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">{{ orderIndex + 1 }}.{{ title }}(量表题)</span>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" class=\"rich-text\"/>\n </div>\n </div>\n <div class=\"answer-radio flex-col\">\n <el-row style=\"padding: 10px 0;\">\n <el-col :span=\"span\" />\n <el-col\n v-for=\"item in answers\"\n :key=\"item.title\"\n class=\"flex flex-center\"\n :span=\"span\"\n >\n <span>{{ item.title }}</span>\n </el-col>\n </el-row>\n <el-row\n v-for=\"item in scaleQuestionList\"\n :key=\"item\"\n style=\"padding: 10px 0;\"\n >\n <el-col :span=\"span\" class=\"flex flex-center\">\n <span>{{ item }}</span>\n </el-col>\n <el-col\n v-for=\"i in answers.length\"\n :key=\"i\"\n class=\"radio-item flex flex-center\"\n :span=\"span\"\n >\n <el-radio :disabled=\"true\" />\n </el-col>\n </el-row>\n </div>\n </div>\n </template>\n <template #edit>\n <div class=\"flex\" :class=\"[{ 'margin-bottom': showRichText }]\">\n <div class=\"label flex flex-justify-center\">\n <span>题目:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"【量表题】请输入问题\"\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"answer flex\">\n <div class=\"label flex flex-justify-center\">\n <span>行标题:</span>\n </div>\n <div class=\"flex\">\n <el-input\n v-model=\"rowTitle\"\n type=\"textarea\"\n placeholder=\"请输入行标题\"\n style=\"width: 160px;\"\n :rows=\"10\"\n />\n <div class=\"answer-list flex-col\">\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <span class=\"order\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n :maxlength=\"10\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <!-- <PlusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n <MinusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n /> -->\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n </div>\n </div>\n </div>\n </div>\n <div class=\"flex\" style=\"margin-bottom: 20px;\">\n <div class=\"label flex flex-justify-center\">\n <span>解析:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"analysis\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入题目解析\"\n />\n </div>\n </div>\n <div v-if=\"showRichText\" class=\"margin-bottom flex\">\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor v-model:model-value=\"richText\" v-bind=\"attrs\" style=\"width: 100%;\" />\n <div class=\"flex flex-justify-end\">\n <el-link\n type=\"danger\"\n @click=\"deleteRichText\"\n >\n 删除富文本\n </el-link>\n </div>\n </div>\n </div>\n </template>\n <SubjectAction\n v-if=\"showAction\"\n :is-edit=\"isEdit\"\n :is-set=\"isSet\"\n :showOtherOption=\"false\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\n @move-up=\"emits('move', 'up')\"\n @move-down=\"emits('move', 'down')\"\n @delete=\"emits('delete')\"\n @save=\"save\"\n @edit=\"emits('edit')\"\n @add=\"(type: any) => emits('add', type)\"\n @onShowRichText=\"showRichText = true\"\n />\n </SubjectLayout>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answers","ref","title","analysis","rowTitle","showRichText","richText","scaleQuestionList","span","computed","Math","ceil","value","length","addAnswer","push","deleteRichText","save","ElMessage","error","msg","forEach","v","i","String","fromCharCode","split","filter","examRichTextContent","onMounted","answerList","join","ns","useNamespace","index","splice"],"mappings":"4kEAWA,MAAMA,EAAQC,EAcRC,EAAQC,EAERC,EAAQC,IAERC,EAAUC,EAEX,CAAC,CACJC,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,MAGHA,EAAQD,EAAI,IACZE,GAAWF,EAAI,IACfG,GAAWH,EAAI,IACfI,GAAeJ,GAAI,GACnBK,GAAWL,EAAI,IACfM,GAAoBN,EAAc,IAClCO,GAAOC,GAAS,IAAMC,KAAKC,KAAK,IAAMX,EAAQY,MAAMC,OAAS,MACnE,SAASC,KACsB,IAAzBd,EAAQY,MAAMC,QAGlBb,EAAQY,MAAMG,KAAK,CACjBb,MAAO,IACR,CAUH,SAASc,KACPX,GAAaO,OAAQ,EACrBN,GAASM,MAAQ,EAAA,CAGnB,SAASK,KACH,IAACf,EAAMU,MAET,YADAM,EAAUC,MAAM,aAGlB,IAAIC,EAAM,GACVpB,EAAQY,MAAMS,SAAQ,CAACC,EAAGC,KACnBD,EAAEpB,QACLkB,GAAO,KAAKI,OAAOC,aAAa,GAAKF,SAAE,IAIvCH,EACFF,EAAUC,MAAMC,GAIbhB,GAASQ,OAKIL,GAAAK,MAAQR,GAASQ,MAAMc,MAAM,MAAMC,WAAYJ,IAEjE3B,EAAM,OAAQ,CACZM,MAAOA,EAAMU,MACbZ,QAASA,EAAQY,MACjBT,SAAUA,GAASS,MACnBL,kBAAmBA,GAAkBK,MACrCgB,oBAAqBvB,GAAaO,MAAQN,GAASM,MAAQ,MAX3DM,EAAUC,MAAM,WAYjB,CA0BHU,GAvBA,WACMnC,EAAMQ,QACRA,EAAMU,MAAQlB,EAAMQ,OAGlBR,EAAMoC,YAAcpC,EAAMoC,WAAWjB,SACvCb,EAAQY,MAAQlB,EAAMoC,YAGpBpC,EAAMS,WACRA,GAASS,MAAQlB,EAAMS,UAGrBT,EAAMa,oBACRA,GAAkBK,MAAQlB,EAAMa,kBAChCH,GAASQ,MAAQL,GAAkBK,MAAMmB,KAAK,OAE5CrC,EAAMkC,sBACRtB,GAASM,MAAQlB,EAAMkC,oBACvBvB,GAAaO,OAAQ,EACvB,IAII,MAAAoB,GAAKC,EAAa,oiFArExB,SAAsBC,GAChBlC,EAAQY,MAAMC,OAAS,GAGnBb,EAAAY,MAAMuB,OAAOD,EAAO,EAAC"}
|
1
|
+
{"version":3,"file":"subject-scale.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-scale.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { ElMessage } from 'element-plus'\nimport SubjectAction from '../../../subject-action/src/subject-action.vue'\nimport SubjectLayout from '../../../subject-layout/src/subject-layout.vue'\nimport TinyMceEditor from '../../../tiny-mce-editor/src/tiny-mce-editor.vue'\n\ndefineOptions({\n name: 'QxsSubjectScale',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n answerList?: any\n analysis?: string\n rowTitle?: string\n isEdit: boolean\n isSet: boolean\n scaleQuestionList?: any\n examRichTextContent?: string\n examAnswerRelationType?: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add'])\n\nconst attrs = useAttrs()\n\nconst answers = ref<{\n title: string\n}[]>([{\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}, {\n title: '',\n}])\n\nconst title = ref('')\nconst analysis = ref('')\nconst rowTitle = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst scaleQuestionList = ref<string[]>([])\nconst span = computed(() => Math.ceil(24 / (answers.value.length + 1)))\nfunction addAnswer() {\n if (answers.value.length === 5) {\n return\n }\n answers.value.push({\n title: '',\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n let msg = ''\n answers.value.forEach((v, i) => {\n if (!v.title) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n })\n\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n if (!rowTitle.value) {\n ElMessage.error('行标题不能为空!')\n return\n }\n\n scaleQuestionList.value = rowTitle.value.split('\\n').filter(i => i)\n\n emits('save', {\n title: title.value,\n answers: answers.value,\n analysis: analysis.value,\n scaleQuestionList: scaleQuestionList.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.scaleQuestionList) {\n scaleQuestionList.value = props.scaleQuestionList\n rowTitle.value = scaleQuestionList.value.join('\\n')\n }\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\n\nonMounted(init)\nconst ns = useNamespace('subject-scale')\n</script>\n\n<template>\n <div :class=\"ns.e('scale-exam')\">\n <SubjectLayout :show-edit=\"isEdit\">\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">{{ orderIndex + 1 }}.{{ title }}(量表题)</span>\n <div v-if=\"showRichText\">\n <div\n class=\"rich-text\"\n v-html=\"richText\"\n />\n </div>\n </div>\n <div class=\"answer-radio 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\n :span=\"span\"\n class=\"flex flex-center\"\n >\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\n class=\"flex\"\n :class=\"[{ 'margin-bottom': showRichText }]\"\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=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"【量表题】请输入问题\"\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"answer flex\">\n <div class=\"label flex flex-justify-center\">\n <span>行标题:</span>\n </div>\n <div class=\"flex\">\n <el-input\n v-model=\"rowTitle\"\n type=\"textarea\"\n placeholder=\"请输入行标题\"\n style=\"width: 160px;\"\n :rows=\"10\"\n />\n <div class=\"answer-list flex-col\">\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <span class=\"order\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n :maxlength=\"10\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <!-- <PlusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n <MinusCircleOutlined\n class=\"icon\"\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n /> -->\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: answers.length === 5 }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n </div>\n </div>\n </div>\n </div>\n <div\n class=\"flex\"\n style=\"margin-bottom: 20px;\"\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\n v-if=\"showRichText\"\n class=\"margin-bottom flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor\n v-model:model-value=\"richText\"\n v-bind=\"attrs\"\n style=\"width: 100%;\"\n />\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 :show-other-option=\"false\"\n :exam-answer-relation-type=\"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 @on-show-rich-text=\"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":"4kEAWA,MAAMA,EAAQC,EAcRC,EAAQC,EAERC,EAAQC,IAERC,EAAUC,EAEX,CAAC,CACJC,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,IACN,CACDA,MAAO,MAGHA,EAAQD,EAAI,IACZE,GAAWF,EAAI,IACfG,GAAWH,EAAI,IACfI,GAAeJ,GAAI,GACnBK,GAAWL,EAAI,IACfM,GAAoBN,EAAc,IAClCO,GAAOC,GAAS,IAAMC,KAAKC,KAAK,IAAMX,EAAQY,MAAMC,OAAS,MACnE,SAASC,KACsB,IAAzBd,EAAQY,MAAMC,QAGlBb,EAAQY,MAAMG,KAAK,CACjBb,MAAO,IACR,CAUH,SAASc,KACPX,GAAaO,OAAQ,EACrBN,GAASM,MAAQ,EAAA,CAGnB,SAASK,KACH,IAACf,EAAMU,MAET,YADAM,EAAUC,MAAM,aAGlB,IAAIC,EAAM,GACVpB,EAAQY,MAAMS,SAAQ,CAACC,EAAGC,KACnBD,EAAEpB,QACLkB,GAAO,KAAKI,OAAOC,aAAa,GAAKF,SAAE,IAIvCH,EACFF,EAAUC,MAAMC,GAIbhB,GAASQ,OAKIL,GAAAK,MAAQR,GAASQ,MAAMc,MAAM,MAAMC,WAAYJ,IAEjE3B,EAAM,OAAQ,CACZM,MAAOA,EAAMU,MACbZ,QAASA,EAAQY,MACjBT,SAAUA,GAASS,MACnBL,kBAAmBA,GAAkBK,MACrCgB,oBAAqBvB,GAAaO,MAAQN,GAASM,MAAQ,MAX3DM,EAAUC,MAAM,WAYjB,CA0BHU,GAvBA,WACMnC,EAAMQ,QACRA,EAAMU,MAAQlB,EAAMQ,OAGlBR,EAAMoC,YAAcpC,EAAMoC,WAAWjB,SACvCb,EAAQY,MAAQlB,EAAMoC,YAGpBpC,EAAMS,WACRA,GAASS,MAAQlB,EAAMS,UAGrBT,EAAMa,oBACRA,GAAkBK,MAAQlB,EAAMa,kBAChCH,GAASQ,MAAQL,GAAkBK,MAAMmB,KAAK,OAE5CrC,EAAMkC,sBACRtB,GAASM,MAAQlB,EAAMkC,oBACvBvB,GAAaO,OAAQ,EACvB,IAII,MAAAoB,GAAKC,EAAa,oiFArExB,SAAsBC,GAChBlC,EAAQY,MAAMC,OAAS,GAGnBb,EAAAY,MAAMuB,OAAOD,EAAO,EAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{ElCheckbox as e,ElRadio as l,ElInput as t,ElSelect as s,ElOption as a,ElIcon as n,ElLink as i,ElDialog as o,ElButton as r,ElMessage as u}from"element-plus/es";import"element-plus/es/components/base/style/index";import"element-plus/es/components/dialog/style/index";import"element-plus/es/components/button/style/index";import"element-plus/es/components/link/style/index";import"element-plus/es/components/icon/style/index";import"element-plus/es/components/select/style/index";import"element-plus/es/components/option/style/index";import"element-plus/es/components/input/style/index";import"element-plus/es/components/radio/style/index";import"element-plus/es/components/checkbox/style/index";import{defineComponent as d,useAttrs as m,ref as p,computed as c,watch as v,onMounted as y,createElementBlock as f,openBlock as x,normalizeClass as w,unref as h,createVNode as C,createSlots as g,withCtx as b,createBlock as k,createCommentVNode as S,createElementVNode as A,createTextVNode as V,toDisplayString as T,Fragment as q,renderList as R,isRef as j,mergeProps as I}from"vue";import{CirclePlus as _,Remove as E}from"@element-plus/icons-vue";import{useNamespace as U}from"@qxs-bns/hooks";import K from"../../../subject-action/src/subject-action.vue.mjs";import B from"../../../subject-layout/src/subject-layout.vue.mjs";import L from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";import{setGuid as $}from"@qxs-bns/utils";import"element-plus/es/components/message/style/index";const N={class:"preview"},O={class:"title"},z={key:0},M={key:1},D={key:0},H=["innerHTML"],Q={class:"preview-answer"},F={class:"order"},G={class:"order"},J={style:{flex:"1"}},P={class:"margin-bottom flex flex-items-center"},W={class:"margin-bottom answer-list"},X={class:"label flex flex-justify-center"},Y={key:0,class:"margin-bottom flex flex-items-center"},Z={style:{flex:"1"}},ee={key:1,class:"flex"},le={style:{flex:"1"}},te={key:2,class:"margin-bottom flex"},se={style:{flex:"1"}},ae={class:"flex flex-justify-end"};var ne=d({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},customId:{type:Number,required:!1},examId:{type:Number,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(d,{emit:ne}){const ie=d,oe=ne,re=m(),ue=p(0),de=p(ie.isKey),me=p(1),pe=p(ie.examAnswerRelationType),ce=p([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),ve=p(2),ye=p(""),fe=p(""),xe=p(!1),we=p(""),he=p(0),Ce=p(!1),ge=p(""),be=c((()=>"single"===ie.type?"单选题":"multiple"===ie.type?"多选题":"排序题")),ke=p([]),Se=c((()=>{const e=[];for(let l=ce.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function Ae(){ie.isSave||ce.value.push({title:"",isCorrect:!1,customAnswerId:$()})}function Ve(){xe.value=!1,we.value=""}function Te(){if(!ye.value)return void u.error("题目标题不能为空!");if(!me.value)return void u.error("请选择答题设置");let e="",l=!1,t=0;if("multiple"===ie.type||"single"===ie.type?ce.value.forEach(((s,a)=>{s.title?.trim()||(e+=`选项${String.fromCharCode(65+a)}未填写。`),s.isCorrect&&(l=!0,t++),s.relationType=s.resultItem?1:s.answerRelations?.length?2:null})):"sort"===ie.type&&ke.value.length&&(l=!0),e)return void u.error(e);if(new Set(ce.value.map((e=>e.title))).size===ce.value.length){if("multiple"===ie.type){if(1===t)return void u.error("请至少设置两个支持选项");if(l&&t<ve.value)return void u.error("至少选几项与支持选项数不符")}2!==me.value&&3!==me.value||l?oe("save",{title:ye.value,answers:ce.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:ke.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:fe.value,isSetCorrectAnswer:l,leastAnswerCount:ve.value,examRichTextContent:xe.value?we.value:"",examAnswerRelationType:pe.value,isKey:de.value,answerCheckType:me.value}):u.error("请设置支持选项")}else u.error("选项不能重复")}function qe(){ce.value[ue.value].resultItem=ge.value||"",Ce.value=!1}function Re(){Ce.value=!1,ge.value=""}function je(e){de.value=e}function Ie(e){me.value=e}function _e(e,l){oe("add",e,l?ie.examAnswerRelationType:null)}v((()=>ie.isEdit),(()=>{ie.isEdit&&(he.value=(new Date).getTime())}));const Ee=c((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),Ue=U("subject-single");return y((function(){if(ie.title&&(ye.value=ie.title),ie.answerCheckType&&(me.value=ie.answerCheckType),ie.isKey&&(de.value=ie.isKey),ie.examAnswerRelationType&&(pe.value=ie.examAnswerRelationType),ie.answerList&&ie.answerList.length&&(ce.value=ie.answerList),ie.leastAnswerCount&&(ve.value=ie.leastAnswerCount),ie.examExpand&&ie.examExpand){const e=ie.examExpand.split(",");ke.value=e.map((e=>{const l=ie.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}ie.analysis&&(fe.value=ie.analysis),ie.examRichTextContent&&(we.value=ie.examRichTextContent,xe.value=!0)})),(u,d)=>{const m=e,p=l,c=t,v=a,y=s,U=n,ne=i,he=r,Ke=o;return x(),f("div",{class:w(h(Ue).e("single-exam"))},[C(B,{"show-edit":u.isEdit},g({preview:b((()=>[A("div",N,[A("div",null,[A("span",O,[V(T(u.orderIndex+1)+"."+T(h(ye))+" ",1),"single"===u.type?(x(),f("span",z,"(单选题)")):["multiple","sort"].includes(u.type)?(x(),f("span",M," ("+T(h(be))+T(h(ve)?`至少选${h(ve)}项${"sort"===u.type?"并排序":""}`:"")+") ",1)):S("v-if",!0)])]),h(xe)?(x(),f("div",D,[A("div",{innerHTML:h(we),class:"rich-text"},null,8,H)])):S("v-if",!0),A("div",Q,["sort"===u.type?(x(!0),f(q,{key:0},R(h(ce),((e,l)=>(x(),k(m,{key:l,class:"radio",disabled:!0},{default:b((()=>[A("span",F,T(String.fromCharCode(65+l))+". ",1),V(" "+T(e.title),1)])),_:2},1024)))),128)):(x(!0),f(q,{key:1},R(h(ce),((e,l)=>(x(),k(p,{key:l,class:"radio",value:"disabled",disabled:""},{default:b((()=>[A("span",G,T(String.fromCharCode(65+l))+". ",1),V(" "+T(e.title)+" "+T(e.isCorrect?"(支持选项)":"")+" "+T(1===h(pe)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+T(2===h(pe)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:b((()=>[u.showAction?(x(),k(K,{key:0,"is-edit":u.isEdit,"is-set":u.isSet,isKey:h(de),showOtherOption:"multiple"===ie.type||"single"===ie.type,examAnswerRelationType:ie.examAnswerRelationType,answerCheckType:h(me),onMoveUp:d[5]||(d[5]=e=>oe("move","up")),onMoveDown:d[6]||(d[6]=e=>oe("move","down")),onDelete:d[7]||(d[7]=e=>oe("delete")),onSave:Te,onEdit:d[8]||(d[8]=e=>oe("edit")),onAdd:_e,onOnShowRichText:d[9]||(d[9]=e=>xe.value=!0),onSetKey:je,onSetAnswerSetting:Ie},null,8,["is-edit","is-set","isKey","showOtherOption","examAnswerRelationType","answerCheckType"])):S("v-if",!0)])),_:2},[u.isEdit?{name:"edit",fn:b((()=>[A("div",{class:w(["flex",[{"margin-bottom":h(xe)}]])},[d[12]||(d[12]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"题目:")],-1)),A("div",J,[C(c,{modelValue:h(ye),"onUpdate:modelValue":d[0]||(d[0]=e=>j(ye)?ye.value=e:null),type:"textarea",rows:2,placeholder:`【${h(be)}】请输入问题`,disabled:u.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),A("div",P,[d[13]||(d[13]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"设置:")],-1)),["multiple","sort"].includes(u.type)?(x(),k(y,{key:0,modelValue:h(ve),"onUpdate:modelValue":d[1]||(d[1]=e=>j(ve)?ve.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:u.isSave},{default:b((()=>[(x(!0),f(q,null,R(h(Se),(e=>(x(),k(v,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):S("v-if",!0)]),A("div",W,[(x(!0),f(q,null,R(h(ce),((e,l)=>(x(),f("div",{key:l,class:"answer-item flex flex-items-center"},[A("span",X,T(String.fromCharCode(65+l))+".",1),C(c,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+l)}`,disabled:u.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(u.type)?(x(),k(m,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:w([{"is-correct":e.isCorrect}]),disabled:u.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===ie.type?(l&&ce.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===ie.type&&(e.isCorrect=l)}(e,l)},{default:b((()=>[...d[14]||(d[14]=[V(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):S("v-if",!0),C(U,{class:"icon"},{default:b((()=>[C(h(_),{class:w([{disabled:u.isSave}]),onClick:Ae},null,8,["class"])])),_:1}),C(U,{class:"icon"},{default:b((()=>[C(h(E),{class:w([{disabled:h(ce).length<3||u.isSave}]),onClick:e=>function(e){ce.value.length<3||ie.isSave||ce.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024),1===h(pe)&&"sort"!==u.type?(x(),k(ne,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=l,ue.value=t,ge.value=ce.value[t].resultItem||"",void(Ce.value=!0);var t}},{default:b((()=>[A("span",null,T(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):S("v-if",!0),2===h(pe)&&"sort"!==u.type?(x(),k(ne,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||$(),oe("setRelation",ie.customId,e)}(e)},{default:b((()=>[A("span",null,T(e.answerRelations?.length?`关联了${h(Ee)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):S("v-if",!0)])))),128))]),"sort"===u.type?(x(),f("div",Y,[d[15]||(d[15]=A("div",{class:"label flex flex-justify-end"},[A("span",null,"排序答案:")],-1)),A("div",Z,[C(y,{modelValue:h(ke),"onUpdate:modelValue":d[2]||(d[2]=e=>j(ke)?ke.value=e:null),multiple:"",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:b((()=>[(x(!0),f(q,null,R(h(ce),((e,l)=>(x(),k(v,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):S("v-if",!0),u.showAnalysis?(x(),f("div",ee,[d[16]||(d[16]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"解析:")],-1)),A("div",le,[C(c,{modelValue:h(fe),"onUpdate:modelValue":d[3]||(d[3]=e=>j(fe)?fe.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):S("v-if",!0),h(xe)?(x(),f("div",te,[d[18]||(d[18]=A("div",{class:"label flex flex-justify-center"},[A("span",null,"富文本:")],-1)),A("div",se,[C(L,I({"model-value":h(we),"onUpdate:modelValue":d[4]||(d[4]=e=>j(we)?we.value=e:null)},h(re),{style:{width:"100%"}}),null,16,["model-value"]),A("div",ae,[C(ne,{type:"danger",onClick:Ve},{default:b((()=>d[17]||(d[17]=[V(" 删除富文本 ")]))),_:1})])])])):S("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),C(Ke,{modelValue:h(Ce),"onUpdate:modelValue":d[11]||(d[11]=e=>j(Ce)?Ce.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:b((()=>[C(he,{class:"customize-button",type:"primary",plain:"",onClick:Re},{default:b((()=>d[19]||(d[19]=[V(" 取消 ")]))),_:1}),C(he,{class:"customize-button",type:"primary",plain:"",onClick:qe},{default:b((()=>d[20]||(d[20]=[V(" 保存 ")]))),_:1})])),default:b((()=>[(x(),k(L,I({key:h(ue),"model-value":h(ge),"onUpdate:modelValue":d[10]||(d[10]=e=>j(ge)?ge.value=e:null)},h(re),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});export{ne as default};
|
1
|
+
import{ElCheckbox as e,ElRadio as l,ElInput as t,ElSelect as s,ElOption as a,ElIcon as n,ElLink as i,ElDialog as o,ElButton as r,ElMessage as u}from"element-plus/es";import"element-plus/es/components/base/style/index";import"element-plus/es/components/dialog/style/index";import"element-plus/es/components/button/style/index";import"element-plus/es/components/link/style/index";import"element-plus/es/components/icon/style/index";import"element-plus/es/components/select/style/index";import"element-plus/es/components/option/style/index";import"element-plus/es/components/input/style/index";import"element-plus/es/components/radio/style/index";import"element-plus/es/components/checkbox/style/index";import{defineComponent as d,useAttrs as m,ref as p,computed as c,watch as v,onMounted as y,createElementBlock as f,openBlock as x,normalizeClass as w,unref as h,createVNode as C,createSlots as g,withCtx as b,createBlock as k,createCommentVNode as S,createElementVNode as V,createTextVNode as A,toDisplayString as q,Fragment as T,renderList as j,isRef as R,mergeProps as I}from"vue";import{CirclePlus as _,Remove as E}from"@element-plus/icons-vue";import{useNamespace as U}from"@qxs-bns/hooks";import{setGuid as B}from"@qxs-bns/utils";import L from"../../../subject-action/src/subject-action.vue.mjs";import $ from"../../../subject-layout/src/subject-layout.vue.mjs";import K from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";import"element-plus/es/components/message/style/index";const N={class:"preview"},z={class:"title"},M={key:0},D={key:1},H={key:0},O=["innerHTML"],Q={class:"preview-answer"},F={class:"order"},G={class:"order"},J={style:{flex:"1"}},P={class:"margin-bottom flex flex-items-center"},W={class:"margin-bottom answer-list"},X={class:"label flex flex-justify-center"},Y={key:0,class:"margin-bottom flex flex-items-center"},Z={style:{flex:"1"}},ee={key:1,class:"flex"},le={style:{flex:"1"}},te={key:2,class:"margin-bottom flex"},se={style:{flex:"1"}},ae={class:"flex flex-justify-end"};var ne=d({name:"QxsSubjectSingle",__name:"subject-single",props:{orderIndex:{type:Number,required:!0},title:{type:String,required:!1},isSave:{type:Boolean,required:!0},showAction:{type:Boolean,required:!1},type:{type:String,required:!0},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},answerList:{type:null,required:!1},leastAnswerCount:{type:Number,required:!1},analysis:{type:String,required:!1},examExpand:{type:String,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1},customId:{type:Number,required:!1},examId:{type:Number,required:!1},isKey:{type:Boolean,required:!0},answerCheckType:{type:Number,required:!0}},emits:["move","save","delete","edit","add","setRelation"],setup(d,{emit:ne}){const ie=d,oe=ne,re=m(),ue=p(0),de=p(ie.isKey),me=p(1),pe=p(ie.examAnswerRelationType),ce=p([{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}]),ve=p(2),ye=p(""),fe=p(""),xe=p(!1),we=p(""),he=p(0),Ce=p(!1),ge=p(""),be=c((()=>"single"===ie.type?"单选题":"multiple"===ie.type?"多选题":"排序题")),ke=p([]),Se=c((()=>{const e=[];for(let l=ce.value.length;l>1;l--)e.push({label:`至少选择${l}项`,value:l});return e.reverse()}));function Ve(){ie.isSave||ce.value.push({title:"",isCorrect:!1,customAnswerId:B()})}function Ae(){xe.value=!1,we.value=""}function qe(){if(!ye.value)return void u.error("题目标题不能为空!");if(!me.value)return void u.error("请选择答题设置");let e="",l=!1,t=0;if("multiple"===ie.type||"single"===ie.type?ce.value.forEach(((s,a)=>{s.title?.trim()||(e+=`选项${String.fromCharCode(65+a)}未填写。`),s.isCorrect&&(l=!0,t++),s.relationType=s.resultItem?1:s.answerRelations?.length?2:null})):"sort"===ie.type&&ke.value.length&&(l=!0),e)return void u.error(e);if(new Set(ce.value.map((e=>e.title))).size===ce.value.length){if("multiple"===ie.type){if(1===t)return void u.error("请至少设置两个支持选项");if(l&&t<ve.value)return void u.error("至少选几项与支持选项数不符")}2!==me.value&&3!==me.value||l?oe("save",{title:ye.value,answers:ce.value.map(((e,l)=>({...e,orderIndex:l+1}))),examExpand:ke.value.map((e=>e.charCodeAt(0)-65+1)).join(","),analysis:fe.value,isSetCorrectAnswer:l,leastAnswerCount:ve.value,examRichTextContent:xe.value?we.value:"",examAnswerRelationType:pe.value,isKey:de.value,answerCheckType:me.value}):u.error("请设置支持选项")}else u.error("选项不能重复")}function Te(){ce.value[ue.value].resultItem=ge.value||"",Ce.value=!1}function je(){Ce.value=!1,ge.value=""}function Re(e){de.value=e}function Ie(e){me.value=e}function _e(e,l){oe("add",e,l?ie.examAnswerRelationType:null)}v((()=>ie.isEdit),(()=>{ie.isEdit&&(he.value=(new Date).getTime())}));const Ee=c((()=>e=>{let l=0;return e.forEach((e=>{e.relationAnswers&&(l+=e.relationAnswers.length)})),l})),Ue=U("subject-single");return y((function(){if(ie.title&&(ye.value=ie.title),ie.answerCheckType&&(me.value=ie.answerCheckType),ie.isKey&&(de.value=ie.isKey),ie.examAnswerRelationType&&(pe.value=ie.examAnswerRelationType),ie.answerList&&ie.answerList.length&&(ce.value=ie.answerList),ie.leastAnswerCount&&(ve.value=ie.leastAnswerCount),ie.examExpand&&ie.examExpand){const e=ie.examExpand.split(",");ke.value=e.map((e=>{const l=ie.answerList.find((l=>l.answerId?.toString()===e));return l?String.fromCharCode(65+l.orderIndex-1):e})).filter(Boolean)}ie.analysis&&(fe.value=ie.analysis),ie.examRichTextContent&&(we.value=ie.examRichTextContent,xe.value=!0)})),(u,d)=>{const m=e,p=l,c=t,v=a,y=s,U=n,ne=i,he=r,Be=o;return x(),f("div",{class:w(h(Ue).e("single-exam"))},[C($,{"show-edit":u.isEdit},g({preview:b((()=>[V("div",N,[V("div",null,[V("span",z,[A(q(u.orderIndex+1)+"."+q(h(ye))+" ",1),"single"===u.type?(x(),f("span",M,"(单选题)")):["multiple","sort"].includes(u.type)?(x(),f("span",D," ("+q(h(be))+q(h(ve)?`至少选${h(ve)}项${"sort"===u.type?"并排序":""}`:"")+") ",1)):S("v-if",!0)])]),h(xe)?(x(),f("div",H,[V("div",{class:"rich-text",innerHTML:h(we)},null,8,O)])):S("v-if",!0),V("div",Q,["sort"===u.type?(x(!0),f(T,{key:0},j(h(ce),((e,l)=>(x(),k(m,{key:l,class:"radio",disabled:!0},{default:b((()=>[V("span",F,q(String.fromCharCode(65+l))+". ",1),A(" "+q(e.title),1)])),_:2},1024)))),128)):(x(!0),f(T,{key:1},j(h(ce),((e,l)=>(x(),k(p,{key:l,class:"radio",value:"disabled",disabled:""},{default:b((()=>[V("span",G,q(String.fromCharCode(65+l))+". ",1),A(" "+q(e.title)+" "+q(e.isCorrect?"(支持选项)":"")+" "+q(1===h(pe)?e.resultItem?"(已设置结果项)":"(未设置结果项)":"")+" "+q(2===h(pe)?e.answerRelations?.length?"(已设置关联)":"(未设置关联)":""),1)])),_:2},1024)))),128))])])])),default:b((()=>[u.showAction?(x(),k(L,{key:0,"is-edit":u.isEdit,"is-set":u.isSet,"is-key":h(de),"show-other-option":"multiple"===ie.type||"single"===ie.type,"exam-answer-relation-type":ie.examAnswerRelationType,"answer-check-type":h(me),onMoveUp:d[5]||(d[5]=e=>oe("move","up")),onMoveDown:d[6]||(d[6]=e=>oe("move","down")),onDelete:d[7]||(d[7]=e=>oe("delete")),onSave:qe,onEdit:d[8]||(d[8]=e=>oe("edit")),onAdd:_e,onOnShowRichText:d[9]||(d[9]=e=>xe.value=!0),onSetKey:Re,onSetAnswerSetting:Ie},null,8,["is-edit","is-set","is-key","show-other-option","exam-answer-relation-type","answer-check-type"])):S("v-if",!0)])),_:2},[u.isEdit?{name:"edit",fn:b((()=>[V("div",{class:w(["flex",[{"margin-bottom":h(xe)}]])},[d[12]||(d[12]=V("div",{class:"label flex flex-justify-center"},[V("span",null,"题目:")],-1)),V("div",J,[C(c,{modelValue:h(ye),"onUpdate:modelValue":d[0]||(d[0]=e=>R(ye)?ye.value=e:null),type:"textarea",rows:2,placeholder:`【${h(be)}】请输入问题`,disabled:u.isSave,"show-word-limit":"",maxlength:"200",class:"margin-bottom"},null,8,["modelValue","placeholder","disabled"])])],2),V("div",P,[d[13]||(d[13]=V("div",{class:"label flex flex-justify-center"},[V("span",null,"设置:")],-1)),["multiple","sort"].includes(u.type)?(x(),k(y,{key:0,modelValue:h(ve),"onUpdate:modelValue":d[1]||(d[1]=e=>R(ve)?ve.value=e:null),style:{width:"150px"},placeholder:"至少选择几项",disabled:u.isSave},{default:b((()=>[(x(!0),f(T,null,j(h(Se),(e=>(x(),k(v,{key:e.value,value:e.value,label:e.label},null,8,["value","label"])))),128))])),_:1},8,["modelValue","disabled"])):S("v-if",!0)]),V("div",W,[(x(!0),f(T,null,j(h(ce),((e,l)=>(x(),f("div",{key:l,class:"answer-item flex flex-items-center"},[V("span",X,q(String.fromCharCode(65+l))+".",1),C(c,{modelValue:e.title,"onUpdate:modelValue":l=>e.title=l,class:"input","show-word-limit":"",maxlength:"100",placeholder:`选项${String.fromCharCode(65+l)}`,disabled:u.isSave},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"]),["single","multiple"].includes(u.type)?(x(),k(m,{key:0,modelValue:e.isCorrect,"onUpdate:modelValue":l=>e.isCorrect=l,class:w([{"is-correct":e.isCorrect}]),disabled:u.isSave,style:{"margin-left":"10px"},onChange:l=>function(e,l){"single"===ie.type?(l&&ce.value.forEach((l=>{l!==e&&(l.isCorrect=!1)})),e.isCorrect=l):"multiple"===ie.type&&(e.isCorrect=l)}(e,l)},{default:b((()=>[...d[14]||(d[14]=[A(" 支持选项 ")])])),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled","onChange"])):S("v-if",!0),C(U,{class:"icon"},{default:b((()=>[C(h(_),{class:w([{disabled:u.isSave}]),onClick:Ve},null,8,["class"])])),_:1}),C(U,{class:"icon"},{default:b((()=>[C(h(E),{class:w([{disabled:h(ce).length<3||u.isSave}]),onClick:e=>function(e){ce.value.length<3||ie.isSave||ce.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024),1===h(pe)&&"sort"!==u.type?(x(),k(ne,{key:1,type:"primary",class:"margin-left-10",onClick:e=>{return t=l,ue.value=t,ge.value=ce.value[t].resultItem||"",void(Ce.value=!0);var t}},{default:b((()=>[V("span",null,q(e.resultItem?"编辑结果":"添加结果"),1)])),_:2},1032,["onClick"])):S("v-if",!0),2===h(pe)&&"sort"!==u.type?(x(),k(ne,{key:2,type:"primary",class:"margin-left-10",onClick:l=>function(e){e.customAnswerId=e.examAnswerId||B(),oe("setRelation",ie.customId,e)}(e)},{default:b((()=>[V("span",null,q(e.answerRelations?.length?`关联了${h(Ee)(e.answerRelations)}项`:"关联检查"),1)])),_:2},1032,["onClick"])):S("v-if",!0)])))),128))]),"sort"===u.type?(x(),f("div",Y,[d[15]||(d[15]=V("div",{class:"label flex flex-justify-end"},[V("span",null,"排序答案:")],-1)),V("div",Z,[C(y,{modelValue:h(ke),"onUpdate:modelValue":d[2]||(d[2]=e=>R(ke)?ke.value=e:null),multiple:"",style:{width:"360px"},placeholder:"请按顺序选择排序答案","show-arrow":!0},{default:b((()=>[(x(!0),f(T,null,j(h(ce),((e,l)=>(x(),k(v,{key:l,label:e.title,value:String.fromCharCode(65+l)},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])])):S("v-if",!0),u.showAnalysis?(x(),f("div",ee,[d[16]||(d[16]=V("div",{class:"label flex flex-justify-center"},[V("span",null,"解析:")],-1)),V("div",le,[C(c,{modelValue:h(fe),"onUpdate:modelValue":d[3]||(d[3]=e=>R(fe)?fe.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):S("v-if",!0),h(xe)?(x(),f("div",te,[d[18]||(d[18]=V("div",{class:"label flex flex-justify-center"},[V("span",null,"富文本:")],-1)),V("div",se,[C(K,I({"model-value":h(we),"onUpdate:modelValue":d[4]||(d[4]=e=>R(we)?we.value=e:null)},h(re),{style:{width:"100%"}}),null,16,["model-value"]),V("div",ae,[C(ne,{type:"danger",onClick:Ae},{default:b((()=>d[17]||(d[17]=[A(" 删除富文本 ")]))),_:1})])])])):S("v-if",!0)])),key:"0"}:void 0]),1032,["show-edit"]),C(Be,{modelValue:h(Ce),"onUpdate:modelValue":d[11]||(d[11]=e=>R(Ce)?Ce.value=e:null),title:"添加结果",class:"customize-dialog"},{footer:b((()=>[C(he,{class:"customize-button",type:"primary",plain:"",onClick:je},{default:b((()=>d[19]||(d[19]=[A(" 取消 ")]))),_:1}),C(he,{class:"customize-button",type:"primary",plain:"",onClick:Te},{default:b((()=>d[20]||(d[20]=[A(" 保存 ")]))),_:1})])),default:b((()=>[(x(),k(K,I({key:h(ue),"model-value":h(ge),"onUpdate:modelValue":d[10]||(d[10]=e=>R(ge)?ge.value=e:null)},h(re),{style:{width:"100%"}}),null,16,["model-value"]))])),_:1},8,["modelValue"])],2)}}});export{ne as default};
|
2
2
|
//# sourceMappingURL=subject-single.vue.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-single.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-single.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport SubjectAction from '../../../subject-action/src/subject-action.vue'\nimport SubjectLayout from '../../../subject-layout/src/subject-layout.vue'\nimport TinyMceEditor from '../../../tiny-mce-editor/src/tiny-mce-editor.vue'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectSingle',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n type: 'single' | 'multiple' | 'sort'\n isEdit: boolean\n isSet: boolean\n answerList?: any\n leastAnswerCount?: number\n analysis?: string\n examExpand?: string\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n customId?: number\n examId?: number\n isKey: boolean\n answerCheckType: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add', 'setRelation'])\n\nconst attrs = useAttrs()\n\nconst answersIndex = ref(0)\nconst isKey = ref(props.isKey)\nconst answerCheckType = ref(1)\nconst examAnswerRelationType = ref(props.examAnswerRelationType)\nconst answers = ref<{\n title: string\n isCorrect: boolean\n orderIndex?: number\n resultItem?: string\n customAnswerId?: string\n answerRelations?: {\n relationExamId: number\n relationAnswers: {\n relationAnswerId: number\n relationAnswerIndex: number\n }[]\n }[]\n}[]>([{\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref(2)\nconst title = ref('')\nconst analysis = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst startTime = ref(0)\nconst showRichContent = ref(false)\nconst resultItem = ref<string>('')\nconst titlePlaceholder = computed(() => {\n if (props.type === 'single') {\n return '单选题'\n }\n else if (props.type === 'multiple') {\n return '多选题'\n }\n else {\n return '排序题'\n }\n})\n\nconst orderList = ref<string[]>([])\n\nconst leastAnswerOptions = computed(() => {\n const items = []\n const length = answers.value.length\n for (let count = length; count > 1; count--) {\n items.push({\n label: `至少选择${count}项`,\n value: count,\n })\n }\n return items.reverse()\n})\nfunction addAnswer() {\n if (props.isSave) {\n return\n }\n answers.value.push({\n title: '',\n isCorrect: false,\n customAnswerId: setGuid()\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3 || props.isSave) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction setCorrect(it: any, event: any) {\n if (props.type === 'single') {\n // 单选题:确保只有一个支持选项\n if (event) {\n answers.value.forEach((answer: any) => {\n if (answer !== it) {\n answer.isCorrect = false\n }\n })\n }\n it.isCorrect = event\n } else if (props.type === 'multiple') {\n // 多选题:可以有多个支持选项\n it.isCorrect = event\n }\n}\nfunction setRelation(item: any) {\n item.customAnswerId = item.examAnswerId || setGuid()\n emits('setRelation', props.customId, item)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n // 答题设置必选\n if(!answerCheckType.value) {\n ElMessage.error('请选择答题设置')\n return\n }\n let msg = ''\n let isSetCorrectAnswer = false\n let correctAnswerCount = 0\n if (props.type === 'multiple' || props.type === 'single') {\n answers.value.forEach((v: any, i: number) => {\n if (!v.title?.trim()) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n v.relationType = v.resultItem ? 1 : (v.answerRelations?.length ? 2 : null)\n })\n }\n else if (props.type === 'sort') {\n // 如果设置了支持选项\n if (orderList.value.length) {\n isSetCorrectAnswer = true\n }\n }\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n const uniqueAnswer = new Set(answers.value.map((item: any) => item.title))\n\n if (uniqueAnswer.size !== answers.value.length) {\n ElMessage.error('选项不能重复')\n return\n }\n\n if (props.type === 'multiple') {\n if (correctAnswerCount === 1) {\n ElMessage.error('请至少设置两个支持选项')\n return\n }\n\n if (isSetCorrectAnswer && correctAnswerCount < leastAnswerCount.value) {\n ElMessage.error('至少选几项与支持选项数不符')\n return\n }\n } \n\n if(answerCheckType.value === 2 || answerCheckType.value === 3) {\n // 必须有设置支持选项\n if (!isSetCorrectAnswer) {\n ElMessage.error('请设置支持选项')\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.map((item: any, index: number) => {\n return { ...item, orderIndex: index + 1 }\n }),\n examExpand: orderList.value.map((i: string) => i.charCodeAt(0) - 65 + 1).join(','),\n analysis: analysis.value,\n isSetCorrectAnswer,\n leastAnswerCount: leastAnswerCount.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n examAnswerRelationType: examAnswerRelationType.value,\n isKey: isKey.value,\n answerCheckType: answerCheckType.value\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\n }\n\n if (props.isKey) {\n isKey.value = props.isKey\n }\n\n if (props.examAnswerRelationType) {\n examAnswerRelationType.value = props.examAnswerRelationType\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.leastAnswerCount) {\n leastAnswerCount.value = props.leastAnswerCount\n }\n\n if (props.examExpand) {\n // 设置支持选项 props.examExpand里是答案id\n if (props.examExpand) {\n const correctAnswerIdList = props.examExpand.split(',')\n\n // 遍历 correctAnswerIdList,直接在 props.answerList 中查找对应的 orderIndex 并转换成字母\n orderList.value = correctAnswerIdList.map((id: string) => {\n const answer = props.answerList.find((item: any) => item.answerId?.toString() === id)\n return answer ? String.fromCharCode(65 + answer.orderIndex - 1) : id\n }).filter(Boolean) // 过滤掉任何可能的空字符串\n }\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n resultItem.value = answers.value[i].resultItem || ''\n showRichContent.value = true\n}\n\nfunction onSaveResult() {\n answers.value[answersIndex.value].resultItem = resultItem.value || ''\n showRichContent.value = false\n}\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\nfunction setKey(key: boolean) {\n isKey.value = key\n}\nfunction setAnswerSetting(type: number) {\n answerCheckType.value = type\n}\n\nfunction add(type: string, canSet: boolean) {\n emits('add', type, canSet? props.examAnswerRelationType: null)\n}\n// 监听isEdit\nwatch(() => props.isEdit, () => {\n if (props.isEdit) {\n startTime.value = new Date().getTime()\n }\n})\n\nconst relationLength = computed(() => {\n return (v: any) => {\n let count = 0\n v.forEach((item: any) => {\n if (item.relationAnswers) {\n count += item.relationAnswers.length\n }\n })\n return count\n }\n})\n\nconst ns = useNamespace('subject-single')\n\nonMounted(init)\n</script>\n\n<template>\n <div :class=\"ns.e('single-exam')\">\n <SubjectLayout\n :show-edit=\"isEdit\"\n >\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">\n {{ orderIndex + 1 }}.{{ title }}\n <span v-if=\"type === 'single'\">(单选题)</span>\n <span v-else-if=\"['multiple', 'sort'].includes(type)\">\n ({{ titlePlaceholder }}{{ leastAnswerCount ? `至少选${leastAnswerCount}项${type === 'sort' ? '并排序' : ''}` : '' }})\n </span>\n </span>\n </div>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" class=\"rich-text\"/>\n </div>\n <div class=\"preview-answer\">\n <template v-if=\"type === 'sort'\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }}\n </el-checkbox>\n </template>\n <template v-else>\n <el-radio\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n value=\"disabled\"\n disabled\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }} \n {{ item.isCorrect ? '(支持选项)' : '' }} \n {{ examAnswerRelationType === 1 ? (item.resultItem? '(已设置结果项)' : '(未设置结果项)' ) : ''}} \n {{ examAnswerRelationType === 2 ? (item.answerRelations?.length? '(已设置关联)' : '(未设置关联)') : '' }}\n </el-radio>\n </template>\n </div>\n </div>\n </template>\n <template v-if=\"isEdit\" #edit>\n <div class=\"flex\" :class=\"[{ 'margin-bottom': showRichText }]\">\n <div class=\"label flex flex-justify-center\">\n <span>题目:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n :placeholder=\"`【${titlePlaceholder}】请输入问题`\"\n :disabled=\"isSave\"\n show-word-limit\n maxlength=\"200\"\n class=\"margin-bottom\"\n />\n </div>\n </div>\n <div class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-center\">\n <span>设置:</span>\n </div>\n <el-select\n v-if=\"['multiple', 'sort'].includes(type)\"\n v-model=\"leastAnswerCount\"\n style=\"width: 150px;\"\n placeholder=\"至少选择几项\"\n :disabled=\"isSave\"\n >\n <el-option\n v-for=\"item in leastAnswerOptions\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n >\n </el-option>\n </el-select>\n </div>\n <div class=\"margin-bottom answer-list\">\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <span class=\"label flex flex-justify-center\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n maxlength=\"100\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <el-checkbox\n v-if=\"['single', 'multiple'].includes(type)\"\n v-model=\"item.isCorrect\"\n :class=\"[{ 'is-correct': item.isCorrect }]\"\n :disabled=\"isSave\"\n style=\"margin-left: 10px;\"\n @change=\"(event: any) => setCorrect(item, event)\"\n >\n 支持选项 \n </el-checkbox>\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: isSave }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n <el-link\n v-if=\"examAnswerRelationType === 1 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"onOpenResult(index)\"\n >\n <span>{{ item.resultItem ? '编辑结果' : '添加结果' }}</span>\n </el-link>\n <el-link\n v-if=\"examAnswerRelationType === 2 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"setRelation(item)\"\n >\n <span>{{ item.answerRelations?.length ? `关联了${relationLength(item.answerRelations)}项` : '关联检查' }}</span>\n </el-link>\n </div>\n </div>\n <div v-if=\"type === 'sort'\" class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-end\">\n <span>排序答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-select\n v-model=\"orderList\"\n multiple\n style=\"width: 360px;\"\n placeholder=\"请按顺序选择排序答案\"\n :show-arrow=\"true\"\n >\n <el-option\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n :label=\"item.title\"\n :value=\"String.fromCharCode(65 + index)\"\n />\n </el-select>\n </div>\n </div>\n <div\n v-if=\"showAnalysis\"\n class=\"flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>解析:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"analysis\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入题目解析\"\n />\n </div>\n </div>\n <div v-if=\"showRichText\" class=\"margin-bottom flex\">\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor v-model:model-value=\"richText\" v-bind=\"attrs\" style=\"width: 100%;\" />\n <div class=\"flex flex-justify-end\">\n <el-link\n type=\"danger\"\n @click=\"deleteRichText\"\n >\n 删除富文本\n </el-link>\n </div>\n </div>\n </div>\n </template>\n <SubjectAction\n v-if=\"showAction\"\n :is-edit=\"isEdit\"\n :is-set=\"isSet\"\n :isKey=\"isKey\"\n :showOtherOption=\"props.type === 'multiple' || props.type === 'single'\"\n :examAnswerRelationType=\"props.examAnswerRelationType\"\n :answerCheckType=\"answerCheckType\"\n @move-up=\"emits('move', 'up')\"\n @move-down=\"emits('move', 'down')\"\n @delete=\"emits('delete')\"\n @save=\"save\"\n @edit=\"emits('edit')\"\n @add=\"add\"\n @onShowRichText=\"showRichText = true\"\n @setKey=\"setKey\"\n @setAnswerSetting=\"setAnswerSetting\"\n />\n </SubjectLayout>\n <el-dialog\n v-model=\"showRichContent\"\n title=\"添加结果\"\n class=\"customize-dialog\"\n >\n <TinyMceEditor\n :key=\"answersIndex\"\n v-model:model-value=\"resultItem\" \n v-bind=\"attrs\"\n style=\"width: 100%;\" />\n <template #footer>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onCloseResult\"\n >\n 取消\n </el-button>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onSaveResult\"\n >\n 保存\n </el-button>\n </template>\n </el-dialog>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answersIndex","ref","isKey","answerCheckType","examAnswerRelationType","answers","title","isCorrect","leastAnswerCount","analysis","showRichText","richText","startTime","showRichContent","resultItem","titlePlaceholder","computed","type","orderList","leastAnswerOptions","items","count","value","length","push","label","reverse","addAnswer","isSave","customAnswerId","setGuid","deleteRichText","save","ElMessage","error","msg","isSetCorrectAnswer","correctAnswerCount","forEach","v","i","trim","String","fromCharCode","relationType","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onSaveResult","onCloseResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","relationLength","relationAnswers","ns","useNamespace","onMounted","answerList","correctAnswerIdList","split","id","answer","find","answerId","toString","filter","Boolean","it","event","splice","examAnswerId","customId"],"mappings":"owFAWA,MAAMA,GAAQC,EAoBRC,GAAQC,GAERC,GAAQC,IAERC,GAAeC,EA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AY,EAAA,IAIzB2E,EAAG3E,UAAY4E,GACS,aAAfzF,GAAMuB,OAEfiE,EAAG3E,UAAY4E,EACjB,gXArBF,SAAsBjC,GAChB7C,GAAQiB,MAAMC,OAAS,GAAK7B,GAAMkC,QAG9BvB,GAAAiB,MAAM8D,OAAOlC,EAAO,EAAC,qJA2JTV,IACpBxC,GAAasB,MAAQkB,EACrB1B,GAAWQ,MAAQjB,GAAQiB,MAAMkB,GAAG1B,YAAc,QAClDD,GAAgBS,OAAQ,GAH1B,IAAsBkB,yMAxItB,SAAqBQ,GACdA,EAAAnB,eAAiBmB,EAAKqC,cAAgBvD,IACrClC,GAAA,cAAeF,GAAM4F,SAAUtC,EAAI"}
|
1
|
+
{"version":3,"file":"subject-single.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-single.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Remove } from '@element-plus/icons-vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { setGuid } from '@qxs-bns/utils'\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: 'QxsSubjectSingle',\n})\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n type: 'single' | 'multiple' | 'sort'\n isEdit: boolean\n isSet: boolean\n answerList?: any\n leastAnswerCount?: number\n analysis?: string\n examExpand?: string\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n customId?: number\n examId?: number\n isKey: boolean\n answerCheckType: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add', 'setRelation'])\n\nconst attrs = useAttrs()\n\nconst answersIndex = ref(0)\nconst isKey = ref(props.isKey)\nconst answerCheckType = ref(1)\nconst examAnswerRelationType = ref(props.examAnswerRelationType)\nconst answers = ref<{\n title: string\n isCorrect: boolean\n orderIndex?: number\n resultItem?: string\n customAnswerId?: string\n answerRelations?: {\n relationExamId: number\n relationAnswers: {\n relationAnswerId: number\n relationAnswerIndex: number\n }[]\n }[]\n}[]>([{\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}, {\n title: '',\n isCorrect: false,\n}])\n\nconst leastAnswerCount = ref(2)\nconst title = ref('')\nconst analysis = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\nconst startTime = ref(0)\nconst showRichContent = ref(false)\nconst resultItem = ref<string>('')\nconst titlePlaceholder = computed(() => {\n if (props.type === 'single') {\n return '单选题'\n }\n else if (props.type === 'multiple') {\n return '多选题'\n }\n else {\n return '排序题'\n }\n})\n\nconst orderList = ref<string[]>([])\n\nconst leastAnswerOptions = computed(() => {\n const items = []\n const length = answers.value.length\n for (let count = length; count > 1; count--) {\n items.push({\n label: `至少选择${count}项`,\n value: count,\n })\n }\n return items.reverse()\n})\nfunction addAnswer() {\n if (props.isSave) {\n return\n }\n answers.value.push({\n title: '',\n isCorrect: false,\n customAnswerId: setGuid(),\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 3 || props.isSave) {\n return\n }\n answers.value.splice(index, 1)\n}\n\nfunction setCorrect(it: any, event: any) {\n if (props.type === 'single') {\n // 单选题:确保只有一个支持选项\n if (event) {\n answers.value.forEach((answer: any) => {\n if (answer !== it) {\n answer.isCorrect = false\n }\n })\n }\n it.isCorrect = event\n }\n else if (props.type === 'multiple') {\n // 多选题:可以有多个支持选项\n it.isCorrect = event\n }\n}\nfunction setRelation(item: any) {\n item.customAnswerId = item.examAnswerId || setGuid()\n emits('setRelation', props.customId, item)\n}\n\nfunction deleteRichText() {\n showRichText.value = false\n richText.value = ''\n}\n\nfunction save() {\n if (!title.value) {\n ElMessage.error('题目标题不能为空!')\n return\n }\n // 答题设置必选\n if (!answerCheckType.value) {\n ElMessage.error('请选择答题设置')\n return\n }\n let msg = ''\n let isSetCorrectAnswer = false\n let correctAnswerCount = 0\n if (props.type === 'multiple' || props.type === 'single') {\n answers.value.forEach((v: any, i: number) => {\n if (!v.title?.trim()) {\n msg += `选项${String.fromCharCode(65 + i)}未填写。`\n }\n if (v.isCorrect) {\n isSetCorrectAnswer = true\n correctAnswerCount++\n }\n v.relationType = v.resultItem ? 1 : (v.answerRelations?.length ? 2 : null)\n })\n }\n else if (props.type === 'sort') {\n // 如果设置了支持选项\n if (orderList.value.length) {\n isSetCorrectAnswer = true\n }\n }\n if (msg) {\n ElMessage.error(msg)\n return\n }\n\n const uniqueAnswer = new Set(answers.value.map((item: any) => item.title))\n\n if (uniqueAnswer.size !== answers.value.length) {\n ElMessage.error('选项不能重复')\n return\n }\n\n if (props.type === 'multiple') {\n if (correctAnswerCount === 1) {\n ElMessage.error('请至少设置两个支持选项')\n return\n }\n\n if (isSetCorrectAnswer && correctAnswerCount < leastAnswerCount.value) {\n ElMessage.error('至少选几项与支持选项数不符')\n return\n }\n }\n\n if (answerCheckType.value === 2 || answerCheckType.value === 3) {\n // 必须有设置支持选项\n if (!isSetCorrectAnswer) {\n ElMessage.error('请设置支持选项')\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.map((item: any, index: number) => {\n return { ...item, orderIndex: index + 1 }\n }),\n examExpand: orderList.value.map((i: string) => i.charCodeAt(0) - 65 + 1).join(','),\n analysis: analysis.value,\n isSetCorrectAnswer,\n leastAnswerCount: leastAnswerCount.value,\n examRichTextContent: showRichText.value ? richText.value : '',\n examAnswerRelationType: examAnswerRelationType.value,\n isKey: isKey.value,\n answerCheckType: answerCheckType.value,\n })\n}\n\nfunction init() {\n if (props.title) {\n title.value = props.title\n }\n\n if (props.answerCheckType) {\n answerCheckType.value = props.answerCheckType\n }\n\n if (props.isKey) {\n isKey.value = props.isKey\n }\n\n if (props.examAnswerRelationType) {\n examAnswerRelationType.value = props.examAnswerRelationType\n }\n\n if (props.answerList && props.answerList.length) {\n answers.value = props.answerList\n }\n\n if (props.leastAnswerCount) {\n leastAnswerCount.value = props.leastAnswerCount\n }\n\n if (props.examExpand) {\n // 设置支持选项 props.examExpand里是答案id\n if (props.examExpand) {\n const correctAnswerIdList = props.examExpand.split(',')\n\n // 遍历 correctAnswerIdList,直接在 props.answerList 中查找对应的 orderIndex 并转换成字母\n orderList.value = correctAnswerIdList.map((id: string) => {\n const answer = props.answerList.find((item: any) => item.answerId?.toString() === id)\n return answer ? String.fromCharCode(65 + answer.orderIndex - 1) : id\n }).filter(Boolean) // 过滤掉任何可能的空字符串\n }\n }\n\n if (props.analysis) {\n analysis.value = props.analysis\n }\n\n if (props.examRichTextContent) {\n richText.value = props.examRichTextContent\n showRichText.value = true\n }\n}\nfunction onOpenResult(i: number) {\n answersIndex.value = i\n resultItem.value = answers.value[i].resultItem || ''\n showRichContent.value = true\n}\n\nfunction onSaveResult() {\n answers.value[answersIndex.value].resultItem = resultItem.value || ''\n showRichContent.value = false\n}\nfunction onCloseResult() {\n showRichContent.value = false\n resultItem.value = ''\n}\nfunction setKey(key: boolean) {\n isKey.value = key\n}\nfunction setAnswerSetting(type: number) {\n answerCheckType.value = type\n}\n\nfunction add(type: string, canSet: boolean) {\n emits('add', type, canSet ? props.examAnswerRelationType : null)\n}\n// 监听isEdit\nwatch(() => props.isEdit, () => {\n if (props.isEdit) {\n startTime.value = new Date().getTime()\n }\n})\n\nconst relationLength = computed(() => {\n return (v: any) => {\n let count = 0\n v.forEach((item: any) => {\n if (item.relationAnswers) {\n count += item.relationAnswers.length\n }\n })\n return count\n }\n})\n\nconst ns = useNamespace('subject-single')\n\nonMounted(init)\n</script>\n\n<template>\n <div :class=\"ns.e('single-exam')\">\n <SubjectLayout\n :show-edit=\"isEdit\"\n >\n <template #preview>\n <div class=\"preview\">\n <div>\n <span class=\"title\">\n {{ orderIndex + 1 }}.{{ title }}\n <span v-if=\"type === 'single'\">(单选题)</span>\n <span v-else-if=\"['multiple', 'sort'].includes(type)\">\n ({{ titlePlaceholder }}{{ leastAnswerCount ? `至少选${leastAnswerCount}项${type === 'sort' ? '并排序' : ''}` : '' }})\n </span>\n </span>\n </div>\n <div v-if=\"showRichText\">\n <div\n class=\"rich-text\"\n v-html=\"richText\"\n />\n </div>\n <div class=\"preview-answer\">\n <template v-if=\"type === 'sort'\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }}\n </el-checkbox>\n </template>\n <template v-else>\n <el-radio\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n value=\"disabled\"\n disabled\n >\n <span class=\"order\">\n {{ String.fromCharCode(65 + index) }}.\n </span>\n {{ item.title }}\n {{ item.isCorrect ? '(支持选项)' : '' }}\n {{ examAnswerRelationType === 1 ? (item.resultItem ? '(已设置结果项)' : '(未设置结果项)') : '' }}\n {{ examAnswerRelationType === 2 ? (item.answerRelations?.length ? '(已设置关联)' : '(未设置关联)') : '' }}\n </el-radio>\n </template>\n </div>\n </div>\n </template>\n <template\n v-if=\"isEdit\"\n #edit\n >\n <div\n class=\"flex\"\n :class=\"[{ 'margin-bottom': showRichText }]\"\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=\"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-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=\"label flex flex-justify-center\">{{ String.fromCharCode(65 + index) }}.</span>\n <el-input\n v-model=\"item.title\"\n class=\"input\"\n show-word-limit\n maxlength=\"100\"\n :placeholder=\"`选项${String.fromCharCode(65 + index)}`\"\n :disabled=\"isSave\"\n />\n <el-checkbox\n v-if=\"['single', 'multiple'].includes(type)\"\n v-model=\"item.isCorrect\"\n :class=\"[{ 'is-correct': item.isCorrect }]\"\n :disabled=\"isSave\"\n style=\"margin-left: 10px;\"\n @change=\"(event: any) => setCorrect(item, event)\"\n >\n 支持选项\n </el-checkbox>\n <el-icon class=\"icon\">\n <CirclePlus\n :class=\"[{ disabled: isSave }]\"\n @click=\"addAnswer\"\n />\n </el-icon>\n <el-icon class=\"icon\">\n <Remove\n :class=\"[{ disabled: answers.length < 3 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n <el-link\n v-if=\"examAnswerRelationType === 1 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"onOpenResult(index)\"\n >\n <span>{{ item.resultItem ? '编辑结果' : '添加结果' }}</span>\n </el-link>\n <el-link\n v-if=\"examAnswerRelationType === 2 && type !== 'sort'\"\n type=\"primary\"\n class=\"margin-left-10\"\n @click=\"setRelation(item)\"\n >\n <span>{{ item.answerRelations?.length ? `关联了${relationLength(item.answerRelations)}项` : '关联检查' }}</span>\n </el-link>\n </div>\n </div>\n <div\n v-if=\"type === 'sort'\"\n class=\"margin-bottom flex flex-items-center\"\n >\n <div class=\"label flex flex-justify-end\">\n <span>排序答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-select\n v-model=\"orderList\"\n multiple\n style=\"width: 360px;\"\n placeholder=\"请按顺序选择排序答案\"\n :show-arrow=\"true\"\n >\n <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\n v-if=\"showRichText\"\n class=\"margin-bottom flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor\n v-model:model-value=\"richText\"\n v-bind=\"attrs\"\n style=\"width: 100%;\"\n />\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 :is-key=\"isKey\"\n :show-other-option=\"props.type === 'multiple' || props.type === 'single'\"\n :exam-answer-relation-type=\"props.examAnswerRelationType\"\n :answer-check-type=\"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 @on-show-rich-text=\"showRichText = true\"\n @set-key=\"setKey\"\n @set-answer-setting=\"setAnswerSetting\"\n />\n </SubjectLayout>\n <el-dialog\n v-model=\"showRichContent\"\n title=\"添加结果\"\n class=\"customize-dialog\"\n >\n <TinyMceEditor\n :key=\"answersIndex\"\n v-model:model-value=\"resultItem\"\n v-bind=\"attrs\"\n style=\"width: 100%;\"\n />\n <template #footer>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onCloseResult\"\n >\n 取消\n </el-button>\n <el-button\n class=\"customize-button\"\n type=\"primary\"\n plain\n @click=\"onSaveResult\"\n >\n 保存\n </el-button>\n </template>\n </el-dialog>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answersIndex","ref","isKey","answerCheckType","examAnswerRelationType","answers","title","isCorrect","leastAnswerCount","analysis","showRichText","richText","startTime","showRichContent","resultItem","titlePlaceholder","computed","type","orderList","leastAnswerOptions","items","count","value","length","push","label","reverse","addAnswer","isSave","customAnswerId","setGuid","deleteRichText","save","ElMessage","error","msg","isSetCorrectAnswer","correctAnswerCount","forEach","v","i","trim","String","fromCharCode","relationType","answerRelations","Set","map","item","size","index","orderIndex","examExpand","charCodeAt","join","examRichTextContent","onSaveResult","onCloseResult","setKey","key","setAnswerSetting","add","canSet","watch","isEdit","Date","getTime","relationLength","relationAnswers","ns","useNamespace","onMounted","answerList","correctAnswerIdList","split","id","answer","find","answerId","toString","filter","Boolean","it","event","splice","examAnswerId","customId"],"mappings":"owFAWA,MAAMA,GAAQC,EAoBRC,GAAQC,GAERC,GAAQC,IAERC,GAAeC,EAAI,GACnBC,GAAQD,EAAIP,GAAMQ,OAClBC,GAAkBF,EAAI,GACtBG,GAAyBH,EAAIP,GAAMU,wBACnCC,GAAUJ,EAaX,CAAC,CACJK,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,GACV,CACDD,MAAO,GACPC,WAAW,KAGPC,GAAmBP,EAAI,GACvBK,GAAQL,EAAI,IACZQ,GAAWR,EAAI,IACfS,GAAeT,GAAI,GACnBU,GAAWV,EAAI,IACfW,GAAYX,EAAI,GAChBY,GAAkBZ,GAAI,GACtBa,GAAab,EAAY,IACzBc,GAAmBC,GAAS,IACb,WAAftB,GAAMuB,KACD,MAEe,aAAfvB,GAAMuB,KACN,MAGA,QAILC,GAAYjB,EAAc,IAE1BkB,GAAqBH,GAAS,KAClC,MAAMI,EAAQ,GAEd,IAAA,IAASC,EADMhB,GAAQiB,MAAMC,OACJF,EAAQ,EAAGA,IAClCD,EAAMI,KAAK,CACT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B,MAAQ5B,GAAM8E,YAGpB9E,GAAMc,mBACRA,GAAiBc,MAAQ5B,GAAMc,kBAG7Bd,GAAM0D,YAEJ1D,GAAM0D,WAAY,CACpB,MAAMqB,EAAsB/E,GAAM0D,WAAWsB,MAAM,KAGnDxD,GAAUI,MAAQmD,EAAoB1B,KAAK4B,IACnC,MAAAC,EAASlF,GAAM8E,WAAWK,MAAM7B,GAAcA,EAAK8B,UAAUC,aAAeJ,IAClF,OAAOC,EAASlC,OAAOC,aAAa,GAAKiC,EAAOzB,WAAa,GAAKwB,CAAA,IACjEK,OAAOC,QAAO,CAIjBvF,GAAMe,WACRA,GAASa,MAAQ5B,GAAMe,UAGrBf,GAAM6D,sBACR5C,GAASW,MAAQ5B,GAAM6D,oBACvB7C,GAAaY,OAAQ,EACvB,+rGAvJO,SAAW4D,EAASC,GACR,WAAfzF,GAAMuB,MAEJkE,GACM9E,GAAAiB,MAAMgB,SAASsC,IACjBA,IAAWM,IACbN,EAAOrE,WAAY,EAAA,IAIzB2E,EAAG3E,UAAY4E,GAEO,aAAfzF,GAAMuB,OAEbiE,EAAG3E,UAAY4E,EACjB,gXAtBF,SAAsBjC,GAChB7C,GAAQiB,MAAMC,OAAS,GAAK7B,GAAMkC,QAG9BvB,GAAAiB,MAAM8D,OAAOlC,EAAO,EAAC,qJA4JTV,IACpBxC,GAAasB,MAAQkB,EACrB1B,GAAWQ,MAAQjB,GAAQiB,MAAMkB,GAAG1B,YAAc,QAClDD,GAAgBS,OAAQ,GAH1B,IAAsBkB,yMAxItB,SAAqBQ,GACdA,EAAAnB,eAAiBmB,EAAKqC,cAAgBvD,IACrClC,GAAA,cAAeF,GAAM4F,SAAUtC,EAAI"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{ElInput as e,ElInputNumber as l,ElCheckboxGroup as t,ElCheckbox as s,ElTag as n,ElButton as i,ElIcon as a,ElLink as o}from"element-plus/es";import"element-plus/es/components/base/style/index";import"element-plus/es/components/link/style/index";import"element-plus/es/components/button/style/index";import"element-plus/es/components/icon/style/index";import"element-plus/es/components/tag/style/index";import"element-plus/es/components/checkbox-group/style/index";import"element-plus/es/components/input-number/style/index";import"element-plus/es/components/input/style/index";import"element-plus/es/components/checkbox/style/index";import{defineComponent as u,useAttrs as r,ref as d,onMounted as m,createElementBlock as p,openBlock as c,normalizeClass as v,unref as x,createVNode as f,withCtx as y,createBlock as w,createCommentVNode as g,createElementVNode as h,isRef as b,Fragment as k,renderList as V,createTextVNode as C,toDisplayString as S,mergeProps as j}from"vue";import{Plus as I,CirclePlus as O,Remove as A}from"@element-plus/icons-vue";import{useNamespace as q}from"@qxs-bns/hooks";import{ElMessage as _}from"element-plus";import
|
1
|
+
import{ElInput as e,ElInputNumber as l,ElCheckboxGroup as t,ElCheckbox as s,ElTag as n,ElButton as i,ElIcon as a,ElLink as o}from"element-plus/es";import"element-plus/es/components/base/style/index";import"element-plus/es/components/link/style/index";import"element-plus/es/components/button/style/index";import"element-plus/es/components/icon/style/index";import"element-plus/es/components/tag/style/index";import"element-plus/es/components/checkbox-group/style/index";import"element-plus/es/components/input-number/style/index";import"element-plus/es/components/input/style/index";import"element-plus/es/components/checkbox/style/index";import{defineComponent as u,useAttrs as r,ref as d,onMounted as m,createElementBlock as p,openBlock as c,normalizeClass as v,unref as x,createVNode as f,withCtx as y,createBlock as w,createCommentVNode as g,createElementVNode as h,isRef as b,Fragment as k,renderList as V,createTextVNode as C,toDisplayString as S,mergeProps as j}from"vue";import{Plus as I,CirclePlus as O,Remove as A}from"@element-plus/icons-vue";import{useNamespace as q}from"@qxs-bns/hooks";import{ElMessage as _}from"element-plus";import E from"../../../subject-action/src/subject-action.vue.mjs";import T from"../../../subject-layout/src/subject-layout.vue.mjs";import U from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";const B={class:"preview"},R={class:"content"},L={class:"title"},M={key:0},D=["innerHTML"],H={class:"content flex flex-col"},N={key:1,class:"flex",style:{"margin-top":"10px",color:"#a8abb2"}},z={class:"title"},$={class:"flex"},F={style:{flex:"1"},class:"margin-bottom"},G={class:"margin-bottom flex flex-items-center"},J={class:"flex"},K={style:{flex:"1"}},P={class:"margin-bottom answer-list"},Q={class:"label flex flex-justify-end"},W={class:"answer-tags"},X={class:"operation"},Y={key:0,class:"margin-bottom flex"},Z={style:{flex:"1"}},ee={key:1,class:"margin-bottom flex"},le={style:{flex:"1"}},te={class:"flex flex-justify-end"};var se=u({__name:"subject-text-fill",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},isEdit:{type:Boolean,required:!0},isSet:{type:Boolean,required:!0},examExpand:{type:String,required:!1},examAnswerSettingVO:{type:Object,required:!1},examRichTextContent:{type:String,required:!1},showAnalysis:{type:Boolean,required:!1},examAnswerRelationType:{type:Number,required:!1}},emits:["move","save","delete","edit","add"],setup(u,{emit:se}){const ne=u,ie=se,ae=r(),oe=d([{title:"",tag:"",showInput:!1}]),ue=d(""),re=d(""),de=d(),me=d(""),pe=d(!1),ce=d(""),ve=[{label:"答案不分顺序",value:"isInOrder"},{label:"忽略大小写",value:"isIgnoreCase"}],xe=d(["isInOrder","isIgnoreCase"]);function fe(){oe.value.push({title:"",tag:"",showInput:!1})}function ye(){pe.value=!1,ce.value=""}function we(){if(ue.value){if(de.value||me.value){if(!de.value)return void _.error("请完善答题设置!");if(!me.value)return void _.error("请输入问题正确答案!");if(oe.value.length!==de.value)return void _.error("关键词个数设置有误!");const e=[];if(oe.value.forEach(((l,t)=>{l.title||e.push(`关键词${t+1}未设置`)})),e.length>0)return void _.error(e.join(","))}ie("save",{title:ue.value,answers:oe.value.filter((e=>e.title)).map((e=>({title:e.title}))),analysis:re.value,isSetCorrectAnswer:!!me.value,examExpand:me.value,examAnswerSettingBO:{isIgnoreCase:xe.value?.includes("isIgnoreCase"),isInOrder:xe.value?.includes("isInOrder"),keywordCount:de.value},examRichTextContent:pe.value?ce.value:""})}else _.error("题目标题不能为空!")}m((function(){ne.title&&(ue.value=ne.title),ne.answerList&&ne.answerList.length&&(oe.value=ne.answerList),ne.examAnswerSettingVO&&(xe.value=xe.value.filter((e=>"isIgnoreCase"===e&&ne.examAnswerSettingVO?.isIgnoreCase||"isInOrder"===e&&ne.examAnswerSettingVO?.isInOrder))),ne.examAnswerSettingVO?.keywordCount&&(de.value=ne.examAnswerSettingVO?.keywordCount),ne.examExpand&&(me.value=ne.examExpand),ne.analysis&&(re.value=ne.analysis),ne.examRichTextContent&&(ce.value=ne.examRichTextContent,pe.value=!0)}));const ge=q("subject-text-fill");return(u,r)=>{const d=s,m=e,q=l,_=t,se=n,he=a,be=i,ke=o;return c(),p("div",{class:v(x(ge).e("text-fill-exam"))},[f(T,{"show-edit":u.isEdit},{preview:y((()=>[h("div",B,[h("div",R,[h("span",L,S(u.orderIndex+1)+"."+S(x(ue))+"(问答题)",1),x(pe)?(c(),p("div",M,[h("div",{class:"rich-text",innerHTML:x(ce)},null,8,D)])):g("v-if",!0),h("div",H,[x(oe).some((e=>e.title))?(c(!0),p(k,{key:0},V(x(oe),((e,l)=>(c(),w(d,{key:l,class:"radio",disabled:!0},{default:y((()=>[C(S(e.title),1)])),_:2},1024)))),128)):g("v-if",!0)]),x(me)?(c(),p("div",N,[h("span",z,"正确答案:"+S(x(me)),1)])):g("v-if",!0)])])])),edit:y((()=>[h("div",$,[r[12]||(r[12]=h("div",{class:"label flex flex-justify-end"},[h("span",null,"题目:")],-1)),h("div",F,[f(m,{modelValue:x(ue),"onUpdate:modelValue":r[0]||(r[0]=e=>b(ue)?ue.value=e:null),type:"textarea",rows:2,placeholder:"【问答题】请输入问题",maxlength:200,"show-word-limit":"",disabled:u.isSave},null,8,["modelValue","disabled"])])]),h("div",G,[r[13]||(r[13]=h("div",{class:"label flex flex-justify-end"},[h("span",null,"答题设置:")],-1)),r[14]||(r[14]=h("span",null,"共答对",-1)),f(q,{modelValue:x(de),"onUpdate:modelValue":r[1]||(r[1]=e=>b(de)?de.value=e:null),style:{width:"100px",margin:"0 10px"},min:1},null,8,["modelValue"]),r[15]||(r[15]=h("span",{style:{"margin-right":"10px"}},"个关键词,算是正确的",-1)),(c(),p(k,null,V(ve,(e=>f(_,{key:e.value,modelValue:x(xe),"onUpdate:modelValue":r[2]||(r[2]=e=>b(xe)?xe.value=e:null)},{default:y((()=>[f(d,{label:e.value,class:"margin-left-10"},{default:y((()=>[C(S(e.label),1)])),_:2},1032,["label"])])),_:2},1032,["modelValue"]))),64))]),h("div",J,[r[16]||(r[16]=h("div",{class:"label flex flex-justify-end"},[h("span",null,"答案:")],-1)),h("div",K,[f(m,{modelValue:x(me),"onUpdate:modelValue":r[3]||(r[3]=e=>b(me)?me.value=e:null),type:"textarea",rows:2,placeholder:"请输入正确答案",maxlength:200,"show-word-limit":"",disabled:u.isSave},null,8,["modelValue","disabled"])])]),h("div",P,[r[17]||(r[17]=h("span",{style:{"padding-left":"60px"}},"*如遇包含特殊字符的关键词,需添加多个同义词,例:'CO₂'需添加同义词'CO2'",-1)),(c(!0),p(k,null,V(x(oe),((e,l)=>(c(),p("div",{key:l,class:"answer-item flex flex-items-center"},[h("div",Q,[h("span",null,"关键词"+S(l+1)+":",1)]),h("div",W,[(c(!0),p(k,null,V(e.title.split(","),(l=>(c(),p(k,{key:l},[l?(c(),w(se,{key:0,closable:"",onClose:t=>function(e,l){if(e){const t=l.title.split(","),s=t.findIndex((l=>l===e));s>-1&&(t.splice(s,1),l.title=t.join(","))}}(l,e)},{default:y((()=>[C(S(l),1)])),_:2},1032,["onClose"])):g("v-if",!0)],64)))),128)),u.isSave?g("v-if",!0):(c(),p(k,{key:0},[e.showInput?(c(),w(m,{key:0,modelValue:e.tag,"onUpdate:modelValue":l=>e.tag=l,style:{width:"80px"},onBlur:()=>function(e){e.showInput=!1,e.tag&&(e.title=e.title?[e.title,e.tag].join(","):e.tag,e.tag="")}(e)},null,8,["modelValue","onUpdate:modelValue","onBlur"])):(c(),w(be,{key:1,size:"small",onClick:l=>e.showInput=!0},{default:y((()=>[f(he,null,{default:y((()=>[f(x(I))])),_:1}),h("span",null,S(e.title?"添加同义词":"添加关键词"),1)])),_:2},1032,["onClick"]))],64))]),h("div",X,[f(he,{class:"icon"},{default:y((()=>[f(x(O),{class:v([{disabled:u.isSave}]),onClick:fe},null,8,["class"])])),_:1}),f(he,{class:"icon"},{default:y((()=>[f(x(A),{class:v([{disabled:x(oe).length<2||u.isSave}]),onClick:e=>function(e){oe.value.length<2||ne.isSave||oe.value.splice(e,1)}(l)},null,8,["class","onClick"])])),_:2},1024)])])))),128))]),u.showAnalysis?(c(),p("div",Y,[r[18]||(r[18]=h("div",{class:"label flex flex-justify-end"},[h("span",null,"解析:")],-1)),h("div",Z,[f(m,{modelValue:x(re),"onUpdate:modelValue":r[4]||(r[4]=e=>b(re)?re.value=e:null),type:"textarea",rows:2,placeholder:"请输入题目解析"},null,8,["modelValue"])])])):g("v-if",!0),x(pe)?(c(),p("div",ee,[r[20]||(r[20]=h("div",{class:"label flex flex-justify-center"},[h("span",null,"富文本:")],-1)),h("div",le,[f(U,j({"model-value":x(ce),"onUpdate:modelValue":r[5]||(r[5]=e=>b(ce)?ce.value=e:null)},x(ae),{style:{width:"100%"}}),null,16,["model-value"]),h("div",te,[f(ke,{type:"danger",onClick:ye},{default:y((()=>r[19]||(r[19]=[C(" 删除富文本 ")]))),_:1})])])])):g("v-if",!0)])),default:y((()=>[u.showAction?(c(),w(E,{key:0,"is-edit":u.isEdit,"is-set":u.isSet,"show-other-option":!1,"exam-answer-relation-type":ne.examAnswerRelationType,onMoveUp:r[6]||(r[6]=e=>ie("move","up")),onMoveDown:r[7]||(r[7]=e=>ie("move","down")),onDelete:r[8]||(r[8]=e=>ie("delete")),onSave:we,onEdit:r[9]||(r[9]=e=>ie("edit")),onAdd:r[10]||(r[10]=e=>ie("add",e)),onOnShowRichText:r[11]||(r[11]=e=>pe.value=!0)},null,8,["is-edit","is-set","exam-answer-relation-type"])):g("v-if",!0)])),_:1},8,["show-edit"])],2)}}});export{se as default};
|
2
2
|
//# sourceMappingURL=subject-text-fill.vue.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-text-fill.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-text-fill.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Plus, 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\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n answerList?: any\n analysis?: string\n isEdit: boolean\n isSet: boolean\n examExpand?: string\n examAnswerSettingVO?: {\n isInOrder: boolean\n isIgnoreCase: boolean\n keywordCount: number\n }\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add'])\n\nconst attrs = useAttrs()\n\nconst answers = ref<{\n title: string\n tag: string\n showInput: boolean\n}[]>([{\n title: '',\n tag: '',\n showInput: false,\n}])\n\nconst title = ref('')\nconst analysis = ref('')\nconst keywordCount = ref()\nconst correct = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\n\nconst checkList = [\n {\n label: '答案不分顺序',\n value: 'isInOrder',\n },\n {\n label: '忽略大小写',\n value: 'isIgnoreCase',\n },\n]\n\nconst isCheckList = ref(['isInOrder', 'isIgnoreCase'])\n\nfunction handleAddTag(item: any) {\n item.showInput = false\n if (item.tag) {\n item.title = item.title ? [item.title, item.tag].join(',') : item.tag\n item.tag = ''\n }\n}\n\nfunction closeTag(tag: string, item: any) {\n if (tag) {\n const tags = item.title.split(',')\n const index = tags.findIndex((i: string) => i === tag)\n if (index > -1) {\n tags.splice(index, 1)\n item.title = tags.join(',')\n }\n }\n}\n\nfunction addAnswer() {\n answers.value.push({\n title: '',\n tag: '',\n showInput: false,\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 2 || props.isSave) {\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\n if (keywordCount.value || correct.value) {\n if (!keywordCount.value) {\n ElMessage.error('请完善答题设置!')\n return\n }\n\n if (!correct.value) {\n ElMessage.error('请输入问题正确答案!')\n return\n }\n\n if (answers.value.length !== keywordCount.value) {\n ElMessage.error('关键词个数设置有误!')\n return\n }\n const msg: string[] = []\n answers.value.forEach((item, index) => {\n if (!item.title) {\n msg.push(`关键词${index + 1}未设置`)\n }\n })\n if (msg.length > 0) {\n ElMessage.error(msg.join(','))\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.filter((i: any) => i.title).map((item: any) => {\n return { title: item.title }\n }),\n analysis: analysis.value,\n isSetCorrectAnswer: !!correct.value,\n examExpand: correct.value,\n examAnswerSettingBO: {\n isIgnoreCase: isCheckList.value?.includes('isIgnoreCase'),\n isInOrder: isCheckList.value?.includes('isInOrder'),\n ...{ keywordCount: keywordCount.value },\n },\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.examAnswerSettingVO) {\n // 仅保留与设置匹配的选项\n isCheckList.value = isCheckList.value.filter(item =>\n (item === 'isIgnoreCase' && props.examAnswerSettingVO?.isIgnoreCase)\n || (item === 'isInOrder' && props.examAnswerSettingVO?.isInOrder),\n )\n }\n\n if (props.examAnswerSettingVO?.keywordCount) {\n keywordCount.value = props.examAnswerSettingVO?.keywordCount\n }\n\n if (props.examExpand) {\n correct.value = props.examExpand\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\nonMounted(init)\nconst ns = useNamespace('subject-text-fill')\n</script>\n\n<template>\n <div :class=\"ns.e('text-fill-exam')\">\n <SubjectLayout :show-edit=\"isEdit\">\n <template #preview>\n <div class=\"preview\">\n <div class=\"content\">\n <span class=\"title\">{{ orderIndex + 1 }}.{{ title }}(问答题)</span>\n <div v-if=\"showRichText\">\n <div v-html=\"richText\" class=\"rich-text\" />\n </div>\n <div class=\"content flex flex-col\">\n <template v-if=\"answers.some(item => item.title)\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n {{ item.title }}\n </el-checkbox>\n </template>\n </div>\n <div\n v-if=\"correct\"\n class=\"flex\"\n style=\"margin-top: 10px;color: #a8abb2;\"\n >\n <span class=\"title\">正确答案:{{ correct }}</span>\n </div>\n </div>\n </div>\n </template>\n <template #edit>\n <div class=\"flex\">\n <div class=\"label flex flex-justify-end\">\n <span>题目:</span>\n </div>\n <div style=\"flex: 1;\" class=\"margin-bottom\">\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"【问答题】请输入问题\"\n :maxlength=\"200\"\n show-word-limit\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-end\">\n <span>答题设置:</span>\n </div>\n <span>共答对</span>\n <el-input-number\n v-model=\"keywordCount\"\n style=\"width: 100px;margin: 0 10px;\"\n :min=\"1\"\n />\n <span style=\"margin-right: 10px;\">个关键词,算是正确的</span>\n <el-checkbox-group\n v-for=\"item in checkList\"\n :key=\"item.value\"\n v-model=\"isCheckList\"\n >\n <el-checkbox :label=\"item.value\" class=\"margin-left-10\">\n {{ item.label }}\n </el-checkbox>\n </el-checkbox-group>\n </div>\n <div class=\"flex\">\n <div class=\"label flex flex-justify-end\">\n <span>答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"correct\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入正确答案\"\n :maxlength=\"200\"\n show-word-limit\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"margin-bottom answer-list\">\n <span style=\"padding-left: 60px;\">*如遇包含特殊字符的关键词,需添加多个同义词,例:'CO₂'需添加同义词'CO2'</span>\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <div class=\"label flex flex-justify-end\">\n <span>关键词{{ index + 1 }}:</span>\n </div>\n\n <div class=\"answer-tags\">\n <template\n v-for=\"i in item.title.split(',')\"\n :key=\"i\"\n >\n <el-tag\n v-if=\"i\"\n closable\n @close=\"closeTag(i, item)\"\n >\n {{ i }}\n </el-tag>\n </template>\n <template v-if=\"!isSave\">\n <el-input\n v-if=\"item.showInput\"\n v-model=\"item.tag\"\n style=\"width: 80px;\"\n @blur=\"() => handleAddTag(item)\"\n />\n <el-button\n v-else\n size=\"small\"\n @click=\"item.showInput = true\"\n >\n <el-icon><Plus /></el-icon>\n <span>{{ item.title ? '添加同义词' : '添加关键词' }}</span>\n </el-button>\n </template>\n </div>\n <div class=\"operation\">\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 < 2 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n </div>\n </div>\n </div>\n <div v-if=\"showAnalysis\" class=\"margin-bottom flex\">\n <div class=\"label flex flex-justify-end\">\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","tag","showInput","analysis","keywordCount","correct","showRichText","richText","checkList","label","value","isCheckList","addAnswer","push","deleteRichText","save","ElMessage","error","length","msg","forEach","item","index","join","filter","i","map","isSetCorrectAnswer","examExpand","examAnswerSettingBO","isIgnoreCase","includes","isInOrder","examRichTextContent","onMounted","answerList","examAnswerSettingVO","ns","useNamespace","tags","split","findIndex","splice","isSave"],"mappings":"khFAQA,MAAMA,GAAQC,EAmBRC,GAAQC,GAERC,GAAQC,IAERC,GAAUC,EAIX,CAAC,CACJC,MAAO,GACPC,IAAK,GACLC,WAAW,KAGPF,GAAQD,EAAI,IACZI,GAAWJ,EAAI,IACfK,GAAeL,IACfM,GAAUN,EAAI,IACdO,GAAeP,GAAI,GACnBQ,GAAWR,EAAI,IAEfS,GAAY,CAChB,CACEC,MAAO,SACPC,MAAO,aAET,CACED,MAAO,QACPC,MAAO,iBAILC,GAAcZ,EAAI,CAAC,YAAa,iBAqBtC,SAASa,KACPd,GAAQY,MAAMG,KAAK,CACjBb,MAAO,GACPC,IAAK,GACLC,WAAW,GACZ,CAUH,SAASY,KACPR,GAAaI,OAAQ,EACrBH,GAASG,MAA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AAQK,MAAQlB,GAAMoC,YAGpBpC,GAAMW,WACRA,GAASO,MAAQlB,GAAMW,UAGrBX,GAAMyC,sBACR1B,GAASG,MAAQlB,GAAMyC,oBACvB3B,GAAaI,OAAQ,EACvB,IAII,MAAA2B,GAAKC,EAAa,+uEArHf,SAASrC,EAAaoB,GAC7B,GAAIpB,EAAK,CACP,MAAMsC,EAAOlB,EAAKrB,MAAMwC,MAAM,KACxBlB,EAAQiB,EAAKE,WAAWhB,GAAcA,IAAMxB,IAC9CqB,GAAQ,IACLiB,EAAAG,OAAOpB,EAAO,GACdD,EAAArB,MAAQuC,EAAKhB,KAAK,KACzB,CACF,+OAhBF,SAAsBF,GACpBA,EAAKnB,WAAY,EACbmB,EAAKpB,MACPoB,EAAKrB,MAAQqB,EAAKrB,MAAQ,CAACqB,EAAKrB,MAAOqB,EAAKpB,KAAKsB,KAAK,KAAOF,EAAKpB,IAClEoB,EAAKpB,IAAM,GACb,ueAsBF,SAAsBqB,GAChBxB,GAAQY,MAAMQ,OAAS,GAAK1B,GAAMmD,QAG9B7C,GAAAY,MAAMgC,OAAOpB,EAAO,EAAC"}
|
1
|
+
{"version":3,"file":"subject-text-fill.vue.mjs","sources":["../../../../../../../packages/components/src/subject-list/src/components/subject-text-fill.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { CirclePlus, Plus, 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\nconst props = defineProps<{\n orderIndex: number\n title?: string\n isSave: boolean\n showAction?: boolean\n answerList?: any\n analysis?: string\n isEdit: boolean\n isSet: boolean\n examExpand?: string\n examAnswerSettingVO?: {\n isInOrder: boolean\n isIgnoreCase: boolean\n keywordCount: number\n }\n examRichTextContent?: string\n showAnalysis?: boolean\n examAnswerRelationType?: number\n}>()\nconst emits = defineEmits(['move', 'save', 'delete', 'edit', 'add'])\n\nconst attrs = useAttrs()\n\nconst answers = ref<{\n title: string\n tag: string\n showInput: boolean\n}[]>([{\n title: '',\n tag: '',\n showInput: false,\n}])\n\nconst title = ref('')\nconst analysis = ref('')\nconst keywordCount = ref()\nconst correct = ref('')\nconst showRichText = ref(false)\nconst richText = ref('')\n\nconst checkList = [\n {\n label: '答案不分顺序',\n value: 'isInOrder',\n },\n {\n label: '忽略大小写',\n value: 'isIgnoreCase',\n },\n]\n\nconst isCheckList = ref(['isInOrder', 'isIgnoreCase'])\n\nfunction handleAddTag(item: any) {\n item.showInput = false\n if (item.tag) {\n item.title = item.title ? [item.title, item.tag].join(',') : item.tag\n item.tag = ''\n }\n}\n\nfunction closeTag(tag: string, item: any) {\n if (tag) {\n const tags = item.title.split(',')\n const index = tags.findIndex((i: string) => i === tag)\n if (index > -1) {\n tags.splice(index, 1)\n item.title = tags.join(',')\n }\n }\n}\n\nfunction addAnswer() {\n answers.value.push({\n title: '',\n tag: '',\n showInput: false,\n })\n}\n\nfunction deleteAnswer(index: number) {\n if (answers.value.length < 2 || props.isSave) {\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\n if (keywordCount.value || correct.value) {\n if (!keywordCount.value) {\n ElMessage.error('请完善答题设置!')\n return\n }\n\n if (!correct.value) {\n ElMessage.error('请输入问题正确答案!')\n return\n }\n\n if (answers.value.length !== keywordCount.value) {\n ElMessage.error('关键词个数设置有误!')\n return\n }\n const msg: string[] = []\n answers.value.forEach((item, index) => {\n if (!item.title) {\n msg.push(`关键词${index + 1}未设置`)\n }\n })\n if (msg.length > 0) {\n ElMessage.error(msg.join(','))\n return\n }\n }\n\n emits('save', {\n title: title.value,\n answers: answers.value.filter((i: any) => i.title).map((item: any) => {\n return { title: item.title }\n }),\n analysis: analysis.value,\n isSetCorrectAnswer: !!correct.value,\n examExpand: correct.value,\n examAnswerSettingBO: {\n isIgnoreCase: isCheckList.value?.includes('isIgnoreCase'),\n isInOrder: isCheckList.value?.includes('isInOrder'),\n ...{ keywordCount: keywordCount.value },\n },\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.examAnswerSettingVO) {\n // 仅保留与设置匹配的选项\n isCheckList.value = isCheckList.value.filter(item =>\n (item === 'isIgnoreCase' && props.examAnswerSettingVO?.isIgnoreCase)\n || (item === 'isInOrder' && props.examAnswerSettingVO?.isInOrder),\n )\n }\n\n if (props.examAnswerSettingVO?.keywordCount) {\n keywordCount.value = props.examAnswerSettingVO?.keywordCount\n }\n\n if (props.examExpand) {\n correct.value = props.examExpand\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\nonMounted(init)\nconst ns = useNamespace('subject-text-fill')\n</script>\n\n<template>\n <div :class=\"ns.e('text-fill-exam')\">\n <SubjectLayout :show-edit=\"isEdit\">\n <template #preview>\n <div class=\"preview\">\n <div class=\"content\">\n <span class=\"title\">{{ orderIndex + 1 }}.{{ title }}(问答题)</span>\n <div v-if=\"showRichText\">\n <div\n class=\"rich-text\"\n v-html=\"richText\"\n />\n </div>\n <div class=\"content flex flex-col\">\n <template v-if=\"answers.some(item => item.title)\">\n <el-checkbox\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"radio\"\n :disabled=\"true\"\n >\n {{ item.title }}\n </el-checkbox>\n </template>\n </div>\n <div\n v-if=\"correct\"\n class=\"flex\"\n style=\"margin-top: 10px;color: #a8abb2;\"\n >\n <span class=\"title\">正确答案:{{ correct }}</span>\n </div>\n </div>\n </div>\n </template>\n <template #edit>\n <div class=\"flex\">\n <div class=\"label flex flex-justify-end\">\n <span>题目:</span>\n </div>\n <div\n style=\"flex: 1;\"\n class=\"margin-bottom\"\n >\n <el-input\n v-model=\"title\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"【问答题】请输入问题\"\n :maxlength=\"200\"\n show-word-limit\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"margin-bottom flex flex-items-center\">\n <div class=\"label flex flex-justify-end\">\n <span>答题设置:</span>\n </div>\n <span>共答对</span>\n <el-input-number\n v-model=\"keywordCount\"\n style=\"width: 100px;margin: 0 10px;\"\n :min=\"1\"\n />\n <span style=\"margin-right: 10px;\">个关键词,算是正确的</span>\n <el-checkbox-group\n v-for=\"item in checkList\"\n :key=\"item.value\"\n v-model=\"isCheckList\"\n >\n <el-checkbox\n :label=\"item.value\"\n class=\"margin-left-10\"\n >\n {{ item.label }}\n </el-checkbox>\n </el-checkbox-group>\n </div>\n <div class=\"flex\">\n <div class=\"label flex flex-justify-end\">\n <span>答案:</span>\n </div>\n <div style=\"flex: 1;\">\n <el-input\n v-model=\"correct\"\n type=\"textarea\"\n :rows=\"2\"\n placeholder=\"请输入正确答案\"\n :maxlength=\"200\"\n show-word-limit\n :disabled=\"isSave\"\n />\n </div>\n </div>\n <div class=\"margin-bottom answer-list\">\n <span style=\"padding-left: 60px;\">*如遇包含特殊字符的关键词,需添加多个同义词,例:'CO₂'需添加同义词'CO2'</span>\n <div\n v-for=\"(item, index) in answers\"\n :key=\"index\"\n class=\"answer-item flex flex-items-center\"\n >\n <div class=\"label flex flex-justify-end\">\n <span>关键词{{ index + 1 }}:</span>\n </div>\n\n <div class=\"answer-tags\">\n <template\n v-for=\"i in item.title.split(',')\"\n :key=\"i\"\n >\n <el-tag\n v-if=\"i\"\n closable\n @close=\"closeTag(i, item)\"\n >\n {{ i }}\n </el-tag>\n </template>\n <template v-if=\"!isSave\">\n <el-input\n v-if=\"item.showInput\"\n v-model=\"item.tag\"\n style=\"width: 80px;\"\n @blur=\"() => handleAddTag(item)\"\n />\n <el-button\n v-else\n size=\"small\"\n @click=\"item.showInput = true\"\n >\n <el-icon><Plus /></el-icon>\n <span>{{ item.title ? '添加同义词' : '添加关键词' }}</span>\n </el-button>\n </template>\n </div>\n <div class=\"operation\">\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 < 2 || isSave }]\"\n @click=\"deleteAnswer(index)\"\n />\n </el-icon>\n </div>\n </div>\n </div>\n <div\n v-if=\"showAnalysis\"\n class=\"margin-bottom flex\"\n >\n <div class=\"label flex flex-justify-end\">\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\n v-if=\"showRichText\"\n class=\"margin-bottom flex\"\n >\n <div class=\"label flex flex-justify-center\">\n <span>富文本:</span>\n </div>\n <div style=\"flex: 1;\">\n <TinyMceEditor\n v-model:model-value=\"richText\"\n v-bind=\"attrs\"\n style=\"width: 100%;\"\n />\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 :show-other-option=\"false\"\n :exam-answer-relation-type=\"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 @on-show-rich-text=\"showRichText = true\"\n />\n </SubjectLayout>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","attrs","useAttrs","answers","ref","title","tag","showInput","analysis","keywordCount","correct","showRichText","richText","checkList","label","value","isCheckList","addAnswer","push","deleteRichText","save","ElMessage","error","length","msg","forEach","item","index","join","filter","i","map","isSetCorrectAnswer","examExpand","examAnswerSettingBO","isIgnoreCase","includes","isInOrder","examRichTextContent","onMounted","answerList","examAnswerSettingVO","ns","useNamespace","tags","split","findIndex","splice","isSave"],"mappings":"khFAQA,MAAMA,GAAQC,EAmBRC,GAAQC,GAERC,GAAQC,IAERC,GAAUC,EAIX,CAAC,CACJC,MAAO,GACPC,IAAK,GACLC,WAAW,KAGPF,GAAQD,EAAI,IACZI,GAAWJ,EAAI,IACfK,GAAeL,IACfM,GAAUN,EAAI,IACdO,GAAeP,GAAI,GACnBQ,GAAWR,EAAI,IAEfS,GAAY,CAChB,CACEC,MAAO,SACPC,MAAO,aAET,CACED,MAAO,QACPC,MAAO,iBAILC,GAAcZ,EAAI,CAAC,YAAa,iBAqBtC,SAASa,KACPd,GAAQY,MAAMG,KAAK,CACjBb,MAAO,GACPC,IAAK,GACLC,WAAW,GACZ,CAUH,SAASY,KACPR,GAAaI,OAAQ,EACrBH,GAASG,MAAQ,EAAA,CAGnB,SAASK,KACH,GAACf,GAAMU,MAAP,CAKA,GAAAN,GAAaM,OAASL,GAAQK,MAAO,CACnC,IAACN,GAAaM,MAEhB,YADAM,EAAUC,MAAM,YAId,IAACZ,GAAQK,MAEX,YADAM,EAAUC,MAAM,cAIlB,GAAInB,GAAQY,MAAMQ,SAAWd,GAAaM,MAExC,YADAM,EAAUC,MAAM,cAGlB,MAAME,EAAgB,GAMlB,GALJrB,GAAQY,MAAMU,SAAQ,CAACC,EAAMC,KACtBD,EAAKrB,OACRmB,EAAIN,KAAK,MAAMS,EAAQ,OAAM,IAG7BH,EAAID,OAAS,EAEf,YADAF,EAAUC,MAAME,EAAII,KAAK,KAE3B,CAGF7B,GAAM,OAAQ,CACZM,MAAOA,GAAMU,MACbZ,QAASA,GAAQY,MAAMc,QAAQC,GAAWA,EAAEzB,QAAO0B,KAAKL,IAC/C,CAAErB,MAAOqB,EAAKrB,UAE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,GACb,ueAsBF,SAAsBqB,GAChBxB,GAAQY,MAAMQ,OAAS,GAAK1B,GAAMmD,QAG9B7C,GAAAY,MAAMgC,OAAOpB,EAAO,EAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{defineComponent as e,ref as
|
1
|
+
import{defineComponent as e,ref as t,useAttrs as s,computed as n,watch as i,createElementBlock as a,openBlock as o,normalizeClass as l,unref as r,createElementVNode as d,Fragment as c,renderList as m,createBlock as u,createCommentVNode as p,mergeProps as x}from"vue";import{useNamespace as w}from"@qxs-bns/hooks";import{setGuid as v}from"@qxs-bns/utils";import y from"./components/subject-blank-fill.vue.mjs";import h from"./components/subject-scale.vue.mjs";import f from"./components/subject-single.vue.mjs";import E from"./components/subject-text-fill.vue.mjs";import T from"./components/SubjectPageEnd.vue.mjs";import S from"./components/SubjectRichText.vue.mjs";import{ElMessage as A}from"element-plus/es";import"element-plus/es/components/base/style/index";import"element-plus/es/components/message/style/index";const R={class:"subject-list-wrapper"};var g=e({name:"QxsSubjectList",__name:"subject-list",props:{subjectList:{type:Array,required:!0},isPreview:{type:Boolean,required:!0}},emits:["setRelation"],setup(e,{expose:g,emit:D}){const I=e,j=D,b=t([]),C=s();g({addSubject:M,currentList:b,uploadExcel:function(e){b.value=b.value.concat(e)},addExam:function(e){console.log(e,"items");let t=1;const s=[];e.forEach((e=>{const n={...e,customId:v(),answerType:e.richTextContent?"rich_text":e.examTypeEnum,answers:e.answers?.map((e=>({...e,title:e.answer,answerId:e.examAnswerId,isCorrect:e.isCorrect})))||[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1};n.pageIndex>t&&(s.push({customId:v(),answerType:"page_end",analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:0}),t=n.pageIndex),s.push(n)})),b.value=b.value.concat(s)},setAnswerRelation:function(e,t,s){const n=b.value.find((e=>e.customId===t));if(n){const t=n.answers?.find((e=>e.customAnswerId===s));t&&(t.answerRelations=e)}}});const _=n((()=>{const e=b.value.filter((e=>"page_end"===e.answerType));return t=>{const s=e.findIndex((e=>e.customId===t));return-1!==s?s+1:0}}));function k(){return e=>{let t=0,s=0;return b.value.forEach((n=>{"page_end"!==n.answerType&&(t++,e===n.customId&&(s=t))})),s-1}}function M(e,t=null,s=null){const n={customId:v(),answerType:e,analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:s};null!==t?b.value.splice(t+1,0,n):b.value.push(n)}function L(e,t){if("up"===t&&e>0){const[t]=b.value.splice(e,1);b.value.splice(e-1,0,t)}else if("down"===t&&e<b.value.length-1){const[t]=b.value.splice(e,1);b.value.splice(e+1,0,t)}}function P(e,t){b.value[e]={...b.value[e],...t,isEdit:!1,examAnswerRelationType:t.examAnswerRelationType}}function q(e){b.value.splice(e,1),A.success("删除成功")}function Q(e,t){j("setRelation",e,t)}i((()=>I.subjectList),(e=>{e&&(b.value=[...e])}),{immediate:!0});const O=w("subject-list");return(e,t)=>(o(),a("div",{class:l(r(O).e("list-exam"))},[d("div",R,[(o(!0),a(c,null,m(r(b),((t,s)=>(o(),a("div",{key:t.customId,class:"subject-item"},[["single","multiple","sort"].includes(t.answerType)?(o(),u(f,x({key:0,ref_for:!0},r(C),{"order-index":k()(t.customId),title:t.title,type:t.answerType,"exam-id":t.examId,"is-key":t.isKey,"is-save":!t.isRealCanDel,"custom-id":t.customId,"is-set":t.hasSet||!1,"answer-list":t.answers,analysis:t.analysis,"least-answer-count":t.leastAnswerCount,"is-edit":t.isEdit||!1,"show-action":!e.isPreview,"exam-expand":t.examExpand,"answer-check-type":t.answerCheckType,"exam-rich-text-content":t.examRichTextContent,"exam-answer-relation-type":t.examAnswerRelationType,onSetRelation:Q,onMove:e=>L(s,e),onDelete:e=>q(s),onSave:e=>P(s,e),onEdit:e=>t.isEdit=!0,onAdd:(e,t)=>M(e,s,t)}),null,16,["order-index","title","type","exam-id","is-key","is-save","custom-id","is-set","answer-list","analysis","least-answer-count","is-edit","show-action","exam-expand","answer-check-type","exam-rich-text-content","exam-answer-relation-type","onMove","onDelete","onSave","onEdit","onAdd"])):"scale"===t.answerType?(o(),u(h,x({key:1,ref_for:!0},r(C),{"order-index":k()(t.customId),title:t.title,"is-save":!t.isRealCanDel,"is-set":t.hasSet||!1,"answer-list":t.answers,analysis:t.analysis,"is-edit":t.isEdit||!1,"scale-question-list":t.scaleQuestionList,"show-action":!e.isPreview,"exam-rich-text-content":t.examRichTextContent,"exam-answer-relation-type":t.examAnswerRelationType,onMove:e=>L(s,e),onDelete:e=>q(s),onSave:e=>P(s,e),onEdit:e=>t.isEdit=!0,onAdd:e=>M(e,s,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","is-edit","scale-question-list","show-action","exam-rich-text-content","exam-answer-relation-type","onMove","onDelete","onSave","onEdit","onAdd"])):"blank_fill"===t.answerType?(o(),u(y,x({key:2,ref_for:!0},r(C),{"order-index":k()(t.customId),title:t.title,"is-save":!t.isRealCanDel,"is-set":t.hasSet||!1,"answer-list":t.answers,analysis:t.analysis,"show-action":!e.isPreview,"is-edit":t.isEdit||!1,"exam-answer-setting-v-o":t.examAnswerSettingVO||{},"exam-rich-text-content":t.examRichTextContent,"exam-answer-relation-type":t.examAnswerRelationType,onMove:e=>L(s,e),onDelete:e=>q(s),onSave:e=>P(s,e),onEdit:e=>t.isEdit=!0,onAdd:e=>M(e,s,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","exam-answer-relation-type","onMove","onDelete","onSave","onEdit","onAdd"])):"text_fill"===t.answerType?(o(),u(E,x({key:3,ref_for:!0},r(C),{"order-index":k()(t.customId),title:t.title,"is-save":!t.isRealCanDel,"is-set":t.hasSet||!1,"answer-list":t.answers,analysis:t.analysis,"show-action":!e.isPreview,"is-edit":t.isEdit||!1,"exam-expand":t.examExpand,"exam-answer-setting-v-o":t.examAnswerSettingVO||{},"exam-answer-relation-type":t.examAnswerRelationType,"exam-rich-text-content":t.examRichTextContent,onMove:e=>L(s,e),onDelete:e=>q(s),onSave:e=>P(s,e),onEdit:e=>t.isEdit=!0,onAdd:e=>M(e,s,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","show-action","is-edit","exam-expand","exam-answer-setting-v-o","exam-answer-relation-type","exam-rich-text-content","onMove","onDelete","onSave","onEdit","onAdd"])):"rich_text"===t.answerType?(o(),u(S,x({key:4,ref_for:!0},r(C),{"order-index":k()(t.customId),"rich-text-content":t.richTextContent,"is-set":t.hasSet||!1,"is-save":!t.isRealCanDel,"is-edit":t.isEdit||!1,"show-action":!e.isPreview,"exam-answer-relation-type":t.examAnswerRelationType,onMove:e=>L(s,e),onDelete:e=>q(s),onSave:e=>P(s,e),onEdit:e=>t.isEdit=!0,onAdd:e=>M(e,s,null)}),null,16,["order-index","rich-text-content","is-set","is-save","is-edit","show-action","exam-answer-relation-type","onMove","onDelete","onSave","onEdit","onAdd"])):"page_end"===t.answerType?(o(),u(T,{key:s,"total-page":b.value.filter((e=>"page_end"===e.answerType)).length,"current-page-index":r(_)(t.customId),item:t,"is-edit":t.isEdit||!1,"is-set":t.hasSet||!1,"is-save":!t.isRealCanDel,"exam-answer-relation-type":t.examAnswerRelationType,onMove:e=>L(s,e),onDelete:e=>q(s),onSave:e=>P(s,e),onEdit:e=>t.isEdit=!0,onAdd:e=>M(e,s,null)},null,8,["total-page","current-page-index","item","is-edit","is-set","is-save","exam-answer-relation-type","onMove","onDelete","onSave","onEdit","onAdd"])):p("v-if",!0)])))),128))])],2))}});export{g as default};
|
2
2
|
//# sourceMappingURL=subject-list.vue.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-list.vue.mjs","sources":["../../../../../../packages/components/src/subject-list/src/subject-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport SubjectBlankFill from './components/subject-blank-fill.vue'\nimport SubjectScale from './components/subject-scale.vue'\nimport SubjectSingle from './components/subject-single.vue'\nimport SubjectTextFill from './components/subject-text-fill.vue'\nimport SubjectRichText from './components/SubjectRichText.vue'\nimport SubjectPageEnd from './components/SubjectPageEnd.vue'\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { setGuid } from '@qxs-bns/utils'\n\ndefineOptions({\n name: 'QxsSubjectList',\n})\n\nconst props = defineProps<{\n subjectList: any[]\n isPreview: boolean\n}>()\nconst currentList = ref([] as any)\nconst emits = defineEmits(['setRelation'])\n\nconst attrs = useAttrs()\n\ndefineExpose({\n addSubject,\n currentList,\n uploadExcel,\n addExam,\n setAnswerRelation,\n})\n\nfunction totalPageIndex() {\n return currentList.value.filter((v: any) => v.answerType === 'page_end').length\n}\n\nconst currentPageIndex = computed(() => {\n const currentPageList = currentList.value.filter((v: any) => v.answerType === 'page_end')\n return (currentId: string) => {\n const currentIndex = currentPageList.findIndex((c: any) => c.customId === currentId)\n return currentIndex !== -1 ? currentIndex + 1 : 0\n }\n})\n\nfunction currentIndex() {\n return (currentExamId: string) => {\n let current = 0\n let output = 0\n\n // 遍历 currentList,过滤掉分页器,并计算题目序号\n currentList.value.forEach((v: any) => {\n if (v.answerType !== 'page_end') { // 排除分页器\n current++\n if (currentExamId === v.customId) { // 匹配当前题目 ID\n output = current\n }\n }\n })\n\n return output-1\n }\n}\n\nfunction addSubject(type: string, index: number | null = null, examAnswerRelationType: number | null = null) {\n const newSubject = {\n customId: setGuid(),\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType,\n }\n\n if (index !== null) {\n currentList.value.splice(index + 1, 0, newSubject)\n } else {\n currentList.value.push(newSubject)\n }\n}\nfunction addExam(items: any[]) {\n console.log(items, 'items')\n\n let currentIndex = 1\n const newList: any[] = []\n\n items.forEach((v: any) => {\n // 创建新的题目对象\n const newItem = {\n ...v,\n customId: setGuid(),\n answerType: v.richTextContent ? 'rich_text' : v.examTypeEnum,\n answers: v.answers?.map((c: any) => ({\n ...c,\n title: c.answer,\n answerId: c.examAnswerId,\n isCorrect: c.isCorrect,\n })) || [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n }\n\n // 如果当前题目的 pageIndex 和 currentIndex 不一致,则插入分页器\n if (newItem.pageIndex > currentIndex) {\n newList.push({\n customId: setGuid(),\n answerType: 'page_end',\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: 0,\n })\n currentIndex = newItem.pageIndex\n }\n\n // 将题目添加到 newList\n newList.push(newItem)\n })\n\n // 更新 currentList\n currentList.value = currentList.value.concat(newList)\n}\nfunction uploadExcel(list: any[]) {\n currentList.value = currentList.value.concat(list)\n}\n\nfunction move(index: number, type: 'up' | 'down') {\n if (type === 'up' && index > 0) {\n const [item] = currentList.value.splice(index, 1)\n currentList.value.splice(index - 1, 0, item)\n } else if (type === 'down' && index < currentList.value.length - 1) {\n const [item] = currentList.value.splice(index, 1)\n currentList.value.splice(index + 1, 0, item)\n }\n}\n\nfunction saveSubject(index: number, item: any) {\n currentList.value[index] = {\n ...currentList.value[index],\n ...item,\n isEdit: false,\n examAnswerRelationType: item.examAnswerRelationType,\n }\n}\n\nfunction deleteSubject(index: number) {\n currentList.value.splice(index, 1)\n ElMessage.success('删除成功')\n}\n\nfunction setRelation(customId: number, examAnswers: any) {\n emits('setRelation', customId, examAnswers)\n}\n\nfunction setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const targetItem = currentList.value.find((v: any) => v.customId === customId)\n if (targetItem) {\n const targetAnswer = targetItem.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (targetAnswer) {\n targetAnswer.answerRelations = answerRelations\n }\n }\n}\n\nwatch(() => props.subjectList, (newList: any) => {\n if (newList) {\n currentList.value = [...newList]\n }\n}, { immediate: true })\n\nconst ns = useNamespace('subject-list')\n</script>\n\n<template>\n <div :class=\"ns.e('list-exam')\">\n <div class=\"subject-list-wrapper\">\n <div v-for=\"(item, index) in currentList\" :key=\"item.customId\" class=\"subject-item\">\n <template v-if=\"['single', 'multiple', 'sort'].includes(item.answerType)\">\n <SubjectSingle\n v-bind=\"attrs\"\n :order-index=\"currentIndex()(item.customId)\"\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 />\n </template>\n <SubjectScale\n v-bind=\"attrs\"\n v-else-if=\"item.answerType === 'scale'\"\n :order-index=\"currentIndex()(item.customId)\"\n :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\"\n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\"\n :analysis=\"item.analysis\"\n :is-edit=\"item.isEdit || false\"\n :scale-question-list=\"item.scaleQuestionList\"\n :show-action=\"!isPreview\"\n :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\"\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) => addSubject(type, index, null)\"\n />\n <SubjectBlankFill\n v-bind=\"attrs\"\n v-else-if=\"item.answerType === 'blank_fill'\"\n :order-index=\"currentIndex()(item.customId)\"\n :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\"\n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\"\n :analysis=\"item.analysis\"\n :show-action=\"!isPreview\"\n :is-edit=\"item.isEdit || false\"\n :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\"\n :exam-rich-text-content=\"item.examRichTextContent\"\n :examAnswerRelationType=\"item.examAnswerRelationType\"\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) => addSubject(type, index, null)\"\n />\n <SubjectTextFill\n v-bind=\"attrs\"\n v-else-if=\"item.answerType === 'text_fill'\"\n :order-index=\"currentIndex()(item.customId)\"\n :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\"\n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\"\n :analysis=\"item.analysis\"\n :show-action=\"!isPreview\"\n :is-edit=\"item.isEdit || false\"\n :exam-expand=\"item.examExpand\"\n :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\"\n :examAnswerRelationType=\"item.examAnswerRelationType\"\n :exam-rich-text-content=\"item.examRichTextContent\"\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) => addSubject(type, index, null)\"\n />\n <SubjectRichText\n v-bind=\"attrs\"\n :order-index=\"currentIndex()(item.customId)\"\n v-else-if=\"item.answerType === 'rich_text'\"\n :richTextContent=\"item.richTextContent\"\n :is-set=\"item.hasSet || false\"\n :is-save=\"!item.isRealCanDel\"\n :is-edit=\"item.isEdit || false\"\n :show-action=\"!isPreview\"\n @move=\"(type: 'up' | 'down') => move(index, type)\"\n @delete=\"deleteSubject(index)\"\n :examAnswerRelationType=\"item.examAnswerRelationType\"\n @save=\"(item: any) => saveSubject(index, item)\"\n @edit=\"item.isEdit = true\"\n @add=\"(type: string) => addSubject(type, index, null)\"\n />\n <SubjectPageEnd\n v-else-if=\"item.answerType === 'page_end'\"\n :total-page=\"totalPageIndex()\"\n :key=\"index\"\n :current-page-index=\"currentPageIndex(item.customId)\"\n :item=\"item\"\n :is-edit=\"item.isEdit || false\"\n :is-set=\"item.hasSet || false\"\n :is-save=\"!item.isRealCanDel\"\n :examAnswerRelationType=\"item.examAnswerRelationType\"\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) => addSubject(type, index, null)\"\n />\n </div>\n </div>\n </div>\n</template>"],"names":["props","__props","currentList","ref","emits","__emit","attrs","useAttrs","__expose","addSubject","uploadExcel","list","value","concat","addExam","items","console","log","currentIndex","newList","forEach","v","newItem","customId","setGuid","answerType","richTextContent","examTypeEnum","answers","map","c","title","answer","answerId","examAnswerId","isCorrect","isSave","isEdit","isRealCanDel","hasSet","pageIndex","push","analysis","scaleQuestionList","examAnswerRelationType","setAnswerRelation","answerRelations","customAnswerId","targetItem","find","targetAnswer","currentPageIndex","computed","currentPageList","filter","currentId","findIndex","currentExamId","current","output","type","index","newSubject","splice","move","item","length","saveSubject","deleteSubject","ElMessage","success","setRelation","examAnswers","watch","subjectList","immediate","ns","useNamespace"],"mappings":"ihCAcA,MAAMA,EAAQC,EAIRC,EAAcC,EAAI,IAClBC,EAAQC,EAERC,EAAQC,IAEDC,EAAA,CACXC,aACAP,cACAQ,YAsGF,SAAqBC,GACnBT,EAAYU,MAAQV,EAAYU,MAAMC,OAAOF,EAAI,EAtGjDG,QAsDF,SAAiBC,GACPC,QAAAC,IAAIF,EAAO,SAEnB,IAAIG,EAAe,EACnB,MAAMC,EAAiB,GAEjBJ,EAAAK,SAASC,IAEb,MAAMC,EAAU,IACXD,EACHE,SAAUC,IAC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ACVC,WAAYmC,EACZlB,SAAU,GACVC,kBAAmB,GACnBP,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRK,0BAGY,OAAViB,EACF3D,EAAYU,MAAMmD,OAAOF,EAAQ,EAAG,EAAGC,GAE3B5D,EAAAU,MAAM6B,KAAKqB,EACzB,CAqDO,SAAAE,EAAKH,EAAeD,GACvB,GAAS,OAATA,GAAiBC,EAAQ,EAAG,CAC9B,MAAOI,GAAQ/D,EAAYU,MAAMmD,OAAOF,EAAO,GAC/C3D,EAAYU,MAAMmD,OAAOF,EAAQ,EAAG,EAAGI,EAAI,SACzB,SAATL,GAAmBC,EAAQ3D,EAAYU,MAAMsD,OAAS,EAAG,CAClE,MAAOD,GAAQ/D,EAAYU,MAAMmD,OAAOF,EAAO,GAC/C3D,EAAYU,MAAMmD,OAAOF,EAAQ,EAAG,EAAGI,EAAI,CAC7C,CAGO,SAAAE,EAAYN,EAAeI,GACtB/D,EAAAU,MAAMiD,GAAS,IACtB3D,EAAYU,MAAMiD,MAClBI,EACH5B,QAAQ,EACRO,uBAAwBqB,EAAKrB,uBAC/B,CAGF,SAASwB,EAAcP,GACT3D,EAAAU,MAAMmD,OAAOF,EAAO,GAChCQ,EAAUC,QAAQ,OAAM,CAGjB,SAAAC,EAAYhD,EAAkBiD,GAC/BpE,EAAA,cAAemB,EAAUiD,EAAW,CAa5CC,GAAM,IAAMzE,EAAM0E,cAAcvD,IAC1BA,IACUjB,EAAAU,MAAQ,IAAIO,GAAO,GAEhC,CAAEwD,WAAW,IAEV,MAAAC,EAAKC,EAAa,ixHAhJf3E,EAAYU,MAAM0C,QAAQjC,GAA4B,aAAjBA,EAAEI,aAA2ByC"}
|
1
|
+
{"version":3,"file":"subject-list.vue.mjs","sources":["../../../../../../packages/components/src/subject-list/src/subject-list.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useNamespace } from '@qxs-bns/hooks'\nimport { setGuid } from '@qxs-bns/utils'\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 SubjectPageEnd from './components/SubjectPageEnd.vue'\nimport SubjectRichText from './components/SubjectRichText.vue'\n\ndefineOptions({\n name: 'QxsSubjectList',\n})\n\nconst props = defineProps<{\n subjectList: any[]\n isPreview: boolean\n}>()\nconst emits = defineEmits(['setRelation'])\nconst currentList = ref([] as any)\nconst attrs = useAttrs()\n\ndefineExpose({\n addSubject,\n currentList,\n uploadExcel,\n addExam,\n setAnswerRelation,\n})\n\nfunction totalPageIndex() {\n return currentList.value.filter((v: any) => v.answerType === 'page_end').length\n}\n\nconst currentPageIndex = computed(() => {\n const currentPageList = currentList.value.filter((v: any) => v.answerType === 'page_end')\n return (currentId: string) => {\n const currentIndex = currentPageList.findIndex((c: any) => c.customId === currentId)\n return currentIndex !== -1 ? currentIndex + 1 : 0\n }\n})\n\nfunction currentIndex() {\n return (currentExamId: string) => {\n let current = 0\n let output = 0\n\n // 遍历 currentList,过滤掉分页器,并计算题目序号\n currentList.value.forEach((v: any) => {\n if (v.answerType !== 'page_end') { // 排除分页器\n current++\n if (currentExamId === v.customId) { // 匹配当前题目 ID\n output = current\n }\n }\n })\n\n return output - 1\n }\n}\n\nfunction addSubject(type: string, index: number | null = null, examAnswerRelationType: number | null = null) {\n const newSubject = {\n customId: setGuid(),\n answerType: type,\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType,\n }\n\n if (index !== null) {\n currentList.value.splice(index + 1, 0, newSubject)\n }\n else {\n currentList.value.push(newSubject)\n }\n}\nfunction addExam(items: any[]) {\n console.log(items, 'items')\n\n let currentIndex = 1\n const newList: any[] = []\n\n items.forEach((v: any) => {\n // 创建新的题目对象\n const newItem = {\n ...v,\n customId: setGuid(),\n answerType: v.richTextContent ? 'rich_text' : v.examTypeEnum,\n answers: v.answers?.map((c: any) => ({\n ...c,\n title: c.answer,\n answerId: c.examAnswerId,\n isCorrect: c.isCorrect,\n })) || [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n }\n\n // 如果当前题目的 pageIndex 和 currentIndex 不一致,则插入分页器\n if (newItem.pageIndex > currentIndex) {\n newList.push({\n customId: setGuid(),\n answerType: 'page_end',\n analysis: '',\n scaleQuestionList: [],\n isSave: false,\n isEdit: true,\n isRealCanDel: true,\n hasSet: false,\n examAnswerRelationType: 0,\n })\n currentIndex = newItem.pageIndex\n }\n\n // 将题目添加到 newList\n newList.push(newItem)\n })\n\n // 更新 currentList\n currentList.value = currentList.value.concat(newList)\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 currentList.value[index] = {\n ...currentList.value[index],\n ...item,\n isEdit: false,\n examAnswerRelationType: item.examAnswerRelationType,\n }\n}\n\nfunction deleteSubject(index: number) {\n currentList.value.splice(index, 1)\n ElMessage.success('删除成功')\n}\n\nfunction setRelation(customId: number, examAnswers: any) {\n emits('setRelation', customId, examAnswers)\n}\n\nfunction setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const targetItem = currentList.value.find((v: any) => v.customId === customId)\n if (targetItem) {\n const targetAnswer = targetItem.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (targetAnswer) {\n targetAnswer.answerRelations = answerRelations\n }\n }\n}\n\nwatch(() => props.subjectList, (newList: any) => {\n if (newList) {\n currentList.value = [...newList]\n }\n}, { immediate: true })\n\nconst ns = useNamespace('subject-list')\n</script>\n\n<template>\n <div :class=\"ns.e('list-exam')\">\n <div class=\"subject-list-wrapper\">\n <div\n v-for=\"(item, index) in currentList\"\n :key=\"item.customId\"\n class=\"subject-item\"\n >\n <template v-if=\"['single', 'multiple', 'sort'].includes(item.answerType)\">\n <SubjectSingle\n v-bind=\"attrs\"\n :order-index=\"currentIndex()(item.customId)\"\n :title=\"item.title\"\n :type=\"item.answerType\"\n :exam-id=\"item.examId\"\n :is-key=\"item.isKey\"\n :is-save=\"!item.isRealCanDel\"\n :custom-id=\"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 :answer-check-type=\"item.answerCheckType\"\n :exam-rich-text-content=\"item.examRichTextContent\"\n :exam-answer-relation-type=\"item.examAnswerRelationType\"\n @set-relation=\"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 />\n </template>\n <SubjectScale\n v-else-if=\"item.answerType === 'scale'\"\n v-bind=\"attrs\"\n :order-index=\"currentIndex()(item.customId)\"\n :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\"\n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\"\n :analysis=\"item.analysis\"\n :is-edit=\"item.isEdit || false\"\n :scale-question-list=\"item.scaleQuestionList\"\n :show-action=\"!isPreview\"\n :exam-rich-text-content=\"item.examRichTextContent\"\n :exam-answer-relation-type=\"item.examAnswerRelationType\"\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) => addSubject(type, index, null)\"\n />\n <SubjectBlankFill\n v-else-if=\"item.answerType === 'blank_fill'\"\n v-bind=\"attrs\"\n :order-index=\"currentIndex()(item.customId)\"\n :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\"\n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\"\n :analysis=\"item.analysis\"\n :show-action=\"!isPreview\"\n :is-edit=\"item.isEdit || false\"\n :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\"\n :exam-rich-text-content=\"item.examRichTextContent\"\n :exam-answer-relation-type=\"item.examAnswerRelationType\"\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) => addSubject(type, index, null)\"\n />\n <SubjectTextFill\n v-else-if=\"item.answerType === 'text_fill'\"\n v-bind=\"attrs\"\n :order-index=\"currentIndex()(item.customId)\"\n :title=\"item.title\"\n :is-save=\"!item.isRealCanDel\"\n :is-set=\"item.hasSet || false\"\n :answer-list=\"item.answers\"\n :analysis=\"item.analysis\"\n :show-action=\"!isPreview\"\n :is-edit=\"item.isEdit || false\"\n :exam-expand=\"item.examExpand\"\n :exam-answer-setting-v-o=\"item.examAnswerSettingVO || {}\"\n :exam-answer-relation-type=\"item.examAnswerRelationType\"\n :exam-rich-text-content=\"item.examRichTextContent\"\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) => addSubject(type, index, null)\"\n />\n <SubjectRichText\n v-else-if=\"item.answerType === 'rich_text'\"\n v-bind=\"attrs\"\n :order-index=\"currentIndex()(item.customId)\"\n :rich-text-content=\"item.richTextContent\"\n :is-set=\"item.hasSet || false\"\n :is-save=\"!item.isRealCanDel\"\n :is-edit=\"item.isEdit || false\"\n :show-action=\"!isPreview\"\n :exam-answer-relation-type=\"item.examAnswerRelationType\"\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) => addSubject(type, index, null)\"\n />\n <SubjectPageEnd\n v-else-if=\"item.answerType === 'page_end'\"\n :key=\"index\"\n :total-page=\"totalPageIndex()\"\n :current-page-index=\"currentPageIndex(item.customId)\"\n :item=\"item\"\n :is-edit=\"item.isEdit || false\"\n :is-set=\"item.hasSet || false\"\n :is-save=\"!item.isRealCanDel\"\n :exam-answer-relation-type=\"item.examAnswerRelationType\"\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) => addSubject(type, index, null)\"\n />\n </div>\n </div>\n </div>\n</template>\n"],"names":["props","__props","emits","__emit","currentList","ref","attrs","useAttrs","__expose","addSubject","uploadExcel","list","value","concat","addExam","items","console","log","currentIndex","newList","forEach","v","newItem","customId","setGuid","answerType","richTextContent","examTypeEnum","answers","map","c","title","answer","answerId","examAnswerId","isCorrect","isSave","isEdit","isRealCanDel","hasSet","pageIndex","push","analysis","scaleQuestionList","examAnswerRelationType","setAnswerRelation","answerRelations","customAnswerId","targetItem","find","targetAnswer","currentPageIndex","computed","currentPageList","filter","currentId","findIndex","currentExamId","current","output","type","index","newSubject","splice","move","item","length","saveSubject","deleteSubject","ElMessage","success","setRelation","examAnswers","watch","subjectList","immediate","ns","useNamespace"],"mappings":"ihCAcA,MAAMA,EAAQC,EAIRC,EAAQC,EACRC,EAAcC,EAAI,IAClBC,EAAQC,IAEDC,EAAA,CACXC,aACAL,cACAM,YAuGF,SAAqBC,GACnBP,EAAYQ,MAAQR,EAAYQ,MAAMC,OAAOF,EAAI,EAvGjDG,QAuDF,SAAiBC,GACPC,QAAAC,IAAIF,EAAO,SAEnB,IAAIG,EAAe,EACnB,MAAMC,EAAiB,GAEjBJ,EAAAK,SAASC,IAEb,MAAMC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ACrG,MAAMkB,EAAa,CACjBvC,SAAUC,IACVC,WAAYmC,EACZlB,SAAU,GACVC,kBAAmB,GACnBP,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,QAAQ,EACRK,0BAGY,OAAViB,EACFzD,EAAYQ,MAAMmD,OAAOF,EAAQ,EAAG,EAAGC,GAG3B1D,EAAAQ,MAAM6B,KAAKqB,EACzB,CAqDO,SAAAE,EAAKH,EAAeD,GACvB,GAAS,OAATA,GAAiBC,EAAQ,EAAG,CAC9B,MAAOI,GAAQ7D,EAAYQ,MAAMmD,OAAOF,EAAO,GAC/CzD,EAAYQ,MAAMmD,OAAOF,EAAQ,EAAG,EAAGI,EAAI,SAE3B,SAATL,GAAmBC,EAAQzD,EAAYQ,MAAMsD,OAAS,EAAG,CAChE,MAAOD,GAAQ7D,EAAYQ,MAAMmD,OAAOF,EAAO,GAC/CzD,EAAYQ,MAAMmD,OAAOF,EAAQ,EAAG,EAAGI,EAAI,CAC7C,CAGO,SAAAE,EAAYN,EAAeI,GACtB7D,EAAAQ,MAAMiD,GAAS,IACtBzD,EAAYQ,MAAMiD,MAClBI,EACH5B,QAAQ,EACRO,uBAAwBqB,EAAKrB,uBAC/B,CAGF,SAASwB,EAAcP,GACTzD,EAAAQ,MAAMmD,OAAOF,EAAO,GAChCQ,EAAUC,QAAQ,OAAM,CAGjB,SAAAC,EAAYhD,EAAkBiD,GAC/BtE,EAAA,cAAeqB,EAAUiD,EAAW,CAa5CC,GAAM,IAAMzE,EAAM0E,cAAcvD,IAC1BA,IACUf,EAAAQ,MAAQ,IAAIO,GAAO,GAEhC,CAAEwD,WAAW,IAEV,MAAAC,EAAKC,EAAa,m1HAlJfzE,EAAYQ,MAAM0C,QAAQjC,GAA4B,aAAjBA,EAAEI,aAA2ByC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/src/subject-type/index.ts"],"sourcesContent":["import { withInstall } from '../withInstall'\nimport component from './src/subject-type.vue'\n\nconst QxsSubjectType = withInstall(component)\n
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/src/subject-type/index.ts"],"sourcesContent":["import { withInstall } from '../withInstall'\nimport component from './src/subject-type.vue'\n\nconst QxsSubjectType = withInstall(component)\n\nexport {\n QxsSubjectType,\n}\n\nexport default QxsSubjectType\n"],"names":["QxsSubjectType","withInstall","component"],"mappings":"2FAGA,MAAMA,EAAiBC,EAAYC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"subject-type.vue.mjs","sources":["../../../../../../packages/components/src/subject-type/src/subject-type.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useNamespace } from '@qxs-bns/hooks'\n\ndefineOptions({\n name: 'QxsSubjectType',\n})\nconst emits = defineEmits(['select'])\nconst subjectOptions = ref([\n {\n type: 'single',\n label: '单选题',\n }, {\n type: 'multiple',\n label: '多选题',\n },\n {\n type: 'blank_fill',\n label: '填空题',\n },\n {\n type: 'text_fill',\n label: '问答题',\n },\n {\n type: 'scale',\n label: '量表题',\n },\n {\n type: 'sort',\n label: '排序题',\n },\n])\nconst otherOptions = ref([\n {\n type: 'rich_text',\n label: '富文本',\n },\n {\n type: 'page_end',\n label: '分页器',\n },\n])\nconst interactionOptions = ref([\n {\n type: 'single',\n label: '单选题',\n }, {\n type: 'multiple',\n label: '多选题',\n },\n])\nconst ns = useNamespace('subject-type')\n
|
1
|
+
{"version":3,"file":"subject-type.vue.mjs","sources":["../../../../../../packages/components/src/subject-type/src/subject-type.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useNamespace } from '@qxs-bns/hooks'\n\ndefineOptions({\n name: 'QxsSubjectType',\n})\nconst emits = defineEmits(['select'])\nconst subjectOptions = ref([\n {\n type: 'single',\n label: '单选题',\n }, {\n type: 'multiple',\n label: '多选题',\n },\n {\n type: 'blank_fill',\n label: '填空题',\n },\n {\n type: 'text_fill',\n label: '问答题',\n },\n {\n type: 'scale',\n label: '量表题',\n },\n {\n type: 'sort',\n label: '排序题',\n },\n])\nconst otherOptions = ref([\n {\n type: 'rich_text',\n label: '富文本',\n },\n {\n type: 'page_end',\n label: '分页器',\n },\n])\nconst interactionOptions = ref([\n {\n type: 'single',\n label: '单选题',\n }, {\n type: 'multiple',\n label: '多选题',\n },\n])\nconst ns = useNamespace('subject-type')\n</script>\n\n<template>\n <div :class=\"ns.e('type-list')\">\n <div class=\"type-item\">\n <div>普通题目类型</div>\n <div class=\"base-subject\">\n <div\n v-for=\"item in subjectOptions\"\n :key=\"item.type\"\n class=\"item flex-center\"\n @click=\"emits('select', item.type)\"\n >\n <span>{{ item.label }}</span>\n </div>\n </div>\n </div>\n <div class=\"type-item\">\n <div>其他</div>\n <div class=\"base-subject flex\">\n <div\n v-for=\"item in otherOptions\"\n :key=\"item.type\"\n class=\"item flex-center\"\n @click=\"emits('select', item.type)\"\n >\n <span>{{ item.label }}</span>\n </div>\n </div>\n </div>\n <div class=\"type-item\">\n <div>互动问答类型(支持设置结果项)</div>\n <div class=\"base-subject flex\">\n <div\n v-for=\"item in interactionOptions\"\n :key=\"item.type\"\n class=\"item flex-center\"\n @click=\"emits('select', item.type, true)\"\n >\n <span>{{ item.label }}</span>\n </div>\n </div>\n </div>\n </div>\n</template>\n"],"names":["emits","__emit","subjectOptions","ref","type","label","otherOptions","interactionOptions","ns","useNamespace"],"mappings":"6gBAMA,MAAMA,EAAQC,EACRC,EAAiBC,EAAI,CACzB,CACEC,KAAM,SACNC,MAAO,OACN,CACDD,KAAM,WACNC,MAAO,OAET,CACED,KAAM,aACNC,MAAO,OAET,CACED,KAAM,YACNC,MAAO,OAET,CACED,KAAM,QACNC,MAAO,OAET,CACED,KAAM,OACNC,MAAO,SAGLC,EAAeH,EAAI,CACvB,CACEC,KAAM,YACNC,MAAO,OAET,CACED,KAAM,WACNC,MAAO,SAGLE,EAAqBJ,EAAI,CAC7B,CACEC,KAAM,SACNC,MAAO,OACN,CACDD,KAAM,WACNC,MAAO,SAGLG,EAAKC,EAAa"}
|
package/lib/index.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./src/defaults.cjs"),
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./src/defaults.cjs"),t=require("./src/data-chart/index.cjs"),s=require("./src/file-upload/index.cjs"),r=require("./src/fixed-action-bar/index.cjs"),o=require("./src/image-upload/index.cjs"),c=require("./src/photo-crop-tool/index.cjs"),i=require("./src/subject-action/index.cjs"),a=require("./src/subject-layout/index.cjs"),x=require("./src/subject-list/index.cjs"),u=require("./src/subject-type/index.cjs"),p=require("./src/tiny-mce-editor/index.cjs"),n=require("./src/data-chart/src/analyze.cjs"),d=require("./src/data-chart/src/utils/config.cjs");const l=e.default.install,j=e.default.version;exports.default=e.default,exports.QxsDataChart=t.QxsDataChart,exports.QxsFileUpload=s.QxsFileUpload,exports.QxsFixedActionBar=r.QxsFixedActionBar,exports.QxsImageUpload=o.QxsImageUpload,exports.QxsPhotoCropTool=c.QxsPhotoCropTool,exports.QxsSubjectAction=i.QxsSubjectAction,exports.QxsSubjectLayout=a.QxsSubjectLayout,exports.QxsSubjectList=x.QxsSubjectList,exports.QxsSubjectType=u.QxsSubjectType,exports.QxsTinyMceEditor=p.QxsTinyMceEditor,exports.getObjectValue=n.getObjectValue,exports.keysMap=n.keysMap,exports.defaultChartOption=d.defaultChartOption,exports.getGeoJsonData=d.getGeoJsonData,exports.iconList=d.iconList,exports.setDefaultChartOption=d.setDefaultChartOption,exports.showTypeText=d.showTypeText,exports.install=l,exports.version=j;
|
2
2
|
//# sourceMappingURL=index.cjs.map
|