var e=(e,a,l)=>new Promise((t,i)=>{var r=e=>{try{s(l.next(e))}catch(a){i(a)}},o=e=>{try{s(l.throw(e))}catch(a){i(a)}},s=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,o);s((l=l.apply(e,a)).next())});import{d as a,a as l,r as t,w as i,o as r,y as o,f as s,z as d,p as u,u as n,e as m,F as p,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               *//* empty css              *//* empty css                     */import{i as y}from"./itemCards-C_dE3q5e.js";import{E as f,a as b}from"./index-CxGOZAw2.js";import{E as j,a as g}from"./index-Br3btmwp.js";import{E as h}from"./index-HtXsSizM.js";import{E as _}from"./index-opP5No9I.js";import{E as x}from"./index-BpP4itD-.js";const q=a({__name:"add-item-card-dialog",props:{visible:{type:Boolean}},emits:["update:visible","submit"],setup(a,{emit:q}){const I=a,V=q,w=l(),k=l(!1),E=l([]),C=t({cardId:null,quantity:1});i(()=>I.visible,e=>{});const U={cardId:[{required:!0,message:"请选择道具卡",trigger:"change"}],quantity:[{required:!0,message:"请输入数量",trigger:"change"}]},$=()=>e(this,null,function*(){var e;try{yield null==(e=w.value)?void 0:e.validate(),k.value=!0,V("submit",{card_id:C.cardId,quantity:C.quantity})}catch(a){}finally{k.value=!1}}),z=()=>{V("update:visible",!1)},A=()=>{var e;C.cardId=null,C.quantity=1,null==(e=w.value)||e.clearValidate()};return r(()=>e(this,null,function*(){try{const e=yield y.getList({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)=>(s(),o(n(x),{"model-value":a.visible,title:"分配道具卡",width:"420px","close-on-click-modal":!1,"onUpdate:modelValue":l[2]||(l[2]=e=>V("update:visible",e)),onClosed:A},{footer:d(()=>[u(n(_),{onClick:z},{default:d(()=>[...l[3]||(l[3]=[v("取消",-1)])]),_:1}),u(n(_),{type:"primary",loading:k.value,onClick:$},{default:d(()=>[...l[4]||(l[4]=[v("确定",-1)])]),_:1},8,["loading"])]),default:d(()=>[u(n(f),{ref_key:"formRef",ref:w,model:C,rules:U,"label-width":"80px"},{default:d(()=>[u(n(b),{label:"道具卡",prop:"cardId"},{default:d(()=>[u(n(j),{modelValue:C.cardId,"onUpdate:modelValue":l[0]||(l[0]=e=>C.cardId=e),placeholder:"请选择道具卡",filterable:"",style:{width:"100%"}},{default:d(()=>[(s(!0),m(p,null,c(E.value,e=>(s(),o(n(g),{key:e.id,label:`${e.name}（ID: ${e.id}）`,value:e.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),u(n(b),{label:"数量",prop:"quantity"},{default:d(()=>[u(n(h),{modelValue:C.quantity,"onUpdate:modelValue":l[1]||(l[1]=e=>C.quantity=e),min:1,max:100},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["model-value"]))}});export{q as _};
