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