2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
|
import{Z as J,T as M,k as c,C as K,D as W,c as Z,F as G,I as H,w as Q,g as X}from"./element-plus.73c9e9a6.js";import{r as _,d as Y,a as ee,m as E}from"./index.bd5cd373.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 T,U as t,u as q,R as B}from"./@vue.663bc523.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"),N=(e,a)=>{l.value=L,$.value=e,e=="add"?b.value=!0:e=="edit"&&(b.value=!0,O(a.product_id))},O=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:N}),(e,a)=>{const s=K,i=W,k=J,y=ae("Plus"),w=Z,o=M,f=G,g=H,p=Q,v=X;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(()=>[T("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
|