mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-04 04:08:13 +00:00
2 lines
4.4 KiB
JavaScript
2 lines
4.4 KiB
JavaScript
import{d as M,k as l,r as y,ap as q,aI as z,h as x,c as b,J as S,ac as V,u as n,a as m,b as g,e as a,w as p,i as f,t as d,F as E,T as D,B as U,X as F,ad as P,ae as j,G,D as J,E as K,R as A,H}from"./index-e05985b6.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import"./el-form-item-4ed993c7.js";/* empty css *//* empty css */import{u as L}from"./diy-17e91366.js";import{S as X}from"./sortable.esm-be94e56d.js";import{r as Q}from"./range-e90b089a.js";const W={class:"content-wrap"},Y=["onClick"],Z={class:"mb-[5px]"},ee={class:"text-[#888] text-[12px] mb-[5px]"},te={class:"mt-[10px] text-right"},oe={class:"style-wrap"},ne=M({__name:"edit-form-checkbox",setup(le,{expose:T}){const e=L();e.editComponent.ignore=["componentBgUrl"],e.editComponent.verify=o=>{const t={code:!0,message:""};let s=!0;for(let r=0;r<e.value[o].options.length;r++)if(!e.value[o].options[r].text){t.code=!1,t.message=l("optionPlaceholder"),s=!1;break}return s&&v(e.value[o].options,"text").length!=e.value[o].options.length&&(t.code=!1,t.message=l("errorTipsOne")),t},e.editComponent.options.forEach(o=>{o.id||(o.id=e.generateRandom())});const _=y(!1),c=y(),N=()=>{e.editComponent.options.push({id:e.generateRandom(),text:"选项"+(e.editComponent.options.length+1)})},R=o=>{e.editComponent.options.splice(o,1)},B=()=>{if(c.value.trim()){const o=c.value.split(",").map(i=>({id:e.generateRandom(),text:i.trim()})).filter(i=>i.text!==""),s=v(o,"text").filter(i=>!e.editComponent.options.some(r=>r.text===i.text));s.length>0?e.editComponent.options.push(...s):F({message:l("errorTipsTwo"),type:"error"}),c.value="",_.value=!1}},v=(o,t)=>{const s=new Set;return o.filter(i=>{const r=JSON.stringify(i[t]);return s.has(r)?!1:s.add(r)})},C=y();return q(()=>{z(()=>{const o=X.create(C.value,{group:"option-item",animation:200,onEnd:t=>{const s=e.editComponent.options[t.oldIndex];e.editComponent.options.splice(t.oldIndex,1),e.editComponent.options.splice(t.newIndex,0,s),o.sort(Q(e.editComponent.options.length).map(i=>i.toString()))}})})}),T({}),(o,t)=>{const s=P,i=j,r=G,w=J,k=K,$=A,I=H;return x(),b(E,null,[S(m("div",W,[g(o.$slots,"field"),a(I,{"label-width":"100px",class:"px-[10px]"},{default:p(()=>[a(r,{label:n(l)("style")},{default:p(()=>[a(i,{modelValue:n(e).editComponent.style,"onUpdate:modelValue":t[0]||(t[0]=u=>n(e).editComponent.style=u)},{default:p(()=>[a(s,{label:"style-1"},{default:p(()=>[f(d(n(l)("defaultSources")),1)]),_:1}),a(s,{label:"style-2"},{default:p(()=>[f(d(n(l)("listStyle")),1)]),_:1}),a(s,{label:"style-3"},{default:p(()=>[f(d(n(l)("dropDownStyle")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),a(r,{label:n(l)("option")},{default:p(()=>[m("div",{ref_key:"formCheckboxRef",ref:C},[(x(!0),b(E,null,D(n(e).editComponent.options,(u,h)=>(x(),b("div",{key:u.id,class:"option-item flex items-center mb-[15px]"},[a(w,{modelValue:n(e).editComponent.options[h].text,"onUpdate:modelValue":O=>n(e).editComponent.options[h].text=O,class:"!w-[215px]",placeholder:n(l)("optionPlaceholder"),maxlength:"30",clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"]),n(e).editComponent.options.length>1?(x(),b("span",{key:0,onClick:O=>R(h),class:"cursor-pointer ml-[5px] nc-iconfont nc-icon-shanchu-yuangaizhiV6xx"},null,8,Y)):U("",!0)]))),128))],512),m("span",{class:"text-primary cursor-pointer mr-[10px]",onClick:N},d(n(l)("addSingleOption")),1),a($,{visible:_.value,placement:"bottom",width:300},{reference:p(()=>[m("span",{class:"text-primary cursor-pointer",onClick:t[3]||(t[3]=u=>_.value=!0)},d(n(l)("addMultipleOption")),1)]),default:p(()=>[m("p",Z,d(n(l)("addMultipleOption")),1),m("p",ee,d(n(l)("addOptionTips")),1),a(w,{modelValue:c.value,"onUpdate:modelValue":t[1]||(t[1]=u=>c.value=u),modelModifiers:{trim:!0},type:"textarea",clearable:"",maxlength:"200","show-word-limit":""},null,8,["modelValue"]),m("div",te,[a(k,{size:"small",text:"",onClick:t[2]||(t[2]=u=>_.value=!1)},{default:p(()=>[f(d(n(l)("cancel")),1)]),_:1}),a(k,{size:"small",type:"primary",onClick:B},{default:p(()=>[f(d(n(l)("confirm")),1)]),_:1})])]),_:1},8,["visible"])]),_:1},8,["label"])]),_:1}),g(o.$slots,"other")],512),[[V,n(e).editTab=="content"]]),S(m("div",oe,[g(o.$slots,"style-field"),g(o.$slots,"style")],512),[[V,n(e).editTab=="style"]])],64)}}}),be=Object.freeze(Object.defineProperty({__proto__:null,default:ne},Symbol.toStringTag,{value:"Module"}));export{be as _};
|