cashier-ERP/dist/assets/index-BcmmN2mF.js

2 lines
13 KiB
JavaScript

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