import{e as S,a8 as F,r as m,w as I,o as B,a2 as M,P as T,a3 as D,a4 as l,f as a,I as c,H as _}from"./vue-bf422dc1.js";import{l as L}from"./category-7ca503b8.js";import{a as N}from"./coupon-4cf5fc97.js";import{d as P,_ as $}from"./index-c2dd6a24.js";import{i as G,a as H}from"./constant-b61c1b97.js";import{M as v,l as j,B as A,d as E,F as O,h as z,R as J,S as K,D as Q,g as W,e as X,b as Y}from"./ui-ba7aaa7e.js";import"./libs-51817cd7.js";import"./plugins-ca970193.js";import"./others-9f318174.js";import"./echarts-bf9d612c.js";import"./icons-a8498fb6.js";import"./date-20546ee0.js";const Z={name:"GoodsCouponAdd"},ee=S({...Z,setup(ae){const r=F(),t=m({cate_id:"",type:1,amount:"",quantity:"",min_banlance:"",expire_at:"",remark:"",import_coupon:0}),s=m("满减优惠券，设置多少元则抵扣总价的多少元");I(()=>t.value.type,n=>{n===1?s.value=`
      满减优惠券，设置多少元则抵扣总价的多少元
      `:s.value=`
      折扣卡券，设置比例10%则是9折20%为8折，以此类推
      `});const p=m([]),b=async()=>{const{data:n}=await L();p.value=n.list,p.value.unshift({label:"店铺通用",value:""})},f=m(null),y={amount:[{required:!0,message:"请输入折扣面额",type:"error"}],quantity:[{required:!0,message:"请输入数量",type:"error"}],expire_at:[{required:!0,message:"请选择到期时间",type:"error"}]};B(()=>{b();const{query:n}=r.currentRoute.value;n.cate_id&&(t.value.cate_id=n.cate_id)});const V=async()=>{const n=await f.value.validate();if(typeof n!="object"&&n){const e=await N(t.value);e.code===1?(v.success("新增成功"),t.value.import_coupon&&P(e.data.url),setTimeout(()=>{r.push("/merchant/goods/coupon")},3e3)):v.error(`新增失败：${e.msg}`)}};return(n,e)=>{const x=j,d=A,h=E,u=O,i=z,g=J,k=K,w=Q,q=W,U=M("wp-check-tag"),C=X,R=Y;return T(),D(R,{title:"添加优惠券",class:"basic-container",bordered:!1},{actions:l(()=>[a(d,{variant:"text",theme:"default",onClick:e[0]||(e[0]=o=>c(r).push("/merchant/goods/coupon"))},{icon:l(()=>[a(x,{name:"rollback"})]),default:l(()=>[_(" 返回 ")]),_:1})]),default:l(()=>[a(C,{ref_key:"form",ref:f,class:"base-form",data:t.value,rules:y,"label-align":"left","label-width":160,onSubmit:V},{default:l(()=>[a(u,{label:"选择分类",name:"cate_id",help:"【必选】请选择商品分类"},{default:l(()=>[a(h,{modelValue:t.value.cate_id,"onUpdate:modelValue":e[1]||(e[1]=o=>t.value.cate_id=o),placeholder:"请选择商品分类",type:"search",clearable:"",options:p.value,style:{width:"415px"}},null,8,["modelValue","options"])]),_:1}),a(u,{label:"折扣面额",name:"amount",help:s.value},{default:l(()=>[a(k,null,{default:l(()=>[a(i,{modelValue:t.value.amount,"onUpdate:modelValue":e[2]||(e[2]=o=>t.value.amount=o),"decimal-places":0,theme:"normal",placeholder:"请输入数字",style:{width:"415px"}},null,8,["modelValue"]),a(g,{modelValue:t.value.type,"onUpdate:modelValue":e[3]||(e[3]=o=>t.value.type=o),options:c(G)},null,8,["modelValue","options"])]),_:1})]),_:1},8,["help"]),a(u,{label:"生成数量",name:"quantity",help:"最多一次生成200张"},{default:l(()=>[a(i,{modelValue:t.value.quantity,"onUpdate:modelValue":e[4]||(e[4]=o=>t.value.quantity=o),max:200,min:1,"decimal-places":0,theme:"normal"},null,8,["modelValue"])]),_:1}),a(u,{label:"最低使用金额",name:"min_banlance",help:"此功能为满减优惠卷"},{default:l(()=>[a(i,{modelValue:t.value.min_banlance,"onUpdate:modelValue":e[5]||(e[5]=o=>t.value.min_banlance=o),placeholder:"请输入数字","decimal-places":0,theme:"normal"},null,8,["modelValue"])]),_:1}),a(u,{label:"到期时间",name:"expire_at",help:"过期优惠券系统将自动清理"},{default:l(()=>[a(w,{modelValue:t.value.expire_at,"onUpdate:modelValue":e[6]||(e[6]=o=>t.value.expire_at=o),"enable-time-picker":"","allow-input":"",clearable:"",placeholder:"请选择到期时间"},null,8,["modelValue"])]),_:1}),a(u,{label:"备注信息",name:"remark"},{default:l(()=>[a(q,{modelValue:t.value.remark,"onUpdate:modelValue":e[7]||(e[7]=o=>t.value.remark=o),placeholder:"",style:{width:"415"}},null,8,["modelValue"])]),_:1}),a(u,{label:"导出格式",name:"import_coupon",help:"添加完导出优惠券"},{default:l(()=>[a(U,{modelValue:t.value.import_coupon,"onUpdate:modelValue":e[8]||(e[8]=o=>t.value.import_coupon=o),items:c(H)},null,8,["modelValue","items"])]),_:1}),a(u,null,{default:l(()=>[a(d,{theme:"primary",class:"form-submit-confirm",type:"submit"},{default:l(()=>[_(" 提交 ")]),_:1}),a(d,{type:"reset",class:"form-submit-cancel",theme:"default",variant:"base"},{default:l(()=>[_(" 重置 ")]),_:1})]),_:1})]),_:1},8,["data"])]),_:1})}}});const _e=$(ee,[["__scopeId","data-v-55c3932a"]]);export{_e as default};
