niucloud-admin/niucloud/public/admin/assets/edit-form-checkbox-c2e1523c.js
全栈小学生 eff269ab88 up
2025-09-20 09:12:11 +08:00

2 lines
4.4 KiB
JavaScript

import{d as q,k as s,r as y,as as z,am as D,h as x,c as g,J as S,ae as V,u as n,a as m,b,e as a,w as p,i as f,t as d,F as E,T as I,B as U,Y as F,af as P,ag as j,G,D as J,E as K,R as A,H}from"./index-9f163f98.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-700f9c59.js";import{S as Y}from"./sortable.esm-be94e56d.js";import{r as Q}from"./range-60f1c18d.js";const W={class:"content-wrap"},X=["onClick"],Z={class:"mb-[5px]"},ee={class:"text-[#888] text-[12px] mb-[5px]"},te={class:"mt-[10px] text-right"},oe={class:"style-wrap"},ne=q({__name:"edit-form-checkbox",setup(se,{expose:T}){const e=L();e.editComponent.ignore=["componentBgUrl"],e.editComponent.verify=o=>{const t={code:!0,message:""};let l=!0;for(let r=0;r<e.value[o].options.length;r++)if(!e.value[o].options[r].text){t.code=!1,t.message=s("optionPlaceholder"),l=!1;break}return l&&v(e.value[o].options,"text").length!=e.value[o].options.length&&(t.code=!1,t.message=s("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!==""),l=v(o,"text").filter(i=>!e.editComponent.options.some(r=>r.text===i.text));l.length>0?e.editComponent.options.push(...l):F({message:s("errorTipsTwo"),type:"error"}),c.value="",_.value=!1}},v=(o,t)=>{const l=new Set;return o.filter(i=>{const r=JSON.stringify(i[t]);return l.has(r)?!1:l.add(r)})},C=y();return z(()=>{D(()=>{const o=Y.create(C.value,{group:"option-item",animation:200,onEnd:t=>{const l=e.editComponent.options[t.oldIndex];e.editComponent.options.splice(t.oldIndex,1),e.editComponent.options.splice(t.newIndex,0,l),o.sort(Q(e.editComponent.options.length).map(i=>i.toString()))}})})}),T({}),(o,t)=>{const l=P,i=j,r=G,w=J,k=K,$=A,M=H;return x(),g(E,null,[S(m("div",W,[b(o.$slots,"field"),a(M,{"label-width":"100px",class:"px-[10px]"},{default:p(()=>[a(r,{label:n(s)("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(l,{label:"style-1"},{default:p(()=>[f(d(n(s)("defaultSources")),1)]),_:1}),a(l,{label:"style-2"},{default:p(()=>[f(d(n(s)("listStyle")),1)]),_:1}),a(l,{label:"style-3"},{default:p(()=>[f(d(n(s)("dropDownStyle")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["label"]),a(r,{label:n(s)("option")},{default:p(()=>[m("div",{ref_key:"formCheckboxRef",ref:C},[(x(!0),g(E,null,I(n(e).editComponent.options,(u,h)=>(x(),g("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(s)("optionPlaceholder"),maxlength:"30",clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"]),n(e).editComponent.options.length>1?(x(),g("span",{key:0,onClick:O=>R(h),class:"cursor-pointer ml-[5px] nc-iconfont nc-icon-shanchu-yuangaizhiV6xx"},null,8,X)):U("",!0)]))),128))],512),m("span",{class:"text-primary cursor-pointer mr-[10px]",onClick:N},d(n(s)("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(s)("addMultipleOption")),1)]),default:p(()=>[m("p",Z,d(n(s)("addMultipleOption")),1),m("p",ee,d(n(s)("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(s)("cancel")),1)]),_:1}),a(k,{size:"small",type:"primary",onClick:B},{default:p(()=>[f(d(n(s)("confirm")),1)]),_:1})])]),_:1},8,["visible"])]),_:1},8,["label"])]),_:1}),b(o.$slots,"other")],512),[[V,n(e).editTab=="content"]]),S(m("div",oe,[b(o.$slots,"style-field"),b(o.$slots,"style")],512),[[V,n(e).editTab=="style"]])],64)}}}),ge=Object.freeze(Object.defineProperty({__proto__:null,default:ne},Symbol.toStringTag,{value:"Module"}));export{ge as _};