import{d as C,r,ay as V,j as n,B as g,aa as P,H as k,dZ as x,c as N,o as j,w as a,W as w,l as m,i as $,G as A,p as d,e3 as S,X as H,af as p,e4 as I,e5 as W,e6 as F,e7 as G}from"./index-9PRMimni.js";const T={value:{type:Array},multiple:{type:Boolean,default:!1},options:{type:Array,default:()=>[]}};function U(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!x(o)}const b=C({name:"CheckButton",props:T,setup(o,{emit:v}){const l=r([]);V(()=>o.value,e=>{e&&(l.value=o.multiple?e:[e[e.length-1]])},{immediate:!0});function _(e){return l.value?.includes(e)}function u(){return o.options.filter(e=>l.value?.includes(e.value))}function s(e){const t=e.value;e.disabled!==!0&&(o.multiple?l.value?.includes(t)?l.value.splice(l.value.indexOf(t),1):l.value?.push(t):l.value=l.value?.includes(t)?[]:[t],v("change",l.value,u()))}function i(e){return{icon:e.icon??e.icon}}return()=>{let e;return n(k,o,U(e=o.options.map(t=>n(g,P({strong:!0,secondary:!0},t,{type:_(t.value)?"primary":t.type||"default",onClick:s.bind(this,t)}),{default:()=>[t.label],...i(t)})))?e:{default:()=>[e]})}}}),X={class:"mt-3"},q=C({__name:"checkButton",setup(o){const v=r([{label:"催款中",value:1},{label:"已执行",value:2},{label:"已关闭",value:3},{label:"已完成",value:4,disabled:!0}]),l=r([{label:"休眠客户",value:1},{label:"意向客户",value:2},{label:"正常客户",value:3}]),_=r([{label:"催款中",value:1,round:!0,icon:p(I)},{label:"已执行",value:2,round:!0,icon:p(W)},{label:"已关闭",value:3,round:!0,icon:p(F)},{label:"已完成",value:4,round:!0,icon:p(G)}]),u=r([1,3]);function s(i,e){console.log("values",i),console.log("options",e)}return(i,e)=>{const t=w,y=A,f=g,B=k,h=S,O=H;return j(),N(O,{title:"可选按钮",content:"基于 Button 组件扩展",showFooter:""},{default:a(()=>[n(t,{bordered:!1,class:"mt-3 proCard",title:"单选","content-style":"padding-top: 0;"},{default:a(()=>[n(m(b),{options:v.value,onChange:s},null,8,["options"])]),_:1}),n(t,{bordered:!1,class:"mt-3 proCard",title:"多选","content-style":"padding-top: 0;"},{default:a(()=>[n(m(b),{options:l.value,multiple:"",onChange:s,value:u.value,"onUpdate:value":e[0]||(e[0]=c=>u.value=c)},null,8,["options","value"]),n(y),$("div",X,[n(B,null,{default:a(()=>[n(f,{onClick:e[1]||(e[1]=c=>u.value=[1])},{default:a(()=>e[4]||(e[4]=[d("选择第一个")])),_:1}),n(f,{onClick:e[2]||(e[2]=c=>u.value=[1,2,3])},{default:a(()=>e[5]||(e[5]=[d("选择全部")])),_:1}),n(f,{onClick:e[3]||(e[3]=c=>u.value=[])},{default:a(()=>e[6]||(e[6]=[d("取消全部")])),_:1})]),_:1})])]),_:1}),n(t,{bordered:!1,class:"mt-3 proCard",title:"自定义风格","content-style":"padding-top: 0;"},{default:a(()=>[n(h,{class:"ml-2"},{default:a(()=>e[7]||(e[7]=[d("更多用法，请参考 Button 组件")])),_:1}),n(m(b),{options:_.value,onChange:s},null,8,["options"])]),_:1})]),_:1})}}});export{q as default};
