import{aA as g,d as pe,b as me,P as ce,r as v,x as U,av as fe,o as i,C as c,A as l,f as t,a,D as n,k as ve,c as P,F as D,R as E,E as T,a3 as I,B,a2 as ye,n as _e,a9 as he,V as Ve,I as be,at as ge,au as Te,J as we,H as xe,ap as ke,cf as Se,K as Ue,S as Pe,U as De,W as Ee,Z as Ie,_ as Ae,__tla as Ce}from"./index-286756b9.js";import{_ as Oe,__tla as Re}from"./Dialog-4c2de357.js";import{h as qe,__tla as Fe}from"./spu-c6e01563.js";import{a as Y,D as H,__tla as ze}from"./dict-82dca549.js";import{i as J,h as A}from"./constants-637baed6.js";import{u as Le,__tla as Me}from"./useMessage-084b1e70.js";let C,Z,K,W,Ne=Promise.all([(()=>{try{return Ce}catch{}})(),(()=>{try{return Re}catch{}})(),(()=>{try{return Fe}catch{}})(),(()=>{try{return ze}catch{}})(),(()=>{try{return Me}catch{}})()]).then(async()=>{let O,R;W=async w=>await g.get({url:"/promotion/reward-activity/page",params:w}),K=async w=>await g.delete({url:"/promotion/reward-activity/delete?id="+w}),O={style:{float:"left"}},R={style:{float:"right","font-size":"13px",color:"#8492a6"}},C=Ae(pe({name:"ProductBrandForm",__name:"RewardForm",emits:["success"],setup(w,{expose:$,emit:G}){me(()=>{qe().then(u=>{F.value=u})});const{t:V}=ce(),q=Le(),F=v([]),y=v(!1),z=v(""),_=v(!1),L=v(""),d=v({id:void 0,name:void 0,startAndEndTime:void 0,startTime:void 0,endTime:void 0,conditionType:J.PRICE.type,remark:void 0,productScope:A.ALL.scope,productSpuIds:void 0,rules:[{limit:void 0,discountPrice:void 0,freeDelivery:void 0,point:void 0,couponIds:[],couponCounts:[]}]}),s=U([]),Q=U({name:[{required:!0,message:"\u6D3B\u52A8\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],startAndEndTime:[{required:!0,message:"\u6D3B\u52A8\u65F6\u95F4\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],conditionType:[{required:!0,message:"\u6761\u4EF6\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A",trigger:"change"}],productScope:[{required:!0,message:"\u5546\u54C1\u8303\u56F4\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],productSpuIds:[{required:!0,message:"\u5546\u54C1\u8303\u56F4\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),x=v([]);$({open:async(u,o)=>{if(y.value=!0,z.value=V("action."+u),L.value=u,ae(),o){_.value=!0;try{let p=await(async r=>await g.get({url:"/promotion/reward-activity/get?id="+r}))(o);p.startAndEndTime=[new Date(p.startTime),new Date(p.endTime)],s.splice(0,s.length),p.rules.forEach(r=>{let h=U([]);r.freeDelivery&&h.push("\u5305\u90AE"),r.point&&h.push("\u9001\u79EF\u5206"),r.discountPrice&&h.push("\u8BA2\u5355\u91D1\u989D\u4F18\u60E0"),s.push(h)}),d.value=p}finally{_.value=!1}}}});const X=G,ee=async()=>{if(x&&await x.value.validate()){d.value.startTime=+new Date(d.value.startAndEndTime[0]),d.value.endTime=+new Date(d.value.startAndEndTime[1]),s.forEach((u,o)=>{d.value.rules[o].freeDelivery=!!u.includes("\u5305\u90AE"),u.includes("\u9001\u79EF\u5206")||(d.value.rules[o].point=void 0),u.includes("\u8BA2\u5355\u91D1\u989D\u4F18\u60E0")||(d.value.rules[o].discountPrice=void 0)}),_.value=!0;try{const u=d.value;L.value==="create"?(await(async o=>await g.post({url:"/promotion/reward-activity/create",data:o}))(u),q.success(V("common.createSuccess"))):(await(async o=>await g.put({url:"/promotion/reward-activity/update",data:o}))(u),q.success(V("common.updateSuccess"))),y.value=!1,X("success")}finally{_.value=!1}}},le=()=>{d.value.rules.push({limit:void 0,discountPrice:void 0,freeDelivery:void 0,point:void 0,couponIds:[],couponCounts:[]}),s.push([])},ae=()=>{d.value={id:void 0,name:void 0,startAndEndTime:void 0,startTime:void 0,endTime:void 0,conditionType:J.PRICE.type,remark:void 0,productScope:A.ALL.scope,productSpuIds:void 0,rules:[{limit:void 0,discountPrice:void 0,freeDelivery:void 0,point:void 0,couponIds:[],couponCounts:[]}]},s.splice(0,s.length),s.push(U([])),_e(()=>{var u;(u=x.value)==null||u.resetFields()})};return(u,o)=>{const p=he,r=Ve,h=be,M=ge,N=Te,k=we,b=xe,S=ke,te=Se,de=fe("e-form"),oe=Ue,re=Pe,ue=De,ie=Ee,se=Oe,ne=Ie;return i(),c(se,{title:a(z),modelValue:a(y),"onUpdate:modelValue":o[7]||(o[7]=e=>ye(y)?y.value=e:null)},{footer:l(()=>[t(k,{onClick:ee,type:"primary",disabled:a(_)},{default:l(()=>[n("\u786E \u5B9A")]),_:1},8,["disabled"]),t(k,{onClick:o[6]||(o[6]=e=>y.value=!1)},{default:l(()=>[n("\u53D6 \u6D88")]),_:1})]),default:l(()=>[ve((i(),c(ie,{ref_key:"formRef",ref:x,model:a(d),rules:a(Q),"label-width":"80px"},{default:l(()=>[t(r,{label:"\u6D3B\u52A8\u540D\u79F0",prop:"name"},{default:l(()=>[t(p,{modelValue:a(d).name,"onUpdate:modelValue":o[0]||(o[0]=e=>a(d).name=e),placeholder:"\u8BF7\u8F93\u5165\u6D3B\u52A8\u540D\u79F0"},null,8,["modelValue"])]),_:1}),t(r,{label:"\u6D3B\u52A8\u65F6\u95F4",prop:"startAndEndTime"},{default:l(()=>[t(h,{modelValue:a(d).startAndEndTime,"onUpdate:modelValue":o[1]||(o[1]=e=>a(d).startAndEndTime=e),type:"datetimerange","range-separator":"-","start-placeholder":a(V)("common.startTimeText"),"end-placeholder":a(V)("common.endTimeText")},null,8,["modelValue","start-placeholder","end-placeholder"])]),_:1}),t(r,{label:"\u6761\u4EF6\u7C7B\u578B",prop:"conditionType"},{default:l(()=>[t(N,{modelValue:a(d).conditionType,"onUpdate:modelValue":o[2]||(o[2]=e=>a(d).conditionType=e)},{default:l(()=>[(i(!0),P(D,null,E(a(Y)(a(H).PROMOTION_CONDITION_TYPE),e=>(i(),c(M,{key:e.value,label:e.value},{default:l(()=>[n(T(e.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(r,{label:"\u4F18\u60E0\u8BBE\u7F6E"},{default:l(()=>[(i(!0),P(D,null,E(a(d).rules,(e,f)=>(i(),c(oe,{key:f,type:"flex"},{default:l(()=>[t(b,{span:24,style:{"font-weight":"bold",display:"flex"}},{default:l(()=>[n(" \u6D3B\u52A8\u5C42\u7EA7"+T(f+1)+" ",1),f!=0?(i(),c(k,{key:0,link:"",type:"danger",style:{"margin-left":"auto"},onClick:m=>(j=>{d.value.rules.splice(j,1),s.splice(j,1)})(f)},{default:l(()=>[n(" \u5220\u9664 ")]),_:2},1032,["onClick"])):I("",!0)]),_:2},1024),t(de,{ref_for:!0,ref:"formRef"+f,model:e},{default:l(()=>[t(r,{label:"\u4F18\u60E0\u95E8\u69DB:",prop:"limit","label-width":"100px",style:{"padding-left":"50px"}},{default:l(()=>[n(" \u6EE1 "),t(p,{style:{width:"150px",padding:"0 10px"},modelValue:e.limit,"onUpdate:modelValue":m=>e.limit=m,type:"number",placeholder:""},null,8,["modelValue","onUpdate:modelValue"]),n(" \u5143 ")]),_:2},1024),t(r,{label:"\u4F18\u60E0\u5185\u5BB9:","label-width":"100px",style:{"padding-left":"50px"}},{default:l(()=>[t(te,{modelValue:a(s)[f],"onUpdate:modelValue":m=>a(s)[f]=m,style:{width:"100%"}},{default:l(()=>[t(b,{span:24},{default:l(()=>[t(S,{label:"\u8BA2\u5355\u91D1\u989D\u4F18\u60E0",name:"type"}),a(s)[f].includes("\u8BA2\u5355\u91D1\u989D\u4F18\u60E0")?(i(),c(r,{key:0},{default:l(()=>[n(" \u51CF "),t(p,{style:{width:"150px",padding:"0 20px"},modelValue:e.discountPrice,"onUpdate:modelValue":m=>e.discountPrice=m,type:"number",placeholder:""},null,8,["modelValue","onUpdate:modelValue"]),n(" \u5143 ")]),_:2},1024)):I("",!0)]),_:2},1024),t(b,{span:24},{default:l(()=>[t(S,{modelValue:e.freeDelivery,"onUpdate:modelValue":m=>e.freeDelivery=m,label:"\u5305\u90AE",name:"type"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),t(b,{span:24},{default:l(()=>[t(S,{label:"\u9001\u79EF\u5206",name:"type"}),a(s)[f].includes("\u9001\u79EF\u5206")?(i(),c(r,{key:0},{default:l(()=>[n(" \u9001 "),t(p,{style:{width:"150px",padding:"0 20px"},modelValue:e.point,"onUpdate:modelValue":m=>e.point=m,type:"number",placeholder:""},null,8,["modelValue","onUpdate:modelValue"]),n(" \u79EF\u5206 ")]),_:2},1024)):I("",!0)]),_:2},1024),t(b,{span:24},{default:l(()=>[t(S,{label:"\u9001\u4F18\u60E0\u5238",name:"type"})]),_:1})]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1032,["model"])]),_:2},1024))),128)),t(k,{type:"primary",onClick:le},{default:l(()=>[n("\u6DFB\u52A0\u6D3B\u52A8\u5C42\u7EA7")]),_:1})]),_:1}),t(r,{label:"\u6D3B\u52A8\u5546\u54C1",prop:"productScope"},{default:l(()=>[t(N,{modelValue:a(d).productScope,"onUpdate:modelValue":o[3]||(o[3]=e=>a(d).productScope=e)},{default:l(()=>[(i(!0),P(D,null,E(a(Y)(a(H).PROMOTION_PRODUCT_SCOPE),e=>(i(),c(M,{key:e.value,label:e.value},{default:l(()=>[n(T(e.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(d).productScope===a(A).SPU.scope?(i(),c(r,{key:0,prop:"productSpuIds"},{default:l(()=>[t(ue,{modelValue:a(d).productSpuIds,"onUpdate:modelValue":o[4]||(o[4]=e=>a(d).productSpuIds=e),placeholder:"\u8BF7\u9009\u62E9\u6D3B\u52A8\u5546\u54C1",clearable:"",size:"small",multiple:"",filterable:"",style:{width:"400px"}},{default:l(()=>[(i(!0),P(D,null,E(a(F),e=>(i(),c(re,{key:e.id,label:e.name,value:e.id},{default:l(()=>[B("span",O,T(e.name),1),B("span",R," \uFFE5"+T((e.price/100).toFixed(2)),1)]),_:2},1032,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})):I("",!0),t(r,{label:"\u5907\u6CE8",prop:"remark"},{default:l(()=>[t(p,{modelValue:a(d).remark,"onUpdate:modelValue":o[5]||(o[5]=e=>a(d).remark=e),placeholder:"\u8BF7\u8F93\u5165\u5907\u6CE8"},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])),[[ne,a(_)]])]),_:1},8,["title","modelValue"])}}}),[["__file","D:/zx/mall-newfeifan-zx-admin/src/views/mall/promotion/rewardActivity/RewardForm.vue"]]),Z=Object.freeze(Object.defineProperty({__proto__:null,default:C},Symbol.toStringTag,{value:"Module"}))});export{C as R,Ne as __tla,Z as a,K as d,W as g};