index-DCAUD33F.js 2.8 KB

1
  1. import{_ as I,A as z,bC as N,aA as T,ca as U,v as W}from"./index-CKIhG1T4.js";import{a,f as j,v as D,M as q,D as n,T as k,U as w,$ as E,u as p,a7 as f,F as P,V as M,E as K,K as O,ad as G,_ as $,n as J}from"./spreadSheetsDesignerVue-MRUT1X_l.js";const Q=["onClick"],X={class:"loading-tip"},Y=I({__name:"index",props:{modelValue:{type:Object,default:()=>({})},disabled:{type:Boolean,default:!1},searchKeyProp:{type:String,default:"label"},labelKey:{type:String,default:"label"},valueKey:{type:String,default:"value"},fetchFunc:{type:Function,required:!0},pageSize:{type:Number,default:20},isPagnation:{type:Boolean,default:!0}},emits:["update:modelValue","change"],setup(s,{emit:F}){const c=s,V=F,t=a(!1),y=a(""),u=a([]),m=a(1),d=a(!1),o=a(!1),r=a(null),L=a(null),R=a(null),b=a("0px"),A=j(()=>({[c.searchKeyProp]:y.value,pageNo:m.value,pageSize:c.pageSize})),g=()=>{var e;t.value=!t.value,t.value&&(b.value=(e=r.value)==null?void 0:e.$el.clientWidth,J(()=>{h()}))},B=()=>{m.value=1,u.value=[],o.value=!1,h()},h=async()=>{if(!d.value&&!o.value){d.value=!0;try{const e=await c.fetchFunc(A.value);if(c.isPagnation){const{list:l,total:i}=e;u.value=[...u.value,...l],o.value=u.value.length>=i,m.value++}else u.value=e,o.value=!0}finally{d.value=!1}}},H=e=>{const{scrollTop:l,clientHeight:i,scrollHeight:_}=e.target;_-l-i<10&&h()},C=()=>{var e;b.value=(e=r.value)==null?void 0:e.$el.clientWidth},S=e=>{var l;(l=r.value)!=null&&l.$el.contains(e.target)||(t.value=!1)};return D(()=>{document.addEventListener("click",S),window.addEventListener("resize",C)}),q(()=>{document.removeEventListener("click",S),window.removeEventListener("resize",C)}),(e,l)=>{const i=U,_=W;return n(),k(i,{visible:t.value,placement:"bottom",width:`${b.value}px`},{reference:w(()=>[E(p(z),{"model-value":s.modelValue[s.labelKey],readonly:"",disabled:s.disabled,placeholder:"\u8BF7\u9009\u62E9",onClick:g,ref_key:"inputRef",ref:r},{suffix:w(()=>[t.value?(n(),k(p(N),{key:0,class:"el-input__icon",onClick:f(g,["stop"])})):(n(),k(p(T),{key:1,class:"el-input__icon",onClick:f(g,["stop"])}))]),_:1},8,["model-value","disabled"])]),default:w(()=>[P("div",{ref_key:"contentRef",ref:L,class:"dropdown-content",onClick:l[1]||(l[1]=f(()=>t.value=!0,["stop","prevent"]))},[E(p(z),{modelValue:y.value,"onUpdate:modelValue":l[0]||(l[0]=v=>y.value=v),placeholder:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",clearable:"",onInput:B,class:"search-input"},null,8,["modelValue"]),M((n(),K("div",{class:"options-list",onScrollPassive:H,ref_key:"scrollRef",ref:R},[(n(!0),K(O,null,G(u.value,v=>(n(),K("div",{key:v[s.valueKey],class:"option-item",onClick:f(Z=>(x=>{V("update:modelValue",x),V("change",x),t.value=!1})(v),["stop"])},$(v[s.labelKey]),9,Q))),128)),P("div",X,$(o.value?"\u6CA1\u6709\u66F4\u591A\u6570\u636E\u4E86":"\u52A0\u8F7D\u4E2D..."),1)],32)),[[_,d.value]])],512)]),_:1},8,["visible","width"])}}},[["__scopeId","data-v-0606ba57"]]);export{Y as _};