import{u as R}from"./useResponse.DqThFJSa.js";import{e as U}from"./api.BtS8iSjH.js";import{F as B,G as N,h as g}from"./elementPlus.CSBdF9Zt.js";import{d as O,aJ as T,r as V,aI as q,aK as G,Z as v,ai as t,o as I,M as J,O as a,U as s,S as y,u as o}from"./vue.1RczIYhx.js";const $=O({__name:"CreateDialog",props:{modelValue:{default:!1},modelModifiers:{}},emits:T(["refresh"],["update:modelValue"]),setup(b,{emit:k}){const d=V(!1),c=q("createDialog"),i=G(b,"modelValue"),C=k,m=V(),n=v({name:""}),F=v({name:[{required:!0,message:"请输入种类名称",trigger:"blur"}]}),w=async l=>{l&&await l.validate(async(e,f)=>{if(e){const u={name:n.name};(await R(U,u,d)).code===2e3&&(g.success({message:"创建成功",plain:!0,icon:"CirclePlus"}),i.value=!1,C("refresh"))}else g.error("创建失败，请检查表单")})};function x(){D(m.value),c.value.visible=!1}const D=l=>{l&&l.resetFields()};return(l,e)=>{const f=t("el-input"),u=t("el-form-item"),p=t("el-form"),_=t("el-button"),M=t("el-dialog");return I(),J(M,{ref_key:"createDialog",ref:c,modelValue:i.value,"onUpdate:modelValue":e[2]||(e[2]=r=>i.value=r),"close-on-click-modal":!1,"close-on-press-escape":!1,title:"产品种类 - 创建 ",style:{width:"30%"}},{footer:a(()=>[s(_,{icon:o(B),onClick:x},{default:a(()=>e[3]||(e[3]=[y("取 消")])),_:1},8,["icon"]),s(_,{icon:o(N),loading:o(d),type:"primary",onClick:e[1]||(e[1]=r=>w(o(m)))},{default:a(()=>e[4]||(e[4]=[y("确 定")])),_:1},8,["icon","loading"])]),default:a(()=>[s(p,{ref_key:"ruleFormRef",ref:m,model:o(n),rules:o(F),class:"mx-2.5 mt-5","label-width":"auto","status-icon":""},{default:a(()=>[s(u,{class:"font-medium",label:"种类名称",prop:"name"},{default:a(()=>[s(f,{modelValue:o(n).name,"onUpdate:modelValue":e[0]||(e[0]=r=>o(n).name=r),placeholder:"请输入种类名称",style:{width:"328px"}},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}});export{$ as _};
