var e=(e,a,t)=>new Promise(((s,o)=>{var r=e=>{try{n(t.next(e))}catch(a){o(a)}},l=e=>{try{n(t.throw(e))}catch(a){o(a)}},n=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,l);n((t=t.apply(e,a)).next())}));import{_ as a}from"./uni-search-bar.48a9b35c.js";import{d as t,e as s,f as o,g as r,l,t as n,u,m as c,p as i,C as d,M as m,r as g,c as f,D as p,I as _,s as h,_ as v,a as C,i as y,j as b,F as x,b as N}from"./index-45b322f7.js";import{_ as S}from"./su-sticky.dcc8e273.js";import{d as I}from"./index.f474d5f6.js";import{_ as P}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as j}from"./uni-load-more.575c3b96.js";import{_ as k}from"./s-layout.940eafb4.js";import"./uni-icons.c22fa7d9.js";const w=P({__name:"s-org-card",props:{org:{type:Object,default:{}},isSelected:{type:Boolean,default:!0}},emits:["tapCard"],setup(e,{emit:a}){const m=e;function g(){a("tapCard",m.org)}return(a,m)=>{const f=i,p=d;return t(),s(f,{class:"ss-flex ss-row-between org-card",onClick:g},{default:o((()=>[r(f,{class:"ss-flex-1"},{default:o((()=>[r(f,{class:"org-name"},{default:o((()=>[l(n(e.org.orgName),1)])),_:1}),r(f,{class:"ss-flex org-number"},{default:o((()=>[r(p,null,{default:o((()=>[l(n(e.org.orgNumber),1)])),_:1}),r(p,{class:"ss-m-l-10"},{default:o((()=>[l(n(e.org.orgPattern),1)])),_:1})])),_:1})])),_:1}),e.isSelected?(t(),s(u(I),{key:0,size:"20",fill:"#276FF5",class:"ss-m-r-24"})):c("",!0)])),_:1})}}},[["__scopeId","data-v-db33f728"]]),$=P({__name:"org",setup(l){const n=m({currentPageNum:1,lastPageNum:1,pageSize:20,total:0,loadStatus:""}),d=g(""),I=g([]),P=f((()=>h.$store("homepage").mainConfigData.userInfo.orgId));function $(e){M(),T()}function z(){d.value="",M(),T()}function F(a){!function(a){e(this,null,(function*(){const e=yield h.$api.user.switchOrg({orgId:a.orgId,isDefault:!1});if(0==e.errorCode){let e=h.$store("homepage").mainConfigData;e.userInfo.orgId=a.orgId,e.userInfo.orgName=a.orgName,h.$store("homepage").updateMainConfig(e),h.$store("cart").refreshCart(),h.$router.back()}else console.log("切换组织失败："+e.message)}))}(a)}function M(){n.currentPageNum=1,I.value=[]}function T(){return e(this,null,(function*(){n.loadStatus="loading";const e=yield h.$api.user.getOrgList({pageSize:n.pageSize,pageNum:n.currentPageNum,paramFilterList:[{searchField:"number",serarchText:d.value},{searchField:"name",serarchText:d.value}]});0==e.errorCode?(I.value=v.concat(I.value,e.data.items),n.total=e.data.total,n.lastPageNum=Math.ceil(e.data.total/n.pageSize),n.lastPageNum>n.currentPageNum?n.loadStatus="more":n.loadStatus="noMore"):console.log("获取组织列表出错："+e.message)}))}function D(){"noMore"!==n.loadStatus&&(n.currentPageNum=n.currentPageNum+1,T())}return p((()=>{T()})),_((()=>{D()})),(e,l)=>{const m=C(N("uni-search-bar"),a),g=i,f=C(N("su-sticky"),S),p=C(N("s-org-card"),w),_=C(N("uni-load-more"),j),h=C(N("s-layout"),k);return t(),s(h,null,{default:o((()=>[r(f,{bgColor:"#fff",stickyToTop:!1},{default:o((()=>[r(g,{class:"search-block ss-flex ss-row-center"},{default:o((()=>[r(m,{class:"search-bar",placeholder:"请搜索组织名称/编码",onConfirm:$,onCancel:z,modelValue:d.value,"onUpdate:modelValue":l[0]||(l[0]=e=>d.value=e)},null,8,["modelValue"])])),_:1})])),_:1}),(t(!0),y(x,null,b(I.value,(e=>(t(),s(p,{org:e,onTapCard:F,isSelected:e.orgId==u(P)},null,8,["org","isSelected"])))),256)),n.total>0?(t(),s(_,{key:0,status:n.loadStatus,"content-text":{contentdown:"上拉加载更多"},onClick:D},null,8,["status"])):c("",!0)])),_:1})}}},[["__scopeId","data-v-8b3d43fd"]]);export{$ as default};
