import{d as e,I as a,a5 as o,r as l,ad as t,o as r,g as n,b as s,w as u,L as i,u as c,F as d,i as m,h as p,j as v,k as C,m as b,aw as f,ax as h,Q as g,a as y,q as k,a3 as N,c as w,C as S,D as x,f as _,t as P,T as D,W as I,z as L,Y as z,au as j,_ as O}from"./index-CY26MUkV.js";import{g as $}from"./table-config.Bhn2IzT2.js";import{u as q}from"./useService.-Ss4zQ-R.js";import"./useUserStore.Cw6yzw5k.js";import"./useConfigStroe.kvAOvD0g.js";const V=O(e({__name:"warehouseLocationSearch",setup(e){const{l:O}=a(),{styles:V,fontSize:A,topContainerColor:B,itemColor:E,itemEvenColor:F}=o(),{isShowColorForRow:G,ifNeedPrint:Q}=q(),U=l(!1),M=l(!0),R=l({barCode:""}),T=l("lotNo"),W=l([{name:"batch",label:O("Batch")},{name:"locationCode",label:O("LocationCode")},{name:"lotNo",label:O("LotNO")}]),Y=l([]),H=t(()=>Y.value),J=l([]),K=l([]),X=l();r(()=>{Z(),G(U)});const Z=async()=>{const e=await $("warehouse-location-search");e&&(Y.value=e.listViewColumns||[])},ee=e=>{var a;J.value.length&&(null==(a=X.value)||a.scrollTo(0),oe())},ae=async()=>{if(!R.value.barCode.trim())return void D.info(O("PleaseInputorScan"));let e={lotNo:R.value.barCode.trim()};I(O("NowIsLoading"));let a=await L("/api/services/app/PDA/LotForSearch",e).catch(e=>{});le.clear(),z(),M.value=!1,j(()=>{M.value=!0}),a&&a.success&&(a.result&&a.result.length?(J.value=(a.result||[]).map((e,a)=>({...e,index:a,backgroundColor:a%2&&U?F:E})),oe()):D.error(O("ResultIsEmpty")))},oe=()=>{let e=((e,a)=>{const o=new Map;return e.forEach(e=>{const l=e[a];o.has(l)||o.set(l,[]),o.get(l).push(e)}),o})(J.value,T.value||"lotNo"),a=[],o="batch"===T.value||"locationCode"===T.value;for(const[l,t]of e){let e=t.reduce((e,a)=>e+a.quantity,0),r=t.reduce((e,a)=>e+a.warehouseQuantity,0),n=l;o&&(n=[...new Set(t.map(e=>e.lotNo))].toString()),a.push({...t[0],backgroundColor:o?t[0].index%2&&U?F:E:t[0].backgroundColor,lotNo:n,quantity:e,warehouseQuantity:r})}K.value=a},le=new Map,te=async()=>{if(!le.size&&!J.value.length)return D.warning(O("PleaseSearchOneOrChoiceOneData"));if("batch"===T.value||"locationCode"===T.value)return D.warning(O("PleaseSelectLotNoChoiceAndPrint"));let e=[];for(const t of le.values())e.push(t.id);let a=le.size?e:J.value.map(e=>e.id),o=await L("/api/services/app/PDA/printDataInfo",a).catch(e=>{});if(!o)return D.error(O("CanNotGetPrintData"));if(!o.success)return D.error(O("CanNotGetPrintData"));let l=o.result||{};Q(l.printData||"")};return(e,a)=>{const o=p(C("up-navbar"),v),l=b("m-page-item"),t=p(C("up-radio"),f),r=p(C("up-radio-group"),h),D=m,I=b("m-blank"),L=b("m-card"),z=b("m-virtual-scroll"),j=p(C("up-button"),g),O=b("m-toast-app"),$=b("m-loading-round-app");return y(),n(d,null,[s(D,{class:"page-container",style:i({...c(V)})},{default:u(()=>[s(o,{title:e.$t("Nav.WarehouseLocationSearch"),border:"",bgColor:c(k).bgColor,leftIconColor:c(k).leftIconColor,titleStyle:"color:"+c(k).titleColor,autoBack:!0},null,8,["title","bgColor","leftIconColor","titleStyle"]),s(D,{class:"serach-container mb-10",style:i({backgroundColor:c(B)})},{default:u(()=>[s(l,{value:R.value.barCode,"onUpdate:value":a[0]||(a[0]=e=>R.value.barCode=e),title:e.$t("LotNO"),iconName:"yo-icon-kuqukuwei",iconSize:"32",focus:M.value,class:"last-input",onConfirm:ae,placeholder:e.$t("PleaseInputorScan"),onScan:a[1]||(a[1]=e=>((e,a=1)=>{1===a&&(R.value.barCode=e,ae())})(e,1))},null,8,["value","title","focus","placeholder"]),s(D,{class:"search-item last radio-last"},{default:u(()=>[s(r,{modelValue:T.value,"onUpdate:modelValue":a[2]||(a[2]=e=>T.value=e),class:"item-text",placement:"row",style:{gap:"15px","margin-left":"5px"},onChange:ee},{default:u(()=>[(y(!0),n(d,null,N(W.value,(e,a)=>(y(),w(t,{label:e.label,name:e.name,labelSize:.9*Number(c(A)),labelColor:c(A),key:a},null,8,["label","name","labelSize","labelColor"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["style"]),s(D,{class:"body-container"},{default:u(()=>[S(s(I,{class:"page-blank"},null,512),[[x,!K.value.length]]),S(s(z,{ref_key:"scrollDom",ref:X,list:K.value,class:"list-container",height:450},{default:u(({item:a,index:o})=>[s(L,{columns:H.value,item:a,backgroundColor:a.backgroundColor,title:e.$t("LotNO"),keyName:"lotNo",onClick:e=>(e=>{if("batch"===T.value||"locationCode"===T.value)return;le.get(e.lotNo)?(le.delete(e.lotNo),J.value[e.index].backgroundColor=e.index%2&&U?F:E,K.value[e.index].backgroundColor=e.index%2&&U?F:E):(le.set(e.lotNo,e),J.value[e.index].backgroundColor="#ccc",K.value[e.index].backgroundColor="#ccc")})(a)},null,8,["columns","item","backgroundColor","title","onClick"])]),_:1},8,["list"]),[[x,K.value.length]])]),_:1}),s(D,{class:"container-footer"},{default:u(()=>[s(D,{class:"operate-btn"},{default:u(()=>[s(j,{type:"primary",class:"btn-item",onClick:te,style:{width:"100%"}},{default:u(()=>[_(P(e.$t("Print")),1)]),_:1})]),_:1})]),_:1})]),_:1},8,["style"]),s(O),s($)],64)}}}),[["__scopeId","data-v-b515c349"]]);export{V as default};
