2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
|
import{_ as H,r as c,u as Q,b as i,c as f,d as L,w as a,h as S,t as W,e as E,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 z}from"./index-EgCJN650.js";import{p as re,c as ue,a as ie,b as de,d as se,s as pe,u as ce,e as _e}from"./shop-BLA2ONJP.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 d=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"?d.value=!0:t=="edit"&&(d.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,k,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=(k=(y=t.image[0])==null?void 0:y.response)==null?void 0:k.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"?ie(U.userInfo.service.mer_id,t).then(r=>{g.success(r.message),D("reload",!0),$()}):de(U.userInfo.service.mer_id,t.product_id,t).then(r=>{g.success(r.message),D("reload",!0),$()})},J=()=>{$()},$=()=>{d.value=!1},F=()=>{};return T({drawer:d,show:I}),(t,e)=>{const m=i("el-input"),p=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(),L(b,{size:800,modelValue:d.value,"onUpdate:modelValue":e[10]||(e[10]=u=>d.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]
|