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

2 lines
14 KiB
JavaScript

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