@qxs-bns/components-wc 0.0.13 → 0.0.14
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/editor/blocksuite-editor.mjs +3 -3
- package/es/editor/blocksuite-editor.mjs.map +1 -1
- package/es/index.mjs +1 -1
- package/es/subject/list.mjs +7 -7
- package/es/subject/list.mjs.map +1 -1
- package/es/subject/single.mjs +50 -50
- package/es/subject/single.mjs.map +1 -1
- package/lib/editor/blocksuite-editor.cjs +2 -2
- package/lib/editor/blocksuite-editor.cjs.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/subject/list.cjs +2 -2
- package/lib/subject/list.cjs.map +1 -1
- package/lib/subject/single.cjs +3 -3
- package/lib/subject/single.cjs.map +1 -1
- package/package.json +1 -1
package/es/subject/list.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as
|
|
1
|
+
import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as a}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import r from"sortablejs";import{safeCustomElement as o}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";import{SubjectError as l}from"./single.mjs";import{SubjectType as d}from"./types.mjs";import"./action.mjs";import"./blank-fill.mjs";import"./layout.mjs";import"./text-fill.mjs";import"./scale.mjs";import"./page-end.mjs";import"./type.mjs";var c=Object.defineProperty,h=Object.getOwnPropertyDescriptor,p=(t,e,s,i)=>{for(var a,r=i>1?void 0:i?h(e,s):e,o=t.length-1;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&c(e,s,r),r};d.SINGLE,d.MULTIPLE,d.SORT,d.BLANK_FILL,d.TEXT_FILL,d.SCALE;let m=class extends e{constructor(){super(...arguments),this.isPreview=!1,this.uploadImage=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this._list=[],this._sortMode=!1,this._sortable=null,this._initialDataProcessed=!1}get subjectList(){return this._list}set subjectList(t){if(t){if("string"==typeof t)try{t=JSON.parse(t)}catch{return this._list=[],void this.requestUpdate()}if(!Array.isArray(t))return this._list=[],void this.requestUpdate();this._list=t.map(t=>({...t,customId:t.customId||n()})),this.requestUpdate()}else this._list=[]}attributeChangedCallback(t,e,s){if(super.attributeChangedCallback(t,e,s),"subject-list"===t&&s&&!this._list.length){if(s.includes("[object Object]"))return;try{const t=JSON.parse(s);Array.isArray(t)&&(this._list=t.map(t=>({...t,customId:t.customId||n()})),this.requestUpdate())}catch{}}}get _isPreviewValue(){const t=this.isPreview;return"string"==typeof t?"false"!==t:!!t}connectedCallback(){super.connectedCallback(),this._initialDataProcessed||(this._initialDataProcessed=!0,Promise.resolve().then(()=>{0===this._list.length&&this._processAttributeList()}))}_processAttributeList(){const t=this.getAttribute("subject-list");if(t&&"[]"!==t&&!t.includes("[object Object]"))try{const e=JSON.parse(t);Array.isArray(e)&&e.length>0&&(this._list=e.map(t=>({...t,customId:t.customId||n()})),this.requestUpdate())}catch{}}firstUpdated(){this.updateComplete.then(()=>this._initSortable())}updated(t){t.has("_sortMode")&&(this._sortable?.destroy(),this._sortable=null,this.updateComplete.then(()=>this._initSortable())),t.has("_list")&&this._sortMode&&setTimeout(()=>{this._sortable&&(this._sortable.destroy(),this._sortable=null),this._initSortable()},50)}disconnectedCallback(){super.disconnectedCallback(),this._sortable?.destroy(),this._sortable=null}_initSortable(){if(!this._sortMode)return;this.querySelector(".sort-list")&&(this._sortable&&(this._sortable.destroy(),this._sortable=null),requestAnimationFrame(()=>{const t=this.querySelector(".sort-list");t&&!this._sortable&&(this._sortable=r.create(t,{handle:".sort-handle",animation:200,ghostClass:"sort-ghost",chosenClass:"sort-chosen",onEnd:t=>{const{oldIndex:e,newIndex:s}=t;if(void 0===e||void 0===s||e===s)return;const i=[...this._list],[a]=i.splice(e,1);i.splice(s,0,a),this._list=i,this._emit("change",this._list)}}))}))}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}async toJSON(){const t=this.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text");if(!t||0===t.length)return[];const e=[],s=[];for(const i of t)if("function"==typeof i.toJSON)try{const t=await i.toJSON();e.push(t)}catch(t){t instanceof l?s.push(t):s.push(new l(t.message||"未知错误","UNKNOWN","unknown"))}if(s.length>0)throw s;return e}async validate(){const t=this.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale");if(!t||0===t.length)return{valid:!0,errors:[]};const e=[];for(const s of t)if("function"==typeof s.validate){const t=s.validate();t?.length&&e.push(...t)}return{valid:0===e.length,errors:e}}get currentList(){return this._list}addSubject(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const i={customId:n(),answerType:t,title:"",answers:[],analysis:"",scaleQuestionList:[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1,isKey:!1,answerCheckType:1,examAnswerRelationType:s??0},a=[...this._list];"number"==typeof e&&e>=0?a.splice(e+1,0,i):a.push(i),this._list=a,this.requestUpdate(),this._emit("change",this._list)}addExam(t){const e=[];t.forEach(t=>{const s={...t,customId:t.customId||n(),answers:t.answers?.map(t=>({...t,title:t.answer,answerId:t.examAnswerId,isCorrect:t.isCorrect}))||[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1};t.richTextContent||(s.answerType=t.examTypeEnum),e.push(s)}),this._list=[...this._list,...e],this._emit("change",this._list)}uploadExcel(t){this._list=[...this._list,...t.map(t=>({...t,customId:t.customId||n(),isRealCanDel:!0}))],this._emit("change",this._list)}setAnswerRelation(t,e,s){const i=this._list.find(t=>t.customId===e);if(i){const e=i.answers?.find(t=>t.customAnswerId===s);e&&(e.answerRelations=t)}this.requestUpdate(),this._emit("change",this._list)}_orderIndex(t){let e=0,s=0;return this._list.forEach(i=>{e++,i.customId===t&&(s=e)}),s-1}_move(t,e){const s=[...this._list];"up"===e&&t>0?[s[t-1],s[t]]=[s[t],s[t-1]]:"down"===e&&t<s.length-1&&([s[t],s[t+1]]=[s[t+1],s[t]]),this._list=s,this._emit("change",this._list)}_save(t,e){this._list=this._list.map((s,i)=>i===t?{...s,...e.detail,isEdit:!1,isSave:!0}:s),this._emit("change",this._list)}_deleteByCustomId(t){this._list=this._list.filter(e=>e.customId!==t),this._emit("change",this._list)}_delete(t){const e=[...this._list];e.splice(t,1),this._list=e,this._emit("change",this._list)}_setEdit(t,e){this._list=this._list.map((s,i)=>i===t?{...s,isEdit:e}:s)}_renderItem(t,e){const i=this._orderIndex(t.customId),a=(t.isEdit,t.hasSet,t.isRealCanDel,this._isPreviewValue,t.examAnswerRelationType,t=>this._move(e,t.detail)),r=()=>this._deleteByCustomId(t.customId),o=t=>this._save(e,t),n=()=>this._setEdit(e,!0),l=t=>this.addSubject(t.detail?.type??t.detail,e);return[d.SINGLE,d.MULTIPLE,d.SORT].includes(t.answerType)?s`<qxs-subject-single
|
|
2
2
|
.title=${t.title||""}
|
|
3
3
|
.answerList=${t.answers||[]}
|
|
4
4
|
.uploadImage=${this.uploadImage}
|
|
@@ -8,7 +8,7 @@ import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"..
|
|
|
8
8
|
?is-save=${!t.isRealCanDel}
|
|
9
9
|
?show-action=${!this._isPreviewValue}
|
|
10
10
|
?is-key=${t.isKey}
|
|
11
|
-
type=${t.answerType}
|
|
11
|
+
question-type=${String(t.answerType)}
|
|
12
12
|
answer-check-type=${t.answerCheckType??1}
|
|
13
13
|
exam-answer-relation-type=${t.examAnswerRelationType??0}
|
|
14
14
|
rich-text-content=${t.examRichTextContent||""}
|
|
@@ -17,7 +17,7 @@ import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"..
|
|
|
17
17
|
exam-expand=${t.examExpand||""}
|
|
18
18
|
custom-id=${t.customId||""}
|
|
19
19
|
exam-id=${t.examId??0}
|
|
20
|
-
@move=${
|
|
20
|
+
@move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
|
|
21
21
|
@set-relation=${t=>this._emit("set-relation",t.detail)}
|
|
22
22
|
></qxs-subject-single>`:t.answerType===d.BLANK_FILL?s`<qxs-blank-fill
|
|
23
23
|
.title=${t.title||""}
|
|
@@ -31,7 +31,7 @@ import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"..
|
|
|
31
31
|
rich-text-content=${t.examRichTextContent||""}
|
|
32
32
|
analysis=${t.analysis||""}
|
|
33
33
|
custom-id=${t.customId||""}
|
|
34
|
-
@move=${
|
|
34
|
+
@move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
|
|
35
35
|
></qxs-blank-fill>`:t.answerType===d.TEXT_FILL?s`<qxs-text-fill
|
|
36
36
|
.title=${t.title||""}
|
|
37
37
|
.answerList=${t.answers||[]}
|
|
@@ -44,7 +44,7 @@ import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"..
|
|
|
44
44
|
rich-text-content=${t.examRichTextContent||""}
|
|
45
45
|
analysis=${t.analysis||""}
|
|
46
46
|
custom-id=${t.customId||""}
|
|
47
|
-
@move=${
|
|
47
|
+
@move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
|
|
48
48
|
></qxs-text-fill>`:t.answerType===d.SCALE?s`<qxs-scale
|
|
49
49
|
.title=${t.title||""}
|
|
50
50
|
.answerList=${t.answers||[]}
|
|
@@ -56,7 +56,7 @@ import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"..
|
|
|
56
56
|
rich-text-content=${t.examRichTextContent||""}
|
|
57
57
|
analysis=${t.analysis||""}
|
|
58
58
|
custom-id=${t.customId||""}
|
|
59
|
-
@move=${
|
|
59
|
+
@move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
|
|
60
60
|
></qxs-scale>`:s`<div style="color:#909399;padding:8px">未知题型: ${t.answerType}</div>`}render(){return s`
|
|
61
61
|
<div class="subject-list">
|
|
62
62
|
${this._list.map((t,e)=>this._renderItem(t,e))}
|
|
@@ -83,5 +83,5 @@ import{css as t,LitElement as e,html as s}from"lit";import{property as i}from"..
|
|
|
83
83
|
.sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }
|
|
84
84
|
.sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
85
85
|
.sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }
|
|
86
|
-
`,p([i({attribute:"is-preview"})],m.prototype,"isPreview",2),p([i({type:Object})],m.prototype,"uploadImage",2),p([i({type:Array})],m.prototype,"subjectList",1),p([
|
|
86
|
+
`,p([i({attribute:"is-preview"})],m.prototype,"isPreview",2),p([i({type:Object})],m.prototype,"uploadImage",2),p([i({type:Array})],m.prototype,"subjectList",1),p([a()],m.prototype,"_list",2),p([a()],m.prototype,"_sortMode",2),m=p([o("qxs-subject-list")],m);export{m as QxsSubjectList};
|
|
87
87
|
//# sourceMappingURL=list.mjs.map
|
package/es/subject/list.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.mjs","sources":["../../../../packages/components-wc/src/subject/list.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\nimport { SubjectType } from './types'\n\n// 导入子组件以确保它们被注册为 Custom Elements\nimport './action'\nimport './blank-fill'\nimport './layout'\nimport './single'\nimport './text-fill'\nimport './scale'\nimport './page-end'\nimport './rich-text'\nimport './type'\n\nconst TYPE_LABEL: Record<string, string> = {\n [SubjectType.SINGLE]: '单选题', [SubjectType.MULTIPLE]: '多选题', [SubjectType.SORT]: '排序题',\n [SubjectType.BLANK_FILL]: '填空题', [SubjectType.TEXT_FILL]: '问答题', [SubjectType.SCALE]: '量表题',\n}\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .btn.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .btn.primary:hover { background: #3D61E3; border-color: #3D61E3; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n\n\n @property({ attribute: 'is-preview' }) isPreview = false\n\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = e => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n\n @property({ type: Array })\n get subjectList() { return this._list }\n\n set subjectList(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = v.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = (this as any).isPreview\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode) { return }\n const el = this.querySelector<HTMLElement>('.sort-list')\n if (!el) { return }\n\n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n\n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) { return }\n\n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emit('change', this._list)\n },\n })\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return results\n }\n\n async validate(): Promise<{ valid: boolean, errors: SubjectError[] }> {\n const subjectEls = this.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n const item = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n isKey: false, answerCheckType: 1,\n examAnswerRelationType: examAnswerRelationType ?? 0,\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n addExam(items: any[]) {\n const newItems: any[] = []\n items.forEach((v: any) => {\n const item: any = {\n ...v,\n customId: v.customId || uid(),\n answers: v.answers?.map((c: any) => ({ ...c, title: c.answer, answerId: c.examAnswerId, isCorrect: c.isCorrect })) || [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n }\n if (!v.richTextContent) {\n item.answerType = v.examTypeEnum\n }\n newItems.push(item)\n })\n this._list = [...this._list, ...newItems]\n this._emit('change', this._list)\n }\n\n uploadExcel(list: any[]) {\n this._list = [...this._list, ...list.map((i: any) => ({ ...i, customId: i.customId || uid(), isRealCanDel: true }))]\n this._emit('change', this._list)\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n n++; if (v.customId === customId) { out = n }\n })\n return out - 1\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _save(index: number, e: CustomEvent) {\n this._list = this._list.map((item, i) =>\n i === index ? { ...item, ...e.detail, isEdit: false, isSave: true } : item,\n )\n this._emit('change', this._list)\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emit('change', this._list)\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?is-save': !item.isRealCanDel,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if ([SubjectType.SINGLE, SubjectType.MULTIPLE, SubjectType.SORT].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit}\n ?is-set=${item.hasSet}\n ?is-save=${!item.isRealCanDel}\n ?show-action=${!this._isPreviewValue}\n ?is-key=${item.isKey}\n type=${item.answerType}\n answer-check-type=${item.answerCheckType ?? 1}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n least-answer-count=${item.leastAnswerCount ?? 2}\n exam-expand=${item.examExpand || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @set-relation=${(e: CustomEvent) => this._emit('set-relation', e.detail)}\n ></qxs-subject-single>`\n }\n if (item.answerType === SubjectType.BLANK_FILL) {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-blank-fill>`\n }\n if (item.answerType === SubjectType.TEXT_FILL) {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-text-fill>`\n }\n if (item.answerType === SubjectType.SCALE) {\n return html`<qxs-scale\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .scaleQuestions=${item.scaleQuestionList || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-scale>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n return html`\n <div class=\"subject-list\">\n ${this._list.map((item, index) => this._renderItem(item, index))}\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["SubjectType","SINGLE","MULTIPLE","SORT","BLANK_FILL","TEXT_FILL","SCALE","QxsSubjectList","LitElement","constructor","super","arguments","this","isPreview","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","subjectList","v","JSON","parse","requestUpdate","Array","isArray","map","i","customId","uid","attributeChangedCallback","name","oldVal","newVal","length","includes","parsed","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","item","splice","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","subjectEls","querySelectorAll","results","errors","el","data","push","err","SubjectError","message","validate","valid","errs","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","addExam","items","newItems","forEach","c","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","_orderIndex","n","out","_move","dir","_save","_deleteByCustomId","filter","_delete","_setEdit","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","html","examRichTextContent","leastAnswerCount","examExpand","examId","examAnswerSettingVO","render","styles","css","__decorateClass","property","attribute","prototype","Object","state","safeCustomElement"],"mappings":"43BAqBGA,EAAYC,OAAiBD,EAAYE,SAAmBF,EAAYG,KACxEH,EAAYI,WAAqBJ,EAAYK,UAAoBL,EAAYM,MAIzE,IAAMC,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WA2BkCC,KAAAC,WAAY,EAGnDD,KAAAE,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAASC,GAAKL,EAAQK,EAAEC,QAAQC,QACvCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAkDhBf,KAAQgB,MAAe,GACvBhB,KAAQiB,WAAY,EAC7BjB,KAAQkB,UAA6B,KAOrClB,KAAQmB,uBAAwB,CAAA,CAtDhC,eAAIC,GAAgB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EAAA,CADHC,EAAS,CAAE5D,KAAMnE,SAvCP9B,EAwCP+J,UAAA,cAAA,GA6CaH,EAAA,CAAhBK,KArFUjK,EAqFM+J,UAAA,QAAA,GACAH,EAAA,CAAhBK,KAtFUjK,EAsFM+J,UAAA,YAAA,GAtFN/J,EAAN4J,EAAA,CADNM,EAAkB,qBACNlK"}
|
|
1
|
+
{"version":3,"file":"list.mjs","sources":["../../../../packages/components-wc/src/subject/list.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\nimport { SubjectType } from './types'\n\n// 导入子组件以确保它们被注册为 Custom Elements\nimport './action'\nimport './blank-fill'\nimport './layout'\nimport './single'\nimport './text-fill'\nimport './scale'\nimport './page-end'\nimport './type'\n\nconst TYPE_LABEL: Record<string, string> = {\n [SubjectType.SINGLE]: '单选题', [SubjectType.MULTIPLE]: '多选题', [SubjectType.SORT]: '排序题',\n [SubjectType.BLANK_FILL]: '填空题', [SubjectType.TEXT_FILL]: '问答题', [SubjectType.SCALE]: '量表题',\n}\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .btn.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .btn.primary:hover { background: #3D61E3; border-color: #3D61E3; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n\n\n @property({ attribute: 'is-preview' }) isPreview = false\n\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = e => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n\n @property({ type: Array })\n get subjectList() { return this._list }\n\n set subjectList(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = v.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = (this as any).isPreview\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode) { return }\n const el = this.querySelector<HTMLElement>('.sort-list')\n if (!el) { return }\n\n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n\n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) { return }\n\n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emit('change', this._list)\n },\n })\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return results\n }\n\n async validate(): Promise<{ valid: boolean, errors: SubjectError[] }> {\n const subjectEls = this.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n const item = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n isKey: false, answerCheckType: 1,\n examAnswerRelationType: examAnswerRelationType ?? 0,\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n addExam(items: any[]) {\n const newItems: any[] = []\n items.forEach((v: any) => {\n const item: any = {\n ...v,\n customId: v.customId || uid(),\n answers: v.answers?.map((c: any) => ({ ...c, title: c.answer, answerId: c.examAnswerId, isCorrect: c.isCorrect })) || [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n }\n if (!v.richTextContent) {\n item.answerType = v.examTypeEnum\n }\n newItems.push(item)\n })\n this._list = [...this._list, ...newItems]\n this._emit('change', this._list)\n }\n\n uploadExcel(list: any[]) {\n this._list = [...this._list, ...list.map((i: any) => ({ ...i, customId: i.customId || uid(), isRealCanDel: true }))]\n this._emit('change', this._list)\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n n++; if (v.customId === customId) { out = n }\n })\n return out - 1\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _save(index: number, e: CustomEvent) {\n console.log('_save receive detail:', JSON.stringify(e.detail))\n this._list = this._list.map((item, i) =>\n i === index ? { ...item, ...e.detail, isEdit: false, isSave: true } : item,\n )\n console.log('_save after merge:', JSON.stringify(this._list[index]))\n this._emit('change', this._list)\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emit('change', this._list)\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?is-save': !item.isRealCanDel,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if ([SubjectType.SINGLE, SubjectType.MULTIPLE, SubjectType.SORT].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit}\n ?is-set=${item.hasSet}\n ?is-save=${!item.isRealCanDel}\n ?show-action=${!this._isPreviewValue}\n ?is-key=${item.isKey}\n question-type=${String(item.answerType)}\n answer-check-type=${item.answerCheckType ?? 1}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n least-answer-count=${item.leastAnswerCount ?? 2}\n exam-expand=${item.examExpand || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @set-relation=${(e: CustomEvent) => this._emit('set-relation', e.detail)}\n ></qxs-subject-single>`\n }\n if (item.answerType === SubjectType.BLANK_FILL) {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-blank-fill>`\n }\n if (item.answerType === SubjectType.TEXT_FILL) {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-text-fill>`\n }\n if (item.answerType === SubjectType.SCALE) {\n return html`<qxs-scale\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .scaleQuestions=${item.scaleQuestionList || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-scale>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n return html`\n <div class=\"subject-list\">\n ${this._list.map((item, index) => this._renderItem(item, index))}\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["SubjectType","SINGLE","MULTIPLE","SORT","BLANK_FILL","TEXT_FILL","SCALE","QxsSubjectList","LitElement","constructor","super","arguments","this","isPreview","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","subjectList","v","JSON","parse","requestUpdate","Array","isArray","map","i","customId","uid","attributeChangedCallback","name","oldVal","newVal","length","includes","parsed","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","item","splice","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","subjectEls","querySelectorAll","results","errors","el","data","push","err","SubjectError","message","validate","valid","errs","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","addExam","items","newItems","forEach","c","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","_orderIndex","n","out","_move","dir","_save","_deleteByCustomId","filter","_delete","_setEdit","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","html","String","examRichTextContent","leastAnswerCount","examExpand","examId","examAnswerSettingVO","render","styles","css","__decorateClass","property","attribute","prototype","Object","state","safeCustomElement"],"mappings":"o2BAoBGA,EAAYC,OAAiBD,EAAYE,SAAmBF,EAAYG,KACxEH,EAAYI,WAAqBJ,EAAYK,UAAoBL,EAAYM,MAIzE,IAAMC,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WA2BkCC,KAAAC,WAAY,EAGnDD,KAAAE,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAASC,GAAKL,EAAQK,EAAEC,QAAQC,QACvCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAkDhBf,KAAQgB,MAAe,GACvBhB,KAAQiB,WAAY,EAC7BjB,KAAQkB,UAA6B,KAOrClB,KAAQmB,uBAAwB,CAAA,CAtDhC,eAAIC,GAAgB,OAAOpB,KAAKgB,KAAM,CAEtC,eAAII,CAAYC,GACd,GAAKA,EAAL,CAIA,GAAiB,iBAANA,EACT,IACEA,EAAIC,KAAKC,MAAMF,EACjB,CAAA,MAIE,OAFArB,KAAKgB,MAAQ,QACbhB,KAAKwB,eAEP,CAEF,IAAKC,MAAMC,QAAQL,GAGjB,OAFArB,KAAKgB,MAAQ,QACbhB,KAAKwB,gBAGPxB,KAAKgB,MAAQK,EAAEM,IAAKC,IAAA,IAAiBA,EAAGC,SAAUD,EAAEC,UAAYC,OAChE9B,KAAKwB,eAjBL,MAFExB,KAAKgB,MAAQ,EAoBjB,CAEAe,wBAAAA,CAAyBC,EAAcC,EAAuBC,GAE5D,GADApC,MAAMiC,yBAAyBC,EAAMC,EAAQC,GAChC,iBAATF,GAA2BE,IAAWlC,KAAKgB,MAAMmB,OAAQ,CAC3D,GAAID,EAAOE,SAAS,mBAClB,OAEF,IACE,MAAMC,EAASf,KAAKC,MAAMW,GACtBT,MAAMC,QAA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uBAC7BpG,KAAKE;sBACNsI;mBACHpE,EAAKiC,kBAAkBjC,EAAKoC,oBAAoBpC,EAAKmC,8BAA8BvG,KAAKsC;oCACvE8B,EAAK0B,wBAA0B;4BACvC1B,EAAK4E,qBAAuB;mBACrC5E,EAAK+B,UAAY;oBAChB/B,EAAKvC,UAAY;gBACrB4G,aAAkBC,WAAkBC,WAAgBC,UAAeC;qBAGxEC,CAAA,gDAAoD1E,EAAK4B,kBAClE,CAEAqD,MAAAA,GACE,OAAOP,CAAA;;UAED9I,KAAKgB,MAAMW,IAAI,CAACyC,EAAMyB,IAAU7F,KAAKuI,YAAYnE,EAAMyB;;KAG/D,GA5bWlG,EACJ2J,OAASC,CAAA;;;;;;;;;;;;;;;;;;;;;;KA0BuBC,EAAA,CAAtCC,EAAS,CAAEC,UAAW,gBA3BZ/J,EA2B4BgK,UAAA,YAAA,GAGvCH,EAAA,CADCC,EAAS,CAAE7D,KAAMgE,UA7BPjK,EA8BXgK,UAAA,cAAA,GAUIH,EAAA,CADHC,EAAS,CAAE7D,KAAMnE,SAvCP9B,EAwCPgK,UAAA,cAAA,GA6CaH,EAAA,CAAhBK,KArFUlK,EAqFMgK,UAAA,QAAA,GACAH,EAAA,CAAhBK,KAtFUlK,EAsFMgK,UAAA,YAAA,GAtFNhK,EAAN6J,EAAA,CADNM,EAAkB,qBACNnK"}
|
package/es/subject/single.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as r}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as o}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,p=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?l(t,s):t,n=e.length-1;n>=0;n--)(r=e[n])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&a(t,s,o),o};class d extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new d(e.message,e.code,e.field,e.row)}}const c=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,h=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;const u=e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;let x=class extends s{constructor(){super(...arguments),this.orderIndex=0,this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAnalysis=!0,this.type="single",this.answerCheckType=1,this.examAnswerRelationType=0,this.richTextContent="",this.analysis="",this.leastAnswerCount=2,this.examExpand="",this.customId="",this.examId=0,this.uploadImage=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this.modelValue="",this.useModel=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=2,this._answerCheckType=1,this._orderList=[],this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper");s&&!t.includes(s)&&(this._sortDropdownOpen=!1,this.requestUpdate())}}get answerList(){return this._answers}set answerList(e){const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>({...e})):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answerList")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick)}willUpdate(e){e.has("isEdit")&&this.isEdit&&this._syncProps(),(e.has("examExpand")||e.has("answerList"))&&this._syncExamExpand(),e.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this.leastAnswerCount||2,this._answerCheckType=this.answerCheckType||1,this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0),this.answerList?.length&&(this._answers=this.answerList.map(e=>({...e,title:e.title||"",isCorrect:!!e.isCorrect}))),this._syncExamExpand()}_syncExamExpand(){if(!this.examExpand||!this.answerList?.length)return;const e=this.examExpand.split(",");this._orderList=e.map(e=>{const t=this.answerList.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){"single"===this.type?(this._answers.forEach(e=>{e.isCorrect=!1}),e.isCorrect=t):e.isCorrect=t,this.requestUpdate()}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(e,t){const s=e.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[t].title=s.value,this.requestUpdate()}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",isCorrect:!1,customAnswerId:n()}])}_deleteAnswer(e){this._answers.length<3||this.isSave||(this._answers=this._answers.filter((t,s)=>s!==e))}_toggleSortItem(e){const t=this._orderList.indexOf(e);this._orderList=t>=0?this._orderList.filter(t=>t!==e):[...this._orderList,e],this.requestUpdate()}_removeSortItem(e){this._orderList=this._orderList.filter(t=>t!==e),this.requestUpdate()}_getSortOrder(e){const t=this._orderList.indexOf(this._label(e));return t>=0?t+1:null}async toJSON(){return new Promise((e,t)=>{const s={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._answerCheckType:this.answerCheckType||1,n=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,a=this.isEdit?this._analysis:this.analysis||"",l=this.isEdit?this._orderList.map(e=>e.charCodeAt(0)-65+1).join(","):this.examExpand||"",p=this.isEdit?this._showRichText:!!this.richTextContent,c=this.isEdit?this._richText:this.richTextContent||"",h=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();if(!i)return void t(new d("题目标题不能为空!","EMPTY_TITLE","title",s));if(!o)return void t(new d("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",s));let u="",x=!1,w=0;if("multiple"===this.type||"single"===this.type)r.forEach((e,t)=>{e.title?.trim()||(u+=`选项${String.fromCharCode(65+t)}未填写。`),e.isCorrect&&(x=!0,w++)});else if("sort"===this.type&&(h.length&&(x=!0),x&&h.length<n))return void t(new d(`排序题至少需要设置${n}项排序答案`,"SORT_COUNT_INVALID","orderList",s));if(u)return void t(new d(u,"ANSWER_EMPTY","answers",s));if(new Set(r.map(e=>e.title)).size!==r.length)return void t(new d("选项不能重复","DUPLICATE_ANSWERS","answers",s));if("multiple"===this.type){if(1===w)return void t(new d("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",s));if(x&&w<n)return void t(new d("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))}if((2===o||3===o)&&!x)return void t(new d("请设置支持选项","NO_CORRECT_ANSWER","answers",s));const m={answerType:this.type,title:i,answers:r.filter(e=>e.title).map((e,t)=>({...e,orderIndex:t+1})),examExpand:l,analysis:a,isSetCorrectAnswer:x,leastAnswerCount:n,examRichTextContent:p?c:"",examAnswerRelationType:this.examAnswerRelationType,isKey:this.isKey,answerCheckType:o};this.customId&&(m.customId=this.customId),e(m)})}validate(){const e=[],t={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._answerCheckType:this.answerCheckType||1,o=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,n=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();s||e.push(new d("题目标题不能为空!","EMPTY_TITLE","title",t)),r||e.push(new d("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",t));let a=!1,l=0;"multiple"===this.type||"single"===this.type?i.forEach((s,i)=>{s.title?.trim()||e.push(new d(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",t)),s.isCorrect&&(a=!0,l++)}):"sort"===this.type&&(n.length&&(a=!0),a&&n.length<o&&e.push(new d(`排序题至少需要设置${o}项排序答案`,"SORT_COUNT_INVALID","orderList",t)));return new Set(i.map(e=>e.title)).size!==i.length&&i.length>0&&e.push(new d("选项不能重复","DUPLICATE_ANSWERS","answers",t)),"multiple"===this.type&&(1===l&&i.length>0&&e.push(new d("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",t)),a&&l<o&&e.push(new d("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",t))),2!==r&&3!==r||a||e.push(new d("请设置支持选项","NO_CORRECT_ANSWER","answers",t)),e}_openResultDialog(e){this._resultDialogIndex=e,this._resultDialogValue=this._answers[e].resultItem||"",this._resultDialogOpen=!0}_saveResultDialog(){this._answers[this._resultDialogIndex].resultItem=this._resultDialogValue,this._resultDialogOpen=!1,this.requestUpdate()}_renderResultDialog(){if(!this._resultDialogOpen)return"";const t=this._label(this._resultDialogIndex);return e`
|
|
1
|
+
import{html as t,css as e,LitElement as s}from"lit";import{property as i}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as r}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as o}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,p=(t,e,s,i)=>{for(var r,o=i>1?void 0:i?l(e,s):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(i?r(e,s,o):r(o))||o);return i&&o&&a(e,s,o),o};class d extends Error{constructor(t){let e=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(t),this.code=e,this.field=s,this.row=i,this.name="SubjectError"}static from(t){return new d(t.message,t.code,t.field,t.row)}}const h=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,c=t`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;t`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;const u=t`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;let x=class extends s{constructor(){super(...arguments),this.orderIndex=0,this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAnalysis=!0,this.type="single",this.answerCheckType=1,this.examAnswerRelationType=0,this.richTextContent="",this.analysis="",this.leastAnswerCount=2,this.examExpand="",this.customId="",this.examId=0,this.uploadImage=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this.modelValue="",this.useModel=!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=2,this._answerCheckType=1,this._orderList=[],this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=t=>{const e=t.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper");s&&!e.includes(s)&&(this._sortDropdownOpen=!1,this.requestUpdate())}}get answerList(){return this._answers}set answerList(t){const e=Array.isArray(t)?t:[];this._answers=e.length?e.map(t=>({...t})):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answerList")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick),this._syncExternalProps(),this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0)}firstUpdated(){this._syncExternalProps(),this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick)}willUpdate(t){t.has("isEdit")&&this.isEdit&&this._syncProps(),(t.has("title")||t.has("answerList")||t.has("analysis")||t.has("leastAnswerCount")||t.has("answerCheckType"))&&this._syncExternalProps(),(t.has("examExpand")||t.has("answerList"))&&this._syncExamExpand(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncExternalProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this.leastAnswerCount||2,this._answerCheckType=this.answerCheckType||1,this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0),this.answerList?.length&&(this._answers=this.answerList.map(t=>({...t,title:t.title||"",isCorrect:!!t.isCorrect})))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this.leastAnswerCount||2,this._answerCheckType=this.answerCheckType||1,this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0),this.answerList?.length&&(this._answers=this.answerList.map(t=>({...t,title:t.title||"",isCorrect:!!t.isCorrect}))),this._syncExamExpand()}_syncExamExpand(){if(!this.examExpand||!this.answerList?.length)return;const t=this.examExpand.split(",");this._orderList=t.map(t=>{const e=this.answerList.find(e=>e.answerId?.toString()===t);return e?String.fromCharCode(65+e.orderIndex-1):t}).filter(Boolean)}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_label(t){return String.fromCharCode(65+t)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(t,e){"single"===this.type?(this._answers.forEach(t=>{t.isCorrect=!1}),t.isCorrect=e):t.isCorrect=e,this.requestUpdate()}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(t,e){const s=t.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[e].title=s.value,this.requestUpdate()}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",isCorrect:!1,customAnswerId:n()}])}_deleteAnswer(t){this._answers.length<3||this.isSave||(this._answers=this._answers.filter((e,s)=>s!==t))}_toggleSortItem(t){const e=this._orderList.indexOf(t);this._orderList=e>=0?this._orderList.filter(e=>e!==t):[...this._orderList,t],this.requestUpdate()}_removeSortItem(t){this._orderList=this._orderList.filter(e=>e!==t),this.requestUpdate()}_getSortOrder(t){const e=this._orderList.indexOf(this._label(t));return e>=0?e+1:null}async toJSON(){return new Promise((t,e)=>{const s={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._answerCheckType:this.answerCheckType||1,n=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,a=this.isEdit?this._analysis:this.analysis||"",l=this.isEdit?this._orderList.map(t=>t.charCodeAt(0)-65+1).join(","):this.examExpand||"",p=this.isEdit?this._showRichText:!!this.richTextContent,h=this.isEdit?this._richText:this.richTextContent||"",c=this.isEdit?this._orderList:(()=>{const t=this.examExpand;return t?t.split(",").map(t=>{const e=this.answerList?.find(e=>e.answerId?.toString()===t);return e?String.fromCharCode(65+e.orderIndex-1):t}).filter(Boolean):[]})();if(!i)return void e(new d("题目标题不能为空!","EMPTY_TITLE","title",s));if(!o)return void e(new d("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",s));let u="",x=!1,w=0;if("multiple"===this.type||"single"===this.type)r.forEach((t,e)=>{t.title?.trim()||(u+=`选项${String.fromCharCode(65+e)}未填写。`),t.isCorrect&&(x=!0,w++)});else if("sort"===this.type&&(c.length&&(x=!0),x&&c.length<n))return void e(new d(`排序题至少需要设置${n}项排序答案`,"SORT_COUNT_INVALID","orderList",s));if(u)return void e(new d(u,"ANSWER_EMPTY","answers",s));if(new Set(r.map(t=>t.title)).size!==r.length)return void e(new d("选项不能重复","DUPLICATE_ANSWERS","answers",s));if("multiple"===this.type){if(1===w)return void e(new d("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",s));if(x&&w<n)return void e(new d("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))}if((2===o||3===o)&&!x)return void e(new d("请设置支持选项","NO_CORRECT_ANSWER","answers",s));const m={answerType:String(this.type),title:i,answers:r.filter(t=>t.title).map((t,e)=>({...t,orderIndex:e+1})),examExpand:l,analysis:a,isSetCorrectAnswer:x,leastAnswerCount:n,examRichTextContent:p?h:"",examAnswerRelationType:this.examAnswerRelationType,isKey:this.isKey,answerCheckType:o};this.customId&&(m.customId=this.customId),t(m)})}validate(){const t=[],e={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._answerCheckType:this.answerCheckType||1,o=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,n=this.isEdit?this._orderList:(()=>{const t=this.examExpand;return t?t.split(",").map(t=>{const e=this.answerList?.find(e=>e.answerId?.toString()===t);return e?String.fromCharCode(65+e.orderIndex-1):t}).filter(Boolean):[]})();s||t.push(new d("题目标题不能为空!","EMPTY_TITLE","title",e)),r||t.push(new d("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",e));let a=!1,l=0;"multiple"===this.type||"single"===this.type?i.forEach((s,i)=>{s.title?.trim()||t.push(new d(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",e)),s.isCorrect&&(a=!0,l++)}):"sort"===this.type&&(n.length&&(a=!0),a&&n.length<o&&t.push(new d(`排序题至少需要设置${o}项排序答案`,"SORT_COUNT_INVALID","orderList",e)));return new Set(i.map(t=>t.title)).size!==i.length&&i.length>0&&t.push(new d("选项不能重复","DUPLICATE_ANSWERS","answers",e)),"multiple"===this.type&&(1===l&&i.length>0&&t.push(new d("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",e)),a&&l<o&&t.push(new d("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",e))),2!==r&&3!==r||a||t.push(new d("请设置支持选项","NO_CORRECT_ANSWER","answers",e)),t}_openResultDialog(t){this._resultDialogIndex=t,this._resultDialogValue=this._answers[t].resultItem||"",this._resultDialogOpen=!0}_saveResultDialog(){this._answers[this._resultDialogIndex].resultItem=this._resultDialogValue,this._resultDialogOpen=!1,this.requestUpdate()}_renderResultDialog(){if(!this._resultDialogOpen)return"";const e=this._label(this._resultDialogIndex);return t`
|
|
2
2
|
<div class="modal-backdrop" @click=${()=>{this._resultDialogOpen=!1}}>
|
|
3
|
-
<div class="modal" @click=${
|
|
3
|
+
<div class="modal" @click=${t=>t.stopPropagation()}>
|
|
4
4
|
<div class="modal-header">
|
|
5
|
-
<span class="modal-title">编辑结果项 — 选项 ${
|
|
5
|
+
<span class="modal-title">编辑结果项 — 选项 ${e}</span>
|
|
6
6
|
<button class="modal-close" @click=${()=>{this._resultDialogOpen=!1}}>✕</button>
|
|
7
7
|
</div>
|
|
8
8
|
<div class="modal-body">
|
|
9
9
|
<textarea rows="5" .value=${this._resultDialogValue}
|
|
10
|
-
@input=${
|
|
10
|
+
@input=${t=>{this._resultDialogValue=t.target.value}}
|
|
11
11
|
placeholder="请输入该选项的结果项内容"></textarea>
|
|
12
12
|
</div>
|
|
13
13
|
<div class="modal-footer">
|
|
@@ -16,107 +16,107 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
|
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
|
-
`}async _save(
|
|
19
|
+
`}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!function(t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(e),setTimeout(()=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},2500)}(t.message)}}_renderPreview(){const e="single"===this.type?"(单选题)":`(${this._titlePlaceholder}${this.leastAnswerCount?`至少选${this.leastAnswerCount}项${"sort"===this.type?"并排序":""}`:""})`,s=this.answerList;return t`
|
|
20
20
|
<div class="preview">
|
|
21
|
-
<div><span class="title">${this.orderIndex+1}.${this.title||""}${
|
|
22
|
-
${this.richTextContent?
|
|
21
|
+
<div><span class="title">${this.orderIndex+1}.${this.title||""}${e}</span></div>
|
|
22
|
+
${this.richTextContent?t`<div class="rich-text" .innerHTML=${this.richTextContent}></div>`:""}
|
|
23
23
|
<div class="preview-answer">
|
|
24
|
-
${s.map((
|
|
24
|
+
${s.map((e,s)=>t`
|
|
25
25
|
<label class="radio">
|
|
26
26
|
<input type="${"sort"===this.type?"checkbox":"radio"}" disabled />
|
|
27
|
-
<span class="order">${this._label(s)}.</span> ${
|
|
28
|
-
${"sort"!==this.type&&
|
|
29
|
-
${"sort"!==this.type&&1===this.examAnswerRelationType?
|
|
30
|
-
${"sort"!==this.type&&2===this.examAnswerRelationType?
|
|
27
|
+
<span class="order">${this._label(s)}.</span> ${e.title}
|
|
28
|
+
${"sort"!==this.type&&e.isCorrect?t`<span class="correct">(支持选项)</span>`:""}
|
|
29
|
+
${"sort"!==this.type&&1===this.examAnswerRelationType?t`<span class="result-info">${e.resultItem?"(已设置结果项)":"(未设置结果项)"}</span>`:""}
|
|
30
|
+
${"sort"!==this.type&&2===this.examAnswerRelationType?t`<span class="result-info">${e.answerRelations?.length?"(已设置关联)":"(未设置关联)"}</span>`:""}
|
|
31
31
|
</label>
|
|
32
32
|
`)}
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
|
-
`}_renderEdit(){return
|
|
35
|
+
`}_renderEdit(){return t`
|
|
36
36
|
<div class="flex-items-start">
|
|
37
37
|
<div class="label"><span>题目:</span></div>
|
|
38
38
|
<div style="flex:1">
|
|
39
39
|
<div class="el-input">
|
|
40
40
|
<textarea rows="2" .value=${this._title} ?disabled=${this.isSave}
|
|
41
41
|
maxlength=${this.TITLE_MAX}
|
|
42
|
-
@input=${
|
|
42
|
+
@input=${t=>this._onTitleInput(t)}
|
|
43
43
|
placeholder="【${this._titlePlaceholder}】请输入问题"></textarea>
|
|
44
44
|
<span class="char-counter">${this._title.length}/${this.TITLE_MAX}</span>
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
|
-
${["multiple","sort"].includes(this.type)?
|
|
49
|
+
${["multiple","sort"].includes(this.type)?t`
|
|
50
50
|
<div class="flex-items-start" style="margin-top:12px">
|
|
51
51
|
<div class="label"><span>设置:</span></div>
|
|
52
52
|
<select class="el-select" .value=${String(this._leastAnswerCount)} ?disabled=${this.isSave}
|
|
53
|
-
@change=${
|
|
54
|
-
${Array.from({length:Math.max(0,this._answers.length-1)},(e
|
|
55
|
-
<option value=${
|
|
53
|
+
@change=${t=>{this._leastAnswerCount=Number(t.target.value)}}>
|
|
54
|
+
${Array.from({length:Math.max(0,this._answers.length-1)},(t,e)=>e+2).map(e=>t`
|
|
55
|
+
<option value=${e} ?selected=${this._leastAnswerCount===e}>至少选择${e}项</option>
|
|
56
56
|
`)}
|
|
57
57
|
</select>
|
|
58
58
|
</div>
|
|
59
59
|
`:""}
|
|
60
60
|
|
|
61
61
|
<div class="answer-list">
|
|
62
|
-
${this._answers.map((
|
|
62
|
+
${this._answers.map((e,s)=>t`
|
|
63
63
|
<div class="answer-item">
|
|
64
64
|
<span class="label">${this._label(s)}.</span>
|
|
65
65
|
<div class="input">
|
|
66
|
-
<input type="text" .value=${
|
|
66
|
+
<input type="text" .value=${e.title} ?disabled=${this.isSave}
|
|
67
67
|
maxlength=${this.ANSWER_MAX}
|
|
68
|
-
@input=${
|
|
68
|
+
@input=${t=>this._onAnswerInput(t,s)}
|
|
69
69
|
placeholder="选项${this._label(s)}" />
|
|
70
|
-
<span class="char-counter">${
|
|
70
|
+
<span class="char-counter">${e.title.length}/${this.ANSWER_MAX}</span>
|
|
71
71
|
</div>
|
|
72
72
|
|
|
73
|
-
${"sort"===this.type&&null!==this._getSortOrder(s)?
|
|
73
|
+
${"sort"===this.type&&null!==this._getSortOrder(s)?t`<span class="sort-badge">第${this._getSortOrder(s)}位</span>`:""}
|
|
74
74
|
|
|
75
|
-
${["single","multiple"].includes(this.type)?
|
|
76
|
-
<label class="correct ${
|
|
77
|
-
<input type="checkbox" .checked=${
|
|
78
|
-
@change=${
|
|
75
|
+
${["single","multiple"].includes(this.type)?t`
|
|
76
|
+
<label class="correct ${e.isCorrect?"is-correct":""}">
|
|
77
|
+
<input type="checkbox" .checked=${e.isCorrect} ?disabled=${this.isSave}
|
|
78
|
+
@change=${t=>this._setCorrect(e,t.target.checked)} />
|
|
79
79
|
支持选项
|
|
80
80
|
</label>
|
|
81
81
|
`:""}
|
|
82
82
|
|
|
83
83
|
<span class="icon ${this.isSave?"disabled":""}"
|
|
84
84
|
@click=${()=>this._addAnswer()}>
|
|
85
|
-
${
|
|
85
|
+
${h}
|
|
86
86
|
</span>
|
|
87
87
|
<span class="icon ${this.isSave||this._answers.length<3?"disabled":""}"
|
|
88
88
|
@click=${()=>this._deleteAnswer(s)}>
|
|
89
|
-
${
|
|
89
|
+
${c}
|
|
90
90
|
</span>
|
|
91
91
|
|
|
92
|
-
${1===this.examAnswerRelationType&&"sort"!==this.type?
|
|
93
|
-
<span class="link" @click=${()=>this._openResultDialog(s)}>${
|
|
92
|
+
${1===this.examAnswerRelationType&&"sort"!==this.type?t`
|
|
93
|
+
<span class="link" @click=${()=>this._openResultDialog(s)}>${e.resultItem?"编辑结果":"添加结果"}</span>
|
|
94
94
|
`:""}
|
|
95
|
-
${2===this.examAnswerRelationType&&"sort"!==this.type?
|
|
95
|
+
${2===this.examAnswerRelationType&&"sort"!==this.type?t`
|
|
96
96
|
<span class="link">关联检查</span>
|
|
97
97
|
`:""}
|
|
98
98
|
</div>
|
|
99
99
|
`)}
|
|
100
100
|
</div>
|
|
101
101
|
|
|
102
|
-
${"sort"===this.type?
|
|
102
|
+
${"sort"===this.type?t`
|
|
103
103
|
<div class="flex-items-center" style="margin-top:12px">
|
|
104
104
|
<div class="label"><span>排序答案:</span></div>
|
|
105
105
|
<div style="flex:1">
|
|
106
106
|
<div class="multi-select-wrapper">
|
|
107
107
|
<div class="multi-select ${this._sortDropdownOpen?"focused":""} ${this.isSave?"disabled":""}"
|
|
108
108
|
@click=${()=>{this.isSave||(this._sortDropdownOpen=!this._sortDropdownOpen,this.requestUpdate())}}>
|
|
109
|
-
${this._orderList.length>0?this._orderList.map(t
|
|
109
|
+
${this._orderList.length>0?this._orderList.map(e=>t`
|
|
110
110
|
<span class="tag">
|
|
111
|
-
${
|
|
112
|
-
<span class="tag-close" @click=${
|
|
111
|
+
${e}
|
|
112
|
+
<span class="tag-close" @click=${t=>{t.stopPropagation(),this._removeSortItem(e)}}>✕</span>
|
|
113
113
|
</span>
|
|
114
|
-
`):
|
|
114
|
+
`):t`<span class="placeholder">请按顺序选择排序答案</span>`}
|
|
115
115
|
<span class="arrow">${u}</span>
|
|
116
116
|
</div>
|
|
117
|
-
${this._sortDropdownOpen?
|
|
117
|
+
${this._sortDropdownOpen?t`
|
|
118
118
|
<div class="multi-select-dropdown">
|
|
119
|
-
${this._answers.map((
|
|
119
|
+
${this._answers.map((e,s)=>t`
|
|
120
120
|
<div class="multi-select-option ${this._orderList.includes(this._label(s))?"selected":""}"
|
|
121
121
|
@click=${()=>{this._toggleSortItem(this._label(s)),this.requestUpdate()}}>
|
|
122
122
|
${this._label(s)}
|
|
@@ -129,7 +129,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
|
|
|
129
129
|
</div>
|
|
130
130
|
`:""}
|
|
131
131
|
|
|
132
|
-
${this._showRichText?
|
|
132
|
+
${this._showRichText?t`
|
|
133
133
|
<div class="flex-items-start" style="margin-top:12px">
|
|
134
134
|
<div class="label"><span>富文本:</span></div>
|
|
135
135
|
<div style="flex:1">
|
|
@@ -137,28 +137,28 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
|
|
|
137
137
|
.content=${this._richText}
|
|
138
138
|
.uploadImage=${this.uploadImage}
|
|
139
139
|
?is-edit=${!0}
|
|
140
|
-
@input=${
|
|
140
|
+
@input=${t=>{this._richText=t.target.getContent()}}
|
|
141
141
|
></qxs-blocksuite-editor>
|
|
142
142
|
<div class="flex-justify-end" style="margin-top:8px"><span class="el-link danger" @click=${()=>{this._showRichText=!1,this._richText=""}}>删除富文本</span></div>
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
145
|
`:""}
|
|
146
146
|
|
|
147
|
-
${this.showAnalysis?
|
|
147
|
+
${this.showAnalysis?t`
|
|
148
148
|
<div class="flex-items-start" style="margin-top:12px">
|
|
149
149
|
<div class="label"><span>解析:</span></div>
|
|
150
150
|
<div style="flex:1">
|
|
151
151
|
<textarea rows="2" .value=${this._analysis}
|
|
152
|
-
@input=${
|
|
152
|
+
@input=${t=>{this._analysis=t.target.value}}
|
|
153
153
|
placeholder="请输入题目解析"></textarea>
|
|
154
154
|
</div>
|
|
155
155
|
</div>
|
|
156
156
|
`:""}
|
|
157
|
-
`}render(){return
|
|
157
|
+
`}render(){return t`
|
|
158
158
|
<qxs-subject-layout ?show-edit=${this.isEdit}>
|
|
159
159
|
<div slot="preview">${this._renderPreview()}</div>
|
|
160
160
|
<div slot="edit">${this._renderEdit()}</div>
|
|
161
|
-
${this.showAction?
|
|
161
|
+
${this.showAction?t`
|
|
162
162
|
<qxs-subject-action
|
|
163
163
|
?is-edit=${this.isEdit}
|
|
164
164
|
?is-set=${this.isSet}
|
|
@@ -169,15 +169,15 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
|
|
|
169
169
|
@delete=${()=>this._emit("delete")}
|
|
170
170
|
@save=${this._save}
|
|
171
171
|
@edit=${()=>this._emit("edit")}
|
|
172
|
-
@add=${
|
|
173
|
-
@set-key=${
|
|
174
|
-
@set-answer-setting=${
|
|
172
|
+
@add=${t=>this._emit("add",t.detail)}
|
|
173
|
+
@set-key=${t=>{this._emit("set-key",t.detail)}}
|
|
174
|
+
@set-answer-setting=${t=>{this._answerCheckType=t.detail.value}}
|
|
175
175
|
@on-show-rich-text=${()=>{this._showRichText=!0}}
|
|
176
176
|
></qxs-subject-action>
|
|
177
177
|
`:""}
|
|
178
178
|
</qxs-subject-layout>
|
|
179
179
|
${this._renderResultDialog()}
|
|
180
|
-
`}};x.styles=
|
|
180
|
+
`}};x.styles=e`
|
|
181
181
|
:host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
|
|
182
182
|
*, ::before, ::after { box-sizing: border-box; }
|
|
183
183
|
|
|
@@ -315,5 +315,5 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i}from"..
|
|
|
315
315
|
.modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }
|
|
316
316
|
.modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }
|
|
317
317
|
.modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }
|
|
318
|
-
`,p([i({type:Number,attribute:"order-index"})],x.prototype,"orderIndex",2),p([i({type:Boolean,attribute:"is-edit"})],x.prototype,"isEdit",2),p([i({type:Boolean,attribute:"is-save"})],x.prototype,"isSave",2),p([i({type:Boolean,attribute:"is-set"})],x.prototype,"isSet",2),p([i({type:Boolean,attribute:"is-key"})],x.prototype,"isKey",2),p([i({type:Boolean,attribute:"show-action"})],x.prototype,"showAction",2),p([i({type:Boolean,attribute:"show-analysis"})],x.prototype,"showAnalysis",2),p([i({type
|
|
318
|
+
`,p([i({type:Number,attribute:"order-index"})],x.prototype,"orderIndex",2),p([i({type:Boolean,attribute:"is-edit"})],x.prototype,"isEdit",2),p([i({type:Boolean,attribute:"is-save"})],x.prototype,"isSave",2),p([i({type:Boolean,attribute:"is-set"})],x.prototype,"isSet",2),p([i({type:Boolean,attribute:"is-key"})],x.prototype,"isKey",2),p([i({type:Boolean,attribute:"show-action"})],x.prototype,"showAction",2),p([i({type:Boolean,attribute:"show-analysis"})],x.prototype,"showAnalysis",2),p([i({attribute:"question-type",reflect:!0})],x.prototype,"type",2),p([i({type:Number,attribute:"answer-check-type"})],x.prototype,"answerCheckType",2),p([i({type:Number,attribute:"exam-answer-relation-type"})],x.prototype,"examAnswerRelationType",2),p([i({type:String,attribute:"rich-text-content"})],x.prototype,"richTextContent",2),p([i({type:String})],x.prototype,"analysis",2),p([i({type:Number,attribute:"least-answer-count"})],x.prototype,"leastAnswerCount",2),p([i({type:String,attribute:"exam-expand"})],x.prototype,"examExpand",2),p([i({type:String,attribute:"custom-id"})],x.prototype,"customId",2),p([i({type:Number,attribute:"exam-id"})],x.prototype,"examId",2),p([i({type:Object})],x.prototype,"uploadImage",2),p([i({type:Array,attribute:"answer-list"})],x.prototype,"answerList",1),p([i({type:String,attribute:"model-value"})],x.prototype,"modelValue",2),p([i({type:Boolean,attribute:"use-model"})],x.prototype,"useModel",2),p([r()],x.prototype,"_answers",2),p([i({type:String})],x.prototype,"title",2),p([r()],x.prototype,"_title",2),p([r()],x.prototype,"_analysis",2),p([r()],x.prototype,"_richText",2),p([r()],x.prototype,"_showRichText",2),p([r()],x.prototype,"_leastAnswerCount",2),p([r()],x.prototype,"_answerCheckType",2),p([r()],x.prototype,"_orderList",2),p([r()],x.prototype,"_resultDialogOpen",2),p([r()],x.prototype,"_resultDialogIndex",2),p([r()],x.prototype,"_resultDialogValue",2),p([r()],x.prototype,"_sortDropdownOpen",2),x=p([o("qxs-subject-single")],x);export{x as QxsSubjectSingle,d as SubjectError};
|
|
319
319
|
//# sourceMappingURL=single.mjs.map
|