cashier-ERP/dist/assets/index-Do69Dp-3.js

2 lines
14 KiB
JavaScript

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