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