import{a as y,E as h}from"./el-form-item-D5kF3B90.js";import{E as B}from"./index-TFUf94PZ.js";import{E as R}from"./index-BjEW7-SA.js";import{d as S,G as I,e as N,w as l,j as g,z as O,o as m,s as o,q as v,c as V,ad as U,n as b,f as q,bE as F,M as L,x,aa as M,A as w,y as j,v as z,ac as D}from"./index-BKKvzUDD.js";import{P}from"./PageCard-BoKXOzst.js";import{u as A}from"./tools-BSjcVinb.js";import{_ as G}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./castArray-5uErZEc3.js";import"./_baseClone-B5RBzbh5.js";import"./raf-C-x62Pcl.js";import"./index-DLzof2Fz.js";import"./index-GAnQrJsQ.js";import"./el-card-CApHJ1Gj.js";const $={class:"icon-grid"},H=["onClick"],J=S({__name:"ToolCreateView",setup(K){const d=D(),p=z(),n=A(),i=j(),s=g(()=>d.params.id!=null),c=g(()=>s.value?n.getTool(d.params.id):void 0),e=O({id:"",name:"",description:"",url:"",icon:"fa-cog"}),C={name:[{required:!0,message:"请输入工具名称",trigger:"blur"},{max:30,message:"不超过 30 字符",trigger:"blur"}],url:[{required:!0,message:"请输入跳转地址",trigger:"blur"}]};function E(){i.value&&i.value.validate(f=>{f&&(s.value?(n.updateTool(e.id,{...e}),w.success("更新成功")):(n.addTool({...e,id:"custom_"+Date.now()}),w.success("添加成功")),p.push("/tools"))})}function k(){p.back()}return I(()=>{c.value&&Object.assign(e,c.value)}),(f,a)=>{const u=B,r=y,_=R,T=h;return m(),N(P,{title:s.value?"编辑自定义工具":"添加自定义工具"},{default:l(()=>[o(T,{ref_key:"formRef",ref:i,model:e,rules:C,"label-width":"100px",style:{"max-width":"600px"}},{default:l(()=>[o(r,{label:"工具名称",prop:"name"},{default:l(()=>[o(u,{modelValue:e.name,"onUpdate:modelValue":a[0]||(a[0]=t=>e.name=t),placeholder:"请输入工具名称",maxlength:"30","show-word-limit":""},null,8,["modelValue"])]),_:1}),o(r,{label:"工具描述"},{default:l(()=>[o(u,{modelValue:e.description,"onUpdate:modelValue":a[1]||(a[1]=t=>e.description=t),type:"textarea",rows:2,maxlength:"100","show-word-limit":""},null,8,["modelValue"])]),_:1}),o(r,{label:"跳转地址",prop:"url"},{default:l(()=>[o(u,{modelValue:e.url,"onUpdate:modelValue":a[2]||(a[2]=t=>e.url=t),placeholder:"相对路径或完整 URL"},null,8,["modelValue"])]),_:1}),o(r,{label:"图标"},{default:l(()=>[v("div",$,[(m(!0),V(L,null,U(q(F),t=>(m(),V("div",{key:t,class:b(["icon-option",{selected:e.icon===t}]),onClick:Q=>e.icon=t},[v("i",{class:b(["fa",t])},null,2)],10,H))),128))])]),_:1}),o(r,null,{default:l(()=>[o(_,{type:"primary",onClick:E},{default:l(()=>[x(M(s.value?"保存":"添加"),1)]),_:1}),o(_,{onClick:k},{default:l(()=>[...a[3]||(a[3]=[x("取消",-1)])]),_:1})]),_:1})]),_:1},8,["model"])]),_:1},8,["title"])}}}),ue=G(J,[["__scopeId","data-v-9116c5de"]]);export{ue as default};
