import{a1 as J,I as M,k as c,C as G,D as K,c as W,F as H,G as Q,w as X,g as Y}from"./element-plus.619595c4.js";import{r as _,d as Z,a as ee,e as E}from"./index.adbcc6f1.js";import{r as V,af as ae,o as x,K as te,L as r,c as P,S as le,a as B,U as t,u as q,R as N}from"./@vue.18505fe0.js";function Ve(d,n){return _.get(`server/${d}/product/lst`,{params:n})}function be(d,n){return _.post(`user_free_trial/${d}`,n)}function ye(d,n){return _.get(`server/${d}/product/title`,{params:n})}function we(d,n,m){return _.post(`server/${d}/product/status/${n}`,m)}function oe(d,n){return _.get(`server/${d}/category/list`,{params:n})}function re(d,n){return _.post(`server/${d}/product/create`,n)}function ue(d,n,m){return _.post(`server/${d}/product/update/${n}`,m)}function ne(d,n,m){return _.get(`server/${d}/product/detail/${n}`,{params:m})}const de={key:0},se={key:1},ie={class:"dra-body"},ce=["src"],pe={__name:"add",emits:["reload"],setup(d,{expose:n,emit:m}){const b=V(!1),L={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"]},l=V(L),U=ee(),S=m,C=V(!1),A=V(""),I=e=>{A.value=e.url,C.value=!0},$=V("add"),O=(e,a)=>{l.value=L,$.value=e,e=="add"?b.value=!0:e=="edit"&&(b.value=!0,T(a.product_id))},T=e=>{ne(U.userInfo.service.mer_id,e).then(a=>{a.data.image=[{url:a.data.image,uid:a.data.image}],a.data.content.image=a.data.content.image.map(s=>({url:s,uid:a.data.image})),a.data.slider_image=a.data.slider_image.map(s=>({url:s,uid:a.data.image})),l.value=a.data,console.log(l.value)})},D=V([]);(()=>{oe(U.userInfo.service.mer_id).then(e=>{D.value=e.data})})();const F=V(null),j=()=>{var a,s,i,k,y,w;let e=JSON.parse(JSON.stringify(l.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 c.error("\u8BF7\u4E0A\u4F20\u5546\u54C1\u5C01\u9762\u56FE");if(e.slider_image.length==0)return c.error("\u8BF7\u4E0A\u4F20\u5546\u54C1\u8F6E\u64AD\u56FE");if(e.content.image=e.content.image.map(o=>{var f,g,p,v;return(g=(f=o==null?void 0:o.response)==null?void 0:f.data)!=null&&g.path?(v=(p=o==null?void 0:o.response)==null?void 0:p.data)==null?void 0:v.path:o.url}),e.image=(i=(s=(a=e.image[0])==null?void 0:a.response)==null?void 0:s.data)!=null&&i.path?(w=(y=(k=e.image[0])==null?void 0:k.response)==null?void 0:y.data)==null?void 0:w.path:e.image[0].url,e.slider_image=e.slider_image.map(o=>{var f,g,p,v;return(g=(f=o==null?void 0:o.response)==null?void 0:f.data)!=null&&g.path?(v=(p=o==null?void 0:o.response)==null?void 0:p.data)==null?void 0:v.path:o.url}),e.store_name=="")return c.error("\u8BF7\u8F93\u5165\u5546\u54C1\u540D\u79F0");if(e.cate_id=="")return c.error("\u8BF7\u9009\u62E9\u5E73\u53F0\u5206\u7C7B");if(e.attrValue[0].bar_code=="")return c.error("\u8BF7\u8F93\u5165\u5546\u54C1\u6761\u7801");if(e.attrValue[0].stock<=0)return c.error("\u8BF7\u8F93\u5165\u5546\u54C1\u5E93\u5B58");if(e.attrValue[0].price<=0)return c.error("\u8BF7\u8F93\u5165\u5546\u54C1\u4EF7\u683C");$.value=="add"?re(U.userInfo.service.mer_id,e).then(o=>{c.success(o.message),S("reload"),h()}):ue(U.userInfo.service.mer_id,e.product_id,e).then(o=>{c.success(o.message),S("reload"),h()})},R=()=>{h()},h=()=>{b.value=!1},z=()=>{};return n({drawer:b,show:O}),(e,a)=>{const s=G,i=K,k=J,y=ae("Plus"),w=W,o=M,f=H,g=Q,p=X,v=Y;return x(),te(v,{size:800,modelValue:b.value,"onUpdate:modelValue":a[10]||(a[10]=u=>b.value=u),direction:"rtl",onOpen:z,"before-close":h},{header:r(()=>[$.value=="add"?(x(),P("h4",de,"\u6DFB\u52A0\u5546\u54C1")):(x(),P("h4",se,"\u7F16\u8F91\u5546\u54C1 ["+le(l.value.product_id)+"]",1))]),default:r(()=>[B("div",ie,[t(f,{ref_key:"formRef",ref:F,model:l.value,"label-width":"150px"},{default:r(()=>[t(i,{label:"\u5546\u54C1\u6761\u7801",required:""},{default:r(()=>[t(s,{modelValue:l.value.attrValue[0].bar_code,"onUpdate:modelValue":a[0]||(a[0]=u=>l.value.attrValue[0].bar_code=u),type:"number",placeholder:"\u8BF7\u8F93\u5165\u5546\u54C1\u6761\u7801"},null,8,["modelValue"])]),_:1}),t(i,{label:"\u5546\u54C1\u540D\u79F0",required:""},{default:r(()=>[t(s,{modelValue:l.value.store_name,"onUpdate:modelValue":a[1]||(a[1]=u=>l.value.store_name=u),placeholder:"\u8BF7\u8F93\u5165\u5546\u54C1\u540D\u79F0"},null,8,["modelValue"])]),_:1}),t(i,{label:"\u5E73\u53F0\u5206\u7C7B",required:""},{default:r(()=>[t(k,{modelValue:l.value.cate_id,"onUpdate:modelValue":a[2]||(a[2]=u=>l.value.cate_id=u),class:"pageWidth",options:D.value,filterable:"",clearable:""},null,8,["modelValue","options"])]),_:1}),t(i,{label:"\u5546\u54C1\u5C01\u9762\u56FE",required:""},{default:r(()=>[t(o,{"file-list":l.value.image,"onUpdate:fileList":a[3]||(a[3]=u=>l.value.image=u),action:q(E).upload,name:"field","list-type":"picture-card","on-preview":I,limit:1},{default:r(()=>[t(w,null,{default:r(()=>[t(y)]),_:1})]),_:1},8,["file-list","action"])]),_:1}),t(i,{label:"\u5546\u54C1\u8F6E\u64AD\u56FE",required:""},{default:r(()=>[t(o,{"file-list":l.value.slider_image,"onUpdate:fileList":a[4]||(a[4]=u=>l.value.slider_image=u),action:q(E).upload,name:"field","list-type":"picture-card","on-preview":I,limit:9},{default:r(()=>[t(w,null,{default:r(()=>[t(y)]),_:1})]),_:1},8,["file-list","action"])]),_:1}),t(i,{label:"\u5546\u54C1\u8BE6\u60C5"},{default:r(()=>[t(o,{"file-list":l.value.content.image,"onUpdate:fileList":a[5]||(a[5]=u=>l.value.content.image=u),action:q(E).upload,name:"field","list-type":"picture-card","on-preview":I,limit:9},{default:r(()=>[t(w,null,{default:r(()=>[t(y)]),_:1})]),_:1},8,["file-list","action"])]),_:1}),t(i,{label:"\u5546\u54C1\u5355\u4F4D",required:""},{default:r(()=>[t(s,{modelValue:l.value.unit_name,"onUpdate:modelValue":a[6]||(a[6]=u=>l.value.unit_name=u),placeholder:"\u8BF7\u8F93\u5165\u5546\u54C1\u5355\u4F4D"},null,8,["modelValue"])]),_:1}),t(i,{label:"\u96F6\u552E\u4EF7",required:""},{default:r(()=>[t(s,{modelValue:l.value.attrValue[0].price,"onUpdate:modelValue":a[7]||(a[7]=u=>l.value.attrValue[0].price=u),type:"number",placeholder:"\u8BF7\u8F93\u5165\u96F6\u552E\u4EF7"},null,8,["modelValue"])]),_:1}),t(i,{label:"\u5E93\u5B58",required:""},{default:r(()=>[t(s,{modelValue:l.value.attrValue[0].stock,"onUpdate:modelValue":a[8]||(a[8]=u=>l.value.attrValue[0].stock=u),type:"number",placeholder:"\u8BF7\u8F93\u5165\u5E93\u5B58"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),t(g,{modelValue:C.value,"onUpdate:modelValue":a[9]||(a[9]=u=>C.value=u)},{default:r(()=>[B("img",{style:{width:"100%",height:"100%"},"w-full":"",src:A.value,alt:"Preview Image"},null,8,ce)]),_:1},8,["modelValue"])]),footer:r(()=>[t(p,{onClick:R},{default:r(()=>[N("\u53D6\u6D88")]),_:1}),t(p,{type:"primary",onClick:j},{default:r(()=>[N("\u786E\u8BA4")]),_:1})]),_:1},8,["modelValue"])}}},_e=Z(pe,[["__scopeId","data-v-a425ddcc"]]),Ue=Object.freeze(Object.defineProperty({__proto__:null,default:_e},Symbol.toStringTag,{value:"Module"}));export{_e as a,we as b,Ue as c,ye as p,Ve as s,be as u};