@qxs-bns/components 0.0.48 → 0.0.49

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.
Files changed (177) hide show
  1. package/es/index.css +5 -5
  2. package/es/package.json.mjs +1 -1
  3. package/es/src/data-chart/src/components/area.vue2.mjs.map +1 -1
  4. package/es/src/data-chart/src/components/bar.vue.mjs +1 -1
  5. package/es/src/data-chart/src/components/bar.vue.mjs.map +1 -1
  6. package/es/src/data-chart/src/components/card.vue2.mjs.map +1 -1
  7. package/es/src/data-chart/src/components/empty.svg.mjs +1 -1
  8. package/es/src/data-chart/src/components/empty.svg.mjs.map +1 -1
  9. package/es/src/data-chart/src/components/empty.vue.mjs +1 -1
  10. package/es/src/data-chart/src/components/empty.vue.mjs.map +1 -1
  11. package/es/src/data-chart/src/components/funnel.vue.mjs +1 -1
  12. package/es/src/data-chart/src/components/funnel.vue.mjs.map +1 -1
  13. package/es/src/data-chart/src/components/line.vue2.mjs +1 -1
  14. package/es/src/data-chart/src/components/line.vue2.mjs.map +1 -1
  15. package/es/src/data-chart/src/components/pie.vue.mjs +1 -1
  16. package/es/src/data-chart/src/components/pie.vue.mjs.map +1 -1
  17. package/es/src/data-chart/src/components/radar.vue.mjs +1 -1
  18. package/es/src/data-chart/src/components/radar.vue.mjs.map +1 -1
  19. package/es/src/data-chart/src/components/scatter-simple.vue.mjs +1 -1
  20. package/es/src/data-chart/src/components/scatter-simple.vue.mjs.map +1 -1
  21. package/es/src/data-chart/src/components/scatter.vue.mjs +1 -1
  22. package/es/src/data-chart/src/components/scatter.vue.mjs.map +1 -1
  23. package/es/src/data-chart/src/components/table.vue.mjs +1 -1
  24. package/es/src/data-chart/src/components/table.vue.mjs.map +1 -1
  25. package/es/src/data-chart/src/data-chart.vue.mjs +1 -1
  26. package/es/src/data-chart/src/data-chart.vue.mjs.map +1 -1
  27. package/es/src/data-chart/src/utils/config.mjs +1 -1
  28. package/es/src/data-chart/src/utils/config.mjs.map +1 -1
  29. package/es/src/data-chart/src/utils/safe-eval.mjs +2 -0
  30. package/es/src/data-chart/src/utils/safe-eval.mjs.map +1 -0
  31. package/es/src/data-chart/src/utils/useCharts.mjs +1 -1
  32. package/es/src/data-chart/src/utils/useCharts.mjs.map +1 -1
  33. package/es/src/file-upload/src/file-upload.vue.mjs +1 -1
  34. package/es/src/file-upload/src/file-upload.vue.mjs.map +1 -1
  35. package/es/src/fixed-action-bar/src/fixed-action-bar.vue.mjs +1 -1
  36. package/es/src/fixed-action-bar/src/fixed-action-bar.vue.mjs.map +1 -1
  37. package/es/src/image-upload/src/image-upload.vue.mjs +1 -1
  38. package/es/src/image-upload/src/image-upload.vue.mjs.map +1 -1
  39. package/es/src/photo-crop-tool/src/photo-crop-tool.vue.mjs.map +1 -1
  40. package/es/src/subject-action/index.mjs.map +1 -1
  41. package/es/src/subject-action/src/subject-action.vue.mjs +1 -1
  42. package/es/src/subject-action/src/subject-action.vue.mjs.map +1 -1
  43. package/es/src/subject-layout/index.mjs.map +1 -1
  44. package/es/src/subject-layout/src/subject-layout.vue.mjs.map +1 -1
  45. package/es/src/subject-list/src/components/SubjectPageEnd.vue.mjs +1 -1
  46. package/es/src/subject-list/src/components/SubjectPageEnd.vue.mjs.map +1 -1
  47. package/es/src/subject-list/src/components/SubjectRichText.vue.mjs +1 -1
  48. package/es/src/subject-list/src/components/SubjectRichText.vue.mjs.map +1 -1
  49. package/es/src/subject-list/src/components/subject-blank-fill.vue.mjs +1 -1
  50. package/es/src/subject-list/src/components/subject-blank-fill.vue.mjs.map +1 -1
  51. package/es/src/subject-list/src/components/subject-scale.vue.mjs +1 -1
  52. package/es/src/subject-list/src/components/subject-scale.vue.mjs.map +1 -1
  53. package/es/src/subject-list/src/components/subject-single.vue.mjs +1 -1
  54. package/es/src/subject-list/src/components/subject-single.vue.mjs.map +1 -1
  55. package/es/src/subject-list/src/components/subject-text-fill.vue.mjs +1 -1
  56. package/es/src/subject-list/src/components/subject-text-fill.vue.mjs.map +1 -1
  57. package/es/src/subject-list/src/subject-list.vue.mjs +1 -1
  58. package/es/src/subject-list/src/subject-list.vue.mjs.map +1 -1
  59. package/es/src/subject-type/index.mjs.map +1 -1
  60. package/es/src/subject-type/src/subject-type.vue.mjs.map +1 -1
  61. package/lib/index.css +5 -5
  62. package/lib/package.json.cjs +1 -1
  63. package/lib/src/data-chart/src/components/area.vue2.cjs.map +1 -1
  64. package/lib/src/data-chart/src/components/bar.vue.cjs +1 -1
  65. package/lib/src/data-chart/src/components/bar.vue.cjs.map +1 -1
  66. package/lib/src/data-chart/src/components/card.vue2.cjs.map +1 -1
  67. package/lib/src/data-chart/src/components/empty.svg.cjs +1 -1
  68. package/lib/src/data-chart/src/components/empty.svg.cjs.map +1 -1
  69. package/lib/src/data-chart/src/components/empty.vue.cjs +1 -1
  70. package/lib/src/data-chart/src/components/empty.vue.cjs.map +1 -1
  71. package/lib/src/data-chart/src/components/funnel.vue.cjs +1 -1
  72. package/lib/src/data-chart/src/components/funnel.vue.cjs.map +1 -1
  73. package/lib/src/data-chart/src/components/line.vue2.cjs +1 -1
  74. package/lib/src/data-chart/src/components/line.vue2.cjs.map +1 -1
  75. package/lib/src/data-chart/src/components/pie.vue.cjs +1 -1
  76. package/lib/src/data-chart/src/components/pie.vue.cjs.map +1 -1
  77. package/lib/src/data-chart/src/components/radar.vue.cjs +1 -1
  78. package/lib/src/data-chart/src/components/radar.vue.cjs.map +1 -1
  79. package/lib/src/data-chart/src/components/scatter-simple.vue.cjs +1 -1
  80. package/lib/src/data-chart/src/components/scatter-simple.vue.cjs.map +1 -1
  81. package/lib/src/data-chart/src/components/scatter.vue.cjs +1 -1
  82. package/lib/src/data-chart/src/components/scatter.vue.cjs.map +1 -1
  83. package/lib/src/data-chart/src/components/table.vue.cjs +1 -1
  84. package/lib/src/data-chart/src/components/table.vue.cjs.map +1 -1
  85. package/lib/src/data-chart/src/data-chart.vue.cjs +1 -1
  86. package/lib/src/data-chart/src/data-chart.vue.cjs.map +1 -1
  87. package/lib/src/data-chart/src/utils/config.cjs +1 -1
  88. package/lib/src/data-chart/src/utils/config.cjs.map +1 -1
  89. package/lib/src/data-chart/src/utils/safe-eval.cjs +2 -0
  90. package/lib/src/data-chart/src/utils/safe-eval.cjs.map +1 -0
  91. package/lib/src/data-chart/src/utils/useCharts.cjs +1 -1
  92. package/lib/src/data-chart/src/utils/useCharts.cjs.map +1 -1
  93. package/lib/src/file-upload/src/file-upload.vue.cjs +1 -1
  94. package/lib/src/file-upload/src/file-upload.vue.cjs.map +1 -1
  95. package/lib/src/fixed-action-bar/src/fixed-action-bar.vue.cjs +1 -1
  96. package/lib/src/fixed-action-bar/src/fixed-action-bar.vue.cjs.map +1 -1
  97. package/lib/src/image-upload/src/image-upload.vue.cjs +1 -1
  98. package/lib/src/image-upload/src/image-upload.vue.cjs.map +1 -1
  99. package/lib/src/photo-crop-tool/src/photo-crop-tool.vue.cjs.map +1 -1
  100. package/lib/src/subject-action/index.cjs.map +1 -1
  101. package/lib/src/subject-action/src/subject-action.vue.cjs +1 -1
  102. package/lib/src/subject-action/src/subject-action.vue.cjs.map +1 -1
  103. package/lib/src/subject-layout/index.cjs.map +1 -1
  104. package/lib/src/subject-layout/src/subject-layout.vue.cjs.map +1 -1
  105. package/lib/src/subject-list/src/components/SubjectPageEnd.vue.cjs +1 -1
  106. package/lib/src/subject-list/src/components/SubjectPageEnd.vue.cjs.map +1 -1
  107. package/lib/src/subject-list/src/components/SubjectRichText.vue.cjs +1 -1
  108. package/lib/src/subject-list/src/components/SubjectRichText.vue.cjs.map +1 -1
  109. package/lib/src/subject-list/src/components/subject-blank-fill.vue.cjs +1 -1
  110. package/lib/src/subject-list/src/components/subject-blank-fill.vue.cjs.map +1 -1
  111. package/lib/src/subject-list/src/components/subject-scale.vue.cjs +1 -1
  112. package/lib/src/subject-list/src/components/subject-scale.vue.cjs.map +1 -1
  113. package/lib/src/subject-list/src/components/subject-single.vue.cjs +1 -1
  114. package/lib/src/subject-list/src/components/subject-single.vue.cjs.map +1 -1
  115. package/lib/src/subject-list/src/components/subject-text-fill.vue.cjs +1 -1
  116. package/lib/src/subject-list/src/components/subject-text-fill.vue.cjs.map +1 -1
  117. package/lib/src/subject-list/src/subject-list.vue.cjs +1 -1
  118. package/lib/src/subject-list/src/subject-list.vue.cjs.map +1 -1
  119. package/lib/src/subject-type/index.cjs.map +1 -1
  120. package/lib/src/subject-type/src/subject-type.vue.cjs.map +1 -1
  121. package/package.json +4 -11
  122. package/theme-chalk/index.css +1 -1
  123. package/theme-chalk/src/base.scss +2 -2
  124. package/theme-chalk/src/fixed-action-bar.css +1 -1
  125. package/theme-chalk/src/fixed-action-bar.scss +1 -1
  126. package/theme-chalk/src/image-upload.css +1 -1
  127. package/theme-chalk/src/image-upload.scss +3 -1
  128. package/theme-chalk/src/subject-action.css +1 -1
  129. package/theme-chalk/src/subject-action.scss +3 -2
  130. package/theme-chalk/src/subject-layout.scss +19 -19
  131. package/theme-chalk/src/subject-list.css +1 -1
  132. package/theme-chalk/src/subject-list.scss +15 -14
  133. package/theme-chalk/src/tiny-mce-editor.scss +4 -2
  134. package/types/src/data-chart/src/components/area.vue.d.ts.map +1 -1
  135. package/types/src/data-chart/src/components/bar.vue.d.ts.map +1 -1
  136. package/types/src/data-chart/src/components/card.vue.d.ts.map +1 -1
  137. package/types/src/data-chart/src/components/empty.vue.d.ts.map +1 -1
  138. package/types/src/data-chart/src/components/funnel.vue.d.ts.map +1 -1
  139. package/types/src/data-chart/src/components/line.vue.d.ts.map +1 -1
  140. package/types/src/data-chart/src/components/pie.vue.d.ts +1 -1
  141. package/types/src/data-chart/src/components/pie.vue.d.ts.map +1 -1
  142. package/types/src/data-chart/src/components/radar.vue.d.ts.map +1 -1
  143. package/types/src/data-chart/src/components/scatter-simple.vue.d.ts.map +1 -1
  144. package/types/src/data-chart/src/components/scatter.vue.d.ts.map +1 -1
  145. package/types/src/data-chart/src/components/table.vue.d.ts.map +1 -1
  146. package/types/src/data-chart/src/data-chart.vue.d.ts.map +1 -1
  147. package/types/src/data-chart/src/utils/config.d.ts.map +1 -1
  148. package/types/src/data-chart/src/utils/safe-eval.d.ts +9 -0
  149. package/types/src/data-chart/src/utils/safe-eval.d.ts.map +1 -0
  150. package/types/src/data-chart/src/utils/useCharts.d.ts +4 -4
  151. package/types/src/data-chart/src/utils/useCharts.d.ts.map +1 -1
  152. package/types/src/file-upload/src/file-upload.vue.d.ts +5 -5
  153. package/types/src/file-upload/src/file-upload.vue.d.ts.map +1 -1
  154. package/types/src/fixed-action-bar/index.d.ts +3 -3
  155. package/types/src/fixed-action-bar/src/fixed-action-bar.vue.d.ts +1 -1
  156. package/types/src/fixed-action-bar/src/fixed-action-bar.vue.d.ts.map +1 -1
  157. package/types/src/image-upload/src/image-upload.vue.d.ts +6 -6
  158. package/types/src/image-upload/src/image-upload.vue.d.ts.map +1 -1
  159. package/types/src/photo-crop-tool/src/photo-crop-tool.vue.d.ts.map +1 -1
  160. package/types/src/subject-action/index.d.ts +11 -11
  161. package/types/src/subject-action/index.d.ts.map +1 -1
  162. package/types/src/subject-action/src/subject-action.vue.d.ts +10 -10
  163. package/types/src/subject-action/src/subject-action.vue.d.ts.map +1 -1
  164. package/types/src/subject-layout/index.d.ts +1 -1
  165. package/types/src/subject-layout/index.d.ts.map +1 -1
  166. package/types/src/subject-layout/src/subject-layout.vue.d.ts.map +1 -1
  167. package/types/src/subject-list/src/components/SubjectPageEnd.vue.d.ts.map +1 -1
  168. package/types/src/subject-list/src/components/SubjectRichText.vue.d.ts.map +1 -1
  169. package/types/src/subject-list/src/components/subject-blank-fill.vue.d.ts.map +1 -1
  170. package/types/src/subject-list/src/components/subject-scale.vue.d.ts.map +1 -1
  171. package/types/src/subject-list/src/components/subject-single.vue.d.ts.map +1 -1
  172. package/types/src/subject-list/src/components/subject-text-fill.vue.d.ts.map +1 -1
  173. package/types/src/subject-list/src/subject-list.vue.d.ts.map +1 -1
  174. package/types/src/subject-type/index.d.ts +1 -1
  175. package/types/src/subject-type/index.d.ts.map +1 -1
  176. package/types/src/subject-type/src/subject-type.vue.d.ts.map +1 -1
  177. package/types/tsconfig.tsbuildinfo +1 -1
@@ -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,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,CACTC,MAAO,OAAOJ,KACdC,MAAOD,IAGX,OAAOD,EAAMM,SAAQ,IAEvB,SAASC,KACHjC,GAAMkC,QAGVvB,GAAQiB,MAAME,KAAK,CACjBlB,MAAO,GACPC,WAAW,EACXsB,eAAgBC,KACjB,CA+BH,SAASC,KACPrB,GAAaY,OAAQ,EACrBX,GAASW,MAAQ,EAAA,CAGnB,SAASU,KACH,IAAC1B,GAAMgB,MAET,YADAW,EAAUC,MAAM,aAIf,IAAC/B,GAAgBmB,MAElB,YADAW,EAAUC,MAAM,WAGlB,IAAIC,EAAM,GACNC,GAAqB,EACrBC,EAAqB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GAAMe,WACRA,GAASa,MAAQ5B,GAAMe,UAGrBf,GAAM6D,sBACR5C,GAASW,MAAQ5B,GAAM6D,oBACvB7C,GAAaY,OAAQ,EACvB,uqGAtJO,SAAW4D,EAASC,GACR,WAAfzF,GAAMuB,MAEJkE,GACM9E,GAAAiB,MAAMgB,SAASsC,IACjBA,IAAWM,IACbN,EAAOrE,WAAY,EAAA,IAIzB2E,EAAG3E,UAAY4E,GACS,aAAfzF,GAAMuB,OAEfiE,EAAG3E,UAAY4E,EACjB,gXArBF,SAAsBjC,GAChB7C,GAAQiB,MAAMC,OAAS,GAAK7B,GAAMkC,QAG9BvB,GAAAiB,MAAM8D,OAAOlC,EAAO,EAAC,qJA2JTV,IACpBxC,GAAasB,MAAQkB,EACrB1B,GAAWQ,MAAQjB,GAAQiB,MAAMkB,GAAG1B,YAAc,QAClDD,GAAgBS,OAAQ,GAH1B,IAAsBkB,yMAxItB,SAAqBQ,GACdA,EAAAnB,eAAiBmB,EAAKqC,cAAgBvD,IACrClC,GAAA,cAAeF,GAAM4F,SAAUtC,EAAI"}
1
+ {"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,IACz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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 T from"../../../subject-action/src/subject-action.vue.mjs";import E from"../../../subject-layout/src/subject-layout.vue.mjs";import R from"../../../tiny-mce-editor/src/tiny-mce-editor.vue.mjs";const U={class:"preview"},B={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(E,{"show-edit":u.isEdit},{preview:y((()=>[h("div",U,[h("div",B,[h("span",L,S(u.orderIndex+1)+"."+S(x(ue))+"(问答题)",1),x(pe)?(c(),p("div",M,[h("div",{innerHTML:x(ce),class:"rich-text"},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(R,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(T,{key:0,"is-edit":u.isEdit,"is-set":u.isSet,showOtherOption:!1,examAnswerRelationType: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","examAnswerRelationType"])):g("v-if",!0)])),_:1},8,["show-edit"])],2)}}});export{se as default};
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":"khFAQ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CuB,oBAAqB3B,GAAaI,MAAQH,GAASG,MAAQ,IA3C3D,MADAM,EAAUC,MAAM,YA6CjB,CAsCHiB,GAnCA,WACM1C,GAAMQ,QACRA,GAAMU,MAAQlB,GAAMQ,OAGlBR,GAAM2C,YAAc3C,GAAM2C,WAAWjB,SACvCpB,GAAQY,MAAQlB,GAAM2C,YAGpB3C,GAAM4C,sBAEIzB,GAAAD,MAAQC,GAAYD,MAAMc,QAAOH,GACjC,iBAATA,GAA2B7B,GAAM4C,qBAAqBN,cAC1C,cAATT,GAAwB7B,GAAM4C,qBAAqBJ,aAIvDxC,GAAM4C,qBAAqBhC,eAChBA,GAAAM,MAAQlB,GAAM4C,qBAAqBhC,cAG9CZ,GAAMoC,aACRvB,GAAQK,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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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,2 +1,2 @@
1
- import{defineComponent as e,ref as s,useAttrs as t,computed as n,watch as i,createElementBlock as a,openBlock as o,normalizeClass as l,unref as r,createElementVNode as d,Fragment as c,renderList as m,createBlock as u,createCommentVNode as p,mergeProps as x}from"vue";import w from"./components/subject-blank-fill.vue.mjs";import v from"./components/subject-scale.vue.mjs";import y from"./components/subject-single.vue.mjs";import h from"./components/subject-text-fill.vue.mjs";import T from"./components/SubjectRichText.vue.mjs";import f from"./components/SubjectPageEnd.vue.mjs";import{useNamespace as A}from"@qxs-bns/hooks";import{setGuid as R}from"@qxs-bns/utils";import{ElMessage as E}from"element-plus/es";import"element-plus/es/components/base/style/index";import"element-plus/es/components/message/style/index";const S={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:C}){const I=e,D=s([]),j=C,b=t();g({addSubject:M,currentList:D,uploadExcel:function(e){D.value=D.value.concat(e)},addExam:function(e){console.log(e,"items");let s=1;const t=[];e.forEach((e=>{const n={...e,customId:R(),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>s&&(t.push({customId:R(),answerType:"page_end",analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:0}),s=n.pageIndex),t.push(n)})),D.value=D.value.concat(t)},setAnswerRelation:function(e,s,t){const n=D.value.find((e=>e.customId===s));if(n){const s=n.answers?.find((e=>e.customAnswerId===t));s&&(s.answerRelations=e)}}});const _=n((()=>{const e=D.value.filter((e=>"page_end"===e.answerType));return s=>{const t=e.findIndex((e=>e.customId===s));return-1!==t?t+1:0}}));function k(){return e=>{let s=0,t=0;return D.value.forEach((n=>{"page_end"!==n.answerType&&(s++,e===n.customId&&(t=s))})),t-1}}function M(e,s=null,t=null){const n={customId:R(),answerType:e,analysis:"",scaleQuestionList:[],isSave:!1,isEdit:!0,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:t};null!==s?D.value.splice(s+1,0,n):D.value.push(n)}function L(e,s){if("up"===s&&e>0){const[s]=D.value.splice(e,1);D.value.splice(e-1,0,s)}else if("down"===s&&e<D.value.length-1){const[s]=D.value.splice(e,1);D.value.splice(e+1,0,s)}}function P(e,s){D.value[e]={...D.value[e],...s,isEdit:!1,examAnswerRelationType:s.examAnswerRelationType}}function q(e){D.value.splice(e,1),E.success("删除成功")}function Q(e,s){j("setRelation",e,s)}i((()=>I.subjectList),(e=>{e&&(D.value=[...e])}),{immediate:!0});const K=A("subject-list");return(e,s)=>(o(),a("div",{class:l(r(K).e("list-exam"))},[d("div",S,[(o(!0),a(c,null,m(r(D),((s,t)=>(o(),a("div",{key:s.customId,class:"subject-item"},[["single","multiple","sort"].includes(s.answerType)?(o(),u(y,x({key:0,ref_for:!0},r(b),{"order-index":k()(s.customId),title:s.title,type:s.answerType,"exam-id":s.examId,isKey:s.isKey,"is-save":!s.isRealCanDel,customId:s.customId,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"least-answer-count":s.leastAnswerCount,"is-edit":s.isEdit||!1,"show-action":!e.isPreview,"exam-expand":s.examExpand,answerCheckType:s.answerCheckType,"exam-rich-text-content":s.examRichTextContent,examAnswerRelationType:s.examAnswerRelationType,onSetRelation:Q,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:(e,s)=>M(e,t,s)}),null,16,["order-index","title","type","exam-id","isKey","is-save","customId","is-set","answer-list","analysis","least-answer-count","is-edit","show-action","exam-expand","answerCheckType","exam-rich-text-content","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):"scale"===s.answerType?(o(),u(v,x({key:1,ref_for:!0},r(b),{"order-index":k()(s.customId),title:s.title,"is-save":!s.isRealCanDel,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"is-edit":s.isEdit||!1,"scale-question-list":s.scaleQuestionList,"show-action":!e.isPreview,"exam-rich-text-content":s.examRichTextContent,examAnswerRelationType:s.examAnswerRelationType,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","is-edit","scale-question-list","show-action","exam-rich-text-content","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):"blank_fill"===s.answerType?(o(),u(w,x({key:2,ref_for:!0},r(b),{"order-index":k()(s.customId),title:s.title,"is-save":!s.isRealCanDel,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"show-action":!e.isPreview,"is-edit":s.isEdit||!1,"exam-answer-setting-v-o":s.examAnswerSettingVO||{},"exam-rich-text-content":s.examRichTextContent,examAnswerRelationType:s.examAnswerRelationType,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","show-action","is-edit","exam-answer-setting-v-o","exam-rich-text-content","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):"text_fill"===s.answerType?(o(),u(h,x({key:3,ref_for:!0},r(b),{"order-index":k()(s.customId),title:s.title,"is-save":!s.isRealCanDel,"is-set":s.hasSet||!1,"answer-list":s.answers,analysis:s.analysis,"show-action":!e.isPreview,"is-edit":s.isEdit||!1,"exam-expand":s.examExpand,"exam-answer-setting-v-o":s.examAnswerSettingVO||{},examAnswerRelationType:s.examAnswerRelationType,"exam-rich-text-content":s.examRichTextContent,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","title","is-save","is-set","answer-list","analysis","show-action","is-edit","exam-expand","exam-answer-setting-v-o","examAnswerRelationType","exam-rich-text-content","onMove","onDelete","onSave","onEdit","onAdd"])):"rich_text"===s.answerType?(o(),u(T,x({key:4,ref_for:!0},r(b),{"order-index":k()(s.customId),richTextContent:s.richTextContent,"is-set":s.hasSet||!1,"is-save":!s.isRealCanDel,"is-edit":s.isEdit||!1,"show-action":!e.isPreview,onMove:e=>L(t,e),onDelete:e=>q(t),examAnswerRelationType:s.examAnswerRelationType,onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)}),null,16,["order-index","richTextContent","is-set","is-save","is-edit","show-action","onMove","onDelete","examAnswerRelationType","onSave","onEdit","onAdd"])):"page_end"===s.answerType?(o(),u(f,{"total-page":D.value.filter((e=>"page_end"===e.answerType)).length,key:t,"current-page-index":r(_)(s.customId),item:s,"is-edit":s.isEdit||!1,"is-set":s.hasSet||!1,"is-save":!s.isRealCanDel,examAnswerRelationType:s.examAnswerRelationType,onMove:e=>L(t,e),onDelete:e=>q(t),onSave:e=>P(t,e),onEdit:e=>s.isEdit=!0,onAdd:e=>M(e,t,null)},null,8,["total-page","current-page-index","item","is-edit","is-set","is-save","examAnswerRelationType","onMove","onDelete","onSave","onEdit","onAdd"])):p("v-if",!0)])))),128))])],2))}});export{g as default};
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,IACVC,WAAYJ,EAAEK,gBAAkB,YAAcL,EAAE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,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,EAAU,IACXD,EACHE,SAAUC,IACVC,WAAYJ,EAA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YmC,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 \nexport {\n QxsSubjectType\n}\n \nexport default QxsSubjectType"],"names":["QxsSubjectType","withInstall","component"],"mappings":"2FAGA,MAAMA,EAAiBC,EAAYC"}
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\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 v-for=\"item in subjectOptions\" :key=\"item.type\" class=\"item flex-center\"\n @click=\"emits('select', item.type)\">\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 v-for=\"item in otherOptions\" :key=\"item.type\" class=\"item flex-center\" @click=\"emits('select', item.type)\">\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 v-for=\"item in interactionOptions\" :key=\"item.type\" class=\"item flex-center\"\n @click=\"emits('select', item.type, true)\">\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"}
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.css CHANGED
@@ -1,9 +1,4 @@
1
1
  /* unplugin-vue-components disabled */
2
- .line-vue-vue-type-style-index-0-scoped-397864aa-lang_data-chart-line__IKZEs[data-v-397864aa] {
3
- width: 100%;
4
- height: 100%;
5
- }
6
- /* unplugin-vue-components disabled */
7
2
  .area-vue-vue-type-style-index-0-scoped-51660d7b-lang_data-chart-area-wrap__nAnr8[data-v-51660d7b] {
8
3
  position: relative;
9
4
  }
@@ -80,4 +75,9 @@
80
75
  padding: 0 30px 10px 20px;
81
76
  font-size: 14px;
82
77
  color: #464646;
78
+ }
79
+ /* unplugin-vue-components disabled */
80
+ .line-vue-vue-type-style-index-0-scoped-397864aa-lang_data-chart-line__IKZEs[data-v-397864aa] {
81
+ width: 100%;
82
+ height: 100%;
83
83
  }
@@ -1,2 +1,2 @@
1
- "use strict";exports.version="0.0.48";
1
+ "use strict";exports.version="0.0.49";
2
2
  //# sourceMappingURL=package.json.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"area.vue2.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/area.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ECharts } from 'echarts/types/dist/echarts'\nimport type { EChartsOption, GeoJson, IFormatPublicData } from '../types'\nimport * as echarts from 'echarts'\nimport { getGeoJsonData } from '../utils/config'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\ndefineOptions({\n name: 'DataChartArea',\n})\n\nconst {\n chartOptions,\n chartData = {\n colDesc: [],\n xGroupByDesc: {\n colDesc: '',\n groupByDesc: '',\n groupByValues: [],\n xAxis: false,\n },\n groupByDesc: [],\n data: [],\n modelName: '',\n },\n} = defineProps<{\n chartOptions: EChartsOption\n chartData?: IFormatPublicData\n}>()\n\nconst merge = inject(InjectionChartMerge, (v: any) => v, true)\n\nlet adcode = '中国'\nconst currentGeoJson = ref<GeoJson>({\n features: [],\n type: 'FeatureCollection',\n})\nconst dataChartArea = ref(null)\nlet myChart: ECharts | null = null\n\nconst areaChartOptions = computed<EChartsOption>(() => {\n const { xGroupByDesc, groupByDesc, colDesc, modelName, data } = chartData\n const allNums: number[] = []\n colDesc.forEach((item) => {\n data.forEach((dataItem) => {\n allNums.push(Number(dataItem[item]))\n })\n })\n const config = {\n title: {\n text: modelName,\n },\n tooltip: {\n formatter(params: { name: string }) {\n let res = `${params.name}<br/>`\n config.series?.forEach((colDescItem) => {\n colDescItem.data?.forEach((item) => {\n if (item.name === params.name) {\n res += `${colDescItem.name}:${item.value}</br>`\n }\n })\n if (!res.includes(colDescItem.name)) {\n res += `${colDescItem.name}:-</br>`\n }\n })\n return res\n },\n },\n visualMap: {\n min: Math.min(...allNums, 0),\n max: Math.max(...allNums, 0),\n },\n series: colDesc?.map((colDescItem) => {\n const seriesData = []\n const row = groupByDesc.find(item => item.colDesc === (adcode === '中国' ? '医院所在省' : '医院所在市'))\n // 先用省份数据,如果没有再用市级数据\n\n const arr: {\n [key: string]: number\n } = {}\n data.map((item) => {\n const sourceName = item[(adcode === '中国' ? (xGroupByDesc?.colDesc || '') : row?.colDesc) || '']\n const find = currentGeoJson.value.features?.find(({ properties: { name } }: { properties: { name?: string } }) => name?.includes(sourceName as string))\n return {\n name: find?.properties?.name || '',\n value: Number(item[colDescItem]),\n }\n }).forEach((item) => {\n if (!arr[item.name]) {\n arr[item.name] = item.value\n }\n else {\n arr[item.name] = arr[item.name] + item.value\n }\n })\n for (const key in arr) {\n seriesData.push({\n name: key,\n value: arr[key],\n })\n }\n return {\n name: colDescItem,\n type: 'map',\n map: adcode,\n data: seriesData,\n }\n }),\n }\n\n return merge(config, chartOptions)\n})\n// const propsXgroupByInfos = computed(() => {\n// const { groupByDesc } = chartData\n// const [row] = groupByDesc.filter(item => item.colDesc === '医院所在省')\n// if (row) {\n// return row\n// }\n// else {\n// const [res] = groupByDesc.filter(item => item.colDesc === '医院所在市')\n// return res\n// }\n// })\n// const selectList = computed(() => {\n// let arr = [{ label: '中国', value: '中国' }]\n// if (chartData.groupByDesc.length === 1 && propsXgroupByInfos.value?.colDesc === '医院所在市') {\n// const {\n// data,\n// xGroupByDesc: { colDesc },\n// } = chartData\n// arr = data.map((item) => {\n// return {\n// label: item[colDesc],\n// value: item[colDesc],\n// }\n// })\n// }\n// return arr\n// })\n\n// const isShowSelect = computed(() => {\n// const { groupByDesc } = chartData.value\n// return groupByDesc[0] && groupByDesc[0].colDesc !== '医院所在省' && groupByDesc.length === 1 && selectList.value.length\n// })\n\nasync function initAfter() {\n await registerMap()\n // 添加判断,确保图表实例存在且未被销毁\n if (myChart && !myChart.isDisposed()) {\n // charts 监听事件\n myChart.getZr()?.on('click', (params: { target: HTMLElement }) => {\n if (!params.target && adcode !== '中国') {\n registerMap('中国')\n }\n })\n myChart.on('click', (params: { name: string }) => {\n const flag = chartData.groupByDesc?.some(item => item.colDesc === '医院所在市')\n\n if (adcode === '中国' && flag) {\n registerMap(params.name).then(() => {\n if (myChart && !myChart.isDisposed()) {\n myChart.setOption(areaChartOptions.value)\n }\n })\n }\n })\n }\n}\n// function selectChina() {\n// registerMap(adcode)\n// }\nasync function registerMap(keyword = '中国') {\n if (!myChart || myChart.isDisposed()) {\n return\n }\n\n myChart.showLoading()\n try {\n const geoJson = await getGeoJsonData({ adcode: keyword })\n if (!geoJson) {\n myChart.hideLoading() // 添加加载状态的清除\n return\n }\n currentGeoJson.value = geoJson\n adcode = keyword\n\n const result = echarts.registerMap(keyword, geoJson as any)\n myChart.hideLoading() // 添加加载状态的清除\n return result\n }\n catch (error) {\n console.log(error)\n myChart.hideLoading() // 添加加载状态的清除\n }\n}\nuseCharts({\n chartDOM: dataChartArea,\n chartOptions: areaChartOptions,\n chartData: computed(() => chartData),\n initAfter,\n callback: (chart) => {\n myChart = chart\n },\n})\n</script>\n\n<template>\n <div class=\"data-chart-area-wrap\">\n <!-- <el-select\n v-if=\"isShowSelect\"\n v-model=\"adcode\"\n class=\"city-select\"\n size=\"small\"\n @change=\"selectChina\"\n >\n <el-option\n v-for=\"item in selectList\"\n :key=\"item.value\"\n :label=\"item.label\"\n :value=\"item.value\"\n />\n </el-select> -->\n <div ref=\"dataChartArea\" class=\"data-chart-area\" />\n </div>\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-area-wrap {\n position: relative;\n\n .city-select {\n position: absolute;\n top: 10px;\n right: 100px;\n z-index: 1;\n width: 120px;\n }\n\n .data-chart-area {\n height: 100%;\n }\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","adcode","currentGeoJson","ref","features","type","dataChartArea","myChart","areaChartOptions","computed","xGroupByDesc","groupByDesc","colDesc","modelName","data","__props","chartData","allNums","forEach","item","dataItem","push","Number","config","title","text","tooltip","formatter","params","res","name","series","colDescItem","value","includes","visualMap","min","Math","max","map","seriesData","row","find","arr","sourceName","properties","key","chartOptions","async","registerMap","keyword","isDisposed","showLoading","geoJson","getGeoJsonData","hideLoading","result","echarts","error","console","log","useCharts","chartDOM","initAfter","getZr","on","target","flag","some","then","setOption","callback","chart"],"mappings":"wyBA+BA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,qBAAsBC,GAAWA,IAAG,GAEzD,IAAIC,EAAS,KACb,MAAMC,EAAiBC,EAAAA,IAAa,CAClCC,SAAU,GACVC,KAAM,sBAEFC,EAAgBH,MAAI,MAC1B,IAAII,EAA0B,KAExB,MAAAC,EAAmBC,EAAAA,UAAwB,KAC/C,MAAMC,aAAEA,EAAcC,YAAAA,EAAAC,QAAaA,YAASC,EAAWC,KAAAA,GAASC,EAAAC,UAC1DC,EAAoB,GAClBL,EAAAM,SAASC,IACVL,EAAAI,SAASE,IACZH,EAAQI,KAAKC,OAAOF,EAASD,IAAM,GACpC,IAEH,MAAMI,EAAS,CACbC,MAAO,CACLC,KAAMZ,GAERa,QAAS,CACP,SAAAC,CAAUC,GACJ,IAAAC,EAAM,GAAGD,EAAOE,YAWb,OAVAP,EAAAQ,QAAQb,SAASc,IACVA,EAAAlB,MAAMI,SAASC,IACrBA,EAAKW,OAASF,EAAOE,OACvBD,GAAO,GAAGG,EAAYF,QAAQX,EAAKc,aAAK,IAGvCJ,EAAIK,SAASF,EAAYF,QACrBD,GAAA,GAAGG,EAAYF,cAAI,IAGvBD,CAAA,GAGXM,UAAW,CACTC,IAAKC,KAAKD,OAAOnB,EAAS,GAC1BqB,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1B+C,UAtDFf,uBACQC,IAEF1C,IAAYA,EAAQ4C,eAEtB5C,EAAQyD,SAASC,GAAG,SAAUrC,IACvBA,EAAOsC,QAAqB,OAAXjE,GACpBgD,EAAY,KAAI,IAGZ1C,EAAA0D,GAAG,SAAUrC,IACb,MAAAuC,EAAOpD,EAASC,UAACL,aAAayD,MAAajD,GAAiB,UAAjBA,EAAKP,UAEvC,OAAXX,GAAmBkE,GACrBlB,EAAYrB,EAAOE,MAAMuC,MAAK,KACxB9D,IAAYA,EAAQ4C,cACd5C,EAAA+D,UAAU9D,EAAiByB,MAAK,GAE3C,IAGP,EAkCAsC,SAAWC,IACCjE,EAAAiE,CAAA"}
1
+ {"version":3,"file":"area.vue2.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/area.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ECharts } from 'echarts/types/dist/echarts'\nimport type { EChartsOption, GeoJson, IFormatPublicData } from '../types'\nimport * as echarts from 'echarts'\nimport { getGeoJsonData } from '../utils/config'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\ndefineOptions({\n name: 'DataChartArea',\n})\n\nconst {\n chartOptions,\n chartData = {\n colDesc: [],\n xGroupByDesc: {\n colDesc: '',\n groupByDesc: '',\n groupByValues: [],\n xAxis: false,\n },\n groupByDesc: [],\n data: [],\n modelName: '',\n },\n} = defineProps<{\n chartOptions: EChartsOption\n chartData?: IFormatPublicData\n}>()\n\nconst merge = inject(InjectionChartMerge, (v: any) => v, true)\n\nlet adcode = '中国'\nconst currentGeoJson = ref<GeoJson>({\n features: [],\n type: 'FeatureCollection',\n})\nconst dataChartArea = ref(null)\nlet myChart: ECharts | null = null\n\nconst areaChartOptions = computed<EChartsOption>(() => {\n const { xGroupByDesc, groupByDesc, colDesc, modelName, data } = chartData\n const allNums: number[] = []\n colDesc.forEach((item) => {\n data.forEach((dataItem) => {\n allNums.push(Number(dataItem[item]))\n })\n })\n const config = {\n title: {\n text: modelName,\n },\n tooltip: {\n formatter(params: { name: string }) {\n let res = `${params.name}<br/>`\n config.series?.forEach((colDescItem) => {\n colDescItem.data?.forEach((item) => {\n if (item.name === params.name) {\n res += `${colDescItem.name}:${item.value}</br>`\n }\n })\n if (!res.includes(colDescItem.name)) {\n res += `${colDescItem.name}:-</br>`\n }\n })\n return res\n },\n },\n visualMap: {\n min: Math.min(...allNums, 0),\n max: Math.max(...allNums, 0),\n },\n series: colDesc?.map((colDescItem) => {\n const seriesData = []\n const row = groupByDesc.find(item => item.colDesc === (adcode === '中国' ? '医院所在省' : '医院所在市'))\n // 先用省份数据,如果没有再用市级数据\n\n const arr: {\n [key: string]: number\n } = {}\n data.map((item) => {\n const sourceName = item[(adcode === '中国' ? (xGroupByDesc?.colDesc || '') : row?.colDesc) || '']\n const find = currentGeoJson.value.features?.find(({ properties: { name } }: { properties: { name?: string } }) => name?.includes(sourceName as string))\n return {\n name: find?.properties?.name || '',\n value: Number(item[colDescItem]),\n }\n }).forEach((item) => {\n if (!arr[item.name]) {\n arr[item.name] = item.value\n }\n else {\n arr[item.name] = arr[item.name] + item.value\n }\n })\n for (const key in arr) {\n seriesData.push({\n name: key,\n value: arr[key],\n })\n }\n return {\n name: colDescItem,\n type: 'map',\n map: adcode,\n data: seriesData,\n }\n }),\n }\n\n return merge(config, chartOptions)\n})\n\nasync function initAfter() {\n await registerMap()\n // 添加判断,确保图表实例存在且未被销毁\n if (myChart && !myChart.isDisposed()) {\n // charts 监听事件\n myChart.getZr()?.on('click', (params: { target: HTMLElement }) => {\n if (!params.target && adcode !== '中国') {\n registerMap('中国')\n }\n })\n myChart.on('click', (params: { name: string }) => {\n const flag = chartData.groupByDesc?.some(item => item.colDesc === '医院所在市')\n\n if (adcode === '中国' && flag) {\n registerMap(params.name).then(() => {\n if (myChart && !myChart.isDisposed()) {\n myChart.setOption(areaChartOptions.value)\n }\n })\n }\n })\n }\n}\n// function selectChina() {\n// registerMap(adcode)\n// }\nasync function registerMap(keyword = '中国') {\n if (!myChart || myChart.isDisposed()) {\n return\n }\n\n myChart.showLoading()\n try {\n const geoJson = await getGeoJsonData({ adcode: keyword })\n if (!geoJson) {\n myChart.hideLoading() // 添加加载状态的清除\n return\n }\n currentGeoJson.value = geoJson\n adcode = keyword\n\n const result = echarts.registerMap(keyword, geoJson as any)\n myChart.hideLoading() // 添加加载状态的清除\n return result\n }\n catch (error) {\n console.log(error)\n myChart.hideLoading() // 添加加载状态的清除\n }\n}\nuseCharts({\n chartDOM: dataChartArea,\n chartOptions: areaChartOptions,\n chartData: computed(() => chartData),\n initAfter,\n callback: (chart) => {\n myChart = chart\n },\n})\n</script>\n\n<template>\n <div class=\"data-chart-area-wrap\">\n <!-- <el-select\n v-if=\"isShowSelect\"\n v-model=\"adcode\"\n class=\"city-select\"\n size=\"small\"\n @change=\"selectChina\"\n >\n <el-option\n v-for=\"item in selectList\"\n :key=\"item.value\"\n :label=\"item.label\"\n :value=\"item.value\"\n />\n </el-select> -->\n <div\n ref=\"dataChartArea\"\n class=\"data-chart-area\"\n />\n </div>\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-area-wrap {\n position: relative;\n\n .city-select {\n position: absolute;\n top: 10px;\n right: 100px;\n z-index: 1;\n width: 120px;\n }\n\n .data-chart-area {\n height: 100%;\n }\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","adcode","currentGeoJson","ref","features","type","dataChartArea","myChart","areaChartOptions","computed","xGroupByDesc","groupByDesc","colDesc","modelName","data","__props","chartData","allNums","forEach","item","dataItem","push","Number","config","title","text","tooltip","formatter","params","res","name","series","colDescItem","value","includes","visualMap","min","Math","max","map","seriesData","row","find","arr","sourceName","properties","key","chartOptions","async","registerMap","keyword","isDisposed","showLoading","geoJson","getGeoJsonData","hideLoading","result","echarts","error","console","log","useCharts","chartDOM","initAfter","getZr","on","target","flag","some","then","setOption","callback","chart"],"mappings":"wyBA+BA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,qBAAsBC,GAA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("lodash-es"),t=require("../utils/injectionKeys.cjs"),s=require("../utils/useCharts.cjs"),r=e.defineComponent({name:"DataChartBar",__name:"bar",props:{chartData:{type:Object,required:!0,default:()=>({colDesc:[],xGroupByDesc:{colDesc:"",groupByDesc:"",groupByValues:[],xAxis:!1},groupByDesc:[],data:[],modelName:""})},subShowType:{type:String,required:!0,default:"bar-simple"},chartOptions:{type:null,required:!0}},setup(r){const c=e.inject(t.InjectionChartMerge,(e=>e),!0),l=e.ref(null),o=e.computed((()=>{const{colDesc:e,xGroupByDesc:t,groupByDesc:s,data:l=[],modelName:o}=r.chartData,i=Array.from(new Set(l.map((e=>e[t.colDesc||""])))).filter((e=>null!=e))||[],u=s.find((e=>!e.xAxis))||{groupByValues:[],colDesc:""};u.groupByValues=a.uniq(l.map((e=>u.colDesc?String(e[u.colDesc]):""))),t&&t.groupByValues&&(t.groupByValues=a.uniq(l.map((e=>t.colDesc?String(e[t.colDesc]):""))));const n={title:{text:o},xAxis:{name:"",type:"category",axisLabel:{interval:0,formatter:e=>e.length>5?`${e.substring(0,5)}...`:e},data:i},yAxis:{type:"value"},legend:{data:[]},dataZoom:[{type:"inside",disabled:i.length<15}]};if(1===s.length)n.series=e.map((e=>({name:e,data:l.map((a=>a[e])),type:"bar",emphasis:{focus:"series"},label:{show:!0,position:"inside"}}))),n.legend.data=e;else if(2===s.length){const a=e.map((e=>u.groupByValues?.map((a=>{const s={name:`${a||"/"}-${e}`,type:"bar",stack:e,emphasis:{focus:"series"},data:[],label:{show:!0,position:"inside"}};return s.data=(t.groupByValues||[]).map((e=>{let r=null;return l.forEach((c=>{u.colDesc&&c[u.colDesc]===a&&t.colDesc&&c[t.colDesc]===e&&s.stack&&(r=c[s.stack]??null)})),r||""})).filter((e=>""!==e)),s}))||[])).flat();n.series=a,delete n.legend}function p(e,a,t,s){Array.isArray(e)?e.forEach((e=>{e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=s||""))})):e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=s||""))}switch(r.subShowType){case"bar-simple":case"default":p(n.xAxis,"category",i,t.colDesc||""),p(n.yAxis,"value");break;case"bar-y-category":p(n.xAxis,"value"),p(n.yAxis,"category",i,t.colDesc||"")}return c(n,r.chartOptions)}));return s.useCharts({chartDOM:l,chartOptions:o,chartData:e.computed((()=>r.chartData))}),(a,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataChartBar",ref:l,class:"data-chart-bar"},null,512))}});exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),a=require("lodash-es"),t=require("../utils/injectionKeys.cjs"),r=require("../utils/useCharts.cjs"),s=e.defineComponent({name:"DataChartBar",__name:"bar",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"bar-simple"},chartOptions:{type:null,required:!0}},setup(s){const c=e.inject(t.InjectionChartMerge,(e=>e),!0),l=e.ref(null),o=e.computed((()=>{const{colDesc:e,xGroupByDesc:t,groupByDesc:r,data:l=[],modelName:o}=s.chartData,i=Array.from(new Set(l.map((e=>e[t.colDesc||""])))).filter((e=>null!=e))||[],n=r.find((e=>!e.xAxis))||{groupByValues:[],colDesc:""};n.groupByValues=a.uniq(l.map((e=>n.colDesc?String(e[n.colDesc]):""))),t&&t.groupByValues&&(t.groupByValues=a.uniq(l.map((e=>t.colDesc?String(e[t.colDesc]):""))));const u={title:{text:o},xAxis:{name:"",type:"category",axisLabel:{interval:0,formatter:e=>e.length>5?`${e.substring(0,5)}...`:e},data:i},yAxis:{type:"value"},legend:{data:[]},dataZoom:[{type:"inside",disabled:i.length<15}]};if(1===r.length)u.series=e.map((e=>({name:e,data:l.map((a=>a[e])),type:"bar",emphasis:{focus:"series"},label:{show:!0,position:"inside"}}))),u.legend.data=e;else if(2===r.length){const a=e.map((e=>n.groupByValues?.map((a=>{const r={name:`${a||"/"}-${e}`,type:"bar",stack:e,emphasis:{focus:"series"},data:[],label:{show:!0,position:"inside"}};return r.data=(t.groupByValues||[]).map((e=>{let s=null;return l.forEach((c=>{n.colDesc&&c[n.colDesc]===a&&t.colDesc&&c[t.colDesc]===e&&r.stack&&(s=c[r.stack]??null)})),s||""})).filter((e=>""!==e)),r}))||[])).flat();u.series=a,delete u.legend}function p(e,a,t,r){Array.isArray(e)?e.forEach((e=>{e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))})):e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))}switch(s.subShowType){case"bar-simple":case"default":p(u.xAxis,"category",i,t.colDesc||""),p(u.yAxis,"value");break;case"bar-y-category":p(u.xAxis,"value"),p(u.yAxis,"category",i,t.colDesc||"")}return c(u,s.chartOptions)}));return r.useCharts({chartDOM:l,chartOptions:o,chartData:e.computed((()=>s.chartData))}),(a,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataChartBar",ref:l,class:"data-chart-bar"},null,512))}});exports.default=s;
2
2
  //# sourceMappingURL=bar.vue.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bar.vue.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { LegendComponentOption, XAXisComponentOption, YAXisComponentOption } from 'echarts'\nimport type {\n EChartData,\n EChartsOption,\n IFormatPublicData,\n SeriesOption,\n} from '../types'\nimport { uniq } from 'lodash-es'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\n// 定义组件名称\ndefineOptions({\n name: 'DataChartBar',\n})\n\n// 定义组件属性\nconst {\n chartOptions,\n chartData = {\n colDesc: [],\n xGroupByDesc: {\n colDesc: '',\n groupByDesc: '',\n groupByValues: [],\n xAxis: false,\n },\n groupByDesc: [],\n data: [],\n modelName: '',\n },\n subShowType = 'bar-simple',\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n}>()\n\n// 注入合并函数,并明确类型\nconst merge = inject(InjectionChartMerge, (v: any) => v, true) as (config: EChartsOption, chartOptions: EChartsOption) => EChartsOption\nconst dataChartBar = ref<HTMLElement | null>(null)\n\n// 计算图表选项\nconst barChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, groupByDesc, data = [], modelName } = chartData\n\n const axisData = Array.from(new Set(data.map(item => item[xGroupByDesc.colDesc || '']))).filter(item => item !== undefined && item !== null) || []\n const yGroupByDesc: EChartData['desc']['groupByDesc'][0] = groupByDesc.find(item => !item.xAxis) || {\n groupByDesc: null,\n groupByValues: [],\n colDesc: '',\n xAxis: false,\n }\n\n yGroupByDesc.groupByValues = uniq(data.map(item => yGroupByDesc.colDesc ? String(item[yGroupByDesc.colDesc]) : ''))\n if (xGroupByDesc && xGroupByDesc.groupByValues) {\n xGroupByDesc.groupByValues = uniq(data.map(item => xGroupByDesc.colDesc ? String(item[xGroupByDesc.colDesc]) : ''))\n }\n\n const config: EChartsOption = {\n title: {\n text: modelName,\n },\n xAxis: {\n name: '',\n type: 'category',\n axisLabel: {\n interval: 0, // 强制显示所有标签\n formatter(value: string) {\n const screenshotLength = 5\n return value.length > screenshotLength ? `${value.substring(0, screenshotLength)}...` : value // 截取前5个字符并添加省略号\n },\n },\n data: axisData,\n },\n yAxis: {\n type: 'value',\n },\n legend: {\n data: [],\n },\n dataZoom: [{\n type: 'inside',\n disabled: axisData.length < 15,\n }],\n }\n\n // 堆叠图\n if (groupByDesc.length === 1) {\n config.series = colDesc.map((yItem) => {\n return {\n name: yItem,\n data: data.map(item => item[yItem]),\n type: 'bar',\n emphasis: {\n focus: 'series',\n },\n label: {\n show: true,\n position: 'inside',\n },\n }\n });\n (config.legend as LegendComponentOption).data = colDesc\n }\n else if (groupByDesc.length === 2) {\n const arr = colDesc.map((colDescItem) => {\n return yGroupByDesc.groupByValues?.map((yGroupByDescItem) => {\n const obj: SeriesOption = {\n name: `${yGroupByDescItem || '/'}-${colDescItem}`,\n type: 'bar',\n stack: colDescItem,\n emphasis: {\n focus: 'series',\n },\n data: [],\n label: {\n show: true,\n position: 'inside',\n },\n }\n obj.data = (xGroupByDesc.groupByValues || []).map((xGroupByDescItem) => {\n let targetVal: number | string | null = null\n data.forEach((item) => {\n if (yGroupByDesc.colDesc && item[yGroupByDesc.colDesc] === yGroupByDescItem && xGroupByDesc.colDesc && item[xGroupByDesc.colDesc] === xGroupByDescItem) {\n if (obj.stack) {\n targetVal = item[obj.stack] ?? null\n }\n }\n })\n return targetVal || ''\n }).filter(v => v !== '')\n return obj\n }) || []\n }).flat()\n\n config.series = arr\n delete config.legend\n }\n\n // 1. 定义轴类型\n type CategoryAxisOption = XAXisComponentOption & {\n type: 'category'\n data: (string | number)[]\n }\n\n // 2. 创建配置轴的辅助函数\n function configureAxis(\n axis: XAXisComponentOption | XAXisComponentOption[] | YAXisComponentOption | YAXisComponentOption[] | undefined,\n type: 'category' | 'value',\n data?: (string | number)[],\n name?: string,\n ) {\n if (Array.isArray(axis)) {\n axis.forEach((item) => {\n if (item) {\n item.type = type\n if (type === 'category') {\n (item as CategoryAxisOption).data = data || []\n item.name = name || ''\n }\n }\n })\n }\n else if (axis) {\n axis.type = type\n if (type === 'category') {\n (axis as CategoryAxisOption).data = data || []\n axis.name = name || ''\n }\n }\n }\n\n // 3. 使用配置函数\n switch (subShowType) {\n case 'bar-simple':\n case 'default':\n configureAxis(config.xAxis, 'category', axisData, xGroupByDesc.colDesc || '')\n configureAxis(config.yAxis, 'value')\n break\n\n case 'bar-y-category':\n configureAxis(config.xAxis, 'value')\n configureAxis(config.yAxis, 'category', axisData, xGroupByDesc.colDesc || '')\n break\n }\n\n return merge(config, chartOptions)\n})\n\nuseCharts({ chartDOM: dataChartBar, chartOptions: barChartOptions, chartData: computed(() => chartData) })\n</script>\n\n<template>\n <div ref=\"dataChartBar\" class=\"data-chart-bar\" />\n</template>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartBar","ref","barChartOptions","computed","colDesc","xGroupByDesc","groupByDesc","data","modelName","__props","chartData","axisData","Array","from","Set","map","item","filter","yGroupByDesc","find","xAxis","groupByValues","uniq","String","config","title","text","name","type","axisLabel","interval","formatter","value","length","substring","yAxis","legend","dataZoom","disabled","series","yItem","emphasis","focus","label","show","position","arr","colDescItem","yGroupByDescItem","obj","stack","xGroupByDescItem","targetVal","forEach","flat","configureAxis","axis","isArray","subShowType","chartOptions","useCharts","chartDOM"],"mappings":"ygBAwCA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,qBAAsBC,GAAWA,IAAG,GACnDC,EAAeC,MAAwB,MAGvCC,EAAkBC,EAAAA,UAAwB,KACxC,MAAAC,QAAEA,eAASC,EAAcC,YAAAA,EAAAC,KAAaA,EAAO,GAACC,UAAGA,GAAcC,EAAAC,UAE/DC,EAAWC,MAAMC,KAAK,IAAIC,IAAIP,EAAKQ,KAAYC,GAAAA,EAAKX,EAAaD,SAAW,QAAOa,QAAOD,GAAQA,WAAwC,GAC1IE,EAAqDZ,EAAYa,UAAcH,EAAKI,SAAU,CAElGC,cAAe,GACfjB,QAAS,IAIXc,EAAaG,cAAgBC,EAAAA,KAAKf,EAAKQ,QAAYG,EAAad,QAAUmB,OAAOP,EAAKE,EAAad,UAAY,MAC3GC,GAAgBA,EAAagB,gBAC/BhB,EAAagB,cAAgBC,EAAAA,KAAKf,EAAKQ,QAAYV,EAAaD,QAAUmB,OAAOP,EAAKX,EAAaD,UAAY,OAGjH,MAAMoB,EAAwB,CAC5BC,MAAO,CACLC,KAAMlB,GAERY,MAAO,CACLO,KAAM,GACNC,KAAM,WACNC,UAAW,CACTC,SAAU,EACVC,UAAUC,GAEDA,EAAMC,OADY,EACgB,GAAGD,EAAME,UAAU,EADnC,QAC+DF,GAG5FzB,KAAMI,GAERwB,MAAO,CACLP,KAAM,SAERQ,OAAQ,CACN7B,KAAM,IAER8B,SAAU,CAAC,CACTT,KAAM,SACNU,SAAU3B,EAASsB,OAAS,MAK5B,GAAuB,IAAvB3B,EAAY2B,OACdT,EAAOe,OAASnC,EAAQW,KAAKyB,IACpB,CACLb,KAAMa,EACNjC,KAAM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,EAAA/B,EAAOJ,MAAO,SAC5BmC,EAAc/B,EAAOW,MAAO,WAAYxB,EAAUN,EAAaD,SAAW,IAIvE,OAAAR,EAAM4B,EAAQf,EAAYkD,aAAA,WAGzBC,EAAAA,UAAA,CAAEC,SAAU7D,EAAc2D,aAAczD,EAAiBQ,UAAWP,YAAS,IAAMM,EAAAC"}
1
+ {"version":3,"file":"bar.vue.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { LegendComponentOption, XAXisComponentOption, YAXisComponentOption } from 'echarts'\nimport type {\n EChartData,\n EChartsOption,\n IFormatPublicData,\n SeriesOption,\n} from '../types'\nimport { uniq } from 'lodash-es'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\n// 定义组件名称\ndefineOptions({\n name: 'DataChartBar',\n})\n\n// 定义组件属性\nconst {\n chartOptions,\n chartData,\n subShowType = 'bar-simple',\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n}>()\n\n// 注入合并函数,并明确类型\nconst merge = inject(InjectionChartMerge, (v: any) => v, true) as (config: EChartsOption, chartOptions: EChartsOption) => EChartsOption\nconst dataChartBar = ref<HTMLElement | null>(null)\n\n// 计算图表选项\nconst barChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, groupByDesc, data = [], modelName } = chartData\n\n const axisData = Array.from(new Set(data.map(item => item[xGroupByDesc.colDesc || '']))).filter(item => item !== undefined && item !== null) || []\n const yGroupByDesc: EChartData['desc']['groupByDesc'][0] = groupByDesc.find(item => !item.xAxis) || {\n groupByDesc: null,\n groupByValues: [],\n colDesc: '',\n xAxis: false,\n }\n\n yGroupByDesc.groupByValues = uniq(data.map(item => yGroupByDesc.colDesc ? String(item[yGroupByDesc.colDesc]) : ''))\n if (xGroupByDesc && xGroupByDesc.groupByValues) {\n xGroupByDesc.groupByValues = uniq(data.map(item => xGroupByDesc.colDesc ? String(item[xGroupByDesc.colDesc]) : ''))\n }\n\n const config: EChartsOption = {\n title: {\n text: modelName,\n },\n xAxis: {\n name: '',\n type: 'category',\n axisLabel: {\n interval: 0, // 强制显示所有标签\n formatter(value: string) {\n const screenshotLength = 5\n return value.length > screenshotLength ? `${value.substring(0, screenshotLength)}...` : value // 截取前5个字符并添加省略号\n },\n },\n data: axisData,\n },\n yAxis: {\n type: 'value',\n },\n legend: {\n data: [],\n },\n dataZoom: [{\n type: 'inside',\n disabled: axisData.length < 15,\n }],\n }\n\n // 堆叠图\n if (groupByDesc.length === 1) {\n config.series = colDesc.map((yItem) => {\n return {\n name: yItem,\n data: data.map(item => item[yItem]),\n type: 'bar',\n emphasis: {\n focus: 'series',\n },\n label: {\n show: true,\n position: 'inside',\n },\n }\n });\n (config.legend as LegendComponentOption).data = colDesc\n }\n else if (groupByDesc.length === 2) {\n const arr = colDesc.map((colDescItem) => {\n return yGroupByDesc.groupByValues?.map((yGroupByDescItem) => {\n const obj: SeriesOption = {\n name: `${yGroupByDescItem || '/'}-${colDescItem}`,\n type: 'bar',\n stack: colDescItem,\n emphasis: {\n focus: 'series',\n },\n data: [],\n label: {\n show: true,\n position: 'inside',\n },\n }\n obj.data = (xGroupByDesc.groupByValues || []).map((xGroupByDescItem) => {\n let targetVal: number | string | null = null\n data.forEach((item) => {\n if (yGroupByDesc.colDesc && item[yGroupByDesc.colDesc] === yGroupByDescItem && xGroupByDesc.colDesc && item[xGroupByDesc.colDesc] === xGroupByDescItem) {\n if (obj.stack) {\n targetVal = item[obj.stack] ?? null\n }\n }\n })\n return targetVal || ''\n }).filter(v => v !== '')\n return obj\n }) || []\n }).flat()\n\n config.series = arr\n delete config.legend\n }\n\n // 1. 定义轴类型\n type CategoryAxisOption = XAXisComponentOption & {\n type: 'category'\n data: (string | number)[]\n }\n\n // 2. 创建配置轴的辅助函数\n function configureAxis(\n axis: XAXisComponentOption | XAXisComponentOption[] | YAXisComponentOption | YAXisComponentOption[] | undefined,\n type: 'category' | 'value',\n data?: (string | number)[],\n name?: string,\n ) {\n if (Array.isArray(axis)) {\n axis.forEach((item) => {\n if (item) {\n item.type = type\n if (type === 'category') {\n (item as CategoryAxisOption).data = data || []\n item.name = name || ''\n }\n }\n })\n }\n else if (axis) {\n axis.type = type\n if (type === 'category') {\n (axis as CategoryAxisOption).data = data || []\n axis.name = name || ''\n }\n }\n }\n\n // 3. 使用配置函数\n switch (subShowType) {\n case 'bar-simple':\n case 'default':\n configureAxis(config.xAxis, 'category', axisData, xGroupByDesc.colDesc || '')\n configureAxis(config.yAxis, 'value')\n break\n\n case 'bar-y-category':\n configureAxis(config.xAxis, 'value')\n configureAxis(config.yAxis, 'category', axisData, xGroupByDesc.colDesc || '')\n break\n }\n\n return merge(config, chartOptions)\n})\n\nuseCharts({ chartDOM: dataChartBar, chartOptions: barChartOptions, chartData: computed(() => chartData) })\n</script>\n\n<template>\n <div\n ref=\"dataChartBar\"\n class=\"data-chart-bar\"\n />\n</template>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartBar","ref","barChartOptions","computed","colDesc","xGroupByDesc","groupByDesc","data","modelName","__props","chartData","axisData","Array","from","Set","map","item","filter","yGroupByDesc","find","xAxis","groupByValues","uniq","String","config","title","text","name","type","axisLabel","interval","formatter","value","length","substring","yAxis","legend","dataZoom","disabled","series","yItem","emphasis","focus","label","show","position","arr","colDescItem","yGroupByDescItem","obj","stack","xGroupByDescItem","targetVal","forEach","flat","configureAxis","axis","isArray","subShowType","chartOptions","useCharts","chartDOM"],"mappings":"uYA6BA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,qBAAsBC,GAAWA,IAAG,GACnDC,EAAeC,MAAwB,MAGvCC,EAAkBC,EAAAA,UAAwB,KACxC,MAAAC,QAAEA,eAASC,EAAcC,YAAAA,EAAAC,KAAaA,EAAO,GAACC,UAAGA,GAAcC,EAAAC,UAE/DC,EAAWC,MAAMC,KAAK,IAAIC,IAAIP,EAAKQ,KAAYC,GAAAA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