@qxs-bns/components-wc 0.0.29 → 0.0.31
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 +166 -357
- package/es/editor/blocksuite-editor.mjs.map +1 -1
- package/es/editor/toolbar.mjs +2 -0
- package/es/editor/toolbar.mjs.map +1 -0
- package/es/subject/action.mjs +7 -8
- package/es/subject/action.mjs.map +1 -1
- package/es/subject/blank-fill.mjs +243 -132
- package/es/subject/blank-fill.mjs.map +1 -1
- package/es/subject/layout.mjs +4 -4
- package/es/subject/layout.mjs.map +1 -1
- package/es/subject/page-end.mjs +1 -1
- package/es/subject/page-end.mjs.map +1 -1
- package/es/subject/scale.mjs +165 -126
- package/es/subject/scale.mjs.map +1 -1
- package/es/subject/shared-methods.mjs +2 -0
- package/es/subject/shared-methods.mjs.map +1 -0
- package/es/subject/shared-styles.mjs +75 -0
- package/es/subject/shared-styles.mjs.map +1 -0
- package/es/subject/single.mjs +243 -187
- package/es/subject/single.mjs.map +1 -1
- package/es/subject/sortable.mjs +7 -7
- package/es/subject/sortable.mjs.map +1 -1
- package/es/subject/text-fill.mjs +273 -138
- package/es/subject/text-fill.mjs.map +1 -1
- package/es/subject/title-prefix.mjs +2 -0
- package/es/subject/title-prefix.mjs.map +1 -0
- package/lib/editor/blocksuite-editor.cjs +166 -357
- package/lib/editor/blocksuite-editor.cjs.map +1 -1
- package/lib/editor/toolbar.cjs +2 -0
- package/lib/editor/toolbar.cjs.map +1 -0
- package/lib/subject/action.cjs +33 -34
- package/lib/subject/action.cjs.map +1 -1
- package/lib/subject/blank-fill.cjs +247 -136
- package/lib/subject/blank-fill.cjs.map +1 -1
- package/lib/subject/layout.cjs +2 -2
- package/lib/subject/layout.cjs.map +1 -1
- package/lib/subject/page-end.cjs +2 -2
- package/lib/subject/page-end.cjs.map +1 -1
- package/lib/subject/scale.cjs +165 -126
- package/lib/subject/scale.cjs.map +1 -1
- package/lib/subject/shared-methods.cjs +2 -0
- package/lib/subject/shared-methods.cjs.map +1 -0
- package/lib/subject/shared-styles.cjs +75 -0
- package/lib/subject/shared-styles.cjs.map +1 -0
- package/lib/subject/single.cjs +243 -187
- package/lib/subject/single.cjs.map +1 -1
- package/lib/subject/sortable.cjs +1 -1
- package/lib/subject/sortable.cjs.map +1 -1
- package/lib/subject/text-fill.cjs +273 -138
- package/lib/subject/text-fill.cjs.map +1 -1
- package/lib/subject/title-prefix.cjs +2 -0
- package/lib/subject/title-prefix.cjs.map +1 -0
- package/package.json +1 -1
package/es/subject/scale.mjs
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import{html as t,css as e,LitElement as i}from"lit";import{property as s,state 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 m}from"./shared-styles.mjs";import{SubjectError as y,trimText as v}from"./single.mjs";import{sortingCardStyles as g,renderSortingCard as _}from"./sorting-card.mjs";import{SubjectType as b,SubjectTypeLabel as f}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 L=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 y("量表题选项数量必须在 3-5 个之间!","ANSWER_COUNT_INVALID","answers",t)}async toJSON(){return new Promise((t,e)=>{const i={customId:this["custom-id"]||void 0,answerType:b.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 y("题目标题不能为空!","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 y(`选项${String.fromCharCode(65+t)}未填写。`,"ANSWER_EMPTY","answers",i));if(0===o.length)return void e(new y("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",i));const l={answerType:b.SCALE,examTypeEnum:b.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:b.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 y("题目标题不能为空!","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 y(`选项${String.fromCharCode(65+s)}未填写`,"ANSWER_EMPTY","answers",e))}),0===r.length&&t.push(new y("行标题不能为空!","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
|
-
<
|
|
4
|
-
|
|
3
|
+
<div class="preview-header">
|
|
4
|
+
<div class="preview-title-row">
|
|
5
|
+
<span class="title">${r}</span>
|
|
6
|
+
<span class="preview-type">量表题</span>
|
|
7
|
+
</div>
|
|
8
|
+
${this["show-rich-text"]&&this["rich-text-content"]?t`<div class="rich-text" .innerHTML=${this["rich-text-content"]}></div>`:""}
|
|
9
|
+
</div>
|
|
5
10
|
<div class="scale-table-wrap">
|
|
6
11
|
<table class="scale-table">
|
|
7
12
|
<thead>
|
|
8
13
|
<tr>
|
|
9
|
-
<th style="width:${s}%"
|
|
14
|
+
<th style="width:${s}%">问题</th>
|
|
10
15
|
${e.map(e=>t`<th style="width:${s}%">${e.title}</th>`)}
|
|
11
16
|
</tr>
|
|
12
17
|
</thead>
|
|
@@ -22,103 +27,114 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
22
27
|
</div>
|
|
23
28
|
</div>
|
|
24
29
|
`}_renderEdit(){return t`
|
|
25
|
-
<div class="
|
|
26
|
-
<div class="
|
|
27
|
-
|
|
28
|
-
<div class="
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
<div class="edit-form">
|
|
31
|
+
<div class="edit-row">
|
|
32
|
+
<div class="label"><span>题目:</span></div>
|
|
33
|
+
<div class="row-body">
|
|
34
|
+
<div class="el-input">
|
|
35
|
+
<textarea
|
|
36
|
+
rows="2"
|
|
37
|
+
.value=${this._title}
|
|
38
|
+
maxlength=${this.TITLE_MAX}
|
|
39
|
+
@input=${t=>this._onTitleInput(t)}
|
|
40
|
+
placeholder="【量表题】请输入问题"
|
|
41
|
+
></textarea>
|
|
42
|
+
<span class="char-counter">${this._title.length}/${this.TITLE_MAX}</span>
|
|
43
|
+
</div>
|
|
37
44
|
</div>
|
|
38
45
|
</div>
|
|
39
|
-
</div>
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
<slot name="business-tag"></slot>
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<div class="answer-item">
|
|
58
|
-
<span class="label">${String.fromCharCode(65+i)}.</span>
|
|
59
|
-
<div class="input">
|
|
60
|
-
<input
|
|
61
|
-
type="text"
|
|
62
|
-
.value=${e.title}
|
|
63
|
-
maxlength="10"
|
|
64
|
-
@input=${t=>{const e=t.target.value;this._answers=this._answers.map((t,s)=>s===i?{...t,title:e}:t)}}
|
|
65
|
-
placeholder="选项${i+1}"
|
|
66
|
-
/>
|
|
49
|
+
<div class="edit-row">
|
|
50
|
+
<div class="label"><span>量表内容:</span></div>
|
|
51
|
+
<div class="row-body">
|
|
52
|
+
<div class="edit-grid">
|
|
53
|
+
<div class="edit-column">
|
|
54
|
+
<div class="edit-column-title">行标题</div>
|
|
55
|
+
<div class="el-input">
|
|
56
|
+
<textarea
|
|
57
|
+
class="row-title-textarea"
|
|
58
|
+
.value=${this._rowTitle}
|
|
59
|
+
@input=${t=>{this._rowTitle=t.target.value}}
|
|
60
|
+
@keydown=${t=>{t.stopPropagation()}}
|
|
61
|
+
placeholder="请输入行标题"
|
|
62
|
+
></textarea>
|
|
67
63
|
</div>
|
|
68
|
-
<
|
|
69
|
-
class="icon"
|
|
70
|
-
@click=${()=>{this._answers.length<5&&(this._answers=[...this._answers,{title:""}])}}
|
|
71
|
-
>${f}</span>
|
|
72
|
-
<span
|
|
73
|
-
class="icon ${this._answers.length<3?"disabled":""}"
|
|
74
|
-
@click=${()=>{this._answers.length>3&&(this._answers=this._answers.filter((t,e)=>e!==i))}}
|
|
75
|
-
>${g}</span>
|
|
64
|
+
<div class="edit-note">一行一个标题,预览时会自动整理空白行。</div>
|
|
76
65
|
</div>
|
|
77
|
-
|
|
66
|
+
<div class="edit-column">
|
|
67
|
+
<div class="edit-column-title">评分选项</div>
|
|
68
|
+
${this._answers.map((e,i)=>t`
|
|
69
|
+
<div class="answer-item">
|
|
70
|
+
<span class="label">${String.fromCharCode(65+i)}.</span>
|
|
71
|
+
<div class="input">
|
|
72
|
+
<input
|
|
73
|
+
type="text"
|
|
74
|
+
.value=${e.title}
|
|
75
|
+
maxlength="10"
|
|
76
|
+
@input=${t=>{const e=t.target.value;this._answers=this._answers.map((t,s)=>s===i?{...t,title:e}:t)}}
|
|
77
|
+
placeholder="选项${i+1}"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
<span
|
|
81
|
+
class="icon"
|
|
82
|
+
@click=${()=>{this._answers.length<5&&(this._answers=[...this._answers,{title:""}])}}
|
|
83
|
+
>${q}</span>
|
|
84
|
+
<span
|
|
85
|
+
class="icon ${this._answers.length<3?"disabled":""}"
|
|
86
|
+
@click=${()=>{this._answers.length>3&&(this._answers=this._answers.filter((t,e)=>e!==i))}}
|
|
87
|
+
>${C}</span>
|
|
88
|
+
</div>
|
|
89
|
+
`)}
|
|
90
|
+
<div class="edit-note">量表题需保持 3-5 个选项,保存时会校验。</div>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
78
93
|
</div>
|
|
79
94
|
</div>
|
|
80
|
-
</div>
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
${this["show-rich-text"]&&this._showRichText?t`
|
|
97
|
+
<div class="edit-row">
|
|
98
|
+
<div class="label"><span>副文本:</span></div>
|
|
99
|
+
<div class="row-body">
|
|
100
|
+
<slot name="sub-text">
|
|
101
|
+
<qxs-blocksuite-editor
|
|
102
|
+
.content=${this._richText}
|
|
103
|
+
.toolbar=${a}
|
|
104
|
+
.upload-image=${this["upload-image"]}
|
|
105
|
+
?is-edit=${!0}
|
|
106
|
+
@input=${t=>{this._richText=t.target.getContent()}}
|
|
107
|
+
></qxs-blocksuite-editor>
|
|
108
|
+
</slot>
|
|
109
|
+
${this["show-action"]?"":t`
|
|
110
|
+
<div class="flex-justify-end" style="margin-top:8px">
|
|
111
|
+
<span
|
|
112
|
+
class="el-link danger"
|
|
113
|
+
@click=${()=>{this._showRichText=!1,this._richText=""}}
|
|
114
|
+
>删除富文本</span>
|
|
115
|
+
</div>
|
|
116
|
+
`}
|
|
117
|
+
</div>
|
|
102
118
|
</div>
|
|
103
|
-
|
|
104
|
-
`:""}
|
|
119
|
+
`:""}
|
|
105
120
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
${this["show-analysis"]?t`
|
|
122
|
+
<div class="edit-row">
|
|
123
|
+
<div class="label"><span>解析:</span></div>
|
|
124
|
+
<div class="row-body">
|
|
125
|
+
<div class="el-input">
|
|
126
|
+
<textarea
|
|
127
|
+
rows="2"
|
|
128
|
+
.value=${this._analysis}
|
|
129
|
+
@input=${t=>{this._analysis=t.target.value}}
|
|
130
|
+
placeholder="请输入题目解析"
|
|
131
|
+
></textarea>
|
|
132
|
+
</div>
|
|
117
133
|
</div>
|
|
118
134
|
</div>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
`}_renderSorting(){const t=
|
|
135
|
+
`:""}
|
|
136
|
+
</div>
|
|
137
|
+
`}_renderSorting(){const t=v(this["is-edit"]?this._title:this.title||"")||"未命名题目",e=c(this["subject-prefix"],this["order-index"],t);return _(e,f[b.SCALE]||b.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`
|
|
122
138
|
<qxs-subject-layout .show-edit=${this["is-edit"]}>
|
|
123
139
|
${e}
|
|
124
140
|
${this["show-action"]?t`
|
|
@@ -141,31 +157,21 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
141
157
|
`:""}
|
|
142
158
|
<slot name="action"></slot>
|
|
143
159
|
</qxs-subject-layout>
|
|
144
|
-
`}};
|
|
145
|
-
:host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
|
|
146
|
-
*, ::before, ::after { box-sizing: border-box; }
|
|
147
|
-
|
|
148
|
-
.preview { padding: 12px 0; }
|
|
149
|
-
.preview .title { font-size: 14px; color: #303133; }
|
|
150
|
-
.preview .rich-text { margin-top: 8px; }
|
|
151
|
-
.preview .rich-text img { max-width: 100%; }
|
|
152
|
-
.preview .rich-text img[data-align="left"] { display: block !important; margin: 0 auto 0 0 !important; }
|
|
153
|
-
.preview .rich-text img[data-align="center"] { display: block !important; margin: 0 auto !important; }
|
|
154
|
-
.preview .rich-text img[data-align="right"] { display: block !important; margin: 0 0 0 auto !important; }
|
|
160
|
+
`}};L.styles=[g,p,u,w,x,m,e`
|
|
155
161
|
.scale-table-wrap {
|
|
156
|
-
margin-top:
|
|
157
|
-
background: #fff;
|
|
162
|
+
margin-top: 18px;
|
|
158
163
|
overflow: hidden;
|
|
159
164
|
}
|
|
160
|
-
.scale-table { width: 100%; border-collapse: collapse; font-size:
|
|
161
|
-
.scale-table th, .scale-table td { border: 1px solid #
|
|
162
|
-
.scale-table th {
|
|
165
|
+
.scale-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; color: #4b5563; }
|
|
166
|
+
.scale-table th, .scale-table td { border-bottom: 1px solid #eef2f7; padding: 10px 8px; text-align: center; vertical-align: middle; }
|
|
167
|
+
.scale-table thead th { font-size: 12px; font-weight: 600; color: #8b95a7; }
|
|
163
168
|
.scale-table td:first-child,
|
|
164
169
|
.scale-table th:first-child {
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
color: #303133;
|
|
171
|
+
text-align: left;
|
|
167
172
|
font-weight: 600;
|
|
168
173
|
}
|
|
174
|
+
.scale-table tbody tr:last-child td { border-bottom: none; }
|
|
169
175
|
.scale-table input[type="radio"] {
|
|
170
176
|
accent-color: #3D61E3;
|
|
171
177
|
}
|
|
@@ -173,33 +179,49 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
173
179
|
.flex { display: flex; }
|
|
174
180
|
.flex-items-start { display: flex; align-items: flex-start; }
|
|
175
181
|
.flex-justify-end { display: flex; justify-content: flex-end; }
|
|
176
|
-
.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
.edit-grid {
|
|
183
|
+
display: grid;
|
|
184
|
+
grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
|
|
185
|
+
gap: 20px;
|
|
186
|
+
}
|
|
187
|
+
.edit-column {
|
|
188
|
+
min-width: 0;
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: column;
|
|
191
|
+
gap: 10px;
|
|
192
|
+
}
|
|
193
|
+
.edit-column-title {
|
|
194
|
+
font-size: 12px;
|
|
195
|
+
line-height: 1.4;
|
|
196
|
+
font-weight: 600;
|
|
197
|
+
color: #8b95a7;
|
|
198
|
+
letter-spacing: 0.02em;
|
|
199
|
+
}
|
|
200
|
+
.edit-note {
|
|
201
|
+
font-size: 12px;
|
|
202
|
+
line-height: 1.6;
|
|
203
|
+
color: #909399;
|
|
182
204
|
}
|
|
183
|
-
textarea:focus, input[type="text"]:focus { border-color: #3D61E3; outline: none; }
|
|
184
|
-
textarea:disabled, input[type="text"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }
|
|
185
205
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
206
|
+
textarea, input[type="text"] { white-space: pre-wrap; }
|
|
207
|
+
input[type="text"] {
|
|
208
|
+
border: 1px solid #dcdfe6; border-radius: 6px; padding: 7px 11px;
|
|
209
|
+
font-size: 13px; font-family: inherit; width: 100%; transition: border-color .2s;
|
|
210
|
+
line-height: 1.5; display: block; box-sizing: border-box;
|
|
191
211
|
}
|
|
212
|
+
input[type="text"]:focus { border-color: #3D61E3; outline: none; }
|
|
213
|
+
input[type="text"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }
|
|
192
214
|
|
|
193
215
|
.el-link { color: #3D61E3; cursor: pointer; font-size: 12px; }
|
|
194
216
|
.el-link.danger { color: #f56c6c; }
|
|
195
217
|
|
|
196
|
-
.answer-item { display: flex; align-items: center;
|
|
197
|
-
.answer-item .label { min-width:
|
|
198
|
-
.answer-item .input { flex: 1; max-width:
|
|
218
|
+
.answer-item { display: flex; align-items: center; gap: 8px; }
|
|
219
|
+
.answer-item .label { min-width: 28px; font-size: 13px; font-weight: 600; color: #6b7280; letter-spacing: 0; }
|
|
220
|
+
.answer-item .input { flex: 1; max-width: 220px; }
|
|
199
221
|
.answer-item .input input {
|
|
200
|
-
height:
|
|
222
|
+
height: 36px; padding: 0 10px;
|
|
201
223
|
font-size: 13px; line-height: 32px;
|
|
202
|
-
border: 1px solid #dcdfe6; border-radius:
|
|
224
|
+
border: 1px solid #dcdfe6; border-radius: 6px; width: 100%;
|
|
203
225
|
transition: border-color .2s; box-sizing: border-box;
|
|
204
226
|
}
|
|
205
227
|
.answer-item .input input:focus { border-color: #3D61E3; outline: none; }
|
|
@@ -214,6 +236,23 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
214
236
|
.answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }
|
|
215
237
|
.answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }
|
|
216
238
|
|
|
217
|
-
.row-title-textarea { height:
|
|
218
|
-
|
|
239
|
+
.row-title-textarea { min-height: 220px; }
|
|
240
|
+
|
|
241
|
+
@media (max-width: 720px) {
|
|
242
|
+
.edit-row {
|
|
243
|
+
flex-direction: column;
|
|
244
|
+
gap: 8px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.edit-row > .label {
|
|
248
|
+
min-width: 0;
|
|
249
|
+
padding-top: 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.edit-grid {
|
|
253
|
+
grid-template-columns: 1fr;
|
|
254
|
+
gap: 16px;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
`],A([s({type:Number,attribute:"order-index"})],L.prototype,"order-index",2),A([s({type:String,attribute:"subject-prefix"})],L.prototype,"subject-prefix",2),A([s({type:String})],L.prototype,"title",2),A([s({type:String,attribute:"custom-id"})],L.prototype,"custom-id",2),A([s({type:Boolean,attribute:"is-edit"})],L.prototype,"is-edit",2),A([s({type:Boolean,attribute:"is-save"})],L.prototype,"is-save",2),A([s({type:Boolean,attribute:"is-set"})],L.prototype,"is-set",2),A([s({type:Boolean,attribute:"show-action"})],L.prototype,"show-action",2),A([s({type:Boolean,attribute:"show-add"})],L.prototype,"show-add",2),A([s({type:Boolean,attribute:"hide-add-rich-text"})],L.prototype,"hide-add-rich-text",2),A([s({type:Boolean,attribute:"show-rich-text"})],L.prototype,"show-rich-text",2),A([s({type:Boolean,attribute:"show-delete-action"})],L.prototype,"show-delete-action",2),A([s({type:Boolean,attribute:"show-save-action"})],L.prototype,"show-save-action",2),A([s({type:Boolean,reflect:!0})],L.prototype,"sorting",2),A([s({type:Boolean,attribute:"show-analysis"})],L.prototype,"show-analysis",2),A([s({type:String})],L.prototype,"analysis",2),A([s({type:String,attribute:"rich-text-content"})],L.prototype,"rich-text-content",2),A([s({type:Number,attribute:"exam-answer-relation-type"})],L.prototype,"exam-answer-relation-type",2),A([s({type:Object,attribute:"upload-image"})],L.prototype,"upload-image",2),A([s({type:Array,attribute:"answer-list"})],L.prototype,"answer-list",1),A([s({type:Array,attribute:"scale-question-list"})],L.prototype,"scale-question-list",1),A([s({type:Array,attribute:"scale-questions"})],L.prototype,"scale-questions",1),A([r()],L.prototype,"_answers",2),A([r()],L.prototype,"_scaleQuestions",2),A([r()],L.prototype,"_rowTitle",2),A([r()],L.prototype,"_title",2),A([r()],L.prototype,"_analysis",2),A([r()],L.prototype,"_showRichText",2),A([r()],L.prototype,"_richText",2),A([s({type:String,attribute:"model-value"})],L.prototype,"model-value",2),A([s({type:Boolean,attribute:"use-model"})],L.prototype,"use-model",2),L=A([o("qxs-scale")],L);export{L as QxsScale};
|
|
219
258
|
//# sourceMappingURL=scale.mjs.map
|
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 { 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\nfunction showToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',\n padding: '10px 20px', borderRadius: '4px', fontSize: '13px', color: '#fff',\n background: '#f56c6c', zIndex: '99999', boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s', opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => {\n el.style.opacity = '0'\n setTimeout(() => el.remove(), 300)\n }, 2500)\n}\n\n@safeCustomElement('qxs-scale')\nexport class QxsScale extends LitElement {\n static styles = [sortingCardStyles, css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .preview { padding: 12px 0; }\n .preview .title { font-size: 14px; color: #303133; }\n .preview .rich-text { margin-top: 8px; }\n .preview .rich-text img { max-width: 100%; }\n .preview .rich-text img[data-align=\"left\"] { display: block !important; margin: 0 auto 0 0 !important; }\n .preview .rich-text img[data-align=\"center\"] { display: block !important; margin: 0 auto !important; }\n .preview .rich-text img[data-align=\"right\"] { display: block !important; margin: 0 0 0 auto !important; }\n .scale-table-wrap {\n margin-top: 12px;\n background: #fff;\n overflow: hidden;\n }\n .scale-table { width: 100%; border-collapse: collapse; font-size: 12px; }\n .scale-table th, .scale-table td { border: 1px solid #e4e7ed; padding: 8px 6px; text-align: center; }\n .scale-table th { background: #f5f7fa; color: #909399; }\n .scale-table td:first-child,\n .scale-table th:first-child {\n background: #fbfcff;\n color: #606266;\n font-weight: 600;\n }\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 .label { min-width: 60px; font-size: 13px; color: #606266; }\n\n textarea, input[type=\"text\"] {\n border: 1px solid #dcdfe6; border-radius: 3px; padding: 5px 11px;\n font-size: 13px; font-family: inherit; width: 100%; resize: none; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box; white-space: pre-wrap;\n }\n textarea:focus, input[type=\"text\"]:focus { border-color: #3D61E3; outline: none; }\n textarea:disabled, input[type=\"text\"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n\n .el-input { position: relative; display: block; }\n .el-input textarea { padding-bottom: 24px; }\n .el-input .char-counter {\n position: absolute; right: 12px; bottom: 8px;\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; }\n .el-link.danger { color: #f56c6c; }\n\n .answer-item { display: flex; align-items: center; margin-top: 6px; }\n .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }\n .answer-item .input { flex: 1; max-width: 200px; }\n .answer-item .input input {\n height: 32px; padding: 0 8px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n transition: border-color .2s; box-sizing: border-box;\n }\n .answer-item .input input:focus { border-color: #3D61E3; outline: none; }\n\n .answer-item .icon {\n margin-left: 6px; cursor: pointer; display: inline-flex;\n align-items: center; justify-content: center;\n width: 24px; height: 24px; border-radius: 4px;\n border: 1px solid #dcdfe6; background: #fff; color: #909399;\n transition: all 0.2s;\n }\n .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }\n\n .row-title-textarea { height: 200px; }\n `]\n\n @property({ type: Number, attribute: 'order-index' }) 'order-index' = 0\n @property({ type: String }) title = ''\n @property({ type: String, attribute: 'custom-id' }) 'custom-id' = ''\n @property({ type: Boolean, attribute: 'is-edit' }) 'is-edit' = false\n @property({ type: Boolean, attribute: 'is-save' }) 'is-save' = false\n @property({ type: Boolean, attribute: 'is-set' }) 'is-set' = false\n @property({ type: Boolean, attribute: 'show-action' }) 'show-action' = true\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: 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 this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private _onTitleInput(e: Event) {\n const el = e.target as HTMLTextAreaElement\n if (el.value.length > this.TITLE_MAX) {\n el.value = el.value.slice(0, this.TITLE_MAX)\n }\n this._title = el.value\n if (this['use-model']) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private _resolvedQuestions(): string[] {\n const rowTitle = this['is-edit'] ? this._rowTitle : this._scaleQuestions.join('\\n')\n return splitScaleQuestionLines(rowTitle)\n }\n\n 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 showToast(err.message)\n }\n }\n\n validate(): SubjectError[] {\n const errors: SubjectError[] = []\n const row = {\n customId: this['custom-id'] || undefined,\n answerType: SubjectType.SCALE,\n orderIndex: this['order-index'],\n }\n\n const title = 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\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this['order-index'] + 1}.${this.title}(量表题)</span>\n ${this['show-rich-text'] && this['rich-text-content'] ? html`<div class=\"rich-text\" .innerHTML=${this['rich-text-content']}></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=\"flex-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea\n rows=\"2\"\n .value=${this._title}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【量表题】请输入问题\"\n ></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <slot name=\"business-tag\"></slot>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>行标题:</span></div>\n <div class=\"flex\" style=\"flex:1\">\n <div class=\"el-input\" style=\"width:160px\">\n <textarea\n class=\"row-title-textarea\"\n .value=${this._rowTitle}\n @input=${(e: Event) => { this._rowTitle = (e.target as HTMLTextAreaElement).value }}\n @keydown=${(e: KeyboardEvent) => { e.stopPropagation() }}\n placeholder=\"请输入行标题\"\n ></textarea>\n </div>\n <div style=\"flex:1;margin-left:12px\">\n ${this._answers.map((answer, index) => html`\n <div class=\"answer-item\">\n <span class=\"label\">${String.fromCharCode(65 + index)}.</span>\n <div class=\"input\">\n <input\n type=\"text\"\n .value=${answer.title}\n maxlength=\"10\"\n @input=${(e: Event) => {\n const value = (e.target as HTMLInputElement).value\n this._answers = this._answers.map((item, currentIndex) =>\n currentIndex === index ? { ...item, title: value } : item,\n )\n }}\n placeholder=\"选项${index + 1}\"\n />\n </div>\n <span\n class=\"icon\"\n @click=${() => {\n if (this._answers.length < 5) {\n this._answers = [...this._answers, createEmptyScaleAnswer()]\n }\n }}\n >${iconPlus}</span>\n <span\n class=\"icon ${this._answers.length < 3 ? 'disabled' : ''}\"\n @click=${() => {\n if (this._answers.length > 3) {\n this._answers = this._answers.filter((_, currentIndex) => currentIndex !== index)\n }\n }}\n >${iconRemove}</span>\n </div>\n `)}\n </div>\n </div>\n </div>\n\n ${this['show-rich-text'] && this._showRichText\n ? html`\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>副文本:</span></div>\n <div style=\"flex:1\">\n <slot name=\"sub-text\">\n <qxs-blocksuite-editor\n .content=${this._richText}\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=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>解析:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea\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 `\n }\n\n private _renderSorting() {\n const title = trimText(this['is-edit'] ? this._title : this.title || '') || '未命名题目'\n const orderText = `${this['order-index'] + 1}. ${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","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","slice","_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","msg","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","push","forEach","_renderPreview","colWidth","Math","floor","question","_renderEdit","stopPropagation","currentIndex","_","getContent","_renderSorting","orderText","renderSortingCard","SubjectTypeLabel","render","content","styles","sortingCardStyles","css","__decorateClass","property","type","Number","attribute","prototype","reflect","state","safeCustomElement"],"mappings":"2iBAeA,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,EAAKP,O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jIU3I,EAiIMyI,UAAA,WAAA,GACAL,EAAA,CAAhBO,KAlIU3I,EAkIMyI,UAAA,kBAAA,GACAL,EAAA,CAAhBO,KAnIU3I,EAmIMyI,UAAA,YAAA,GACAL,EAAA,CAAhBO,KApIU3I,EAoIMyI,UAAA,SAAA,GACAL,EAAA,CAAhBO,KArIU3I,EAqIMyI,UAAA,YAAA,GACAL,EAAA,CAAhBO,KAtIU3I,EAsIMyI,UAAA,gBAAA,GACAL,EAAA,CAAhBO,KAvIU3I,EAuIMyI,UAAA,YAAA,GAEqCL,EAAA,CAArDC,EAAS,CAAEC,KAAMlG,OAAQoG,UAAW,iBAzI1BxI,EAyI2CyI,UAAA,cAAA,GACDL,EAAA,CAApDC,EAAS,CAAEC,KAAM/F,QAASiG,UAAW,eA1I3BxI,EA0I0CyI,UAAA,YAAA,GA1I1CzI,EAANoI,EAAA,CADNQ,EAAkB,cACN5I"}
|
|
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 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; }\n .scale-table td:first-child,\n .scale-table th:first-child {\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,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,EAAKP,OAAS,SACd,IAAlBO,EAAKE,WACPF,EAAKG,aAAeH,EAAKE,eAEL,IAAlBF,EAAKE,iBACAF,EAAKE,gBAEPF,EAAKI,UACLJ,CACT,CAEA,MAAMQ,EAAWC,CAAA,2NACXC,EAAaD,CAAA,qLAGZ,IAAME,EAAN,cAAuBC,EAAvBC,WAAAA,GAAAC,SAAAC,WAoGiDC,KAAA,eAAgB,EAE1CA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,CADNS,EAAkB,cACN5H"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{joinSubjectTitle as e,resolveSubjectPrefix as t}from"./title-prefix.mjs";function n(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:n??null}))}function o(e,t){e.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:t}))}function i(e){const t=document.createElement("div");t.textContent=e,Object.assign(t.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(t),setTimeout(()=>{t.style.opacity="0",setTimeout(()=>t.remove(),300)},2500)}function r(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(e=>1===e?.resourceType).map(e=>e?.resource?.middle||e?.resource?.url).filter(Boolean)}function u(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.find(e=>2===e?.resourceType)?.resource||null}function c(){let e=arguments.length>1?arguments[1]:void 0;const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).find(t=>String(t?.categoryId)===String(e));return t?.title||t?.categoryName||e||"未选择分类"}function d(n,o,i){return e(t(n,`${o+1}.`),i)}function l(n,o,i){return e(t(n,`${o+1}. `),i)}export{d as buildSubjectPreviewTitle,l as buildSubjectSortingTitle,n as emitSubjectEvent,o as emitSubjectModelValue,r as getSubjectImageResources,u as getSubjectVideoResource,c as resolveSubjectCategoryLabel,i as showSubjectToast};
|
|
2
|
+
//# sourceMappingURL=shared-methods.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-methods.mjs","sources":["../../../../packages/components-wc/src/subject/shared-methods.ts"],"sourcesContent":["import { joinSubjectTitle, resolveSubjectPrefix } from './title-prefix'\n\nexport function emitSubjectEvent(host: EventTarget, name: string, detail?: unknown) {\n host.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n}\n\nexport function emitSubjectModelValue(host: EventTarget, value: string) {\n host.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: value,\n }))\n}\n\nexport function showSubjectToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed',\n top: '20px',\n left: '50%',\n transform: 'translateX(-50%)',\n padding: '10px 20px',\n borderRadius: '4px',\n fontSize: '13px',\n color: '#fff',\n background: '#f56c6c',\n zIndex: '99999',\n boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s',\n opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => {\n el.style.opacity = '0'\n setTimeout(() => el.remove(), 300)\n }, 2500)\n}\n\nexport function getSubjectImageResources(resourceList: any[] = []) {\n return resourceList\n .filter(item => item?.resourceType === 1)\n .map(item => item?.resource?.middle || item?.resource?.url)\n .filter(Boolean) as string[]\n}\n\nexport function getSubjectVideoResource(resourceList: any[] = []) {\n return resourceList.find(item => item?.resourceType === 2)?.resource || null\n}\n\nexport function resolveSubjectCategoryLabel(categoryList: any[] = [], categoryId?: string | number) {\n const matched = categoryList.find((item: any) => String(item?.categoryId) === String(categoryId))\n return matched?.title || matched?.categoryName || categoryId || '未选择分类'\n}\n\nexport function buildSubjectPreviewTitle(subjectPrefix: unknown, orderIndex: number, title: string) {\n return joinSubjectTitle(\n resolveSubjectPrefix(subjectPrefix, `${orderIndex + 1}.`),\n title,\n )\n}\n\nexport function buildSubjectSortingTitle(subjectPrefix: unknown, orderIndex: number, title: string) {\n return joinSubjectTitle(\n resolveSubjectPrefix(subjectPrefix, `${orderIndex + 1}. `),\n title,\n )\n}\n"],"names":["emitSubjectEvent","host","name","detail","dispatchEvent","CustomEvent","bubbles","composed","emitSubjectModelValue","value","showSubjectToast","msg","el","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","getSubjectImageResources","arguments","length","undefined","filter","item","resourceType","map","resource","middle","url","Boolean","getSubjectVideoResource","resourceList","find","resolveSubjectCategoryLabel","categoryId","matched","String","title","categoryName","buildSubjectPreviewTitle","subjectPrefix","orderIndex","joinSubjectTitle","resolveSubjectPrefix","buildSubjectSortingTitle"],"mappings":"gFAEO,SAASA,EAAiBC,EAAmBC,EAAcC,GAChEF,EAAKG,cAAc,IAAIC,YAAYH,EAAM,CAAEI,SAAS,EAAMC,UAAU,EAAMJ,OAAQA,GAAU,OAC9F,CAEO,SAASK,EAAsBP,EAAmBQ,GACvDR,EAAKG,cAAc,IAAIC,YAAY,oBAAqB,CACtDC,SAAS,EACTC,UAAU,EACVJ,OAAQM,IAEZ,CAEO,SAASC,EAAiBC,GAC/B,MAAMC,EAAKC,SAASC,cAAc,OAClCF,EAAGG,YAAcJ,EACjBK,OAAOC,OAAOL,EAAGM,MAAO,CACtBC,SAAU,QACVC,IAAK,OACLC,KAAM,MACNC,UAAW,mBACXC,QAAS,YACTC,aAAc,MACdC,SAAU,OACVC,MAAO,OACPC,WAAY,UACZC,OAAQ,QACRC,UAAW,6BACXC,WAAY,cACZC,QAAS,MAEXlB,SAASmB,KAAKC,YAAYrB,GAC1BsB,WAAW,KACTtB,EAAGM,MAAMa,QAAU,IACnBG,WAAW,IAAMtB,EAAGuB,SAAU,MAC7B,KACL,CAEO,SAASC,IACd,OADuCC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAsB,IAE1DG,OAAOC,GAA+B,IAAvBA,GAAMC,cACrBC,IAAIF,GAAQA,GAAMG,UAAUC,QAAUJ,GAAMG,UAAUE,KACtDN,OAAOO,QACZ,CAEO,SAASC,IAAkD,IAA1BC,EAAAZ,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAsB,GAC5D,OAAOY,EAAaC,KAAKT,GAA+B,I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