2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{_ as qe,a7 as Le,b as g,$ as Me,o as h,y as O,w as l,r as s,a as Z,v as Pe,Z as Ie,x as Re,a4 as Te,ay as Ye,a3 as Ue,U as $e,au as Ne,aB as Ke,am as We,aH as je,d as p,e as o,g as ne,c as V,ac as J,F as Q,h as c,a0 as re,B as i,aI as se,A as Ge,az as X,E as z,C as He}from"./index.a99ea9b6.js";import{r as ie}from"./request.3edc855e.js";import{c as Ze}from"./outbound.9448d8c7.js";import{createWaveOutbound as Je,createWaveOutboundRelease as Qe}from"./wave-task.7d4932b3.js";import{g as Xe}from"./barcode.8180984e.js";import{a as xe}from"./warehouse.4bd16ffd.js";import{i as ea}from"./stock-check.6291d824.js";import"./axios.e318b91e.js";const de="/sales-order",aa=e=>{const u=e==null?void 0:e.data;return u?Array.isArray(u)?{list:u,total:u.length}:{list:Array.isArray(u.list)?u.list:[],total:typeof u.total=="number"?u.total:0}:{list:[],total:0}},x=async({keyword:e,status:u,customer_id:q,warehouse_id:R,page:f,pageSize:y,sort_by:A,sort_order:_})=>{const v={keyword:e||void 0,status:u,customer_id:q,warehouse_id:R,page:f,page_size:y,sort_by:A||"updated_at",sort_order:_||"desc"},b=await ie.get(`${de}/list`,{params:v});return aa(b)},ta=async e=>{const u=await ie.get(`${de}/detail`,{params:{id:e}});return(u==null?void 0:u.data)||null};const ee={1:{label:"\u8349\u7A3F",type:"info"},2:{label:"\u5DF2\u786E\u8BA4",type:"info"},3:{label:"\u5DF2\u5206\u914D\u5E93\u5B58",type:"info"},4:{label:"\u62E3\u8D27\u4E2D",type:"warning"},5:{label:"\u5DF2\u53D1\u8D27",type:"success"},6:{label:"\u5DF2\u53D6\u6D88",type:"danger"}},ua=Le({name:"SalesOrder",setup(){const e=s(!1),u=s(!1),q=s([]),R=Object.entries(ee).map(([t,{label:r}])=>({value:Number(t),label:r})),f=Z({keyword:"",status:null,warehouse_id:null,customer_id:null}),y=Z({current:1,pageSize:10,total:0}),A=s(!1),_=s("\u65B0\u5EFA\u9500\u552E\u8BA2\u5355"),v=s(null),b=Z({id:null,so_no:"",customer_id:null,warehouse_id:null,order_date:"",required_delivery_date:"",sales_person:"",remark:"",items:[]}),L={so_no:[{required:!0,message:"\u9500\u552E\u8BA2\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"}],order_date:[{required:!0,message:"\u8BF7\u9009\u62E9\u8BA2\u5355\u65E5\u671F",trigger:"change"}]},D=s(!1),n=s(null),T=s([]),E=s(!1),K=s([]),M=s({}),W=s({}),C=s({}),P=s(!1),w=s(!1),a=s(!1),d=s([]),Y=s(""),I=s([]),ae=s(null),j=s(""),G=s(""),ce=Pe(()=>b.items.reduce((t,r)=>t+r.amount_yuan,0)),pe=t=>{var r;return((r=ee[t])==null?void 0:r.label)||"\u672A\u77E5"},me=t=>{var r;return((r=ee[t])==null?void 0:r.type)||"info"},ge=t=>!t&&t!==0?"-":X.unix(Number(t)).format("YYYY-MM-DD HH:mm"),fe=t=>t?typeof t=="number"&&t<1e10?X.unix(t).format("YYYY-MM-DD"):X(t).format("YYYY-MM-DD"):"-",he=t=>!t&&t!==0?"\xA50.00":"\xA5"+(Number(t)/100).toFixed(2),ye=t=>{t.amount_yuan=t.unit_price_yuan*t.quantity},be=(t,r)=>{},te=async(t="")=>{E.value=!0;try{const r=await xe({keyword:t,page:1,pageSize:9999});T.value=r.list||[];const m={};for(const F of r.list)m[String(F.id)]=F.name||F.code||String(F.id);M.value=m}catch{}finally{E.value=!1}},B=async()=>{e.value=!0;try{const t=await x({keyword:f.keyword,status:f.status||void 0,warehouse_id:f.warehouse_id||void 0,customer_id:f.customer_id||void 0,page:y.current,pageSize:y.pageSize,sort_by:"updated_at",sort_order:"desc"});q.value=t.list||[],y.total=t.total||0}catch{z.error("\u52A0\u8F7D\u9500\u552E\u8BA2\u5355\u5217\u8868\u5931\u8D25")}finally{e.value=!1}},we=()=>{y.current=1,B()},_e=()=>{f.keyword="",f.status=null,f.warehouse_id=null,f.customer_id=null,y.current=1,B()},ve=t=>{y.pageSize=t,B()},De=t=>{y.current=t,B()},Ee=async(t,r)=>{if(r.find(m=>m.id===t.id)&&!C.value[t.id])try{const m=await ta(t.id);C.value[t.id]=m}catch{C.value[t.id]={items:[]}}},Fe=()=>{b.items.push({product_id:null,unit_price_yuan:0,quantity:1,amount_yuan:0})},Ae=t=>{b.items.splice(t,1)},Ce=async(t,r)=>{try{const{value:m}=await He.prompt("\u8BF7\u8F93\u5165\u9000\u8D27\u5907\u6CE8\uFF08\u9009\u586B\uFF09","\u9000\u8D27\u786E\u8BA4",{confirmButtonText:"\u786E\u5B9A\u9000\u8D27",cancelButtonText:"\u53D6\u6D88",inputType:"textarea",inputPlaceholder:"\u9000\u8D27\u5907\u6CE8"}).catch(()=>({value:""}));await ea({sales_order_id:t.id,sales_order_item_id:r.id,remark:m||""}),z.success("\u9000\u8D27\u6210\u529F"),B()}catch(m){if(m==="cancel")return;z.error((m==null?void 0:m.message)||"\u9000\u8D27\u5931\u8D25")}},Be=async()=>{P.value=!0,Y.value="",I.value=[],w.value=!0;try{const t=await x({keyword:"",status:3,page:1,pageSize:100});d.value=t.list||[]}catch{z.error("\u52A0\u8F7D\u9500\u552E\u8BA2\u5355\u5931\u8D25")}finally{w.value=!1}},ke=async()=>{w.value=!0;try{const t=await x({keyword:Y.value,status:3,page:1,pageSize:100});d.value=t.list||[]}catch{}finally{w.value=!1}},Se=t=>{I.value=t},Oe=t=>{var r;(r=ae.value)==null||r.toggleRowSelection(t)},Ve=async()=>{var t,r,m,F;if(I.value.length!==0){a.value=!0;try{const k=I.value.map(S=>S.id),ze=k.length,U=await Ze(k,ze,j.value);console.log("\u521B\u5EFA\u51FA\u5E93\u5355\u54CD\u5E94:",U);const H=(t=U==null?void 0:U.data)==null?void 0:t.outbound_order_id;if(H){const S=await Je(H);console.log("\u521B\u5EFA\u6CE2\u6B21\u51FA\u5E93\u54CD\u5E94:",S);const ue=(r=S==null?void 0:S.data)==null?void 0:r.wave_id;if(ue){const $=await Qe(H,ue);console.log("\u91CA\u653E\u6CE2\u6B21\u51FA\u5E93\u54CD\u5E94:",$);const oe=(m=$==null?void 0:$.data)==null?void 0:m.wave_no;if(oe){const N=await Xe(oe);console.log("\u751F\u6210\u6761\u7801\u54CD\u5E94:",N);const le=(F=N==null?void 0:N.data)==null?void 0:F.image_base64;le&&(G.value=`data:image/jpeg;base64,${le}`)}}}z.success("\u6210\u529F\u751F\u6210\u51FA\u5E93\u5355"),j.value="",G.value||(P.value=!1)}catch(k){z.error((k==null?void 0:k.message)||"\u751F\u6210\u51FA\u5E93\u5355\u5931\u8D25")}finally{a.value=!1}}};return Ie(()=>{const t=Re();t.query.keyword&&(f.keyword=t.query.keyword),te(""),B()}),{loading:e,submitLoading:u,tableData:q,statusOptions:R,searchParams:f,pagination:y,dialogVisible:A,dialogTitle:_,formRef:v,formData:b,formRules:L,detailVisible:D,detailData:n,warehouseOptions:T,warehouseLoading:E,loadWarehouses:te,customerOptions:K,warehouseMap:M,customerMap:W,detailCache:C,totalAmountYuan:ce,statusLabel:pe,statusTagType:me,formatTimestamp:ge,formatDate:fe,formatAmount:he,calculateAmount:ye,onProductChange:be,handleSearch:we,resetSearch:_e,handleSizeChange:ve,handleCurrentChange:De,handleExpandChange:Ee,addItem:Fe,removeItem:Ae,refundGoods:Ce,openOutboundDialog:Be,outboundDialogVisible:P,outboundLoading:w,outboundOrderList:d,outboundSearchKeyword:Y,selectedOutboundOrders:I,outboundTableRef:ae,outboundRemark:j,barcodeImage:G,handleOutboundSelectionChange:Se,handleRowClick:Oe,handleOutboundSearch:ke,handleGenerateOutbound:Ve,generateLoading:a,Search:Te,Refresh:Ye,Plus:Ue,Edit:$e,Delete:Ne,View:Ke,Loading:We,Check:je}}}),oa={class:"filter-bar"},la={key:0,style:{padding:"12px 20px"}},na={style:{color:"#e6a23c"}},ra={style:{color:"#409eff","font-weight":"600"}},sa={style:{color:"#f56c6c","font-weight":"600"}},ia={key:1,style:{padding:"20px","text-align":"center",color:"#909399"}},da={style:{color:"#e6a23c","font-weight":"600"}},ca={class:"pagination-wrapper"},pa={class:"outbound-search-bar"},ma={class:"selected-tip"},ga={style:{color:"#e6a23c","font-weight":"600"}},fa={style:{"margin-top":"16px"}},ha={key:0,style:{"margin-top":"16px","text-align":"center"}},ya=["src"];function ba(e,u,q,R,f,y){const A=g("Search"),_=g("el-icon"),v=g("el-input"),b=g("el-option"),L=g("el-select"),D=g("el-button"),n=g("el-table-column"),T=g("el-link"),E=g("el-table"),K=g("Loading"),M=g("el-tag"),W=g("el-pagination"),C=g("el-dialog"),P=g("el-card"),w=Me("loading");return h(),O(P,{class:"sales-order-manager"},{header:l(()=>[...u[10]||(u[10]=[p("div",{class:"card-header"},"\u9500\u552E\u8BA2\u5355\u7BA1\u7406",-1)])]),default:l(()=>[p("div",oa,[o(v,{modelValue:e.searchParams.keyword,"onUpdate:modelValue":u[0]||(u[0]=a=>e.searchParams.keyword=a),placeholder:"\u9500\u552E\u8BA2\u5355\u53F7",clearable:"",style:{width:"220px"},onKeyup:ne(e.handleSearch,["enter"])},{prefix:l(()=>[o(_,null,{default:l(()=>[o(A)]),_:1})]),_:1},8,["modelValue","onKeyup"]),o(L,{modelValue:e.searchParams.status,"onUpdate:modelValue":u[1]||(u[1]=a=>e.searchParams.status=a),placeholder:"\u72B6\u6001",clearable:"",style:{width:"140px"}},{default:l(()=>[(h(!0),V(Q,null,J(e.statusOptions,a=>(h(),O(b,{key:a.value,label:a.label,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(L,{modelValue:e.searchParams.warehouse_id,"onUpdate:modelValue":u[2]||(u[2]=a=>e.searchParams.warehouse_id=a),placeholder:"\u4ED3\u5E93",clearable:"",filterable:"",remote:"","reserve-keyword":"","remote-method":e.loadWarehouses,loading:e.warehouseLoading,style:{width:"160px"}},{default:l(()=>[(h(!0),V(Q,null,J(e.warehouseOptions,a=>(h(),O(b,{key:a.id,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","remote-method","loading"]),o(L,{modelValue:e.searchParams.customer_id,"onUpdate:modelValue":u[3]||(u[3]=a=>e.searchParams.customer_id=a),placeholder:"\u5BA2\u6237",clearable:"",filterable:"",style:{width:"180px"}},{default:l(()=>[(h(!0),V(Q,null,J(e.customerOptions,a=>(h(),O(b,{key:a.id,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(D,{type:"primary",icon:e.Search,onClick:e.handleSearch},{default:l(()=>[...u[11]||(u[11]=[c("\u641C\u7D22",-1)])]),_:1},8,["icon","onClick"]),o(D,{icon:e.Refresh,onClick:e.resetSearch},{default:l(()=>[...u[12]||(u[12]=[c("\u91CD\u7F6E",-1)])]),_:1},8,["icon","onClick"]),u[14]||(u[14]=p("div",{style:{flex:"1"}},null,-1)),o(D,{type:"success",icon:e.Plus,onClick:e.openOutboundDialog},{default:l(()=>[...u[13]||(u[13]=[c("\u751F\u6210\u51FA\u5E93\u5355",-1)])]),_:1},8,["icon","onClick"])]),re((h(),O(E,{data:e.tableData,border:"",stripe:"",style:{width:"100%"},onExpandChange:e.handleExpandChange},{default:l(()=>[o(n,{type:"expand"},{default:l(({row:a})=>[e.detailCache[a.id]?(h(),V("div",la,[u[16]||(u[16]=p("h4",{style:{margin:"0 0 10px","font-size":"14px",color:"#303133"}},"\u8BA2\u5355\u660E\u7EC6",-1)),o(E,{data:e.detailCache[a.id].items||[],border:"",size:"small"},{default:l(()=>[o(n,{prop:"product_name",label:"\u5546\u54C1\u540D\u79F0","min-width":"120","show-overflow-tooltip":"",align:"center"}),o(n,{prop:"product_code",label:"ISBN/\u6761\u7801",width:"130","show-overflow-tooltip":"",align:"center"}),o(n,{label:"\u5355\u4EF7",width:"100",align:"center"},{default:l(({row:d})=>[p("span",na,i(e.formatAmount(d.unit_price)),1)]),_:1}),o(n,{prop:"quantity",label:"\u8BA2\u8D2D\u6570\u91CF",width:"90",align:"center"},{default:l(({row:d})=>[p("span",ra,i(d.quantity),1)]),_:1}),o(n,{prop:"allocated_quantity",label:"\u5DF2\u5206\u914D\u6570\u91CF",width:"90",align:"center"},{default:l(({row:d})=>[p("span",{style:se({color:d.allocated_quantity>=d.quantity?"#67c23a":"#e6a23c"})},i(d.allocated_quantity),5)]),_:1}),o(n,{prop:"shipped_quantity",label:"\u5DF2\u53D1\u8D27\u6570\u91CF",width:"90",align:"center"},{default:l(({row:d})=>[p("span",{style:se({color:d.shipped_quantity>=d.quantity?"#67c23a":"#909399"})},i(d.shipped_quantity),5)]),_:1}),o(n,{label:"\u5F85\u53D1\u8D27\u6570\u91CF",width:"90",align:"center"},{default:l(({row:d})=>[p("span",sa,i(d.quantity-d.shipped_quantity),1)]),_:1}),o(n,{prop:"receiver_name",label:"\u6536\u8D27\u4EBA",width:"150","show-overflow-tooltip":"",align:"center"}),o(n,{prop:"receiver_phone",label:"\u6536\u8D27\u4EBA\u7535\u8BDD",width:"150","show-overflow-tooltip":"",align:"center"}),o(n,{prop:"receiver_address",label:"\u6536\u8D27\u4EBA\u5730\u5740","min-width":"100","show-overflow-tooltip":"",align:"center"}),o(n,{label:"\u64CD\u4F5C",width:"100",align:"center"},{default:l(({row:d})=>[o(T,{type:"danger",size:"small",onClick:Y=>e.refundGoods(a,d)},{default:l(()=>[...u[15]||(u[15]=[c("\u7F3A\u8D27",-1)])]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1032,["data"])])):(h(),V("div",ia,[o(_,{class:"is-loading",style:{"margin-right":"6px"}},{default:l(()=>[o(K)]),_:1}),u[17]||(u[17]=c("\u52A0\u8F7D\u4E2D... ",-1))]))]),_:1}),o(n,{prop:"so_no",label:"\u9500\u552E\u8BA2\u5355\u53F7","min-width":"180","show-overflow-tooltip":"",align:"center"}),o(n,{label:"\u5BA2\u6237","min-width":"150",align:"center"},{default:l(({row:a})=>[c(i(e.customerMap[a.sales_person]||a.sales_person||"-")+"\uFF08"+i(e.customerMap[a.shop_type_text]||a.shop_type_text||"-")+"\uFF09",1)]),_:1}),o(n,{label:"\u4ED3\u5E93","min-width":"120",align:"center"},{default:l(({row:a})=>[c(i(e.warehouseMap[a.warehouse_id]||a.warehouse_id||"-"),1)]),_:1}),o(n,{label:"\u8BA2\u5355\u65E5\u671F","min-width":"110",align:"center"},{default:l(({row:a})=>[c(i(e.formatDate(a.order_date)),1)]),_:1}),o(n,{label:"\u8981\u6C42\u9001\u8FBE\u65E5\u671F","min-width":"120",align:"center"},{default:l(({row:a})=>[c(i(e.formatDate(a.required_delivery_date)),1)]),_:1}),o(n,{label:"\u8BA2\u5355\u91D1\u989D","min-width":"120",align:"center"},{default:l(({row:a})=>[p("span",da,i(e.formatAmount(a.total_amount)),1)]),_:1}),o(n,{prop:"status_text",label:"\u72B6\u6001",width:"100",align:"center"},{default:l(({row:a})=>[o(M,{size:"small","disable-transitions":""},{default:l(()=>[c(i(a.status_text),1)]),_:2},1024)]),_:1}),o(n,{label:"\u521B\u5EFA\u65F6\u95F4","min-width":"160",align:"center"},{default:l(({row:a})=>[c(i(e.formatTimestamp(a.created_at)),1)]),_:1}),o(n,{prop:"remark",label:"\u5907\u6CE8","min-width":"150","show-overflow-tooltip":"",align:"center"},{default:l(({row:a})=>[c(i(a.remark||"-"),1)]),_:1})]),_:1},8,["data","onExpandChange"])),[[w,e.loading]]),p("div",ca,[o(W,{"current-page":e.pagination.current,"onUpdate:currentPage":u[4]||(u[4]=a=>e.pagination.current=a),"page-size":e.pagination.pageSize,"onUpdate:pageSize":u[5]||(u[5]=a=>e.pagination.pageSize=a),"page-sizes":[10,20,50,100],total:e.pagination.total,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:e.handleSizeChange,onCurrentChange:e.handleCurrentChange},null,8,["current-page","page-size","total","onSizeChange","onCurrentChange"])]),o(C,{modelValue:e.outboundDialogVisible,"onUpdate:modelValue":u[9]||(u[9]=a=>e.outboundDialogVisible=a),title:"\u751F\u6210\u51FA\u5E93\u5355",width:"880px","destroy-on-close":""},{footer:l(()=>[o(D,{onClick:u[8]||(u[8]=a=>e.outboundDialogVisible=!1)},{default:l(()=>[...u[21]||(u[21]=[c("\u53D6\u6D88",-1)])]),_:1}),o(D,{type:"success",loading:e.generateLoading,disabled:e.selectedOutboundOrders.length===0,onClick:e.handleGenerateOutbound},{default:l(()=>[c(" \u786E\u8BA4\u751F\u6210\u51FA\u5E93\u5355 ("+i(e.selectedOutboundOrders.length)+") ",1)]),_:1},8,["loading","disabled","onClick"])]),default:l(()=>[p("div",pa,[o(v,{modelValue:e.outboundSearchKeyword,"onUpdate:modelValue":u[6]||(u[6]=a=>e.outboundSearchKeyword=a),placeholder:"\u641C\u7D22\u9500\u552E\u8BA2\u5355\u53F7 / \u5BA2\u6237 / \u4ED3\u5E93",clearable:"",style:{width:"320px"},onInput:e.handleOutboundSearch,onKeyup:ne(e.handleOutboundSearch,["enter"])},{prefix:l(()=>[o(_,null,{default:l(()=>[o(A)]),_:1})]),_:1},8,["modelValue","onInput","onKeyup"]),p("span",ma,[u[18]||(u[18]=c("\u5DF2\u9009 ",-1)),p("strong",null,i(e.selectedOutboundOrders.length),1),u[19]||(u[19]=c(" \u5F20",-1))])]),re((h(),O(E,{ref:"outboundTableRef",data:e.outboundOrderList,border:"",stripe:"",onSelectionChange:e.handleOutboundSelectionChange,onRowClick:e.handleRowClick},{default:l(()=>[o(n,{type:"selection",width:"55",align:"center"}),o(n,{prop:"so_no",label:"\u9500\u552E\u8BA2\u5355\u53F7","min-width":"180","show-overflow-tooltip":"",align:"center"}),o(n,{label:"\u5BA2\u6237","min-width":"150",align:"center"},{default:l(({row:a})=>[c(i(e.customerMap[a.customer_id]||"-"),1)]),_:1}),o(n,{label:"\u4ED3\u5E93","min-width":"120",align:"center"},{default:l(({row:a})=>[c(i(e.warehouseMap[a.warehouse_id]||"-"),1)]),_:1}),o(n,{label:"\u8BA2\u5355\u65E5\u671F","min-width":"110",align:"center"},{default:l(({row:a})=>[c(i(e.formatDate(a.order_date)),1)]),_:1}),o(n,{label:"\u8BA2\u5355\u91D1\u989D","min-width":"120",align:"center"},{default:l(({row:a})=>[p("span",ga,i(e.formatAmount(a.total_amount)),1)]),_:1}),o(n,{prop:"status_text",label:"\u72B6\u6001",width:"100",align:"center"},{default:l(({row:a})=>[o(M,{size:"small"},{default:l(()=>[c(i(a.status_text),1)]),_:2},1024)]),_:1})]),_:1},8,["data","onSelectionChange","onRowClick"])),[[w,e.outboundLoading]]),p("div",fa,[o(v,{modelValue:e.outboundRemark,"onUpdate:modelValue":u[7]||(u[7]=a=>e.outboundRemark=a),type:"textarea",rows:2,placeholder:"\u8BF7\u8F93\u5165\u5907\u6CE8\uFF08\u9009\u586B\uFF09",maxlength:"200","show-word-limit":""},null,8,["modelValue"])]),e.barcodeImage?(h(),V("div",ha,[u[20]||(u[20]=p("p",{style:{"margin-bottom":"8px",color:"#606266","font-size":"14px"}},"\u51FA\u5E93\u6761\u7801",-1)),p("img",{src:e.barcodeImage,alt:"\u6761\u7801",style:{"max-width":"400px",height:"auto"}},null,8,ya)])):Ge("",!0)]),_:1},8,["modelValue"])]),_:1})}var Ba=qe(ua,[["render",ba],["__scopeId","data-v-6514288b"]]);export{Ba as default};
|