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

2 lines
12 KiB
JavaScript

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