mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2026-01-26 04:28:10 +00:00
2 lines
4.4 KiB
JavaScript
2 lines
4.4 KiB
JavaScript
import{d as B,q as s,r as h,a_ as z,ay as F,h as x,c as y,Z as S,_ as V,u as n,a as m,b,e as a,w as p,i as f,t as d,F as E,W as I,C as U,$ as D,aE as P,aF as j,M as K,L,E as A,a8 as G,N as J}from"./index-981069db.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import"./el-form-item-4ed993c7.js";/* empty css *//* empty css */import{u as W}from"./diy-d896d899.js";import{S as Z}from"./sortable.esm-be94e56d.js";import{r as H}from"./range-b65bb312.js";const Q={class:"content-wrap"},X=["onClick"],Y={class:"mb-[5px]"},ee={class:"text-[#888] text-[12px] mb-[5px]"},te={class:"mt-[10px] text-right"},oe={class:"style-wrap"},ne=B({__name:"edit-form-checkbox",setup(se,{expose:N}){const e=W();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 _=h(!1),c=h(),T=()=>{e.editComponent.options.push({id:e.generateRandom(),text:"选项"+(e.editComponent.options.length+1)})},$=o=>{e.editComponent.options.splice(o,1)},M=()=>{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):D({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=h();return z(()=>{F(()=>{const o=Z.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(H(e.editComponent.options.length).map(i=>i.toString()))}})})}),N({}),(o,t)=>{const l=P,i=j,r=K,w=L,O=A,R=G,q=J;return x(),y(E,null,[S(m("div",Q,[b(o.$slots,"field"),a(q,{"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),y(E,null,I(n(e).editComponent.options,(u,g)=>(x(),y("div",{key:u.id,class:"option-item flex items-center mb-[15px]"},[a(w,{modelValue:n(e).editComponent.options[g].text,"onUpdate:modelValue":k=>n(e).editComponent.options[g].text=k,class:"!w-[215px]",placeholder:n(s)("optionPlaceholder"),maxlength:"30",clearable:""},null,8,["modelValue","onUpdate:modelValue","placeholder"]),n(e).editComponent.options.length>1?(x(),y("span",{key:0,onClick:k=>$(g),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:T},d(n(s)("addSingleOption")),1),a(R,{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",Y,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(O,{size:"small",text:"",onClick:t[2]||(t[2]=u=>_.value=!1)},{default:p(()=>[f(d(n(s)("cancel")),1)]),_:1}),a(O,{size:"small",type:"primary",onClick:M},{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)}}}),ye=Object.freeze(Object.defineProperty({__proto__:null,default:ne},Symbol.toStringTag,{value:"Module"}));export{ye as _};
|