super.9577631e.js 3.0 KB

1
  1. import{_ as V,d as H,W as N,X as O,ah as R,w as h,Z as T,x as U,$ as P,z as W,r as y,o as r,G as S,C as j,u as z,a as C,c as E,F as G,D as X,l as Z,M as $,a1 as J,aD as A,aE as L}from"./index.0bc83371.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:b,emit:B}){const l=d,{setCurrentCompany:F}=N(),M=O(),{userLevel:i}=R(),m=h(l.code),q=h(null),c=h([]),e=T({loading:!1,noMore:!1,name:"",count:0,page:1});let s=null;const x=J(w,500);function k(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?A:L,{data:u,message:t,code:g}=await p({[a?"name":"company_name"]:e.name,[a?"code":"companyNo"]:n,page:e.page});M({code:g,message:t,handler:()=>{c.value=k(u.list),e.count=u.count,e.loading=!1;const v=Math.ceil(e.count/10);e.noMore=v<=1}})}function I(o){const n=c.value.find(({code:a})=>a===o);l.noSet||F(n),B("change",n)}async function w(){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?A:L,{data:u,message:t,code:g}=await p({name:e.name,page:e.page,noRela:!0}),v=_=>{c.value=[...c.value,...k(_)]};M({code:g,message:t,handler:()=>{e.count=u.count;const _=Math.ceil(e.count/10);if(e.page>_){e.noMore=!0,e.loading=!1;return}v(u.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)}),P(()=>{e.loading=!1,e.noMore=!1,e.name="",e.page=1,s&&s.removeEventListener("scroll",x)}),W(()=>i.value,o=>{o!==""&&(e.loading=!1,e.noMore=!1,e.name="",e.page=1,c.value=[],f(void 0,l.code))});const D=o=>{const{code:n,name:a}=o;return n+" / "+a};return f(void 0,l.code),b({selectAll:()=>m.value=""}),(o,n)=>{const a=y("ElOption"),p=y("IconifyIconOffline"),u=y("ElSelect");return r(),S(u,{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:j(()=>[d.noAll?C("v-if",!0):(r(),S(a,{key:0,label:z(i)==="3"?"\u6240\u6709\u4F9B\u5E94\u5546\u516C\u53F8":"\u6240\u6709\u4E1A\u52A1\u516C\u53F8",value:""},null,8,["label"])),(r(!0),E(G,null,X(c.value,t=>(r(),S(a,{class:"super-item",key:t.code,value:t.code,label:D(t)},null,8,["value","label"]))),128)),e.loading?(r(),E("p",K,[Z(p,{class:"animate-spin",icon:"Loading"}),$(" \u52A0\u8F7D\u4E2D ")])):C("v-if",!0),e.noMore?(r(),E("p",Q,"\u6CA1\u6709\u66F4\u591A\u6570\u636E\u4E86...")):C("v-if",!0)]),_:1},8,["modelValue","placeholder"])}}});var oe=V(Y,[["__scopeId","data-v-894137a8"],["__file","C:/Users/63107/Desktop/projects/accout-vue3-ui/src/layout/components/company/super.vue"]]);export{oe as S};