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