import{_ as e}from"./uni-search-bar.48a9b35c.js";import{s as a,M as l,r as t,c as s,D as o,I as r,d as n,e as u,f as i,a as d,g as c,i as p,j as f,F as v,m,u as g,l as h,b as I,p as _,z as y,k as b,t as k}from"./index-45b322f7.js";import{_ as x}from"./su-sticky.dcc8e273.js";import{_ as P}from"./uni-load-more.575c3b96.js";import{_ as C}from"./s-layout.940eafb4.js";import{i as S}from"./itemList.bfc32ea9.js";import{_ as j}from"./_plugin-vue_export-helper.1b428a4d.js";import"./uni-icons.c22fa7d9.js";import"./index.f474d5f6.js";const z=j({__name:"costProjectSelect",setup(j){const z=a.$store("order"),w=l({currentPageNo:1,pageSize:20,supplierId:"",goodsId:"",materialId:"",bizTypeId:"",isLastPage:!1,loadStatus:"",isSearch:!1,parentId:"",level:1}),N=t([]),D=s((()=>null==$.value?(console.log("list data length : "+N.value.length),N.value):null==$.value.children||null==$.value.children?[]:$.value.children)),L=t(""),T=t([]),$=s((()=>T.value.length>0?T.value[T.value.length-1]:null)),O=s((()=>""==L.value?"*":L.value));function B(){z.modifyCostProject(w.supplierId,w.goodsId,{id:"",name:""}),a.$router.back()}function E(e){w.level+=1,w.parentId=e,R()}function M(){w.isSearch=!0,A(),R()}function V(){L.value="",w.isSearch=!1,A(),R()}function F(e){let l=D.value.find((a=>a.id==e));z.modifyCostProject(w.supplierId,w.goodsId,l),a.$router.back()}function R(){return e=this,l=null,t=function*(){w.loadStatus="loading";let e=null;if(e=w.isSearch?yield a.$api.baseData.getCostProject({name:O.value,number:O.value,settle_org_id:z.malOrgRelation.settleOrgId,route:"er_expenseitemedit",pageSize:w.pageSize,pageNo:w.currentPageNo}):yield a.$api.baseData.getCostProject({parent_id:BigInt(w.parentId),settle_org_id:z.malOrgRelation.settleOrgId,route:"er_expenseitemedit",level:w.level,pageSize:w.pageSize,pageNo:w.currentPageNo}),0==e.errorCode){if(null==w.parentId||null==w.parentId||""==w.parentId)w.isSearch?e.data.rows.forEach((e=>{e.isleaf&&N.value.push(e)})):N.value.push(...e.data.rows);else if(null==$.value||$.value.id!=w.parentId){let a=D.value.find((e=>e.id==w.parentId));a.children=e.data.rows,T.value.push(a)}else $.value.children.push(...e.data.rows);w.isLastPage=e.data.lastPage,w.isLastPage?w.loadStatus="noMore":w.loadStatus="more"}},new Promise(((a,s)=>{var o=e=>{try{n(t.next(e))}catch(a){s(a)}},r=e=>{try{n(t.throw(e))}catch(a){s(a)}},n=e=>e.done?a(e.value):Promise.resolve(e.value).then(o,r);n((t=t.apply(e,l)).next())}));var e,l,t}function A(){w.currentPageNo=1,w.level=1,w.parentId="",N.value=[],T.value=[]}return o((e=>{A(),w.materialId=e.materialId,w.bizTypeId=e.bizTypeId,w.supplierId=e.supplierId,w.goodsId=e.goodsId,R()})),r((()=>{w.currentPageNo+=1,R()})),(a,l)=>{const t=d(I("uni-search-bar"),e),s=_,o=d(I("su-sticky"),x),r=y("entry"),j=d(I("uni-load-more"),P),z=d(I("s-layout"),C);return n(),u(z,null,{default:i((()=>[c(o,{bgColor:"#fff",stickyToTop:!1},{default:i((()=>[c(s,{class:"search-block ss-flex ss-row-center"},{default:i((()=>[c(t,{class:"search-bar",placeholder:"请搜索费用项目编号/名称",onConfirm:M,onCancel:V,modelValue:L.value,"onUpdate:modelValue":l[0]||(l[0]=e=>L.value=e)},null,8,["modelValue"])])),_:1})])),_:1}),c(s,{class:"ss-flex-col content-box"},{default:i((()=>[c(s,{class:"ss-flex-col"},{default:i((()=>[T.value.length>0?(n(),u(s,{key:0,class:"ss-flex pathBox"},{default:i((()=>[(n(!0),p(v,null,f(T.value,((e,a)=>(n(),u(s,{class:"ss-flex",onClick:e=>function(e,a){T.value[a+1].children=[],T.value.splice(a+1),w.level=a+1}(0,a)},{default:i((()=>[0!=a?(n(),u(r,{key:0,fill:"#999999"})):m("",!0),c(s,{class:b(["pathName",{oldPath:a!=T.value.length-1}])},{default:i((()=>[h(k(e.name),1)])),_:2},1032,["class"])])),_:2},1032,["onClick"])))),256))])),_:1})):m("",!0),c(S,{listData:g(D),onClickFirstLevelEntry:E,onClickEntry:F},null,8,["listData"])])),_:1}),g(D).length>0?(n(),u(j,{key:0,status:w.loadStatus,"content-text":{contentdown:"上拉加载更多"},onClick:a.loadmore},null,8,["status","onClick"])):m("",!0)])),_:1}),c(s,{class:"bottom-bar ss-col-center"},{default:i((()=>[c(s,{class:"clear-btn",onClick:B},{default:i((()=>[h("清空并退出")])),_:1})])),_:1})])),_:1})}}},[["__scopeId","data-v-b66bcb9c"]]);export{z as default};
