@qxs-bns/components-wc 0.0.33 → 0.0.34
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/scale.mjs +9 -6
- package/es/subject/scale.mjs.map +1 -1
- package/es/subject/single.mjs +18 -5
- package/es/subject/single.mjs.map +1 -1
- package/lib/subject/scale.cjs +6 -3
- package/lib/subject/scale.cjs.map +1 -1
- package/lib/subject/single.cjs +17 -4
- package/lib/subject/single.cjs.map +1 -1
- package/package.json +1 -1
package/es/subject/scale.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{html as t,css as e,LitElement as i}from"lit";import{property as s,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{SUB_TEXT_EDITOR_TOOLBAR as a}from"../editor/toolbar.mjs";import{emitSubjectEvent as n,emitSubjectModelValue as l,showSubjectToast as d,buildSubjectPreviewTitle as h,buildSubjectSortingTitle as c}from"./shared-methods.mjs";import{subjectHostStyles as p,subjectControlResetStyles as u,subjectPreviewBaseStyles as w,subjectFormBaseStyles as x,subjectTextareaStyles as
|
|
1
|
+
import{html as t,css as e,LitElement as i}from"lit";import{property as s,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{SUB_TEXT_EDITOR_TOOLBAR as a}from"../editor/toolbar.mjs";import{emitSubjectEvent as n,emitSubjectModelValue as l,showSubjectToast as d,buildSubjectPreviewTitle as h,buildSubjectSortingTitle as c}from"./shared-methods.mjs";import{subjectHostStyles as p,subjectControlResetStyles as u,subjectPreviewBaseStyles as w,subjectFormBaseStyles as x,subjectTextareaStyles as y}from"./shared-styles.mjs";import{SubjectError as m,trimText as v}from"./single.mjs";import{sortingCardStyles as b,renderSortingCard as f}from"./sorting-card.mjs";import{SubjectType as g,SubjectTypeLabel as _}from"./types.mjs";var T=Object.defineProperty,$=Object.getOwnPropertyDescriptor,A=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?$(e,i):e,a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&T(e,i,o),o};function E(){return{title:""}}function I(){return Array.from({length:5},E)}function j(t){const e={...t,title:v(t?.title??t?.answer??"")},i=t?.answerId??t?.examAnswerId;return void 0!==i&&(e.answerId=i),delete e.answer,delete e.examAnswerId,delete e.isCorrect,e}function S(t,e){const i={...j(t),orderIndex:e+1,answer:v(t?.title??t?.answer??"")};return i.title=v(i.title??""),void 0!==i.answerId&&(i.examAnswerId=i.answerId),void 0===i.answerId&&delete i.answerId,delete i.isCorrect,i}const q=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,C=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;let k=class extends i{constructor(){super(...arguments),this["order-index"]=0,this.title="",this["custom-id"]="",this["is-edit"]=!1,this["is-save"]=!1,this["is-set"]=!1,this["show-action"]=!0,this["show-add"]=!0,this["hide-add-rich-text"]=!1,this["show-rich-text"]=!1,this["show-delete-action"]=!0,this["show-save-action"]=!0,this.sorting=!1,this["show-analysis"]=!1,this.analysis="",this["rich-text-content"]="",this["exam-answer-relation-type"]=0,this["upload-image"]=async t=>new Promise((e,i)=>{const s=new FileReader;s.onload=t=>e(t.target?.result),s.onerror=i,s.readAsDataURL(t)}),this._answers=I(),this._scaleQuestions=[],this._rowTitle="",this._title="",this._analysis="",this._showRichText=!1,this._richText="",this["model-value"]="",this["use-model"]=!1,this.TITLE_MAX=200}get"answer-list"(){return this._answers}set"answer-list"(t){const e=function(t){return Array.isArray(t)?t.map(j):[]}(t);this._answers=e.length?e:I(),this.requestUpdate("answer-list")}get"scale-question-list"(){return this._scaleQuestions}set"scale-question-list"(t){this._scaleQuestions=function(t){return Array.isArray(t)?t.map(t=>String(t??"").trim()).filter(Boolean):[]}(t),this.requestUpdate("scale-question-list")}get"scale-questions"(){return this._scaleQuestions}set"scale-questions"(t){this["scale-question-list"]=t,this.requestUpdate("scale-questions")}willUpdate(t){const e=t.has("title")||t.has("answer-list")||t.has("rich-text-content")||t.has("scale-question-list")||t.has("scale-questions");(t.has("is-edit")&&this["is-edit"]||!this["is-edit"]&&e)&&this._syncProps(),t.has("model-value")&&this["use-model"]&&(this._title=this["model-value"])}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._rowTitle=this._scaleQuestions.join("\n"),this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"]}_emit(t,e){n(this,t,e)}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value,this["use-model"]&&l(this,this._title)}_resolvedQuestions(){const t=this["is-edit"]?this._rowTitle:this._scaleQuestions.join("\n");return t.split("\n").map(t=>t.trim()).filter(Boolean)}_resolvedAnswers(){const t=this["is-edit"]?this._answers:this["answer-list"];return Array.isArray(t)?t.map(j):[]}_createAnswerCountError(t){return new m("量表题选项数量必须在 3-5 个之间!","ANSWER_COUNT_INVALID","answers",t)}async toJSON(){return new Promise((t,e)=>{const i={customId:this["custom-id"]||void 0,answerType:g.SCALE,orderIndex:this["order-index"]},s=v(this["is-edit"]?this._title:this.title||""),r=this._resolvedAnswers(),o=this._resolvedQuestions(),a=this["is-edit"]?this._richText:this["rich-text-content"]||"",n=this["show-rich-text"]&&(this["is-edit"]?this._showRichText:!!this["rich-text-content"]);if(!s)return void e(new m("题目标题不能为空!","EMPTY_TITLE","title",i));if(r.length<3||r.length>5)return void e(this._createAnswerCountError(i));for(let t=0;t<r.length;t++)if(!r[t].title)return void e(new m(`选项${String.fromCharCode(65+t)}未填写。`,"ANSWER_EMPTY","answers",i));if(0===o.length)return void e(new m("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",i));const l={answerType:g.SCALE,examTypeEnum:g.SCALE,title:s,answers:r.map(S),scaleQuestionList:o,analysis:v(this["is-edit"]?this._analysis:this.analysis||""),examRichTextContent:n?a:"",isSetCorrectAnswer:!1};this["custom-id"]&&(l.customId=this["custom-id"]),this["exam-answer-relation-type"]&&(l.examAnswerRelationType=this["exam-answer-relation-type"]),t(l)})}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){d(t.message)}}validate(){const t=[],e={customId:this["custom-id"]||void 0,answerType:g.SCALE,orderIndex:this["order-index"]},i=v(this["is-edit"]?this._title:this.title||""),s=this._resolvedAnswers(),r=this._resolvedQuestions();return i||t.push(new m("题目标题不能为空!","EMPTY_TITLE","title",e)),s.length<3||s.length>5?(t.push(this._createAnswerCountError(e)),t):(s.forEach((i,s)=>{i.title||t.push(new m(`选项${String.fromCharCode(65+s)}未填写`,"ANSWER_EMPTY","answers",e))}),0===r.length&&t.push(new m("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e)),t)}_renderPreview(){const e=this._resolvedAnswers(),i=this._resolvedQuestions(),s=Math.floor(100/((e.length||1)+1)),r=h(this["subject-prefix"],this["order-index"],this.title);return t`
|
|
2
2
|
<div class="preview">
|
|
3
3
|
<div class="preview-header">
|
|
4
4
|
<div class="preview-title-row">
|
|
@@ -134,7 +134,7 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
134
134
|
</div>
|
|
135
135
|
`:""}
|
|
136
136
|
</div>
|
|
137
|
-
`}_renderSorting(){const t=v(this["is-edit"]?this._title:this.title||"")||"未命名题目",e=c(this["subject-prefix"],this["order-index"],t);return
|
|
137
|
+
`}_renderSorting(){const t=v(this["is-edit"]?this._title:this.title||"")||"未命名题目",e=c(this["subject-prefix"],this["order-index"],t);return f(e,_[g.SCALE]||g.SCALE)}render(){if(this.sorting)return this._renderSorting();const e=this["is-edit"]?t`<div slot="edit">${this._renderEdit()}</div>`:t`<div slot="preview">${this._renderPreview()}</div>`;return t`
|
|
138
138
|
<qxs-subject-layout .show-edit=${this["is-edit"]}>
|
|
139
139
|
${e}
|
|
140
140
|
${this["show-action"]?t`
|
|
@@ -157,7 +157,7 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
157
157
|
`:""}
|
|
158
158
|
<slot name="action"></slot>
|
|
159
159
|
</qxs-subject-layout>
|
|
160
|
-
`}};k.styles=[
|
|
160
|
+
`}};k.styles=[b,p,u,w,x,y,e`
|
|
161
161
|
.scale-table-wrap {
|
|
162
162
|
margin-top: 18px;
|
|
163
163
|
border: 1px solid #e5e7eb;
|
|
@@ -168,14 +168,17 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
168
168
|
.scale-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; color: #4b5563; }
|
|
169
169
|
.scale-table th, .scale-table td { border-bottom: 1px solid #eef2f7; padding: 10px 8px; text-align: center; vertical-align: middle; }
|
|
170
170
|
.scale-table thead th { font-size: 12px; font-weight: 600; color: #8b95a7; background: #f8fafc; }
|
|
171
|
+
.scale-table thead th:first-child,
|
|
172
|
+
.scale-table tbody td:first-child {
|
|
173
|
+
color: #303133;
|
|
174
|
+
text-align: left;
|
|
175
|
+
font-weight: 600;
|
|
176
|
+
}
|
|
171
177
|
.scale-table thead th:first-child {
|
|
172
178
|
background: #f3f4f6;
|
|
173
179
|
}
|
|
174
180
|
.scale-table tbody td:first-child {
|
|
175
181
|
background: #fafafa;
|
|
176
|
-
color: #303133;
|
|
177
|
-
text-align: left;
|
|
178
|
-
font-weight: 600;
|
|
179
182
|
}
|
|
180
183
|
.scale-table tbody tr:last-child td { border-bottom: none; }
|
|
181
184
|
.scale-table input[type="radio"] {
|
package/es/subject/scale.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale.mjs","sources":["../../../../packages/components-wc/src/subject/scale.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\nimport { SUB_TEXT_EDITOR_TOOLBAR } from '../editor/toolbar'\nimport { buildSubjectPreviewTitle, buildSubjectSortingTitle, emitSubjectEvent, emitSubjectModelValue, showSubjectToast } from './shared-methods'\nimport { subjectControlResetStyles, subjectFormBaseStyles, subjectHostStyles, subjectPreviewBaseStyles, subjectTextareaStyles } from './shared-styles'\nimport { SubjectError, trimText } from './single'\nimport { renderSortingCard, sortingCardStyles } from './sorting-card'\nimport { SubjectType, SubjectTypeLabel } 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: trimText(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 delete next.isCorrect\n return next\n}\n\nfunction normalizeScaleAnswers(value: any): ScaleAnswer[] {\n return Array.isArray(value) ? value.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: trimText(answer?.title ?? answer?.answer ?? ''),\n }\n next.title = trimText(next.title ?? '')\n if (next.answerId !== undefined) {\n next.examAnswerId = next.answerId\n }\n if (next.answerId === undefined) {\n delete next.answerId\n }\n delete next.isCorrect\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\n@safeCustomElement('qxs-scale')\nexport class QxsScale extends LitElement {\n static styles = [sortingCardStyles, subjectHostStyles, subjectControlResetStyles, subjectPreviewBaseStyles, subjectFormBaseStyles, subjectTextareaStyles, css`\n .scale-table-wrap {\n margin-top: 18px;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n background: #fff;\n overflow: hidden;\n }\n .scale-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; color: #4b5563; }\n .scale-table th, .scale-table td { border-bottom: 1px solid #eef2f7; padding: 10px 8px; text-align: center; vertical-align: middle; }\n .scale-table thead th { font-size: 12px; font-weight: 600; color: #8b95a7; background: #f8fafc; }\n .scale-table thead th:first-child {\n background: #f3f4f6;\n }\n .scale-table tbody td:first-child {\n background: #fafafa;\n color: #303133;\n text-align: left;\n font-weight: 600;\n }\n .scale-table tbody tr:last-child td { border-bottom: none; }\n .scale-table input[type=\"radio\"] {\n accent-color: #3D61E3;\n }\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 .edit-grid {\n display: grid;\n grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);\n gap: 20px;\n }\n .edit-column {\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .edit-column-title {\n font-size: 12px;\n line-height: 1.4;\n font-weight: 600;\n color: #8b95a7;\n letter-spacing: 0.02em;\n }\n .edit-note {\n font-size: 12px;\n line-height: 1.6;\n color: #909399;\n }\n\n textarea, input[type=\"text\"] { white-space: pre-wrap; }\n input[type=\"text\"] {\n border: 1px solid #dcdfe6; border-radius: 6px; padding: 7px 11px;\n font-size: 13px; font-family: inherit; width: 100%; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box;\n }\n input[type=\"text\"]:focus { border-color: #3D61E3; outline: none; }\n input[type=\"text\"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\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; gap: 8px; }\n .answer-item .label { min-width: 28px; font-size: 13px; font-weight: 600; color: #6b7280; letter-spacing: 0; }\n .answer-item .input { flex: 1; max-width: 220px; }\n .answer-item .input input {\n height: 36px; padding: 0 10px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 6px; 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 { min-height: 220px; }\n\n @media (max-width: 720px) {\n .edit-row {\n flex-direction: column;\n gap: 8px;\n }\n\n .edit-row > .label {\n min-width: 0;\n padding-top: 0;\n }\n\n .edit-grid {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n }\n `]\n\n @property({ type: Number, attribute: 'order-index' }) 'order-index' = 0\n @property({ type: String, attribute: 'subject-prefix' }) 'subject-prefix'?: string\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: 'hide-add-rich-text' }) 'hide-add-rich-text' = false\n @property({ type: Boolean, attribute: 'show-rich-text' }) 'show-rich-text' = false\n @property({ type: Boolean, attribute: 'show-delete-action' }) 'show-delete-action' = true\n @property({ type: Boolean, attribute: 'show-save-action' }) 'show-save-action' = true\n @property({ type: Boolean, reflect: true }) sorting = false\n @property({ type: Boolean, attribute: 'show-analysis' }) 'show-analysis' = false\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 const answers = normalizeScaleAnswers(value)\n this._answers = answers.length ? answers : 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 _analysis = ''\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._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 }\n\n private _emit(name: string, detail?: unknown) {\n emitSubjectEvent(this, name, detail)\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 emitSubjectModelValue(this, this._title)\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 private _resolvedAnswers(): ScaleAnswer[] {\n const answers = this['is-edit'] ? this._answers : this['answer-list']\n return Array.isArray(answers) ? answers.map(normalizeScaleAnswer) : []\n }\n\n private _createAnswerCountError(row: Record<string, unknown>) {\n return new SubjectError('量表题选项数量必须在 3-5 个之间!', 'ANSWER_COUNT_INVALID', 'answers', row)\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 = trimText(this['is-edit'] ? this._title : this.title || '')\n const answers = this._resolvedAnswers()\n const questions = this._resolvedQuestions()\n const richText = this['is-edit'] ? this._richText : this['rich-text-content'] || ''\n const showRichText = this['show-rich-text'] && (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 if (answers.length < 3 || answers.length > 5) {\n reject(this._createAnswerCountError(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: trimText(this['is-edit'] ? this._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 if (this['exam-answer-relation-type']) {\n result.examAnswerRelationType = this['exam-answer-relation-type']\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 showSubjectToast(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 = trimText(this['is-edit'] ? this._title : this.title || '')\n const answers = this._resolvedAnswers()\n const questions = this._resolvedQuestions()\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n if (answers.length < 3 || answers.length > 5) {\n errors.push(this._createAnswerCountError(row))\n return errors\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 answers = this._resolvedAnswers()\n const questions = this._resolvedQuestions()\n const colWidth = Math.floor(100 / ((answers.length || 1) + 1))\n const previewTitle = buildSubjectPreviewTitle(this['subject-prefix'], this['order-index'], this.title)\n\n return html`\n <div class=\"preview\">\n <div class=\"preview-header\">\n <div class=\"preview-title-row\">\n <span class=\"title\">${previewTitle}</span>\n <span class=\"preview-type\">量表题</span>\n </div>\n ${this['show-rich-text'] && this['rich-text-content'] ? html`<div class=\"rich-text\" .innerHTML=${this['rich-text-content']}></div>` : ''}\n </div>\n <div class=\"scale-table-wrap\">\n <table class=\"scale-table\">\n <thead>\n <tr>\n <th style=\"width:${colWidth}%\">问题</th>\n ${answers.map(answer => html`<th style=\"width:${colWidth}%\">${answer.title}</th>`)}\n </tr>\n </thead>\n <tbody>\n ${questions.map(question => html`\n <tr>\n <td>${question}</td>\n ${answers.map(() => html`<td><input type=\"radio\" disabled /></td>`)}\n </tr>\n `)}\n </tbody>\n </table>\n </div>\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"edit-form\">\n <div class=\"edit-row\">\n <div class=\"label\"><span>题目:</span></div>\n <div class=\"row-body\">\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=\"edit-row\">\n <div class=\"label\"><span>量表内容:</span></div>\n <div class=\"row-body\">\n <div class=\"edit-grid\">\n <div class=\"edit-column\">\n <div class=\"edit-column-title\">行标题</div>\n <div class=\"el-input\">\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 class=\"edit-note\">一行一个标题,预览时会自动整理空白行。</div>\n </div>\n <div class=\"edit-column\">\n <div class=\"edit-column-title\">评分选项</div>\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 class=\"edit-note\">量表题需保持 3-5 个选项,保存时会校验。</div>\n </div>\n </div>\n </div>\n </div>\n\n ${this['show-rich-text'] && this._showRichText\n ? html`\n <div class=\"edit-row\">\n <div class=\"label\"><span>副文本:</span></div>\n <div class=\"row-body\">\n <slot name=\"sub-text\">\n <qxs-blocksuite-editor\n .content=${this._richText}\n .toolbar=${SUB_TEXT_EDITOR_TOOLBAR}\n .upload-image=${this['upload-image']}\n ?is-edit=${true}\n @input=${(e: CustomEvent) => { this._richText = (e.target as any).getContent() }}\n ></qxs-blocksuite-editor>\n </slot>\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 ${this['show-analysis']\n ? html`\n <div class=\"edit-row\">\n <div class=\"label\"><span>解析:</span></div>\n <div class=\"row-body\">\n <div class=\"el-input\">\n <textarea\n rows=\"2\"\n .value=${this._analysis}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"\n ></textarea>\n </div>\n </div>\n </div>\n `\n : ''}\n </div>\n `\n }\n\n private _renderSorting() {\n const title = trimText(this['is-edit'] ? this._title : this.title || '') || '未命名题目'\n const orderText = buildSubjectSortingTitle(this['subject-prefix'], this['order-index'], title)\n return renderSortingCard(orderText, SubjectTypeLabel[SubjectType.SCALE] || SubjectType.SCALE)\n }\n\n render() {\n if (this.sorting) {\n return this._renderSorting()\n }\n\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['show-rich-text'] && this._showRichText}\n .hide-add-rich-text=${!this['show-rich-text'] || this['hide-add-rich-text']}\n .show-delete-action=${this['show-delete-action']}\n .show-save-action=${this['show-save-action']}\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 <slot name=\"action\"></slot>\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["createEmptyScaleAnswer","title","createDefaultScaleAnswers","Array","from","length","normalizeScaleAnswer","answer","next","trimText","answerId","examAnswerId","isCorrect","serializeScaleAnswer","index","orderIndex","iconPlus","html","iconRemove","QxsScale","LitElement","constructor","super","arguments","this","sorting","analysis","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_analysis","_showRichText","_richText","TITLE_MAX","value","answers","isArray","map","normalizeScaleAnswers","requestUpdate","item","String","trim","filter","Boolean","normalizeScaleQuestionList","willUpdate","changed","shouldSyncProps","has","_syncProps","join","_emit","name","detail","emitSubjectEvent","_onTitleInput","el","slice","emitSubjectModelValue","_resolvedQuestions","rowTitle","split","_resolvedAnswers","_createAnswerCountError","row","SubjectError","toJSON","customId","answerType","SubjectType","SCALE","questions","richText","showRichText","i","fromCharCode","examTypeEnum","scaleQuestionList","examRichTextContent","isSetCorrectAnswer","examAnswerRelationType","_save","stopImmediatePropagation","data","err","showSubjectToast","message","validate","errors","push","forEach","_renderPreview","colWidth","Math","floor","previewTitle","buildSubjectPreviewTitle","question","_renderEdit","stopPropagation","currentIndex","_","SUB_TEXT_EDITOR_TOOLBAR","getContent","_renderSorting","orderText","buildSubjectSortingTitle","renderSortingCard","SubjectTypeLabel","render","content","styles","sortingCardStyles","subjectHostStyles","subjectControlResetStyles","subjectPreviewBaseStyles","subjectFormBaseStyles","subjectTextareaStyles","css","__decorateClass","property","type","Number","attribute","prototype","reflect","Object","state","safeCustomElement"],"mappings":"27BAkBA,SAASA,IACP,MAAO,CAAEC,MAAO,GAClB,CAEA,SAASC,IACP,OAAOC,MAAMC,KAAK,CAAEC,OAAQ,GAAKL,EACnC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AAA,GAQAL,EAAA,CADHC,EAAS,CAAEC,KAAMrI,MAAOuI,UAAW,qBAvJzBvH,EAwJPwH,UAAA,kBAAA,GAOaL,EAAA,CAAhBQ,KA/JU3H,EA+JMwH,UAAA,WAAA,GACAL,EAAA,CAAhBQ,KAhKU3H,EAgKMwH,UAAA,kBAAA,GACAL,EAAA,CAAhBQ,KAjKU3H,EAiKMwH,UAAA,YAAA,GACAL,EAAA,CAAhBQ,KAlKU3H,EAkKMwH,UAAA,SAAA,GACAL,EAAA,CAAhBQ,KAnKU3H,EAmKMwH,UAAA,YAAA,GACAL,EAAA,CAAhBQ,KApKU3H,EAoKMwH,UAAA,gBAAA,GACAL,EAAA,CAAhBQ,KArKU3H,EAqKMwH,UAAA,YAAA,GAEqCL,EAAA,CAArDC,EAAS,CAAEC,KAAMjF,OAAQmF,UAAW,iBAvK1BvH,EAuK2CwH,UAAA,cAAA,GACDL,EAAA,CAApDC,EAAS,CAAEC,KAAM9E,QAASgF,UAAW,eAxK3BvH,EAwK0CwH,UAAA,YAAA,GAxK1CxH,EAANmH,EAAA,CADNS,EAAkB,cACN5H"}
|
|
1
|
+
{"version":3,"file":"scale.mjs","sources":["../../../../packages/components-wc/src/subject/scale.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\nimport { SUB_TEXT_EDITOR_TOOLBAR } from '../editor/toolbar'\nimport { buildSubjectPreviewTitle, buildSubjectSortingTitle, emitSubjectEvent, emitSubjectModelValue, showSubjectToast } from './shared-methods'\nimport { subjectControlResetStyles, subjectFormBaseStyles, subjectHostStyles, subjectPreviewBaseStyles, subjectTextareaStyles } from './shared-styles'\nimport { SubjectError, trimText } from './single'\nimport { renderSortingCard, sortingCardStyles } from './sorting-card'\nimport { SubjectType, SubjectTypeLabel } 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: trimText(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 delete next.isCorrect\n return next\n}\n\nfunction normalizeScaleAnswers(value: any): ScaleAnswer[] {\n return Array.isArray(value) ? value.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: trimText(answer?.title ?? answer?.answer ?? ''),\n }\n next.title = trimText(next.title ?? '')\n if (next.answerId !== undefined) {\n next.examAnswerId = next.answerId\n }\n if (next.answerId === undefined) {\n delete next.answerId\n }\n delete next.isCorrect\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\n@safeCustomElement('qxs-scale')\nexport class QxsScale extends LitElement {\n static styles = [sortingCardStyles, subjectHostStyles, subjectControlResetStyles, subjectPreviewBaseStyles, subjectFormBaseStyles, subjectTextareaStyles, css`\n .scale-table-wrap {\n margin-top: 18px;\n border: 1px solid #e5e7eb;\n border-radius: 12px;\n background: #fff;\n overflow: hidden;\n }\n .scale-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; color: #4b5563; }\n .scale-table th, .scale-table td { border-bottom: 1px solid #eef2f7; padding: 10px 8px; text-align: center; vertical-align: middle; }\n .scale-table thead th { font-size: 12px; font-weight: 600; color: #8b95a7; background: #f8fafc; }\n .scale-table thead th:first-child,\n .scale-table tbody td:first-child {\n color: #303133;\n text-align: left;\n font-weight: 600;\n }\n .scale-table thead th:first-child {\n background: #f3f4f6;\n }\n .scale-table tbody td:first-child {\n background: #fafafa;\n }\n .scale-table tbody tr:last-child td { border-bottom: none; }\n .scale-table input[type=\"radio\"] {\n accent-color: #3D61E3;\n }\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 .edit-grid {\n display: grid;\n grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);\n gap: 20px;\n }\n .edit-column {\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n .edit-column-title {\n font-size: 12px;\n line-height: 1.4;\n font-weight: 600;\n color: #8b95a7;\n letter-spacing: 0.02em;\n }\n .edit-note {\n font-size: 12px;\n line-height: 1.6;\n color: #909399;\n }\n\n textarea, input[type=\"text\"] { white-space: pre-wrap; }\n input[type=\"text\"] {\n border: 1px solid #dcdfe6; border-radius: 6px; padding: 7px 11px;\n font-size: 13px; font-family: inherit; width: 100%; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box;\n }\n input[type=\"text\"]:focus { border-color: #3D61E3; outline: none; }\n input[type=\"text\"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\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; gap: 8px; }\n .answer-item .label { min-width: 28px; font-size: 13px; font-weight: 600; color: #6b7280; letter-spacing: 0; }\n .answer-item .input { flex: 1; max-width: 220px; }\n .answer-item .input input {\n height: 36px; padding: 0 10px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 6px; 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 { min-height: 220px; }\n\n @media (max-width: 720px) {\n .edit-row {\n flex-direction: column;\n gap: 8px;\n }\n\n .edit-row > .label {\n min-width: 0;\n padding-top: 0;\n }\n\n .edit-grid {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n }\n `]\n\n @property({ type: Number, attribute: 'order-index' }) 'order-index' = 0\n @property({ type: String, attribute: 'subject-prefix' }) 'subject-prefix'?: string\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: 'hide-add-rich-text' }) 'hide-add-rich-text' = false\n @property({ type: Boolean, attribute: 'show-rich-text' }) 'show-rich-text' = false\n @property({ type: Boolean, attribute: 'show-delete-action' }) 'show-delete-action' = true\n @property({ type: Boolean, attribute: 'show-save-action' }) 'show-save-action' = true\n @property({ type: Boolean, reflect: true }) sorting = false\n @property({ type: Boolean, attribute: 'show-analysis' }) 'show-analysis' = false\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 const answers = normalizeScaleAnswers(value)\n this._answers = answers.length ? answers : 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 _analysis = ''\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._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 }\n\n private _emit(name: string, detail?: unknown) {\n emitSubjectEvent(this, name, detail)\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 emitSubjectModelValue(this, this._title)\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 private _resolvedAnswers(): ScaleAnswer[] {\n const answers = this['is-edit'] ? this._answers : this['answer-list']\n return Array.isArray(answers) ? answers.map(normalizeScaleAnswer) : []\n }\n\n private _createAnswerCountError(row: Record<string, unknown>) {\n return new SubjectError('量表题选项数量必须在 3-5 个之间!', 'ANSWER_COUNT_INVALID', 'answers', row)\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 = trimText(this['is-edit'] ? this._title : this.title || '')\n const answers = this._resolvedAnswers()\n const questions = this._resolvedQuestions()\n const richText = this['is-edit'] ? this._richText : this['rich-text-content'] || ''\n const showRichText = this['show-rich-text'] && (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 if (answers.length < 3 || answers.length > 5) {\n reject(this._createAnswerCountError(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: trimText(this['is-edit'] ? this._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 if (this['exam-answer-relation-type']) {\n result.examAnswerRelationType = this['exam-answer-relation-type']\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 showSubjectToast(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 = trimText(this['is-edit'] ? this._title : this.title || '')\n const answers = this._resolvedAnswers()\n const questions = this._resolvedQuestions()\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n if (answers.length < 3 || answers.length > 5) {\n errors.push(this._createAnswerCountError(row))\n return errors\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 answers = this._resolvedAnswers()\n const questions = this._resolvedQuestions()\n const colWidth = Math.floor(100 / ((answers.length || 1) + 1))\n const previewTitle = buildSubjectPreviewTitle(this['subject-prefix'], this['order-index'], this.title)\n\n return html`\n <div class=\"preview\">\n <div class=\"preview-header\">\n <div class=\"preview-title-row\">\n <span class=\"title\">${previewTitle}</span>\n <span class=\"preview-type\">量表题</span>\n </div>\n ${this['show-rich-text'] && this['rich-text-content'] ? html`<div class=\"rich-text\" .innerHTML=${this['rich-text-content']}></div>` : ''}\n </div>\n <div class=\"scale-table-wrap\">\n <table class=\"scale-table\">\n <thead>\n <tr>\n <th style=\"width:${colWidth}%\">问题</th>\n ${answers.map(answer => html`<th style=\"width:${colWidth}%\">${answer.title}</th>`)}\n </tr>\n </thead>\n <tbody>\n ${questions.map(question => html`\n <tr>\n <td>${question}</td>\n ${answers.map(() => html`<td><input type=\"radio\" disabled /></td>`)}\n </tr>\n `)}\n </tbody>\n </table>\n </div>\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"edit-form\">\n <div class=\"edit-row\">\n <div class=\"label\"><span>题目:</span></div>\n <div class=\"row-body\">\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=\"edit-row\">\n <div class=\"label\"><span>量表内容:</span></div>\n <div class=\"row-body\">\n <div class=\"edit-grid\">\n <div class=\"edit-column\">\n <div class=\"edit-column-title\">行标题</div>\n <div class=\"el-input\">\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 class=\"edit-note\">一行一个标题,预览时会自动整理空白行。</div>\n </div>\n <div class=\"edit-column\">\n <div class=\"edit-column-title\">评分选项</div>\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 class=\"edit-note\">量表题需保持 3-5 个选项,保存时会校验。</div>\n </div>\n </div>\n </div>\n </div>\n\n ${this['show-rich-text'] && this._showRichText\n ? html`\n <div class=\"edit-row\">\n <div class=\"label\"><span>副文本:</span></div>\n <div class=\"row-body\">\n <slot name=\"sub-text\">\n <qxs-blocksuite-editor\n .content=${this._richText}\n .toolbar=${SUB_TEXT_EDITOR_TOOLBAR}\n .upload-image=${this['upload-image']}\n ?is-edit=${true}\n @input=${(e: CustomEvent) => { this._richText = (e.target as any).getContent() }}\n ></qxs-blocksuite-editor>\n </slot>\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 ${this['show-analysis']\n ? html`\n <div class=\"edit-row\">\n <div class=\"label\"><span>解析:</span></div>\n <div class=\"row-body\">\n <div class=\"el-input\">\n <textarea\n rows=\"2\"\n .value=${this._analysis}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"\n ></textarea>\n </div>\n </div>\n </div>\n `\n : ''}\n </div>\n `\n }\n\n private _renderSorting() {\n const title = trimText(this['is-edit'] ? this._title : this.title || '') || '未命名题目'\n const orderText = buildSubjectSortingTitle(this['subject-prefix'], this['order-index'], title)\n return renderSortingCard(orderText, SubjectTypeLabel[SubjectType.SCALE] || SubjectType.SCALE)\n }\n\n render() {\n if (this.sorting) {\n return this._renderSorting()\n }\n\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['show-rich-text'] && this._showRichText}\n .hide-add-rich-text=${!this['show-rich-text'] || this['hide-add-rich-text']}\n .show-delete-action=${this['show-delete-action']}\n .show-save-action=${this['show-save-action']}\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 <slot name=\"action\"></slot>\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["createEmptyScaleAnswer","title","createDefaultScaleAnswers","Array","from","length","normalizeScaleAnswer","answer","next","trimText","answerId","examAnswerId","isCorrect","serializeScaleAnswer","index","orderIndex","iconPlus","html","iconRemove","QxsScale","LitElement","constructor","super","arguments","this","sorting","analysis","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_analysis","_showRichText","_richText","TITLE_MAX","value","answers","isArray","map","normalizeScaleAnswers","requestUpdate","item","String","trim","filter","Boolean","normalizeScaleQuestionList","willUpdate","changed","shouldSyncProps","has","_syncProps","join","_emit","name","detail","emitSubjectEvent","_onTitleInput","el","slice","emitSubjectModelValue","_resolvedQuestions","rowTitle","split","_resolvedAnswers","_createAnswerCountError","row","SubjectError","toJSON","customId","answerType","SubjectType","SCALE","questions","richText","showRichText","i","fromCharCode","examTypeEnum","scaleQuestionList","examRichTextContent","isSetCorrectAnswer","examAnswerRelationType","_save","stopImmediatePropagation","data","err","showSubjectToast","message","validate","errors","push","forEach","_renderPreview","colWidth","Math","floor","previewTitle","buildSubjectPreviewTitle","question","_renderEdit","stopPropagation","currentIndex","_","SUB_TEXT_EDITOR_TOOLBAR","getContent","_renderSorting","orderText","buildSubjectSortingTitle","renderSortingCard","SubjectTypeLabel","render","content","styles","sortingCardStyles","subjectHostStyles","subjectControlResetStyles","subjectPreviewBaseStyles","subjectFormBaseStyles","subjectTextareaStyles","css","__decorateClass","property","type","Number","attribute","prototype","reflect","Object","state","safeCustomElement"],"mappings":"27BAkBA,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,EAASF,GAAQN,OAASM,GAAQA,QAAU,KAE/CG,EAAWH,GAAQG,UAAYH,GAAQI,aAO7C,YANiB,IAAbD,IACFF,EAAKE,SAAWA,UAEXF,EAAKD,cACLC,EAAKG,oBACLH,EAAKI,UACLJ,CACT,CAsBA,SAASK,EAAqBN,EAAaO,GACzC,MAAMN,EAAoB,IACrBF,EAAqBC,GACxBQ,WAAYD,EAAQ,EACpBP,OAAQE,EAASF,GAAQN,OAASM,GAAQA,QAAU,KAUtD,OARAC,EAAKP,MAAQQ,EAASD,EAAK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UAAA,gBAAA,GACAL,EAAA,CAAhBQ,KAxKU3H,EAwKMwH,UAAA,YAAA,GAEqCL,EAAA,CAArDC,EAAS,CAAEC,KAAMjF,OAAQmF,UAAW,iBA1K1BvH,EA0K2CwH,UAAA,cAAA,GACDL,EAAA,CAApDC,EAAS,CAAEC,KAAM9E,QAASgF,UAAW,eA3K3BvH,EA2K0CwH,UAAA,YAAA,GA3K1CxH,EAANmH,EAAA,CADNS,EAAkB,cACN5H"}
|
package/es/subject/single.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{html as e,css as t,LitElement as s}from"lit";import{property as i,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{uid as a}from"../base/uid.mjs";import{SUB_TEXT_EDITOR_TOOLBAR as n}from"../editor/toolbar.mjs";import{emitSubjectEvent as l,showSubjectToast as c,emitSubjectModelValue as h,getSubjectImageResources as d,getSubjectVideoResource as p,resolveSubjectCategoryLabel as u,buildSubjectPreviewTitle as w,buildSubjectSortingTitle as m}from"./shared-methods.mjs";import{subjectHostStyles as g,subjectControlResetStyles as x,subjectPreviewBaseStyles as y,subjectFormBaseStyles as _,subjectTextareaStyles as v}from"./shared-styles.mjs";import{sortingCardStyles as f,renderSortingCard as b}from"./sorting-card.mjs";import{SubjectTypeLabel as $}from"./types.mjs";var k=Object.defineProperty,A=Object.getOwnPropertyDescriptor,I=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?A(t,s):t,a=e.length-1;a>=0;a--)(r=e[a])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&k(t,s,o),o};class C extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new C(e.message,e.code,e.field,e.row)}}const T=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,S=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`,E=e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;function R(e){return e.replace(/^\d+\.\s*/,"").replace(/[\s,,。.!!??;;::、'"“”‘’()()[\]【】\-_/\\]+/g,"").toLowerCase()}function L(e){return String(e??"").trim()}function D(e){return String(e??"").split(",").map(e=>e.trim()).filter(Boolean).join(",")}let O=class extends s{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["hide-add-rich-text"]=!1,this["show-rich-text"]=!1,this["show-delete-action"]=!0,this["show-save-action"]=!0,this.sorting=!1,this["show-answer-setting"]=!1,this["show-key"]=!1,this["show-analysis"]=!1,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._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()}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:L(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){l(this,e,t)}_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=[],c(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"]&&h(this,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 c("暂无 AI 推荐答案");const e=this["ai-answer"].split(/\r?\n/).map(e=>R(e)).filter(Boolean);let t=0;if("single"===this.type){let s=!1;this._answers=this._answers.map(i=>{const r=!s&&e.includes(R(i.title||""));return r&&(s=!0,t++),{...i,isCorrect:r}})}else this._answers=this._answers.map(s=>{const i=e.includes(R(s.title||""));return i&&t++,{...s,isCorrect:i}});t?this.requestUpdate():c("未找到匹配的选项,请检查选项内容是否一致")}_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||a()};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)}_emitEditResultItem(e,t){this._emit("edit-result-item",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerIndex:t,answer:{...e},resultItem:e.resultItem||""})}_resultSlotName(e){return`business-result-item-${e}`}_imageResources(){return d(this["resource-list"]||[])}_videoResource(){return p(this["resource-list"]||[])}_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"]&&h(this,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:a()}),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:L(e?.title??e?.answer??""),isCorrect:!!e?.isCorrect,resultItem:L(e?.resultItem??"")})),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:L(this["is-edit"]?this._title:this.title||""),answers:e,analysis:L(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 C("题目标题不能为空!","EMPTY_TITLE","title",s));let r=!1,o=0;e.answers.forEach((e,a)=>{e.title?.trim()||i.push(new C(`选项${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 C("选项不能重复","DUPLICATE_ANSWERS","answers",s)),"single"===t&&o>1&&i.push(new C("此题为单选题,设置了多个推荐/正确选项,请保存时确认是否切换为多选题","SINGLE_MULTI_CORRECT","answers",s)),"multiple"===t&&(1===o&&i.push(new C("请设置至少两个推荐/正确选项","CORRECT_COUNT_INVALID","answers",s)),o>0&&(r=!0),r&&null!==e.leastAnswerCount&&o<e.leastAnswerCount&&i.push(new C("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))),"sort"===t&&(r=e.orderList.length>0,null!==e.leastAnswerCount&&e.orderList.length<e.leastAnswerCount&&i.push(new C("至少选几项与推荐/正确选项数不符","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.resultItem?1:Array.isArray(e.answerRelations)&&e.answerRelations.length?2:null,i={...e,orderIndex:t+1,answer:e.title,relationType:s};return void 0!==e.answerId&&(i.examAnswerId=e.answerId),null===s&&delete i.relationType,i}),examExpand:t.examExpand,analysis:t.analysis,isSetCorrectAnswer:i,examRichTextContent:t.showRichText?t.richText:""};return this["exam-answer-relation-type"]&&(r.examAnswerRelationType=this["exam-answer-relation-type"]),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 _finalizeSave(){try{const e=await this.toJSON();this._emit("save",e)}catch(e){c(e.message)}}async toJSON(){return Promise.resolve(this._serialize())}validate(){return this._validateSnapshot(this._collectSnapshot()).errors}setResultItem(e,t){e<0||e>=this._answers.length||(this._answers=this._answers.map((s,i)=>i===e?{...s,resultItem:t||""}:s),this.requestUpdate())}setAnswerRelation(e,t){e&&(this._answers=this._answers.map(s=>String(s.customAnswerId??s.answerId??"")===String(e)?{...s,answerRelations:t}:s),this.requestUpdate())}_renderCorrectHintDialog(){return this._correctHintDialogOpen?e`
|
|
1
|
+
import{html as e,css as t,LitElement as s}from"lit";import{property as i,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{uid as a}from"../base/uid.mjs";import{SUB_TEXT_EDITOR_TOOLBAR as n}from"../editor/toolbar.mjs";import{emitSubjectEvent as l,showSubjectToast as c,emitSubjectModelValue as h,getSubjectImageResources as d,getSubjectVideoResource as p,resolveSubjectCategoryLabel as u,buildSubjectPreviewTitle as w,buildSubjectSortingTitle as m}from"./shared-methods.mjs";import{subjectHostStyles as g,subjectControlResetStyles as x,subjectPreviewBaseStyles as y,subjectFormBaseStyles as _,subjectTextareaStyles as v}from"./shared-styles.mjs";import{sortingCardStyles as f,renderSortingCard as b}from"./sorting-card.mjs";import{SubjectTypeLabel as $}from"./types.mjs";var k=Object.defineProperty,A=Object.getOwnPropertyDescriptor,C=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?A(t,s):t,a=e.length-1;a>=0;a--)(r=e[a])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&k(t,s,o),o};class I 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 I(e.message,e.code,e.field,e.row)}}const T=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,S=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`,E=e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;function R(e){return e.replace(/^\d+\.\s*/,"").replace(/[\s,,。.!!??;;::、'"“”‘’()()[\]【】\-_/\\]+/g,"").toLowerCase()}function L(e){return String(e??"").trim()}function D(e){return String(e??"").split(",").map(e=>e.trim()).filter(Boolean).join(",")}let O=class extends s{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["hide-add-rich-text"]=!1,this["show-rich-text"]=!1,this["show-delete-action"]=!0,this["show-save-action"]=!0,this.sorting=!1,this["show-answer-setting"]=!1,this["show-key"]=!1,this["show-analysis"]=!1,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._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()}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:L(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){l(this,e,t)}_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=[],c(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"]&&h(this,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 c("暂无 AI 推荐答案");const e=this["ai-answer"].split(/\r?\n/).map(e=>R(e)).filter(Boolean);let t=0;if("single"===this.type){let s=!1;this._answers=this._answers.map(i=>{const r=!s&&e.includes(R(i.title||""));return r&&(s=!0,t++),{...i,isCorrect:r}})}else this._answers=this._answers.map(s=>{const i=e.includes(R(s.title||""));return i&&t++,{...s,isCorrect:i}});t?this.requestUpdate():c("未找到匹配的选项,请检查选项内容是否一致")}_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||a()};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)}_emitEditResultItem(e,t){this._emit("edit-result-item",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerIndex:t,answer:{...e},resultItem:e.resultItem||""})}_resultSlotName(e){return`business-result-item-${e}`}_imageResources(){return d(this["resource-list"]||[])}_videoResource(){return p(this["resource-list"]||[])}_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||("single"===this.type?this._answers=this._answers.map(s=>({...s,isCorrect:s===e?t:!t&&!!s.isCorrect})):this._answers=this._answers.map(s=>s===e?{...s,isCorrect:t}:s),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"]&&h(this,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:a()}),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:L(e?.title??e?.answer??""),isCorrect:!!e?.isCorrect,resultItem:L(e?.resultItem??"")})),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:L(this["is-edit"]?this._title:this.title||""),answers:e,analysis:L(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 I("题目标题不能为空!","EMPTY_TITLE","title",s));let r=!1,o=0;e.answers.forEach((e,a)=>{e.title?.trim()||i.push(new I(`选项${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 I("选项不能重复","DUPLICATE_ANSWERS","answers",s)),"single"===t&&o>1&&i.push(new I("此题为单选题,设置了多个推荐/正确选项,请保存时确认是否切换为多选题","SINGLE_MULTI_CORRECT","answers",s)),"multiple"===t&&(1===o&&i.push(new I("请设置至少两个推荐/正确选项","CORRECT_COUNT_INVALID","answers",s)),o>0&&(r=!0),r&&null!==e.leastAnswerCount&&o<e.leastAnswerCount&&i.push(new I("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))),"sort"===t&&(r=e.orderList.length>0,null!==e.leastAnswerCount&&e.orderList.length<e.leastAnswerCount&&i.push(new I("至少选几项与推荐/正确选项数不符","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.resultItem?1:Array.isArray(e.answerRelations)&&e.answerRelations.length?2:null,i={...e,orderIndex:t+1,answer:e.title,relationType:s};return void 0!==e.answerId&&(i.examAnswerId=e.answerId),null===s&&delete i.relationType,i}),examExpand:t.examExpand,analysis:t.analysis,isSetCorrectAnswer:i,examRichTextContent:t.showRichText?t.richText:""};return this["exam-answer-relation-type"]&&(r.examAnswerRelationType=this["exam-answer-relation-type"]),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 _finalizeSave(){try{const e=await this.toJSON();this._emit("save",e)}catch(e){c(e.message)}}async toJSON(){return Promise.resolve(this._serialize())}validate(){return this._validateSnapshot(this._collectSnapshot()).errors}setResultItem(e,t){e<0||e>=this._answers.length||(this._answers=this._answers.map((s,i)=>i===e?{...s,resultItem:t||""}:s),this.requestUpdate())}setAnswerRelation(e,t){e&&(this._answers=this._answers.map(s=>String(s.customAnswerId??s.answerId??"")===String(e)?{...s,answerRelations:t}:s),this.requestUpdate())}_renderCorrectHintDialog(){return this._correctHintDialogOpen?e`
|
|
2
2
|
<div class="modal-backdrop" @click=${()=>{this._correctHintDialogOpen=!1}}>
|
|
3
3
|
<div class="modal correct-hint-dialog" @click=${e=>e.stopPropagation()}>
|
|
4
4
|
<div class="modal-header">
|
|
@@ -202,7 +202,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
|
|
|
202
202
|
<label class="correct ${t.isCorrect?"is-correct":""}">
|
|
203
203
|
<input type="checkbox" .checked=${t.isCorrect} ?disabled=${this.lockAnswerKey}
|
|
204
204
|
@change=${e=>this._setCorrect(t,e.target.checked)} />
|
|
205
|
-
|
|
205
|
+
<span class="correct-text">推荐/正确选项</span>
|
|
206
206
|
</label>
|
|
207
207
|
`:""}
|
|
208
208
|
|
|
@@ -397,12 +397,25 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
|
|
|
397
397
|
cursor: pointer;
|
|
398
398
|
display: inline-flex;
|
|
399
399
|
align-items: center;
|
|
400
|
-
gap:
|
|
400
|
+
gap: 6px;
|
|
401
|
+
min-height: 20px;
|
|
401
402
|
white-space: nowrap;
|
|
402
403
|
}
|
|
403
404
|
.answer-item .correct:hover { color: #3D61E3; }
|
|
404
405
|
.answer-item .correct.is-correct { color: #67c23a; }
|
|
405
|
-
.answer-item .correct input {
|
|
406
|
+
.answer-item .correct input {
|
|
407
|
+
width: 14px;
|
|
408
|
+
height: 14px;
|
|
409
|
+
margin: 0;
|
|
410
|
+
flex: 0 0 auto;
|
|
411
|
+
cursor: pointer;
|
|
412
|
+
accent-color: #3D61E3;
|
|
413
|
+
}
|
|
414
|
+
.answer-item .correct .correct-text {
|
|
415
|
+
display: inline-flex;
|
|
416
|
+
align-items: center;
|
|
417
|
+
line-height: 1.2;
|
|
418
|
+
}
|
|
406
419
|
|
|
407
420
|
.answer-item .icon {
|
|
408
421
|
margin-left: 6px; cursor: pointer; display: inline-flex;
|
|
@@ -583,5 +596,5 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
|
|
|
583
596
|
font-size: 14px;
|
|
584
597
|
border-radius: 4px;
|
|
585
598
|
}
|
|
586
|
-
`],
|
|
599
|
+
`],C([i({type:Number,attribute:"order-index"})],O.prototype,"order-index",2),C([i({type:String,attribute:"subject-prefix"})],O.prototype,"subject-prefix",2),C([i({type:Boolean,attribute:"is-edit"})],O.prototype,"is-edit",2),C([i({type:Boolean,attribute:"is-save"})],O.prototype,"is-save",2),C([i({type:Boolean,attribute:"is-set"})],O.prototype,"is-set",2),C([i({type:Boolean,attribute:"is-set-correct-answer"})],O.prototype,"is-set-correct-answer",2),C([i({type:Boolean,attribute:"lock-answer-key"})],O.prototype,"lockAnswerKey",2),C([i({type:Boolean,attribute:"is-key"})],O.prototype,"is-key",2),C([i({type:Boolean,attribute:"show-action"})],O.prototype,"show-action",2),C([i({type:Boolean,attribute:"show-add"})],O.prototype,"show-add",2),C([i({type:Boolean,attribute:"hide-add-rich-text"})],O.prototype,"hide-add-rich-text",2),C([i({type:Boolean,attribute:"show-rich-text"})],O.prototype,"show-rich-text",2),C([i({type:Boolean,attribute:"show-delete-action"})],O.prototype,"show-delete-action",2),C([i({type:Boolean,attribute:"show-save-action"})],O.prototype,"show-save-action",2),C([i({type:Boolean,reflect:!0})],O.prototype,"sorting",2),C([i({type:Boolean,attribute:"show-answer-setting"})],O.prototype,"show-answer-setting",2),C([i({type:Boolean,attribute:"show-key"})],O.prototype,"show-key",2),C([i({type:Boolean,attribute:"show-analysis"})],O.prototype,"show-analysis",2),C([i({attribute:"question-type",reflect:!0})],O.prototype,"type",2),C([i({type:Number,attribute:"answer-check-type"})],O.prototype,"answer-check-type",2),C([i({type:Number,attribute:"exam-answer-relation-type"})],O.prototype,"exam-answer-relation-type",2),C([i({type:String,attribute:"rich-text-content"})],O.prototype,"rich-text-content",2),C([i({type:String})],O.prototype,"analysis",2),C([i({type:Number,attribute:"least-answer-count"})],O.prototype,"least-answer-count",2),C([i({type:String,attribute:"exam-expand"})],O.prototype,"exam-expand",2),C([i({type:String,attribute:"custom-id"})],O.prototype,"custom-id",2),C([i({type:Number,attribute:"exam-id"})],O.prototype,"exam-id",2),C([i({type:String,attribute:"category-id"})],O.prototype,"category-id",2),C([i({type:Object,attribute:"upload-image"})],O.prototype,"upload-image",2),C([i({type:Array,attribute:"answer-list"})],O.prototype,"answer-list",1),C([i({type:Array,attribute:"tag-list"})],O.prototype,"tag-list",2),C([i({type:Array,attribute:"category-list"})],O.prototype,"category-list",2),C([i({type:String,attribute:"ai-answer"})],O.prototype,"ai-answer",2),C([i({type:Array,attribute:"resource-list"})],O.prototype,"resource-list",2),C([i({type:Boolean,attribute:"show-tag"})],O.prototype,"show-tag",2),C([i({type:Boolean,attribute:"show-category"})],O.prototype,"show-category",2),C([i({type:Boolean,attribute:"show-ai"})],O.prototype,"show-ai",2),C([i({type:Boolean,attribute:"show-resource"})],O.prototype,"show-resource",2),C([i({type:Boolean,attribute:"show-jump"})],O.prototype,"show-jump",2),C([i({type:Boolean,attribute:"has-jump"})],O.prototype,"has-jump",2),C([i({type:String,attribute:"search-api"})],O.prototype,"search-api",2),C([i({type:Object,attribute:"search-handler"})],O.prototype,"search-handler",2),C([i({type:String,attribute:"model-value"})],O.prototype,"model-value",2),C([i({type:Boolean,attribute:"use-model"})],O.prototype,"use-model",2),C([r()],O.prototype,"_answers",2),C([i({type:String})],O.prototype,"title",2),C([r()],O.prototype,"_title",2),C([r()],O.prototype,"_analysis",2),C([r()],O.prototype,"_richText",2),C([r()],O.prototype,"_showRichText",2),C([r()],O.prototype,"_leastAnswerCount",2),C([r()],O.prototype,"_answerCheckType",2),C([r()],O.prototype,"_isKey",2),C([r()],O.prototype,"_orderList",2),C([r()],O.prototype,"_selectedTagList",2),C([r()],O.prototype,"_categoryId",2),C([r()],O.prototype,"_searchResults",2),C([r()],O.prototype,"_searchOpen",2),C([r()],O.prototype,"_searchLoading",2),C([r()],O.prototype,"_sortDropdownOpen",2),C([r()],O.prototype,"_imageViewerOpen",2),C([r()],O.prototype,"_imageViewerIndex",2),C([r()],O.prototype,"_videoViewerOpen",2),C([r()],O.prototype,"_correctHintDialogOpen",2),C([r()],O.prototype,"_hasShownCorrectHint",2),C([r()],O.prototype,"_changeTypeDialogOpen",2),O=C([o("qxs-subject-single")],O);export{O as QxsSubjectSingle,I as SubjectError,D as trimCommaSeparatedText,L as trimText};
|
|
587
600
|
//# sourceMappingURL=single.mjs.map
|