cashier-mer/dist/assets/index-CInbkgrA.js
weipengfei 9ed175c975 1
2024-04-10 11:36:40 +08:00

2 lines
12 KiB
JavaScript

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