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