import{d as V,r,ay as g,aw as w,j as t,aB as R,ee as x,aA as N,aa as P,k as O,B as S,p as q,l as d,N as j,dA as A,c as C,o as F,w as f,W as I,ei as K,X as T}from"./index-9PRMimni.js";const $={request:{type:Function,default:()=>{}},options:{type:Array,default:()=>[]},buttonText:{type:String,default:"查询"},buttonProps:{type:Object,default:()=>({type:"primary"})},inputProps:{type:Object,default:()=>({clearable:!0})},inputValue:{type:String,default:""},selectProps:{type:Object,default:()=>({clearable:!0})},selectValue:{type:[String,Number,Array],default:null},isReset:{type:Boolean,default:!1},isButton:{type:Boolean,default:!0}},m=V({name:"ProSearchGroup",props:$,emits:["complete","submit","update:selectValue","update:inputValue"],setup(l,{emit:u,expose:c}){const o=r(!0),n=r(),a=r(),s=r([]);g(()=>l.selectValue,e=>{n.value=e},{immediate:!0,deep:!0}),g(()=>l.inputValue,e=>{a.value=e},{immediate:!0});function p(){o.value=!1,u("complete",s.value)}async function h(){const{request:e,options:_}=l;if(!e&&!_){o.value=!1;return}if(_&&_.length){s.value=_,p();return}try{const b=await e();s.value=b||[],p()}catch(b){o.value=!1,console.error(b)}}function i(e){!e||!d(e).length||(s.value=d(e))}function v(e){a.value=e}function B(){return{icon:()=>t(j,null,{default:()=>[t(A,null,null)]})}}function y(){return{searchValue:a.value,searchKey:n.value}}function k(){const e=y();u("update:selectValue",e.searchKey),u("update:inputValue",e.searchValue),u("submit",e,!1)}function G(){a.value="",n.value=null,u("update:selectValue",n.value),u("update:inputValue",a.value),u("submit",y(),!0)}return c({setOptions:i,getValues:y,setValue:v}),w(()=>{h()}),()=>t("div",{class:"inline-block"},[t(R,{show:o.value,size:"small"},{default:()=>[t(x,l,{default:()=>[t(N,P({value:n.value,"onUpdate:value":e=>n.value=e,options:s.value},l.selectProps,{clearable:!0}),null),t(O,P({value:a.value,"onUpdate:value":e=>a.value=e},l.inputProps,{clearable:!0}),null),l.isButton?t(S,P(l.buttonProps,{onclick:k}),{default:()=>[l.buttonText],...B()}):null,l.isReset?t(S,{quaternary:!0,type:"primary",onclick:G},{default:()=>[q("重置")]}):null]})]})])}}),U=V({__name:"proSearchGroup",setup(l){const u=r({style:{width:"160px"}}),c=r({placeholder:"请输入查询内容"}),o=r(),n=[{label:"账号",value:"uid"},{label:"邮箱",value:"emial"}];function a(p){console.log("表单组返回参数",p)}async function s(){return await K()}return(p,h)=>{const i=I,v=T;return F(),C(v,{title:"搜索表单组",content:"ProSearchGroup 基于 NInputGroup 组件扩展，很多时候这种表单组搜索很实用",showFooter:""},{default:f(()=>[t(i,{bordered:!1,class:"mt-3",title:"基本使用","content-style":"padding-top: 0;"},{default:f(()=>[t(d(m),{ref_key:"proSearchGroupRef",ref:o,options:n,selectProps:u.value,inputProps:c.value,onSubmit:a},null,8,["selectProps","inputProps"])]),_:1}),t(i,{bordered:!1,class:"mt-3",title:"带重置功能","content-style":"padding-top: 0;"},{default:f(()=>[t(d(m),{ref_key:"proSearchGroupRef",ref:o,isReset:"",options:n,selectProps:u.value,inputProps:c.value,onSubmit:a},null,8,["selectProps","inputProps"])]),_:1}),t(i,{bordered:!1,class:"mt-3",title:"不展示按钮","content-style":"padding-top: 0;"},{default:f(()=>[t(d(m),{ref_key:"proSearchGroupRef",ref:o,isButton:!1,options:n,selectProps:u.value,inputProps:c.value,onSubmit:a},null,8,["selectProps","inputProps"])]),_:1}),t(i,{bordered:!1,class:"mt-3",title:"远程获取数据","content-style":"padding-top: 0;"},{default:f(()=>[t(d(m),{ref_key:"proSearchGroupRef",ref:o,request:s,selectProps:u.value,inputProps:c.value,onSubmit:a},null,8,["selectProps","inputProps"])]),_:1})]),_:1})}}});export{U as default};
