@qxs-bns/components-wc 0.0.23 → 0.0.25
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 +14 -14
- package/es/editor/blocksuite-editor.mjs.map +1 -1
- package/es/subject/action.mjs +18 -18
- package/es/subject/action.mjs.map +1 -1
- package/es/subject/blank-fill.mjs +128 -49
- package/es/subject/blank-fill.mjs.map +1 -1
- package/es/subject/layout.mjs +3 -3
- package/es/subject/layout.mjs.map +1 -1
- package/es/subject/list.mjs +80 -46
- package/es/subject/list.mjs.map +1 -1
- package/es/subject/page-end.mjs +8 -8
- package/es/subject/page-end.mjs.map +1 -1
- package/es/subject/scale.mjs +110 -29
- package/es/subject/scale.mjs.map +1 -1
- package/es/subject/single.mjs +48 -48
- package/es/subject/single.mjs.map +1 -1
- package/es/subject/text-fill.mjs +139 -98
- package/es/subject/text-fill.mjs.map +1 -1
- package/lib/editor/blocksuite-editor.cjs +4 -4
- package/lib/editor/blocksuite-editor.cjs.map +1 -1
- package/lib/subject/action.cjs +18 -18
- package/lib/subject/action.cjs.map +1 -1
- package/lib/subject/blank-fill.cjs +123 -44
- 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/list.cjs +83 -49
- package/lib/subject/list.cjs.map +1 -1
- package/lib/subject/page-end.cjs +8 -8
- package/lib/subject/page-end.cjs.map +1 -1
- package/lib/subject/scale.cjs +103 -22
- package/lib/subject/scale.cjs.map +1 -1
- package/lib/subject/single.cjs +48 -48
- package/lib/subject/single.cjs.map +1 -1
- package/lib/subject/text-fill.cjs +128 -87
- package/lib/subject/text-fill.cjs.map +1 -1
- package/package.json +1 -1
package/es/subject/action.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import{css as e,LitElement as t,html as o}from"lit";import{property as i,state as
|
|
1
|
+
import{css as e,LitElement as t,html as o}from"lit";import{property as i,state as s}from"lit/decorators.js";import{safeCustomElement as n}from"../base/define.mjs";var a=Object.defineProperty,r=Object.getOwnPropertyDescriptor,l=(e,t,o,i)=>{for(var s,n=i>1?void 0:i?r(t,o):t,l=e.length-1;l>=0;l--)(s=e[l])&&(n=(i?s(t,o,n):s(n))||n);return i&&n&&a(t,o,n),n};const d=[{value:2,label:"必须全部都是支持选项,方可下一步"},{value:1,label:"无需判断是否是支持选项"},{value:3,label:"包含全部支持选项,即可下一步"}],c=[{type:"single",label:"单选题"},{type:"multiple",label:"多选题"},{type:"blank_fill",label:"填空题"},{type:"text_fill",label:"问答题"},{type:"scale",label:"量表题"},{type:"sort",label:"排序题"},{type:"page_end",label:"分页符"}];let p=class extends t{constructor(){super(...arguments),this["is-edit"]=!1,this["is-set"]=!1,this["is-key"]=!1,this["answer-check-type"]=1,this["show-other-option"]=!1,this["show-answer-setting"]=!1,this["show-key"]=!1,this["show-rich-text"]=!1,this["hide-add-rich-text"]=!1,this["page-end"]=!1,this["show-move"]=!1,this["show-add"]=!0,this["show-jump"]=!1,this["exam-answer-relation-type"]=0,this._modalOpen=!1,this._currentCheckType=1,this._addMenuOpen=!1,this._handleDocumentClick=e=>{const t=e.composedPath(),o=this.shadowRoot?.querySelector(".add-menu-wrap");o&&!t.includes(o)&&(this._addMenuOpen=!1)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick)}updated(e){e.has("answer-check-type")&&(this._currentCheckType=this["answer-check-type"])}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}get _answerText(){return d.find(e=>e.value===this["answer-check-type"])?.label??""}get _showAnswerSetting(){return this["show-other-option"]||this["show-answer-setting"]}get _showKey(){return this["show-other-option"]||this["show-key"]}_renderEditMode(){return o`
|
|
2
2
|
<div class="left">
|
|
3
3
|
<span class="inline-actions">
|
|
4
|
-
${this
|
|
4
|
+
${this["show-add"]?o`
|
|
5
5
|
<span class="add-menu-wrap">
|
|
6
6
|
<span class="link-btn" @click=${()=>{this._addMenuOpen=!this._addMenuOpen}}>在此题后加入新题</span>
|
|
7
7
|
${this._renderAddMenu()}
|
|
8
8
|
</span>
|
|
9
9
|
`:""}
|
|
10
|
-
${this
|
|
10
|
+
${this["hide-add-rich-text"]?"":o`
|
|
11
11
|
<span class="link-btn" @click=${()=>this._emit("on-show-rich-text")}>
|
|
12
|
-
${this
|
|
12
|
+
${this["show-rich-text"]?"删除题目描述(图文)":"+添加题目描述(图文)"}
|
|
13
13
|
</span>
|
|
14
14
|
`}
|
|
15
|
-
${this
|
|
16
|
-
<span class="link-btn" @click=${()=>this._emit("jump")}>${this
|
|
15
|
+
${this["show-jump"]?o`
|
|
16
|
+
<span class="link-btn" @click=${()=>this._emit("jump")}>${this["is-set"]?"编辑跳题逻辑":"设置跳题逻辑"}</span>
|
|
17
17
|
`:""}
|
|
18
18
|
${this._showAnswerSetting?o`
|
|
19
19
|
<span class="link-btn" @click=${()=>{this._modalOpen=!0}}>答题设置</span>
|
|
20
20
|
`:""}
|
|
21
21
|
${this._showKey?o`
|
|
22
22
|
<label class="checkbox-label">
|
|
23
|
-
<input type="checkbox" .checked=${this
|
|
23
|
+
<input type="checkbox" .checked=${this["is-key"]} @change=${e=>this._emit("set-key",{value:e.target.checked})} />
|
|
24
24
|
核心题
|
|
25
25
|
</label>
|
|
26
26
|
`:""}
|
|
@@ -35,30 +35,30 @@ import{css as e,LitElement as t,html as o}from"lit";import{property as i,state a
|
|
|
35
35
|
<span class="inline-actions">
|
|
36
36
|
${this._showKey?o`
|
|
37
37
|
<label class="checkbox-label disabled">
|
|
38
|
-
<input type="checkbox" disabled .checked=${this
|
|
38
|
+
<input type="checkbox" disabled .checked=${this["is-key"]} /> 核心题
|
|
39
39
|
</label>
|
|
40
40
|
`:""}
|
|
41
41
|
${this._showAnswerSetting?o`
|
|
42
42
|
<span class="answer-text">${this._answerText}</span>
|
|
43
43
|
`:""}
|
|
44
|
-
${this
|
|
44
|
+
${this["show-add"]?o`
|
|
45
45
|
<span class="add-menu-wrap">
|
|
46
46
|
<span class="link-btn" @click=${()=>{this._addMenuOpen=!this._addMenuOpen}}>在此题后加入新题</span>
|
|
47
47
|
${this._renderAddMenu()}
|
|
48
48
|
</span>
|
|
49
49
|
`:""}
|
|
50
|
-
${this
|
|
51
|
-
<span class="link-btn" @click=${()=>this._emit("jump")}>${this
|
|
50
|
+
${this["show-jump"]?o`
|
|
51
|
+
<span class="link-btn" @click=${()=>this._emit("jump")}>${this["is-set"]?"编辑跳题逻辑":"设置跳题逻辑"}</span>
|
|
52
52
|
`:""}
|
|
53
53
|
</span>
|
|
54
54
|
</div>
|
|
55
55
|
<div class="right">
|
|
56
|
-
${!this
|
|
56
|
+
${!this["is-set"]&&this["show-move"]?o`
|
|
57
57
|
<button class="text-btn text-btn--default" @click=${()=>this._emit("move","up")}>上移</button>
|
|
58
58
|
<button class="text-btn text-btn--default btn-margin" @click=${()=>this._emit("move","down")}>下移</button>
|
|
59
59
|
`:""}
|
|
60
|
-
${this
|
|
61
|
-
${this
|
|
60
|
+
${this["is-set"]?"":o`<button class="text-btn text-btn--danger btn-margin" @click=${()=>this._emit("delete")}>删除</button>`}
|
|
61
|
+
${this["page-end"]||this["is-set"]?"":o`
|
|
62
62
|
<button class="text-btn text-btn--default" @click=${()=>this._emit("edit")}>编辑</button>
|
|
63
63
|
`}
|
|
64
64
|
</div>
|
|
@@ -92,9 +92,9 @@ import{css as e,LitElement as t,html as o}from"lit";import{property as i,state a
|
|
|
92
92
|
`)}
|
|
93
93
|
</div>
|
|
94
94
|
`:""}render(){return o`
|
|
95
|
-
<div class="action ${this
|
|
96
|
-
${this
|
|
97
|
-
${this
|
|
95
|
+
<div class="action ${this["is-edit"]?"active":""}">
|
|
96
|
+
${this["is-edit"]?this._renderEditMode():this._renderViewMode()}
|
|
97
|
+
${this["is-set"]?o`<div class="has-set">*此题设置了跳题逻辑</div>`:""}
|
|
98
98
|
</div>
|
|
99
99
|
${this._renderModal()}
|
|
100
100
|
`}};p.styles=e`
|
|
@@ -168,5 +168,5 @@ import{css as e,LitElement as t,html as o}from"lit";import{property as i,state a
|
|
|
168
168
|
background: #fff; color: #606266; font-size: 12px; cursor: pointer; transition: all .2s;
|
|
169
169
|
}
|
|
170
170
|
.add-item:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }
|
|
171
|
-
`,l([i({type:Boolean,attribute:"is-edit"})],p.prototype,"
|
|
171
|
+
`,l([i({type:Boolean,attribute:"is-edit"})],p.prototype,"is-edit",2),l([i({type:Boolean,attribute:"is-set"})],p.prototype,"is-set",2),l([i({type:Boolean,attribute:"is-key"})],p.prototype,"is-key",2),l([i({type:Number,attribute:"answer-check-type"})],p.prototype,"answer-check-type",2),l([i({type:Boolean,attribute:"show-other-option"})],p.prototype,"show-other-option",2),l([i({type:Boolean,attribute:"show-answer-setting"})],p.prototype,"show-answer-setting",2),l([i({type:Boolean,attribute:"show-key"})],p.prototype,"show-key",2),l([i({type:Boolean,attribute:"show-rich-text"})],p.prototype,"show-rich-text",2),l([i({type:Boolean,attribute:"hide-add-rich-text"})],p.prototype,"hide-add-rich-text",2),l([i({type:Boolean,attribute:"page-end"})],p.prototype,"page-end",2),l([i({type:Boolean,attribute:"show-move"})],p.prototype,"show-move",2),l([i({type:Boolean,attribute:"show-add"})],p.prototype,"show-add",2),l([i({type:Boolean,attribute:"show-jump"})],p.prototype,"show-jump",2),l([i({type:Number,attribute:"exam-answer-relation-type"})],p.prototype,"exam-answer-relation-type",2),l([s()],p.prototype,"_modalOpen",2),l([s()],p.prototype,"_currentCheckType",2),l([s()],p.prototype,"_addMenuOpen",2),p=l([n("qxs-subject-action")],p);export{p as QxsSubjectAction};
|
|
172
172
|
//# sourceMappingURL=action.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.mjs","sources":["../../../../packages/components-wc/src/subject/action.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\nconst answerTextList = [\n { value: 2, label: '必须全部都是支持选项,方可下一步' },\n { value: 1, label: '无需判断是否是支持选项' },\n { value: 3, label: '包含全部支持选项,即可下一步' },\n]\n\nconst addSubjectOptions = [\n { type: 'single', label: '单选题' },\n { type: 'multiple', label: '多选题' },\n { type: 'blank_fill', label: '填空题' },\n { type: 'text_fill', label: '问答题' },\n { type: 'scale', label: '量表题' },\n { type: 'sort', label: '排序题' },\n { type: 'page_end', label: '分页符' },\n]\n\n@safeCustomElement('qxs-subject-action')\nexport class QxsSubjectAction extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .action { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }\n .action.active { background: transparent; }\n .left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n .right { display: flex; align-items: center; gap: 4px; }\n\n .action-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 32px; height: 32px; font-size: 18px; color: #303133;\n cursor: pointer; border-radius: 6px; border: 1px solid #dcdfe6;\n background: #fff; transition: all 0.2s;\n }\n .action-icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .action-icon--danger:hover { color: #f56c6c; border-color: #f56c6c; background: #fef0f0; }\n .action-icon:disabled { color: #c0c4cc; cursor: not-allowed; opacity: 0.6; }\n\n .text-btn {\n display: inline-flex; align-items: center; gap: 4px;\n padding: 6px 12px; font-size: 12px; border-radius: 3px;\n cursor: pointer; border: 1px solid; transition: all 0.2s;\n }\n .text-btn--primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .text-btn--primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n .text-btn--default { background: #fff; border-color: #dcdfe6; color: #606266; }\n .text-btn--default:hover { color: #3D61E3; border-color: #a0cfff; }\n .text-btn--danger { background: #f56c6c; border-color: #f56c6c; color: #fff; }\n .text-btn--danger:hover { background: #e05252; border-color: #e05252; }\n\n .link-btn { background: none; border: none; color: #3D61E3; cursor: pointer; font-size: 12px; }\n .link-btn:hover { color: #2D4CB8; }\n\n .checkbox-label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: #606266; user-select: none; font-size: 12px; }\n .checkbox-label.disabled { cursor: not-allowed; opacity: 0.6; }\n .has-set { display: flex; align-items: center; font-size: 12px; color: #bbb; }\n .answer-text { font-size: 11px; color: #909399; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n\n .btn-margin { margin-right: 10px; }\n\n .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; }\n .modal { background: #fff; border-radius: 4px; min-width: 360px; max-width: 460px; box-shadow: 0 12px 32px rgba(0,0,0,.1); }\n .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid #e4e7ed; }\n .modal-title { font-size: 14px; font-weight: 600; color: #303133; }\n .modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: #909399; padding: 0; line-height: 1; }\n .modal-close:hover { color: #3D61E3; }\n .modal-body { padding: 20px; }\n .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4e7ed; }\n .modal-footer button { padding: 6px 16px; font-size: 12px; border-radius: 3px; cursor: pointer; border: 1px solid #dcdfe6; background: #fff; color: #606266; }\n .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }\n .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n\n .radio-item { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; font-size: 13px; color: #606266; }\n .radio-item:last-child { margin-bottom: 0; }\n\n .inline-actions { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n .add-menu-wrap { position: relative; display: inline-flex; }\n .add-menu {\n position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;\n display: grid; grid-template-columns: repeat(2, minmax(84px, 1fr)); gap: 8px;\n min-width: 196px; padding: 10px; background: #fff; border: 1px solid #e4e7ed;\n border-radius: 6px; box-shadow: 0 8px 20px rgba(0,0,0,.12);\n }\n .add-item {\n display: inline-flex; align-items: center; justify-content: center;\n min-height: 30px; padding: 0 10px; border: 1px solid #dcdfe6; border-radius: 4px;\n background: #fff; color: #606266; font-size: 12px; cursor: pointer; transition: all .2s;\n }\n .add-item:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n `\n\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'is-key' }) isKey = false\n @property({ type: Number, attribute: 'answer-check-type' }) answerCheckType = 1\n @property({ type: Boolean, attribute: 'show-other-option' }) showOtherOption = false\n @property({ type: Boolean, attribute: 'show-answer-setting' }) showAnswerSetting = false\n @property({ type: Boolean, attribute: 'show-key' }) showKey = false\n @property({ type: Boolean, attribute: 'show-rich-text' }) showRichText = false\n @property({ type: Boolean, attribute: 'hide-add-rich-text' }) hideAddRichText = false\n @property({ type: Boolean, attribute: 'page-end' }) pageEnd = false\n @property({ type: Boolean, attribute: 'show-move' }) showMove = false\n @property({ type: Boolean, attribute: 'show-add' }) showAdd = true\n @property({ type: Boolean, attribute: 'show-jump' }) showJump = false\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n\n @state() private _modalOpen = false\n @state() private _currentCheckType = 1\n @state() private _addMenuOpen = false\n\n connectedCallback() {\n super.connectedCallback()\n document.addEventListener('click', this._handleDocumentClick)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n document.removeEventListener('click', this._handleDocumentClick)\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('answerCheckType')) {\n this._currentCheckType = this.answerCheckType\n }\n }\n\n private _handleDocumentClick = (e: MouseEvent) => {\n const path = e.composedPath()\n const wrap = this.shadowRoot?.querySelector('.add-menu-wrap')\n if (wrap && !path.includes(wrap)) {\n this._addMenuOpen = false\n }\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private get _answerText() {\n return answerTextList.find(i => i.value === this.answerCheckType)?.label ?? ''\n }\n\n private get _showAnswerSetting() {\n return this.showOtherOption || this.showAnswerSetting\n }\n\n private get _showKey() {\n return this.showOtherOption || this.showKey\n }\n\n private _renderEditMode() {\n return html`\n <div class=\"left\">\n <span class=\"inline-actions\">\n ${this.showAdd\n ? html`\n <span class=\"add-menu-wrap\">\n <span class=\"link-btn\" @click=${() => { this._addMenuOpen = !this._addMenuOpen }}>在此题后加入新题</span>\n ${this._renderAddMenu()}\n </span>\n `\n : ''}\n ${!this.hideAddRichText\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('on-show-rich-text')}>\n ${this.showRichText ? '删除题目描述(图文)' : '+添加题目描述(图文)'}\n </span>\n `\n : ''}\n ${this.showJump\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('jump')}>${this.isSet ? '编辑跳题逻辑' : '设置跳题逻辑'}</span>\n `\n : ''}\n ${this._showAnswerSetting\n ? html`\n <span class=\"link-btn\" @click=${() => { this._modalOpen = true }}>答题设置</span>\n `\n : ''}\n ${this._showKey\n ? html`\n <label class=\"checkbox-label\">\n <input type=\"checkbox\" .checked=${this.isKey} @change=${(e: Event) => this._emit('set-key', { value: (e.target as HTMLInputElement).checked })} />\n 核心题\n </label>\n `\n : ''}\n </span>\n </div>\n <div class=\"right\">\n <button class=\"text-btn text-btn--danger btn-margin\" @click=${() => this._emit('delete')}>删除</button>\n <button class=\"text-btn text-btn--primary\" @click=${() => this._emit('save')}>完成编辑</button>\n </div>\n `\n }\n\n private _renderViewMode() {\n return html`\n <div class=\"left\">\n <span class=\"inline-actions\">\n ${this._showKey\n ? html`\n <label class=\"checkbox-label disabled\">\n <input type=\"checkbox\" disabled .checked=${this.isKey} /> 核心题\n </label>\n `\n : ''}\n ${this._showAnswerSetting\n ? html`\n <span class=\"answer-text\">${this._answerText}</span>\n `\n : ''}\n ${this.showAdd\n ? html`\n <span class=\"add-menu-wrap\">\n <span class=\"link-btn\" @click=${() => { this._addMenuOpen = !this._addMenuOpen }}>在此题后加入新题</span>\n ${this._renderAddMenu()}\n </span>\n `\n : ''}\n ${this.showJump\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('jump')}>${this.isSet ? '编辑跳题逻辑' : '设置跳题逻辑'}</span>\n `\n : ''}\n </span>\n </div>\n <div class=\"right\">\n ${!this.isSet && this.showMove\n ? html`\n <button class=\"text-btn text-btn--default\" @click=${() => this._emit('move', 'up')}>上移</button>\n <button class=\"text-btn text-btn--default btn-margin\" @click=${() => this._emit('move', 'down')}>下移</button>\n `\n : ''}\n ${!this.isSet\n ? html`<button class=\"text-btn text-btn--danger btn-margin\" @click=${() => this._emit('delete')}>删除</button>`\n : ''}\n ${!this.pageEnd && !this.isSet\n ? html`\n <button class=\"text-btn text-btn--default\" @click=${() => this._emit('edit')}>编辑</button>\n `\n : ''}\n </div>\n `\n }\n\n private _renderModal() {\n if (!this._modalOpen) { return '' }\n return html`\n <div class=\"modal-backdrop\" @click=${() => { this._modalOpen = false }}>\n <div class=\"modal\" @click=${(e: Event) => e.stopPropagation()}>\n <div class=\"modal-header\">\n <span class=\"modal-title\">答题设置</span>\n <button class=\"modal-close\" @click=${() => { this._modalOpen = false }}>✕</button>\n </div>\n <div class=\"modal-body\">\n ${answerTextList.map(item => html`\n <label class=\"radio-item\">\n <input type=\"radio\" name=\"answer-check-type\" .value=${String(item.value)}\n .checked=${this._currentCheckType === item.value}\n @change=${() => { this._currentCheckType = item.value }} />\n ${item.label}\n </label>\n `)}\n </div>\n <div class=\"modal-footer\">\n <button @click=${() => { this._modalOpen = false }}>取消</button>\n <button class=\"primary\" @click=${() => {\n this._emit('set-answer-setting', { value: this._currentCheckType })\n this._modalOpen = false\n }}>保存</button>\n </div>\n </div>\n </div>\n `\n }\n\n private _renderAddMenu() {\n if (!this._addMenuOpen) { return '' }\n return html`\n <div class=\"add-menu\">\n ${addSubjectOptions.map(item => html`\n <button class=\"add-item\" @click=${() => {\n this._addMenuOpen = false\n this._emit('add', item.type)\n }}>${item.label}</button>\n `)}\n </div>\n `\n }\n\n render() {\n return html`\n <div class=\"action ${this.isEdit ? 'active' : ''}\">\n ${this.isEdit ? this._renderEditMode() : this._renderViewMode()}\n ${this.isSet ? html`<div class=\"has-set\">*此题设置了跳题逻辑</div>` : ''}\n </div>\n ${this._renderModal()}\n `\n }\n}\n\nexport function register() {}\n"],"names":["answerTextList","value","label","addSubjectOptions","type","QxsSubjectAction","LitElement","constructor","super","arguments","this","isEdit","isSet","isKey","answerCheckType","showOtherOption","showAnswerSetting","showKey","showRichText","hideAddRichText","pageEnd","showMove","showAdd","showJump","examAnswerRelationType","_modalOpen","_currentCheckType","_addMenuOpen","_handleDocumentClick","e","path","composedPath","wrap","shadowRoot","querySelector","includes","connectedCallback","document","addEventListener","disconnectedCallback","removeEventListener","updated","changed","has","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_answerText","find","i","_showAnswerSetting","_showKey","_renderEditMode","html","_renderAddMenu","target","checked","_renderViewMode","_renderModal","stopPropagation","map","item","String","render","styles","css","__decorateClass","property","Boolean","attribute","prototype","Number","state","safeCustomElement"],"mappings":"mWAIA,MAAMA,EAAiB,CACrB,CAAEC,MAAO,EAAGC,MAAO,oBACnB,CAAED,MAAO,EAAGC,MAAO,eACnB,CAAED,MAAO,EAAGC,MAAO,mBAGfC,EAAoB,CACxB,CAAEC,KAAM,SAAUF,MAAO,OACzB,CAAEE,KAAM,WAAYF,MAAO,OAC3B,CAAEE,KAAM,aAAcF,MAA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|
|
1
|
+
{"version":3,"file":"action.mjs","sources":["../../../../packages/components-wc/src/subject/action.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\nconst answerTextList = [\n { value: 2, label: '必须全部都是支持选项,方可下一步' },\n { value: 1, label: '无需判断是否是支持选项' },\n { value: 3, label: '包含全部支持选项,即可下一步' },\n]\n\nconst addSubjectOptions = [\n { type: 'single', label: '单选题' },\n { type: 'multiple', label: '多选题' },\n { type: 'blank_fill', label: '填空题' },\n { type: 'text_fill', label: '问答题' },\n { type: 'scale', label: '量表题' },\n { type: 'sort', label: '排序题' },\n { type: 'page_end', label: '分页符' },\n]\n\n@safeCustomElement('qxs-subject-action')\nexport class QxsSubjectAction extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .action { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }\n .action.active { background: transparent; }\n .left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n .right { display: flex; align-items: center; gap: 4px; }\n\n .action-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 32px; height: 32px; font-size: 18px; color: #303133;\n cursor: pointer; border-radius: 6px; border: 1px solid #dcdfe6;\n background: #fff; transition: all 0.2s;\n }\n .action-icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .action-icon--danger:hover { color: #f56c6c; border-color: #f56c6c; background: #fef0f0; }\n .action-icon:disabled { color: #c0c4cc; cursor: not-allowed; opacity: 0.6; }\n\n .text-btn {\n display: inline-flex; align-items: center; gap: 4px;\n padding: 6px 12px; font-size: 12px; border-radius: 3px;\n cursor: pointer; border: 1px solid; transition: all 0.2s;\n }\n .text-btn--primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .text-btn--primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n .text-btn--default { background: #fff; border-color: #dcdfe6; color: #606266; }\n .text-btn--default:hover { color: #3D61E3; border-color: #a0cfff; }\n .text-btn--danger { background: #f56c6c; border-color: #f56c6c; color: #fff; }\n .text-btn--danger:hover { background: #e05252; border-color: #e05252; }\n\n .link-btn { background: none; border: none; color: #3D61E3; cursor: pointer; font-size: 12px; }\n .link-btn:hover { color: #2D4CB8; }\n\n .checkbox-label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: #606266; user-select: none; font-size: 12px; }\n .checkbox-label.disabled { cursor: not-allowed; opacity: 0.6; }\n .has-set { display: flex; align-items: center; font-size: 12px; color: #bbb; }\n .answer-text { font-size: 11px; color: #909399; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n\n .btn-margin { margin-right: 10px; }\n\n .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; }\n .modal { background: #fff; border-radius: 4px; min-width: 360px; max-width: 460px; box-shadow: 0 12px 32px rgba(0,0,0,.1); }\n .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid #e4e7ed; }\n .modal-title { font-size: 14px; font-weight: 600; color: #303133; }\n .modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: #909399; padding: 0; line-height: 1; }\n .modal-close:hover { color: #3D61E3; }\n .modal-body { padding: 20px; }\n .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4e7ed; }\n .modal-footer button { padding: 6px 16px; font-size: 12px; border-radius: 3px; cursor: pointer; border: 1px solid #dcdfe6; background: #fff; color: #606266; }\n .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }\n .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n\n .radio-item { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; font-size: 13px; color: #606266; }\n .radio-item:last-child { margin-bottom: 0; }\n\n .inline-actions { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n .add-menu-wrap { position: relative; display: inline-flex; }\n .add-menu {\n position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;\n display: grid; grid-template-columns: repeat(2, minmax(84px, 1fr)); gap: 8px;\n min-width: 196px; padding: 10px; background: #fff; border: 1px solid #e4e7ed;\n border-radius: 6px; box-shadow: 0 8px 20px rgba(0,0,0,.12);\n }\n .add-item {\n display: inline-flex; align-items: center; justify-content: center;\n min-height: 30px; padding: 0 10px; border: 1px solid #dcdfe6; border-radius: 4px;\n background: #fff; color: #606266; font-size: 12px; cursor: pointer; transition: all .2s;\n }\n .add-item:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n `\n\n @property({ type: Boolean, attribute: 'is-edit' }) 'is-edit' = false\n @property({ type: Boolean, attribute: 'is-set' }) 'is-set' = false\n @property({ type: Boolean, attribute: 'is-key' }) 'is-key' = false\n @property({ type: Number, attribute: 'answer-check-type' }) 'answer-check-type' = 1\n @property({ type: Boolean, attribute: 'show-other-option' }) 'show-other-option' = false\n @property({ type: Boolean, attribute: 'show-answer-setting' }) 'show-answer-setting' = false\n @property({ type: Boolean, attribute: 'show-key' }) 'show-key' = false\n @property({ type: Boolean, attribute: 'show-rich-text' }) 'show-rich-text' = false\n @property({ type: Boolean, attribute: 'hide-add-rich-text' }) 'hide-add-rich-text' = false\n @property({ type: Boolean, attribute: 'page-end' }) 'page-end' = false\n @property({ type: Boolean, attribute: 'show-move' }) 'show-move' = false\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: Boolean, attribute: 'show-jump' }) 'show-jump' = false\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) 'exam-answer-relation-type' = 0\n\n @state() private _modalOpen = false\n @state() private _currentCheckType = 1\n @state() private _addMenuOpen = false\n\n connectedCallback() {\n super.connectedCallback()\n document.addEventListener('click', this._handleDocumentClick)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n document.removeEventListener('click', this._handleDocumentClick)\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('answer-check-type')) {\n this._currentCheckType = this['answer-check-type']\n }\n }\n\n private _handleDocumentClick = (e: MouseEvent) => {\n const path = e.composedPath()\n const wrap = this.shadowRoot?.querySelector('.add-menu-wrap')\n if (wrap && !path.includes(wrap)) {\n this._addMenuOpen = false\n }\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private get _answerText() {\n return answerTextList.find(i => i.value === this['answer-check-type'])?.label ?? ''\n }\n\n private get _showAnswerSetting() {\n return this['show-other-option'] || this['show-answer-setting']\n }\n\n private get _showKey() {\n return this['show-other-option'] || this['show-key']\n }\n\n private _renderEditMode() {\n return html`\n <div class=\"left\">\n <span class=\"inline-actions\">\n ${this['show-add']\n ? html`\n <span class=\"add-menu-wrap\">\n <span class=\"link-btn\" @click=${() => { this._addMenuOpen = !this._addMenuOpen }}>在此题后加入新题</span>\n ${this._renderAddMenu()}\n </span>\n `\n : ''}\n ${!this['hide-add-rich-text']\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('on-show-rich-text')}>\n ${this['show-rich-text'] ? '删除题目描述(图文)' : '+添加题目描述(图文)'}\n </span>\n `\n : ''}\n ${this['show-jump']\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('jump')}>${this['is-set'] ? '编辑跳题逻辑' : '设置跳题逻辑'}</span>\n `\n : ''}\n ${this._showAnswerSetting\n ? html`\n <span class=\"link-btn\" @click=${() => { this._modalOpen = true }}>答题设置</span>\n `\n : ''}\n ${this._showKey\n ? html`\n <label class=\"checkbox-label\">\n <input type=\"checkbox\" .checked=${this['is-key']} @change=${(e: Event) => this._emit('set-key', { value: (e.target as HTMLInputElement).checked })} />\n 核心题\n </label>\n `\n : ''}\n </span>\n </div>\n <div class=\"right\">\n <button class=\"text-btn text-btn--danger btn-margin\" @click=${() => this._emit('delete')}>删除</button>\n <button class=\"text-btn text-btn--primary\" @click=${() => this._emit('save')}>完成编辑</button>\n </div>\n `\n }\n\n private _renderViewMode() {\n return html`\n <div class=\"left\">\n <span class=\"inline-actions\">\n ${this._showKey\n ? html`\n <label class=\"checkbox-label disabled\">\n <input type=\"checkbox\" disabled .checked=${this['is-key']} /> 核心题\n </label>\n `\n : ''}\n ${this._showAnswerSetting\n ? html`\n <span class=\"answer-text\">${this._answerText}</span>\n `\n : ''}\n ${this['show-add']\n ? html`\n <span class=\"add-menu-wrap\">\n <span class=\"link-btn\" @click=${() => { this._addMenuOpen = !this._addMenuOpen }}>在此题后加入新题</span>\n ${this._renderAddMenu()}\n </span>\n `\n : ''}\n ${this['show-jump']\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('jump')}>${this['is-set'] ? '编辑跳题逻辑' : '设置跳题逻辑'}</span>\n `\n : ''}\n </span>\n </div>\n <div class=\"right\">\n ${!this['is-set'] && this['show-move']\n ? html`\n <button class=\"text-btn text-btn--default\" @click=${() => this._emit('move', 'up')}>上移</button>\n <button class=\"text-btn text-btn--default btn-margin\" @click=${() => this._emit('move', 'down')}>下移</button>\n `\n : ''}\n ${!this['is-set']\n ? html`<button class=\"text-btn text-btn--danger btn-margin\" @click=${() => this._emit('delete')}>删除</button>`\n : ''}\n ${!this['page-end'] && !this['is-set']\n ? html`\n <button class=\"text-btn text-btn--default\" @click=${() => this._emit('edit')}>编辑</button>\n `\n : ''}\n </div>\n `\n }\n\n private _renderModal() {\n if (!this._modalOpen) { return '' }\n return html`\n <div class=\"modal-backdrop\" @click=${() => { this._modalOpen = false }}>\n <div class=\"modal\" @click=${(e: Event) => e.stopPropagation()}>\n <div class=\"modal-header\">\n <span class=\"modal-title\">答题设置</span>\n <button class=\"modal-close\" @click=${() => { this._modalOpen = false }}>✕</button>\n </div>\n <div class=\"modal-body\">\n ${answerTextList.map(item => html`\n <label class=\"radio-item\">\n <input type=\"radio\" name=\"answer-check-type\" .value=${String(item.value)}\n .checked=${this._currentCheckType === item.value}\n @change=${() => { this._currentCheckType = item.value }} />\n ${item.label}\n </label>\n `)}\n </div>\n <div class=\"modal-footer\">\n <button @click=${() => { this._modalOpen = false }}>取消</button>\n <button class=\"primary\" @click=${() => {\n this._emit('set-answer-setting', { value: this._currentCheckType })\n this._modalOpen = false\n }}>保存</button>\n </div>\n </div>\n </div>\n `\n }\n\n private _renderAddMenu() {\n if (!this._addMenuOpen) { return '' }\n return html`\n <div class=\"add-menu\">\n ${addSubjectOptions.map(item => html`\n <button class=\"add-item\" @click=${() => {\n this._addMenuOpen = false\n this._emit('add', item.type)\n }}>${item.label}</button>\n `)}\n </div>\n `\n }\n\n render() {\n return html`\n <div class=\"action ${this['is-edit'] ? 'active' : ''}\">\n ${this['is-edit'] ? this._renderEditMode() : this._renderViewMode()}\n ${this['is-set'] ? html`<div class=\"has-set\">*此题设置了跳题逻辑</div>` : ''}\n </div>\n ${this._renderModal()}\n `\n }\n}\n\nexport function register() {}\n"],"names":["answerTextList","value","label","addSubjectOptions","type","QxsSubjectAction","LitElement","constructor","super","arguments","this","_modalOpen","_currentCheckType","_addMenuOpen","_handleDocumentClick","e","path","composedPath","wrap","shadowRoot","querySelector","includes","connectedCallback","document","addEventListener","disconnectedCallback","removeEventListener","updated","changed","has","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_answerText","find","i","_showAnswerSetting","_showKey","_renderEditMode","html","_renderAddMenu","target","checked","_renderViewMode","_renderModal","stopPropagation","map","item","String","render","styles","css","__decorateClass","property","Boolean","attribute","prototype","Number","state","safeCustomElement"],"mappings":"mWAIA,MAAMA,EAAiB,CACrB,CAAEC,MAAO,EAAGC,MAAO,oBACnB,CAAED,MAAO,EAAGC,MAAO,eACnB,CAAED,MAAO,EAAGC,MAAO,mBAGfC,EAAoB,CACxB,CAAEC,KAAM,SAAUF,MAAO,OACzB,CAAEE,K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import{html as t,css as e,LitElement as s}from"lit";import{property as i,state as a}from"lit/decorators.js";import{safeCustomElement as r}from"../base/define.mjs";import{SubjectError as o}from"./single.mjs";import{SubjectType as l}from"./types.mjs";var n=Object.defineProperty,h=Object.getOwnPropertyDescriptor,c=(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&&n(e,s,r),r};const d=t`
|
|
2
2
|
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"
|
|
3
3
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
4
4
|
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
|
|
5
|
-
</svg>`;let
|
|
5
|
+
</svg>`;let p=class extends s{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["is-key"]=!1,this["show-action"]=!0,this["show-add"]=!0,this["show-answer-setting"]=!1,this["show-analysis"]=!0,this["rich-text-content"]="",this.analysis="",this["exam-answer-relation-type"]=0,this["exam-expand"]="",this["exam-id"]=0,this["category-id"]="",this["exam-answer-setting"]={isInOrder:!1,isIgnoreCase:!0},this["upload-image"]=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this["answer-list"]=[],this["tag-list"]=[],this["category-list"]=[],this["resource-list"]=[],this["show-tag"]=!1,this["show-category"]=!1,this["show-resource"]=!1,this["model-value"]="",this["use-model"]=!1,this._title="",this._analysis="",this._answers=[{title:"",tag:"",showInput:!1}],this._isInOrder=!1,this._isIgnoreCase=!0,this._showRichText=!1,this._richText="",this._selectedTagList=[],this._categoryId="",this.TITLE_MAX=400}willUpdate(t){t.has("is-edit")&&this["is-edit"]&&this._syncProps(),!this["is-edit"]&&(t.has("title")||t.has("answer-list")||t.has("analysis")||t.has("exam-answer-setting")||t.has("rich-text-content")||t.has("tag-list")||t.has("category-id"))&&this._syncProps(),t.has("model-value")&&this["use-model"]&&(this._title=this["model-value"].replaceAll(/<filter><\/filter>/g," ______")),t.has("tag-list")&&(this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(t=>({...t})):[]),t.has("category-id")&&(this._categoryId=this["category-id"]?String(this["category-id"]):"")}_normalizeAnswerTitle(t){return String(t?.title??t?.answer??"")}_syncProps(){if(this._title=(this.title||"").replaceAll(/<filter><\/filter>/g," ______"),this._analysis=this.analysis||"",this["answer-list"]?.length)this._answers=this["answer-list"].map(t=>({title:this._normalizeAnswerTitle(t),tag:"",showInput:!1,answerId:t?.answerId??t?.examAnswerId}));else{const t=(this._title.match(/ ______/g)||[]).length||1;this._answers=Array.from({length:t},()=>({title:"",tag:"",showInput:!1}))}this["exam-answer-setting"]&&(this._isInOrder=!!this["exam-answer-setting"].isInOrder,this._isIgnoreCase=!!this["exam-answer-setting"].isIgnoreCase),this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(t=>({...t})):[],this._categoryId=this["category-id"]?String(this["category-id"]):""}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_addBlank(){this._title+=" ______",this._answers=[...this._answers,{title:"",tag:"",showInput:!1}],this.requestUpdate(),this._emitModelUpdate()}_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;const s=(this._title.match(/ ______/g)||[]).length;if(s!==this._answers.length)if(s>this._answers.length)for(let t=this._answers.length;t<s;t++)this._answers=[...this._answers,{title:"",tag:"",showInput:!1}];else this._answers=this._answers.slice(0,s);this._emitModelUpdate()}_emitModelUpdate(){if(this["use-model"]){const t=this._title.replaceAll(/ ______/g,"<filter></filter>");this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:t}))}}_handleAddTag(t){t.showInput=!1,t.tag&&(t.title=t.title?[t.title,t.tag].join(","):t.tag,t.tag=""),this.requestUpdate()}_closeTag(t,e){if(!t)return;const s=e.title.split(","),i=s.findIndex(e=>e===t);i>-1&&(s.splice(i,1),e.title=s.join(",")),this.requestUpdate()}_removeTag(t){this._selectedTagList=this._selectedTagList.filter(e=>String(e.tagId)!==String(t)),this._emit("tag-change",{value:this._selectedTagList,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_chooseTag(){this._emit("choose-tag",{value:this._selectedTagList,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_onCategoryChange(t){this._categoryId=t,this._emit("category-change",{value:t,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_imageResources(){return(this["resource-list"]||[]).filter(t=>1===t.resourceType).map(t=>t.resource.middle||t.resource.url).filter(Boolean)}_videoResource(){return(this["resource-list"]||[]).find(t=>2===t.resourceType)?.resource||null}_categoryLabel(){const t=this["category-list"].find(t=>String(t.categoryId)===String(this._categoryId));return t?.title||t?.categoryName||this._categoryId||"未选择分类"}async toJSON(){return new Promise((t,e)=>{const s={customId:this["custom-id"]||void 0,answerType:"blank_fill",orderIndex:this["order-index"]},i=this["is-edit"]?this._title:this.title?.replaceAll(/<filter><\/filter>/g," ______")||"",a=this["is-edit"]?this._answers:(this["answer-list"]||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t),answerId:t?.answerId??t?.examAnswerId})),r=this["is-edit"]?this._analysis:this.analysis||"",n=this["is-edit"]?this._isInOrder:this["exam-answer-setting"]?.isInOrder??!1,h=this["is-edit"]?this._isIgnoreCase:this["exam-answer-setting"]?.isIgnoreCase??!0,c=this["is-edit"]?this._showRichText:!!this["rich-text-content"],d=this["is-edit"]?this._richText:this["rich-text-content"]||"",p=this._selectedTagList||[],g=a.filter(t=>this._normalizeAnswerTitle(t));if(!i)return void e(new o("题目标题不能为空!","EMPTY_TITLE","title",s));if(a.length<1)return void e(new o("至少添加一个填空符!","NO_BLANK","answers",s));const x={answerType:l.BLANK_FILL,title:i.replaceAll(/ ______/g,"<filter></filter>"),answers:g.map(t=>({title:this._normalizeAnswerTitle(t),isCorrect:!0,...t.answerId?{answerId:t.answerId}:{}})),analysis:r,isSetCorrectAnswer:g.length>0,isKey:this["is-key"],examAnswerSettingBO:{isIgnoreCase:h,isInOrder:n},examRichTextContent:c?d:"",categoryId:this._categoryId||"",memberTagInfo:p,tagInfos:p,resourceList:this["resource-list"]||[],examResourceBOList:this["resource-list"]||[]};this["custom-id"]&&(x.customId=this["custom-id"]),t(x)})}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!function(t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(e),setTimeout(()=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},2500)}(t.message)}}validate(){const t=[],e={customId:this["custom-id"]||void 0,answerType:"blank_fill",orderIndex:this["order-index"]},s=this["is-edit"]?this._title:this.title?.replaceAll(/<filter><\/filter>/g," ______")||"",i=this["is-edit"]?this._answers:(this["answer-list"]||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)}));return s||t.push(new o("题目标题不能为空!","EMPTY_TITLE","title",e)),i.length<1&&t.push(new o("至少添加一个填空符!","NO_BLANK","answers",e)),t}_renderPreview(){const e=this.title.replaceAll(/<filter><\/filter>/g," ______"),s=this["is-edit"]?this._answers:(this["answer-list"]||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)}));return t`
|
|
6
6
|
<div class="preview">
|
|
7
|
-
<span class="title">${this
|
|
8
|
-
${this
|
|
9
|
-
${
|
|
7
|
+
<span class="title">${this["order-index"]+1}.${e}(填空题)</span>
|
|
8
|
+
${this["rich-text-content"]?t`<div class="rich-text" .innerHTML=${this["rich-text-content"]}></div>`:""}
|
|
9
|
+
${s.some(t=>t.title)?t`
|
|
10
10
|
<div class="content flex flex-wrap">
|
|
11
11
|
<span>正确答案:</span>
|
|
12
|
-
${
|
|
13
|
-
<span style="margin-right:10px">填空${i+1}: ${e.title}</span>
|
|
14
|
-
`:"")}
|
|
12
|
+
${s.map((e,s)=>e.title?t`<span style="margin-right:10px">填空${s+1}: ${e.title}</span>`:"")}
|
|
15
13
|
</div>
|
|
16
14
|
`:""}
|
|
17
15
|
${this.analysis?t`<div style="color:#909399;font-size:12px;margin-top:8px">解析: ${this.analysis}</div>`:""}
|
|
16
|
+
${this["show-category"]&&this._categoryId?t`<div class="section-row"><span class="value-text">分类:${this._categoryLabel()}</span></div>`:""}
|
|
17
|
+
${this["show-tag"]&&this._selectedTagList.length?t`
|
|
18
|
+
<div class="section-row">
|
|
19
|
+
<span class="value-text">标签/关键信息:</span>
|
|
20
|
+
<div class="tag-list" style="margin-top:6px">
|
|
21
|
+
${this._selectedTagList.map(e=>t`<span class="tag-item">${e.tagName}</span>`)}
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
`:""}
|
|
25
|
+
${this._renderResourceSection()}
|
|
26
|
+
</div>
|
|
27
|
+
`}_renderTagSection(){return this["show-tag"]?t`
|
|
28
|
+
<div class="flex flex-items-start section-row">
|
|
29
|
+
<div class="label"><span>标签:</span></div>
|
|
30
|
+
<div style="flex:1">
|
|
31
|
+
<div class="tag-list">
|
|
32
|
+
${this._selectedTagList.length?this._selectedTagList.map(e=>t`
|
|
33
|
+
<span class="tag-item">
|
|
34
|
+
${e.tagName}
|
|
35
|
+
${this["is-save"]?"":t`<span class="close" @click=${()=>this._removeTag(e.tagId)}>×</span>`}
|
|
36
|
+
</span>
|
|
37
|
+
`):t`<span class="tag-hint">暂无标签/关键信息</span>`}
|
|
38
|
+
</div>
|
|
39
|
+
${this["is-edit"]&&!this["is-save"]?t`<div style="margin-top:8px"><span class="el-link" @click=${()=>this._chooseTag()}>选择</span></div>`:""}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
`:""}_renderCategorySection(){return this["show-category"]?t`
|
|
43
|
+
<div class="flex flex-items-start section-row">
|
|
44
|
+
<div class="label"><span>分类:</span></div>
|
|
45
|
+
<div style="flex:1">
|
|
46
|
+
${this["is-edit"]?t`
|
|
47
|
+
<select class="el-select" .value=${String(this._categoryId)} ?disabled=${this["is-save"]}
|
|
48
|
+
@change=${t=>this._onCategoryChange(t.target.value)}>
|
|
49
|
+
<option value="">选择分类</option>
|
|
50
|
+
${this["category-list"].map(e=>t`
|
|
51
|
+
<option value=${String(e.categoryId)} ?selected=${String(e.categoryId)===String(this._categoryId)}>${e.title||e.categoryName}</option>
|
|
52
|
+
`)}
|
|
53
|
+
</select>
|
|
54
|
+
`:t`<span class="value-text">${this._categoryLabel()}</span>`}
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
`:""}_renderResourceSection(){if(!this["show-resource"])return"";const e=this._imageResources(),s=this._videoResource();return t`
|
|
58
|
+
<div class="flex flex-items-start section-row">
|
|
59
|
+
<div class="label"><span>资源:</span></div>
|
|
60
|
+
<div style="flex:1">
|
|
61
|
+
<div class="resource-summary">图片 ${e.length} 张${s?.url?",含视频资源":""}</div>
|
|
62
|
+
${e.length?t`
|
|
63
|
+
<div class="resource-thumbs">
|
|
64
|
+
${e.slice(0,4).map(e=>t`<img class="resource-thumb" src=${e} alt="resource" />`)}
|
|
65
|
+
</div>
|
|
66
|
+
`:""}
|
|
67
|
+
${s?.url?t`<div style="margin-top:8px"><a class="el-link" href=${s.url} target="_blank" rel="noreferrer">查看视频</a></div>`:""}
|
|
68
|
+
${e.length||s?.url?"":t`<div class="tag-hint">暂无资源</div>`}
|
|
69
|
+
</div>
|
|
18
70
|
</div>
|
|
19
71
|
`}_renderEdit(){return t`
|
|
20
72
|
<div class="flex flex-items-start">
|
|
21
73
|
<div class="label"><span>题目:</span></div>
|
|
22
74
|
<div style="flex:1">
|
|
23
75
|
<div class="el-input">
|
|
24
|
-
<textarea rows="3" .value=${this._title} ?disabled=${this
|
|
76
|
+
<textarea rows="3" .value=${this._title} ?disabled=${this["is-save"]}
|
|
25
77
|
maxlength=${this.TITLE_MAX}
|
|
26
78
|
@input=${t=>this._onTitleInput(t)}
|
|
27
79
|
placeholder="【填空题】请输入问题"></textarea>
|
|
@@ -31,37 +83,41 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
31
83
|
</div>
|
|
32
84
|
|
|
33
85
|
<div class="flex flex-justify-end">
|
|
34
|
-
<span class="el-link ${this
|
|
35
|
-
@click=${()=>{this
|
|
86
|
+
<span class="el-link ${this["is-save"]?"is-disabled":""}"
|
|
87
|
+
@click=${()=>{this["is-save"]||this._addBlank()}}>插入填空符</span>
|
|
36
88
|
</div>
|
|
37
89
|
|
|
38
|
-
|
|
39
|
-
<div class="
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
90
|
+
<div class="flex flex-items-center" style="margin-top:12px">
|
|
91
|
+
<div class="label"><span>答题设置:</span></div>
|
|
92
|
+
<label class="el-checkbox">
|
|
93
|
+
<input type="checkbox" .checked=${this._isInOrder}
|
|
94
|
+
@change=${t=>{this._isInOrder=t.target.checked}} />
|
|
95
|
+
答案不分顺序
|
|
96
|
+
</label>
|
|
97
|
+
<label class="el-checkbox">
|
|
98
|
+
<input type="checkbox" .checked=${this._isIgnoreCase}
|
|
99
|
+
@change=${t=>{this._isIgnoreCase=t.target.checked}} />
|
|
100
|
+
忽略大小写
|
|
101
|
+
</label>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
${this._renderTagSection()}
|
|
105
|
+
|
|
106
|
+
${this._renderCategorySection()}
|
|
107
|
+
|
|
108
|
+
${this._renderResourceSection()}
|
|
53
109
|
|
|
54
|
-
${this._answers.map((e,
|
|
110
|
+
${this._answers.map((e,s)=>t`
|
|
55
111
|
<div class="answer-item" style="margin-top:12px">
|
|
56
|
-
<div class="label"><span>第${
|
|
112
|
+
<div class="label"><span>第${s+1}空答案:</span></div>
|
|
57
113
|
<div class="answer-tags">
|
|
58
|
-
${e.title.split(",").filter(Boolean).map(
|
|
114
|
+
${e.title.split(",").filter(Boolean).map(s=>t`
|
|
59
115
|
<span class="el-tag">
|
|
60
|
-
${
|
|
61
|
-
${this
|
|
116
|
+
${s}
|
|
117
|
+
${this["is-save"]?"":t`<span class="el-tag__close" @click=${()=>this._closeTag(s,e)}>×</span>`}
|
|
62
118
|
</span>
|
|
63
119
|
`)}
|
|
64
|
-
${this
|
|
120
|
+
${this["is-save"]?"":t`
|
|
65
121
|
${e.showInput?t`
|
|
66
122
|
<input type="text" class="el-input--small"
|
|
67
123
|
@keydown=${t=>{"Enter"===t.key&&this._handleAddTag(e)}}
|
|
@@ -84,10 +140,10 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
84
140
|
<div style="flex:1">
|
|
85
141
|
<qxs-blocksuite-editor
|
|
86
142
|
.content=${this._richText}
|
|
87
|
-
.
|
|
143
|
+
.upload-image=${this["upload-image"]}
|
|
88
144
|
?is-edit=${!0}
|
|
89
145
|
></qxs-blocksuite-editor>
|
|
90
|
-
${this
|
|
146
|
+
${this["show-action"]?"":t`
|
|
91
147
|
<div class="flex flex-justify-end" style="margin-top:8px">
|
|
92
148
|
<span class="el-link" style="color:#f56c6c" @click=${()=>{this._showRichText=!1,this._richText=""}}>删除富文本</span>
|
|
93
149
|
</div>
|
|
@@ -96,7 +152,7 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
96
152
|
</div>
|
|
97
153
|
`:""}
|
|
98
154
|
|
|
99
|
-
${this
|
|
155
|
+
${this["show-analysis"]?t`
|
|
100
156
|
<div class="flex flex-items-start" style="margin-top:12px">
|
|
101
157
|
<div class="label"><span>解析:</span></div>
|
|
102
158
|
<div style="flex:1">
|
|
@@ -109,16 +165,16 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
109
165
|
</div>
|
|
110
166
|
`:""}
|
|
111
167
|
`}render(){return t`
|
|
112
|
-
<qxs-subject-layout .
|
|
168
|
+
<qxs-subject-layout .show-edit=${this["is-edit"]}>
|
|
113
169
|
<div slot="preview">${this._renderPreview()}</div>
|
|
114
170
|
<div slot="edit">${this._renderEdit()}</div>
|
|
115
|
-
${this
|
|
171
|
+
${this["show-action"]?t`
|
|
116
172
|
<qxs-subject-action
|
|
117
|
-
.
|
|
118
|
-
.
|
|
119
|
-
.
|
|
120
|
-
.
|
|
121
|
-
exam-answer-relation-type=${this
|
|
173
|
+
.is-edit=${this["is-edit"]}
|
|
174
|
+
.is-set=${this["is-set"]}
|
|
175
|
+
.show-add=${this["show-add"]}
|
|
176
|
+
.show-rich-text=${this._showRichText}
|
|
177
|
+
exam-answer-relation-type=${this["exam-answer-relation-type"]}
|
|
122
178
|
@delete=${()=>this._emit("delete")}
|
|
123
179
|
@save=${this._save}
|
|
124
180
|
@edit=${()=>this._emit("edit")}
|
|
@@ -128,7 +184,7 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
128
184
|
></qxs-subject-action>
|
|
129
185
|
`:""}
|
|
130
186
|
</qxs-subject-layout>
|
|
131
|
-
`}};
|
|
187
|
+
`}};p.styles=e`
|
|
132
188
|
:host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
|
|
133
189
|
*, ::before, ::after { box-sizing: border-box; }
|
|
134
190
|
|
|
@@ -159,7 +215,6 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
159
215
|
font-size: 12px; color: #909399; line-height: 1; pointer-events: none;
|
|
160
216
|
}
|
|
161
217
|
|
|
162
|
-
/* Tag style */
|
|
163
218
|
.el-tag {
|
|
164
219
|
display: inline-flex; align-items: center; height: 24px; padding: 0 9px;
|
|
165
220
|
font-size: 12px; line-height: 1; color: #3D61E3; background: #ecf5ff;
|
|
@@ -172,7 +227,6 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
172
227
|
}
|
|
173
228
|
.el-tag .el-tag__close:hover { background: #909399; color: #fff; }
|
|
174
229
|
|
|
175
|
-
/* Button small style */
|
|
176
230
|
.el-button--small {
|
|
177
231
|
display: inline-flex; align-items: center; gap: 4px;
|
|
178
232
|
height: 24px; padding: 0 10px; font-size: 12px; line-height: 1;
|
|
@@ -181,12 +235,10 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
181
235
|
}
|
|
182
236
|
.el-button--small:hover { color: #3D61E3; border-color: #c6e2ff; background-color: #ecf5ff; }
|
|
183
237
|
|
|
184
|
-
/* Link style */
|
|
185
238
|
.el-link { color: #3D61E3; cursor: pointer; font-size: 12px; text-decoration: none; }
|
|
186
239
|
.el-link:hover { color: #2D4CB8; }
|
|
187
240
|
.el-link.is-disabled { color: #c0c4cc; cursor: not-allowed; }
|
|
188
241
|
|
|
189
|
-
/* Input small for tag */
|
|
190
242
|
.el-input--small { width: 80px; }
|
|
191
243
|
.el-input--small input {
|
|
192
244
|
height: 24px; padding: 0 8px; font-size: 12px; line-height: 24px;
|
|
@@ -194,7 +246,6 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
194
246
|
}
|
|
195
247
|
.el-input--small input:focus { border-color: #3D61E3; outline: none; }
|
|
196
248
|
|
|
197
|
-
/* Checkbox style */
|
|
198
249
|
.el-checkbox {
|
|
199
250
|
display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
|
|
200
251
|
font-size: 13px; color: #606266; user-select: none; margin-right: 16px;
|
|
@@ -206,5 +257,33 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s,state a
|
|
|
206
257
|
.answer-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
|
|
207
258
|
.answer-item .label { min-width: 70px; padding-top: 0; color: #909399; }
|
|
208
259
|
.answer-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
|
|
209
|
-
|
|
260
|
+
|
|
261
|
+
.section-row { margin-top: 12px; }
|
|
262
|
+
.value-text { font-size: 13px; color: #606266; white-space: pre-wrap; }
|
|
263
|
+
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 32px; }
|
|
264
|
+
.tag-item {
|
|
265
|
+
display: inline-flex; align-items: center; gap: 4px;
|
|
266
|
+
padding: 4px 8px; font-size: 12px; line-height: 1;
|
|
267
|
+
color: #3D61E3; background: #ecf5ff; border: 1px solid #d9ecff; border-radius: 4px;
|
|
268
|
+
}
|
|
269
|
+
.tag-item .close { cursor: pointer; color: #909399; }
|
|
270
|
+
.tag-item .close:hover { color: #f56c6c; }
|
|
271
|
+
.tag-hint { font-size: 12px; color: #909399; }
|
|
272
|
+
|
|
273
|
+
.el-select {
|
|
274
|
+
width: 150px; height: 32px; border: 1px solid #dcdfe6; border-radius: 3px;
|
|
275
|
+
padding: 0 8px; font-size: 13px; background: #fff; appearance: none;
|
|
276
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c0c4cc' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
|
|
277
|
+
background-repeat: no-repeat; background-position: right 8px center;
|
|
278
|
+
}
|
|
279
|
+
.el-select:focus { border-color: #3D61E3; outline: none; }
|
|
280
|
+
.el-select:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }
|
|
281
|
+
|
|
282
|
+
.resource-summary { font-size: 12px; color: #606266; }
|
|
283
|
+
.resource-thumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
|
|
284
|
+
.resource-thumb {
|
|
285
|
+
width: 72px; height: 72px; object-fit: cover; border-radius: 6px;
|
|
286
|
+
border: 1px solid #e4e7ed; background: #f5f7fa;
|
|
287
|
+
}
|
|
288
|
+
`,c([i({type:Number,attribute:"order-index"})],p.prototype,"order-index",2),c([i({type:String})],p.prototype,"title",2),c([i({type:String,attribute:"custom-id"})],p.prototype,"custom-id",2),c([i({type:Boolean,attribute:"is-edit"})],p.prototype,"is-edit",2),c([i({type:Boolean,attribute:"is-save"})],p.prototype,"is-save",2),c([i({type:Boolean,attribute:"is-set"})],p.prototype,"is-set",2),c([i({type:Boolean,attribute:"is-key"})],p.prototype,"is-key",2),c([i({type:Boolean,attribute:"show-action"})],p.prototype,"show-action",2),c([i({type:Boolean,attribute:"show-add"})],p.prototype,"show-add",2),c([i({type:Boolean,attribute:"show-answer-setting"})],p.prototype,"show-answer-setting",2),c([i({type:Boolean,attribute:"show-analysis"})],p.prototype,"show-analysis",2),c([i({type:String,attribute:"rich-text-content"})],p.prototype,"rich-text-content",2),c([i({type:String})],p.prototype,"analysis",2),c([i({type:Number,attribute:"exam-answer-relation-type"})],p.prototype,"exam-answer-relation-type",2),c([i({type:String,attribute:"exam-expand"})],p.prototype,"exam-expand",2),c([i({type:Number,attribute:"exam-id"})],p.prototype,"exam-id",2),c([i({type:String,attribute:"category-id"})],p.prototype,"category-id",2),c([i({type:Object,attribute:"exam-answer-setting"})],p.prototype,"exam-answer-setting",2),c([i({type:Object,attribute:"upload-image"})],p.prototype,"upload-image",2),c([i({type:Array,attribute:"answer-list"})],p.prototype,"answer-list",2),c([i({type:Array,attribute:"tag-list"})],p.prototype,"tag-list",2),c([i({type:Array,attribute:"category-list"})],p.prototype,"category-list",2),c([i({type:Array,attribute:"resource-list"})],p.prototype,"resource-list",2),c([i({type:Boolean,attribute:"show-tag"})],p.prototype,"show-tag",2),c([i({type:Boolean,attribute:"show-category"})],p.prototype,"show-category",2),c([i({type:Boolean,attribute:"show-resource"})],p.prototype,"show-resource",2),c([i({type:String,attribute:"model-value"})],p.prototype,"model-value",2),c([i({type:Boolean,attribute:"use-model"})],p.prototype,"use-model",2),c([a()],p.prototype,"_title",2),c([a()],p.prototype,"_analysis",2),c([a()],p.prototype,"_answers",2),c([a()],p.prototype,"_isInOrder",2),c([a()],p.prototype,"_isIgnoreCase",2),c([a()],p.prototype,"_showRichText",2),c([a()],p.prototype,"_richText",2),c([a()],p.prototype,"_selectedTagList",2),c([a()],p.prototype,"_categoryId",2),p=c([r("qxs-blank-fill")],p);export{p as QxsBlankFill};
|
|
210
289
|
//# sourceMappingURL=blank-fill.mjs.map
|