cashier-mer/dist/assets/index-B9xI11ZK.js

2 lines
13 KiB
JavaScript

import{c as re,a as ie,b as Z,d as ue,o as de}from"./pay.vue_vue_type_style_index_0_scoped_43f405bf_lang-UtIhw1Q5.js";import{_ as K,r as c,o as M,m as b,a as N,b as m,c as g,d as J,w as x,e,f as i,g as h,t as E,n as H,E as T,u as ee,h as A,F as Q,i as W,j as te,k as _e,l as j,p as oe,q as se,s as G,v as ae,x as le,y as pe,z as ve}from"./index-BK45VPeO.js";import{_ as fe}from"./lodash-BI5zS7wc.js";import{p as me}from"./padding-C_XosNLD.js";import{g as he,a as ge}from"./shop-DFQI72f9.js";import{p as ye}from"./pay-jKmmbq3P.js";const ke={class:"price"},be={class:"flex"},$e={style:{margin:"0.625rem","padding-bottom":"40px"}},we={style:{color:"#f5222d","font-weight":"bold","margin-left":"1rem"}},xe={class:"dialog-footer"},Pe={__name:"price",emits:["changeAllPrice"],setup(S,{expose:F,emit:y}){const a=c(!1),u=c(null),o=c(0),d=(n=!0,p=0)=>{l.value.nowPrice="",l.value.percentage="",a.value=n,o.value=p,H(()=>{setTimeout(()=>{var V;(V=u.value)==null||V.focus()},150)})},l=c({nowPrice:"",percentage:""}),v=n=>{l.value.percentage=(n/o.value*100).toFixed(2)},$=n=>{l.value.nowPrice=(o.value*n/100).toFixed(2)},L=y,P=()=>{if(l.value.percentage>100)return l.value.nowPrice="",l.value.percentage="",T.error("改价金额不能大于当前订单金额");if(l.value.nowPrice<=0)return l.value.nowPrice="",l.value.percentage="",T.error("金额不能小于0");L("changeAllPrice",l.value.nowPrice)};F({show:d,dialogVisible:a});const R=()=>{a.value&&P()};return M(()=>{b.on("enter",R)}),N(()=>{b.off("enter",R)}),(n,p)=>{const V=m("el-input"),U=m("el-button"),_=m("el-dialog");return g(),J(_,{modelValue:a.value,"onUpdate:modelValue":p[2]||(p[2]=f=>a.value=f),title:"订单改价",width:"650"},{footer:x(()=>[e("div",xe,[i(U,{class:"ok-btn",type:"primary",onClick:P},{default:x(()=>[h(" 确定 (Enter) ")]),_:1})])]),default:x(()=>[e("div",ke,[e("div",be,[i(V,{ref_key:"priceRef",ref:u,style:{flex:"3",margin:"0.625rem",height:"2.5rem"},modelValue:l.value.nowPrice,"onUpdate:modelValue":p[0]||(p[0]=f=>l.value.nowPrice=f),type:"number",placeholder:"请输入改价后的价格",onInput:v},{suffix:x(()=>[h("元")]),_:1},8,["modelValue"]),i(V,{style:{flex:"2",margin:"0.625rem",height:"2.5rem"},modelValue:l.value.percentage,"onUpdate:modelValue":p[1]||(p[1]=f=>l.value.percentage=f),type:"number",placeholder:"请输入比例",onInput:$},{suffix:x(()=>[h("%")]),_:1},8,["modelValue"])]),e("div",$e,[h(" 改价后金额: "),e("span",we,"¥"+E(l.value.nowPrice||o.value||" - - "),1)])])]),_:1},8,["modelValue"])}}},Ve=K(Pe,[["__scopeId","data-v-924edcc0"]]),Ce={class:"my-order"},Ie={class:"header-nav"},Ae={class:"nav-item"},Se={class:"order-list"},Fe={class:"order-item-info"},Le={class:"order-item-title"},Re={class:"title"},Ee=["onClick"],De={class:"order-item-sku"},Oe=["onClick"],Ue={class:"order-item-price"},ze={class:"order-footer"},qe={class:"order-total"},Me={class:"price"},Ne={class:"total-item"},Be={style:{"font-size":"1.4rem"}},je={class:"total-item"},Te={class:"order-btn"},Ke={__name:"order",emits:["goPay","editAttr"],setup(S,{expose:F,emit:y}){const a=c([]),u=c(0),o=c(0),d=c(0),l=ee(),v=()=>{let t=[];a.value.map(r=>{t.push(r.cart_id)}),t.length!=0&&L(t)},$=t=>{a.value=a.value.filter(r=>r.cart_id!=t),L([t])},L=t=>{re({cart_id:t}).then(r=>{console.log(r),P()})},P=()=>{u.value=0,o.value=0,d.value=0,ie({staff_id:l.userInfo.service.service_id,sale_type:2}).then(t=>{var r,w;((w=(r=t.data)==null?void 0:r.list)==null?void 0:w.length)>0?(a.value=t.data.list[0].list,a.value.forEach(C=>{u.value+=C.productAttr.price*C.cart_num}),o.value=u.value):a.value=[]})};P();const R=y,n=()=>{R("goPay")},p=(t,r)=>{Z(t.cart_id,{cart_num:t.cart_num}).then(w=>{u.value=0,a.value.forEach(C=>{u.value+=C.productAttr.price*C.cart_num}),o.value=u.value})},V=t=>{R("editPupop",t)},U=(t,r)=>{Z(t,r).then(w=>{P()})},_=t=>{d.value=o.value-t,u.value=+t,H(()=>{setTimeout(()=>{k(!1)},150)})};c(0);const f=c(null),k=(t=!0)=>{f.value.show(t,o.value)};F({getList:P,list:a,editItem:U,discounts:d,allPrice:u});const z=()=>{f.value.dialogVisible?f.value.dialogVisible=!1:k()},s=()=>{a.value.length>0&&v()};return M(()=>{b.on("insert",z),b.on("delete",s)}),N(()=>{b.off("insert",z),b.off("delete",s)}),(t,r)=>{const w=m("Delete"),C=m("el-icon"),q=m("el-empty"),I=m("el-image"),D=m("ArrowDown"),Y=m("el-input-number"),ne=m("el-button");return g(),A("div",Ce,[e("div",Ie,[e("div",Ae,[h(" 已选购 "),e("span",null,E(a.value.length),1),h(" 件 ")]),e("div",{class:"nav-item-clear",onClick:v},[i(C,null,{default:x(()=>[i(w)]),_:1}),h("清空 (Delete) ")])]),e("div",Se,[a.value.length==0?(g(),J(q,{key:0,description:"请点击右侧添加商品"})):(g(!0),A(Q,{key:1},W(a.value,(O,ce)=>(g(),A("div",{class:"order-item",key:ce},[i(I,{loading:"lazy",class:"order-item-img",src:O.productAttr&&O.productAttr.image||O.product.image},null,8,["src"]),e("div",Fe,[e("div",Le,[e("div",Re,E(O.spu.store_name),1),e("div",{class:"delete",onClick:B=>$(O.cart_id)},"删除",8,Ee)]),e("div",De,[e("span",{style:{display:"flex","align-items":"center"},onClick:B=>V(O)},[h("商品规格: "+E(O.productAttr.sku||"默认规格"),1),i(C,{size:"16",style:{"margin-left":"0.2rem"}},{default:x(()=>[i(D)]),_:1})],8,Oe)]),e("div",Ue,[e("div",null,[h(" ¥"),e("span",null,E(O.productAttr.price),1)]),e("div",null,[i(Y,{modelValue:O.cart_num,"onUpdate:modelValue":B=>O.cart_num=B,"step-strictly":"",min:1,step:1,onChange:B=>p(O)},null,8,["modelValue","onUpdate:modelValue","onChange"])])])])]))),128))]),e("div",ze,[e("div",qe,[e("div",Me,[e("div",Ne,[h(" 实付: "),e("span",null,[h("¥"),e("span",Be,E(u.value.toFixed(2)),1)])]),e("div",je,[h(" 优惠: "),e("span",null,[h("¥"),e("span",null,E(d.value.toFixed(2)),1)])])])]),e("div",Te,[i(ne,{class:"btn",type:"primary",onClick:n,disabled:a.value.length==0},{default:x(()=>[h("立即结账 (F9)")]),_:1},8,["disabled"])])]),i(Ve,{ref_key:"priceRef",ref:f,onChangeAllPrice:_},null,512)])}}},Ge=K(Ke,[["__scopeId","data-v-d5f59937"]]),X=S=>(ae("data-v-5ddbb518"),S=S(),le(),S),Je={class:"my-order"},He=X(()=>e("div",{class:"nav-item-label"},"搜索 (Shift)",-1)),Qe={class:"nav-item-input"},We={class:"shop-list","infinite-scroll-distance":"100","infinite-scroll-delay":"500","infinite-scroll-immediate":!1,style:{overflow:"auto"}},Xe=["onClick"],Ye={class:"shop-name"},Ze={class:"shop-price"},et={key:0,class:"no-stock"},tt=X(()=>e("div",null,[e("span",null,"暂无"),e("span",null,"库存")],-1)),ot=[tt],st={key:1,class:"no-stock"},at=X(()=>e("div",null,[e("span",null,"平台"),e("span",null,"关闭")],-1)),lt=[at],nt={__name:"shop",props:{storeList:{type:Array,default:()=>[]}},emits:["getStoreList","changeItem","loadMore"],setup(S,{expose:F,emit:y}){const a=c(null),u=y,o=c(""),d=()=>{u("loadMore",{bar_code:o.value})},l=n=>{if(n.is_used==0)return T.error("该商品已被平台关闭");if(n.stock==0)return T.warning("该商品无库存");u("changeItem",n)},v=fe.throttle(()=>{u("getStoreList",{bar_code:o.value},!0)},300);F({bar_code:o});const $=c(!1),L=()=>{$.value=!0},P=()=>{$.value=!1},R=()=>{var n;(n=a.value)==null||n.focus()};return M(()=>{H(()=>{var n;(n=a.value)==null||n.focus(),L()}),b.on("shift",R)}),N(()=>{b.off("shift",R)}),(n,p)=>{const V=m("el-input"),U=m("Search"),_=m("el-icon"),f=m("el-button"),k=m("el-image"),z=m("el-space"),s=te("infinite-scroll");return g(),A("div",Je,[e("div",{class:oe(["header-nav",{"input-focus":$.value}])},[He,e("div",Qe,[i(V,{modelValue:o.value,"onUpdate:modelValue":p[0]||(p[0]=t=>o.value=t),placeholder:" 搜索商品名称/条形码或点击聚焦扫码, 按回车(Enter)搜索",clearable:"",ref_key:"codeRef",ref:a,onFocus:L,onBlur:P,onKeyup:_e(j(v),["enter"]),onClear:j(v)},null,8,["modelValue","onKeyup","onClear"])]),e("div",{class:"nav-item-btn",onClick:p[1]||(p[1]=(...t)=>j(v)&&j(v)(...t))},[i(f,{class:"btn",type:"primary"},{default:x(()=>[i(_,null,{default:x(()=>[i(U)]),_:1})]),_:1})])],2),se((g(),A("div",We,[i(z,{wrap:""},{default:x(()=>[(g(!0),A(Q,null,W(S.storeList,(t,r)=>(g(),A("div",{class:"shop-item",key:r,onClick:w=>l(t)},[i(k,{loading:"lazy",src:t.image},null,8,["src"]),e("div",Ye,E(t.store_name),1),e("div",Ze,[h(" ¥"),e("span",null,E(t.price),1)]),t.stock==0?(g(),A("div",et,ot)):G("",!0),t.is_used==0?(g(),A("div",st,lt)):G("",!0)],8,Xe))),128))]),_:1})])),[[s,d]])])}}},ct=K(nt,[["__scopeId","data-v-5ddbb518"]]),rt=S=>(ae("data-v-29f08ea1"),S=S(),le(),S),it={class:"shop"},ut={key:0,class:"shop-info"},dt={class:"shop-info-left"},_t={class:"shop-info-right"},pt={class:"shop-info-right-top"},vt={class:"shop-info-right-center"},ft={class:"shop-info-right-price"},mt={class:"shop-sku"},ht=rt(()=>e("div",{class:"title"},"产品",-1)),gt={class:"sku"},yt=["onClick"],kt={class:"dialog-footer"},bt={__name:"pupop",emits:["changeItem"],setup(S,{expose:F,emit:y}){const a=c(!1),u=_=>{a.value=_},o=c({}),d=c(null),l=c(!1),v=c("add"),$=c({}),L=(_,f="add")=>{v.value=f,f=="add"?(o.value=_,d.value=_.attr[0]):(l.value=!0,$.value=_,he(_.product_id).then(k=>{k.data.attrValue=JSON.parse(JSON.stringify(k.data.attr)),k.data.attr=Object.keys(k.data.sku),o.value=k.data,d.value=k.data.attr[0],l.value=!1}).catch(k=>{l.value=!1}))},P=y,R=()=>{v.value=="add"?P("changeItem",o.value,d.value):P("editItem",$.value.cart_id,{cart_num:$.value.cart_num,product_attr_unique:o.value.sku[d.value].unique}),a.value=!1},n=_=>{d.value=_};F({show:u,setForm:L});const p=()=>{if(!a.value)return;let _=o.value.attr.indexOf(d.value);if(_>0)return n(o.value.attr[_-1])},V=()=>{if(!a.value)return;let _=o.value.attr.indexOf(d.value);if(_<o.value.attr.length-1)return n(o.value.attr[_+1])},U=()=>{a.value&&R()};return M(()=>{b.on("left",p),b.on("right",V),b.on("enter",U)}),N(()=>{b.off("left",p),b.off("right",V),b.off("enter",U)}),(_,f)=>{const k=m("el-image"),z=m("el-space"),s=m("el-button"),t=m("el-dialog"),r=te("loading");return g(),J(t,{modelValue:a.value,"onUpdate:modelValue":f[0]||(f[0]=w=>a.value=w),title:"商品规格",width:"650"},pe({default:x(()=>{var w,C,q;return[se((g(),A("div",it,[o.value.sku?(g(),A("div",ut,[e("div",dt,[i(k,{loading:"lazy",src:((w=o.value.sku[d.value])==null?void 0:w.image)||o.value.image},null,8,["src"])]),e("div",_t,[e("div",pt,E(o.value.store_name),1),e("div",vt,"库存"+E(((C=o.value.sku[d.value])==null?void 0:C.stock)||0),1),e("div",ft,[h("¥"),e("span",null,E(((q=o.value.sku[d.value])==null?void 0:q.price)||o.value.price),1)])])])):G("",!0),e("div",mt,[ht,e("div",gt,[i(z,{wrap:"",size:20},{default:x(()=>[(g(!0),A(Q,null,W(o.value.attr,(I,D)=>(g(),A("div",{class:oe(["sku-item",{"sku-item_active":d.value==I}]),onClick:Y=>n(I),key:D},E(I||"默认规格"),11,yt))),128))]),_:1})])])])),[[r,l.value]])]}),_:2},[v.value!="add"&&o.value.attr&&o.value.attr.length==1?void 0:{name:"footer",fn:x(()=>[e("div",kt,[i(s,{class:"ok-btn",type:"primary",onClick:R},{default:x(()=>[h(" 确定 (Enter) ")]),_:1})])]),key:"0"}]),1032,["modelValue"])}}},$t=K(bt,[["__scopeId","data-v-29f08ea1"]]),wt={class:"my-card"},St={__name:"index",setup(S){const F=c(null),y=c(null),a=c(null),u=c(null),o=c([]),d=ee(),l=ve(),v=c({page:1,limit:30}),$=(s={},t=!1)=>{v.value={staff_id:d.userInfo.service.service_id,sale_type:2,mer_type:1,...v.value,...s},t&&(o.value=[],v.value.page=1,L.value=!1),ge(v.value).then(r=>{var C,q;((q=(C=r.data)==null?void 0:C.list)==null?void 0:q.length)<v.value.limit&&(L.value=!0);let w=r.data.list.map(I=>(Object.keys(I.sku).forEach(D=>{I.sku[D].wholesale_price&&(I.sku[D].price=I.sku[D].wholesale_price)}),I.attrValue.forEach(D=>{D.wholesale_price&&(D.price=D.wholesale_price)}),I.attr=Object.keys(I.sku),I));o.value=o.value.concat(w),s.bar_code&&o.value.length==1&&R(s.bar_code)&&(a.value.bar_code="",p(o.value[0],o.value[0].attr[0])),v.value.page++})},L=c(!1),P=s=>{L.value||$(s)};function R(s){return/^\d+$/.test(s)}const n=(s,t="")=>{let r={is_new:0,product_id:s.product_id,cart_num:1,product_attr_unique:s.sku[t]!==void 0?s.sku[t].unique:"",staff_id:d.userInfo.service.service_id,product_type:0,sale_type:2};ue(r).then(w=>{y.value.getList()})},p=(s,t)=>{if(!s.attr||s.attr.length==0||s.attr.length==1)return n(s,s.attr[0]?s.attr[0]:"");if(t)return n(s,t);F.value.setForm(s,"add"),F.value.show(!0)},V=(s,t)=>{y.value.editItem(s,t)},U=s=>{F.value.setForm(s,"edit"),F.value.show(!0)},_=()=>{let s=y.value.list.map(r=>r.cart_id),t={takes:[],use_coupon:{},use_integral:!1,cart_id:s};y.value.discounts>0&&(t.deduction_price=y.value.discounts.toFixed(2),t.pay_type="micropay"),de(t).then(r=>{u.value.setForm({data:r.data,cart_id:s})})},f=()=>{_(),u.value.drawer=!0},k=()=>{y.value.getList()},z=()=>{l.name=="saleHome"&&(!u.value.drawer&&y.value.list.length>0?f():u.value.beforeClose())};return M(()=>{$(),v.value.page++,b.on("F9",z)}),N(()=>{b.off("F9",z)}),(s,t)=>(g(),A("div",wt,[i(Ge,{ref_key:"orderRef",ref:y,onGoPay:f,onEditPupop:U},null,512),i(me),i(ct,{ref_key:"shopRef",ref:a,style:{flex:"1"},storeList:o.value,onGetStoreList:$,onChangeItem:p,onLoadMore:P},null,8,["storeList"]),i($t,{ref_key:"pupopRef",ref:F,onChangeItem:p,onEditItem:V},null,512),i(ye,{ref_key:"payRef",ref:u,onPaySuccess:k},null,512)]))}};export{St as default};