cashier-ERP/dist/assets/index-CfHPJYYr.js

2 lines
11 KiB
JavaScript
Raw Normal View History

2024-04-12 10:43:47 +08:00
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.