import{_ as D,d as H,W as N,X as O,ai as R,x as y,Z as T,y as U,$ as z,A as P,r as h,o as r,G as S,D as W,m as j,a as E,c as C,F as G,E as X,l as Z,M as $,a1 as J,aE as k,aF as F}from"./index.js";const K={key:1,class:"super-loading"},Q={key:2,class:"super-no-more"},Y=H({__name:"super",props:{noAll:{type:Boolean,required:!1},noSet:{type:Boolean,required:!1},code:{type:String,required:!1,default:""},isSupplier:{type:Boolean,required:!1},placeholder:{type:String,required:!1}},emits:["change","update:code"],setup(d,{expose:L,emit:b}){const l=d,{setCurrentCompany:B}=N(),M=O(),{userLevel:i}=R(),m=y(l.code),q=y(null),u=y([]),e=T({loading:!1,noMore:!1,name:"",count:0,page:1});let s=null;const x=J(V,500);function A(o){return i.value==="3"||l.isSupplier?o:o.map(a=>({...a,code:a.companyNo,name:a.company_name}))}async function f(o,n){e.name=o,e.page=1,e.noMore=!1;const a=i.value==="3"||l.isSupplier,p=a||l.isSupplier?k:F,{data:c,message:t,code:g}=await p({[a?"name":"company_name"]:e.name,[a?"code":"companyNo"]:n,size:10,page:e.page});M({code:g,message:t,handler:()=>{u.value=A(c.list),e.count=c.count,e.loading=!1;const v=Math.ceil(e.count/10);e.noMore=v<=1}})}function I(o){const n=u.value.find(({code:a})=>a===o);l.noSet||B(n),b("change",n)}async function V(){const o=s.clientHeight,n=s.scrollTop,a=s.scrollHeight;if(o+n>=a&&!e.noMore){e.page++,e.loading=!0;const p=i.value==="3"||l.isSupplier?k:F,{data:c,message:t,code:g}=await p({name:e.name,page:e.page,size:10,noRela:!0}),v=_=>{u.value=[...u.value,...A(_)]};M({code:g,message:t,handler:()=>{e.count=c.count;const _=Math.ceil(e.count/10);if(e.page>_){e.noMore=!0,e.loading=!1;return}v(c.list)}})}}U(()=>{setTimeout(()=>{var n;const o=document.querySelector(".super-item");!o||(s=(n=o.parentElement)==null?void 0:n.parentElement,s&&s.addEventListener("scroll",x,!1))},1e3)}),z(()=>{e.loading=!1,e.noMore=!1,e.name="",e.page=1,s&&s.removeEventListener("scroll",x)}),P(()=>i.value,o=>{o!==""&&(e.loading=!1,e.noMore=!1,e.name="",e.page=1,u.value=[],f(void 0,l.code))});const w=o=>{const{code:n,name:a}=o;return n+" / "+a};return f(void 0,l.code),L({selectAll:()=>m.value=""}),(o,n)=>{const a=h("ElOption"),p=h("IconifyIconOffline"),c=h("ElSelect");return r(),S(c,{filterable:"",remote:"",modelValue:m.value,"onUpdate:modelValue":n[0]||(n[0]=t=>m.value=t),"remote-method":f,onChange:I,style:{width:"450px"},placeholder:d.placeholder,ref_key:"selectRef",ref:q},{default:W(()=>[d.noAll?E("v-if",!0):(r(),S(a,{key:0,label:j(i)==="3"?"\u6240\u6709\u4F9B\u5E94\u5546\u516C\u53F8":"\u6240\u6709\u4E1A\u52A1\u516C\u53F8",value:""},null,8,["label"])),(r(!0),C(G,null,X(u.value,t=>(r(),S(a,{class:"super-item",key:t.code,value:t.code,label:w(t)},null,8,["value","label"]))),128)),e.loading?(r(),C("p",K,[Z(p,{class:"animate-spin",icon:"Loading"}),$(" \u52A0\u8F7D\u4E2D ")])):E("v-if",!0),e.noMore?(r(),C("p",Q,"\u6CA1\u6709\u66F4\u591A\u6570\u636E\u4E86...")):E("v-if",!0)]),_:1},8,["modelValue","placeholder"])}}});var oe=D(Y,[["__scopeId","data-v-894137a8"],["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/layout/components/company/super.vue"]]);export{oe as S};
