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

2 lines
11 KiB
JavaScript
Raw Normal View History

2024-04-11 17:21:51 +08:00
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.