import{m as $,aT as P,r as W,B as X,b2 as Y,p as u,q as b,t,v as o,u as n,aV as T,a2 as r,L as d,y as m,x as y,i as H,A as J,aW as O,aX as Q,ae as Z,aY as ee,b5 as te,b6 as oe,a8 as ne,a9 as ae,aa as le,b7 as ue,b8 as se}from"./.pnpm.1b0299fb.js";import{_ as re}from"./index.vue_vue_type_script_setup_true_lang.b077f234.js";import{e as de,f as k,b as ie}from"./index.689cfa31.js";import{b as me,c as pe,d as _e,e as ce,s as fe}from"./code.575733be.js";import{u as Fe}from"./usePaging.00aa976d.js";import{_ as ge}from"./data-table.vue_vue_type_script_setup_true_lang.b5282ddf.js";import{_ as be}from"./code-preview.vue_vue_type_script_setup_true_lang.7541032b.js";import"./@vueuse.72d44d91.js";import"./lodash.c3b66c05.js";import"./@vue.9d708d7c.js";import"./index.6c48d0ba.js";import"./index.vue_vue_type_style_index_0_scoped_d380c88d_lang.abac7546.js";const ye={class:"code-generation"},Ce={class:"flex"},we={class:"mt-4"},Ee={class:"flex items-center"},ve={class:"flex justify-end mt-4"},ke=$({name:"codeGenerate"}),Ue=$({...ke,setup(Be){const p=P({table_name:"",table_comment:""}),_=P({show:!1,loading:!1,code:[]}),{pager:f,getLists:g,resetParams:h,resetPage:C}=Fe({fetchFun:ce,params:p}),F=W([]),S=a=>{F.value=a.map(({id:e})=>e)},K=async a=>{await k.confirm("\u786E\u5B9A\u8981\u540C\u6B65\u8868\u7ED3\u6784\uFF1F"),await fe({id:a})},B=async a=>{await k.confirm("\u786E\u5B9A\u8981\u5220\u9664\uFF1F"),await me({id:a}),g()},I=async a=>{const e=await pe({id:a});_.code=e,_.show=!0},N=a=>a.some(e=>e.generate_type==1),D=async a=>{if(N(a))return k.msgError("\u751F\u6210\u65B9\u5F0F\u4E3A\u751F\u6210\u5230\u6A21\u5757\uFF0C\u8BF7\u5728\u524D\u7AEF\u5F00\u53D1\u6A21\u5F0F\u4E0B\u4F7F\u7528\uFF0C\u8BE6\u7EC6\u53C2\u8003\u6587\u6863");const e=await _e({id:a});e.file&&window.open(e.file,"_blank")},U=(a,e)=>{switch(a){case"generate":D([e.id]);break;case"sync":K(e.id);break;case"delete":B(e.id)}};return g(),(a,e)=>{const V=O,w=Q,s=Z,G=ee,x=te,E=ie,c=oe,L=X("router-link"),v=ne,q=ae,z=le,M=ue,R=re,i=Y("perms"),j=se;return u(),b("div",ye,[t(x,{class:"!border-none",shadow:"never"},{default:o(()=>[t(G,{class:"mb-[-16px]",model:n(p),inline:""},{default:o(()=>[t(w,{label:"\u8868\u540D\u79F0"},{default:o(()=>[t(V,{class:"w-[280px]",modelValue:n(p).table_name,"onUpdate:modelValue":e[0]||(e[0]=l=>n(p).table_name=l),clearable:"",onKeyup:T(n(C),["enter"])},null,8,["modelValue","onKeyup"])]),_:1}),t(w,{label:"\u8868\u63CF\u8FF0"},{default:o(()=>[t(V,{class:"w-[280px]",modelValue:n(p).table_comment,"onUpdate:modelValue":e[1]||(e[1]=l=>n(p).table_comment=l),clearable:"",onKeyup:T(n(C),["enter"])},null,8,["modelValue","onKeyup"])]),_:1}),t(w,null,{default:o(()=>[t(s,{type:"primary",onClick:n(C)},{default:o(()=>e[6]||(e[6]=[r("\u67E5\u8BE2")])),_:1},8,["onClick"]),t(s,{onClick:n(h)},{default:o(()=>e[7]||(e[7]=[r("\u91CD\u7F6E")])),_:1},8,["onClick"])]),_:1})]),_:1},8,["model"])]),_:1}),d((u(),m(x,{class:"!border-none mt-4",shadow:"never"},{default:o(()=>[y("div",Ce,[d((u(),m(ge,{class:"inline-block mr-[10px]",onSuccess:n(g)},{default:o(()=>[t(s,{type:"primary"},{icon:o(()=>[t(E,{name:"el-icon-Plus"})]),default:o(()=>[e[8]||(e[8]=r(" \u5BFC\u5165\u6570\u636E\u8868 "))]),_:1})]),_:1},8,["onSuccess"])),[[i,["tools.generator/selectTable"]]]),d((u(),m(s,{disabled:!n(F).length,onClick:e[2]||(e[2]=l=>B(n(F))),type:"danger"},{icon:o(()=>[t(E,{name:"el-icon-Delete"})]),default:o(()=>[e[9]||(e[9]=r(" \u5220\u9664 "))]),_:1},8,["disabled"])),[[i,["tools.generator/delete"]]]),d((u(),m(s,{disabled:!n(F).length,onClick:e[3]||(e[3]=l=>D(n(F)))},{default:o(()=>e[10]||(e[10]=[r(" \u751F\u6210\u4EE3\u7801 ")])),_:1},8,["disabled"])),[[i,["tools.generator/generate"]]])]),y("div",we,[t(M,{data:n(f).lists,size:"large",onSelectionChange:S},{default:o(()=>[t(c,{type:"selection",width:"55"}),t(c,{label:"\u8868\u540D\u79F0",prop:"table_name","min-width":"180"}),t(c,{label:"\u8868\u63CF\u8FF0",prop:"table_comment","min-width":"180"}),t(c,{label:"\u521B\u5EFA\u65F6\u95F4",prop:"create_time","min-width":"180"}),t(c,{label:"\u66F4\u65B0\u65F6\u95F4",prop:"update_time","min-width":"180"}),t(c,{label:"\u64CD\u4F5C",width:"160",fixed:"right"},{default:o(({row:l})=>[y("div",Ee,[d((u(),m(s,{type:"primary",link:"",onClick:A=>I(l.id)},{default:o(()=>e[11]||(e[11]=[r(" \u9884\u89C8 ")])),_:2},1032,["onClick"])),[[i,["tools.generator/preview"]]]),t(s,{type:"primary",link:""},{default:o(()=>[d((u(),m(L,{to:{path:n(de)("tools.generator/edit"),query:{id:l.id}}},{default:o(()=>e[12]||(e[12]=[r(" \u7F16\u8F91 ")])),_:2},1032,["to"])),[[i,["tools.generator/edit"]]])]),_:2},1024),d((u(),m(z,{class:"ml-2",onCommand:A=>U(A,l)},{dropdown:o(()=>[t(q,null,{default:o(()=>[d((u(),b("div",null,[t(v,{command:"generate"},{default:o(()=>[t(s,{type:"primary",link:""},{default:o(()=>e[14]||(e[14]=[r(" \u751F\u6210\u4EE3\u7801 ")])),_:1})]),_:1})])),[[i,["tools.generator/generate"]]]),d((u(),b("div",null,[t(v,{command:"sync"},{default:o(()=>[t(s,{type:"primary",link:""},{default:o(()=>e[15]||(e[15]=[r(" \u540C\u6B65 ")])),_:1})]),_:1})])),[[i,["tools.generator/syncColumn"]]]),d((u(),b("div",null,[t(v,{command:"delete"},{default:o(()=>[t(s,{type:"danger",link:""},{default:o(()=>e[16]||(e[16]=[r(" \u5220\u9664 ")])),_:1})]),_:1})])),[[i,["tools.generator/delete"]]])]),_:1})]),default:o(()=>[t(s,{type:"primary",link:""},{default:o(()=>[e[13]||(e[13]=r(" \u66F4\u591A ")),t(E,{name:"el-icon-ArrowDown",size:14})]),_:1})]),_:2},1032,["onCommand"])),[[i,["tools.generator/generate","tools.generator/syncColumn","tools.generator/delete"]]])])]),_:1})]),_:1},8,["data"])]),y("div",ve,[t(R,{modelValue:n(f),"onUpdate:modelValue":e[4]||(e[4]=l=>H(f)?f.value=l:null),onChange:n(g)},null,8,["modelValue","onChange"])])]),_:1})),[[j,n(f).loading]]),n(_).show?(u(),m(be,{key:0,modelValue:n(_).show,"onUpdate:modelValue":e[5]||(e[5]=l=>n(_).show=l),code:n(_).code},null,8,["modelValue","code"])):J("",!0)])}}});export{Ue as default};