@qxs-bns/components-wc 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +1,97 @@
1
- import{css as e,LitElement as t,html as i}from"lit";import{property as s,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{SubjectError as n}from"./single.mjs";import{SubjectType as a}from"./types.mjs";var l=Object.defineProperty,d=Object.getOwnPropertyDescriptor,p=(e,t,i,s)=>{for(var r,o=s>1?void 0:s?d(t,i):t,n=e.length-1;n>=0;n--)(r=e[n])&&(o=(s?r(t,i,o):r(o))||o);return s&&o&&l(t,i,o),o};const h=[{bg:"#ecf5ff",color:"#3D61E3",border:"#d9ecff"},{bg:"#f0f9eb",color:"#67c23a",border:"#c2e7b0"},{bg:"#fdf6ec",color:"#e6a23c",border:"#faecd8"},{bg:"#fef0f0",color:"#f56c6c",border:"#fde2e2"},{bg:"#f4f4f5",color:"#909399",border:"#e9e9eb"}];let c=class extends t{constructor(){super(...arguments),this._iconPlus=i`<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>`,this._iconRemove=i`<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>`,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-answer-setting"]={isInOrder:!0,isIgnoreCase:!0,keywordCount:1},this["upload-image"]=async e=>new Promise((t,i)=>{const s=new FileReader;s.onload=e=>t(e.target?.result),s.onerror=i,s.readAsDataURL(e)}),this["answer-list"]=[],this["model-value"]="",this["use-model"]=!1,this._answers=[{title:"",tag:"",showInput:!1}],this._title="",this._analysis="",this._isInOrder=!0,this._isIgnoreCase=!0,this._keywordCount=1,this._correct="",this._showRichText=!1,this._richText="",this.TITLE_MAX=200}willUpdate(e){e.has("is-edit")&&this["is-edit"]&&this._syncProps(),!this["is-edit"]&&(e.has("title")||e.has("answer-list")||e.has("analysis")||e.has("exam-answer-setting")||e.has("rich-text-content")||e.has("exam-expand"))&&this._syncProps(),e.has("model-value")&&this["use-model"]&&(this._title=this["model-value"])}_normalizeAnswerTitle(e){return String(e?.title??e?.answer??"")}_normalizedAnswerList(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(Array.isArray(e)?e:[]).map(e=>({...e,answerId:e?.answerId??e?.examAnswerId,title:this._normalizeAnswerTitle(e)}))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this["answer-list"]?.length?this._answers=this._normalizedAnswerList(this["answer-list"]).map(e=>({title:e.title||"",tag:"",showInput:!1,answerId:e.answerId,customAnswerId:e.customAnswerId})):this._answers=[{title:"",tag:"",showInput:!1}],this["exam-answer-setting"]&&(this._isInOrder=!!this["exam-answer-setting"].isInOrder,this._isIgnoreCase=!!this["exam-answer-setting"].isIgnoreCase,this._keywordCount=this["exam-answer-setting"].keywordCount||1),this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this._correct=this["exam-expand"]||""}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value,this["use-model"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_addTag(e){const t={...this._answers[e]};t.tag&&(t.title=t.title?[t.title,t.tag].join(","):t.tag,t.tag=""),t.showInput=!1,this._answers=this._answers.map((i,s)=>s===e?t:i)}_closeTag(e,t){const i={...this._answers[t]};i.title=i.title.split(",").filter(t=>t!==e).join(","),this._answers=this._answers.map((e,s)=>s===t?i:e)}async toJSON(){return new Promise((e,t)=>{const i={customId:this["custom-id"]||void 0,answerType:"text_fill",orderIndex:this["order-index"]},s=this["is-edit"]?this._title:this.title||"",r=this["is-edit"]?this._answers:this._normalizedAnswerList(this["answer-list"]||[]),o=this["is-edit"]?this._analysis:this.analysis||"",l=this["is-edit"]?this._correct:this["exam-expand"]||"",d=this["is-edit"]?this._keywordCount:this["exam-answer-setting"]?.keywordCount||1,p=this["is-edit"]?this._isInOrder:this["exam-answer-setting"]?.isInOrder??!0,h=this["is-edit"]?this._isIgnoreCase:this["exam-answer-setting"]?.isIgnoreCase??!0,c=this["is-edit"]?this._showRichText:!!this["rich-text-content"],x=this["is-edit"]?this._richText:this["rich-text-content"]||"";if(!s)return void t(new n("题目标题不能为空!","EMPTY_TITLE","title",i));if(d||l){if(!d)return void t(new n("请完善答题设置!","NO_KEYWORD_COUNT","keywordCount",i));if(!l)return void t(new n("请输入问题正确答案!","NO_CORRECT_ANSWER","correct",i));if(r.length!==d)return void t(new n("关键词个数设置有误!","KEYWORD_COUNT_MISMATCH","answers",i));const e=[];if(r.forEach((t,i)=>{this._normalizeAnswerTitle(t)||e.push(`关键词${i+1}未设置`)}),e.length)return void t(new n(e.join(","),"KEYWORD_EMPTY","answers",i))}const w={answerType:a.TEXT_FILL,title:s,answers:r.filter(e=>this._normalizeAnswerTitle(e)).map(e=>({title:this._normalizeAnswerTitle(e),...e.answerId?{answerId:e.answerId}:{},...e.customAnswerId?{customAnswerId:e.customAnswerId}:{}})),analysis:o,isSetCorrectAnswer:!!l,isKey:this["is-key"],examExpand:l,examAnswerSettingBO:{isIgnoreCase:h,isInOrder:p,keywordCount:d},examRichTextContent:c?x:""};this["custom-id"]&&(w.customId=this["custom-id"]),e(w)})}_addAnswer(){this["is-save"]||(this._answers=[...this._answers,{title:"",tag:"",showInput:!1}])}_deleteAnswer(e){this._answers.length<2||this["is-save"]||(this._answers=this._answers.filter((t,i)=>i!==e))}async _save(e){e?.stopImmediatePropagation();try{const e=await this.toJSON();this._emit("save",e)}catch(e){!function(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)}(e.message)}}validate(){const e=[],t={customId:this["custom-id"]||void 0,answerType:"text_fill",orderIndex:this["order-index"]},i=this["is-edit"]?this._title:this.title||"",s=this["is-edit"]?this._answers:this._normalizedAnswerList(this["answer-list"]||[]),r=this["is-edit"]?this._correct:this["exam-expand"]||"",o=this["is-edit"]?this._keywordCount:this["exam-answer-setting"]?.keywordCount||1;return i||e.push(new n("题目标题不能为空!","EMPTY_TITLE","title",t)),(o||r)&&(o||e.push(new n("请完善答题设置!","NO_KEYWORD_COUNT","keywordCount",t)),r||e.push(new n("请输入问题正确答案!","NO_CORRECT_ANSWER","correct",t)),s.length!==o&&e.push(new n("关键词个数设置有误!","KEYWORD_COUNT_MISMATCH","answers",t)),s.forEach((i,s)=>{this._normalizeAnswerTitle(i)||e.push(new n(`关键词${s+1}未设置`,"KEYWORD_EMPTY","answers",t))})),e}_renderPreview(){const e=this["is-edit"]?this._answers:this._normalizedAnswerList(this["answer-list"]||[]),t=this["is-edit"]?this._correct:this["exam-expand"]||"";return i`
1
+ import{css as t,LitElement as e,html as s}from"lit";import{property as i,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{SubjectError as a}from"./single.mjs";import{SubjectType as n}from"./types.mjs";var l=Object.defineProperty,d=Object.getOwnPropertyDescriptor,h=(t,e,s,i)=>{for(var r,o=i>1?void 0:i?d(e,s):e,a=t.length-1;a>=0;a--)(r=t[a])&&(o=(i?r(e,s,o):r(o))||o);return i&&o&&l(e,s,o),o};const c=[{bg:"#ecf5ff",color:"#3D61E3",border:"#d9ecff"},{bg:"#f0f9eb",color:"#67c23a",border:"#c2e7b0"},{bg:"#fdf6ec",color:"#e6a23c",border:"#faecd8"},{bg:"#fef0f0",color:"#f56c6c",border:"#fde2e2"},{bg:"#f4f4f5",color:"#909399",border:"#e9e9eb"}];let p=class extends e{constructor(){super(...arguments),this._iconPlus=s`<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>`,this._iconRemove=s`<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>`,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._answers=[{title:"",tag:"",showInput:!1}],this._title="",this._analysis="",this._isInOrder=!1,this._isIgnoreCase=!0,this._keywordCount=null,this._correct="",this._showRichText=!1,this._richText="",this._selectedTagList=[],this._categoryId="",this.TITLE_MAX=200}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("exam-expand")||t.has("tag-list")||t.has("category-id"))&&this._syncProps(),t.has("model-value")&&this["use-model"]&&(this._title=this["model-value"]),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??"")}_normalizedAnswerList(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(Array.isArray(t)?t:[]).map(t=>({...t,answerId:t?.answerId??t?.examAnswerId,title:this._normalizeAnswerTitle(t)}))}_filledAnswers(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(t=>this._normalizeAnswerTitle(t))}_readKeywordCount(t){return t&&void 0!==t.keywordCount&&null!==t.keywordCount&&""!==t.keywordCount?Number(t.keywordCount):null}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this["answer-list"]?.length?this._answers=this._normalizedAnswerList(this["answer-list"]).map(t=>({title:t.title||"",tag:"",showInput:!1,answerId:t.answerId,customAnswerId:t.customAnswerId})):this._answers=[{title:"",tag:"",showInput:!1}],this._isInOrder=!!this["exam-answer-setting"]?.isInOrder,this._isIgnoreCase=this["exam-answer-setting"]?.isIgnoreCase??!0,this._keywordCount=this._readKeywordCount(this["exam-answer-setting"]),this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this._correct=this["exam-expand"]||"",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}))}_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"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_addTag(t){const e={...this._answers[t]};e.tag&&(e.title=e.title?[e.title,e.tag].join(","):e.tag,e.tag=""),e.showInput=!1,this._answers=this._answers.map((s,i)=>i===t?e:s)}_closeTag(t,e){const s={...this._answers[e]};s.title=s.title.split(",").filter(e=>e!==t).join(","),this._answers=this._answers.map((t,i)=>i===e?s:t)}_addAnswer(){this._answers=[...this._answers,{title:"",tag:"",showInput:!1}]}_deleteAnswer(t){this._answers.length<2||(this._answers=this._answers.filter((e,s)=>s!==t))}_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||"未选择分类"}_validateState(t){const{row:e,title:s,answers:i,correct:r,keywordCount:o}=t;if(!s)return new a("题目标题不能为空!","EMPTY_TITLE","title",e);const n=this._filledAnswers(i);return!!r||null!==o||n.length>0?r?!o||o<1?new a("请完善答题设置!","NO_KEYWORD_COUNT","keywordCount",e):n.length?o>n.length?new a("关键词个数设置有误!","KEYWORD_COUNT_MISMATCH","answers",e):null:new a("请设置关键词","NO_KEYWORDS","answers",e):new a("请输入问题正确答案!","NO_CORRECT_ANSWER","correct",e):null}async toJSON(){return new Promise((t,e)=>{const s={customId:this["custom-id"]||void 0,answerType:"text_fill",orderIndex:this["order-index"]},i=this["is-edit"]?this._title:this.title||"",r=this["is-edit"]?this._answers:this._normalizedAnswerList(this["answer-list"]||[]),o=this["is-edit"]?this._analysis:this.analysis||"",a=this["is-edit"]?this._correct:this["exam-expand"]||"",l=this["is-edit"]?this._keywordCount:this._readKeywordCount(this["exam-answer-setting"]),d=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"],p=this["is-edit"]?this._richText:this["rich-text-content"]||"",g=this._validateState({row:s,title:i,answers:r,correct:a,keywordCount:l});if(g)return void e(g);const u={answerType:n.TEXT_FILL,examTypeEnum:n.TEXT_FILL,title:i,answers:this._filledAnswers(r).map((t,e)=>{const s=this._normalizeAnswerTitle(t),i={title:s,answer:s,orderIndex:e+1};return t.answerId&&(i.answerId=t.answerId,i.examAnswerId=t.answerId),t.customAnswerId&&(i.customAnswerId=t.customAnswerId),i}),analysis:o,isSetCorrectAnswer:!!a,isKey:this["is-key"],examExpand:a,examAnswerSettingBO:{isIgnoreCase:h,isInOrder:d,...null!==l?{keywordCount:l}:{}},examAnswerSettingVO:{isIgnoreCase:h,isInOrder:d,...null!==l?{keywordCount:l}:{}},examRichTextContent:c?p:""};this["custom-id"]&&(u.customId=this["custom-id"]),t(u)})}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={customId:this["custom-id"]||void 0,answerType:"text_fill",orderIndex:this["order-index"]},e=this["is-edit"]?this._title:this.title||"",s=this["is-edit"]?this._answers:this._normalizedAnswerList(this["answer-list"]||[]),i=this["is-edit"]?this._correct:this["exam-expand"]||"",r=this["is-edit"]?this._keywordCount:this._readKeywordCount(this["exam-answer-setting"]),o=this._validateState({row:t,title:e,answers:s,correct:i,keywordCount:r});return o?[o]:[]}_renderPreview(){const t=this["is-edit"]?this._answers:this._normalizedAnswerList(this["answer-list"]||[]),e=this["is-edit"]?this._correct:this["exam-expand"]||"";return s`
2
2
  <div class="preview">
3
3
  <span class="title">${this["order-index"]+1}.${this.title}(问答题)</span>
4
- ${this["rich-text-content"]?i`<div class="rich-text" .innerHTML=${this["rich-text-content"]}></div>`:""}
5
- ${e.some(e=>e.title)?i`
4
+ ${this["rich-text-content"]?s`<div class="rich-text" .innerHTML=${this["rich-text-content"]}></div>`:""}
5
+ ${this._filledAnswers(t).length?s`
6
6
  <div style="margin-top:8px;color:#a8abb2">
7
- ${e.map((e,t)=>e.title?i`
8
- <span style="margin-right:10px">关键词${t+1}: ${e.title}</span>
9
- `:"")}
7
+ ${this._filledAnswers(t).map((t,e)=>s`<span style="margin-right:10px">关键词${e+1}: ${this._normalizeAnswerTitle(t)}</span>`)}
10
8
  </div>
11
9
  `:""}
12
- ${t?i`<div style="margin-top:8px;color:#a8abb2">正确答案:${t}</div>`:""}
13
- ${this.analysis?i`<div style="color:#909399;font-size:12px;margin-top:8px">解析: ${this.analysis}</div>`:""}
10
+ ${e?s`<div style="margin-top:8px;color:#a8abb2">正确答案:${e}</div>`:""}
11
+ ${this.analysis?s`<div style="color:#909399;font-size:12px;margin-top:8px">解析: ${this.analysis}</div>`:""}
12
+ ${this["show-category"]&&this._categoryId?s`<div class="section-row"><span class="value-text">分类:${this._categoryLabel()}</span></div>`:""}
13
+ ${this._renderResourceSection()}
14
14
  </div>
15
- `}_renderEdit(){return i`
15
+ `}_renderCategorySection(){return this["show-category"]?s`
16
+ <div class="flex-items-start section-row">
17
+ <div class="label"><span>分类:</span></div>
18
+ <div style="flex:1">
19
+ ${this["is-edit"]?s`
20
+ <select class="el-select" .value=${String(this._categoryId)}
21
+ @change=${t=>this._onCategoryChange(t.target.value)}>
22
+ <option value="">选择分类</option>
23
+ ${this["category-list"].map(t=>s`
24
+ <option value=${String(t.categoryId)} ?selected=${String(t.categoryId)===String(this._categoryId)}>${t.title||t.categoryName}</option>
25
+ `)}
26
+ </select>
27
+ `:s`<span class="value-text">${this._categoryLabel()}</span>`}
28
+ </div>
29
+ </div>
30
+ `:""}_renderResourceSection(){if(!this["show-resource"])return"";const t=this._imageResources(),e=this._videoResource();return s`
31
+ <div class="flex-items-start section-row">
32
+ <div class="label"><span>资源:</span></div>
33
+ <div style="flex:1">
34
+ <div class="resource-summary">图片 ${t.length} 张${e?.url?",含视频资源":""}</div>
35
+ ${t.length?s`
36
+ <div class="resource-thumbs">
37
+ ${t.slice(0,4).map(t=>s`<img class="resource-thumb" src=${t} alt="resource" />`)}
38
+ </div>
39
+ `:""}
40
+ ${e?.url?s`<div style="margin-top:8px"><a class="el-link" href=${e.url} target="_blank" rel="noreferrer">查看视频</a></div>`:""}
41
+ ${t.length||e?.url?"":s`<div class="tag-hint">暂无资源</div>`}
42
+ </div>
43
+ </div>
44
+ `}_renderEdit(){return s`
16
45
  <div class="flex-items-start">
17
46
  <div class="label"><span>题目:</span></div>
18
47
  <div style="flex:1">
19
48
  <div class="el-input">
20
- <textarea rows="2" .value=${this._title} ?disabled=${this["is-save"]}
49
+ <textarea rows="2" .value=${this._title}
21
50
  maxlength=${this.TITLE_MAX}
22
- @input=${e=>this._onTitleInput(e)}
51
+ @input=${t=>this._onTitleInput(t)}
23
52
  placeholder="【问答题】请输入问题"></textarea>
24
53
  <span class="char-counter">${this._title.length}/${this.TITLE_MAX}</span>
25
54
  </div>
26
55
  </div>
27
56
  </div>
28
57
 
29
- ${this["show-answer-setting"]?i`
30
- <div class="flex-items-start" style="margin-top:12px">
31
- <div class="label"><span>答题设置:</span></div>
32
- <div style="flex:1;display:flex;align-items:center;flex-wrap:wrap;gap:8px">
33
- <span style="font-size:13px;color:#606266">共答对</span>
34
- <input type="number" style="width:60px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:13px"
35
- .value=${String(this._keywordCount)} min="1"
36
- @change=${e=>{this._keywordCount=Number(e.target.value)}} />
37
- <span style="font-size:13px;color:#606266">个关键词,算是正确的</span>
38
- <label style="display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266">
39
- <input type="checkbox" .checked=${this._isInOrder}
40
- @change=${e=>{this._isInOrder=e.target.checked}} />
41
- 答案不分顺序
42
- </label>
43
- <label style="display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266">
44
- <input type="checkbox" .checked=${this._isIgnoreCase}
45
- @change=${e=>{this._isIgnoreCase=e.target.checked}} />
46
- 忽略大小写
47
- </label>
48
- </div>
58
+ <div class="flex-items-start" style="margin-top:12px">
59
+ <div class="label"><span>答题设置:</span></div>
60
+ <div style="flex:1;display:flex;align-items:center;flex-wrap:wrap;gap:8px">
61
+ <span style="font-size:13px;color:#606266">共答对</span>
62
+ <input
63
+ type="number"
64
+ style="width:60px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:13px"
65
+ .value=${null===this._keywordCount?"":String(this._keywordCount)}
66
+ min="1"
67
+ @change=${t=>{const e=t.target.value;this._keywordCount=""===e?null:Number(e)}} />
68
+ <span style="font-size:13px;color:#606266">个关键词,算是正确的</span>
69
+ <label style="display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266">
70
+ <input type="checkbox" .checked=${this._isInOrder}
71
+ @change=${t=>{this._isInOrder=t.target.checked}} />
72
+ 答案不分顺序
73
+ </label>
74
+ <label style="display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266">
75
+ <input type="checkbox" .checked=${this._isIgnoreCase}
76
+ @change=${t=>{this._isIgnoreCase=t.target.checked}} />
77
+ 忽略大小写
78
+ </label>
49
79
  </div>
50
- `:""}
80
+ </div>
81
+
82
+ <slot name="business-tag"></slot>
83
+
84
+ ${this._renderCategorySection()}
85
+
86
+ ${this._renderResourceSection()}
51
87
 
52
88
  <div class="flex-items-start" style="margin-top:12px">
53
89
  <div class="label"><span>答案:</span></div>
54
90
  <div style="flex:1">
55
91
  <div class="el-input">
56
- <textarea rows="2" .value=${this._correct} ?disabled=${this["is-save"]}
92
+ <textarea rows="2" .value=${this._correct}
57
93
  maxlength="200"
58
- @input=${e=>{this._correct=e.target.value}}
94
+ @input=${t=>{this._correct=t.target.value}}
59
95
  placeholder="请输入正确答案"></textarea>
60
96
  <span class="char-counter">${this._correct.length}/200</span>
61
97
  </div>
@@ -64,37 +100,37 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s,state a
64
100
 
65
101
  <div class="answer-list" style="margin-top:12px">
66
102
  <span style="padding-left:60px;font-size:12px;color:#909399">*如遇包含特殊字符的关键词,需添加多个同义词,例:'CO₂'需添加同义词'CO2'</span>
67
- ${this._answers.map((e,t)=>i`
103
+ ${this._answers.map((t,e)=>s`
68
104
  <div class="answer-item">
69
- <span class="label">关键词${t+1}:</span>
105
+ <span class="label">关键词${e+1}:</span>
70
106
  <div class="answer-tags" style="display:flex;flex-wrap:wrap;gap:5px;align-items:center;flex:1;max-width:360px">
71
- ${e.title.split(",").filter(Boolean).map(e=>{const s=h[t%h.length];return i`
72
- <span style="display:inline-flex;align-items:center;background:${s.bg};color:${s.color};border:1px solid ${s.border};border-radius:3px;padding:2px 8px;font-size:12px;line-height:16px">
73
- ${e}
74
- ${this["is-save"]?"":i`<span style="cursor:pointer;margin-left:4px;color:#909399" @click=${()=>this._closeTag(e,t)}>×</span>`}
107
+ ${t.title.split(",").filter(Boolean).map(t=>{const i=c[e%c.length];return s`
108
+ <span style="display:inline-flex;align-items:center;background:${i.bg};color:${i.color};border:1px solid ${i.border};border-radius:3px;padding:2px 8px;font-size:12px;line-height:16px">
109
+ ${t}
110
+ <span style="cursor:pointer;margin-left:4px;color:#909399" @click=${()=>this._closeTag(t,e)}>×</span>
75
111
  </span>
76
112
  `})}
77
- ${this["is-save"]?"":i`
78
- ${e.showInput?i`
113
+ ${s`
114
+ ${t.showInput?s`
79
115
  <input type="text" style="width:80px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:12px"
80
- @keydown=${e=>{"Enter"===e.key&&this._addTag(t)}}
81
- @input=${t=>{e.tag=t.target.value}}
82
- @blur=${()=>this._addTag(t)} />
83
- <button class="el-link" @click=${()=>this._addTag(t)}>确认</button>
84
- `:i`
85
- <button class="link" @click=${()=>{this._answers=this._answers.map((e,i)=>i===t?{...e,showInput:!0}:e),this.updateComplete.then(()=>{this.shadowRoot?.querySelector('input[style*="width:80px"]')?.focus()})}}>
86
- ${e.title?"添加同义词":"添加关键词"}
116
+ @keydown=${t=>{"Enter"===t.key&&this._addTag(e)}}
117
+ @input=${e=>{t.tag=e.target.value}}
118
+ @blur=${()=>this._addTag(e)} />
119
+ <button class="el-link" @click=${()=>this._addTag(e)}>确认</button>
120
+ `:s`
121
+ <button class="link" @click=${()=>{this._answers=this._answers.map((t,s)=>s===e?{...t,showInput:!0}:t),this.updateComplete.then(()=>{this.shadowRoot?.querySelector('input[style*="width:80px"]')?.focus()})}}>
122
+ ${t.title?"添加同义词":"添加关键词"}
87
123
  </button>
88
124
  `}
89
125
  `}
90
126
  </div>
91
- <span class="icon ${this["is-save"]?"disabled":""}" @click=${()=>this._addAnswer()}>${this._iconPlus}</span>
92
- <span class="icon ${this["is-save"]||this._answers.length<2?"disabled":""}" @click=${()=>this._deleteAnswer(t)}>${this._iconRemove}</span>
127
+ <span class="icon" @click=${()=>this._addAnswer()}>${this._iconPlus}</span>
128
+ <span class="icon ${this._answers.length<2?"disabled":""}" @click=${()=>this._deleteAnswer(e)}>${this._iconRemove}</span>
93
129
  </div>
94
130
  `)}
95
131
  </div>
96
132
 
97
- ${this._showRichText?i`
133
+ ${this._showRichText?s`
98
134
  <div class="flex-items-start" style="margin-top:12px">
99
135
  <div class="label"><span>富文本:</span></div>
100
136
  <div style="flex:1">
@@ -103,28 +139,27 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s,state a
103
139
  .upload-image=${this["upload-image"]}
104
140
  ?is-edit=${!0}
105
141
  ></qxs-blocksuite-editor>
106
- ${this["show-action"]?"":i`<div class="flex-justify-end" style="margin-top:8px"><span class="el-link danger" @click=${()=>{this._showRichText=!1,this._richText=""}}>删除富文本</span></div>`}
142
+ ${this["show-action"]?"":s`<div class="flex-justify-end" style="margin-top:8px"><span class="el-link danger" @click=${()=>{this._showRichText=!1,this._richText=""}}>删除富文本</span></div>`}
107
143
  </div>
108
144
  </div>
109
145
  `:""}
110
146
 
111
- ${this["show-analysis"]?i`
147
+ ${this["show-analysis"]?s`
112
148
  <div class="flex-items-start" style="margin-top:12px">
113
149
  <div class="label"><span>解析:</span></div>
114
150
  <div style="flex:1">
115
151
  <div class="el-input">
116
152
  <textarea rows="2" .value=${this._analysis}
117
- @input=${e=>{this._analysis=e.target.value}}
153
+ @input=${t=>{this._analysis=t.target.value}}
118
154
  placeholder="请输入题目解析"></textarea>
119
155
  </div>
120
156
  </div>
121
157
  </div>
122
158
  `:""}
123
- `}render(){return i`
159
+ `}render(){const t=this["is-edit"]?s`<div slot="edit">${this._renderEdit()}</div>`:s`<div slot="preview">${this._renderPreview()}</div>`;return s`
124
160
  <qxs-subject-layout .show-edit=${this["is-edit"]}>
125
- <div slot="preview">${this._renderPreview()}</div>
126
- <div slot="edit">${this._renderEdit()}</div>
127
- ${this["show-action"]?i`
161
+ ${t}
162
+ ${this["show-action"]?s`
128
163
  <qxs-subject-action
129
164
  .is-edit=${this["is-edit"]}
130
165
  .is-set=${this["is-set"]}
@@ -134,13 +169,13 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s,state a
134
169
  @delete=${()=>this._emit("delete")}
135
170
  @save=${this._save}
136
171
  @edit=${()=>this._emit("edit")}
137
- @add=${e=>this._emit("add",e.detail)}
138
- @set-key=${e=>{this._emit("set-key",e.detail)}}
172
+ @add=${t=>this._emit("add",t.detail)}
173
+ @set-key=${t=>{this._emit("set-key",t.detail)}}
139
174
  @on-show-rich-text=${()=>{this._showRichText=!this._showRichText,this._showRichText||(this._richText="")}}
140
175
  ></qxs-subject-action>
141
176
  `:""}
142
177
  </qxs-subject-layout>
143
- `}};c.styles=e`
178
+ `}};p.styles=t`
144
179
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
145
180
  *, ::before, ::after { box-sizing: border-box; }
146
181
 
@@ -148,11 +183,6 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s,state a
148
183
  .preview .title { font-size: 14px; color: #303133; }
149
184
  .preview .rich-text { margin-top: 8px; }
150
185
  .preview .rich-text img { max-width: 100%; }
151
- .preview-answer { display: flex; flex-direction: column; margin-top: 12px; }
152
- .preview-answer .radio { margin-top: 8px; padding-left: 8px; display: flex; align-items: center; gap: 6px; }
153
- .preview-answer .order { color: #909399; }
154
- .preview-answer .correct { color: #67c23a; }
155
- .preview-answer .result-info { color: #909399; }
156
186
 
157
187
  .flex { display: flex; }
158
188
  .flex-items-center { display: flex; align-items: center; }
@@ -177,25 +207,6 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s,state a
177
207
  .answer-list { margin-top: 12px; }
178
208
  .answer-item { display: flex; align-items: center; margin-top: 6px; border-radius: 4px; }
179
209
  .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }
180
- .answer-item .input { flex: 1; max-width: 360px; position: relative; display: block; }
181
- .answer-item .input input {
182
- height: 32px; padding: 0 50px 0 8px;
183
- font-size: 13px; line-height: 32px;
184
- border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;
185
- transition: border-color .2s; box-sizing: border-box;
186
- }
187
- .answer-item .input input:focus { border-color: #3D61E3; outline: none; }
188
- .answer-item .input input:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }
189
- .answer-item .input .char-counter {
190
- position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
191
- font-size: 12px; color: #909399; line-height: 1; pointer-events: none;
192
- }
193
-
194
- .answer-item .correct { margin: 0 10px; color: #909399; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
195
- .answer-item .correct:hover { color: #3D61E3; }
196
- .answer-item .correct.is-correct { color: #67c23a; }
197
- .answer-item .correct input { width: 14px; height: 14px; cursor: pointer; accent-color: #3D61E3; }
198
-
199
210
  .answer-item .icon {
200
211
  margin-left: 6px; cursor: pointer; display: inline-flex;
201
212
  align-items: center; justify-content: center;
@@ -205,10 +216,6 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s,state a
205
216
  }
206
217
  .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }
207
218
  .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }
208
-
209
- .answer-item .link { margin-left: 8px; color: #3D61E3; cursor: pointer; font-size: 12px; white-space: nowrap; }
210
- .answer-item .link:hover { color: #2D4CB8; }
211
-
212
219
  .answer-item .link { color: #3D61E3; cursor: pointer; font-size: 12px; white-space: nowrap; background: none; border: none; padding: 0; margin: 0; font-family: inherit; }
213
220
  .answer-item .link:hover { color: #2D4CB8; }
214
221
 
@@ -216,18 +223,28 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s,state a
216
223
  .el-link:hover { color: #2D4CB8; }
217
224
  .el-link.danger { color: #f56c6c; }
218
225
 
219
- .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9000; display: flex; align-items: center; justify-content: center; }
220
- .modal { background: #fff; border-radius: 6px; width: 520px; max-width: 90vw; box-shadow: 0 12px 32px rgba(0,0,0,.12); display: flex; flex-direction: column; }
221
- .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid #e4e7ed; }
222
- .modal-title { font-size: 14px; font-weight: 600; color: #303133; }
223
- .modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #909399; padding: 0; line-height: 1; }
224
- .modal-close:hover { color: #3D61E3; }
225
- .modal-body { padding: 20px; }
226
- .modal-body textarea { min-height: 120px; }
227
- .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4e7ed; }
228
- .modal-footer button { padding: 6px 16px; font-size: 12px; border-radius: 3px; cursor: pointer; border: 1px solid #dcdfe6; background: #fff; color: #606266; }
229
- .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }
230
- .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }
231
- .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }
232
- `,p([s({type:Number,attribute:"order-index"})],c.prototype,"order-index",2),p([s({type:String})],c.prototype,"title",2),p([s({type:String,attribute:"custom-id"})],c.prototype,"custom-id",2),p([s({type:Boolean,attribute:"is-edit"})],c.prototype,"is-edit",2),p([s({type:Boolean,attribute:"is-save"})],c.prototype,"is-save",2),p([s({type:Boolean,attribute:"is-set"})],c.prototype,"is-set",2),p([s({type:Boolean,attribute:"is-key"})],c.prototype,"is-key",2),p([s({type:Boolean,attribute:"show-action"})],c.prototype,"show-action",2),p([s({type:Boolean,attribute:"show-add"})],c.prototype,"show-add",2),p([s({type:Boolean,attribute:"show-answer-setting"})],c.prototype,"show-answer-setting",2),p([s({type:Boolean,attribute:"show-analysis"})],c.prototype,"show-analysis",2),p([s({type:String,attribute:"rich-text-content"})],c.prototype,"rich-text-content",2),p([s({type:String})],c.prototype,"analysis",2),p([s({type:Number,attribute:"exam-answer-relation-type"})],c.prototype,"exam-answer-relation-type",2),p([s({type:String,attribute:"exam-expand"})],c.prototype,"exam-expand",2),p([s({type:Object,attribute:"exam-answer-setting"})],c.prototype,"exam-answer-setting",2),p([s({type:Object,attribute:"upload-image"})],c.prototype,"upload-image",2),p([s({type:Array,attribute:"answer-list"})],c.prototype,"answer-list",2),p([s({type:String,attribute:"model-value"})],c.prototype,"model-value",2),p([s({type:Boolean,attribute:"use-model"})],c.prototype,"use-model",2),p([r()],c.prototype,"_answers",2),p([r()],c.prototype,"_title",2),p([r()],c.prototype,"_analysis",2),p([r()],c.prototype,"_isInOrder",2),p([r()],c.prototype,"_isIgnoreCase",2),p([r()],c.prototype,"_keywordCount",2),p([r()],c.prototype,"_correct",2),p([r()],c.prototype,"_showRichText",2),p([r()],c.prototype,"_richText",2),c=p([o("qxs-text-fill")],c);export{c as QxsTextFill};
226
+ .section-row { margin-top: 12px; }
227
+ .value-text { font-size: 13px; color: #606266; white-space: pre-wrap; }
228
+ .tag-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 32px; }
229
+ .tag-item {
230
+ display: inline-flex; align-items: center; gap: 4px;
231
+ padding: 4px 8px; font-size: 12px; line-height: 1;
232
+ color: #3D61E3; background: #ecf5ff; border: 1px solid #d9ecff; border-radius: 4px;
233
+ }
234
+ .tag-item .close { cursor: pointer; color: #909399; }
235
+ .tag-item .close:hover { color: #f56c6c; }
236
+ .tag-hint { font-size: 12px; color: #909399; }
237
+ .el-select {
238
+ width: 150px; height: 32px; border: 1px solid #dcdfe6; border-radius: 3px;
239
+ padding: 0 8px; font-size: 13px; background: #fff; appearance: none;
240
+ 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");
241
+ background-repeat: no-repeat; background-position: right 8px center;
242
+ }
243
+ .resource-summary { font-size: 12px; color: #606266; }
244
+ .resource-thumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
245
+ .resource-thumb {
246
+ width: 72px; height: 72px; object-fit: cover; border-radius: 6px;
247
+ border: 1px solid #e4e7ed; background: #f5f7fa;
248
+ }
249
+ `,h([i({type:Number,attribute:"order-index"})],p.prototype,"order-index",2),h([i({type:String})],p.prototype,"title",2),h([i({type:String,attribute:"custom-id"})],p.prototype,"custom-id",2),h([i({type:Boolean,attribute:"is-edit"})],p.prototype,"is-edit",2),h([i({type:Boolean,attribute:"is-save"})],p.prototype,"is-save",2),h([i({type:Boolean,attribute:"is-set"})],p.prototype,"is-set",2),h([i({type:Boolean,attribute:"is-key"})],p.prototype,"is-key",2),h([i({type:Boolean,attribute:"show-action"})],p.prototype,"show-action",2),h([i({type:Boolean,attribute:"show-add"})],p.prototype,"show-add",2),h([i({type:Boolean,attribute:"show-answer-setting"})],p.prototype,"show-answer-setting",2),h([i({type:Boolean,attribute:"show-analysis"})],p.prototype,"show-analysis",2),h([i({type:String,attribute:"rich-text-content"})],p.prototype,"rich-text-content",2),h([i({type:String})],p.prototype,"analysis",2),h([i({type:Number,attribute:"exam-answer-relation-type"})],p.prototype,"exam-answer-relation-type",2),h([i({type:String,attribute:"exam-expand"})],p.prototype,"exam-expand",2),h([i({type:Number,attribute:"exam-id"})],p.prototype,"exam-id",2),h([i({type:String,attribute:"category-id"})],p.prototype,"category-id",2),h([i({type:Object,attribute:"exam-answer-setting"})],p.prototype,"exam-answer-setting",2),h([i({type:Object,attribute:"upload-image"})],p.prototype,"upload-image",2),h([i({type:Array,attribute:"answer-list"})],p.prototype,"answer-list",2),h([i({type:Array,attribute:"tag-list"})],p.prototype,"tag-list",2),h([i({type:Array,attribute:"category-list"})],p.prototype,"category-list",2),h([i({type:Array,attribute:"resource-list"})],p.prototype,"resource-list",2),h([i({type:Boolean,attribute:"show-tag"})],p.prototype,"show-tag",2),h([i({type:Boolean,attribute:"show-category"})],p.prototype,"show-category",2),h([i({type:Boolean,attribute:"show-resource"})],p.prototype,"show-resource",2),h([i({type:Object,attribute:"search-handler"})],p.prototype,"search-handler",2),h([i({type:String,attribute:"model-value"})],p.prototype,"model-value",2),h([i({type:Boolean,attribute:"use-model"})],p.prototype,"use-model",2),h([r()],p.prototype,"_answers",2),h([r()],p.prototype,"_title",2),h([r()],p.prototype,"_analysis",2),h([r()],p.prototype,"_isInOrder",2),h([r()],p.prototype,"_isIgnoreCase",2),h([r()],p.prototype,"_keywordCount",2),h([r()],p.prototype,"_correct",2),h([r()],p.prototype,"_showRichText",2),h([r()],p.prototype,"_richText",2),h([r()],p.prototype,"_selectedTagList",2),h([r()],p.prototype,"_categoryId",2),p=h([o("qxs-text-fill")],p);export{p as QxsTextFill};
233
250
  //# sourceMappingURL=text-fill.mjs.map