import{N as d,d as R,v as $,r as H,a as B,G as F,g as n,z as S,k as j,w as r,e as l,I as q,t as x,E as y,_ as D}from"./index-CUnFTKV2.js";const p="/admin/business/welfarehouse";function z(a){return d({url:p,method:"get",params:a})}function L(a){return d({url:p,method:"post",data:a})}function O(a,m){return d({url:`${p}/${a}`,method:"put",data:m})}function A(a){return d({url:`${p}/${a}`,method:"delete"})}function T(a,m){return d({url:`${p}/${a}/status`,method:"put",data:m})}const I=R({__name:"WelfareHouseFormDialog",props:{modelValue:{type:Boolean},welfareHouse:{},isEdit:{type:Boolean}},emits:["update:modelValue","success"],setup(a,{emit:m}){const o=a,b=m,c=$({get:()=>o.modelValue,set:u=>b("update:modelValue",u)}),f=H(),g=H(!1),e=B({name:"",image:"",url:"",sort:0,status:1}),U={name:[{required:!0,message:"请输入名称",trigger:"blur"}],image:[{required:!0,message:"请输入图片URL",trigger:"blur"}],url:[{required:!0,message:"请输入跳转链接",trigger:"blur"}],sort:[{required:!0,message:"请输入排序值",trigger:"blur"}]};F(()=>o.modelValue,u=>{u&&(o.isEdit&&o.welfareHouse?Object.assign(e,{name:o.welfareHouse.name||"",image:o.welfareHouse.image||"",url:o.welfareHouse.url||"",sort:o.welfareHouse.sort||0,status:o.welfareHouse.status}):V())});const V=()=>{var u;Object.assign(e,{name:"",image:"",url:"",sort:0,status:1}),(u=f.value)==null||u.resetFields()},_=()=>{c.value=!1,V()},E=async()=>{if(f.value){try{await f.value.validate()}catch{return}g.value=!0;try{const u={name:e.name,image:e.image,url:e.url,sort:e.sort,status:e.status};o.isEdit&&o.welfareHouse?(await O(o.welfareHouse.id,{...u,status:e.status}),y.success("更新成功")):(await L(u),y.success("创建成功")),b("success"),_()}finally{g.value=!1}}};return(u,t)=>{const w=n("el-input"),i=n("el-form-item"),W=n("el-input-number"),h=n("el-switch"),k=n("el-form"),v=n("el-button"),C=n("el-dialog");return j(),S(C,{modelValue:c.value,"onUpdate:modelValue":t[5]||(t[5]=s=>c.value=s),title:a.isEdit?"编辑福利屋入口":"新增福利屋入口",width:"550px","close-on-click-modal":!1,onClose:_},{footer:r(()=>[l(v,{onClick:_},{default:r(()=>[...t[6]||(t[6]=[x("取消",-1)])]),_:1}),l(v,{type:"primary",loading:g.value,onClick:E},{default:r(()=>[...t[7]||(t[7]=[x(" 确定 ",-1)])]),_:1},8,["loading"])]),default:r(()=>[l(k,{ref_key:"formRef",ref:f,model:e,rules:U,"label-width":"90px"},{default:r(()=>[l(i,{label:"名称",prop:"name"},{default:r(()=>[l(w,{modelValue:e.name,"onUpdate:modelValue":t[0]||(t[0]=s=>e.name=s),placeholder:"请输入名称",maxlength:"50"},null,8,["modelValue"])]),_:1}),l(i,{label:"图片",prop:"image"},{default:r(()=>[l(q,{modelValue:e.image,"onUpdate:modelValue":t[1]||(t[1]=s=>e.image=s),placeholder:"点击上传图片","url-placeholder":"或输入图片URL",tip:"支持 jpg、png、gif、webp 格式，最大 10MB"},null,8,["modelValue"])]),_:1}),l(i,{label:"跳转链接",prop:"url"},{default:r(()=>[l(w,{modelValue:e.url,"onUpdate:modelValue":t[2]||(t[2]=s=>e.url=s),placeholder:"请输入跳转链接",maxlength:"500"},null,8,["modelValue"])]),_:1}),l(i,{label:"排序",prop:"sort"},{default:r(()=>[l(W,{modelValue:e.sort,"onUpdate:modelValue":t[3]||(t[3]=s=>e.sort=s),min:0,max:9999,placeholder:"请输入排序值",style:{width:"100%"}},null,8,["modelValue"])]),_:1}),l(i,{label:"状态",prop:"status"},{default:r(()=>[l(h,{modelValue:e.status,"onUpdate:modelValue":t[4]||(t[4]=s=>e.status=s),"active-value":1,"inactive-value":0,"inline-prompt":"","active-text":"开启","inactive-text":"关闭"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])}}}),M=D(I,[["__scopeId","data-v-a43b2395"]]),G=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));export{M as W,G as a,A as d,z as g,T as u};
