nunu-layout-admin/web/dist/assets/api-DDa9fDH4.js

2 lines
9.3 KiB
JavaScript
Raw Normal View History

2025-03-24 05:55:56 +00:00
import{_ as _e}from"./index-1DQ9lz7_.js";import{a7 as ge,R as ve,a8 as ye,I as ke,a0 as he,u as me,v as xe,a1 as Ae,a9 as Ce,H as Ie,S as Ee,aa as we,V as Pe,ab as Te,t as be,M as Se,D as ce,ad as Ue,ae as Oe,n as ze}from"./antd-vtmm7CAy.js";import{a as De,u as Me,c as Ge,d as Re}from"./admin-x2Ewtnku.js";import{u as Be}from"./index-C-JhWVfG.js";import{r as z,s as D,f as w,o as Le,a2 as r,a9 as h,aa as a,k as o,u as n,H as M,a3 as y,F as Q,aj as W,G as s,ad as m,a4 as Ve,ae as _,ai as $e}from"./vue-Dl1fzmsf.js";import"./context-Dawj80bg.js";const je={key:0,flex:"","gap-2":""},qe={key:1,flex:"","gap-2":""},Fe={key:2,flex:"","gap-2":""},Ke=["onClick"],Ne=["onClick"],He=["onClick"],Je={key:3,"gap-2":""},at={__name:"api",setup(Qe){const x=z({pageSize:10,pageSizeOptions:["10","20","30","40"],current:1,total:100,showSizeChanger:!0,showQuickJumper:!0,showTotal:l=>`总数据位:${l}`,onChange(l,t){x.pageSize=t,x.current=l,E()}}),A=Be(),X=D([{title:"#",dataIndex:"id"},{title:"分组",dataIndex:"group"},{title:"API名称",dataIndex:"name"},{title:"API路由",dataIndex:"path"},{title:"Method",dataIndex:"method"},{title:"更新时间",dataIndex:"updatedAt"},{title:"操作",dataIndex:"action",width:200}]),Y={group:[{required:!0,message:"please enter group"}],method:[{required:!0,message:"please select an method"}],name:[{required:!0,message:"Please enter name"}],path:[{required:!0,message:"Please enter path"}]},C=D(!1),G=D([]),g=z({id:0,path:"",name:"",group:"",method:""}),p=w([]),R=l=>{l.length>1?p.value=[l[l.length-1]]:p.value=l,d.group=p.value[0]},d=z({id:0,path:"",name:"",group:"",method:"GET"}),B=()=>{Object.assign(d,{id:0,path:"",name:"",group:"",method:"GET"})},P=w(["large"]),Z=w([{key:"large",label:"默认",title:"默认"},{key:"middle",label:"中等",title:"中等"},{key:"small",label:"紧凑",title:"紧凑"}]),I=w(!1),S=w([]),c=w([]),ee=l=>{const t=new Map;l.forEach(i=>{const u=i.group;t.has(u)||(t.set(u,[]),c.value.includes(u)||c.value.push(u)),t.get(u).push(i)});const f=[];return t.forEach((i,u)=>{f.push({key:u,group:u,children:i})}),f};async function E(){if(!C.value){C.value=!0;try{const{data:l}=await De({...g,page:x.current,pageSize:x.pageSize});G.value=ee(l.list)??[],x.total=l.total??0,S.value=l.groups??[]}catch(l){console.log(l)}finally{C.value=!1}}}async function U(){x.current=1,await E()}async function te(){Object.assign(g,{id:0,path:"",name:"",group:"",method:""}),await E()}const ae=()=>{I.value=!1};async function oe(){const l=A.loading("提交中......");try{let t={};d.id>0?t=await Me({...d}):t=await Ge({...d}),t.code===0&&(await E(),I.value=!1,d.id>0?A.success("更新成功"):A.success("创建成功"))}catch(t){console.log(t)}finally{l()}}async function L(l){B(),p.value=[],l.group&&(d.group=l.group,p.value=[l.group]),I.value=!0}async function ne(l){B(),p.value=[l.group],Object.assign(d,l),I.value=!0}async function le(l){if(l.children&&l.children.length>0){A.error("存在子节点,不允许删除");return}const t=A.loading("删除中......");try{(await Re({id:l.id})).code===0&&await E(),A.success("删除成功")}catch(f){console.log(f)}finally{t()}}function se(){I.value=!1,U()}function de(l){P.value[0]=l.key}return Le(()=>{E()}),(l,t)=>{const f=he,i=me,u=xe,k=Ae,v=Ce,T=Ie,O=Ee,V=we,$=Pe,j=Te,q=be,re=Se,ie=ce,b=Ue,ue=Oe,pe=ze,fe=_e;return r(),h(fe,null,{default:a(()=>[o(j,{"mb-4":""},{default:a(()=>[o($,{model:n(g)},{default:a(()=>[o(V,{gutter:[15,0]},{default:a(()=>[o(v,{span:4},{default:a(()=>[o(k,{name:"group",label:"API分组"},{default:a(()=>[o(f,{style:{display:"none"},value:n(g).group,"onUpdate:value":t[0]||(t[0]=e=>n(g).group=e),placeholder:"描述API的功能"},null,8,["value"]),o(u,{value:n(p),"onUpdate:value":t[1]||(t[1]=e=>M(p)?p.value=e:null),mode:"tags","max-tag-count":1,onChange:R},{default:a(()=>[(r(!0),y(Q,null,W(n(S),e=>(r(),h(i,{key:e,value:e},{default:a(()=>[s(m(e),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1})]),_:1}),o(v,{span:4},{default:a(()=>[o(k,{name:"name",label:"API名称"},{default:a(()=>[o(f,{value:n(g).name,"onUpdate:value":t[2]||(t[2]=e=>n(g).name=e)},null,8,["va