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