var e=(e,a,l)=>new Promise((o,t)=>{var i=e=>{try{r(l.next(e))}catch(a){t(a)}},s=e=>{try{r(l.throw(e))}catch(a){t(a)}},r=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,s);r((l=l.apply(e,a)).next())});import{d as a,a as l,r as o,w as t,o as i,y as s,f as r,z as d,p as u,u as n,e as p,F as m,G as c,l as v}from"./index-ip5gDR6L.js";/* empty css               *//* empty css                *//* empty css                  *//* empty css            *//* empty css               *//* empty css                  *//* empty css               *//* empty css               */import{c as f}from"./coupons-DhPZnSZd.js";import{E as y,a as b}from"./index-CxGOZAw2.js";import{E as j,a as h}from"./index-Br3btmwp.js";import{E as g}from"./index-opP5No9I.js";import{E as _}from"./index-BpP4itD-.js";const x=a({__name:"add-coupon-dialog",props:{visible:{type:Boolean}},emits:["update:visible","submit"],setup(a,{emit:x}){const I=a,w=x,k=l(),V=l(!1),E=l([]),C=o({couponId:null});t(()=>I.visible,e=>{});const $={couponId:[{required:!0,message:"请选择优惠券",trigger:"change"}]},z=()=>e(this,null,function*(){var e;try{yield null==(e=k.value)?void 0:e.validate(),V.value=!0,w("submit",{coupon_id:C.couponId})}catch(a){}finally{V.value=!1}}),A=()=>{w("update:visible",!1)},M=()=>{var e;C.couponId=null,null==(e=k.value)||e.clearValidate()};return i(()=>e(this,null,function*(){try{const e=yield f.getList({status:1,page:1,page_size:100});E.value=Array.isArray(e.list)?e.list.map(e=>({id:e.id,name:e.name})):[]}catch(e){E.value=[]}})),(e,l)=>(r(),s(n(_),{"model-value":a.visible,title:"发放优惠券",width:"400px","close-on-click-modal":!1,"onUpdate:modelValue":l[1]||(l[1]=e=>w("update:visible",e)),onClosed:M},{footer:d(()=>[u(n(g),{onClick:A},{default:d(()=>[...l[2]||(l[2]=[v("取消",-1)])]),_:1}),u(n(g),{type:"primary",loading:V.value,onClick:z},{default:d(()=>[...l[3]||(l[3]=[v(" 确定 ",-1)])]),_:1},8,["loading"])]),default:d(()=>[u(n(y),{ref_key:"formRef",ref:k,model:C,rules:$,"label-width":"80px"},{default:d(()=>[u(n(b),{label:"优惠券",prop:"couponId"},{default:d(()=>[u(n(j),{modelValue:C.couponId,"onUpdate:modelValue":l[0]||(l[0]=e=>C.couponId=e),placeholder:"请选择优惠券",filterable:"",style:{width:"100%"}},{default:d(()=>[(r(!0),p(m,null,c(E.value,e=>(r(),s(n(h),{key:e.id,label:`${e.name}（ID: ${e.id}）`,value:e.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["model-value"]))}});export{x as _};
