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

2 lines
11 KiB
JavaScript

import{_ as H,r as p,u as Q,b as i,c as f,d as A,w as a,h as L,t as W,e as F,f as l,q as K,D as M,g as h,E as g,l as te,v as le,p as ae,F as oe,i as ne,x as N}from"./index-C_cqdhu3.js";import{p as re,c as ue,a as ie,b as de,d as se,s as ce,u as pe,e as _e}from"./shop-C19BYqqI.js";const me={key:0},fe={key:1},ve={class:"dra-body"},ge=["src"],ye={__name:"add",emits:["reload"],setup(X,{expose:T,emit:S}){const d=p(!1),q={store_name:"",image:[],slider_image:[],attrValue:[{bar_code:"",price:"",stock:"",cost:"",ot_price:"",wholesale_price:"0",extension_one:"",extension_two:""}],content:{image:[]},unit_name:"",delivery_way:["1"]},n=p(q),U=Q(),E=S,_=p(!1),z=p(""),P=e=>{z.value=e.url,_.value=!0},D=p("add"),I=(e,t)=>{n.value=q,D.value=e,e=="add"?d.value=!0:e=="edit"&&(d.value=!0,v(t.product_id))},v=e=>{re(U.userInfo.service.mer_id,e).then(t=>{t.data.image=[{url:t.data.image,uid:t.data.image}],t.data.content.image=t.data.content.image.map(m=>({url:m,uid:t.data.image})),t.data.slider_image=t.data.slider_image.map(m=>({url:m,uid:t.data.image})),n.value=t.data,console.log(n.value)})},R=p([]);(()=>{ue(U.userInfo.service.mer_id).then(e=>{R.value=e.data})})();const O=p(null),j=()=>{var t,m,c,y,k,C;let e=JSON.parse(JSON.stringify(n.value));if(console.log(e.cate_id),e.cate_id&&typeof e.cate_id=="object"&&e.cate_id.length>0?e.cate_id=e.cate_id[e.cate_id.length-1]||"":e.cate_id=e.cate_id||"",e.image=="")return g.error("请上传商品封面图");if(e.slider_image.length==0)return g.error("请上传商品轮播图");if(e.content.image=e.content.image.map(r=>{var s,w,V,b;return(w=(s=r==null?void 0:r.response)==null?void 0:s.data)!=null&&w.path?(b=(V=r==null?void 0:r.response)==null?void 0:V.data)==null?void 0:b.path:r.url}),e.image=(c=(m=(t=e.image[0])==null?void 0:t.response)==null?void 0:m.data)!=null&&c.path?(C=(k=(y=e.image[0])==null?void 0:y.response)==null?void 0:k.data)==null?void 0:C.path:e.image[0].url,e.slider_image=e.slider_image.map(r=>{var s,w,V,b;return(w=(s=r==null?void 0:r.response)==null?void 0:s.data)!=null&&w.path?(b=(V=r==null?void 0:r.response)==null?void 0:V.data)==null?void 0:b.path:r.url}),e.store_name=="")return g.error("请输入商品名称");if(e.cate_id=="")return g.error("请选择平台分类");if(e.attrValue[0].bar_code=="")return g.error("请输入商品条码");if(e.attrValue[0].stock<=0)return g.error("请输入商品库存");if(e.attrValue[0].price<=0)return g.error("请输入商品价格");D.value=="add"?ie(U.userInfo.service.mer_id,e).then(r=>{g.success(r.message),E("reload"),$()}):de(U.userInfo.service.mer_id,e.product_id,e).then(r=>{g.success(r.message),E("reload"),$()})},J=()=>{$()},$=()=>{d.value=!1},B=()=>{};return T({drawer:d,show:I}),(e,t)=>{const m=i("el-input"),c=i("el-form-item"),y=i("el-cascader"),k=i("Plus"),C=i("el-icon"),r=i("el-upload"),s=i("el-form"),w=i("el-dialog"),V=i("el-button"),b=i("el-drawer");return f(),A(b,{size:800,modelValue:d.value,"onUpdate:modelValue":t[10]||(t[10]=u=>d.value=u),direction:"rtl",onOpen:B,"before-close":$},{header:a(()=>[D.value=="add"?(f(),L("h4",me,"添加商品")):(f(),L("h4",fe,"编辑商品 ["+W(n.value.product_id)+"]",1))]),default:a(()=>[F("div",ve,[l(s,{ref_key:"formRef",ref:O,model:n.value,"label-width":"150px"},{default:a(()=>[l(c,{label:"商品条码",required:""},{default:a(()=>[l(m,{modelValue:n.value.attrValue[0].bar_code,"onUpdate:modelValue":t[0]||(t[0]=u=>n.value.attrValue[0].bar_code=u),type:"number",placeholder:"请输入商品条码"},null,8,["modelValue"])]),_:1}),l(c,{label:"商品名称",required:""},{default:a(()=>[l(m,{modelValue:n.value.store_name,"onUpdate:modelValue":t[1]||(t[1]=u=>n.value.store_name=u),placeholder:"请输入商品名称"},null,8,["modelValue"])]),_:1}),l(c,{label:"平台分类",required:""},{default:a(()=>[l(y,{modelValue:n.value.cate_id,"onUpdate:modelValue":t[2]||(t[2]=u=>n.value.cate_id=u),class:"pageWidth",options:R.value,filterable:"",clearable:""},null,8,["modelValue","options"])]),_:1}),l(c,{label:"商品封面图",required:""},{default:a(()=>[l(r,{"file-list":n.value.image,"onUpdate:fileList":t[3]||(t[3]=u=>n.value.image=u),action:K(M).upload,name:"field","list-type":"picture-card","on-preview":P,limit:1},{default:a(()=>[l(C,null,{default:a(()=>[l(k)]),_:1})]),_:1},8,["file-list","action"])]),_:1}),l(c,{label:"商品轮播图",required:""},{default:a(()=>[l(r,{"file-list":n.value.slider_image,"onUpdate:fileList":t[4]||(t[4]=u=>n.value.slider_image=u),action:K(M).upload,name:"field","list-type":"picture-card","on-preview":P,limit:9},{default:a(()=>[l(C,null,{default:a(()=>[l(k)]),_:1})]),_:1},8,["file-list","action"])]),_:1}),l(c,{label:"商品详情"},{default:a(()=>[l(r,{"file-list":n.value.content.image,"onUpdate:fileList":t[5]||(t[5]=u=>n.value.content.image=u),action:K(M).upload,name:"field","list-type":"picture-card","on-preview":P,limit:9},{default:a(()=>[l(C,null,{default:a(()=>[l(k)]),_:1})]),_:1},8,["file-list","action"])]),_:1}),l(c,{label:"商品单位",required:""},{default:a(()=>[l(m,{modelValue:n.value.unit_name,"onUpdate:modelValue":t[6]||(t[6]=u=>n.value.unit_name=u),placeholder:"请输入商品单位"},null,8,["modelValue"])]),_:1}),l(c,{label:"零售价",required:""},{default:a(()=>[l(m,{modelValue:n.value.attrValue[0].price,"onUpdate:modelValue":t[7]||(t[7]=u=>n.value.attrValue[0].price=u),type:"number",placeholder:"请输入零售价"},null,8,["modelValue"])]),_:1}),l(c,{label:"库存",required:""},{default:a(()=>[l(m,{modelValue:n.value.attrValue[0].stock,"onUpdate:modelValue":t[8]||(t[8]=u=>n.value.attrValue[0].stock=u),type:"number",placeholder:"请输入库存"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),l(w,{modelValue:_.value,"onUpdate:modelValue":t[9]||(t[9]=u=>_.value=u)},{default:a(()=>[F("img",{style:{width:"100%",height:"100%"},"w-full":"",src:z.value,alt:"Preview Image"},null,8,ge)]),_:1},8,["modelValue"])]),footer:a(()=>[l(V,{onClick:J},{default:a(()=>[h("取消")]),_:1}),l(V,{type:"primary",onClick:j},{default:a(()=>[h("确认")]),_:1})]),_:1},8,["modelValue"])}}},we=H(ye,[["__scopeId","data-v-2d33ceca"]]),Ve={"element-loading-text":"加载中",class:"my-shop"},be={key:0,style:{color:"#ff4a00"}},he={key:1},ke={key:2},Ce={class:"dialog-footer"},xe={__name:"index",setup(X){const T=p([]),S=Q(),d=p({page:1,limit:15,type:1,keyword:"",staff_id:S.userInfo.service.service_id}),q=p(!1),n=p(0),U=p([]);(()=>{se(S.userInfo.service.mer_id).then(e=>{U.value=e.data})})();const _=()=>{q.value=!0,ce(S.userInfo.service.mer_id,d.value).then(e=>{T.value=e.data.list,n.value=e.data.count,q.value=!1})};_();const z=e=>{d.value.page=e,_()},P=e=>{d.value.page=e,_()},D=e=>{d.value.page=e,_()},I=p(!1),v=p({}),R=e=>{v.value=e,I.value=!0},G=()=>{let e={attr:v.value.attr||[],attrValue:v.value.attrValue,mer_cate_id:v.value.merCateId||[],spec_type:v.value.spec_type,is_stock:1};pe(v.value.product_id,e).then(t=>{g({message:t.message,type:"success"}),I.value=!1,_()}).catch(t=>{g({message:t,type:"error"})})},O=p("1"),j=e=>{d.value.type=e,d.value.page=1,_()},J=e=>{_e(S.userInfo.service.mer_id,e.product_id,{status:e.is_show?1:0}).then(t=>{g.success(t.message),_()})},$=p(null),B=(e="add",t)=>{$.value.show(e,t)};return(e,t)=>{const m=i("el-input"),c=i("el-form-item"),y=i("el-button"),k=i("el-form"),C=i("el-menu-item"),r=i("el-menu"),s=i("el-table-column"),w=i("el-image"),V=i("el-switch"),b=i("el-table"),u=i("el-pagination"),Y=i("el-input-number"),Z=i("el-dialog"),ee=te("loading");return le((f(),L("div",Ve,[l(k,{inline:!0},{default:a(()=>[l(c,{label:"关键字:"},{default:a(()=>[l(m,{modelValue:d.value.keyword,"onUpdate:modelValue":t[0]||(t[0]=o=>d.value.keyword=o),placeholder:"请输入关键字搜索",style:{width:"20rem"},clearable:"",onClear:t[1]||(t[1]=o=>_(!0)),onKeydown:t[2]||(t[2]=ae(o=>_(!0),["enter"]))},null,8,["modelValue"])]),_:1}),l(c,null,{default:a(()=>[l(y,{type:"primary",onClick:t[3]||(t[3]=o=>_(!0))},{default:a(()=>[h("搜索")]),_:1})]),_:1}),l(c,null,{default:a(()=>[l(y,{type:"primary",onClick:t[4]||(t[4]=o=>B("add"))},{default:a(()=>[h("新增")]),_:1})]),_:1})]),_:1}),l(r,{"default-active":O.value,class:"el-menu-top",mode:"horizontal",onSelect:j},{default:a(()=>[(f(!0),L(oe,null,ne(U.value,(o,x)=>(f(),A(C,{index:o.type+"",key:x},{default:a(()=>[h(W(`${o.name}(${o.count})`),1)]),_:2},1032,["index"]))),128))]),_:1},8,["default-active"]),l(b,{data:T.value,style:{width:"100%"}},{default:a(()=>[l(s,{prop:"product_id",label:"ID",width:"100"}),l(s,{prop:"image",label:"图片",width:"120"},{default:a(o=>[l(w,{loading:"lazy",style:{width:"60px",height:"60px"},src:o.row.image},null,8,["src"])]),_:1}),l(s,{prop:"store_name",label:"商品名称",width:"500"}),l(s,{prop:"price",label:"售价"}),l(s,{prop:"stock",label:"库存"}),d.value.type<=2?(f(),A(s,{key:0,label:"上/下架",width:"100"},{default:a(o=>[l(V,{modelValue:o.row.is_show,"onUpdate:modelValue":x=>o.row.is_show=x,"active-value":1,"inline-prompt":"","active-text":"上架","inactive-text":"下架",onClick:x=>J(o.row)},null,8,["modelValue","onUpdate:modelValue","onClick"])]),_:1})):N("",!0),d.value.type<=4?(f(),A(s,{key:1,label:"商品状态",width:"100"},{default:a(o=>[o.row.is_used?o.row.is_show?(f(),L("span",he,"上架显示")):(f(),L("span",ke,"下架")):(f(),L("span",be,"平台关闭"))]),_:1})):N("",!0),l(s,{label:"操作",width:"120"},{default:a(o=>[d.value.type!=5?(f(),A(y,{key:0,type:"primary",link:"",onClick:x=>R(o.row)},{default:a(()=>[h("修改库存")]),_:2},1032,["onClick"])):N("",!0),d.value.type!=1&&d.value.type!=5?(f(),A(y,{key:1,type:"primary",link:"",onClick:x=>B("edit",o.row)},{default:a(()=>[h("编辑")]),_:2},1032,["onClick"])):N("",!0)]),_:1})]),_:1},8,["data"]),l(u,{"page-size":d.value.limit,layout:"prev, pager, next",total:n.value,onPrevClick:z,onNextClick:P,onCurrentChange:D},null,8,["page-size","total"]),l(Z,{modelValue:I.value,"onUpdate:modelValue":t[6]||(t[6]=o=>I.value=o),title:"编辑商品库存",width:"800"},{footer:a(()=>[F("div",Ce,[l(y,{onClick:t[5]||(t[5]=o=>I.value=!1)},{default:a(()=>[h("取消")]),_:1}),l(y,{type:"primary",onClick:G},{default:a(()=>[h(" 确定 ")]),_:1})])]),default:a(()=>[v.value.attrValue?(f(),A(b,{key:0,data:v.value.attrValue,stripe:"",style:{width:"100%"}},{default:a(()=>[l(s,{prop:"image",label:"图片",width:"180"},{default:a(o=>[l(w,{loading:"lazy",style:{width:"5rem",height:"5rem"},src:o.row.image||v.value.image},null,8,["src"])]),_:1}),l(s,{prop:"sku",label:"名称",width:"180"},{default:a(o=>[F("span",null,W(o.row.sku||v.value.store_name),1)]),_:1}),l(s,{prop:"price",label:"价格"}),l(s,{prop:"stock",label:"库存"},{default:a(o=>[l(Y,{modelValue:o.row.stock,"onUpdate:modelValue":x=>o.row.stock=x,"step-strictly":"",min:0,step:1},null,8,["modelValue","onUpdate:modelValue"])]),_:1})]),_:1},8,["data"])):N("",!0)]),_:1},8,["modelValue"]),l(we,{ref_key:"addRef",ref:$,onReload:_},null,512)])),[[ee,q.value]])}}},$e=H(xe,[["__scopeId","data-v-61825ba5"]]);export{$e as default};