import{_ as N,d as U,ci as P,O as j,P as Q,ab as G,n as S,Q as J,p as K,R as X,w as Y,cj as v,r as _,o as p,A as M,y as q,c as y,F as Z,z as $,x as W,e as x,G as V,h as ee,H as ae,a as k,i as te,ak as oe,U as le}from"./index.js";const ne={style:{float:"left"}},se={style:{float:"right",color:"var(--el-text-color-secondary)","font-size":"13px"}},ue={key:0,class:"super-loading"},re={key:1,class:"super-no-more"},ce=U({__name:"query-category",props:{noAll:{type:Boolean,required:!1},noSet:{type:Boolean,required:!1},modelValue:{type:String,required:!1,default:""},isSupplier:{type:Boolean,required:!1},placeholder:{type:String,required:!1},classWrapper:{type:String,required:!1,default:"procure-item"}},emits:["change","update:modelValue"],setup(w,{expose:T,emit:B}){const h=B,b=w,f=P(b,"modelValue");j();const C=Q(),{userLevel:I}=G(),L=S(null),s=S([]),e=J({loading:!1,noMore:!1,name:"",count:0,page:1});let o=null;const E=le(D,500);async function m(a){e.name=a,e.page=1,e.noMore=!1;const t=v,{data:l,message:u,code:r}=await t({cat_name:a,size:10,page:e.page});C({code:r,message:u,handler:()=>{s.value=l.list.map(({short_name:c,cat_name:i,merge_code:d,tax:g})=>({tax:g,subTitle:c,value:d,label:i})),e.count=l.count,e.loading=!1;const n=Math.ceil(e.count/10);e.noMore=n<=1}})}function A(a){const t=s.value.find(({value:l})=>a===l);h("change",t)}async function D(){const a=o==null?void 0:o.clientHeight,t=o==null?void 0:o.scrollTop,l=o==null?void 0:o.scrollHeight;if(a+t>=l&&!e.noMore){e.page++,e.loading=!0;const u=v,{data:r,message:n,code:c}=await u({cat_name:e.name,page:e.page,size:10,noRela:!0}),i=d=>{s.value=[...s.value,...d.map(({short_name:g,cat_name:z,merge_code:F,tax:O})=>({tax:O,subTitle:g,value:F,label:z}))]};C({code:c,message:n,handler:()=>{e.count=r.count;const d=Math.ceil(e.count/10);if(e.page>d){e.noMore=!0,e.loading=!1;return}i(r.list)}})}}K(()=>{setTimeout(()=>{var t;const a=document.querySelector("."+b.classWrapper);!a||(o=(t=a.parentElement)==null?void 0:t.parentElement,o&&o.addEventListener("scroll",E,!1))},1e3)}),X(()=>{e.loading=!1,e.noMore=!1,e.name="",e.page=1,o&&o.removeEventListener("scroll",E)}),Y(()=>I.value,a=>{a!==""&&(e.loading=!1,e.noMore=!1,e.name="",e.page=1,s.value=[],m(void 0))});const H=a=>{const{value:t,label:l}=a;return t+" / "+l},R=a=>{const{value:t,label:l,subTitle:u}=a;return t+" / "+l+"-"+u};return m(void 0),T({async initalData(a){const{data:t,message:l,code:u}=await v(a);s.value=(t.list||[]).map(({tax:r,cat_name:n,merge_code:c,short_name:i})=>({tax:r,value:c,label:n,subTitle:i})),f.value=(s.value[0]||{}).value,h("change",s.value[0],!0)}}),(a,t)=>{const l=_("ElOption"),u=_("IconifyIconOffline"),r=_("ElSelect");return p(),M(r,{filterable:"",remote:"",modelValue:te(f),"onUpdate:modelValue":t[0]||(t[0]=n=>oe(f)?f.value=n:null),"remote-method":m,onChange:A,style:{width:"100%"},ref_key:"selectRef",ref:L,placeholder:"\u5546\u54C1\u7C7B\u76EE"},{default:q(()=>[(p(!0),y(Z,null,$(s.value,n=>(p(),M(l,{class:W(a.classWrapper),key:n.value,value:n.value,label:R(n)},{default:q(()=>[x("span",ne,V(H(n)),1),x("span",se,V(n.subTitle),1)]),_:2},1032,["class","value","label"]))),128)),e.loading?(p(),y("p",ue,[ee(u,{class:"animate-spin",icon:"Loading"}),t[1]||(t[1]=ae(" \u52A0\u8F7D\u4E2D "))])):k("v-if",!0),e.noMore?(p(),y("p",re,"\u6CA1\u6709\u66F4\u591A\u6570\u636E\u4E86...")):k("v-if",!0)]),_:1},8,["modelValue"])}}});var de=N(ce,[["__scopeId","data-v-0c174b03"],["__file","D:/work/jiesuan/settle-vue3/src/views/supplyInvoiceSaleSettings/_component/query-category.vue"]]);export{de as default};
