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