@qxs-bns/components-wc 0.0.25 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/subject/blank-fill.mjs +23 -48
- package/es/subject/blank-fill.mjs.map +1 -1
- package/es/subject/list.mjs +57 -99
- package/es/subject/list.mjs.map +1 -1
- package/es/subject/scale.mjs +72 -143
- package/es/subject/scale.mjs.map +1 -1
- package/es/subject/single.mjs +38 -64
- package/es/subject/single.mjs.map +1 -1
- package/es/subject/text-fill.mjs +13 -37
- package/es/subject/text-fill.mjs.map +1 -1
- package/lib/subject/blank-fill.cjs +10 -35
- package/lib/subject/blank-fill.cjs.map +1 -1
- package/lib/subject/list.cjs +16 -58
- package/lib/subject/list.cjs.map +1 -1
- package/lib/subject/scale.cjs +71 -142
- package/lib/subject/scale.cjs.map +1 -1
- package/lib/subject/single.cjs +39 -65
- package/lib/subject/single.cjs.map +1 -1
- package/lib/subject/text-fill.cjs +14 -38
- package/lib/subject/text-fill.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale.cjs","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 { type Category, type Resource, SubjectError, type TagItem } from './single'\nimport { SubjectType } from './types'\n\ninterface ScaleAnswer {\n title: string\n answerId?: string | number\n [key: string]: any\n}\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 { height: 200px; }\n .section-row { margin-top: 12px; }\n .value-text { font-size: 13px; color: #606266; white-space: pre-wrap; }\n .tag-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 32px; }\n .tag-item {\n display: inline-flex; align-items: center; gap: 4px;\n padding: 4px 8px; font-size: 12px; line-height: 1;\n color: #3D61E3; background: #ecf5ff; border: 1px solid #d9ecff; border-radius: 4px;\n }\n .tag-item .close { cursor: pointer; color: #909399; }\n .tag-item .close:hover { color: #f56c6c; }\n .tag-hint { font-size: 12px; color: #909399; }\n .el-select {\n width: 150px; height: 32px; border: 1px solid #dcdfe6; border-radius: 3px;\n padding: 0 8px; font-size: 13px; background: #fff; appearance: none;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c0c4cc' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E\");\n background-repeat: no-repeat; background-position: right 8px center;\n }\n .resource-summary { font-size: 12px; color: #606266; }\n .resource-thumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }\n .resource-thumb {\n width: 72px; height: 72px; object-fit: cover; border-radius: 6px;\n border: 1px solid #e4e7ed; background: #f5f7fa;\n }\n `\n\n @property({ type: Number, attribute: 'order-index' }) 'order-index' = 0\n @property({ type: String }) title = ''\n @property({ type: String, attribute: 'custom-id' }) 'custom-id' = ''\n @property({ type: Boolean, attribute: 'is-edit' }) 'is-edit' = false\n @property({ type: Boolean, attribute: 'is-save' }) 'is-save' = false\n @property({ type: Boolean, attribute: 'is-set' }) 'is-set' = false\n @property({ type: Boolean, attribute: 'show-action' }) 'show-action' = true\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: Boolean, attribute: 'show-analysis' }) 'show-analysis' = true\n @property({ type: String }) analysis = ''\n @property({ type: String, attribute: 'rich-text-content' }) 'rich-text-content' = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) 'exam-answer-relation-type' = 0\n @property({ type: Number, attribute: 'exam-id' }) 'exam-id' = 0\n @property({ type: String, attribute: 'category-id' }) 'category-id' = ''\n @property({ type: Array, attribute: 'tag-list' }) 'tag-list': TagItem[] = []\n @property({ type: Array, attribute: 'category-list' }) 'category-list': Category[] = []\n @property({ type: Array, attribute: 'resource-list' }) 'resource-list': Resource[] = []\n @property({ type: Boolean, attribute: 'show-tag' }) 'show-tag' = false\n @property({ type: Boolean, attribute: 'show-category' }) 'show-category' = false\n @property({ type: Boolean, attribute: 'show-resource' }) 'show-resource' = false\n @property({ type: Object, attribute: 'upload-image' })\n 'upload-image': (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, attribute: 'answer-list' })\n get 'answer-list'() { return this._answers }\n\n set 'answer-list'(value: any) {\n const arr = Array.isArray(value) ? value : []\n this._answers = arr.length ? arr.slice(0, 5) : [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n this.requestUpdate('answer-list')\n }\n\n @property({ type: Array, attribute: 'scale-questions' })\n get 'scale-questions'() { return this._scaleQuestions }\n\n set 'scale-questions'(value: any) {\n this._scaleQuestions = Array.isArray(value) && value.length ? value : ['问题1']\n this.requestUpdate('scale-questions')\n }\n\n @state() private _answers: ScaleAnswer[] = [{ 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 @state() private _selectedTagList: TagItem[] = []\n @state() private _categoryId = ''\n\n @property({ type: String, attribute: 'model-value' }) 'model-value' = ''\n @property({ type: Boolean, attribute: 'use-model' }) 'use-model' = false\n\n private readonly TITLE_MAX = 200\n\n willUpdate(changed: Map<string, unknown>) {\n if (changed.has('is-edit') && this['is-edit']) { this._syncProps() }\n if (!this['is-edit'] && (changed.has('title') || changed.has('answer-list') || changed.has('analysis') || changed.has('rich-text-content') || changed.has('scale-questions') || changed.has('tag-list') || changed.has('category-id'))) {\n this._syncProps()\n }\n if (changed.has('model-value') && this['use-model']) {\n this._title = this['model-value']\n }\n if (changed.has('tag-list')) {\n this._selectedTagList = Array.isArray(this['tag-list']) ? this['tag-list'].map(item => ({ ...item })) : []\n }\n if (changed.has('category-id')) {\n this._categoryId = this['category-id'] ? String(this['category-id']) : ''\n }\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._analysis = this.analysis || ''\n this._rowTitle = this._scaleQuestions.join('\\n')\n this._richText = this['rich-text-content'] || ''\n this._showRichText = !!this['rich-text-content']\n this._selectedTagList = Array.isArray(this['tag-list']) ? this['tag-list'].map(item => ({ ...item })) : []\n this._categoryId = this['category-id'] ? String(this['category-id']) : ''\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 if (this['use-model']) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private _removeTag(tagId: string | number) {\n this._selectedTagList = this._selectedTagList.filter(item => String(item.tagId) !== String(tagId))\n this._emit('tag-change', {\n value: this._selectedTagList,\n customId: this['custom-id'] || '',\n examId: this['exam-id'] || 0,\n })\n }\n\n private _chooseTag() {\n this._emit('choose-tag', {\n value: this._selectedTagList,\n customId: this['custom-id'] || '',\n examId: this['exam-id'] || 0,\n })\n }\n\n private _onCategoryChange(value: string) {\n this._categoryId = value\n this._emit('category-change', {\n value,\n customId: this['custom-id'] || '',\n examId: this['exam-id'] || 0,\n })\n }\n\n private _imageResources() {\n return (this['resource-list'] || [])\n .filter(item => item.resourceType === 1)\n .map(item => item.resource.middle || item.resource.url)\n .filter(Boolean) as string[]\n }\n\n private _videoResource() {\n return (this['resource-list'] || []).find(item => item.resourceType === 2)?.resource || null\n }\n\n private _categoryLabel() {\n const matched = this['category-list'].find((item: any) => String(item.categoryId) === String(this._categoryId))\n return matched?.title || matched?.categoryName || this._categoryId || '未选择分类'\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this['custom-id'] || undefined, answerType: 'scale', orderIndex: this['order-index'] }\n\n const title = this['is-edit'] ? this._title : this.title || ''\n const answers = this['is-edit'] ? this._answers : (this['answer-list'] || [])\n const analysis = this['is-edit'] ? this._analysis : this.analysis || ''\n const rowTitle = this['is-edit'] ? this._rowTitle : (this['scale-questions']?.join('\\n') || '')\n const showRichText = this['is-edit'] ? this._showRichText : !!this['rich-text-content']\n const richText = this['is-edit'] ? this._richText : this['rich-text-content'] || ''\n const selectedTagList = this._selectedTagList || []\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((item: string) => item.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: SubjectType.SCALE,\n title,\n analysis,\n answers,\n scaleQuestionList: questions,\n examRichTextContent: showRichText ? richText : '',\n examAnswerRelationType: this['exam-answer-relation-type'],\n categoryId: this._categoryId || '',\n memberTagInfo: selectedTagList,\n tagInfos: selectedTagList,\n resourceList: this['resource-list'] || [],\n examResourceBOList: this['resource-list'] || [],\n isSetCorrectAnswer: false,\n }\n if (this['custom-id']) { result.customId = this['custom-id'] }\n resolve(result)\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['custom-id'] || undefined, answerType: 'scale', orderIndex: this['order-index'] }\n\n const title = this['is-edit'] ? this._title : this.title || ''\n const answers = this['is-edit'] ? this._answers : (this['answer-list'] || [])\n const rowTitle = this['is-edit'] ? this._rowTitle : (this['scale-questions']?.join('\\n') || '')\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n answers.forEach((answer: any, index: number) => {\n if (!answer.title) {\n errors.push(new SubjectError(`选项${String.fromCharCode(65 + index)}未填写`, '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((item: string) => item.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['order-index'] + 1}.${this.title}(量表题)</span>\n ${this['rich-text-content'] ? html`<div style=\"margin-top:8px\" .innerHTML=${this['rich-text-content']}></div>` : ''}\n <table class=\"scale-table\">\n <thead><tr>\n <th style=\"width:${colWidth}%\">问题 \\ 选项</th>\n ${this._answers.map(answer => html`<th style=\"width:${colWidth}%\">${answer.title}</th>`)}\n </tr></thead>\n <tbody>\n ${this._scaleQuestions.map(question => html`\n <tr><td>${question}</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 ${this['show-category'] && this._categoryId\n ? html`<div class=\"section-row\"><span class=\"value-text\">分类:${this._categoryLabel()}</span></div>`\n : ''}\n ${this['show-tag'] && this._selectedTagList.length\n ? html`\n <div class=\"section-row\">\n <span class=\"value-text\">标签/关键信息:</span>\n <div class=\"tag-list\" style=\"margin-top:6px\">\n ${this._selectedTagList.map(item => html`<span class=\"tag-item\">${item.tagName}</span>`)}\n </div>\n </div>\n `\n : ''}\n ${this._renderResourceSection()}\n </div>\n `\n }\n\n private _renderTagSection() {\n if (!this['show-tag']) { return '' }\n return html`\n <div class=\"flex-items-start section-row\">\n <div class=\"label\"><span>标签:</span></div>\n <div style=\"flex:1\">\n <div class=\"tag-list\">\n ${this._selectedTagList.length\n ? this._selectedTagList.map(item => html`\n <span class=\"tag-item\">\n ${item.tagName}\n ${!this['is-save'] ? html`<span class=\"close\" @click=${() => this._removeTag(item.tagId)}>×</span>` : ''}\n </span>\n `)\n : html`<span class=\"tag-hint\">暂无标签/关键信息</span>`}\n </div>\n ${this['is-edit'] && !this['is-save']\n ? html`<div style=\"margin-top:8px\"><span class=\"el-link\" @click=${() => this._chooseTag()}>选择</span></div>`\n : ''}\n </div>\n </div>\n `\n }\n\n private _renderCategorySection() {\n if (!this['show-category']) { return '' }\n return html`\n <div class=\"flex-items-start section-row\">\n <div class=\"label\"><span>分类:</span></div>\n <div style=\"flex:1\">\n ${this['is-edit']\n ? html`\n <select class=\"el-select\" .value=${String(this._categoryId)} ?disabled=${this['is-save']}\n @change=${(e: Event) => this._onCategoryChange((e.target as HTMLSelectElement).value)}>\n <option value=\"\">选择分类</option>\n ${this['category-list'].map((item: any) => html`\n <option value=${String(item.categoryId)} ?selected=${String(item.categoryId) === String(this._categoryId)}>${item.title || item.categoryName}</option>\n `)}\n </select>\n `\n : html`<span class=\"value-text\">${this._categoryLabel()}</span>`}\n </div>\n </div>\n `\n }\n\n private _renderResourceSection() {\n if (!this['show-resource']) { return '' }\n const images = this._imageResources()\n const video = this._videoResource()\n return html`\n <div class=\"flex-items-start section-row\">\n <div class=\"label\"><span>资源:</span></div>\n <div style=\"flex:1\">\n <div class=\"resource-summary\">图片 ${images.length} 张${video?.url ? ',含视频资源' : ''}</div>\n ${images.length\n ? html`\n <div class=\"resource-thumbs\">\n ${images.slice(0, 4).map(src => html`<img class=\"resource-thumb\" src=${src} alt=\"resource\" />`)}\n </div>\n `\n : ''}\n ${video?.url ? html`<div style=\"margin-top:8px\"><a class=\"el-link\" href=${video.url} target=\"_blank\" rel=\"noreferrer\">查看视频</a></div>` : ''}\n ${!images.length && !video?.url ? html`<div class=\"tag-hint\">暂无资源</div>` : ''}\n </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['is-save']}\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 ${this._renderTagSection()}\n\n ${this._renderCategorySection()}\n\n ${this._renderResourceSection()}\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['is-save']}\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((answer, index) => html`\n <div class=\"answer-item\">\n <span class=\"label\">${String.fromCharCode(65 + index)}.</span>\n <div class=\"input\">\n <input type=\"text\" .value=${answer.title} ?disabled=${this['is-save']}\n maxlength=\"10\"\n @input=${(e: Event) => {\n const value = (e.target as HTMLInputElement).value\n this._answers = this._answers.map((item, currentIndex) => currentIndex === index ? { ...item, title: value } : item)\n }}\n placeholder=\"选项${index + 1}\" />\n </div>\n ${!this['is-save']\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((_, currentIndex) => currentIndex !== index) }\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['is-save']}\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 .upload-image=${this['upload-image']}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n ${!this['show-action']\n ? html`<div class=\"flex-justify-end\" style=\"margin-top:8px\"><span class=\"el-link danger\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span></div>`\n : ''}\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n return html`\n <qxs-subject-layout .show-edit=${this['is-edit']}>\n <div slot=\"preview\">${this._renderPreview()}</div>\n <div slot=\"edit\">${this._renderEdit()}</div>\n ${this['show-action']\n ? html`\n <qxs-subject-action\n .is-edit=${this['is-edit']}\n .is-set=${this['is-set']}\n .show-add=${this['show-add']}\n .show-rich-text=${this._showRichText}\n .show-other-option=${false}\n exam-answer-relation-type=${this['exam-answer-relation-type']}\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=${() => {\n this._showRichText = !this._showRichText\n if (!this._showRichText) {\n this._richText = ''\n }\n }}\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","title","analysis","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_analysis","_showRichText","_richText","_selectedTagList","_categoryId","TITLE_MAX","value","arr","Array","isArray","length","slice","requestUpdate","willUpdate","changed","has","_syncProps","map","item","String","join","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","_removeTag","tagId","filter","customId","examId","_chooseTag","_onCategoryChange","_imageResources","resourceType","resource","middle","url","Boolean","_videoResource","find","_categoryLabel","matched","categoryId","categoryName","toJSON","row","answerType","orderIndex","answers","rowTitle","showRichText","richText","selectedTagList","SubjectError","i","fromCharCode","questions","split","trim","SubjectType","SCALE","scaleQuestionList","examRichTextContent","examAnswerRelationType","memberTagInfo","tagInfos","resourceList","examResourceBOList","isSetCorrectAnswer","_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","answer","index","_renderPreview","colWidth","Math","floor","question","tagName","_renderResourceSection","_renderTagSection","_renderCategorySection","images","video","src","_renderEdit","stopPropagation","currentIndex","_","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","state","safeCustomElement"],"mappings":"gVAYA,MAAMA,EAAWC,EAAAA,IAAA,2NACXC,EAAaD,EAAAA,IAAA,qLAgBNE,QAAAA,SAAN,cAAuBC,EAAAA,WAAvBC,WAAAA,GAAAC,SAAAC,WAmFiDC,KAAA,eAAgB,EAC1CA,KAAAC,MAAQ,GACgBD,KAAA,aAAc,GACfA,KAAA,YAAY,EACZA,KAAA,YAAY,EACbA,KAAA,WAAW,EACNA,KAAA,gBAAgB,EACnBA,KAAA,aAAa,EACRA,KAAA,kBAAkB,EAC/CA,KAAAE,SAAW,GACqBF,KAAA,qBAAsB,GACdA,KAAA,6BAA8B,EAChDA,KAAA,WAAY,EACRA,KAAA,eAAgB,GACpBA,KAAA,YAAwB,GACnBA,KAAA,iBAA8B,GAC9BA,KAAA,iBAA8B,GACjCA,KAAA,aAAa,EACRA,KAAA,kBAAkB,EAClBA,KAAA,kBAAkB,EAE3EA,KAAA,gBAAkDG,S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J,UAAA,kBAAA,GACAL,EAAA,CAAhBM,EAAAA,SApIUhK,QAAAA,SAoIM+J,UAAA,YAAA,GACAL,EAAA,CAAhBM,EAAAA,SArIUhK,QAAAA,SAqIM+J,UAAA,SAAA,GACAL,EAAA,CAAhBM,EAAAA,SAtIUhK,QAAAA,SAsIM+J,UAAA,YAAA,GACAL,EAAA,CAAhBM,EAAAA,SAvIUhK,QAAAA,SAuIM+J,UAAA,gBAAA,GACAL,EAAA,CAAhBM,EAAAA,SAxIUhK,QAAAA,SAwIM+J,UAAA,YAAA,GACAL,EAAA,CAAhBM,EAAAA,SAzIUhK,QAAAA,SAyIM+J,UAAA,mBAAA,GACAL,EAAA,CAAhBM,EAAAA,SA1IUhK,QAAAA,SA0IM+J,UAAA,cAAA,GAEqCL,EAAA,CAArDC,EAAAA,SAAS,CAAEC,KAAMhH,OAAQkH,UAAW,iBA5I1B9J,QAAAA,SA4I2C+J,UAAA,cAAA,GACDL,EAAA,CAApDC,EAAAA,SAAS,CAAEC,KAAMzF,QAAS2F,UAAW,eA7I3B9J,QAAAA,SA6I0C+J,UAAA,YAAA,GA7I1C/J,QAAAA,SAAN0J,EAAA,CADNO,EAAAA,kBAAkB,cACNjK,QAAAA"}
|
|
1
|
+
{"version":3,"file":"scale.cjs","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 { SubjectType } from './types'\n\ninterface ScaleAnswer {\n title: string\n answerId?: string | number\n orderIndex?: number\n isCorrect?: boolean\n [key: string]: any\n}\n\nfunction createEmptyScaleAnswer(): ScaleAnswer {\n return { title: '' }\n}\n\nfunction createDefaultScaleAnswers(): ScaleAnswer[] {\n return Array.from({ length: 5 }, createEmptyScaleAnswer)\n}\n\nfunction normalizeScaleAnswer(answer: any): ScaleAnswer {\n const next: ScaleAnswer = {\n ...answer,\n title: String(answer?.title ?? answer?.answer ?? ''),\n }\n const answerId = answer?.answerId ?? answer?.examAnswerId\n if (answerId !== undefined) {\n next.answerId = answerId\n }\n delete next.answer\n delete next.examAnswerId\n return next\n}\n\nfunction normalizeScaleAnswers(value: any): ScaleAnswer[] {\n return Array.isArray(value) ? value.slice(0, 5).map(normalizeScaleAnswer) : []\n}\n\nfunction normalizeScaleQuestionList(value: any): string[] {\n if (!Array.isArray(value)) {\n return []\n }\n return value\n .map(item => String(item ?? '').trim())\n .filter(Boolean)\n}\n\nfunction splitScaleQuestionLines(value: string): string[] {\n return value\n .split('\\n')\n .map(item => item.trim())\n .filter(Boolean)\n}\n\nfunction serializeScaleAnswer(answer: any, index: number): ScaleAnswer {\n const next: ScaleAnswer = {\n ...normalizeScaleAnswer(answer),\n orderIndex: index + 1,\n answer: String(answer?.title ?? answer?.answer ?? ''),\n }\n next.title = String(next.title ?? '')\n if (next.answerId !== undefined) {\n next.examAnswerId = next.answerId\n }\n if (next.answerId === undefined) {\n delete next.answerId\n }\n if (next.isCorrect === undefined) {\n delete next.isCorrect\n }\n return next\n}\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(() => {\n el.style.opacity = '0'\n setTimeout(() => el.remove(), 300)\n }, 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-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.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 { height: 200px; }\n `\n\n @property({ type: Number, attribute: 'order-index' }) 'order-index' = 0\n @property({ type: String }) title = ''\n @property({ type: String, attribute: 'custom-id' }) 'custom-id' = ''\n @property({ type: Boolean, attribute: 'is-edit' }) 'is-edit' = false\n @property({ type: Boolean, attribute: 'is-save' }) 'is-save' = false\n @property({ type: Boolean, attribute: 'is-set' }) 'is-set' = false\n @property({ type: Boolean, attribute: 'show-action' }) 'show-action' = true\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: String }) analysis = ''\n @property({ type: String, attribute: 'rich-text-content' }) 'rich-text-content' = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) 'exam-answer-relation-type' = 0\n @property({ type: Object, attribute: 'upload-image' })\n 'upload-image': (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, attribute: 'answer-list' })\n get 'answer-list'() { return this._answers }\n\n set 'answer-list'(value: any) {\n this._answers = Array.isArray(value) ? normalizeScaleAnswers(value) : createDefaultScaleAnswers()\n this.requestUpdate('answer-list')\n }\n\n @property({ type: Array, attribute: 'scale-question-list' })\n get 'scale-question-list'() { return this._scaleQuestions }\n\n set 'scale-question-list'(value: any) {\n this._scaleQuestions = normalizeScaleQuestionList(value)\n this.requestUpdate('scale-question-list')\n }\n\n @property({ type: Array, attribute: 'scale-questions' })\n get 'scale-questions'() { return this._scaleQuestions }\n\n set 'scale-questions'(value: any) {\n this['scale-question-list'] = value\n this.requestUpdate('scale-questions')\n }\n\n @state() private _answers: ScaleAnswer[] = createDefaultScaleAnswers()\n @state() private _scaleQuestions: string[] = []\n @state() private _rowTitle = ''\n @state() private _title = ''\n @state() private _showRichText = false\n @state() private _richText = ''\n\n @property({ type: String, attribute: 'model-value' }) 'model-value' = ''\n @property({ type: Boolean, attribute: 'use-model' }) 'use-model' = false\n\n private readonly TITLE_MAX = 200\n\n willUpdate(changed: Map<string, unknown>) {\n const shouldSyncProps = changed.has('title')\n || changed.has('answer-list')\n || changed.has('rich-text-content')\n || changed.has('scale-question-list')\n || changed.has('scale-questions')\n\n if ((changed.has('is-edit') && this['is-edit']) || (!this['is-edit'] && shouldSyncProps)) {\n this._syncProps()\n }\n\n if (changed.has('model-value') && this['use-model']) {\n this._title = this['model-value']\n }\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._rowTitle = this._scaleQuestions.join('\\n')\n this._richText = this['rich-text-content'] || ''\n this._showRichText = !!this['rich-text-content']\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) {\n el.value = el.value.slice(0, this.TITLE_MAX)\n }\n this._title = el.value\n if (this['use-model']) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private _resolvedQuestions(): string[] {\n const rowTitle = this['is-edit'] ? this._rowTitle : this._scaleQuestions.join('\\n')\n return splitScaleQuestionLines(rowTitle)\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = {\n customId: this['custom-id'] || undefined,\n answerType: SubjectType.SCALE,\n orderIndex: this['order-index'],\n }\n\n const title = this['is-edit'] ? this._title : this.title || ''\n const answers = this['is-edit'] ? this._answers : this['answer-list']\n const questions = this._resolvedQuestions()\n const richText = this['is-edit'] ? this._richText : this['rich-text-content'] || ''\n const showRichText = this['is-edit'] ? this._showRichText : !!this['rich-text-content']\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 (questions.length === 0) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const result: any = {\n answerType: SubjectType.SCALE,\n examTypeEnum: SubjectType.SCALE,\n title,\n answers: answers.map(serializeScaleAnswer),\n scaleQuestionList: questions,\n analysis: this.analysis || '',\n examRichTextContent: showRichText ? richText : '',\n isSetCorrectAnswer: false,\n }\n\n if (this['custom-id']) {\n result.customId = this['custom-id']\n }\n\n resolve(result)\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 = {\n customId: this['custom-id'] || undefined,\n answerType: SubjectType.SCALE,\n orderIndex: this['order-index'],\n }\n\n const title = this['is-edit'] ? this._title : this.title || ''\n const answers = this['is-edit'] ? this._answers : this['answer-list']\n const questions = this._resolvedQuestions()\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n answers.forEach((answer: ScaleAnswer, index: number) => {\n if (!answer.title) {\n errors.push(new SubjectError(`选项${String.fromCharCode(65 + index)}未填写`, 'ANSWER_EMPTY', 'answers', row))\n }\n })\n\n if (questions.length === 0) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n\n return errors\n }\n\n private _renderPreview() {\n const colWidth = Math.floor(100 / ((this._answers.length || 1) + 1))\n\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this['order-index'] + 1}.${this.title}(量表题)</span>\n ${this['rich-text-content'] ? html`<div style=\"margin-top:8px\" .innerHTML=${this['rich-text-content']}></div>` : ''}\n <table class=\"scale-table\">\n <thead>\n <tr>\n <th style=\"width:${colWidth}%\">问题 \\ 选项</th>\n ${this._answers.map(answer => html`<th style=\"width:${colWidth}%\">${answer.title}</th>`)}\n </tr>\n </thead>\n <tbody>\n ${this._scaleQuestions.map(question => html`\n <tr>\n <td>${question}</td>\n ${this._answers.map(() => html`<td><input type=\"radio\" disabled /></td>`)}\n </tr>\n `)}\n </tbody>\n </table>\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\n rows=\"2\"\n .value=${this._title}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【量表题】请输入问题\"\n ></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <slot name=\"business-tag\"></slot>\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\n class=\"row-title-textarea\"\n .value=${this._rowTitle}\n @input=${(e: Event) => { this._rowTitle = (e.target as HTMLTextAreaElement).value }}\n @keydown=${(e: KeyboardEvent) => { e.stopPropagation() }}\n placeholder=\"请输入行标题\"\n ></textarea>\n </div>\n <div style=\"flex:1;margin-left:12px\">\n ${this._answers.map((answer, index) => html`\n <div class=\"answer-item\">\n <span class=\"label\">${String.fromCharCode(65 + index)}.</span>\n <div class=\"input\">\n <input\n type=\"text\"\n .value=${answer.title}\n maxlength=\"10\"\n @input=${(e: Event) => {\n const value = (e.target as HTMLInputElement).value\n this._answers = this._answers.map((item, currentIndex) =>\n currentIndex === index ? { ...item, title: value } : item,\n )\n }}\n placeholder=\"选项${index + 1}\"\n />\n </div>\n <span\n class=\"icon\"\n @click=${() => {\n if (this._answers.length < 5) {\n this._answers = [...this._answers, createEmptyScaleAnswer()]\n }\n }}\n >${iconPlus}</span>\n <span\n class=\"icon ${this._answers.length < 3 ? 'disabled' : ''}\"\n @click=${() => {\n if (this._answers.length > 3) {\n this._answers = this._answers.filter((_, currentIndex) => currentIndex !== index)\n }\n }}\n >${iconRemove}</span>\n </div>\n `)}\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 .upload-image=${this['upload-image']}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n ${!this['show-action']\n ? html`\n <div class=\"flex-justify-end\" style=\"margin-top:8px\">\n <span\n class=\"el-link danger\"\n @click=${() => {\n this._showRichText = false\n this._richText = ''\n }}\n >删除富文本</span>\n </div>\n `\n : ''}\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n const content = this['is-edit']\n ? html`<div slot=\"edit\">${this._renderEdit()}</div>`\n : html`<div slot=\"preview\">${this._renderPreview()}</div>`\n\n return html`\n <qxs-subject-layout .show-edit=${this['is-edit']}>\n ${content}\n ${this['show-action']\n ? html`\n <qxs-subject-action\n .is-edit=${this['is-edit']}\n .is-set=${this['is-set']}\n .show-add=${this['show-add']}\n .show-rich-text=${this._showRichText}\n .show-other-option=${false}\n exam-answer-relation-type=${this['exam-answer-relation-type']}\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=${() => {\n this._showRichText = !this._showRichText\n if (!this._showRichText) {\n this._richText = ''\n }\n }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["createEmptyScaleAnswer","title","createDefaultScaleAnswers","Array","from","length","normalizeScaleAnswer","answer","next","String","answerId","examAnswerId","serializeScaleAnswer","index","orderIndex","isCorrect","iconPlus","html","iconRemove","QxsScale","LitElement","constructor","super","arguments","this","analysis","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_showRichText","_richText","TITLE_MAX","value","isArray","slice","map","normalizeScaleAnswers","requestUpdate","item","trim","filter","Boolean","normalizeScaleQuestionList","willUpdate","changed","shouldSyncProps","has","_syncProps","join","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","_resolvedQuestions","rowTitle","split","toJSON","row","customId","answerType","SubjectType","SCALE","answers","questions","richText","showRichText","SubjectError","i","fromCharCode","examTypeEnum","scaleQuestionList","examRichTextContent","isSetCorrectAnswer","_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","_renderPreview","colWidth","Math","floor","question","_renderEdit","stopPropagation","currentIndex","_","render","content","styles","css","__decorateClass","property","type","Number","attribute","prototype","state","safeCustomElement"],"mappings":"gVAcA,SAASA,IACP,MAAO,CAAEC,MAAO,GAClB,CAEA,SAASC,IACP,OAAOC,MAAMC,KAAK,CAAEC,OAAQ,GAAKL,EACnC,CAEA,SAASM,EAAqBC,GAC5B,MAAMC,EAAoB,IACrBD,EACHN,MAAOQ,OAAOF,GAAQN,OAASM,GAAQA,QAAU,KAE7CG,EAAWH,GAAQG,UAAYH,GAAQI,aAM7C,YALiB,IAAbD,IACFF,EAAKE,SAAWA,U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B5H,QAAAA,SAgGP6H,UAAA,kBAAA,GAOaL,EAAA,CAAhBM,EAAAA,SAvGU9H,QAAAA,SAuGM6H,UAAA,WAAA,GACAL,EAAA,CAAhBM,EAAAA,SAxGU9H,QAAAA,SAwGM6H,UAAA,kBAAA,GACAL,EAAA,CAAhBM,EAAAA,SAzGU9H,QAAAA,SAyGM6H,UAAA,YAAA,GACAL,EAAA,CAAhBM,EAAAA,SA1GU9H,QAAAA,SA0GM6H,UAAA,SAAA,GACAL,EAAA,CAAhBM,EAAAA,SA3GU9H,QAAAA,SA2GM6H,UAAA,gBAAA,GACAL,EAAA,CAAhBM,EAAAA,SA5GU9H,QAAAA,SA4GM6H,UAAA,YAAA,GAEqCL,EAAA,CAArDC,EAAAA,SAAS,CAAEC,KAAMpI,OAAQsI,UAAW,iBA9G1B5H,QAAAA,SA8G2C6H,UAAA,cAAA,GACDL,EAAA,CAApDC,EAAAA,SAAS,CAAEC,KAAMtF,QAASwF,UAAW,eA/G3B5H,QAAAA,SA+G0C6H,UAAA,YAAA,GA/G1C7H,QAAAA,SAANwH,EAAA,CADNO,EAAAA,kBAAkB,cACN/H,QAAAA"}
|
package/lib/subject/single.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("lit"),t=require("lit/decorators.js"),s=require("../base/define.cjs"),i=require("../base/uid.cjs"),r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=(e,t,s,i)=>{for(var a,n=i>1?void 0:i?o(t,s):t,l=e.length-1;l>=0;l--)(a=e[l])&&(n=(i?a(t,s,n):a(n))||n);return i&&n&&r(t,s,n),n};class n 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 n(e.message,e.code,e.field,e.row)}}const l=e.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>`,c=e.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>`,h=e.html`<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>`;function p(e){return e.replace(/^\d+\.\s*/,"").replace(/[\s,,。.!!??;;::、'"“”‘’()()[\]【】\-_/\\]+/g,"").toLowerCase()}function d(e){const t=document.createElement("div");t.textContent=e,Object.assign(t.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(t),setTimeout(()=>{t.style.opacity="0",setTimeout(()=>t.remove(),300)},2500)}exports.QxsSubjectSingle=class extends e.LitElement{constructor(){super(...arguments),this["order-index"]=0,this["is-edit"]=!1,this["is-save"]=!1,this["is-set"]=!1,this["is-key"]=!1,this["show-action"]=!0,this["show-add"]=!0,this["show-answer-setting"]=!1,this["show-key"]=!1,this["show-analysis"]=!0,this.type="single",this["answer-check-type"]=1,this["exam-answer-relation-type"]=0,this["rich-text-content"]="",this.analysis="",this["least-answer-count"]=0,this["exam-expand"]="",this["custom-id"]="",this["exam-id"]=0,this["category-id"]="",this["upload-image"]=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this["tag-list"]=[],this["category-list"]=[],this["ai-answer"]="",this["resource-list"]=[],this["show-tag"]=!1,this["show-category"]=!1,this["show-ai"]=!1,this["show-resource"]=!1,this["show-jump"]=!1,this["has-jump"]=!1,this["search-api"]="",this["model-value"]="",this["use-model"]=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.title="",this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=0,this._answerCheckType=1,this._isKey=!1,this._orderList=[],this._selectedTagList=[],this._categoryId="",this._searchResults=[],this._searchOpen=!1,this._searchLoading=!1,this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this._imageViewerOpen=!1,this._imageViewerIndex=0,this._videoViewerOpen=!1,this._correctHintDialogOpen=!1,this._hasShownCorrectHint=!1,this._searchTimer=null,this._searchToken=0,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper"),i=this.shadowRoot?.querySelector(".search-wrap");s&&!t.includes(s)&&(this._sortDropdownOpen=!1),i&&!t.includes(i)&&(this._searchOpen=!1),this.requestUpdate()}}get"answer-list"(){return this._answers}set"answer-list"(e){if(this["is-edit"])return;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("answer-list")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick),this._syncExternalProps()}firstUpdated(){this._syncExternalProps()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick),this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null)}willUpdate(e){e.has("is-edit")&&this["is-edit"]&&this._syncProps(),!this["is-edit"]&&(e.has("title")||e.has("answer-list")||e.has("analysis")||e.has("least-answer-count")||e.has("answer-check-type")||e.has("tag-list")||e.has("category-id")||e.has("rich-text-content"))&&this._syncExternalProps(),e.has("is-key")&&(this._isKey=this["is-key"]),e.has("tag-list")&&(this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[]),e.has("category-id")&&(this._categoryId=this["category-id"]?String(this["category-id"]):""),(e.has("exam-expand")||e.has("answer-list"))&&this._syncExamExpand(),e.has("model-value")&&this["use-model"]&&(this._title=this["model-value"])}_syncExternalProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=Number(this["least-answer-count"])||0,this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>({...e,title:e.title||"",isCorrect:!!e.isCorrect})))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=Number(this["least-answer-count"])||0,this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>({...e,title:e.title||"",isCorrect:!!e.isCorrect}))),this._syncExamExpand()}_syncExamExpand(){if(!this["exam-expand"]||!this["answer-list"]?.length)return;const e=this["exam-expand"].split(","),t=this["answer-list"];this._orderList=e.map(e=>{const s=t.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return s>=0?this._label(s):""}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_searchAnswerType(){return"single"===this.type?0:"multiple"===this.type?1:5}_queueSearch(e){this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null);const t=e.trim();if(!t||!this["search-api"]&&"function"!=typeof this["search-handler"])return this._searchResults=[],this._searchOpen=!1,void(this._searchLoading=!1);this._searchTimer=window.setTimeout(()=>{this._runSearch(t)},300)}async _runSearch(e){const t=++this._searchToken;this._searchLoading=!0,this._searchOpen=!0,this.requestUpdate();try{let s=[];if("function"==typeof this["search-handler"])s=await this["search-handler"](e,this._searchAnswerType());else if(this["search-api"]){const t=new URLSearchParams({searchKey:e,answerType:String(this._searchAnswerType())}),i=await fetch(`${this["search-api"]}${this["search-api"].includes("?")?"&":"?"}${t.toString()}`);if(!i.ok)throw new Error(`HTTP ${i.status}`);const r=await i.json();s=(Array.isArray(r)?r:Array.isArray(r?.data)?r.data:[]).map(e=>({...e,value:e?.value||e?.title||""}))}if(t!==this._searchToken)return;this._searchResults=Array.isArray(s)?s:[]}catch(e){if(t!==this._searchToken)return;this._searchResults=[],d(e?.message||"题库搜索失败")}finally{t===this._searchToken&&(this._searchLoading=!1,this.requestUpdate())}}_selectSearchResult(e){const t=e.value||e.title||"";this._title=t,this._searchResults=[],this._searchOpen=!1,this["use-model"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title})),this._emit("title-select",{...e,id:e.id??e.examId??e.questionId,title:e.title||t,value:t,customId:this["custom-id"]||""})}_applyAiAnswer(){if(!this["ai-answer"]?.trim())return void d("暂无 AI 推荐答案");const e=this["ai-answer"].split(/\r?\n/).map(e=>p(e)).filter(Boolean);let t=0;if("single"===this.type){let s=!1;this._answers=this._answers.map(i=>{const r=!s&&e.includes(p(i.title||""));return r&&(s=!0,t++),{...i,isCorrect:r}})}else this._answers=this._answers.map(s=>{const i=e.includes(p(s.title||""));return i&&t++,{...s,isCorrect:i}});t?this.requestUpdate():d("未找到匹配的选项,请检查选项内容是否一致")}_removeTag(e){this._selectedTagList=this._selectedTagList.filter(t=>String(t.tagId)!==String(e)),this._emit("tag-change",{value:this._selectedTagList,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_chooseTag(){this._emit("choose-tag",{value:this._selectedTagList,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_onCategoryChange(e){this._categoryId=e,this._emit("category-change",{value:e,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_setRelation(e,t){const s=e.customAnswerId?{...e}:{...e,customAnswerId:e.answerId||i.uid()};this._answers=this._answers.map((e,i)=>i===t?s:e),this.requestUpdate(),this._emit("set-relation",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerIndex:t,answer:s})}_relationLength(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce((e,t)=>e+(Array.isArray(t?.relationAnswers)?t.relationAnswers.length:0),0)}_imageResources(){return(this["resource-list"]||[]).filter(e=>1===e.resourceType).map(e=>e.resource.middle||e.resource.url).filter(Boolean)}_videoResource(){return(this["resource-list"]||[]).find(e=>2===e.resourceType)?.resource||null}_openImageViewer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._imageResources().length&&(this._imageViewerIndex=e,this._imageViewerOpen=!0)}_closeImageViewer(){this._imageViewerOpen=!1}_moveImage(e){const t=this._imageResources();t.length&&(this._imageViewerIndex=(this._imageViewerIndex+e+t.length)%t.length)}_openVideoViewer(){this._videoResource()?.url&&(this._videoViewerOpen=!0)}_closeVideoViewer(){this._videoViewerOpen=!1}_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._queueSearch(this._title),this["use-model"]&&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(e){if(this["is-save"])return;const t=[...this._answers];t.splice(e+1,0,{title:"",isCorrect:!1,customAnswerId:i.uid()}),this._answers=t}_deleteAnswer(e){this._answers.length<3||this["is-save"]||(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}_sortAnswerValue(e){const t=e.charCodeAt(0)-65,s=this._answers[t];return s?.answerId??t+1}_shouldShowCorrectHint(){return"sort"===this.type?!this._orderList.length:!this._answers.some(e=>!!e.isCorrect)}async toJSON(){return new Promise((e,t)=>{const s={customId:this["custom-id"]||void 0,answerType:this.type,orderIndex:this["order-index"]},i=this["is-edit"]?this._title:this.title||"",r=this["is-edit"]?this._answers:this["answer-list"]||[],o=this["is-edit"]?this._answerCheckType:this["answer-check-type"]||1,a=this["is-edit"]?this._leastAnswerCount:Number(this["least-answer-count"])||0,l=this["is-edit"]?this._analysis:this.analysis||"",c=this._selectedTagList||[],h=this["is-edit"]?this._orderList.map(e=>this._sortAnswerValue(e)).join(","):this["exam-expand"]||"",p=this["is-edit"]?this._showRichText:!!this["rich-text-content"],d=this["is-edit"]?this._richText:this["rich-text-content"]||"",u=this["is-edit"]?this._orderList:(()=>{const e=this["exam-expand"];return e?e.split(",").map(e=>{const t=this["answer-list"]?.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return t>=0?this._label(t):""}).filter(Boolean):[]})();if(!i)return void t(new n("题目标题不能为空!","EMPTY_TITLE","title",s));if(this["show-tag"]&&0===c.length)return void t(new n("请选择标签/关键信息","EMPTY_TAGS","tagList",s));if(!o)return void t(new n("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",s));let g="",x=!1,m=0;if("multiple"===this.type||"single"===this.type)r.forEach((e,t)=>{e.title?.trim()||(g+=`选项${String.fromCharCode(65+t)}未填写。`),e.isCorrect&&(x=!0,m++)});else if("sort"===this.type&&(u.length&&(x=!0),x&&u.length<a))return void t(new n(`排序题至少需要设置${a}项排序答案`,"SORT_COUNT_INVALID","orderList",s));if(g)return void t(new n(g,"ANSWER_EMPTY","answers",s));if(new Set(r.map(e=>e.title)).size!==r.length)return void t(new n("选项不能重复","DUPLICATE_ANSWERS","answers",s));if("multiple"===this.type){if(1===m)return void t(new n("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",s));if(x&&m<a)return void t(new n("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))}if((2===o||3===o)&&!x)return void t(new n("请设置支持选项","NO_CORRECT_ANSWER","answers",s));const w={answerType:String(this.type),title:i,answers:r.filter(e=>e.title).map((e,t)=>({...e,orderIndex:t+1})),examExpand:h,analysis:l,isSetCorrectAnswer:x,leastAnswerCount:a||"",examRichTextContent:p?d:"",examAnswerRelationType:this["exam-answer-relation-type"],isKey:this._isKey,answerCheckType:o,categoryId:this._categoryId||"",memberTagInfo:c,tagInfos:c,aiAnswer:this["ai-answer"]||"",resourceList:this["resource-list"]||[],examResourceBOList:this["resource-list"]||[]};this["custom-id"]&&(w.customId=this["custom-id"]),e(w)})}validate(){const e=[],t={customId:this["custom-id"]||void 0,answerType:this.type,orderIndex:this["order-index"]},s=this["is-edit"]?this._title:this.title||"",i=this["is-edit"]?this._answers:this["answer-list"]||[],r=this["is-edit"]?this._answerCheckType:this["answer-check-type"]||1,o=this["is-edit"]?this._leastAnswerCount:Number(this["least-answer-count"])||0,a=this._selectedTagList||[],l=this["is-edit"]?this._orderList:(()=>{const e=this["exam-expand"];return e?e.split(",").map(e=>{const t=this["answer-list"]?.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return t>=0?this._label(t):""}).filter(Boolean):[]})();s||e.push(new n("题目标题不能为空!","EMPTY_TITLE","title",t)),this["show-tag"]&&0===a.length&&e.push(new n("请选择标签/关键信息","EMPTY_TAGS","tagList",t)),r||e.push(new n("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",t));let c=!1,h=0;"multiple"===this.type||"single"===this.type?i.forEach((s,i)=>{s.title?.trim()||e.push(new n(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",t)),s.isCorrect&&(c=!0,h++)}):"sort"===this.type&&(l.length&&(c=!0),c&&l.length<o&&e.push(new n(`排序题至少需要设置${o}项排序答案`,"SORT_COUNT_INVALID","orderList",t)));return new Set(i.map(e=>e.title)).size!==i.length&&i.length>0&&e.push(new n("选项不能重复","DUPLICATE_ANSWERS","answers",t)),"multiple"===this.type&&(1===h&&i.length>0&&e.push(new n("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",t)),c&&h<o&&e.push(new n("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",t))),2!==r&&3!==r||c||e.push(new n("请设置支持选项","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()}_renderCorrectHintDialog(){return this._correctHintDialogOpen?e.html`
|
|
1
|
+
"use strict";var e=require("lit"),t=require("lit/decorators.js"),s=require("../base/define.cjs"),i=require("../base/uid.cjs"),r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=(e,t,s,i)=>{for(var a,n=i>1?void 0:i?o(t,s):t,l=e.length-1;l>=0;l--)(a=e[l])&&(n=(i?a(t,s,n):a(n))||n);return i&&n&&r(t,s,n),n};class n 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 n(e.message,e.code,e.field,e.row)}}const l=e.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>`,c=e.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>`,p=e.html`<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>`;function h(e){return e.replace(/^\d+\.\s*/,"").replace(/[\s,,。.!!??;;::、'"“”‘’()()[\]【】\-_/\\]+/g,"").toLowerCase()}function d(e){const t=document.createElement("div");t.textContent=e,Object.assign(t.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(t),setTimeout(()=>{t.style.opacity="0",setTimeout(()=>t.remove(),300)},2500)}exports.QxsSubjectSingle=class extends e.LitElement{constructor(){super(...arguments),this["order-index"]=0,this["is-edit"]=!1,this["is-save"]=!1,this["is-set"]=!1,this["is-set-correct-answer"]=!1,this.lockAnswerKey=!1,this["is-key"]=!1,this["show-action"]=!0,this["show-add"]=!0,this["show-answer-setting"]=!1,this["show-key"]=!1,this["show-analysis"]=!0,this.type="single",this["answer-check-type"]=1,this["exam-answer-relation-type"]=0,this["rich-text-content"]="",this.analysis="",this["least-answer-count"]=null,this["exam-expand"]="",this["custom-id"]="",this["exam-id"]=0,this["category-id"]="",this["upload-image"]=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this["tag-list"]=[],this["category-list"]=[],this["ai-answer"]="",this["resource-list"]=[],this["show-tag"]=!1,this["show-category"]=!1,this["show-ai"]=!1,this["show-resource"]=!1,this["show-jump"]=!1,this["has-jump"]=!1,this["search-api"]="",this["model-value"]="",this["use-model"]=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.title="",this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=null,this._answerCheckType=1,this._isKey=!1,this._orderList=[],this._selectedTagList=[],this._categoryId="",this._searchResults=[],this._searchOpen=!1,this._searchLoading=!1,this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this._imageViewerOpen=!1,this._imageViewerIndex=0,this._videoViewerOpen=!1,this._correctHintDialogOpen=!1,this._hasShownCorrectHint=!1,this._changeTypeDialogOpen=!1,this._searchTimer=null,this._searchToken=0,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper"),i=this.shadowRoot?.querySelector(".search-wrap");s&&!t.includes(s)&&(this._sortDropdownOpen=!1),i&&!t.includes(i)&&(this._searchOpen=!1),this.requestUpdate()}}get"answer-list"(){return this._answers}set"answer-list"(e){if(this["is-edit"])return;const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>this._normalizeAnswerItem(e)):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answer-list")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick),this._syncExternalProps()}firstUpdated(){this._syncExternalProps()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick),this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null)}willUpdate(e){e.has("is-edit")&&this["is-edit"]&&this._syncProps(),!this["is-edit"]&&(e.has("title")||e.has("answer-list")||e.has("analysis")||e.has("least-answer-count")||e.has("answer-check-type")||e.has("tag-list")||e.has("category-id")||e.has("rich-text-content"))&&this._syncExternalProps(),e.has("is-key")&&(this._isKey=this["is-key"]),e.has("tag-list")&&(this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[]),e.has("category-id")&&(this._categoryId=this["category-id"]?String(this["category-id"]):""),(e.has("exam-expand")||e.has("answer-list"))&&this._syncExamExpand(),e.has("model-value")&&this["use-model"]&&(this._title=this["model-value"])}_supportsLeastAnswerCount(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.type;return"multiple"===e||"sort"===e}_normalizeLeastAnswerCount(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;if(!this._supportsLeastAnswerCount(t)||""===e||null==e)return null;const s=Number(e);return Number.isFinite(s)&&s>0?s:null}_leastAnswerCountSuffix(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;return this._supportsLeastAnswerCount(t)&&null!==e?`,至少选${e}项${"sort"===t?"并排序":""}`:""}_normalizeAnswerItem(e){const t={...e,title:String(e?.title??e?.answer??""),isCorrect:!!e?.isCorrect},s=e?.answerId??e?.examAnswerId;return void 0!==s&&(t.answerId=s),t}_syncExternalProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this._normalizeLeastAnswerCount(this["least-answer-count"]),this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>this._normalizeAnswerItem(e)))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this._normalizeLeastAnswerCount(this["least-answer-count"]),this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>this._normalizeAnswerItem(e))),this._syncExamExpand()}_syncExamExpand(){if(!this["exam-expand"]||!this["answer-list"]?.length)return;const e=this["exam-expand"].split(","),t=this["answer-list"];this._orderList=e.map(e=>{const s=t.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return s>=0?this._label(s):""}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_searchAnswerType(){return"single"===this.type?0:"multiple"===this.type?1:5}_queueSearch(e){this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null);const t=e.trim();if(!t||!this["search-api"]&&"function"!=typeof this["search-handler"])return this._searchResults=[],this._searchOpen=!1,void(this._searchLoading=!1);this._searchTimer=window.setTimeout(()=>{this._runSearch(t)},300)}async _runSearch(e){const t=++this._searchToken;this._searchLoading=!0,this._searchOpen=!0,this.requestUpdate();try{let s=[];if("function"==typeof this["search-handler"])s=await this["search-handler"](e,this._searchAnswerType());else if(this["search-api"]){const t=new URLSearchParams({searchKey:e,answerType:String(this._searchAnswerType())}),i=await fetch(`${this["search-api"]}${this["search-api"].includes("?")?"&":"?"}${t.toString()}`);if(!i.ok)throw new Error(`HTTP ${i.status}`);const r=await i.json();s=(Array.isArray(r)?r:Array.isArray(r?.data)?r.data:[]).map(e=>({...e,value:e?.value||e?.title||""}))}if(t!==this._searchToken)return;this._searchResults=Array.isArray(s)?s:[]}catch(e){if(t!==this._searchToken)return;this._searchResults=[],d(e?.message||"题库搜索失败")}finally{t===this._searchToken&&(this._searchLoading=!1,this.requestUpdate())}}_selectSearchResult(e){const t=e.value||e.title||"";this._title=t,this._searchResults=[],this._searchOpen=!1,this["use-model"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title})),this._emit("title-select",{...e,id:e.id??e.examId??e.questionId,title:e.title||t,value:t,customId:this["custom-id"]||""})}_applyAiAnswer(){if(!this["ai-answer"]?.trim())return void d("暂无 AI 推荐答案");const e=this["ai-answer"].split(/\r?\n/).map(e=>h(e)).filter(Boolean);let t=0;if("single"===this.type){let s=!1;this._answers=this._answers.map(i=>{const r=!s&&e.includes(h(i.title||""));return r&&(s=!0,t++),{...i,isCorrect:r}})}else this._answers=this._answers.map(s=>{const i=e.includes(h(s.title||""));return i&&t++,{...s,isCorrect:i}});t?this.requestUpdate():d("未找到匹配的选项,请检查选项内容是否一致")}_onCategoryChange(e){this._categoryId=e,this._emit("category-change",{value:e,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_setRelation(e,t){const s=e.customAnswerId?{...e}:{...e,customAnswerId:e.answerId||i.uid()};this._answers=this._answers.map((e,i)=>i===t?s:e),this.requestUpdate(),this._emit("set-relation",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerIndex:t,answer:s})}_relationLength(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce((e,t)=>e+(Array.isArray(t?.relationAnswers)?t.relationAnswers.length:0),0)}_imageResources(){return(this["resource-list"]||[]).filter(e=>1===e.resourceType).map(e=>e.resource.middle||e.resource.url).filter(Boolean)}_videoResource(){return(this["resource-list"]||[]).find(e=>2===e.resourceType)?.resource||null}_openImageViewer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._imageResources().length&&(this._imageViewerIndex=e,this._imageViewerOpen=!0)}_closeImageViewer(){this._imageViewerOpen=!1}_moveImage(e){const t=this._imageResources();t.length&&(this._imageViewerIndex=(this._imageViewerIndex+e+t.length)%t.length)}_openVideoViewer(){this._videoResource()?.url&&(this._videoViewerOpen=!0)}_closeVideoViewer(){this._videoViewerOpen=!1}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){this.lockAnswerKey||(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._queueSearch(this._title),this["use-model"]&&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(e){const t=[...this._answers];t.splice(e+1,0,{title:"",isCorrect:!1,customAnswerId:i.uid()}),this._answers=t}_deleteAnswer(e){this._answers.length<3||(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}_sortAnswerValue(e){const t=e.charCodeAt(0)-65,s=this._answers[t];return s?.answerId??t+1}_rowMeta(){return{customId:this["custom-id"]||void 0,answerType:this.type,orderIndex:this["order-index"]}}_collectSnapshot(){const e=(this["is-edit"]?this._answers:this["answer-list"]||[]).map(e=>({...e,title:e?.title||"",isCorrect:!!e?.isCorrect})),t=this["is-edit"]?[...this._orderList]:(()=>{const e=this["exam-expand"];return e?e.split(",").map(e=>{const t=this["answer-list"]?.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return t>=0?this._label(t):""}).filter(Boolean):[]})();return{title:this["is-edit"]?this._title:this.title||"",answers:e,analysis:this["is-edit"]?this._analysis:this.analysis||"",leastAnswerCount:this["is-edit"]?this._leastAnswerCount:this._normalizeLeastAnswerCount(this["least-answer-count"]),selectedTagList:Array.isArray(this._selectedTagList)?[...this._selectedTagList]:[],examExpand:this["is-edit"]?t.map(e=>this._sortAnswerValue(e)).join(","):this["exam-expand"]||"",showRichText:this["is-edit"]?this._showRichText:!!this["rich-text-content"],richText:this["is-edit"]?this._richText:this["rich-text-content"]||"",orderList:t}}_validateSnapshot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;const s=this._rowMeta(),i=[];e.title||i.push(new n("题目标题不能为空!","EMPTY_TITLE","title",s));let r=!1,o=0;e.answers.forEach((e,a)=>{e.title?.trim()||i.push(new n(`选项${String.fromCharCode(65+a)}未填写`,"ANSWER_EMPTY","answers",s)),"sort"!==t&&e.isCorrect&&(r=!0,o++)});return new Set(e.answers.map(e=>e.title)).size!==e.answers.length&&e.answers.length>0&&i.push(new n("选项不能重复","DUPLICATE_ANSWERS","answers",s)),"single"===t&&o>1&&i.push(new n("此题为单选题,设置了多个推荐/正确选项,请保存时确认是否切换为多选题","SINGLE_MULTI_CORRECT","answers",s)),"multiple"===t&&(1===o&&i.push(new n("请设置至少两个推荐/正确选项","CORRECT_COUNT_INVALID","answers",s)),o>0&&(r=!0),r&&null!==e.leastAnswerCount&&o<e.leastAnswerCount&&i.push(new n("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))),"sort"===t&&(r=e.orderList.length>0,null!==e.leastAnswerCount&&e.orderList.length<e.leastAnswerCount&&i.push(new n("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","orderList",s))),{errors:i,isSetCorrectAnswer:r,correctAnswerCount:o}}_serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.type;const t=this._collectSnapshot(),{errors:s,isSetCorrectAnswer:i}=this._validateSnapshot(t,e);if(s.length)throw s[0];const r={answerType:String(e),examTypeEnum:String(e),title:t.title,answers:t.answers.map((e,t)=>{const s={...e,orderIndex:t+1,answer:e.title};return void 0!==e.answerId&&(s.examAnswerId=e.answerId),s}),examExpand:t.examExpand,analysis:t.analysis,isSetCorrectAnswer:i,examRichTextContent:t.showRichText?t.richText:""};return this._supportsLeastAnswerCount(e)&&(r.leastAnswerCount=t.leastAnswerCount),this["custom-id"]&&(r.customId=this["custom-id"]),r}_shouldShowCorrectHint(){return"sort"===this.type?!this._orderList.length:!this._answers.some(e=>!!e.isCorrect)}async toJSON(){return Promise.resolve(this._serialize())}validate(){return this._validateSnapshot(this._collectSnapshot()).errors}_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()}_renderCorrectHintDialog(){return this._correctHintDialogOpen?e.html`
|
|
2
2
|
<div class="modal-backdrop" @click=${()=>{this._correctHintDialogOpen=!1}}>
|
|
3
3
|
<div class="modal" @click=${e=>e.stopPropagation()}>
|
|
4
4
|
<div class="modal-header">
|
|
@@ -13,6 +13,22 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
16
|
+
`:""}_renderChangeTypeDialog(){return this._changeTypeDialogOpen?e.html`
|
|
17
|
+
<div class="modal-backdrop" @click=${()=>{this._changeTypeDialogOpen=!1}}>
|
|
18
|
+
<div class="modal" @click=${e=>e.stopPropagation()}>
|
|
19
|
+
<div class="modal-header">
|
|
20
|
+
<span class="modal-title">提示</span>
|
|
21
|
+
<button class="modal-close" @click=${()=>{this._changeTypeDialogOpen=!1}}>✕</button>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="modal-body">
|
|
24
|
+
<div class="value-text">此题为单选题,设置了多个推荐/正确选项,是否切换成多选题?</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="modal-footer">
|
|
27
|
+
<button @click=${()=>{this._changeTypeDialogOpen=!1}}>取消</button>
|
|
28
|
+
<button class="primary" @click=${()=>{try{const e=this._serialize("multiple");this._changeTypeDialogOpen=!1,this._emit("save",e)}catch(e){d(e?.message||"保存失败")}}}>切换</button>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
16
32
|
`:""}_renderResultDialog(){if(!this._resultDialogOpen)return"";const t=this._label(this._resultDialogIndex);return e.html`
|
|
17
33
|
<div class="modal-backdrop" @click=${()=>{this._resultDialogOpen=!1}}>
|
|
18
34
|
<div class="modal" @click=${e=>e.stopPropagation()}>
|
|
@@ -37,31 +53,12 @@
|
|
|
37
53
|
<div class="search-item" @click=${()=>this._selectSearchResult(t)}>${t.value||t.title}</div>
|
|
38
54
|
`):e.html`<div class="search-empty">暂无匹配题目</div>`}
|
|
39
55
|
</div>
|
|
40
|
-
`:""}_renderTagSection(){return this["show-tag"]?e.html`
|
|
41
|
-
<div class="flex-items-start section-row">
|
|
42
|
-
<div class="label"><span>标签:</span></div>
|
|
43
|
-
<div style="flex:1">
|
|
44
|
-
<div class="tag-list">
|
|
45
|
-
${this._selectedTagList.length?this._selectedTagList.map(t=>e.html`
|
|
46
|
-
<span class="tag-item">
|
|
47
|
-
${t.tagName}
|
|
48
|
-
${this["is-save"]?"":e.html`<span class="close" @click=${()=>this._removeTag(t.tagId)}>×</span>`}
|
|
49
|
-
</span>
|
|
50
|
-
`):e.html`<span class="tag-hint">暂无标签/关键信息</span>`}
|
|
51
|
-
</div>
|
|
52
|
-
${this["is-edit"]&&!this["is-save"]?e.html`
|
|
53
|
-
<div style="margin-top:8px">
|
|
54
|
-
<span class="el-link" @click=${()=>this._chooseTag()}>选择</span>
|
|
55
|
-
</div>
|
|
56
|
-
`:""}
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
56
|
`:""}_renderCategorySection(){return this["show-category"]?e.html`
|
|
60
57
|
<div class="flex-items-start section-row">
|
|
61
58
|
<div class="label"><span>分类:</span></div>
|
|
62
59
|
<div style="flex:1">
|
|
63
60
|
${this["is-edit"]?e.html`
|
|
64
|
-
<select class="el-select" .value=${String(this._categoryId)}
|
|
61
|
+
<select class="el-select" .value=${String(this._categoryId)}
|
|
65
62
|
@change=${e=>this._onCategoryChange(e.target.value)}>
|
|
66
63
|
<option value="">选择分类</option>
|
|
67
64
|
${this["category-list"].map(t=>e.html`
|
|
@@ -139,30 +136,20 @@
|
|
|
139
136
|
</div>
|
|
140
137
|
</div>
|
|
141
138
|
</div>
|
|
142
|
-
`:""}async _save(e){e?.stopImmediatePropagation();const t=this.validate();if(
|
|
139
|
+
`:""}async _save(e){e?.stopImmediatePropagation();const t=this.validate(),s=t.find(e=>"SINGLE_MULTI_CORRECT"===e.code),i=t.filter(e=>"SINGLE_MULTI_CORRECT"!==e.code);if(i.length)d(i[0].message);else if(s)this._changeTypeDialogOpen=!0;else if(this._hasShownCorrectHint||!this._shouldShowCorrectHint())try{const e=await this.toJSON();this._emit("save",e)}catch(e){d(e.message)}else this._correctHintDialogOpen=!0}_renderPreview(){const t="single"===this.type?"(单选题)":`(${this._titlePlaceholder}${this._leastAnswerCountSuffix(this._normalizeLeastAnswerCount(this["least-answer-count"]))})`,s=this["answer-list"];return e.html`
|
|
143
140
|
<div class="preview">
|
|
144
|
-
<div><span class="title">${this["order-index"]+1}.${this.title||""}${t}
|
|
141
|
+
<div><span class="title">${this["order-index"]+1}.${this.title||""}${t}</span></div>
|
|
145
142
|
${this["rich-text-content"]?e.html`<div class="rich-text" .innerHTML=${this["rich-text-content"]}></div>`:""}
|
|
146
143
|
<div class="preview-answer">
|
|
147
144
|
${s.map((t,s)=>e.html`
|
|
148
145
|
<label class="radio">
|
|
149
146
|
<input type="${"sort"===this.type?"checkbox":"radio"}" .checked=${!!t.isCorrect} disabled />
|
|
150
147
|
<span class="order">${this._label(s)}.</span> ${t.title}
|
|
151
|
-
${"sort"!==this.type&&t.isCorrect?e.html`<span class="correct"
|
|
152
|
-
${"sort"!==this.type&&1===this["exam-answer-relation-type"]?e.html`<span class="result-info">${t.resultItem?"(已设置结果项)":"(未设置结果项)"}</span>`:""}
|
|
153
|
-
${"sort"!==this.type&&2===this["exam-answer-relation-type"]?e.html`<span class="result-info">${t.answerRelations?.length?"(已设置关联)":"(未设置关联)"}</span>`:""}
|
|
148
|
+
${"sort"!==this.type&&t.isCorrect?e.html`<span class="correct">(推荐/正确选项)</span>`:""}
|
|
154
149
|
</label>
|
|
155
150
|
`)}
|
|
156
151
|
</div>
|
|
157
152
|
${this["show-category"]&&this._categoryId?e.html`<div class="section-row"><span class="value-text">分类:${this["category-list"].find(e=>String(e.categoryId)===String(this._categoryId))?.title||this._categoryId}</span></div>`:""}
|
|
158
|
-
${this._selectedTagList.length&&this["show-tag"]?e.html`
|
|
159
|
-
<div class="section-row">
|
|
160
|
-
<span class="value-text">标签/关键信息:</span>
|
|
161
|
-
<div class="tag-list" style="margin-top:6px">
|
|
162
|
-
${this._selectedTagList.map(t=>e.html`<span class="tag-item">${t.tagName}</span>`)}
|
|
163
|
-
</div>
|
|
164
|
-
</div>
|
|
165
|
-
`:""}
|
|
166
153
|
${this["show-resource"]?this._renderResourceSection():""}
|
|
167
154
|
</div>
|
|
168
155
|
`}_renderEdit(){return e.html`
|
|
@@ -170,7 +157,7 @@
|
|
|
170
157
|
<div class="label"><span>题目:</span></div>
|
|
171
158
|
<div style="flex:1">
|
|
172
159
|
<div class="el-input search-wrap">
|
|
173
|
-
<textarea rows="2" .value=${this._title}
|
|
160
|
+
<textarea rows="2" .value=${this._title}
|
|
174
161
|
maxlength=${this.TITLE_MAX}
|
|
175
162
|
@input=${e=>this._onTitleInput(e)}
|
|
176
163
|
placeholder="【${this._titlePlaceholder}】请输入问题"></textarea>
|
|
@@ -183,8 +170,8 @@
|
|
|
183
170
|
${["multiple","sort"].includes(this.type)?e.html`
|
|
184
171
|
<div class="flex-items-start" style="margin-top:12px">
|
|
185
172
|
<div class="label"><span>设置:</span></div>
|
|
186
|
-
<select class="el-select" .value=${this._leastAnswerCount?String(this._leastAnswerCount)
|
|
187
|
-
@change=${e=>{const t=e.target.value;this._leastAnswerCount=
|
|
173
|
+
<select class="el-select" .value=${null===this._leastAnswerCount?"":String(this._leastAnswerCount)} ?disabled=${this.lockAnswerKey}
|
|
174
|
+
@change=${e=>{const t=e.target.value;this._leastAnswerCount=this._normalizeLeastAnswerCount(t)}}>
|
|
188
175
|
<option value="">至少选择几项</option>
|
|
189
176
|
${Array.from({length:Math.max(0,this._answers.length-1)},(e,t)=>t+2).map(t=>e.html`
|
|
190
177
|
<option value=${t} ?selected=${this._leastAnswerCount===t}>至少选择${t}项</option>
|
|
@@ -198,7 +185,7 @@
|
|
|
198
185
|
<div class="answer-item">
|
|
199
186
|
<span class="label">${this._label(s)}.</span>
|
|
200
187
|
<div class="input">
|
|
201
|
-
<input type="text" .value=${t.title}
|
|
188
|
+
<input type="text" .value=${t.title}
|
|
202
189
|
maxlength=${this.ANSWER_MAX}
|
|
203
190
|
@input=${e=>this._onAnswerInput(e,s)}
|
|
204
191
|
placeholder="选项${this._label(s)}" />
|
|
@@ -209,27 +196,21 @@
|
|
|
209
196
|
|
|
210
197
|
${["single","multiple"].includes(this.type)?e.html`
|
|
211
198
|
<label class="correct ${t.isCorrect?"is-correct":""}">
|
|
212
|
-
<input type="checkbox" .checked=${t.isCorrect} ?disabled=${this
|
|
199
|
+
<input type="checkbox" .checked=${t.isCorrect} ?disabled=${this.lockAnswerKey}
|
|
213
200
|
@change=${e=>this._setCorrect(t,e.target.checked)} />
|
|
214
|
-
|
|
201
|
+
推荐/正确选项
|
|
215
202
|
</label>
|
|
216
203
|
`:""}
|
|
217
204
|
|
|
218
|
-
<span class="icon
|
|
205
|
+
<span class="icon"
|
|
219
206
|
@click=${()=>this._addAnswer(s)}>
|
|
220
207
|
${l}
|
|
221
208
|
</span>
|
|
222
|
-
<span class="icon ${this
|
|
209
|
+
<span class="icon ${this._answers.length<3?"disabled":""}"
|
|
223
210
|
@click=${()=>this._deleteAnswer(s)}>
|
|
224
211
|
${c}
|
|
225
212
|
</span>
|
|
226
213
|
|
|
227
|
-
${1===this["exam-answer-relation-type"]&&"sort"!==this.type?e.html`
|
|
228
|
-
<span class="link" @click=${()=>this._openResultDialog(s)}>${t.resultItem?"编辑结果":"添加结果"}</span>
|
|
229
|
-
`:""}
|
|
230
|
-
${2===this["exam-answer-relation-type"]&&"sort"!==this.type?e.html`
|
|
231
|
-
<span class="link" @click=${()=>this._setRelation(t,s)}>${t.answerRelations?.length?`关联了${this._relationLength(t.answerRelations)}项`:"关联检查"}</span>
|
|
232
|
-
`:""}
|
|
233
214
|
</div>
|
|
234
215
|
`)}
|
|
235
216
|
</div>
|
|
@@ -239,21 +220,21 @@
|
|
|
239
220
|
<div class="label"><span>排序答案:</span></div>
|
|
240
221
|
<div style="flex:1">
|
|
241
222
|
<div class="multi-select-wrapper">
|
|
242
|
-
<div class="multi-select ${this._sortDropdownOpen?"focused":""} ${this
|
|
243
|
-
@click=${()=>{this
|
|
223
|
+
<div class="multi-select ${this._sortDropdownOpen?"focused":""} ${this.lockAnswerKey?"disabled":""}"
|
|
224
|
+
@click=${()=>{this.lockAnswerKey||(this._sortDropdownOpen=!this._sortDropdownOpen,this.requestUpdate())}}>
|
|
244
225
|
${this._orderList.length>0?this._orderList.map(t=>e.html`
|
|
245
226
|
<span class="tag">
|
|
246
227
|
${t}
|
|
247
|
-
<span class="tag-close" @click=${e=>{e.stopPropagation(),this._removeSortItem(t)}}>✕</span>
|
|
228
|
+
<span class="tag-close" @click=${e=>{this.lockAnswerKey||(e.stopPropagation(),this._removeSortItem(t))}}>✕</span>
|
|
248
229
|
</span>
|
|
249
230
|
`):e.html`<span class="placeholder">请按顺序选择排序答案</span>`}
|
|
250
|
-
<span class="arrow">${
|
|
231
|
+
<span class="arrow">${p}</span>
|
|
251
232
|
</div>
|
|
252
233
|
${this._sortDropdownOpen?e.html`
|
|
253
234
|
<div class="multi-select-dropdown">
|
|
254
235
|
${this._answers.map((t,s)=>e.html`
|
|
255
236
|
<div class="multi-select-option ${this._orderList.includes(this._label(s))?"selected":""}"
|
|
256
|
-
@click=${()=>{this._toggleSortItem(this._label(s)),this.requestUpdate()}}>
|
|
237
|
+
@click=${()=>{this.lockAnswerKey||(this._toggleSortItem(this._label(s)),this.requestUpdate())}}>
|
|
257
238
|
${this._label(s)}
|
|
258
239
|
</div>
|
|
259
240
|
`)}
|
|
@@ -264,7 +245,7 @@
|
|
|
264
245
|
</div>
|
|
265
246
|
`:""}
|
|
266
247
|
|
|
267
|
-
|
|
248
|
+
<slot name="business-tag"></slot>
|
|
268
249
|
|
|
269
250
|
${this._renderCategorySection()}
|
|
270
251
|
|
|
@@ -297,36 +278,29 @@
|
|
|
297
278
|
</div>
|
|
298
279
|
</div>
|
|
299
280
|
`:""}
|
|
300
|
-
`}render(){return e.html`
|
|
281
|
+
`}render(){const t=this["is-edit"]?e.html`<div slot="edit">${this._renderEdit()}</div>`:e.html`<div slot="preview">${this._renderPreview()}</div>`;return e.html`
|
|
301
282
|
<qxs-subject-layout .show-edit=${this["is-edit"]}>
|
|
302
|
-
|
|
303
|
-
<div slot="edit">${this._renderEdit()}</div>
|
|
283
|
+
${t}
|
|
304
284
|
${this["show-action"]?e.html`
|
|
305
285
|
<qxs-subject-action
|
|
306
286
|
.is-edit=${this["is-edit"]}
|
|
307
287
|
.is-set=${this["is-set"]}
|
|
308
|
-
.is-key=${this._isKey}
|
|
309
288
|
.show-add=${this["show-add"]}
|
|
310
|
-
.show-answer-setting=${["single","multiple","sort"].includes(this.type)}
|
|
311
|
-
.show-key=${this["show-key"]&&["single","multiple","sort"].includes(this.type)}
|
|
312
289
|
.show-rich-text=${this._showRichText}
|
|
313
290
|
.show-jump=${this["show-jump"]}
|
|
314
|
-
answer-check-type=${this._answerCheckType}
|
|
315
|
-
exam-answer-relation-type=${this["exam-answer-relation-type"]}
|
|
316
291
|
@delete=${()=>this._emit("delete")}
|
|
317
292
|
@save=${this._save}
|
|
318
293
|
@edit=${()=>this._emit("edit")}
|
|
319
294
|
@move=${e=>this._emit("move",e.detail)}
|
|
320
295
|
@jump=${()=>this._emit("jump",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerType:this.type})}
|
|
321
296
|
@add=${e=>this._emit("add",e.detail)}
|
|
322
|
-
@set-key=${e=>{this._isKey=e.detail.value,this._emit("set-key",e.detail)}}
|
|
323
|
-
@set-answer-setting=${e=>{this._answerCheckType=e.detail.value}}
|
|
324
297
|
@on-show-rich-text=${()=>{this._showRichText=!this._showRichText,this._showRichText||(this._richText="")}}
|
|
325
298
|
></qxs-subject-action>
|
|
326
299
|
`:""}
|
|
327
300
|
</qxs-subject-layout>
|
|
328
301
|
${this._renderResultDialog()}
|
|
329
302
|
${this._renderCorrectHintDialog()}
|
|
303
|
+
${this._renderChangeTypeDialog()}
|
|
330
304
|
${this._renderImageViewer()}
|
|
331
305
|
${this._renderVideoViewer()}
|
|
332
306
|
`}},exports.QxsSubjectSingle.styles=e.css`
|
|
@@ -519,5 +493,5 @@
|
|
|
519
493
|
.modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }
|
|
520
494
|
.modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }
|
|
521
495
|
.modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }
|
|
522
|
-
`,a([t.property({type:Number,attribute:"order-index"})],exports.QxsSubjectSingle.prototype,"order-index",2),a([t.property({type:Boolean,attribute:"is-edit"})],exports.QxsSubjectSingle.prototype,"is-edit",2),a([t.property({type:Boolean,attribute:"is-save"})],exports.QxsSubjectSingle.prototype,"is-save",2),a([t.property({type:Boolean,attribute:"is-set"})],exports.QxsSubjectSingle.prototype,"is-set",2),a([t.property({type:Boolean,attribute:"is-key"})],exports.QxsSubjectSingle.prototype,"is-key",2),a([t.property({type:Boolean,attribute:"show-action"})],exports.QxsSubjectSingle.prototype,"show-action",2),a([t.property({type:Boolean,attribute:"show-add"})],exports.QxsSubjectSingle.prototype,"show-add",2),a([t.property({type:Boolean,attribute:"show-answer-setting"})],exports.QxsSubjectSingle.prototype,"show-answer-setting",2),a([t.property({type:Boolean,attribute:"show-key"})],exports.QxsSubjectSingle.prototype,"show-key",2),a([t.property({type:Boolean,attribute:"show-analysis"})],exports.QxsSubjectSingle.prototype,"show-analysis",2),a([t.property({attribute:"question-type",reflect:!0})],exports.QxsSubjectSingle.prototype,"type",2),a([t.property({type:Number,attribute:"answer-check-type"})],exports.QxsSubjectSingle.prototype,"answer-check-type",2),a([t.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsSubjectSingle.prototype,"exam-answer-relation-type",2),a([t.property({type:String,attribute:"rich-text-content"})],exports.QxsSubjectSingle.prototype,"rich-text-content",2),a([t.property({type:String})],exports.QxsSubjectSingle.prototype,"analysis",2),a([t.property({type:Number,attribute:"least-answer-count"})],exports.QxsSubjectSingle.prototype,"least-answer-count",2),a([t.property({type:String,attribute:"exam-expand"})],exports.QxsSubjectSingle.prototype,"exam-expand",2),a([t.property({type:String,attribute:"custom-id"})],exports.QxsSubjectSingle.prototype,"custom-id",2),a([t.property({type:Number,attribute:"exam-id"})],exports.QxsSubjectSingle.prototype,"exam-id",2),a([t.property({type:String,attribute:"category-id"})],exports.QxsSubjectSingle.prototype,"category-id",2),a([t.property({type:Object,attribute:"upload-image"})],exports.QxsSubjectSingle.prototype,"upload-image",2),a([t.property({type:Array,attribute:"answer-list"})],exports.QxsSubjectSingle.prototype,"answer-list",1),a([t.property({type:Array,attribute:"tag-list"})],exports.QxsSubjectSingle.prototype,"tag-list",2),a([t.property({type:Array,attribute:"category-list"})],exports.QxsSubjectSingle.prototype,"category-list",2),a([t.property({type:String,attribute:"ai-answer"})],exports.QxsSubjectSingle.prototype,"ai-answer",2),a([t.property({type:Array,attribute:"resource-list"})],exports.QxsSubjectSingle.prototype,"resource-list",2),a([t.property({type:Boolean,attribute:"show-tag"})],exports.QxsSubjectSingle.prototype,"show-tag",2),a([t.property({type:Boolean,attribute:"show-category"})],exports.QxsSubjectSingle.prototype,"show-category",2),a([t.property({type:Boolean,attribute:"show-ai"})],exports.QxsSubjectSingle.prototype,"show-ai",2),a([t.property({type:Boolean,attribute:"show-resource"})],exports.QxsSubjectSingle.prototype,"show-resource",2),a([t.property({type:Boolean,attribute:"show-jump"})],exports.QxsSubjectSingle.prototype,"show-jump",2),a([t.property({type:Boolean,attribute:"has-jump"})],exports.QxsSubjectSingle.prototype,"has-jump",2),a([t.property({type:String,attribute:"search-api"})],exports.QxsSubjectSingle.prototype,"search-api",2),a([t.property({type:Object,attribute:"search-handler"})],exports.QxsSubjectSingle.prototype,"search-handler",2),a([t.property({type:String,attribute:"model-value"})],exports.QxsSubjectSingle.prototype,"model-value",2),a([t.property({type:Boolean,attribute:"use-model"})],exports.QxsSubjectSingle.prototype,"use-model",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_answers",2),a([t.property({type:String})],exports.QxsSubjectSingle.prototype,"title",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_title",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_analysis",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_richText",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_showRichText",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_leastAnswerCount",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_answerCheckType",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_isKey",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_orderList",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_selectedTagList",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_categoryId",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_searchResults",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_searchOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_searchLoading",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_resultDialogOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_resultDialogIndex",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_resultDialogValue",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_sortDropdownOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_imageViewerOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_imageViewerIndex",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_videoViewerOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_correctHintDialogOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_hasShownCorrectHint",2),exports.QxsSubjectSingle=a([s.safeCustomElement("qxs-subject-single")],exports.QxsSubjectSingle),exports.SubjectError=n;
|
|
496
|
+
`,a([t.property({type:Number,attribute:"order-index"})],exports.QxsSubjectSingle.prototype,"order-index",2),a([t.property({type:Boolean,attribute:"is-edit"})],exports.QxsSubjectSingle.prototype,"is-edit",2),a([t.property({type:Boolean,attribute:"is-save"})],exports.QxsSubjectSingle.prototype,"is-save",2),a([t.property({type:Boolean,attribute:"is-set"})],exports.QxsSubjectSingle.prototype,"is-set",2),a([t.property({type:Boolean,attribute:"is-set-correct-answer"})],exports.QxsSubjectSingle.prototype,"is-set-correct-answer",2),a([t.property({type:Boolean,attribute:"lock-answer-key"})],exports.QxsSubjectSingle.prototype,"lockAnswerKey",2),a([t.property({type:Boolean,attribute:"is-key"})],exports.QxsSubjectSingle.prototype,"is-key",2),a([t.property({type:Boolean,attribute:"show-action"})],exports.QxsSubjectSingle.prototype,"show-action",2),a([t.property({type:Boolean,attribute:"show-add"})],exports.QxsSubjectSingle.prototype,"show-add",2),a([t.property({type:Boolean,attribute:"show-answer-setting"})],exports.QxsSubjectSingle.prototype,"show-answer-setting",2),a([t.property({type:Boolean,attribute:"show-key"})],exports.QxsSubjectSingle.prototype,"show-key",2),a([t.property({type:Boolean,attribute:"show-analysis"})],exports.QxsSubjectSingle.prototype,"show-analysis",2),a([t.property({attribute:"question-type",reflect:!0})],exports.QxsSubjectSingle.prototype,"type",2),a([t.property({type:Number,attribute:"answer-check-type"})],exports.QxsSubjectSingle.prototype,"answer-check-type",2),a([t.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsSubjectSingle.prototype,"exam-answer-relation-type",2),a([t.property({type:String,attribute:"rich-text-content"})],exports.QxsSubjectSingle.prototype,"rich-text-content",2),a([t.property({type:String})],exports.QxsSubjectSingle.prototype,"analysis",2),a([t.property({type:Number,attribute:"least-answer-count"})],exports.QxsSubjectSingle.prototype,"least-answer-count",2),a([t.property({type:String,attribute:"exam-expand"})],exports.QxsSubjectSingle.prototype,"exam-expand",2),a([t.property({type:String,attribute:"custom-id"})],exports.QxsSubjectSingle.prototype,"custom-id",2),a([t.property({type:Number,attribute:"exam-id"})],exports.QxsSubjectSingle.prototype,"exam-id",2),a([t.property({type:String,attribute:"category-id"})],exports.QxsSubjectSingle.prototype,"category-id",2),a([t.property({type:Object,attribute:"upload-image"})],exports.QxsSubjectSingle.prototype,"upload-image",2),a([t.property({type:Array,attribute:"answer-list"})],exports.QxsSubjectSingle.prototype,"answer-list",1),a([t.property({type:Array,attribute:"tag-list"})],exports.QxsSubjectSingle.prototype,"tag-list",2),a([t.property({type:Array,attribute:"category-list"})],exports.QxsSubjectSingle.prototype,"category-list",2),a([t.property({type:String,attribute:"ai-answer"})],exports.QxsSubjectSingle.prototype,"ai-answer",2),a([t.property({type:Array,attribute:"resource-list"})],exports.QxsSubjectSingle.prototype,"resource-list",2),a([t.property({type:Boolean,attribute:"show-tag"})],exports.QxsSubjectSingle.prototype,"show-tag",2),a([t.property({type:Boolean,attribute:"show-category"})],exports.QxsSubjectSingle.prototype,"show-category",2),a([t.property({type:Boolean,attribute:"show-ai"})],exports.QxsSubjectSingle.prototype,"show-ai",2),a([t.property({type:Boolean,attribute:"show-resource"})],exports.QxsSubjectSingle.prototype,"show-resource",2),a([t.property({type:Boolean,attribute:"show-jump"})],exports.QxsSubjectSingle.prototype,"show-jump",2),a([t.property({type:Boolean,attribute:"has-jump"})],exports.QxsSubjectSingle.prototype,"has-jump",2),a([t.property({type:String,attribute:"search-api"})],exports.QxsSubjectSingle.prototype,"search-api",2),a([t.property({type:Object,attribute:"search-handler"})],exports.QxsSubjectSingle.prototype,"search-handler",2),a([t.property({type:String,attribute:"model-value"})],exports.QxsSubjectSingle.prototype,"model-value",2),a([t.property({type:Boolean,attribute:"use-model"})],exports.QxsSubjectSingle.prototype,"use-model",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_answers",2),a([t.property({type:String})],exports.QxsSubjectSingle.prototype,"title",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_title",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_analysis",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_richText",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_showRichText",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_leastAnswerCount",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_answerCheckType",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_isKey",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_orderList",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_selectedTagList",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_categoryId",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_searchResults",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_searchOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_searchLoading",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_resultDialogOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_resultDialogIndex",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_resultDialogValue",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_sortDropdownOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_imageViewerOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_imageViewerIndex",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_videoViewerOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_correctHintDialogOpen",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_hasShownCorrectHint",2),a([t.state()],exports.QxsSubjectSingle.prototype,"_changeTypeDialogOpen",2),exports.QxsSubjectSingle=a([s.safeCustomElement("qxs-subject-single")],exports.QxsSubjectSingle),exports.SubjectError=n;
|
|
523
497
|
//# sourceMappingURL=single.cjs.map
|