JOnlineSearchSelect-04ec87d0-Dow_orco.js 2.2 KB

1
  1. import{co as k,u as q,x as B,j as D}from"./index-BFfnEkVs.js";import{f as h,w as m,ag as S,aB as w,ar as v,aD as y,aq as F,F as I,aC as T,G as H,au as N}from"./vue-vendor-Be68asQ6.js";import"./antd-vue-vendor-DcqS7Wvq.js";import"./vxe-table-vendor-DHF2TRpV.js";var C=(c,p,n)=>new Promise((a,o)=>{var i=l=>{try{e(n.next(l))}catch(u){o(u)}},s=l=>{try{e(n.throw(l))}catch(u){o(u)}},e=l=>l.done?a(l.value):Promise.resolve(l.value).then(i,s);e((n=n.apply(c,p)).next())});const{createMessage:O}=q(),G={name:"JOnlineSearchSelect",props:{placeholder:{type:String,default:"",required:!1},value:{type:String,required:!1},fieldId:{type:String,required:!0}},emits:["update:value"],setup(c,{emit:p}){let n=h(""),a=h([]),o=!0,i=!1,s="";const e=h(1);m(()=>c.value,t=>{t?n.value=t:n.value=void 0},{immediate:!0}),m(()=>c.fieldId,()=>{f()},{immediate:!0});const l=B(t=>{s=t,e.value=1,o=!0,u(t)},800);function u(t=""){return C(this,null,function*(){let d={keyword:t,fieldId:c.fieldId,pageSize:10,pageNo:e.value};yield D.get({url:"/online/cgreport/api/getReportDictList",params:d},{isTransformResponse:!1}).then(r=>{r.success?r.result&&r.result.length>0?(e.value==1?a.value=[...r.result]:a.value.push(...r.result),e.value++):(e.value==1&&(a.value=[]),o=!1):O.warning(r.message)}).catch(()=>{e.value!=1&&e.value--})})}function x(t){p("update:value",t),(!t||t=="")&&f()}function f(){a.value=[],e.value=1,o=!0,s="",u()}return{selectOptions:a,handleSearch:l,handleChange:x,selected:n,handlePopupScroll:t=>C(this,null,function*(){const{target:d}=t,{scrollTop:g,scrollHeight:r,clientHeight:P}=d;!i&&o&&g+P>=r-10&&(i=!0,u(s).finally(()=>{i=!1}))})}}};function L(c,p,n,a,o,i){const s=S("a-select-option"),e=S("a-select");return v(),w(e,{value:a.selected,placeholder:n.placeholder,"show-search":"","default-active-first-option":!1,"show-arrow":!0,"filter-option":!1,"not-found-content":null,onSearch:a.handleSearch,onChange:a.handleChange,onPopupScroll:a.handlePopupScroll,allowClear:""},{default:y(()=>[(v(!0),F(I,null,T(a.selectOptions,l=>(v(),w(s,{key:l.value},{default:y(()=>[H(N(l.text),1)]),_:2},1024))),128))]),_:1},8,["value","placeholder","onSearch","onChange","onPopupScroll"])}const j=k(G,[["render",L]]);export{j as default};