import{_ as Fe,a7 as De,b as h,$ as Ee,o as c,y as A,w as n,r as s,a as U,u as Se,Z as Ae,x as ke,a4 as Oe,ay as Be,a3 as ze,U as Ve,au as Pe,aB as Me,am as Le,d as f,e as o,g as Z,c as w,ac as Y,F as q,h as d,a0 as G,B as p,al as Re,az as N,E as _,C as J}from"./index.a99ea9b6.js";import{f as Q,a as Te,b as Ue,d as Ye}from"./outbound.9448d8c7.js";import{c as qe}from"./shipping-order.fadb9542.js";import{a as $e}from"./warehouse.4bd16ffd.js";import"./request.3edc855e.js";import"./axios.e318b91e.js";const j={1:{label:"\u5F85\u5BA1\u6838",type:"warning"},2:{label:"\u5DF2\u5BA1\u6838",type:"success"},3:{label:"\u5DF2\u62D2\u7EDD",type:"danger"},4:{label:"\u5DF2\u51FA\u5E93",type:"info"}},Ke=De({name:"Outbound",setup(){const t=s(!1),u=s(!1),$=s([]),H=Object.entries(j).map(([e,{label:r}])=>({value:Number(e),label:r})),g=U({keyword:"",status:null,warehouse_id:null,customer_id:null}),y=U({current:1,pageSize:10,total:0}),z=s(!1),k=s("\u65B0\u5EFA\u51FA\u5E93\u5355"),V=s(null),D=U({id:null,shipping_no:"",customer_id:null,warehouse_id:null,sales_order_ids:null,wave_task_id:null,shipping_date:"",remark:"",items:[]}),O={shipping_no:[{required:!0,message:"\u51FA\u5E93\u5355\u53F7\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],customer_id:[{required:!0,message:"\u8BF7\u9009\u62E9\u5BA2\u6237",trigger:"change"}],warehouse_id:[{required:!0,message:"\u8BF7\u9009\u62E9\u4ED3\u5E93",trigger:"change"}],shipping_date:[{required:!0,message:"\u8BF7\u9009\u62E9\u51FA\u5E93\u65E5\u671F",trigger:"change"}]},v=s([]),l=s([]),S=s([]),P=s([]),M=s([]),B=s({}),L=s({}),R=s({}),E=s({}),a=s(!1),i=s(""),C=s([]),K=s([]),I=s(!1),W=s(null),b=U({current:1,pageSize:10,total:0}),X=e=>{var r;return((r=j[e])==null?void 0:r.label)||"\u672A\u77E5"},x=e=>{var r;return((r=j[e])==null?void 0:r.type)||"info"},ee=e=>!e&&e!==0?"-":N.unix(Number(e)).format("YYYY-MM-DD HH:mm"),ae=e=>e?typeof e=="number"&&e<1e10?N.unix(e).format("YYYY-MM-DD"):N(e).format("YYYY-MM-DD"):"-",te=e=>!e&&e!==0?"-":Number(e).toFixed(2),ue=async()=>{try{const e=await $e({keyword:"",page:1,pageSize:9999});v.value=e.list||[];const r={};for(const m of e.list)r[String(m.id)]=m.name||m.code||String(m.id);B.value=r,l.value=[],S.value=[],P.value=[],M.value=[],L.value={},R.value={}}catch{}},F=async()=>{t.value=!0;try{const e=await Q({out_no:g.keyword||void 0,status:g.status!==null?String(g.status):void 0,warehouse_id:g.warehouse_id!==null?String(g.warehouse_id):void 0,customer_id:g.customer_id!==null?String(g.customer_id):void 0,page:String(y.current),page_size:String(y.pageSize)});$.value=e.list||[],y.total=e.total||0}catch{_.error("\u52A0\u8F7D\u51FA\u5E93\u5355\u5217\u8868\u5931\u8D25")}finally{t.value=!1}},oe=async()=>{C.value=[],i.value="",b.current=1,b.pageSize=10,b.total=0,K.value=[],a.value=!0,await T()},T=async()=>{I.value=!0;try{const e={status:"3",page:String(b.current),page_size:String(b.pageSize)};i.value&&(e.out_no=i.value);const r=await Q(e);K.value=r.list||[],b.total=r.total||0}catch{_.error("\u52A0\u8F7D\u53EF\u51FA\u5E93\u8BA2\u5355\u5217\u8868\u5931\u8D25")}finally{I.value=!1}},ne=()=>{b.current=1,T()},le=e=>{C.value=e},re=e=>{const r=W.value;r&&r.toggleRowSelection(e)},se=e=>{b.pageSize=e,T()},ie=e=>{b.current=e,T()},de=Se(),pe=e=>{de.push({name:"sales-order",query:{keyword:e}})},ce=async()=>{if(C.value.length===0){_.warning("\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u6761\u51FA\u5E93\u5355");return}u.value=!0;try{const e=C.value.map(r=>r.id);await qe({total:e.length,outbound_order_ids:e}),_.success(`\u6210\u529F\u4E3A ${e.length} \u4E2A\u51FA\u5E93\u5355\u751F\u6210\u53D1\u8D27\u5355`),a.value=!1,F()}catch{_.error("\u751F\u6210\u53D1\u8D27\u5355\u5931\u8D25")}finally{u.value=!1}},ge=()=>{y.current=1,F()},he=()=>{g.keyword="",g.status=null,g.warehouse_id=null,g.customer_id=null,y.current=1,F()},me=e=>{y.pageSize=e,F()},fe=e=>{y.current=e,F()},be=async(e,r)=>{if(r.find(m=>m.id===e.id)&&!E.value[e.id])try{const m=await Te(e.id);E.value[e.id]=m}catch{E.value[e.id]={items:[]}}},we=()=>{D.items.push({product_id:null,location_id:null,batch_no:"",production_date:"",expiry_date:"",quantity:1})},ye=e=>{D.items.splice(e,1)},_e=async(e,r)=>{const m=r===2?"\u5BA1\u6838\u901A\u8FC7":"\u62D2\u7EDD";try{await J.confirm(`\u786E\u5B9A\u8981${m}\u8BE5\u51FA\u5E93\u5355\u5417\uFF1F`,"\u786E\u8BA4\u64CD\u4F5C",{type:"warning"}),await Ue(e.id,r),_.success(`${m}\u6210\u529F`),F()}catch(Ce){Ce!=="cancel"&&_.error("\u64CD\u4F5C\u5931\u8D25")}},ve=async e=>{try{await J.confirm("\u786E\u5B9A\u8981\u5220\u9664\u8BE5\u51FA\u5E93\u5355\u5417\uFF1F","\u786E\u8BA4\u5220\u9664",{type:"warning"}),await Ye({id:e.id}),_.success("\u5220\u9664\u6210\u529F"),F()}catch(r){r!=="cancel"&&_.error("\u5220\u9664\u5931\u8D25")}};return Ae(()=>{const e=ke();e.query.keyword&&(g.keyword=e.query.keyword),ue(),F()}),{loading:t,submitLoading:u,tableData:$,statusOptions:H,searchParams:g,pagination:y,dialogVisible:z,dialogTitle:k,formRef:V,formData:D,formRules:O,warehouseOptions:v,customerOptions:l,locationOptions:S,salesOrderOptions:P,waveTaskOptions:M,warehouseMap:B,customerMap:L,locationMap:R,detailCache:E,statusLabel:X,statusTagType:x,formatTimestamp:ee,formatDate:ae,handleSearch:ge,openOutboundDialog:oe,resetSearch:he,handleSizeChange:me,handleCurrentChange:fe,handleExpandChange:be,addItem:we,removeItem:ye,handleApprove:_e,handleDelete:ve,outboundDialogVisible:a,outboundSearchKeyword:i,selectedOutboundOrders:C,outboundOrderList:K,outboundLoading:I,outboundTableRef:W,formatAmount:te,handleOutboundSearch:ne,handleOutboundSelectionChange:le,handleRowClick:re,handleOutboundSizeChange:se,handleOutboundCurrentChange:ie,handleCreateOutbound:ce,outboundPagination:b,navigateToSalesOrder:pe,Search:Oe,Refresh:Be,Plus:ze,Edit:Ve,Delete:Pe,View:Me,Loading:Le}}}),Ie={class:"filter-bar"},Ne={key:0,style:{padding:"12px 20px"}},je=["onClick"],He={key:1},We={style:{color:"#409eff","font-weight":"600"}},Ze={key:1,style:{padding:"20px","text-align":"center",color:"#909399"}},Ge={key:1},Je={class:"outbound-search-bar"},Qe={class:"selected-tip"},Xe={class:"dialog-pagination-wrapper"},xe={class:"dialog-footer"},ea={class:"pagination-wrapper"};function aa(t,u,$,H,g,y){const z=h("Search"),k=h("el-icon"),V=h("el-input"),D=h("el-option"),O=h("el-select"),v=h("el-button"),l=h("el-table-column"),S=h("el-table"),P=h("Loading"),M=h("el-tag"),B=h("el-pagination"),L=h("el-dialog"),R=h("el-card"),E=Ee("loading");return c(),A(R,{class:"outbound-manager"},{header:n(()=>[...u[11]||(u[11]=[f("div",{class:"card-header"},"\u51FA\u5E93\u5355\u7BA1\u7406",-1)])]),default:n(()=>[f("div",Ie,[o(V,{modelValue:t.searchParams.keyword,"onUpdate:modelValue":u[0]||(u[0]=a=>t.searchParams.keyword=a),placeholder:"\u51FA\u5E93\u5355\u53F7",clearable:"",style:{width:"220px"},onKeyup:Z(t.handleSearch,["enter"])},{prefix:n(()=>[o(k,null,{default:n(()=>[o(z)]),_:1})]),_:1},8,["modelValue","onKeyup"]),o(O,{modelValue:t.searchParams.status,"onUpdate:modelValue":u[1]||(u[1]=a=>t.searchParams.status=a),placeholder:"\u72B6\u6001",clearable:"",style:{width:"140px"}},{default:n(()=>[(c(!0),w(q,null,Y(t.statusOptions,a=>(c(),A(D,{key:a.value,label:a.label,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(O,{modelValue:t.searchParams.warehouse_id,"onUpdate:modelValue":u[2]||(u[2]=a=>t.searchParams.warehouse_id=a),placeholder:"\u4ED3\u5E93",clearable:"",style:{width:"160px"}},{default:n(()=>[(c(!0),w(q,null,Y(t.warehouseOptions,a=>(c(),A(D,{key:a.id,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(O,{modelValue:t.searchParams.customer_id,"onUpdate:modelValue":u[3]||(u[3]=a=>t.searchParams.customer_id=a),placeholder:"\u5BA2\u6237",clearable:"",filterable:"",style:{width:"180px"}},{default:n(()=>[(c(!0),w(q,null,Y(t.customerOptions,a=>(c(),A(D,{key:a.id,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(v,{type:"primary",icon:t.Search,onClick:t.handleSearch},{default:n(()=>[...u[12]||(u[12]=[d("\u641C\u7D22",-1)])]),_:1},8,["icon","onClick"]),o(v,{icon:t.Refresh,onClick:t.resetSearch},{default:n(()=>[...u[13]||(u[13]=[d("\u91CD\u7F6E",-1)])]),_:1},8,["icon","onClick"]),u[15]||(u[15]=f("div",{style:{flex:"1"}},null,-1)),o(v,{type:"success",icon:t.Plus,onClick:t.openOutboundDialog},{default:n(()=>[...u[14]||(u[14]=[d("\u751F\u6210\u53D1\u8D27\u5355",-1)])]),_:1},8,["icon","onClick"])]),G((c(),A(S,{data:t.tableData,border:"",stripe:"",style:{width:"100%"},onExpandChange:t.handleExpandChange},{default:n(()=>[o(l,{type:"expand"},{default:n(({row:a})=>[t.detailCache[a.id]?(c(),w("div",Ne,[u[16]||(u[16]=f("h4",{style:{margin:"0 0 10px","font-size":"14px",color:"#303133"}},"\u51FA\u5E93\u5355\u660E\u7EC6",-1)),o(S,{data:t.detailCache[a.id].items||[],border:"",size:"small"},{default:n(()=>[o(l,{prop:"product_name",label:"\u5546\u54C1\u540D\u79F0","min-width":"120","show-overflow-tooltip":"",align:"center"}),o(l,{prop:"product_code",label:"ISBN/\u6761\u7801","min-width":"100","show-overflow-tooltip":"",align:"center"}),o(l,{label:"\u5E93\u4F4D","min-width":"80",align:"center"},{default:n(({row:i})=>[d(p(t.locationMap[i.warehouse_code]||i.warehouse_code||"-")+"##"+p(t.locationMap[i.location_name]||i.location_name||"-"),1)]),_:1}),o(l,{prop:"batch_no",label:"\u6279\u6B21\u53F7","min-width":"100",align:"center"},{default:n(({row:i})=>[d(p(i.batch_no||"-"),1)]),_:1}),o(l,{label:"\u9500\u552E\u5355\u53F7","min-width":"140",align:"center"},{default:n(({row:i})=>[i.sales_order_no?(c(),w("a",{key:0,style:{color:"#409eff",cursor:"pointer","text-decoration":"underline"},onClick:Re(C=>t.navigateToSalesOrder(i.sales_order_no),["stop"])},p(i.sales_order_no),9,je)):(c(),w("span",He,"-"))]),_:1}),o(l,{prop:"quantity",label:"\u6570\u91CF","min-width":"80",align:"center"},{default:n(({row:i})=>[f("span",We,p(i.quantity),1)]),_:1})]),_:1},8,["data"])])):(c(),w("div",Ze,[o(k,{class:"is-loading",style:{"margin-right":"6px"}},{default:n(()=>[o(P)]),_:1}),u[17]||(u[17]=d("\u52A0\u8F7D\u4E2D... ",-1))]))]),_:1}),o(l,{prop:"outbound_no",label:"\u51FA\u5E93\u5355\u53F7","min-width":"180","show-overflow-tooltip":"",align:"center"}),o(l,{label:"\u5BA2\u6237","min-width":"200",align:"center"},{default:n(({row:a})=>[a.shop_list&&a.shop_list.length>0?(c(!0),w(q,{key:0},Y(a.shop_list,(i,C)=>(c(),w("div",{key:C},p(i.shop_name)+"("+p(i.shop_type_text)+") ",1))),128)):(c(),w("span",Ge,"-"))]),_:1}),o(l,{label:"\u4ED3\u5E93","min-width":"120",align:"center"},{default:n(({row:a})=>[d(p(t.warehouseMap[a.warehouse_id]||a.warehouse_id||"-"),1)]),_:1}),o(l,{label:"\u51FA\u5E93\u65E5\u671F","min-width":"110",align:"center"},{default:n(({row:a})=>[d(p(t.formatDate(a.created_at)),1)]),_:1}),o(l,{prop:"status_text",label:"\u72B6\u6001",width:"100",align:"center"}),o(l,{prop:"operator",label:"\u64CD\u4F5C\u4EBA","min-width":"100",align:"center","show-overflow-tooltip":""},{default:n(({row:a})=>[d(p(a.operator||"-"),1)]),_:1}),o(l,{label:"\u521B\u5EFA\u65F6\u95F4","min-width":"160",align:"center"},{default:n(({row:a})=>[d(p(t.formatTimestamp(a.created_at)),1)]),_:1}),o(l,{prop:"remark",label:"\u5907\u6CE8","min-width":"150","show-overflow-tooltip":"",align:"center"},{default:n(({row:a})=>[d(p(a.remark||"-"),1)]),_:1})]),_:1},8,["data","onExpandChange"])),[[E,t.loading]]),o(L,{modelValue:t.outboundDialogVisible,"onUpdate:modelValue":u[8]||(u[8]=a=>t.outboundDialogVisible=a),title:"\u751F\u6210\u53D1\u8D27\u5355",width:"880px","destroy-on-close":""},{footer:n(()=>[f("span",xe,[o(v,{onClick:u[7]||(u[7]=a=>t.outboundDialogVisible=!1)},{default:n(()=>[...u[20]||(u[20]=[d("\u53D6\u6D88",-1)])]),_:1}),o(v,{type:"primary",loading:t.submitLoading,onClick:t.handleCreateOutbound},{default:n(()=>[...u[21]||(u[21]=[d("\u751F\u6210\u53D1\u8D27\u5355",-1)])]),_:1},8,["loading","onClick"])])]),default:n(()=>[f("div",Je,[o(V,{modelValue:t.outboundSearchKeyword,"onUpdate:modelValue":u[4]||(u[4]=a=>t.outboundSearchKeyword=a),placeholder:"\u641C\u7D22\u9500\u552E\u8BA2\u5355\u53F7 / \u5BA2\u6237 / \u4ED3\u5E93",clearable:"",style:{width:"320px"},onInput:t.handleOutboundSearch,onKeyup:Z(t.handleOutboundSearch,["enter"])},{prefix:n(()=>[o(k,null,{default:n(()=>[o(z)]),_:1})]),_:1},8,["modelValue","onInput","onKeyup"]),f("span",Qe,[u[18]||(u[18]=d("\u5DF2\u9009 ",-1)),f("strong",null,p(t.selectedOutboundOrders.length),1),u[19]||(u[19]=d(" \u5F20",-1))])]),G((c(),A(S,{ref:"outboundTableRef",data:t.outboundOrderList,border:"",stripe:"","row-key":"id",onSelectionChange:t.handleOutboundSelectionChange,onRowClick:t.handleRowClick},{default:n(()=>[o(l,{type:"selection",width:"55",align:"center","reserve-selection":""}),o(l,{prop:"outbound_no",label:"\u51FA\u5E93\u5355\u53F7","min-width":"180","show-overflow-tooltip":"",align:"center"}),o(l,{label:"\u4ED3\u5E93","min-width":"120",align:"center"},{default:n(({row:a})=>[d(p(t.warehouseMap[a.warehouse_id]||"-"),1)]),_:1}),o(l,{label:"\u8BA2\u5355\u65E5\u671F","min-width":"110",align:"center"},{default:n(({row:a})=>[d(p(t.formatDate(a.created_at)),1)]),_:1}),o(l,{prop:"status_text",label:"\u72B6\u6001",width:"100",align:"center"},{default:n(({row:a})=>[o(M,{size:"small"},{default:n(()=>[d(p(a.status_text),1)]),_:2},1024)]),_:1}),o(l,{prop:"operator",label:"\u64CD\u4F5C\u4EBA","min-width":"100",align:"center","show-overflow-tooltip":""},{default:n(({row:a})=>[d(p(a.operator||"-"),1)]),_:1}),o(l,{prop:"remark",label:"\u5907\u6CE8","min-width":"150","show-overflow-tooltip":"",align:"center"},{default:n(({row:a})=>[d(p(a.remark||"-"),1)]),_:1})]),_:1},8,["data","onSelectionChange","onRowClick"])),[[E,t.outboundLoading]]),f("div",Xe,[o(B,{"current-page":t.outboundPagination.current,"onUpdate:currentPage":u[5]||(u[5]=a=>t.outboundPagination.current=a),"page-size":t.outboundPagination.pageSize,"onUpdate:pageSize":u[6]||(u[6]=a=>t.outboundPagination.pageSize=a),"page-sizes":[10,20,50,100],total:t.outboundPagination.total,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:t.handleOutboundSizeChange,onCurrentChange:t.handleOutboundCurrentChange},null,8,["current-page","page-size","total","onSizeChange","onCurrentChange"])])]),_:1},8,["modelValue"]),f("div",ea,[o(B,{"current-page":t.pagination.current,"onUpdate:currentPage":u[9]||(u[9]=a=>t.pagination.current=a),"page-size":t.pagination.pageSize,"onUpdate:pageSize":u[10]||(u[10]=a=>t.pagination.pageSize=a),"page-sizes":[10,20,50,100],total:t.pagination.total,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:t.handleSizeChange,onCurrentChange:t.handleCurrentChange},null,8,["current-page","page-size","total","onSizeChange","onCurrentChange"])])]),_:1})}var sa=Fe(Ke,[["render",aa],["__scopeId","data-v-05a0e3f2"]]);export{sa as default};