import{_ as H,r as p,u as Q,b as d,c as m,d as L,w as a,h as S,t as W,e as j,f as l,l as K,D as M,g as k,E as g,j as te,q as le,k as ae,F as oe,i as ne,s as z}from"./index-3-t8Fk7s.js";import{p as re,c as ue,b as de,d as ie,e as se,s as ce,u as pe,f as _e}from"./shop-C3GBYBKO.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=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(),D=A,_=p(!1),R=p(""),P=t=>{R.value=t.url,_.value=!0},N=p("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=>{var f;e.data.image=[{url:e.data.image,uid:e.data.image}],(f=e.data.content)!=null&&f.image?e.data.content.image=e.data.content.image.map(s=>({url:s,uid:e.data.image})):e.data.content={image:[]},e.data.slider_image=e.data.slider_image.map(s=>({url:s,uid:e.data.image})),n.value=e.data,console.log(n.value)})},B=p([]);(()=>{ue(U.userInfo.service.mer_id).then(t=>{B.value=t.data})})();const E=p(null),O=()=>{var e,f,s,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 c,w,V,b;return(w=(c=r==null?void 0:r.response)==null?void 0:c.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=(s=(f=(e=t.image[0])==null?void 0:e.response)==null?void 0:f.data)!=null&&s.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 c,w,V,b;return(w=(c=r==null?void 0:r.response)==null?void 0:c.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",!0),$()}):ie(U.userInfo.service.mer_id,t.product_id,t).then(r=>{g.success(r.message),D("reload",!0),$()})},J=()=>{$()},$=()=>{i.value=!1},F=()=>{};return T({drawer:i,show:I}),(t,e)=>{const f=d("el-input"),s=d("el-form-item"),y=d("el-cascader"),h=d("Plus"),C=d("el-icon"),r=d("el-upload"),c=d("el-form"),w=d("el-dialog"),V=d("el-button"),b=d("el-drawer");return m(),L(b,{size:"60rem",modelValue:i.value,"onUpdate:modelValue":e[10]||(e[10]=u=>i.value=u),direction:"rtl",onOpen:F,"before-close":$},{header:a(()=>[N.value=="add"?(m(),S("h4",me,"添加商品")):(m(),S("h4",fe,"编辑商品 ["+W(n.value.product_id)+"]",1))]),default:a(()=>[j("div",ve,[l(c,{ref_key:"formRef",ref:E,model:n.value,"label-width":"150px"},{default:a(()=>[l(s,{label:"商品条码",required:""},{default:a(()=>[l(f,{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(s,{label:"商品名称",required:""},{default:a(()=>[l(f,{modelValue:n.value.store_name,"onUpdate:modelValue":e[1]||(e[1]=u=>n.value.store_name=u),placeholder:"请输入商品名称"},null,8,["modelValue"])]),_:1}),l(s,{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(s,{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(s,{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(s,{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(s,{label:"商品单位",required:""},{default:a(()=>[l(f,{modelValue:n.value.unit_name,"onUpdate:modelValue":e[6]||(e[6]=u=>n.value.unit_name=u),placeholder:"请输入商品单位"},null,8,["modelValue"])]),_:1}),l(s,{label:"零售价",required:""},{default:a(()=>[l(f,{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(s,{label:"库存",required:""},{default:a(()=>[l(f,{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(()=>[j("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:O},{default:a(()=>[k("确认")]),_:1})]),_:1},8,["modelValue"])}}},we=H(ye,[["__scopeId","data-v-4a30c70d"]]),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=p([]),A=Q(),i=p({page:1,limit:15,type:1,keyword:"",staff_id:A.userInfo.service.service_id}),q=p(!1),n=p(0),U=p([]),D=()=>{se(A.userInfo.service.mer_id).then(t=>{U.value=t.data})};D();const _=(t=!1)=>{q.value=!0,D(),ce(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=p(!1),v=p({}),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};pe(v.value.product_id,t).then(e=>{g({message:e.message,type:"success"}),I.value=!1,_()}).catch(e=>{g({message:e,type:"error"})})},E=p("1"),O=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)})},$=p(null),F=(t="add",e)=>{$.value.show(t,e)};return(t,e)=>{const f=d("el-input"),s=d("el-form-item"),y=d("el-button"),h=d("el-form"),C=d("el-menu-item"),r=d("el-menu"),c=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((m(),S("div",Ve,[l(h,{inline:!0},{default:a(()=>[l(s,{label:"关键字:"},{default:a(()=>[l(f,{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(s,null,{default:a(()=>[l(y,{type:"primary",onClick:e[3]||(e[3]=o=>_(!0))},{default:a(()=>[k("搜索")]),_:1})]),_:1}),l(s,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":E.value,class:"el-menu-top",mode:"horizontal",onSelect:O},{default:a(()=>[(m(!0),S(oe,null,ne(U.value,(o,x)=>(m(),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(c,{prop:"product_id",label:"ID",width:"100"}),l(c,{prop:"image",label:"图片",width:"120"},{default:a(o=>[l(w,{loading:"lazy",style:{width:"3.75rem",height:"3.75rem"},src:o.row.image},null,8,["src"])]),_:1}),l(c,{prop:"store_name",label:"商品名称",width:"500"}),l(c,{prop:"price",label:"售价"}),l(c,{prop:"stock",label:"库存"}),i.value.type<=2?(m(),L(c,{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?(m(),L(c,{key:1,label:"商品状态",width:"100"},{default:a(o=>[o.row.is_used?o.row.is_show?(m(),S("span",ke,"上架显示")):(m(),S("span",he,"下架")):(m(),S("span",be,"平台关闭"))]),_:1})):z("",!0),l(c,{label:"操作",width:"120"},{default:a(o=>[i.value.type!=5?(m(),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?(m(),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(()=>[j("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?(m(),L(b,{key:0,data:v.value.attrValue,stripe:"",style:{width:"100%"}},{default:a(()=>[l(c,{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(c,{prop:"sku",label:"名称",width:"180"},{default:a(o=>[j("span",null,W(o.row.sku||v.value.store_name),1)]),_:1}),l(c,{prop:"price",label:"价格"}),l(c,{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:_},null,512)])),[[ee,q.value]])}}},$e=H(xe,[["__scopeId","data-v-22d63487"]]);export{$e as default};