1 |
- import{_ as N,d as U,aR as j,X as P,b0 as G,V as Q,w as M,ab as X,x as J,b1 as K,z as Y,b2 as v,r as _,o as p,G as S,C as V,c as y,F as Z,D as $,B as W,h as q,L as x,j as ee,M as ae,a as k,l as te,a6 as oe,av as se}from"./index.js";const le={style:{float:"left"}},ne={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(B,{expose:T,emit:w}){const h=w,b=B,f=j(b,"modelValue");P();const C=G(),{userLevel:I}=Q(),L=M(null),n=M([]),e=X({loading:!1,noMore:!1,name:"",count:0,page:1});let o=null;const E=se(R,500);async function m(a){e.name=a,e.page=1,e.noMore=!1;const t=v,{data:s,message:u,code:r}=await t({cat_name:a,size:10,page:e.page});C({code:r,message:u,handler:()=>{n.value=s.list.map(({short_name:c,cat_name:i,merge_code:d,tax:g})=>({tax:g,subTitle:c,value:d,label:i})),e.count=s.count,e.loading=!1;const l=Math.ceil(e.count/10);e.noMore=l<=1}})}function D(a){const t=n.value.find(({value:s})=>a===s);h("change",t)}async function R(){const a=o==null?void 0:o.clientHeight,t=o==null?void 0:o.scrollTop,s=o==null?void 0:o.scrollHeight;if(a+t>=s&&!e.noMore){e.page++,e.loading=!0;const u=v,{data:r,message:l,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:g,cat_name:F,merge_code:H,tax:O})=>({tax:O,subTitle:g,value:H,label:F}))]};C({code:c,message:l,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)}})}}J(()=>{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)}),K(()=>{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,n.value=[],m(void 0))});const z=a=>{const{value:t,label:s}=a;return t+" / "+s},A=a=>{const{value:t,label:s,subTitle:u}=a;return t+" / "+s+"-"+u};return m(void 0),T({async initalData(a){const{data:t,message:s,code:u}=await v(a);n.value=(t.list||[]).map(({tax:r,cat_name:l,merge_code:c,short_name:i})=>({tax:r,value:c,label:l,subTitle:i})),f.value=(n.value[0]||{}).value,h("change",n.value[0],!0)}}),(a,t)=>{const s=_("ElOption"),u=_("IconifyIconOffline"),r=_("ElSelect");return p(),S(r,{filterable:"",remote:"",modelValue:te(f),"onUpdate:modelValue":t[0]||(t[0]=l=>oe(f)?f.value=l:null),"remote-method":m,onChange:D,style:{width:"100%"},ref_key:"selectRef",ref:L,placeholder:"\u5546\u54C1\u7C7B\u76EE"},{default:V(()=>[(p(!0),y(Z,null,$(n.value,l=>(p(),S(s,{class:W(a.classWrapper),key:l.value,value:l.value,label:A(l)},{default:V(()=>[q("span",le,x(z(l)),1),q("span",ne,x(l.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-27456e98"],["__file","C:/Users/89793/Desktop/projects/ticket-system/src/views/invoiceInOut/productManager/components/query-category.vue"]]);export{de as default};
|