@qxs-bns/components-wc 0.0.9 → 0.0.11

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 (47) hide show
  1. package/es/editor/blocksuite-editor.mjs +27 -18
  2. package/es/editor/blocksuite-editor.mjs.map +1 -1
  3. package/es/index.mjs +1 -1
  4. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs +2 -0
  5. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs.map +1 -0
  6. package/es/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs +2 -0
  7. package/es/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs.map +1 -0
  8. package/es/subject/action.mjs +3 -3
  9. package/es/subject/action.mjs.map +1 -1
  10. package/es/subject/blank-fill.mjs +5 -5
  11. package/es/subject/blank-fill.mjs.map +1 -1
  12. package/es/subject/layout.mjs +5 -5
  13. package/es/subject/layout.mjs.map +1 -1
  14. package/es/subject/list.mjs +14 -51
  15. package/es/subject/list.mjs.map +1 -1
  16. package/es/subject/scale.mjs +5 -5
  17. package/es/subject/scale.mjs.map +1 -1
  18. package/es/subject/single.mjs +6 -6
  19. package/es/subject/single.mjs.map +1 -1
  20. package/es/subject/text-fill.mjs +4 -4
  21. package/es/subject/text-fill.mjs.map +1 -1
  22. package/es/subject/types.mjs +2 -0
  23. package/es/subject/types.mjs.map +1 -0
  24. package/lib/editor/blocksuite-editor.cjs +17 -8
  25. package/lib/editor/blocksuite-editor.cjs.map +1 -1
  26. package/lib/index.cjs +1 -1
  27. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs +2 -0
  28. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs.map +1 -0
  29. package/lib/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs +2 -0
  30. package/lib/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs.map +1 -0
  31. package/lib/subject/action.cjs +1 -1
  32. package/lib/subject/action.cjs.map +1 -1
  33. package/lib/subject/blank-fill.cjs +4 -4
  34. package/lib/subject/blank-fill.cjs.map +1 -1
  35. package/lib/subject/layout.cjs +3 -3
  36. package/lib/subject/layout.cjs.map +1 -1
  37. package/lib/subject/list.cjs +13 -50
  38. package/lib/subject/list.cjs.map +1 -1
  39. package/lib/subject/scale.cjs +4 -4
  40. package/lib/subject/scale.cjs.map +1 -1
  41. package/lib/subject/single.cjs +5 -5
  42. package/lib/subject/single.cjs.map +1 -1
  43. package/lib/subject/text-fill.cjs +3 -3
  44. package/lib/subject/text-fill.cjs.map +1 -1
  45. package/lib/subject/types.cjs +2 -0
  46. package/lib/subject/types.cjs.map +1 -0
  47. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"list.mjs","sources":["../../../../packages/components-wc/src/subject/list.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { repeat } from 'lit/directives/repeat.js'\nimport { property, state } from 'lit/decorators.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\n\nconst TYPE_LABEL: Record<string, string> = {\n single: '单选题', multiple: '多选题', sort: '排序题',\n blank_fill: '填空题', text_fill: '问答题', scale: '量表题',\n rich_text: '富文本', page_end: '分页符',\n}\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .wrapper { width: 100%; padding: 16px; margin-bottom: 16px; background: #fff; border: 1px solid #ebeef5; border-radius: 4px; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #409eff; border-color: #c6e2ff; background: #ecf5ff; }\n .btn.primary { background: #409eff; border-color: #409eff; color: #fff; }\n .btn.primary:hover { background: #337ecc; border-color: #337ecc; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-item { position: relative; display: flex; align-items: flex-start; transition: background-color 0.3s ease; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n @property({ attribute: 'is-preview' }) isPreview = false\n\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = (e) => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n\n @property({ type: Array })\n get subjectList() { return this._list }\n\n set subjectList(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = v.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = (this as any).isPreview\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode)\n return\n const el = this.shadowRoot?.querySelector<HTMLElement>('.sort-list')\n if (!el)\n return\n \n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n \n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.shadowRoot?.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) return\n \n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emit('change', this._list)\n },\n })\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.shadowRoot?.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return results\n }\n\n async validate(): Promise<{ valid: boolean; errors: SubjectError[] }> {\n const subjectEls = this.shadowRoot?.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n const item = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n isKey: false, answerCheckType: 1,\n examAnswerRelationType: examAnswerRelationType ?? 0,\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this._emit('change', this._list)\n }\n\n addExam(items: any[]) {\n let pageIdx = 1\n const newItems: any[] = []\n items.forEach((v: any) => {\n const item: any = {\n ...v,\n customId: v.customId || uid(),\n answers: v.answers?.map((c: any) => ({ ...c, title: c.answer, answerId: c.examAnswerId, isCorrect: c.isCorrect })) || [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n }\n if (!v.richTextContent) {\n item.answerType = v.examTypeEnum\n }\n if (item.pageIndex > pageIdx) {\n newItems.push({ customId: uid(), answerType: 'page_end', analysis: '', scaleQuestionList: [], isEdit: true, isSave: false, isRealCanDel: true, hasSet: false, examAnswerRelationType: 0 })\n pageIdx = item.pageIndex\n }\n newItems.push(item)\n })\n this._list = [...this._list, ...newItems]\n this._emit('change', this._list)\n }\n\n uploadExcel(list: any[]) {\n this._list = [...this._list, ...list.map((i: any) => ({ ...i, customId: i.customId || uid(), isRealCanDel: true }))]\n this._emit('change', this._list)\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n if (v.answerType !== 'page_end') {\n n++; if (v.customId === customId) { out = n }\n }\n })\n return out - 1\n }\n\n private _pageIndex(customId: string) {\n const pages = this._list.filter((v: any) => v.answerType === 'page_end')\n const idx = pages.findIndex((v: any) => v.customId === customId)\n return idx + 1\n }\n\n private _totalPages() {\n return this._list.filter((v: any) => v.answerType === 'page_end').length\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _save(index: number, e: CustomEvent) {\n this._list = this._list.map((item, i) =>\n i === index ? { ...item, ...e.detail, isEdit: false, isSave: true } : item,\n )\n this._emit('change', this._list)\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emit('change', this._list)\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?is-save': !item.isRealCanDel,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if (['single', 'multiple', 'sort'].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit}\n ?is-set=${item.hasSet}\n ?is-save=${!item.isRealCanDel}\n ?show-action=${!this._isPreviewValue}\n ?is-key=${item.isKey}\n type=${item.answerType}\n answer-check-type=${item.answerCheckType ?? 1}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n least-answer-count=${item.leastAnswerCount ?? 2}\n exam-expand=${item.examExpand || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @set-relation=${(e: CustomEvent) => this._emit('set-relation', e.detail)}\n ></qxs-subject-single>`\n }\n if (item.answerType === 'blank_fill') {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-blank-fill>`\n }\n if (item.answerType === 'text_fill') {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-text-fill>`\n }\n if (item.answerType === 'scale') {\n return html`<qxs-scale\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .scaleQuestions=${item.scaleQuestionList || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-scale>`\n }\n if (item.answerType === 'rich_text') {\n return html`<qxs-subject-rich-text\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.richTextContent || item.examRichTextContent || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-subject-rich-text>`\n }\n if (item.answerType === 'page_end') {\n return html`<qxs-page-end\n current-page-index=${this._pageIndex(item.customId)}\n total-page=${this._totalPages()}\n ?show-action=${!this._isPreviewValue}\n @move=${onMove} @delete=${onDelete} @add=${onAdd}\n ></qxs-page-end>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n return html`\n <div class=\"wrapper\">\n ${!this._isPreviewValue && this._list.length > 1\n ? html`\n <div class=\"sort-mode-toggle\">\n <button class=\"btn ${this._sortMode ? 'primary' : ''}\" @click=${() => { this._sortMode = !this._sortMode }}>\n ${!this._sortMode\n ? html`\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z\"/>\n </svg>\n `\n : ''}\n ${this._sortMode ? '完成排序' : '排序'}\n </button>\n </div>\n `\n : ''}\n ${this._sortMode\n ? html`\n <div class=\"sort-list\">\n ${repeat(this._list, (item) => item.customId, (item, i) => html`\n <div class=\"sort-item\" data-id=${item.customId}>\n <span class=\"sort-handle\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z\"/>\n </svg>\n </span>\n <span class=\"sort-index\">${i + 1}.</span>\n <span class=\"sort-title\">${item.title || '未命名题目'}</span>\n <span class=\"sort-type\">${TYPE_LABEL[item.answerType] || item.answerType}</span>\n </div>\n `)}\n </div>\n `\n : html`\n <div class=\"subject-list\">\n ${this._list.map((item, i) => html`\n <div class=\"subject-item ${this._isPreviewValue ? 'is-preview' : ''}\" key=${item.customId}>\n <div class=\"subject-content\">${this._renderItem(item, i)}</div>\n </div>\n `)}\n </div>\n `}\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["TYPE_LABEL","single","multiple","sort","blank_fill","text_fill","scale","rich_text","page_end","QxsSubjectList","LitElement","constructor","super","arguments","this","isPreview","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","subjectList","v","JSON","parse","requestUpdate","Array","isArray","map","i","customId","uid","attributeChangedCallback","name","oldVal","newVal","length","includes","parsed","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","el","shadowRoot","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","item","splice","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","subjectEls","querySelectorAll","results","errors","data","push","err","SubjectError","message","validate","valid","errs","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","addExam","items","pageIdx","newItems","forEach","c","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","pageIndex","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","_orderIndex","n","out","_pageIndex","filter","findIndex","_totalPages","_move","dir","_save","_deleteByCustomId","_delete","_setEdit","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","html","examRichTextContent","leastAnswerCount","examExpand","examId","examAnswerSettingVO","render","repeat","styles","css","__decorateClass","property","attribute","prototype","Object","state","safeCustomElement"],"mappings":"2wBAQA,MAAMA,EAAqC,CACzCC,OAAQ,MAAOC,SAAU,MAAOC,KAAM,MACtCC,WAAY,MAAOC,UAAW,MAAOC,MAAO,MAC5CC,UAAW,MAAOC,SAAU,OAIvB,IAAMC,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WA2BkCC,KAAAC,WAAY,EAGnDD,KAAAE,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAAUC,GAAML,EAAQK,EAAEC,QAAQC,QACzCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAkDhBf,KAAQgB,MAAe,GACvBhB,KAAQiB,WAAY,EAC7BjB,KAAQkB,UAA6B,KAOrClB,KAAQmB,uBAAwB,CAAA,CAtDhC,eAAIC,GAAgB,OAAOpB,KAAKgB,KAAM,CAEtC,eAAII,CAAYC,GACd,GAAKA,EAAL,CAIA,GAAiB,iBAANA,EACT,IACEA,EAAIC,KAAKC,MAAMF,EACjB,CAAA,MAIE,OAFArB,KAAKgB,MAAQ,QACbhB,K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K,UAAA,cAAA,GAUIH,EAAA,CADHC,EAAS,CAAElE,KAAMpE,SAvCP9B,EAwCPsK,UAAA,cAAA,GA6CaH,EAAA,CAAhBK,KArFUxK,EAqFMsK,UAAA,QAAA,GACAH,EAAA,CAAhBK,KAtFUxK,EAsFMsK,UAAA,YAAA,GAtFNtK,EAANmK,EAAA,CADNM,EAAkB,qBACNzK"}
1
+ {"version":3,"file":"list.mjs","sources":["../../../../packages/components-wc/src/subject/list.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\nimport { getSubjectType } from './types'\n\n// 导入子组件以确保它们被注册为 Custom Elements\nimport './action'\nimport './blank-fill'\nimport './layout'\nimport './single'\nimport './text-fill'\nimport './scale'\nimport './page-end'\nimport './rich-text'\nimport './type'\n\nconst TYPE_LABEL: Record<string, string> = {\n single: '单选题', multiple: '多选题', sort: '排序题',\n blank_fill: '填空题', text_fill: '问答题', scale: '量表题',\n rich_text: '富文本', page_end: '分页符',\n}\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .btn.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .btn.primary:hover { background: #3D61E3; border-color: #3D61E3; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n\n\n @property({ attribute: 'is-preview' }) isPreview = false\n\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = e => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n\n @property({ type: Array })\n get subjectList() { return this._list }\n\n set subjectList(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = v.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = (this as any).isPreview\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode) { return }\n const el = this.querySelector<HTMLElement>('.sort-list')\n if (!el) { return }\n\n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n\n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) { return }\n\n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emit('change', this._list)\n },\n })\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return results\n }\n\n async validate(): Promise<{ valid: boolean, errors: SubjectError[] }> {\n const subjectEls = this.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n const item = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n isKey: false, answerCheckType: 1,\n examAnswerRelationType: examAnswerRelationType ?? 0,\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n addExam(items: any[]) {\n let pageIdx = 1\n const newItems: any[] = []\n items.forEach((v: any) => {\n const item: any = {\n ...v,\n customId: v.customId || uid(),\n answers: v.answers?.map((c: any) => ({ ...c, title: c.answer, answerId: c.examAnswerId, isCorrect: c.isCorrect })) || [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n }\n if (!v.richTextContent) {\n item.answerType = getSubjectType(v.examTypeEnum)\n }\n if (item.pageIndex > pageIdx) {\n newItems.push({ customId: uid(), answerType: 'page_end', analysis: '', scaleQuestionList: [], isEdit: true, isSave: false, isRealCanDel: true, hasSet: false, examAnswerRelationType: 0 })\n pageIdx = item.pageIndex\n }\n newItems.push(item)\n })\n this._list = [...this._list, ...newItems]\n this._emit('change', this._list)\n }\n\n uploadExcel(list: any[]) {\n this._list = [...this._list, ...list.map((i: any) => ({ ...i, customId: i.customId || uid(), isRealCanDel: true }))]\n this._emit('change', this._list)\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n if (v.answerType !== 'page_end') {\n n++; if (v.customId === customId) { out = n }\n }\n })\n return out - 1\n }\n\n private _pageIndex(customId: string) {\n const pages = this._list.filter((v: any) => v.answerType === 'page_end')\n const idx = pages.findIndex((v: any) => v.customId === customId)\n return idx + 1\n }\n\n private _totalPages() {\n return this._list.filter((v: any) => v.answerType === 'page_end').length\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _save(index: number, e: CustomEvent) {\n this._list = this._list.map((item, i) =>\n i === index ? { ...item, ...e.detail, isEdit: false, isSave: true } : item,\n )\n this._emit('change', this._list)\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emit('change', this._list)\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?is-save': !item.isRealCanDel,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if (['single', 'multiple', 'sort'].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit}\n ?is-set=${item.hasSet}\n ?is-save=${!item.isRealCanDel}\n ?show-action=${!this._isPreviewValue}\n ?is-key=${item.isKey}\n type=${item.answerType}\n answer-check-type=${item.answerCheckType ?? 1}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n least-answer-count=${item.leastAnswerCount ?? 2}\n exam-expand=${item.examExpand || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @set-relation=${(e: CustomEvent) => this._emit('set-relation', e.detail)}\n ></qxs-subject-single>`\n }\n if (item.answerType === 'blank_fill') {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-blank-fill>`\n }\n if (item.answerType === 'text_fill') {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-text-fill>`\n }\n if (item.answerType === 'scale') {\n return html`<qxs-scale\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .scaleQuestions=${item.scaleQuestionList || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-scale>`\n }\n if (item.answerType === 'rich_text') {\n return html`<qxs-subject-rich-text\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.richTextContent || item.examRichTextContent || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-subject-rich-text>`\n }\n if (item.answerType === 'page_end') {\n return html`<qxs-page-end\n current-page-index=${this._pageIndex(item.customId)}\n total-page=${this._totalPages()}\n ?show-action=${!this._isPreviewValue}\n @move=${onMove} @delete=${onDelete} @add=${onAdd}\n ></qxs-page-end>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n return html`\n <div class=\"subject-list\">\n ${this._list.map((item, index) => this._renderItem(item, index))}\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["QxsSubjectList","LitElement","constructor","super","arguments","this","isPreview","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","subjectList","v","JSON","parse","requestUpdate","Array","isArray","map","i","customId","uid","attributeChangedCallback","name","oldVal","newVal","length","includes","parsed","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","item","splice","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","subjectEls","querySelectorAll","results","errors","el","data","push","err","SubjectError","message","validate","valid","errs","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","addExam","items","pageIdx","newItems","forEach","c","answer","answerId","examAnswerId","isCorrect","richTextContent","getSubjectType","examTypeEnum","pageIndex","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","_orderIndex","n","out","_pageIndex","filter","findIndex","_totalPages","_move","dir","_save","_deleteByCustomId","_delete","_setEdit","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","html","examRichTextContent","leastAnswerCount","examExpand","examId","examAnswerSettingVO","render","styles","css","__decorateClass","property","attribute","prototype","Object","state","safeCustomElement"],"mappings":"+3BA2BO,IAAMA,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WA2BkCC,KAAAC,WAAY,EAGnDD,KAAAE,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAASC,GAAKL,EAAQK,EAAEC,QAAQC,QACvCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAkDhBf,KAAQgB,MAAe,GACvBhB,KAAQiB,WAAY,EAC7BjB,KAAQkB,UAA6B,KAOrClB,KAAQmB,uBAAwB,CAAA,CAtDhC,eAAIC,GAAgB,OAAOpB,KAAKgB,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ACrBkH,aAAkBC,WAAkBC,WAAgBC,UAAeC;qBAGvD,cAApB/E,EAAK4B,WACAoD,CAAA;uBACUpJ,KAAKE;sBACN4I;mBACH1E,EAAKiC,kBAAkBjC,EAAKoC,oBAAoBpC,EAAKmC,8BAA8BvG,KAAKsC;oCACvE8B,EAAK0B,wBAA0B;4BACvC1B,EAAKiD,iBAAmBjD,EAAKiF,qBAAuB;oBAC5DjF,EAAKvC,UAAY;gBACrBkH,aAAkBC,WAAkBC,WAAgBC,UAAeC;iCAGvD,aAApB/E,EAAK4B,WACAoD,CAAA;6BACgBpJ,KAAKmI,WAAW/D,EAAKvC;qBAC7B7B,KAAKsI;wBACFtI,KAAKsC;gBACbyG,aAAkBC,UAAiBG;wBAGxCC,CAAA,gDAAoDhF,EAAK4B,kBAClE,CAEA0D,MAAAA,GACE,OAAON,CAAA;;UAEDpJ,KAAKgB,MAAMW,IAAI,CAACyC,EAAMyB,IAAU7F,KAAK6I,YAAYzE,EAAMyB;;KAG/D,GA9dWlG,EACJgK,OAASC,CAAA;;;;;;;;;;;;;;;;;;;;;;KA0BuBC,EAAA,CAAtCC,EAAS,CAAEC,UAAW,gBA3BZpK,EA2B4BqK,UAAA,YAAA,GAGvCH,EAAA,CADCC,EAAS,CAAElE,KAAMqE,UA7BPtK,EA8BXqK,UAAA,cAAA,GAUIH,EAAA,CADHC,EAAS,CAAElE,KAAMnE,SAvCP9B,EAwCPqK,UAAA,cAAA,GA6CaH,EAAA,CAAhBK,KArFUvK,EAqFMqK,UAAA,QAAA,GACAH,EAAA,CAAhBK,KAtFUvK,EAsFMqK,UAAA,YAAA,GAtFNrK,EAANkK,EAAA,CADNM,EAAkB,qBACNxK"}
@@ -1,4 +1,4 @@
1
- import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as o}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as r}from"../base/define.mjs";import{SubjectError as a}from"./single.mjs";var n=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=(t,e,i,s)=>{for(var o,r=s>1?void 0:s?l(e,i):e,a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&n(e,i,r),r};const p=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,h=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;let c=class extends i{constructor(){super(...arguments),this.orderIndex=0,this.title="",this.customId="",this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.showAction=!0,this.showAnalysis=!0,this.analysis="",this.richTextContent="",this.examAnswerRelationType=0,this.uploadImage=async t=>new Promise((e,i)=>{const s=new FileReader;s.onload=t=>e(t.target?.result),s.onerror=i,s.readAsDataURL(t)}),this._answers=[{title:""},{title:""},{title:""},{title:""},{title:""}],this._scaleQuestions=["问题1"],this._rowTitle="",this._title="",this._analysis="",this._showRichText=!1,this._richText="",this.modelValue="",this.useModel=!1,this.TITLE_MAX=200}get answerList(){return this._answers}set answerList(t){const e=Array.isArray(t)?t:[];this._answers=e.length?e.slice(0,5):[{title:""},{title:""},{title:""},{title:""},{title:""}],this.requestUpdate("answerList")}get scaleQuestions(){return this._scaleQuestions}set scaleQuestions(t){this._scaleQuestions=Array.isArray(t)&&t.length?t:["问题1"],this.requestUpdate("scaleQuestions")}willUpdate(t){t.has("isEdit")&&this.isEdit&&this._syncProps(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._rowTitle=this._scaleQuestions.join("\n"),this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0)}async toJSON(){return new Promise((t,e)=>{const i={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",o=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._analysis:this.analysis||"",n=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"",l=this.isEdit?this._showRichText:!!this.richTextContent,d=this.isEdit?this._richText:this.richTextContent||"";if(!s)return void e(new a("题目标题不能为空!","EMPTY_TITLE","title",i));for(let t=0;t<o.length;t++)if(!o[t].title)return void e(new a(`选项${String.fromCharCode(65+t)}未填写。`,"ANSWER_EMPTY","answers",i));if(!n)return void e(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",i));const p=n.split("\n").filter(t=>t.trim());if(0===p.length)return void e(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",i));const h={answerType:"scale",title:s,analysis:r,answers:o,scaleQuestionList:p,examRichTextContent:l?d:"",examAnswerRelationType:this.examAnswerRelationType};this.customId&&(h.customId=this.customId),t(h)})}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!function(t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(e),setTimeout(()=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},2500)}(t.message)}}validate(){const t=[],e={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",s=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"";if(i||t.push(new a("题目标题不能为空!","EMPTY_TITLE","title",e)),s.forEach((i,s)=>{i.title||t.push(new a(`选项${String.fromCharCode(65+s)}未填写`,"ANSWER_EMPTY","answers",e))}),o){0===o.split("\n").filter(t=>t.trim()).length&&t.push(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e))}else t.push(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e));return t}_renderPreview(){const e=Math.floor(100/(this._answers.length+1));return t`
1
+ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as o}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as r}from"../base/define.mjs";import{SubjectError as a}from"./single.mjs";import{ExamType as n}from"./types.mjs";var l=Object.defineProperty,d=Object.getOwnPropertyDescriptor,p=(t,e,i,s)=>{for(var o,r=s>1?void 0:s?d(e,i):e,a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&l(e,i,r),r};const h=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,c=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;let x=class extends i{constructor(){super(...arguments),this.orderIndex=0,this.title="",this.customId="",this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.showAction=!0,this.showAnalysis=!0,this.analysis="",this.richTextContent="",this.examAnswerRelationType=0,this.uploadImage=async t=>new Promise((e,i)=>{const s=new FileReader;s.onload=t=>e(t.target?.result),s.onerror=i,s.readAsDataURL(t)}),this._answers=[{title:""},{title:""},{title:""},{title:""},{title:""}],this._scaleQuestions=["问题1"],this._rowTitle="",this._title="",this._analysis="",this._showRichText=!1,this._richText="",this.modelValue="",this.useModel=!1,this.TITLE_MAX=200}get answerList(){return this._answers}set answerList(t){const e=Array.isArray(t)?t:[];this._answers=e.length?e.slice(0,5):[{title:""},{title:""},{title:""},{title:""},{title:""}],this.requestUpdate("answerList")}get scaleQuestions(){return this._scaleQuestions}set scaleQuestions(t){this._scaleQuestions=Array.isArray(t)&&t.length?t:["问题1"],this.requestUpdate("scaleQuestions")}willUpdate(t){t.has("isEdit")&&this.isEdit&&this._syncProps(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._rowTitle=this._scaleQuestions.join("\n"),this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0)}async toJSON(){return new Promise((t,e)=>{const i={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",o=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._analysis:this.analysis||"",l=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"",d=this.isEdit?this._showRichText:!!this.richTextContent,p=this.isEdit?this._richText:this.richTextContent||"";if(!s)return void e(new a("题目标题不能为空!","EMPTY_TITLE","title",i));for(let t=0;t<o.length;t++)if(!o[t].title)return void e(new a(`选项${String.fromCharCode(65+t)}未填写。`,"ANSWER_EMPTY","answers",i));if(!l)return void e(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",i));const h=l.split("\n").filter(t=>t.trim());if(0===h.length)return void e(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",i));const c={answerType:n.SCALE,title:s,analysis:r,answers:o,scaleQuestionList:h,examRichTextContent:d?p:"",examAnswerRelationType:this.examAnswerRelationType};this.customId&&(c.customId=this.customId),t(c)})}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!function(t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(e),setTimeout(()=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},2500)}(t.message)}}validate(){const t=[],e={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",s=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"";if(i||t.push(new a("题目标题不能为空!","EMPTY_TITLE","title",e)),s.forEach((i,s)=>{i.title||t.push(new a(`选项${String.fromCharCode(65+s)}未填写`,"ANSWER_EMPTY","answers",e))}),o){0===o.split("\n").filter(t=>t.trim()).length&&t.push(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e))}else t.push(new a("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e));return t}_renderPreview(){const e=Math.floor(100/(this._answers.length+1));return t`
2
2
  <div class="preview">
3
3
  <span class="title">${this.orderIndex+1}.${this.title}(量表题)</span>
4
4
  ${this.richTextContent?t`<div style="margin-top:8px" .innerHTML=${this.richTextContent}></div>`:""}
@@ -49,8 +49,8 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
49
49
  placeholder="选项${i+1}" />
50
50
  </div>
51
51
  ${this.isSave?"":t`
52
- <span class="icon" @click=${()=>{this._answers.length<5&&(this._answers=[...this._answers,{title:""}])}}>${p}</span>
53
- <span class="icon ${this._answers.length<3?"disabled":""}" @click=${()=>{this._answers.length>3&&(this._answers=this._answers.filter((t,e)=>e!==i))}}>${h}</span>
52
+ <span class="icon" @click=${()=>{this._answers.length<5&&(this._answers=[...this._answers,{title:""}])}}>${h}</span>
53
+ <span class="icon ${this._answers.length<3?"disabled":""}" @click=${()=>{this._answers.length>3&&(this._answers=this._answers.filter((t,e)=>e!==i))}}>${c}</span>
54
54
  `}
55
55
  </div>
56
56
  `)}
@@ -100,7 +100,7 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
100
100
  ></qxs-subject-action>
101
101
  `:""}
102
102
  </qxs-subject-layout>
103
- `}};c.styles=e`
103
+ `}};x.styles=e`
104
104
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
105
105
  *, ::before, ::after { box-sizing: border-box; }
106
106
 
@@ -159,5 +159,5 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
159
159
  .row-title-textarea {
160
160
  height: 200px;
161
161
  }
162
- `,d([s({type:Number,attribute:"order-index"})],c.prototype,"orderIndex",2),d([s({type:String})],c.prototype,"title",2),d([s({type:String,attribute:"custom-id"})],c.prototype,"customId",2),d([s({type:Boolean,attribute:"is-edit"})],c.prototype,"isEdit",2),d([s({type:Boolean,attribute:"is-save"})],c.prototype,"isSave",2),d([s({type:Boolean,attribute:"is-set"})],c.prototype,"isSet",2),d([s({type:Boolean,attribute:"show-action"})],c.prototype,"showAction",2),d([s({type:Boolean,attribute:"show-analysis"})],c.prototype,"showAnalysis",2),d([s({type:String})],c.prototype,"analysis",2),d([s({type:String,attribute:"rich-text-content"})],c.prototype,"richTextContent",2),d([s({type:Number,attribute:"exam-answer-relation-type"})],c.prototype,"examAnswerRelationType",2),d([s({type:Object})],c.prototype,"uploadImage",2),d([s({type:Array,attribute:"answer-list"})],c.prototype,"answerList",1),d([s({type:Array,attribute:"scale-questions"})],c.prototype,"scaleQuestions",1),d([o()],c.prototype,"_answers",2),d([o()],c.prototype,"_scaleQuestions",2),d([o()],c.prototype,"_rowTitle",2),d([o()],c.prototype,"_title",2),d([o()],c.prototype,"_analysis",2),d([o()],c.prototype,"_showRichText",2),d([o()],c.prototype,"_richText",2),d([s({type:String,attribute:"model-value"})],c.prototype,"modelValue",2),d([s({type:Boolean,attribute:"use-model"})],c.prototype,"useModel",2),c=d([r("qxs-scale")],c);export{c as QxsScale};
162
+ `,p([s({type:Number,attribute:"order-index"})],x.prototype,"orderIndex",2),p([s({type:String})],x.prototype,"title",2),p([s({type:String,attribute:"custom-id"})],x.prototype,"customId",2),p([s({type:Boolean,attribute:"is-edit"})],x.prototype,"isEdit",2),p([s({type:Boolean,attribute:"is-save"})],x.prototype,"isSave",2),p([s({type:Boolean,attribute:"is-set"})],x.prototype,"isSet",2),p([s({type:Boolean,attribute:"show-action"})],x.prototype,"showAction",2),p([s({type:Boolean,attribute:"show-analysis"})],x.prototype,"showAnalysis",2),p([s({type:String})],x.prototype,"analysis",2),p([s({type:String,attribute:"rich-text-content"})],x.prototype,"richTextContent",2),p([s({type:Number,attribute:"exam-answer-relation-type"})],x.prototype,"examAnswerRelationType",2),p([s({type:Object})],x.prototype,"uploadImage",2),p([s({type:Array,attribute:"answer-list"})],x.prototype,"answerList",1),p([s({type:Array,attribute:"scale-questions"})],x.prototype,"scaleQuestions",1),p([o()],x.prototype,"_answers",2),p([o()],x.prototype,"_scaleQuestions",2),p([o()],x.prototype,"_rowTitle",2),p([o()],x.prototype,"_title",2),p([o()],x.prototype,"_analysis",2),p([o()],x.prototype,"_showRichText",2),p([o()],x.prototype,"_richText",2),p([s({type:String,attribute:"model-value"})],x.prototype,"modelValue",2),p([s({type:Boolean,attribute:"use-model"})],x.prototype,"useModel",2),x=p([r("qxs-scale")],x);export{x as QxsScale};
163
163
  //# sourceMappingURL=scale.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale.mjs","sources":["../../../../packages/components-wc/src/subject/scale.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\nimport { SubjectError } from './single'\n\nconst iconPlus = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\nconst iconRemove = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n\nfunction showToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',\n padding: '10px 20px', borderRadius: '4px', fontSize: '13px', color: '#fff',\n background: '#f56c6c', zIndex: '99999', boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s', opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => { el.style.opacity = '0'; setTimeout(() => el.remove(), 300) }, 2500)\n}\n\n@safeCustomElement('qxs-scale')\nexport class QxsScale extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .preview { padding: 12px 0; }\n .preview .title { font-size: 14px; color: #303133; }\n .scale-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }\n .scale-table th, .scale-table td { border: 1px solid #e4e7ed; padding: 6px 4px; text-align: center; }\n .scale-table th { background: #f5f7fa; color: #909399; }\n\n .flex { display: flex; }\n .flex-items-center { display: flex; align-items: center; }\n .flex-items-start { display: flex; align-items: flex-start; }\n .flex-justify-end { display: flex; justify-content: flex-end; }\n .label { min-width: 60px; font-size: 13px; color: #606266; }\n\n textarea, input[type=\"text\"] {\n border: 1px solid #dcdfe6; border-radius: 3px; padding: 5px 11px;\n font-size: 13px; font-family: inherit; width: 100%; resize: none; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box; white-space: pre-wrap;\n }\n textarea:focus, input[type=\"text\"]:focus { border-color: #3D61E3; outline: none; }\n textarea:disabled, input[type=\"text\"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n\n .el-input { position: relative; display: block; }\n .el-input textarea { padding-bottom: 24px; }\n .el-input .char-counter {\n position: absolute; right: 12px; bottom: 8px;\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.danger { color: #f56c6c; }\n\n .answer-item { display: flex; align-items: center; margin-top: 6px; }\n .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }\n .answer-item .input { flex: 1; max-width: 200px; }\n .answer-item .input input {\n height: 32px; padding: 0 8px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n transition: border-color .2s; box-sizing: border-box;\n }\n .answer-item .input input:focus { border-color: #3D61E3; outline: none; }\n\n .answer-item .icon {\n margin-left: 6px; cursor: pointer; display: inline-flex;\n align-items: center; justify-content: center;\n width: 24px; height: 24px; border-radius: 4px;\n border: 1px solid #dcdfe6; background: #fff; color: #909399;\n transition: all 0.2s;\n }\n .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }\n\n .row-title-textarea {\n height: 200px;\n }\n `\n\n @property({ type: Number, attribute: 'order-index' }) orderIndex = 0\n @property({ type: String }) title = ''\n @property({ type: String, attribute: 'custom-id' }) customId = ''\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-save' }) isSave = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'show-action' }) showAction = true\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = true\n @property({ type: String }) analysis = ''\n @property({ type: String, attribute: 'rich-text-content' }) richTextContent = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = (e) => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n @property({ type: Array, attribute: 'answer-list' })\n get answerList() { return this._answers }\n\n set answerList(v: any) {\n const arr = Array.isArray(v) ? v : []\n this._answers = arr.length ? arr.slice(0, 5) : [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n this.requestUpdate('answerList')\n }\n\n @property({ type: Array, attribute: 'scale-questions' })\n get scaleQuestions() { return this._scaleQuestions }\n\n set scaleQuestions(v: any) {\n this._scaleQuestions = Array.isArray(v) && v.length ? v : ['问题1']\n this.requestUpdate('scaleQuestions')\n }\n\n @state() private _answers: { title: string }[] = [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n @state() private _scaleQuestions: string[] = ['问题1']\n @state() private _rowTitle = ''\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _showRichText = false\n @state() private _richText = ''\n\n // 双向绑定支持\n @property({ type: String, attribute: 'model-value' }) modelValue = ''\n @property({ type: Boolean, attribute: 'use-model' }) useModel = false\n\n private readonly TITLE_MAX = 200\n\n willUpdate(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue\n }\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._analysis = this.analysis || ''\n this._rowTitle = this._scaleQuestions.join('\\n')\n if (this.richTextContent) {\n this._richText = this.richTextContent\n this._showRichText = true\n }\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n const showRichText = this.isEdit ? this._showRichText : !!this.richTextContent\n const richText = this.isEdit ? this._richText : this.richTextContent || ''\n\n if (!title) {\n reject(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n return\n }\n\n for (let i = 0; i < answers.length; i++) {\n if (!answers[i].title) {\n reject(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写。`, 'ANSWER_EMPTY', 'answers', row))\n return\n }\n }\n\n if (!rowTitle) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const result: any = {\n answerType: 'scale',\n title,\n analysis,\n answers,\n scaleQuestionList: questions,\n examRichTextContent: showRichText ? richText : '',\n examAnswerRelationType: this.examAnswerRelationType,\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private _onTitleInput(e: Event) {\n const el = e.target as HTMLTextAreaElement\n if (el.value.length > this.TITLE_MAX) { el.value = el.value.slice(0, this.TITLE_MAX) }\n this._title = el.value\n // 双向绑定:通知外部更新\n if (this.useModel) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private async _save(e?: Event) {\n e?.stopImmediatePropagation()\n try {\n const data = await this.toJSON()\n this._emit('save', data)\n }\n catch (err: any) {\n showToast(err.message)\n }\n }\n\n validate(): SubjectError[] {\n const errors: SubjectError[] = []\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n answers.forEach((a: any, i: number) => {\n if (!a.title) {\n errors.push(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写`, 'ANSWER_EMPTY', 'answers', row))\n }\n })\n\n if (!rowTitle) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n else {\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n }\n\n return errors\n }\n\n private _renderPreview() {\n const colWidth = Math.floor(100 / (this._answers.length + 1))\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${this.title}(量表题)</span>\n ${this.richTextContent ? html`<div style=\"margin-top:8px\" .innerHTML=${this.richTextContent}></div>` : ''}\n <table class=\"scale-table\">\n <thead><tr>\n <th style=\"width:${colWidth}%\">问题 \\ 选项</th>\n ${this._answers.map(a => html`<th style=\"width:${colWidth}%\">${a.title}</th>`)}\n </tr></thead>\n <tbody>\n ${this._scaleQuestions.map(q => html`\n <tr><td>${q}</td>${this._answers.map(() => html`<td><input type=\"radio\" disabled /></td>`)}</tr>\n `)}\n </tbody>\n </table>\n ${this.analysis ? html`<div style=\"color:#909399;font-size:12px;margin-top:8px\">解析: ${this.analysis}</div>` : ''}\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"flex-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._title} ?disabled=${this.isSave}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【量表题】请输入问题\"></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>行标题:</span></div>\n <div class=\"flex\" style=\"flex:1\">\n <div class=\"el-input\" style=\"width:160px\">\n <textarea class=\"row-title-textarea\" .value=${this._rowTitle} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._rowTitle = (e.target as HTMLTextAreaElement).value }}\n @keydown=${(e: KeyboardEvent) => { e.stopPropagation() }}\n placeholder=\"请输入行标题\"></textarea>\n </div>\n <div style=\"flex:1;margin-left:12px\">\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\">\n <span class=\"label\">${String.fromCharCode(65 + i)}.</span>\n <div class=\"input\">\n <input type=\"text\" .value=${a.title} ?disabled=${this.isSave}\n maxlength=\"10\"\n @input=${(e: Event) => { this._answers = this._answers.map((x, j) => j === i ? { title: (e.target as HTMLInputElement).value } : x) }}\n placeholder=\"选项${i + 1}\" />\n </div>\n ${!this.isSave\n ? html`\n <span class=\"icon\" @click=${() => {\n if (this._answers.length < 5) { this._answers = [...this._answers, { title: '' }] }\n }}>${iconPlus}</span>\n <span class=\"icon ${this._answers.length < 3 ? 'disabled' : ''}\" @click=${() => {\n if (this._answers.length > 3) { this._answers = this._answers.filter((_, j) => j !== i) }\n }}>${iconRemove}</span>\n `\n : ''}\n </div>\n `)}\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>解析:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._analysis} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"></textarea>\n </div>\n </div>\n </div>\n\n ${this._showRichText\n ? html`\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>富文本:</span></div>\n <div style=\"flex:1\">\n <qxs-blocksuite-editor\n .content=${this._richText}\n .uploadImage=${this.uploadImage}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n <div class=\"flex-justify-end\" style=\"margin-top:8px\"><span class=\"el-link danger\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span></div>\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n return html`\n <qxs-subject-layout ?show-edit=${this.isEdit}>\n <div slot=\"preview\">${this._renderPreview()}</div>\n <div slot=\"edit\">${this._renderEdit()}</div>\n ${this.showAction\n ? html`\n <qxs-subject-action\n ?is-edit=${this.isEdit}\n ?is-set=${this.isSet}\n ?show-other-option=${false}\n exam-answer-relation-type=${this.examAnswerRelationType}\n @delete=${() => this._emit('delete')}\n @save=${this._save}\n @edit=${() => this._emit('edit')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n @on-show-rich-text=${() => { this._showRichText = true }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","iconRemove","QxsScale","LitElement","constructor","super","arguments","this","orderIndex","title","customId","isEdit","isSave","isSet","showAction","showAnalysis","analysis","richTextContent","examAnswerRelationType","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_analysis","_showRichText","_richText","modelValue","useModel","TITLE_MAX","answerList","v","arr","Array","isArray","length","slice","requestUpdate","scaleQuestions","willUpdate","changed","has","_syncProps","join","toJSON","row","answerType","answers","rowTitle","showRichText","richText","SubjectError","i","String","fromCharCode","questions","split","filter","trim","scaleQuestionList","examRichTextContent","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","value","_save","stopImmediatePropagation","data","err","msg","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","push","forEach","a","_renderPreview","colWidth","Math","floor","map","q","_renderEdit","stopPropagation","x","j","_","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","Boolean","state","safeCustomElement"],"mappings":"imBAKA,MAAMA,EAAWC,CAAA,2NACXC,EAAaD,CAAA,qLAgBZ,IAAME,EAAN,cAAuBC,EAAvBC,WAAAA,GAAAC,SAAAC,WA8DiDC,KAAAC,WAAa,EACvCD,KAAAE,MAAQ,GACgBF,KAAAG,SAAW,GACZH,KAAAI,QAAS,EACTJ,KAAAK,QAAS,EACVL,KAAAM,OAAQ,EACHN,KAAAO,YAAa,EACXP,KAAAQ,cAAe,EAC5CR,KAAAS,SAAW,GACqBT,KAAAU,gBAAkB,GACVV,KAAAW,uBAAyB,EAE7FX,KAAAY,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAAUC,GAAML,EAAQK,EAAEC,QAAQC,QACzCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAoBhBzB,KAAQ0B,SAAgC,CAAC,CAAExB,MAAO,IAAM,CAAEA,MAAO,IAAM,CAAEA,MAAO,IAAM,CAAEA,MAAO,IAAM,CAAEA,MAAO,KAC9GF,KAAQ2B,gBAA4B,CAAC,OACrC3B,KAAQ4B,UAAY,GACpB5B,KAAQ6B,OAAS,GACjB7B,KAAQ8B,UAAY,GACpB9B,KAAQ+B,eAAgB,EACx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U1I,EAyGMwI,UAAA,YAAA,GAGqCL,EAAA,CAArDC,EAAS,CAAEC,KAAMrE,OAAQuE,UAAW,iBA5G1BvI,EA4G2CwI,UAAA,aAAA,GACDL,EAAA,CAApDC,EAAS,CAAEC,KAAMI,QAASF,UAAW,eA7G3BvI,EA6G0CwI,UAAA,WAAA,GA7G1CxI,EAANmI,EAAA,CADNQ,EAAkB,cACN3I"}
1
+ {"version":3,"file":"scale.mjs","sources":["../../../../packages/components-wc/src/subject/scale.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\nimport { SubjectError } from './single'\nimport { ExamType } from './types'\n\nconst iconPlus = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\nconst iconRemove = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n\nfunction showToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',\n padding: '10px 20px', borderRadius: '4px', fontSize: '13px', color: '#fff',\n background: '#f56c6c', zIndex: '99999', boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s', opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => { el.style.opacity = '0'; setTimeout(() => el.remove(), 300) }, 2500)\n}\n\n@safeCustomElement('qxs-scale')\nexport class QxsScale extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .preview { padding: 12px 0; }\n .preview .title { font-size: 14px; color: #303133; }\n .scale-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }\n .scale-table th, .scale-table td { border: 1px solid #e4e7ed; padding: 6px 4px; text-align: center; }\n .scale-table th { background: #f5f7fa; color: #909399; }\n\n .flex { display: flex; }\n .flex-items-center { display: flex; align-items: center; }\n .flex-items-start { display: flex; align-items: flex-start; }\n .flex-justify-end { display: flex; justify-content: flex-end; }\n .label { min-width: 60px; font-size: 13px; color: #606266; }\n\n textarea, input[type=\"text\"] {\n border: 1px solid #dcdfe6; border-radius: 3px; padding: 5px 11px;\n font-size: 13px; font-family: inherit; width: 100%; resize: none; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box; white-space: pre-wrap;\n }\n textarea:focus, input[type=\"text\"]:focus { border-color: #3D61E3; outline: none; }\n textarea:disabled, input[type=\"text\"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n\n .el-input { position: relative; display: block; }\n .el-input textarea { padding-bottom: 24px; }\n .el-input .char-counter {\n position: absolute; right: 12px; bottom: 8px;\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.danger { color: #f56c6c; }\n\n .answer-item { display: flex; align-items: center; margin-top: 6px; }\n .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }\n .answer-item .input { flex: 1; max-width: 200px; }\n .answer-item .input input {\n height: 32px; padding: 0 8px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n transition: border-color .2s; box-sizing: border-box;\n }\n .answer-item .input input:focus { border-color: #3D61E3; outline: none; }\n\n .answer-item .icon {\n margin-left: 6px; cursor: pointer; display: inline-flex;\n align-items: center; justify-content: center;\n width: 24px; height: 24px; border-radius: 4px;\n border: 1px solid #dcdfe6; background: #fff; color: #909399;\n transition: all 0.2s;\n }\n .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }\n\n .row-title-textarea {\n height: 200px;\n }\n `\n\n @property({ type: Number, attribute: 'order-index' }) orderIndex = 0\n @property({ type: String }) title = ''\n @property({ type: String, attribute: 'custom-id' }) customId = ''\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-save' }) isSave = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'show-action' }) showAction = true\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = true\n @property({ type: String }) analysis = ''\n @property({ type: String, attribute: 'rich-text-content' }) richTextContent = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = (e) => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n @property({ type: Array, attribute: 'answer-list' })\n get answerList() { return this._answers }\n\n set answerList(v: any) {\n const arr = Array.isArray(v) ? v : []\n this._answers = arr.length ? arr.slice(0, 5) : [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n this.requestUpdate('answerList')\n }\n\n @property({ type: Array, attribute: 'scale-questions' })\n get scaleQuestions() { return this._scaleQuestions }\n\n set scaleQuestions(v: any) {\n this._scaleQuestions = Array.isArray(v) && v.length ? v : ['问题1']\n this.requestUpdate('scaleQuestions')\n }\n\n @state() private _answers: { title: string }[] = [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n @state() private _scaleQuestions: string[] = ['问题1']\n @state() private _rowTitle = ''\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _showRichText = false\n @state() private _richText = ''\n\n // 双向绑定支持\n @property({ type: String, attribute: 'model-value' }) modelValue = ''\n @property({ type: Boolean, attribute: 'use-model' }) useModel = false\n\n private readonly TITLE_MAX = 200\n\n willUpdate(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue\n }\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._analysis = this.analysis || ''\n this._rowTitle = this._scaleQuestions.join('\\n')\n if (this.richTextContent) {\n this._richText = this.richTextContent\n this._showRichText = true\n }\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n const showRichText = this.isEdit ? this._showRichText : !!this.richTextContent\n const richText = this.isEdit ? this._richText : this.richTextContent || ''\n\n if (!title) {\n reject(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n return\n }\n\n for (let i = 0; i < answers.length; i++) {\n if (!answers[i].title) {\n reject(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写。`, 'ANSWER_EMPTY', 'answers', row))\n return\n }\n }\n\n if (!rowTitle) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const result: any = {\n answerType: ExamType.SCALE,\n title,\n analysis,\n answers,\n scaleQuestionList: questions,\n examRichTextContent: showRichText ? richText : '',\n examAnswerRelationType: this.examAnswerRelationType,\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private _onTitleInput(e: Event) {\n const el = e.target as HTMLTextAreaElement\n if (el.value.length > this.TITLE_MAX) { el.value = el.value.slice(0, this.TITLE_MAX) }\n this._title = el.value\n // 双向绑定:通知外部更新\n if (this.useModel) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private async _save(e?: Event) {\n e?.stopImmediatePropagation()\n try {\n const data = await this.toJSON()\n this._emit('save', data)\n }\n catch (err: any) {\n showToast(err.message)\n }\n }\n\n validate(): SubjectError[] {\n const errors: SubjectError[] = []\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n answers.forEach((a: any, i: number) => {\n if (!a.title) {\n errors.push(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写`, 'ANSWER_EMPTY', 'answers', row))\n }\n })\n\n if (!rowTitle) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n else {\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n }\n\n return errors\n }\n\n private _renderPreview() {\n const colWidth = Math.floor(100 / (this._answers.length + 1))\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${this.title}(量表题)</span>\n ${this.richTextContent ? html`<div style=\"margin-top:8px\" .innerHTML=${this.richTextContent}></div>` : ''}\n <table class=\"scale-table\">\n <thead><tr>\n <th style=\"width:${colWidth}%\">问题 \\ 选项</th>\n ${this._answers.map(a => html`<th style=\"width:${colWidth}%\">${a.title}</th>`)}\n </tr></thead>\n <tbody>\n ${this._scaleQuestions.map(q => html`\n <tr><td>${q}</td>${this._answers.map(() => html`<td><input type=\"radio\" disabled /></td>`)}</tr>\n `)}\n </tbody>\n </table>\n ${this.analysis ? html`<div style=\"color:#909399;font-size:12px;margin-top:8px\">解析: ${this.analysis}</div>` : ''}\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"flex-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._title} ?disabled=${this.isSave}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【量表题】请输入问题\"></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>行标题:</span></div>\n <div class=\"flex\" style=\"flex:1\">\n <div class=\"el-input\" style=\"width:160px\">\n <textarea class=\"row-title-textarea\" .value=${this._rowTitle} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._rowTitle = (e.target as HTMLTextAreaElement).value }}\n @keydown=${(e: KeyboardEvent) => { e.stopPropagation() }}\n placeholder=\"请输入行标题\"></textarea>\n </div>\n <div style=\"flex:1;margin-left:12px\">\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\">\n <span class=\"label\">${String.fromCharCode(65 + i)}.</span>\n <div class=\"input\">\n <input type=\"text\" .value=${a.title} ?disabled=${this.isSave}\n maxlength=\"10\"\n @input=${(e: Event) => { this._answers = this._answers.map((x, j) => j === i ? { title: (e.target as HTMLInputElement).value } : x) }}\n placeholder=\"选项${i + 1}\" />\n </div>\n ${!this.isSave\n ? html`\n <span class=\"icon\" @click=${() => {\n if (this._answers.length < 5) { this._answers = [...this._answers, { title: '' }] }\n }}>${iconPlus}</span>\n <span class=\"icon ${this._answers.length < 3 ? 'disabled' : ''}\" @click=${() => {\n if (this._answers.length > 3) { this._answers = this._answers.filter((_, j) => j !== i) }\n }}>${iconRemove}</span>\n `\n : ''}\n </div>\n `)}\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>解析:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._analysis} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"></textarea>\n </div>\n </div>\n </div>\n\n ${this._showRichText\n ? html`\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>富文本:</span></div>\n <div style=\"flex:1\">\n <qxs-blocksuite-editor\n .content=${this._richText}\n .uploadImage=${this.uploadImage}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n <div class=\"flex-justify-end\" style=\"margin-top:8px\"><span class=\"el-link danger\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span></div>\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n return html`\n <qxs-subject-layout ?show-edit=${this.isEdit}>\n <div slot=\"preview\">${this._renderPreview()}</div>\n <div slot=\"edit\">${this._renderEdit()}</div>\n ${this.showAction\n ? html`\n <qxs-subject-action\n ?is-edit=${this.isEdit}\n ?is-set=${this.isSet}\n ?show-other-option=${false}\n exam-answer-relation-type=${this.examAnswerRelationType}\n @delete=${() => this._emit('delete')}\n @save=${this._save}\n @edit=${() => this._emit('edit')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n @on-show-rich-text=${() => { this._showRichText = true }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","iconRemove","QxsScale","LitElement","constructor","super","arguments","this","orderIndex","title","customId","isEdit","isSave","isSet","showAction","showAnalysis","analysis","richTextContent","examAnswerRelationType","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_analysis","_showRichText","_richText","modelValue","useModel","TITLE_MAX","answerList","v","arr","Array","isArray","length","slice","requestUpdate","scaleQuestions","willUpdate","changed","has","_syncProps","join","toJSON","row","answerType","answers","rowTitle","showRichText","richText","SubjectError","i","String","fromCharCode","questions","split","filter","trim","ExamType","SCALE","scaleQuestionList","examRichTextContent","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","value","_save","stopImmediatePropagation","data","err","msg","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","push","forEach","a","_renderPreview","colWidth","Math","floor","map","q","_renderEdit","stopPropagation","x","j","_","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","Boolean","state","safeCustomElement"],"mappings":"woBAMA,MAAMA,EAAWC,CAAA,2NACXC,EAAaD,CAAA,qLAgBZ,IAAME,EAAN,cAAuBC,EAAvBC,WAAAA,GAAAC,SAAAC,WA8DiDC,KAAAC,WAAa,EACvCD,KAAAE,MAAQ,GACgBF,KAAAG,SAAW,GACZH,KAAAI,QAAS,EACTJ,KAAAK,QAAS,EACVL,KAAAM,OAAQ,EACHN,KAAAO,YAAa,EACXP,KAAAQ,cAAe,EAC5CR,KAAAS,SAAW,GACqBT,KAAAU,gBAAkB,GACVV,KAAAW,uBAAyB,EAE7FX,KAAAY,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAAUC,GAAML,EAAQK,EAAEC,QAAQC,QACzCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAoBhBzB,KAAQ0B,SAA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A,kBAAA,GACAL,EAAA,CAAhBO,KArGU5I,EAqGM0I,UAAA,YAAA,GACAL,EAAA,CAAhBO,KAtGU5I,EAsGM0I,UAAA,SAAA,GACAL,EAAA,CAAhBO,KAvGU5I,EAuGM0I,UAAA,YAAA,GACAL,EAAA,CAAhBO,KAxGU5I,EAwGM0I,UAAA,gBAAA,GACAL,EAAA,CAAhBO,KAzGU5I,EAyGM0I,UAAA,YAAA,GAGqCL,EAAA,CAArDC,EAAS,CAAEC,KAAMvE,OAAQyE,UAAW,iBA5G1BzI,EA4G2C0I,UAAA,aAAA,GACDL,EAAA,CAApDC,EAAS,CAAEC,KAAMI,QAASF,UAAW,eA7G3BzI,EA6G0C0I,UAAA,WAAA,GA7G1C1I,EAANqI,EAAA,CADNQ,EAAkB,cACN7I"}
@@ -1,4 +1,4 @@
1
- import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as r}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as o}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,p=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?l(t,s):t,n=e.length-1;n>=0;n--)(r=e[n])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&a(t,s,o),o};class d extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new d(e.message,e.code,e.field,e.row)}}const c=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,h=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;const u=e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;let x=class extends s{constructor(){super(...arguments),this.orderIndex=0,this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAnalysis=!0,this.type="single",this.answerCheckType=1,this.examAnswerRelationType=0,this.richTextContent="",this.analysis="",this.leastAnswerCount=2,this.examExpand="",this.customId="",this.examId=0,this.uploadImage=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this.modelValue="",this.useModel=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=2,this._answerCheckType=1,this._orderList=[],this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper");s&&!t.includes(s)&&(this._sortDropdownOpen=!1,this.requestUpdate())}}get answerList(){return this._answers}set answerList(e){const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>({...e})):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answerList")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick)}willUpdate(e){e.has("isEdit")&&this.isEdit&&this._syncProps(),(e.has("examExpand")||e.has("answerList"))&&this._syncExamExpand(),e.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this.leastAnswerCount||2,this._answerCheckType=this.answerCheckType||1,this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0),this.answerList?.length&&(this._answers=this.answerList.map(e=>({...e,title:e.title||"",isCorrect:!!e.isCorrect}))),this._syncExamExpand()}_syncExamExpand(){if(!this.examExpand||!this.answerList?.length)return;const e=this.examExpand.split(",");this._orderList=e.map(e=>{const t=this.answerList.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){"single"===this.type?(this._answers.forEach(e=>{e.isCorrect=!1}),e.isCorrect=t):e.isCorrect=t,this.requestUpdate()}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(e,t){const s=e.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[t].title=s.value,this.requestUpdate()}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",isCorrect:!1,customAnswerId:n()}])}_deleteAnswer(e){this._answers.length<3||this.isSave||(this._answers=this._answers.filter((t,s)=>s!==e))}_toggleSortItem(e){const t=this._orderList.indexOf(e);this._orderList=t>=0?this._orderList.filter(t=>t!==e):[...this._orderList,e],this.requestUpdate()}_removeSortItem(e){this._orderList=this._orderList.filter(t=>t!==e),this.requestUpdate()}_getSortOrder(e){const t=this._orderList.indexOf(this._label(e));return t>=0?t+1:null}async toJSON(){return new Promise((e,t)=>{const s={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._answerCheckType:this.answerCheckType||1,n=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,a=this.isEdit?this._analysis:this.analysis||"",l=this.isEdit?this._orderList.map(e=>e.charCodeAt(0)-65+1).join(","):this.examExpand||"",p=this.isEdit?this._showRichText:!!this.richTextContent,c=this.isEdit?this._richText:this.richTextContent||"",h=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();if(!i)return void t(new d("题目标题不能为空!","EMPTY_TITLE","title",s));if(!o)return void t(new d("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",s));let u="",x=!1,w=0;if("multiple"===this.type||"single"===this.type)r.forEach((e,t)=>{e.title?.trim()||(u+=`选项${String.fromCharCode(65+t)}未填写。`),e.isCorrect&&(x=!0,w++)});else if("sort"===this.type&&(h.length&&(x=!0),x&&h.length<n))return void t(new d(`排序题至少需要设置${n}项排序答案`,"SORT_COUNT_INVALID","orderList",s));if(u)return void t(new d(u,"ANSWER_EMPTY","answers",s));if(new Set(r.map(e=>e.title)).size!==r.length)return void t(new d("选项不能重复","DUPLICATE_ANSWERS","answers",s));if("multiple"===this.type){if(1===w)return void t(new d("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",s));if(x&&w<n)return void t(new d("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))}if((2===o||3===o)&&!x)return void t(new d("请设置支持选项","NO_CORRECT_ANSWER","answers",s));const m={answerType:this.type,title:i,answers:r.filter(e=>e.title).map((e,t)=>({...e,orderIndex:t+1})),examExpand:l,analysis:a,isSetCorrectAnswer:x,leastAnswerCount:n,examRichTextContent:p?c:"",examAnswerRelationType:this.examAnswerRelationType,isKey:this.isKey,answerCheckType:o};this.customId&&(m.customId=this.customId),e(m)})}validate(){const e=[],t={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._answerCheckType:this.answerCheckType||1,o=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,n=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();s||e.push(new d("题目标题不能为空!","EMPTY_TITLE","title",t)),r||e.push(new d("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",t));let a=!1,l=0;"multiple"===this.type||"single"===this.type?i.forEach((s,i)=>{s.title?.trim()||e.push(new d(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",t)),s.isCorrect&&(a=!0,l++)}):"sort"===this.type&&(n.length&&(a=!0),a&&n.length<o&&e.push(new d(`排序题至少需要设置${o}项排序答案`,"SORT_COUNT_INVALID","orderList",t)));return new Set(i.map(e=>e.title)).size!==i.length&&i.length>0&&e.push(new d("选项不能重复","DUPLICATE_ANSWERS","answers",t)),"multiple"===this.type&&(1===l&&i.length>0&&e.push(new d("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",t)),a&&l<o&&e.push(new d("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",t))),2!==r&&3!==r||a||e.push(new d("请设置支持选项","NO_CORRECT_ANSWER","answers",t)),e}_openResultDialog(e){this._resultDialogIndex=e,this._resultDialogValue=this._answers[e].resultItem||"",this._resultDialogOpen=!0}_saveResultDialog(){this._answers[this._resultDialogIndex].resultItem=this._resultDialogValue,this._resultDialogOpen=!1,this.requestUpdate()}_renderResultDialog(){if(!this._resultDialogOpen)return"";const t=this._label(this._resultDialogIndex);return e`
1
+ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as r}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as o}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";import{getExamType as a}from"./types.mjs";var l=Object.defineProperty,p=Object.getOwnPropertyDescriptor,d=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?p(t,s):t,n=e.length-1;n>=0;n--)(r=e[n])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&l(t,s,o),o};class c extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new c(e.message,e.code,e.field,e.row)}}const h=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,u=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;const x=e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;let m=class extends s{constructor(){super(...arguments),this.orderIndex=0,this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAnalysis=!0,this.type="single",this.answerCheckType=1,this.examAnswerRelationType=0,this.richTextContent="",this.analysis="",this.leastAnswerCount=2,this.examExpand="",this.customId="",this.examId=0,this.uploadImage=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this.modelValue="",this.useModel=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=2,this._answerCheckType=1,this._orderList=[],this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper");s&&!t.includes(s)&&(this._sortDropdownOpen=!1,this.requestUpdate())}}get answerList(){return this._answers}set answerList(e){const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>({...e})):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answerList")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick)}willUpdate(e){e.has("isEdit")&&this.isEdit&&this._syncProps(),(e.has("examExpand")||e.has("answerList"))&&this._syncExamExpand(),e.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this.leastAnswerCount||2,this._answerCheckType=this.answerCheckType||1,this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0),this.answerList?.length&&(this._answers=this.answerList.map(e=>({...e,title:e.title||"",isCorrect:!!e.isCorrect}))),this._syncExamExpand()}_syncExamExpand(){if(!this.examExpand||!this.answerList?.length)return;const e=this.examExpand.split(",");this._orderList=e.map(e=>{const t=this.answerList.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){"single"===this.type?(this._answers.forEach(e=>{e.isCorrect=!1}),e.isCorrect=t):e.isCorrect=t,this.requestUpdate()}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(e,t){const s=e.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[t].title=s.value,this.requestUpdate()}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",isCorrect:!1,customAnswerId:n()}])}_deleteAnswer(e){this._answers.length<3||this.isSave||(this._answers=this._answers.filter((t,s)=>s!==e))}_toggleSortItem(e){const t=this._orderList.indexOf(e);this._orderList=t>=0?this._orderList.filter(t=>t!==e):[...this._orderList,e],this.requestUpdate()}_removeSortItem(e){this._orderList=this._orderList.filter(t=>t!==e),this.requestUpdate()}_getSortOrder(e){const t=this._orderList.indexOf(this._label(e));return t>=0?t+1:null}async toJSON(){return new Promise((e,t)=>{const s={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._answerCheckType:this.answerCheckType||1,n=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,l=this.isEdit?this._analysis:this.analysis||"",p=this.isEdit?this._orderList.map(e=>e.charCodeAt(0)-65+1).join(","):this.examExpand||"",d=this.isEdit?this._showRichText:!!this.richTextContent,h=this.isEdit?this._richText:this.richTextContent||"",u=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();if(!i)return void t(new c("题目标题不能为空!","EMPTY_TITLE","title",s));if(!o)return void t(new c("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",s));let x="",m=!1,w=0;if("multiple"===this.type||"single"===this.type)r.forEach((e,t)=>{e.title?.trim()||(x+=`选项${String.fromCharCode(65+t)}未填写。`),e.isCorrect&&(m=!0,w++)});else if("sort"===this.type&&(u.length&&(m=!0),m&&u.length<n))return void t(new c(`排序题至少需要设置${n}项排序答案`,"SORT_COUNT_INVALID","orderList",s));if(x)return void t(new c(x,"ANSWER_EMPTY","answers",s));if(new Set(r.map(e=>e.title)).size!==r.length)return void t(new c("选项不能重复","DUPLICATE_ANSWERS","answers",s));if("multiple"===this.type){if(1===w)return void t(new c("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",s));if(m&&w<n)return void t(new c("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))}if((2===o||3===o)&&!m)return void t(new c("请设置支持选项","NO_CORRECT_ANSWER","answers",s));const g={answerType:a(this.type),title:i,answers:r.filter(e=>e.title).map((e,t)=>({...e,orderIndex:t+1})),examExpand:p,analysis:l,isSetCorrectAnswer:m,leastAnswerCount:n,examRichTextContent:d?h:"",examAnswerRelationType:this.examAnswerRelationType,isKey:this.isKey,answerCheckType:o};this.customId&&(g.customId=this.customId),e(g)})}validate(){const e=[],t={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._answerCheckType:this.answerCheckType||1,o=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,n=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();s||e.push(new c("题目标题不能为空!","EMPTY_TITLE","title",t)),r||e.push(new c("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",t));let a=!1,l=0;"multiple"===this.type||"single"===this.type?i.forEach((s,i)=>{s.title?.trim()||e.push(new c(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",t)),s.isCorrect&&(a=!0,l++)}):"sort"===this.type&&(n.length&&(a=!0),a&&n.length<o&&e.push(new c(`排序题至少需要设置${o}项排序答案`,"SORT_COUNT_INVALID","orderList",t)));return new Set(i.map(e=>e.title)).size!==i.length&&i.length>0&&e.push(new c("选项不能重复","DUPLICATE_ANSWERS","answers",t)),"multiple"===this.type&&(1===l&&i.length>0&&e.push(new c("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",t)),a&&l<o&&e.push(new c("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",t))),2!==r&&3!==r||a||e.push(new c("请设置支持选项","NO_CORRECT_ANSWER","answers",t)),e}_openResultDialog(e){this._resultDialogIndex=e,this._resultDialogValue=this._answers[e].resultItem||"",this._resultDialogOpen=!0}_saveResultDialog(){this._answers[this._resultDialogIndex].resultItem=this._resultDialogValue,this._resultDialogOpen=!1,this.requestUpdate()}_renderResultDialog(){if(!this._resultDialogOpen)return"";const t=this._label(this._resultDialogIndex);return e`
2
2
  <div class="modal-backdrop" @click=${()=>{this._resultDialogOpen=!1}}>
3
3
  <div class="modal" @click=${e=>e.stopPropagation()}>
4
4
  <div class="modal-header">
@@ -82,11 +82,11 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
82
82
 
83
83
  <span class="icon ${this.isSave?"disabled":""}"
84
84
  @click=${()=>this._addAnswer()}>
85
- ${c}
85
+ ${h}
86
86
  </span>
87
87
  <span class="icon ${this.isSave||this._answers.length<3?"disabled":""}"
88
88
  @click=${()=>this._deleteAnswer(s)}>
89
- ${h}
89
+ ${u}
90
90
  </span>
91
91
 
92
92
  ${1===this.examAnswerRelationType&&"sort"!==this.type?e`
@@ -112,7 +112,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
112
112
  <span class="tag-close" @click=${e=>{e.stopPropagation(),this._removeSortItem(t)}}>&#x2715;</span>
113
113
  </span>
114
114
  `):e`<span class="placeholder">请按顺序选择排序答案</span>`}
115
- <span class="arrow">${u}</span>
115
+ <span class="arrow">${x}</span>
116
116
  </div>
117
117
  ${this._sortDropdownOpen?e`
118
118
  <div class="multi-select-dropdown">
@@ -177,7 +177,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
177
177
  `:""}
178
178
  </qxs-subject-layout>
179
179
  ${this._renderResultDialog()}
180
- `}};x.styles=t`
180
+ `}};m.styles=t`
181
181
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
182
182
  *, ::before, ::after { box-sizing: border-box; }
183
183
 
@@ -315,5 +315,5 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
315
315
  .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }
316
316
  .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }
317
317
  .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }
318
- `,p([i({type:Number,attribute:"order-index"})],x.prototype,"orderIndex",2),p([i({type:Boolean,attribute:"is-edit"})],x.prototype,"isEdit",2),p([i({type:Boolean,attribute:"is-save"})],x.prototype,"isSave",2),p([i({type:Boolean,attribute:"is-set"})],x.prototype,"isSet",2),p([i({type:Boolean,attribute:"is-key"})],x.prototype,"isKey",2),p([i({type:Boolean,attribute:"show-action"})],x.prototype,"showAction",2),p([i({type:Boolean,attribute:"show-analysis"})],x.prototype,"showAnalysis",2),p([i({type:String})],x.prototype,"type",2),p([i({type:Number,attribute:"answer-check-type"})],x.prototype,"answerCheckType",2),p([i({type:Number,attribute:"exam-answer-relation-type"})],x.prototype,"examAnswerRelationType",2),p([i({type:String,attribute:"rich-text-content"})],x.prototype,"richTextContent",2),p([i({type:String})],x.prototype,"analysis",2),p([i({type:Number,attribute:"least-answer-count"})],x.prototype,"leastAnswerCount",2),p([i({type:String,attribute:"exam-expand"})],x.prototype,"examExpand",2),p([i({type:String,attribute:"custom-id"})],x.prototype,"customId",2),p([i({type:Number,attribute:"exam-id"})],x.prototype,"examId",2),p([i({type:Object})],x.prototype,"uploadImage",2),p([i({type:Array,attribute:"answer-list"})],x.prototype,"answerList",1),p([i({type:String,attribute:"model-value"})],x.prototype,"modelValue",2),p([i({type:Boolean,attribute:"use-model"})],x.prototype,"useModel",2),p([r()],x.prototype,"_answers",2),p([r()],x.prototype,"_title",2),p([r()],x.prototype,"_analysis",2),p([r()],x.prototype,"_richText",2),p([r()],x.prototype,"_showRichText",2),p([r()],x.prototype,"_leastAnswerCount",2),p([r()],x.prototype,"_answerCheckType",2),p([r()],x.prototype,"_orderList",2),p([r()],x.prototype,"_resultDialogOpen",2),p([r()],x.prototype,"_resultDialogIndex",2),p([r()],x.prototype,"_resultDialogValue",2),p([r()],x.prototype,"_sortDropdownOpen",2),x=p([o("qxs-subject-single")],x);export{x as QxsSubjectSingle,d as SubjectError};
318
+ `,d([i({type:Number,attribute:"order-index"})],m.prototype,"orderIndex",2),d([i({type:Boolean,attribute:"is-edit"})],m.prototype,"isEdit",2),d([i({type:Boolean,attribute:"is-save"})],m.prototype,"isSave",2),d([i({type:Boolean,attribute:"is-set"})],m.prototype,"isSet",2),d([i({type:Boolean,attribute:"is-key"})],m.prototype,"isKey",2),d([i({type:Boolean,attribute:"show-action"})],m.prototype,"showAction",2),d([i({type:Boolean,attribute:"show-analysis"})],m.prototype,"showAnalysis",2),d([i({type:String})],m.prototype,"type",2),d([i({type:Number,attribute:"answer-check-type"})],m.prototype,"answerCheckType",2),d([i({type:Number,attribute:"exam-answer-relation-type"})],m.prototype,"examAnswerRelationType",2),d([i({type:String,attribute:"rich-text-content"})],m.prototype,"richTextContent",2),d([i({type:String})],m.prototype,"analysis",2),d([i({type:Number,attribute:"least-answer-count"})],m.prototype,"leastAnswerCount",2),d([i({type:String,attribute:"exam-expand"})],m.prototype,"examExpand",2),d([i({type:String,attribute:"custom-id"})],m.prototype,"customId",2),d([i({type:Number,attribute:"exam-id"})],m.prototype,"examId",2),d([i({type:Object})],m.prototype,"uploadImage",2),d([i({type:Array,attribute:"answer-list"})],m.prototype,"answerList",1),d([i({type:String,attribute:"model-value"})],m.prototype,"modelValue",2),d([i({type:Boolean,attribute:"use-model"})],m.prototype,"useModel",2),d([r()],m.prototype,"_answers",2),d([r()],m.prototype,"_title",2),d([r()],m.prototype,"_analysis",2),d([r()],m.prototype,"_richText",2),d([r()],m.prototype,"_showRichText",2),d([r()],m.prototype,"_leastAnswerCount",2),d([r()],m.prototype,"_answerCheckType",2),d([r()],m.prototype,"_orderList",2),d([r()],m.prototype,"_resultDialogOpen",2),d([r()],m.prototype,"_resultDialogIndex",2),d([r()],m.prototype,"_resultDialogValue",2),d([r()],m.prototype,"_sortDropdownOpen",2),m=d([o("qxs-subject-single")],m);export{m as QxsSubjectSingle,c as SubjectError};
319
319
  //# sourceMappingURL=single.mjs.map