@gientech/modual 1.0.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/database.js CHANGED
@@ -1,4 +1,4 @@
1
- import{jsxs as Z,jsx as c,Fragment as ne}from"react/jsx-runtime";import{useState as E,useMemo as G,useRef as q,useEffect as ce}from"react";import{Button as U,DropDownButton as de,DashboardContainer as De}from"@mxmweb/zui";import{d as me}from"./assets/styled-components.browser.esm-BKnFpJ_S.js";import{Xviwer as K}from"@mxmweb/xviewer";import{a as be}from"./assets/index-NIGUFBhG.js";/* empty css */import{aB as $,aA as _}from"./assets/index-CGHNxHzA.js";import{T as ge}from"./assets/index-JdQHnMoG.js";import"react-dom";const ye=({url:b,token:z,role:N,eventsEmit:p})=>{const l=be.create({baseURL:b,timeout:1e6});return l.interceptors.request.use(e=>{let s=z;return!s&&!["user/login","user/kaptcha","user/regist"].some(t=>e.url.includes(t))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=s||"",e.headers.userName=N==="\u672A\u767B\u5F55\u7528\u6237"?"":N,e)}),l.interceptors.response.use(e=>{const s=["user/kaptcha"],a=e.data;if(s.some(I=>e.config.url&&e.config.url.includes(I))||a.size&&a.type)return a;const{success:t,errorMsg:i,errorCode:g}=a;return t?a:(p&&p("request:error_business",{errorCode:g,errorMsg:i||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:a}),!1)},async e=>{var s,a,t,i,g,I,A,C,h;if(e.message==="canceled")return Promise.reject(e);if(p){let B="request:error_network",D={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((s=e==null?void 0:e.response)==null?void 0:s.status)===401?(B="request:error_auth",D={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((t=(a=e==null?void 0:e.response)==null?void 0:a.data)==null?void 0:t.errorCode)==="30013"||((g=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:g.errorCode)==="30023")&&(B="request:error_business",D={errorCode:(A=(I=e==null?void 0:e.response)==null?void 0:I.data)==null?void 0:A.errorCode,errorMsg:((h=(C=e==null?void 0:e.response)==null?void 0:C.data)==null?void 0:h.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),p(B,D)}return console.log("Error occurs",e),Promise.reject(e)}),{getDatabaseList:async e=>{try{const s=await l.get(`/queryPageDBList?${new URLSearchParams(e).toString()}`),{success:a,data:t}=s;if(a)return t}catch(s){console.log("getDatabaseList error:",s)}},getShareDatabaseList:async e=>{try{const s=await l.get(`/queryShareDBList?${new URLSearchParams(e).toString()}`),{success:a,data:t}=s;if(a)return t}catch(s){console.log("getShareDatabaseList error:",s)}},delDatabaseById:async(e,s)=>{const a=O(s);try{const t=await l.delete(`/${a}/deleteDB/${e}`),{success:i,data:g}=t;if(i)return g}catch(t){console.log("delDatabaseById error:",t)}},saveDatabase:async(e,s)=>{const a=O(s);try{const t=await l.post(`/${a}/saveDBInfo`,e),{success:i,data:g}=t;if(i)return g}catch(t){console.log("saveDatabase error:",t)}},testConnection:async e=>{try{const s=await l.post("/directDB/testConnect",e),{success:a,data:t}=s;if(a)return t}catch(s){console.log("testConnection error:",s)}}}},O=b=>b=="DataTable"?"dataTable":"directDB",Ee="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCAzNiAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE0IDEyQzE0IDEwLjg5NTQgMTQuODk1NCAxMCAxNiAxMEgyOUMzMS4yMDkxIDEwIDMzIDExLjc5MDkgMzMgMTRWMjZDMzMgMzAuNDE4MyAyOS40MTgzIDM0IDI1IDM0SDE2QzE0Ljg5NTQgMzQgMTQgMzMuMTA0NiAxNCAzMlYxMloiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl80NDcyXzE4MDUyKSIvPgo8Zm9yZWlnbk9iamVjdCB4PSItMSIgeT0iLTEiIHdpZHRoPSIzMiIgaGVpZ2h0PSIzNiI+PGRpdiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCIgc3R5bGU9ImJhY2tkcm9wLWZpbHRlcjpibHVyKDJweCk7Y2xpcC1wYXRoOnVybCgjYmdibHVyXzBfNDQ3Ml8xODA1Ml9jbGlwX3BhdGgpO2hlaWdodDoxMDAlO3dpZHRoOjEwMCUiPjwvZGl2PjwvZm9yZWlnbk9iamVjdD48ZyBkYXRhLWZpZ21hLWJnLWJsdXItcmFkaXVzPSI0Ij4KPHBhdGggZD0iTTMgN0MzIDQuNzkwODYgNC43OTA4NiAzIDcgM0gyM0MyNS4yMDkxIDMgMjcgNC43OTA4NiAyNyA3VjE5QzI3IDI1LjYyNzQgMjEuNjI3NCAzMSAxNSAzMUg3QzQuNzkwODYgMzEgMyAyOS4yMDkxIDMgMjdWN1oiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuNDYiLz4KPHBhdGggZD0iTTcgMy4yNUgyM0MyNS4wNzExIDMuMjUgMjYuNzUgNC45Mjg5MyAyNi43NSA3VjE5QzI2Ljc1IDI1LjQ4OTMgMjEuNDg5MyAzMC43NSAxNSAzMC43NUg3QzQuOTI4OTMgMzAuNzUgMy4yNSAyOS4wNzExIDMuMjUgMjdWN0MzLjI1IDQuOTI4OTMgNC45Mjg5MyAzLjI1IDcgMy4yNVoiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS1vcGFjaXR5PSIwLjM0IiBzdHJva2Utd2lkdGg9IjAuNSIvPgo8L2c+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2RfNDQ3Ml8xODA1MikiPgo8cGF0aCBkPSJNMTQgMTlWMTEuNjY2NyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjgzOTcyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHBhdGggZD0iTTExIDE0TDEyIDEzTDE0IDExTDE2IDEzTDE3IDE0IiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTAgMjJIMTgiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iYmdibHVyXzBfNDQ3Ml8xODA1Ml9jbGlwX3BhdGgiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPjxwYXRoIGQ9Ik0zIDdDMyA0Ljc5MDg2IDQuNzkwODYgMyA3IDNIMjNDMjUuMjA5MSAzIDI3IDQuNzkwODYgMjcgN1YxOUMyNyAyNS42Mjc0IDIxLjYyNzQgMzEgMTUgMzFIN0M0Ljc5MDg2IDMxIDMgMjkuMjA5MSAzIDI3VjdaIi8+CjwvY2xpcFBhdGg+PGZpbHRlciBpZD0iZmlsdGVyMV9kXzQ0NzJfMTgwNTIiIHg9IjUiIHk9IjYiIHdpZHRoPSIxOCIgaGVpZ2h0PSIyMSIgZmlsdGVyVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiPgo8ZmVGbG9vZCBmbG9vZC1vcGFjaXR5PSIwIiByZXN1bHQ9IkJhY2tncm91bmRJbWFnZUZpeCIvPgo8ZmVDb2xvck1hdHJpeCBpbj0iU291cmNlQWxwaGEiIHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAxMjcgMCIgcmVzdWx0PSJoYXJkQWxwaGEiLz4KPGZlT2Zmc2V0Lz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMiIvPgo8ZmVDb21wb3NpdGUgaW4yPSJoYXJkQWxwaGEiIG9wZXJhdG9yPSJvdXQiLz4KPGZlQ29sb3JNYXRyaXggdHlwZT0ibWF0cml4IiB2YWx1ZXM9IjAgMCAwIDAgMCAwIDAgMCAwIDAuMzk2MDc4IDAgMCAwIDAgMC45ODQzMTQgMCAwIDAgMC40IDAiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbjI9IkJhY2tncm91bmRJbWFnZUZpeCIgcmVzdWx0PSJlZmZlY3QxX2Ryb3BTaGFkb3dfNDQ3Ml8xODA1MiIvPgo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9ImVmZmVjdDFfZHJvcFNoYWRvd180NDcyXzE4MDUyIiByZXN1bHQ9InNoYXBlIi8+CjwvZmlsdGVyPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNDQ3Ml8xODA1MiIgeDE9IjIzLjUiIHkxPSIxMCIgeDI9IjIzLjUiIHkyPSIzNCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjNjRBMEZEIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAxNUFGRiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=",Fe=""+new URL("assets/database_connect.svg",import.meta.url).href,pe=""+new URL("assets/mysql.svg",import.meta.url).href,Ie=""+new URL("assets/SQLServer.png",import.meta.url).href,Me=""+new URL("assets/PostgreSQL.png",import.meta.url).href,fe=""+new URL("assets/Doris.png",import.meta.url).href,Ae=[{label:"MySQL",value:"MySQL",icon:pe},{label:"PostgreSQL",value:"PostgreSQL",icon:Me},{label:"SQLServer",value:"SQLServer",icon:Ie},{label:"Doris",value:"Doris",icon:fe}],Ce=({drawerTitle:b,drawerVisible:z,isConnectSuccess:N,handleDrawerClose:p,dbInfo:l,dbType:d,eventsEmit:f})=>{const[W,R]=E(!1),[V,e]=E(!1),[s,a]=E({}),[t,i]=E(!1),g=G(()=>({id:d,layout:"vertical",formWidth:"500px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:u=>{if(!u)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(u))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",counter:150,required:!1,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""}]}),[d,l]),I=G(()=>({id:d,layout:"vertical",formWidth:"470px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:u=>{if(!u)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(u))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",required:!1,counter:150,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""},{id:"db-info",label:"\u76F4\u8FDE\u6570\u636E\u6E90\u4FE1\u606F",type:"title",level:2},{id:"dbType",name:"dbType",label:"\u6570\u636E\u6E90\u7C7B\u578B",type:"select",disabled:!!l,required:!0,options:Ae.map(u=>{const{label:r,value:M,icon:v}=u;return{label:r,value:M,render:()=>Z("div",{className:"flex items-center gap-2",children:[c("img",{src:v,width:24}),c("span",{children:r})]})}})},{id:"dbHost",name:"dbHost",label:"\u4E3B\u673A\u5730\u5740",type:"input",required:!0,disabled:!!l,placeholder:"\u8BF7\u8F93\u5165IP\u5730\u5740\u6216\u8005\u57DF\u540D"},{id:"dbPort",name:"dbPort",label:"\u7AEF\u53E3\u53F7",type:"number",required:!0,disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u7AEF\u53E3\u540D\u79F0"},{id:"dbDatabase",name:"dbDatabase",label:"\u8FDE\u63A5\u6570\u636E\u5E93\u540D",disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u8FDE\u63A5\u6570\u636E\u5E93\u540D",required:!0,type:"input"},{type:"col",children:[{id:"dbUser",type:"input",name:"dbUser",label:"\u7528\u6237\u540D",disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u7528\u6237\u540D",required:!0},{id:"dbPassword",type:"password",name:"dbPassword",label:"\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u5BC6\u7801",required:!0,disabled:t?!1:!!l}]}]}),[d,l,t]),A=q(null),C=(u,r,M)=>{switch(console.log("[Form] eventsEmit:",u,r,M),u){case"form:ready":r.formRef&&(A.current=r.formRef);break;case"form_field_change":console.log("\u5B57\u6BB5\u503C\u53D8\u5316:",r),a(v=>({...v,[r.fieldId]:r.value}));break;case"form_validation_error":console.log("\u8868\u5355\u9A8C\u8BC1\u9519\u8BEF:",r);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",u,r)}f==null||f(u,r,M)},h=async()=>{try{R(!0);const u=await A.current.getAllData();u.isValid&&(console.log(u,"==="),d=="DirectDB"&&b=="\u7F16\u8F91\u6570\u636E\u5E93"&&!t&&(u.fields=u.fields.filter(r=>r.name=="name"||r.name=="description")),await f("form_submitted",u,void 0),i(!1))}catch(u){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",u)}finally{R(!1)}},B=async()=>{try{e(!0);const u=await A.current.getAllData();if(u.isValid){const r=u.fields.reduce((M,v)=>(M[v.name]=v.value,M),{});await f("form:connect_test",r,void 0)}}catch{e(!1)}finally{e(!1)}},D=G(()=>{const u=d=="DataTable"?g:I;return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:u.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:u.id,type:"form",size:"md",formWidth:u.formWidth,formConfig:{layout:u.layout,showReset:!1,showSubmit:!1,formWidth:u.formWidth,getFormData:()=>({...s,timestamp:new Date().toISOString(),formId:u.id}),onFieldChange:(r,M)=>{C("form_field_change",{fieldId:r,value:M},void 0)},onValidationError:r=>{C("form_validation_error",r,void 0)}}}],dataSource:[{id:u.id,fields:u.fields,defaultValues:{...l}}],eventsEmit:C}},[d,g,I,z,l]),Q=G(()=>d=="DirectDB"?l?t&&!N:!N:!1,[d,N,t,z]);return Z($,{title:b,width:620,onCancel:()=>{p(),i(!1)},open:z,destroyOnHidden:!0,footer:Z("div",{className:"flex justify-end gap-3",children:[c(U,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{p(),i(!1)}}),c(U,{mode:"primary",label:"\u786E\u8BA4",loading:W,disabled:Q,onClick:h})]}),children:[c(K,{...D},"example-form"),d==="DirectDB"&&c(ne,{children:b=="\u7F16\u8F91\u6570\u636E\u5E93"&&!t?c(U,{mode:"primary",className:"mt-[10px]",label:"\u4FEE\u6539\u5BC6\u7801",onClick:()=>{i(!0),A.current.setValues({dbPassword:void 0})}}):c(ge,{title:"\u9700\u901A\u8FC7\u6D4B\u8BD5\u624D\u53EF\u521B\u5EFA\u6210\u529F",children:c(U,{mode:"primary",className:"mt-[10px]",label:"\u8FDE\u63A5\u6D4B\u8BD5",loading:V,onClick:B})})})]})},he=""+new URL("assets/empty.png",import.meta.url).href,{confirm:Be}=$,we=me.div`
1
+ import{jsxs as Z,jsx as c,Fragment as ne}from"react/jsx-runtime";import{useState as E,useMemo as T,useRef as q,useEffect as ce}from"react";import{k as K,J as U,i as de,F as De}from"./assets/index-CwZH-3RQ.js";import{a as me}from"./assets/index-CZ9KcyHq.js";import{d as ge}from"./assets/styled-components.browser.esm-DPkS13KC.js";/* empty css */import{aL as $,z as be,aH as Y}from"./assets/index-C_syaGTO.js";import"react-dom";const ye=({url:g,token:z,role:N,eventsEmit:p})=>{const l=me.create({baseURL:g,timeout:1e6});return l.interceptors.request.use(e=>{let s=z;return!s&&!["user/login","user/kaptcha","user/regist"].some(t=>e.url.includes(t))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=s||"",e.headers.userName=N==="\u672A\u767B\u5F55\u7528\u6237"?"":N,e)}),l.interceptors.response.use(e=>{const s=["user/kaptcha"],a=e.data;if(s.some(I=>e.config.url&&e.config.url.includes(I))||a.size&&a.type)return a;const{success:t,errorMsg:i,errorCode:b}=a;return t?a:(p&&p("request:error_business",{errorCode:b,errorMsg:i||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:a}),!1)},async e=>{var s,a,t,i,b,I,A,C,h;if(e.message==="canceled")return Promise.reject(e);if(p){let B="request:error_network",D={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((s=e==null?void 0:e.response)==null?void 0:s.status)===401?(B="request:error_auth",D={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((t=(a=e==null?void 0:e.response)==null?void 0:a.data)==null?void 0:t.errorCode)==="30013"||((b=(i=e==null?void 0:e.response)==null?void 0:i.data)==null?void 0:b.errorCode)==="30023")&&(B="request:error_business",D={errorCode:(A=(I=e==null?void 0:e.response)==null?void 0:I.data)==null?void 0:A.errorCode,errorMsg:((h=(C=e==null?void 0:e.response)==null?void 0:C.data)==null?void 0:h.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),p(B,D)}return console.log("Error occurs",e),Promise.reject(e)}),{getDatabaseList:async e=>{try{const s=await l.get(`/queryPageDBList?${new URLSearchParams(e).toString()}`),{success:a,data:t}=s;if(a)return t}catch(s){console.log("getDatabaseList error:",s)}},getShareDatabaseList:async e=>{try{const s=await l.get(`/queryShareDBList?${new URLSearchParams(e).toString()}`),{success:a,data:t}=s;if(a)return t}catch(s){console.log("getShareDatabaseList error:",s)}},delDatabaseById:async(e,s)=>{const a=O(s);try{const t=await l.delete(`/${a}/deleteDB/${e}`),{success:i,data:b}=t;if(i)return b}catch(t){console.log("delDatabaseById error:",t)}},saveDatabase:async(e,s)=>{const a=O(s);try{const t=await l.post(`/${a}/saveDBInfo`,e),{success:i,data:b}=t;if(i)return b}catch(t){console.log("saveDatabase error:",t)}},testConnection:async e=>{try{const s=await l.post("/directDB/testConnect",e),{success:a,data:t}=s;if(a)return t}catch(s){console.log("testConnection error:",s)}}}},O=g=>g=="DataTable"?"dataTable":"directDB",Ee="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCAzNiAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE0IDEyQzE0IDEwLjg5NTQgMTQuODk1NCAxMCAxNiAxMEgyOUMzMS4yMDkxIDEwIDMzIDExLjc5MDkgMzMgMTRWMjZDMzMgMzAuNDE4MyAyOS40MTgzIDM0IDI1IDM0SDE2QzE0Ljg5NTQgMzQgMTQgMzMuMTA0NiAxNCAzMlYxMloiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl80NDcyXzE4MDUyKSIvPgo8Zm9yZWlnbk9iamVjdCB4PSItMSIgeT0iLTEiIHdpZHRoPSIzMiIgaGVpZ2h0PSIzNiI+PGRpdiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCIgc3R5bGU9ImJhY2tkcm9wLWZpbHRlcjpibHVyKDJweCk7Y2xpcC1wYXRoOnVybCgjYmdibHVyXzBfNDQ3Ml8xODA1Ml9jbGlwX3BhdGgpO2hlaWdodDoxMDAlO3dpZHRoOjEwMCUiPjwvZGl2PjwvZm9yZWlnbk9iamVjdD48ZyBkYXRhLWZpZ21hLWJnLWJsdXItcmFkaXVzPSI0Ij4KPHBhdGggZD0iTTMgN0MzIDQuNzkwODYgNC43OTA4NiAzIDcgM0gyM0MyNS4yMDkxIDMgMjcgNC43OTA4NiAyNyA3VjE5QzI3IDI1LjYyNzQgMjEuNjI3NCAzMSAxNSAzMUg3QzQuNzkwODYgMzEgMyAyOS4yMDkxIDMgMjdWN1oiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuNDYiLz4KPHBhdGggZD0iTTcgMy4yNUgyM0MyNS4wNzExIDMuMjUgMjYuNzUgNC45Mjg5MyAyNi43NSA3VjE5QzI2Ljc1IDI1LjQ4OTMgMjEuNDg5MyAzMC43NSAxNSAzMC43NUg3QzQuOTI4OTMgMzAuNzUgMy4yNSAyOS4wNzExIDMuMjUgMjdWN0MzLjI1IDQuOTI4OTMgNC45Mjg5MyAzLjI1IDcgMy4yNVoiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS1vcGFjaXR5PSIwLjM0IiBzdHJva2Utd2lkdGg9IjAuNSIvPgo8L2c+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2RfNDQ3Ml8xODA1MikiPgo8cGF0aCBkPSJNMTQgMTlWMTEuNjY2NyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjgzOTcyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHBhdGggZD0iTTExIDE0TDEyIDEzTDE0IDExTDE2IDEzTDE3IDE0IiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTAgMjJIMTgiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iYmdibHVyXzBfNDQ3Ml8xODA1Ml9jbGlwX3BhdGgiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPjxwYXRoIGQ9Ik0zIDdDMyA0Ljc5MDg2IDQuNzkwODYgMyA3IDNIMjNDMjUuMjA5MSAzIDI3IDQuNzkwODYgMjcgN1YxOUMyNyAyNS42Mjc0IDIxLjYyNzQgMzEgMTUgMzFIN0M0Ljc5MDg2IDMxIDMgMjkuMjA5MSAzIDI3VjdaIi8+CjwvY2xpcFBhdGg+PGZpbHRlciBpZD0iZmlsdGVyMV9kXzQ0NzJfMTgwNTIiIHg9IjUiIHk9IjYiIHdpZHRoPSIxOCIgaGVpZ2h0PSIyMSIgZmlsdGVyVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiPgo8ZmVGbG9vZCBmbG9vZC1vcGFjaXR5PSIwIiByZXN1bHQ9IkJhY2tncm91bmRJbWFnZUZpeCIvPgo8ZmVDb2xvck1hdHJpeCBpbj0iU291cmNlQWxwaGEiIHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAxMjcgMCIgcmVzdWx0PSJoYXJkQWxwaGEiLz4KPGZlT2Zmc2V0Lz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMiIvPgo8ZmVDb21wb3NpdGUgaW4yPSJoYXJkQWxwaGEiIG9wZXJhdG9yPSJvdXQiLz4KPGZlQ29sb3JNYXRyaXggdHlwZT0ibWF0cml4IiB2YWx1ZXM9IjAgMCAwIDAgMCAwIDAgMCAwIDAuMzk2MDc4IDAgMCAwIDAgMC45ODQzMTQgMCAwIDAgMC40IDAiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbjI9IkJhY2tncm91bmRJbWFnZUZpeCIgcmVzdWx0PSJlZmZlY3QxX2Ryb3BTaGFkb3dfNDQ3Ml8xODA1MiIvPgo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9ImVmZmVjdDFfZHJvcFNoYWRvd180NDcyXzE4MDUyIiByZXN1bHQ9InNoYXBlIi8+CjwvZmlsdGVyPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNDQ3Ml8xODA1MiIgeDE9IjIzLjUiIHkxPSIxMCIgeDI9IjIzLjUiIHkyPSIzNCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjNjRBMEZEIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAxNUFGRiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=",Fe=""+new URL("assets/database_connect.svg",import.meta.url).href,pe=""+new URL("assets/mysql.svg",import.meta.url).href,Ie=""+new URL("assets/SQLServer.png",import.meta.url).href,Me=""+new URL("assets/PostgreSQL.png",import.meta.url).href,fe=""+new URL("assets/Doris.png",import.meta.url).href,Ae=[{label:"MySQL",value:"MySQL",icon:pe},{label:"PostgreSQL",value:"PostgreSQL",icon:Me},{label:"SQLServer",value:"SQLServer",icon:Ie},{label:"Doris",value:"Doris",icon:fe}],Ce=({drawerTitle:g,drawerVisible:z,isConnectSuccess:N,handleDrawerClose:p,dbInfo:l,dbType:d,eventsEmit:f})=>{const[W,R]=E(!1),[V,e]=E(!1),[s,a]=E({}),[t,i]=E(!1),b=T(()=>({id:d,layout:"vertical",formWidth:"500px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:u=>{if(!u)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(u))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",counter:150,required:!1,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""}]}),[d,l]),I=T(()=>({id:d,layout:"vertical",formWidth:"470px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:u=>{if(!u)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(u))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",required:!1,counter:150,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""},{id:"db-info",label:"\u76F4\u8FDE\u6570\u636E\u6E90\u4FE1\u606F",type:"title",level:2},{id:"dbType",name:"dbType",label:"\u6570\u636E\u6E90\u7C7B\u578B",type:"select",disabled:!!l,required:!0,options:Ae.map(u=>{const{label:r,value:M,icon:v}=u;return{label:r,value:M,render:()=>Z("div",{className:"flex items-center gap-2",children:[c("img",{src:v,width:24}),c("span",{children:r})]})}})},{id:"dbHost",name:"dbHost",label:"\u4E3B\u673A\u5730\u5740",type:"input",required:!0,disabled:!!l,placeholder:"\u8BF7\u8F93\u5165IP\u5730\u5740\u6216\u8005\u57DF\u540D"},{id:"dbPort",name:"dbPort",label:"\u7AEF\u53E3\u53F7",type:"number",required:!0,disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u7AEF\u53E3\u540D\u79F0"},{id:"dbDatabase",name:"dbDatabase",label:"\u8FDE\u63A5\u6570\u636E\u5E93\u540D",disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u8FDE\u63A5\u6570\u636E\u5E93\u540D",required:!0,type:"input"},{type:"col",children:[{id:"dbUser",type:"input",name:"dbUser",label:"\u7528\u6237\u540D",disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u7528\u6237\u540D",required:!0},{id:"dbPassword",type:"password",name:"dbPassword",label:"\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u5BC6\u7801",required:!0,disabled:t?!1:!!l}]}]}),[d,l,t]),A=q(null),C=(u,r,M)=>{switch(console.log("[Form] eventsEmit:",u,r,M),u){case"form:ready":r.formRef&&(A.current=r.formRef);break;case"form_field_change":console.log("\u5B57\u6BB5\u503C\u53D8\u5316:",r),a(v=>({...v,[r.fieldId]:r.value}));break;case"form_validation_error":console.log("\u8868\u5355\u9A8C\u8BC1\u9519\u8BEF:",r);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",u,r)}f==null||f(u,r,M)},h=async()=>{try{R(!0);const u=await A.current.getAllData();u.isValid&&(console.log(u,"==="),d=="DirectDB"&&g=="\u7F16\u8F91\u6570\u636E\u5E93"&&!t&&(u.fields=u.fields.filter(r=>r.name=="name"||r.name=="description")),await f("form_submitted",u,void 0),i(!1))}catch(u){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",u)}finally{R(!1)}},B=async()=>{try{e(!0);const u=await A.current.getAllData();if(u.isValid){const r=u.fields.reduce((M,v)=>(M[v.name]=v.value,M),{});await f("form:connect_test",r,void 0)}}catch{e(!1)}finally{e(!1)}},D=T(()=>{const u=d=="DataTable"?b:I;return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:u.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:u.id,type:"form",size:"md",formWidth:u.formWidth,formConfig:{layout:u.layout,showReset:!1,showSubmit:!1,formWidth:u.formWidth,getFormData:()=>({...s,timestamp:new Date().toISOString(),formId:u.id}),onFieldChange:(r,M)=>{C("form_field_change",{fieldId:r,value:M},void 0)},onValidationError:r=>{C("form_validation_error",r,void 0)}}}],dataSource:[{id:u.id,fields:u.fields,defaultValues:{...l}}],eventsEmit:C}},[d,b,I,z,l]),H=T(()=>d=="DirectDB"?l?t&&!N:!N:!1,[d,N,t,z]);return Z($,{title:g,width:620,onCancel:()=>{p(),i(!1)},open:z,destroyOnHidden:!0,footer:Z("div",{className:"flex justify-end gap-3",children:[c(U,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{p(),i(!1)}}),c(U,{mode:"primary",label:"\u786E\u8BA4",loading:W,disabled:H,onClick:h})]}),children:[c(K,{...D},"example-form"),d==="DirectDB"&&c(ne,{children:g=="\u7F16\u8F91\u6570\u636E\u5E93"&&!t?c(U,{mode:"primary",className:"mt-[10px]",label:"\u4FEE\u6539\u5BC6\u7801",onClick:()=>{i(!0),A.current.setValues({dbPassword:void 0})}}):c(be,{title:"\u9700\u901A\u8FC7\u6D4B\u8BD5\u624D\u53EF\u521B\u5EFA\u6210\u529F",children:c(U,{mode:"primary",className:"mt-[10px]",label:"\u8FDE\u63A5\u6D4B\u8BD5",loading:V,onClick:B})})})]})},he=""+new URL("assets/empty.png",import.meta.url).href,{confirm:Be}=$,we=ge.div`
2
2
  width: 282px;
3
3
  height: 81px;
4
4
  display: flex;
@@ -17,4 +17,4 @@ import{jsxs as Z,jsx as c,Fragment as ne}from"react/jsx-runtime";import{useState
17
17
  background-color: #F1F5FF;
18
18
  };
19
19
  border: 1px solid #EBEBEB
20
- `,Ne=[{key:"add_file_db",label:"\u4E0A\u4F20\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0A\u4F20Excel\u3001csv\u7B49\u683C\u5F0F\u6570\u636E\u8868\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:Ee},{key:"add_direct_db",label:"\u76F4\u8FDE\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0E\u5DF2\u6709\u4E1A\u52A1\u5EFA\u7ACB\u8FDE\u63A5\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:Fe}],Ge=b=>{const{url:z,token:N,role:p,CustomComponents:l,getBtnDisabled:d}=b,[f,W]=E("my-db"),[R,V]=E({app:"ready",container:"ready",content:"ready"}),[e,s]=E(!1),[a,t]=E([{id:"my-db",data:[]},{id:"shared-db",data:[]}]),i=q(null),[g,I]=E(!1),[A,C]=E(""),[h,B]=E("DataTable"),[D,Q]=E(),[u,r]=E(!1),{getDatabaseList:M,delDatabaseById:v,saveDatabase:ee,testConnection:ue,getShareDatabaseList:te}=ye({url:z,token:N,role:p,eventsEmit:b.eventsEmit}),J=G(()=>[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"my-db",type:"card",cardType:"database",rowHeight:220,viewPageSize:12,viewBehavior:"pagination",actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}],toolbar:[{type:"customized",key:"add",render:()=>c(de,{mode:"primary",label:"\u521B\u5EFA\u6570\u636E\u5E93",actions:Ne.map(n=>({key:n.key,component:c(we,{children:Z("div",{className:"flex flex-grow",children:[c("div",{className:"mr-[6px]",children:c("img",{src:n.icon})}),Z("div",{children:[c("div",{className:"text-base font-bold mb-1 text-[14px]",children:n.label}),c("div",{className:"text-[#888] text-[10px]",children:n.dsc})]})]})},n.key)})),eventEmit:Y})},{type:"fuzzy_search",key:"search",label:"\u8F93\u5165\u540D\u79F0\u641C\u7D22",searchKeys:["name","description"],position:"right"}]},{label:"\u5171\u4EAB\u6570\u636E\u5E93",id:"shared-db",type:"card",cardType:"database",rowHeight:240,toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",position:"right"}],actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}]}],[]);ce(()=>{V(n=>({...n,content:"loading"})),ae()},[]);const ae=async()=>{var n,o,P,j;try{const[w,k]=await Promise.allSettled([M({pageNo:1,pageSize:999}),te({pageNo:1,pageSize:999})]);let L=[];if(w.status==="fulfilled"&&w.value&&(n=w.value)!=null&&n.records){const x=(((o=w.value)==null?void 0:o.records)||[]).map(m=>({...m,actions:H("my-db").map((y,S)=>({...y,key:y.type==="divider"?`${y.key}_${m.id}`:y.key,disabled:d&&d(y.key=="edit"?7:4,m.permission)}))}));L.push({id:"my-db",data:x||[]})}if(k.status==="fulfilled"&&k.value&&(P=k.value)!=null&&P.records){const x=(((j=k.value)==null?void 0:j.records)||[]).map(m=>({...m,actions:H("shared-db").map((y,S)=>({...y,key:y.type==="divider"?`${y.key}_${m.id}`:y.key,disabled:d&&d(y.key=="edit"?7:4,m.permission)}))}));L.push({id:"shared-db",data:x||[]})}t(L),V(x=>({...x,content:"ready"}))}catch(w){console.log("[DatabaseApiError] getDatabaseList:",w)}},se="admin",ie=()=>Z("div",{className:"flex flex-col items-center justify-center h-full",children:[c("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:c("img",{src:he,width:120})}),c("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u6DFB\u52A0\u6570\u636E\u5E93"})]}),H=n=>{const o=J.find(j=>j.id===n);return(o==null?void 0:o.actions)||[]},re=G(()=>{var o;const n=((o=a==null?void 0:a.find(P=>P.id===f))==null?void 0:o.data)||[];return e?[]:n},[f,a,e]),X=()=>{I(!1),r(!1),Q(void 0)},oe=async n=>{console.log("[DatabaseViewAdopter] \u6D4B\u8BD5\u8FDE\u63A5:",n);const o=await ue(n);return o&&(r(!0),_.success("\u8FDE\u63A5\u6D4B\u8BD5\u6210\u529F\uFF01")),o};async function Y(n,o,P){var j,w,k,L,x;switch(console.log("[DatabaseViewAdopter] mergedEventsEmit",n,o),n){case"card_delete":Be({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5E93\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await v(o.id,o.datasourceType)&&(i!=null&&i.current)&&(i==null||i.current.appFn.removeItem(o.id))},onCancel(){console.log("Cancel")}});break;case"card_edit":C("\u7F16\u8F91\u6570\u636E\u5E93"),I(!0),B(o.datasourceType),delete o.render,Q(o);break;case"select":W(o.id);break;case"filesDir_clicked":W(o.id);break;case"dropdown_action":C("\u521B\u5EFA\u6570\u636E\u5E93"),I(!0),o.key=="add_file_db"?B("DataTable"):B("DirectDB");break;case"form_submitted":try{const m=o.fields.reduce((T,F)=>(T[F.name]=F.value,T),{}),y=D?{id:D==null?void 0:D.id,...m}:m,S=await ee(y,h);if(S){if(D){const T={...D,...m,datasourceType:h,actions:H("my-db").map((F,le)=>({...F,key:F.type==="divider"?`${F.key}_${S}`:F.key,allow:!0}))};(w=(j=i==null?void 0:i.current)==null?void 0:j.appFn)==null||w.updateItem(T,D==null?void 0:D.id),_.success("\u6570\u636E\u5E93\u7F16\u8F91\u6210\u529F\uFF01")}else{const T={...m,...S,createBy:se,datasourceType:h,actions:H("my-db").map((F,le)=>({...F,key:F.type==="divider"?`${F.key}_${S}`:F.key,allow:!0}))};(L=(k=i==null?void 0:i.current)==null?void 0:k.appFn)==null||L.addItem(T,{animate:!0,position:"start"}),_.success("\u6570\u636E\u5E93\u521B\u5EFA\u6210\u529F\uFF01")}return S}}catch(m){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",m)}finally{X()}break;case"form:connect_test":return await oe(o);case"toolbar_test_empty":console.log("[DatabaseViewAdopter] toolbar_test_empty \u4E8B\u4EF6\u89E6\u53D1"),s(!e);break;default:(x=b.eventsEmit)==null||x.call(b,n,o);break}}return Z(De,{title:"\u6570\u636E\u5E93\u7BA1\u7406",children:[c(K,{ref:i,label:"",model:"tabs",defaultActiveId:f,views:J,dataSource:re,eventsEmit:Y,status:R,CustomComponents:{EmptyData:ie,...l},styles:b.styles},"db"),c(Ce,{drawerTitle:A,drawerVisible:g,isConnectSuccess:u,dbType:h,dbInfo:D,handleDrawerClose:X,eventsEmit:Y})]})};export{Ge as default};
20
+ `,Ne=[{key:"add_file_db",label:"\u4E0A\u4F20\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0A\u4F20Excel\u3001csv\u7B49\u683C\u5F0F\u6570\u636E\u8868\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:Ee},{key:"add_direct_db",label:"\u76F4\u8FDE\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0E\u5DF2\u6709\u4E1A\u52A1\u5EFA\u7ACB\u8FDE\u63A5\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:Fe}],Pe=g=>{const{url:z,token:N,role:p,CustomComponents:l,getBtnDisabled:d}=g,[f,W]=E("my-db"),[R,V]=E({app:"ready",container:"ready",content:"ready"}),[e,s]=E(!1),[a,t]=E([{id:"my-db",data:[]},{id:"shared-db",data:[]}]),i=q(null),[b,I]=E(!1),[A,C]=E(""),[h,B]=E("DataTable"),[D,H]=E(),[u,r]=E(!1),{getDatabaseList:M,delDatabaseById:v,saveDatabase:ee,testConnection:ue,getShareDatabaseList:te}=ye({url:z,token:N,role:p,eventsEmit:g.eventsEmit}),_=T(()=>[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"my-db",type:"card",cardType:"database",rowHeight:220,viewPageSize:12,viewBehavior:"pagination",actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}],toolbar:[{type:"customized",key:"add",render:()=>c(de,{mode:"primary",label:"\u521B\u5EFA\u6570\u636E\u5E93",actions:Ne.map(n=>({key:n.key,component:c(we,{children:Z("div",{className:"flex flex-grow",children:[c("div",{className:"mr-[6px]",children:c("img",{src:n.icon})}),Z("div",{children:[c("div",{className:"text-base font-bold mb-1 text-[14px]",children:n.label}),c("div",{className:"text-[#888] text-[10px]",children:n.dsc})]})]})},n.key)})),eventEmit:J})},{type:"fuzzy_search",key:"search",label:"\u8F93\u5165\u540D\u79F0\u641C\u7D22",searchKeys:["name","description"],position:"right"}]},{label:"\u5171\u4EAB\u6570\u636E\u5E93",id:"shared-db",type:"card",cardType:"database",rowHeight:240,toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",position:"right"}],actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}]}],[]);ce(()=>{V(n=>({...n,content:"loading"})),ae()},[]);const ae=async()=>{var n,o,L,j;try{const[w,k]=await Promise.allSettled([M({pageNo:1,pageSize:999}),te({pageNo:1,pageSize:999})]);let P=[];if(w.status==="fulfilled"&&w.value&&(n=w.value)!=null&&n.records){const x=(((o=w.value)==null?void 0:o.records)||[]).map(m=>({...m,actions:Q("my-db").map((y,S)=>({...y,key:y.type==="divider"?`${y.key}_${m.id}`:y.key,disabled:d&&d(y.key=="edit"?7:4,m.permission)}))}));P.push({id:"my-db",data:x||[]})}if(k.status==="fulfilled"&&k.value&&(L=k.value)!=null&&L.records){const x=(((j=k.value)==null?void 0:j.records)||[]).map(m=>({...m,actions:Q("shared-db").map((y,S)=>({...y,key:y.type==="divider"?`${y.key}_${m.id}`:y.key,disabled:d&&d(y.key=="edit"?7:4,m.permission)}))}));P.push({id:"shared-db",data:x||[]})}t(P),V(x=>({...x,content:"ready"}))}catch(w){console.log("[DatabaseApiError] getDatabaseList:",w)}},se="admin",ie=()=>Z("div",{className:"flex flex-col items-center justify-center h-full",children:[c("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:c("img",{src:he,width:120})}),c("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u6DFB\u52A0\u6570\u636E\u5E93"})]}),Q=n=>{const o=_.find(j=>j.id===n);return(o==null?void 0:o.actions)||[]},re=T(()=>{var o;const n=((o=a==null?void 0:a.find(L=>L.id===f))==null?void 0:o.data)||[];return e?[]:n},[f,a,e]),X=()=>{I(!1),r(!1),H(void 0)},oe=async n=>{console.log("[DatabaseViewAdopter] \u6D4B\u8BD5\u8FDE\u63A5:",n);const o=await ue(n);return o&&(r(!0),Y.success("\u8FDE\u63A5\u6D4B\u8BD5\u6210\u529F\uFF01")),o};async function J(n,o,L){var j,w,k,P,x;switch(console.log("[DatabaseViewAdopter] mergedEventsEmit",n,o),n){case"card_delete":Be({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5E93\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await v(o.id,o.datasourceType)&&(i!=null&&i.current)&&(i==null||i.current.appFn.removeItem(o.id))},onCancel(){console.log("Cancel")}});break;case"card_edit":C("\u7F16\u8F91\u6570\u636E\u5E93"),I(!0),B(o.datasourceType),delete o.render,H(o);break;case"select":W(o.id);break;case"filesDir_clicked":W(o.id);break;case"dropdown_action":C("\u521B\u5EFA\u6570\u636E\u5E93"),I(!0),o.key=="add_file_db"?B("DataTable"):B("DirectDB");break;case"form_submitted":try{const m=o.fields.reduce((G,F)=>(G[F.name]=F.value,G),{}),y=D?{id:D==null?void 0:D.id,...m}:m,S=await ee(y,h);if(S){if(D){const G={...D,...m,datasourceType:h,actions:Q("my-db").map((F,le)=>({...F,key:F.type==="divider"?`${F.key}_${S}`:F.key,allow:!0}))};(w=(j=i==null?void 0:i.current)==null?void 0:j.appFn)==null||w.updateItem(G,D==null?void 0:D.id),Y.success("\u6570\u636E\u5E93\u7F16\u8F91\u6210\u529F\uFF01")}else{const G={...m,...S,createBy:se,datasourceType:h,actions:Q("my-db").map((F,le)=>({...F,key:F.type==="divider"?`${F.key}_${S}`:F.key,allow:!0}))};(P=(k=i==null?void 0:i.current)==null?void 0:k.appFn)==null||P.addItem(G,{animate:!0,position:"start"}),Y.success("\u6570\u636E\u5E93\u521B\u5EFA\u6210\u529F\uFF01")}return S}}catch(m){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",m)}finally{X()}break;case"form:connect_test":return await oe(o);case"toolbar_test_empty":console.log("[DatabaseViewAdopter] toolbar_test_empty \u4E8B\u4EF6\u89E6\u53D1"),s(!e);break;default:(x=g.eventsEmit)==null||x.call(g,n,o);break}}return Z(De,{title:"\u6570\u636E\u5E93\u7BA1\u7406",children:[c(K,{ref:i,label:"",model:"tabs",defaultActiveId:f,views:_,dataSource:re,eventsEmit:J,status:R,CustomComponents:{EmptyData:ie,...l},styles:g.styles},"db"),c(Ce,{drawerTitle:A,drawerVisible:b,isConnectSuccess:u,dbType:h,dbInfo:D,handleDrawerClose:X,eventsEmit:J})]})};export{Pe as default};
package/databaseId.js CHANGED
@@ -1,26 +1,21 @@
1
- import{jsx as e,jsxs as v,Fragment as Ce}from"react/jsx-runtime";import{useMemo as P,useState as C,useRef as Fe,useCallback as j,useEffect as De}from"react";import{u as Me}from"./assets/index-CpW6Dhpp.js";import{Button as $,DashboardContainer as Se}from"@mxmweb/zui";import{Xviwer as be}from"@mxmweb/xviewer";/* empty css */import{PromptTempDesigner as Ae}from"@mxmweb/rtext";import{a as ze}from"./assets/index-NIGUFBhG.js";import{c as J}from"./assets/createLucideIcon-Bj5DlX2s.js";import{aA as X,aB as fe}from"./assets/index-CGHNxHzA.js";import{D as Be}from"./assets/index-Bt4pq4lJ.js";import{T as pe}from"./assets/index-JdQHnMoG.js";import{S as Le,a as _e,T as Ve}from"./assets/index-DkrRMiqX.js";import{X as me}from"./assets/x-CdZQbi--.js";import{B as Ee}from"./assets/index-Df9lUffW.js";import"react-dom";/**
1
+ import{jsx as e,jsxs as v,Fragment as Ce}from"react/jsx-runtime";import{useMemo as J,useState as C,useRef as Fe,useCallback as j,useEffect as De}from"react";import{u as Me}from"./assets/index-CpW6Dhpp.js";import{k as be,J as $,C as Se,S as ze,F as Le}from"./assets/index-CwZH-3RQ.js";import{c as ue,a as _e}from"./assets/index-CZ9KcyHq.js";/* empty css */import{T as Ae}from"./assets/index-CkrtMipy.js";import{aH as X,aL as fe,z as pe,aM as Ve}from"./assets/index-C_syaGTO.js";import{D as Be}from"./assets/index-DhLqP5fb.js";import{X as me}from"./assets/x-CRBeKR4J.js";import{a as Ne}from"./assets/index-CtbH8bkI.js";import{B as Ee}from"./assets/index-DHmv5xUB.js";import"./assets/styled-components.browser.esm-DPkS13KC.js";import"react-dom";/**
2
2
  * @license lucide-react v0.456.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Ne=J("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
6
+ */const Ue=ue("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
7
7
  * @license lucide-react v0.456.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Ue=J("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
11
+ */const Re=ue("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
12
12
  * @license lucide-react v0.456.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const Re=J("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
16
+ */const xe=ue("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
17
17
  * @license lucide-react v0.456.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const xe=J("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
22
- * @license lucide-react v0.456.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const He=J("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),Ge="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",$e="data:image/svg+xml,%3csvg%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42%2022C43.1046%2022%2044%2022.8954%2044%2024V42C44%2043.1046%2043.1046%2044%2042%2044H6C4.89543%2044%204%2043.1046%204%2042V24.0088C4%2022.9042%204.89543%2022.0078%206%2022.0078C7.10457%2022.0078%208%2022.9042%208%2024.0088V40H40V24C40%2022.8954%2040.8954%2022%2042%2022ZM24.0293%204.00195C24.0808%204.00272%2024.1322%204.00504%2024.1836%204.00977C24.1904%204.01042%2024.1973%204.011%2024.2041%204.01172C24.2673%204.01819%2024.3301%204.02757%2024.3926%204.04004C24.3939%204.04031%2024.3952%204.04075%2024.3965%204.04102C24.7693%204.11623%2025.125%204.29691%2025.4141%204.58594L34.4141%2013.5859C35.1951%2014.367%2035.1951%2015.633%2034.4141%2016.4141C33.633%2017.1951%2032.367%2017.1951%2031.5859%2016.4141L25.9922%2010.8203V32C25.9922%2033.1046%2025.0968%2034%2023.9922%2034C22.8876%2034%2021.9922%2033.1046%2021.9922%2032V10.8359L16.4141%2016.4141C15.633%2017.1951%2014.367%2017.1951%2013.5859%2016.4141C12.8049%2015.633%2012.8049%2014.367%2013.5859%2013.5859L22.498%204.67285C22.8016%204.33138%2023.2194%204.09559%2023.6924%204.02441C23.7122%204.02135%2023.732%204.01809%2023.752%204.01562C23.7862%204.01152%2023.8207%204.00919%2023.8555%204.00684C23.8887%204.00446%2023.9218%204.00268%2023.9551%204.00195C23.9674%204.00173%2023.9798%204%2023.9922%204C24.0046%204%2024.0169%204.00173%2024.0293%204.00195Z'%20fill='url(%23paint0_linear_4072_34663)'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_4072_34663'%20x1='4'%20y1='-7.25'%20x2='54.4707'%20y2='1.556'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%232B69FF'/%3e%3cstop%20offset='1'%20stop-color='%238F91FF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",we=({url:a,token:A,role:F,eventsEmit:m})=>{const o=ze.create({baseURL:a,timeout:1e6});return o.interceptors.request.use(t=>{let s=A;return!s&&!["user/login","user/kaptcha","user/regist"].some(l=>t.url.includes(l))?(m&&m("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(t.headers.Authorization=s||"",t.headers.userName=F==="\u672A\u767B\u5F55\u7528\u6237"?"":F,t)}),o.interceptors.response.use(t=>{const s=["user/kaptcha"],i=t.data;if(s.some(L=>t.config.url&&t.config.url.includes(L))||i.size&&i.type)return i;const{success:l,errorMsg:h,errorCode:c}=i;if(l)return i;m&&m("request:error_business",{errorCode:c,errorMsg:h||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:i})},t=>{var s,i,l,h,c,L,p,_,Y;if(t.message==="canceled")return Promise.reject(t);if(m){let q="request:error_network",Z={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:t};((s=t==null?void 0:t.response)==null?void 0:s.status)===401?(q="request:error_auth",Z={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:t,redirect:"/login"}):(((l=(i=t==null?void 0:t.response)==null?void 0:i.data)==null?void 0:l.errorCode)==="30013"||((c=(h=t==null?void 0:t.response)==null?void 0:h.data)==null?void 0:c.errorCode)==="30023")&&(q="request:error_business",Z={errorCode:(p=(L=t==null?void 0:t.response)==null?void 0:L.data)==null?void 0:p.errorCode,errorMsg:((Y=(_=t==null?void 0:t.response)==null?void 0:_.data)==null?void 0:Y.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:t}),m(q,Z)}return Promise.reject(t)}),{getTableList:async t=>{try{const s=await o.get(`/directDB/queryTableList/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("getTableList error:",s)}},getTableTreeList:async t=>{try{const s=await o.get(`/dataTable/queryTableFileTreeList/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("getTableTreeList error:",s)}},getDBDetailById:async(t,s)=>{const i=ge(s);try{const l=await o.get(`/${i}/queryDBInfo/${t}`),{success:h,data:c}=l;if(h)return c}catch(l){console.log("getDBDetailById error:",l)}},delTableById:async(t,s)=>{const i=ge(s);try{const l=await o.delete(`/${i}/deleteTable/${t}`),{success:h,data:c}=l;if(h)return c}catch(l){console.log("delTableById error:",l)}},delFileById:async t=>{try{const s=await o.delete(`/dataTable/deleteTableFileData/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("delFileById",s)}},parseFiles:async({fileIds:t,isGenDescription:s,tableDescriptionMap:i})=>{try{const l=await o.post("/dataTable/parseFiles",{fileIds:t,isGenDescription:s,tableDescriptionMap:i}),{success:h,data:c}=l;if(h)return c}catch(l){console.log("parseFiles error:",l)}},reParseFile:async t=>{try{const s=await o.post(`/dataTable/reParseFile/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("reParseFile error:",s)}},parseAppendFile:async({fileIds:t,tableId:s})=>{try{const i=await o.post("/dataTable/parseAppendFiles",{fileIds:t,tableId:s}),{success:l,data:h}=i;if(l)return h}catch(i){console.log("parseAppendFile error:",i)}},deleteUploadedFiles:async t=>{try{const s=await o.post("/dataTable/cancelUploadFile",{fileIds:t}),{success:i,data:l}=s;if(i)return l}catch(s){console.log("deleteUploadedFiles error:",s)}},getTableInfoById:async t=>{try{const s=await o.get(`/dataTable/queryTableMeta/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("getTableInfoById error:",s)}},updateTableInfo:async({tableId:t,description:s,businessName:i})=>{try{const l=await o.post("/dataTable/updateTableInfo",{tableId:t,businessName:i,description:s}),{success:h,data:c}=l;if(h)return c}catch(l){console.log("updateTableInfo error:",l)}},optimizeDesc:async t=>{try{const s=await o.get(`/genTableDescription/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("optimizeDesc error:",s)}}}},ge=a=>a=="DataTable"?"dataTable":"directDB",re='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',We={colors:{background:"#ffffff",border:"#e5e7eb",appBackground:"#ffffff",listBackground:"#ffffff",dashboardBackground:"#ffffff"},space:{padding:"0",margin:"md",shadow:"none"}},qe=({drawerTitle:a,drawerVisible:A,handleDrawerClose:F,dbId:m,tableInfo:o,token:k,url:O,role:E})=>{const z=P(()=>({id:"upload",layout:"vertical",formWidth:"670px",fields:[{id:"fileIds",name:"fileIds",type:"uploader",required:!1,defaultValue:"",uploaderConfig:{multiple:!o,accept:".csv,.xlsx,.xls",maxFiles:o?1:20,url:"http://10.15.12.13:8888/index/database/dataTable/uploadFile",autoUpload:!0,headers:{Authorization:k},queryParams:{databaseId:m,...o&&{tableId:o.tableId}},placeholder:v("div",{children:[e("div",{className:"text-lg font-bold",children:"\u70B9\u51FB\u6216\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u6B64\u5904\u4E0A\u4F20"}),v("div",{className:"flex flex-col gap-1.8 mt-[12px]",children:[e("div",{className:"text-[#888888] font-[12px]",children:"\u6570\u91CF\uFF1A\u226420 \u6587\u4EF6\uFF08\u5F53\u524D 0/20\uFF09"}),e("div",{className:"text-[#888888] font-[12px]",style:{width:"580px"},children:"\u683C\u5F0F\uFF1A.xlsx / .xls / .csv /\uFF08\u7B2C\u4E00\u884C\u662F\u8868\u5934\uFF0C\u5176\u4ED6\u884C\u662F\u6570\u636E\uFF1BCSV \u652F\u6301 UTF-8/GBK/GB2312\u2026\uFF09"}),e("div",{className:"text-[#888888] font-[12px]",children:"\u5355\u6587\u4EF6\u9650\u5236\uFF1A \u226410\u4E07\u884C\uFF0C\u226460\u5217\uFF08\u8D85\u51FA\u81EA\u52A8\u5FFD\u7565\uFF09\uFF1B \u6BCF\u6587\u4EF6 \u22641\u4E2ASheet"}),e("div",{className:"text-[#888888] font-[12px]",children:"\u4E0A\u4F20\u7684\u6587\u4EF6\uFF0C\u5982\u679C\u6709\u4E0D\u7B26\u5408\u6587\u672C\u683C\u5F0F\u7684\u6570\u636E\u7CFB\u7EDF\u81EA\u52A8\u5FFD\u7565"})]})]}),listName:o?"\u8FFD\u52A0\u6587\u4EF6":"\u4E0A\u4F20\u6587\u4EF6\u5217\u8868",icons:{dragUpload:e("img",{src:$e,width:40}),itemStatus:{pending:e("span",{style:{fontSize:"12px",color:"#6b7280"}}),uploading:e("span",{style:{fontSize:"12px",color:"#007bff"}}),success:e("span",{style:{fontSize:"12px",color:"#10b981"}}),error:e("span",{style:{fontSize:"12px",color:"#ef4444"},children:"\u5931\u8D25"})},fileType:{default:e(Ue,{size:20,style:{color:"#6b7280"}})}},...!o&&{buttons:[{label:"\u4F7F\u7528\u6A21\u7248",icon:e("img",{src:Ge}),mode:"text",onClick:()=>{i(!0)}}]},...!o&&{itemForm:[{type:"textarea",name:"description",counter:150,placeholder:"\u4E3A\u4E86\u63D0\u9AD8\u95EE\u7B54\u51C6\u786E\u7387\uFF0C\u8BF7\u8F93\u5165\u63CF\u8FF0"}]}}}]}),[o]),[M,g]=C(!1),[f,U]=C({}),G=Fe(null),[W,R]=C(!1),[B,t]=C([]),[s,i]=C(!1),[l,h]=C(re),[c,L]=C(null),[p,_]=C(re),[Y,q]=C(0),{parseFiles:Z,parseAppendFile:te,deleteUploadedFiles:ae}=we({url:O,token:k,role:E}),K=j(async(d,r,I)=>{var D;switch(console.log("[DynamicFormAdopter] \u4E8B\u4EF6:",d,r),d){case"form:ready":r.formRef?G.current=r.formRef:console.log("\u274C data.formRef \u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u8868\u5355\u5F15\u7528");break;case"form:submit":Q();break;case"form_field_change":U(b=>({...b,[r.fieldId]:r.value}));break;case"uploader:error":(D=r.item)!=null&&D.id?t(b=>[{id:r.item.id,status:r.item.status},...b]):X.error(r==null?void 0:r.message);break;case"uploader:success":t(b=>[{id:r.item.id,status:r.item.status},...b]);break;case"uploader:remove":const V=r.item.status;t(b=>b.filter(n=>n.id!==r.item.id)),V=="success"&&await ue([r.item.uploadApiRes]);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",d)}},[]),se=P(()=>({label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:"form-view",model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:"form-view",type:"form",size:"md",formWidth:z.formWidth,formConfig:{layout:z.layout,showReset:!1,showSubmit:!1,formWidth:z.formWidth,getFormData:()=>({...f,timestamp:new Date().toISOString(),formId:z.id}),onFieldChange:(d,r)=>{K("form_field_change",{fieldId:d,value:r},void 0)},onValidationError:d=>{K("form_validation_error",d,void 0)}}}],dataSource:[{id:z.id,fields:z.fields,defaultValues:{}}],eventsEmit:K,styles:{theme:We}}),[o,z]),Q=async()=>{var d;try{g(!0);const r=await G.current.getAllData();if(r.isValid){const I=(d=r.fields.find(D=>D.name=="fileIds"))==null?void 0:d.value;if(Array.isArray(I)&&(I==null?void 0:I.length)>0){let D;if(o)D=await te({fileIds:I.map(V=>V.uploadApiRes),tableId:o.id});else{const V={fileIds:I.map(b=>b.uploadApiRes),tableDescriptionMap:I.reduce((b,n)=>(b[n.uploadApiRes]=n.formData.description,b),{}),isGenDescription:W};D=await Z(V)}D&&F("refresh")}}}catch(r){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",r)}finally{F(),g(!1),R(!1)}},ee=async d=>{var r;try{const I=await G.current.getAllData();if(I.isValid){const D=(r=I.fields.find(V=>V.name=="fileIds"))==null?void 0:r.value;if(D&&Array.isArray(D)&&(D==null?void 0:D.length)>0){const V=D.map(n=>n.uploadApiRes),b=await ue(V)}}}catch(I){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",I)}finally{F(),R(!1)}},ue=async d=>{try{const r=await ae(d);if(r)return r}catch(r){console.error("\u5220\u9664\u6587\u4EF6\u6570\u636E\u5931\u8D25:",r)}},ie=d=>{R(d)},le=j(d=>{h(d),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",d)},[]),ne=j(d=>{L(()=>d),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),oe=j(async()=>{try{if(!c){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const d=c("pure_string");await navigator.clipboard.writeText(d),X.success("\u5DF2\u590D\u5236",1)}catch(d){console.error("\u590D\u5236\u5931\u8D25:",d)}finally{i(!1)}},[c]);return v(Be,{title:a,className:"database-upload-drawer",placement:"right",width:720,closeIcon:!1,extra:e(me,{size:20,color:"#888888",onClick:()=>ee(),className:"cursor-pointer"}),open:A,destroyOnHidden:!0,footer:v("div",{className:`flex ${o?"justify-end":"justify-between"} items-center`,children:[!o&&v("div",{className:"flex gap-2 items-center",children:[e("span",{children:"\u81EA\u52A8\u751F\u6210\u6570\u636E\u8868\u63CF\u8FF0"})," ",e(pe,{title:"\u81EA\u52A8\u751F\u6210\u5F00\u542F\u65F6\u5C06\u57FA\u4E8E\u6570\u636E\u667A\u80FD\u751F\u6210\u63CF\u8FF0\uFF1B\u82E5\u5F00\u542F\u6B64\u529F\u80FD\u5E76\u624B\u52A8\u586B\u5199\u63CF\u8FF0\uFF0C\u5C06\u4F18\u5148\u91C7\u7528\u7528\u6237\u586B\u5199\u7684\u5185\u5BB9\u3002",children:e(Ne,{size:14})}),e(Le,{onChange:ie})]}),v("div",{className:"flex self-end gap-3",children:[e($,{mode:"default",label:"\u53D6\u6D88",onClick:ee}),e($,{mode:"primary",label:"\u786E\u8BA4\u5BFC\u5165",loading:M,disabled:B.some(d=>d.status=="error"),onClick:async()=>{await Q()}})]})]}),children:[e(be,{...se},"upload-file"),e(fe,{title:v("div",{children:["\u6A21\u7248",e("span",{className:"text-[12px] text-[#888888] ml-[8px]",children:"\u5B8C\u6210\u7F16\u8F91\u540E\uFF0C\u53EF\u5C06\u6587\u672C\u590D\u5236\u7C98\u8D34\u5230\u76F8\u5E94\u63CF\u8FF0\u6846\u4E2D\u3002"})]}),width:672,destroyOnHidden:!0,open:s,onCancel:()=>i(!1),footer:v("div",{className:"flex justify-end items-center gap-3",children:[e($,{mode:"default",label:"\u91CD\u7F6E",onClick:()=>{_(re),q(d=>d+1)}}),e($,{mode:"primary",label:"\u590D\u5236",onClick:oe})]}),children:e(Ae,{data:p,onChange:le,onGetData:ne,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},Y)})]})},Ze="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",je="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_4199_8826)'%3e%3cpath%20d='M15.5554%2012.4444C14.9626%2013.0373%2014.6666%2013.6293%2014.6666%2014.2222C14.6666%2014.8151%2014.9626%2015.4071%2015.5554%2016C14.9626%2015.4071%2014.3706%2015.1111%2013.7777%2015.1111C13.1848%2015.1111%2012.5928%2015.4071%2011.9999%2016C12.5928%2015.4071%2012.8888%2014.8151%2012.8888%2014.2222C12.8888%2013.6293%2012.5928%2013.0373%2011.9999%2012.4444C12.5928%2013.0373%2013.1848%2013.3333%2013.7777%2013.3333C14.3706%2013.3333%2014.9626%2013.0373%2015.5554%2012.4444ZM14.6488%204.01778C15.1905%204.55954%2015.4948%205.29431%2015.4948%206.06044C15.4948%206.82658%2015.1905%207.56135%2014.6488%208.10311L7.735%2015.0169C7.46766%2015.2892%207.14901%2015.5058%206.79746%2015.6543C6.44592%2015.8028%206.06844%2015.8801%205.68684%2015.8819C5.30523%2015.8836%204.92706%2015.8097%204.57417%2015.6645C4.22127%2015.5193%203.90065%2015.3056%203.63081%2015.0357C3.36097%2014.7659%203.14727%2014.4453%203.00205%2014.0924C2.85682%2013.7395%202.78295%2013.3613%202.7847%2012.9797C2.78646%2012.5981%202.8638%2012.2206%203.01226%2011.8691C3.16072%2011.5176%203.37736%2011.1989%203.64967%2010.9316L3.95545%2010.6249L3.85145%2010.5244C3.30922%2010.0267%202.76522%209.77778%202.22211%209.77778C1.62923%209.77778%201.03722%2010.0738%200.444336%2010.6667C1.03722%2010.0738%201.33322%209.48178%201.33322%208.88889C1.33322%208.296%201.03722%207.704%200.444336%207.11111C1.03722%207.704%201.62923%208%202.22211%208C2.815%208%203.407%207.704%203.99989%207.11111C3.407%207.704%203.111%208.296%203.111%208.88889C3.111%209.46667%203.39278%2010.0444%203.95545%2010.6222L10.5634%204.01778C11.1052%203.47606%2011.84%203.17173%2012.6061%203.17173C13.3723%203.17173%2014.107%203.47606%2014.6488%204.01778ZM9.55189%206.91378L4.59189%2011.8738C4.30004%2012.1655%204.13603%2012.5612%204.13594%2012.9739C4.1359%2013.1782%204.17611%2013.3806%204.25426%2013.5694C4.33242%2013.7582%204.44699%2013.9297%204.59145%2014.0742C4.7359%2014.2187%204.9074%2014.3334%205.09617%2014.4116C5.28493%2014.4898%205.48725%2014.5301%205.69158%2014.5302C6.10424%2014.5303%206.50004%2014.3664%206.79189%2014.0747L11.7519%209.11378L9.55189%206.91378ZM11.5066%204.96089L10.495%205.97156L12.695%208.17156L13.7057%207.16C13.9846%206.86582%2014.1377%206.47437%2014.1323%206.069C14.1269%205.66364%2013.9635%205.27639%2013.6768%204.98973C13.3902%204.70306%2013.0029%204.53964%2012.5976%204.53425C12.1922%204.52887%2011.8007%204.68194%2011.5066%204.96089ZM9.59545%200C8.85589%200.740444%208.48434%201.48178%208.48434%202.22222C8.48434%202.96267%208.85589%203.704%209.59545%204.44444C8.85589%203.704%208.11456%203.33333%207.37322%203.33333C6.63367%203.33333%205.89234%203.704%205.151%204.44444C5.89234%203.704%206.26211%202.96267%206.26211%202.22222C6.26211%201.48178%205.89322%200.740444%205.15189%200C5.89322%200.740444%206.63456%201.11111%207.37411%201.11111C8.11545%201.11111%208.85678%200.740444%209.59634%200H9.59545Z'%20fill='%23055AFF'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_4199_8826'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",{confirm:Oe}=fe,Ye='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',Xe=({drawerTitle:a,drawerVisible:A,tableInfo:F,handleDrawerClose:m,optimizeDesc:o,eventsEmit:k})=>{const O=P(()=>(F==null?void 0:F.data.find(p=>p.columnId=="name").value)||"-",[F]),[E,z]=C(""),[M,g]=C(null),[f,U]=C(""),[G,W]=C(0),[R,B]=C(!1),[t,s]=C(!1);De(()=>{const p=(F==null?void 0:F.data.find(_=>_.columnId=="description").value)||"-";U(p)},[F]);const i=()=>{Oe({title:"\u4F60\u786E\u5B9A\u8981\u4F7F\u7528\u6A21\u677F\u5417\uFF1F",content:"\u8FD9\u5C06\u66FF\u6362\u4F60\u5F53\u524D\u5DF2\u586B\u5199\u7684\u5185\u5BB9\uFF0C\u4E14\u65E0\u6CD5\u64A4\u9500\u3002",okText:"\u786E\u8BA4\u66FF\u6362",cancelText:"\u53D6\u6D88",onOk(){U(Ye),W(p=>p+1)},onCancel(){console.log("Cancel")}})},l=j(p=>{z(p),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",p)},[]),h=j(p=>{g(()=>p),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),c=async()=>{try{B(!0);const p=await o(F.tableId);p&&(U(p),W(_=>_+1),B(!1))}catch{X.error("AI \u4F18\u5316\u5931\u8D25")}},L=j(()=>{if(!M){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const p=M("pure_string");k("table_info:update",p)},[M,k]);return v(Be,{title:a,placement:"right",width:720,onClose:m,closeIcon:!1,extra:e(me,{size:20,color:"#888888",onClick:m,className:"cursor-pointer"}),open:A,destroyOnHidden:!0,footer:e("div",{className:"flex justify-end items-center",children:v("div",{className:"flex self-end gap-3",children:[e($,{mode:"default",label:"\u53D6\u6D88",onClick:m}),e($,{mode:"primary",label:"\u786E\u8BA4",onClick:()=>L(),disabled:R})]})}),children:[e("div",{className:"mb-[10px] font-bold",children:O}),v("div",{className:"mb-[10px]",children:[e("span",{style:{color:"#FF3B30",marginRight:"4px"},children:"*"}),e("span",{children:"\u6570\u636E\u8868\u63CF\u8FF0"}),e("span",{className:"text-[#888888] ml-[4px]",children:"(\u8BF7\u51C6\u786E\u586B\u5199\u8868\u683C\u7684\u5E94\u7528\u573A\u666F\u63CF\u8FF0\uFF0C\u5927\u6A21\u578B\u5C06\u4F9D\u8D56\u6B64\u4FE1\u606F\u8BC6\u522B\u5E76\u6B63\u786E\u8C03\u7528\u8BE5\u6570\u636E\u8868\u3002)"})]}),e(Ae,{data:f,onChange:l,onGetData:h,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},G),v("div",{children:[e(_e,{open:t,onOpenChange:p=>s(!!p),content:e("div",{style:{width:"600px",margin:"10px",padding:"10px"},onClick:i,className:"hover:bg-gray-100 h-[80px] cursor-pointer rounded",children:"______\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86______\u573A\u666F\u7684\u6570\u636E\uFF0C\u5305\u542B______\u3001______\u3001______\u7B49\u4E3B\u8981\u5B57\u6BB5\uFF0C\u652F\u6301\u7528\u6237\u67E5\u8BE2______\u95EE\u9898(\u5927\u6982\u4ECB\u7ECD)\u5982\u679C\u6D89\u53CA\u591A\u8868\u5173\u8054\u67E5\u8BE2\uFF0C\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7______\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A______\u8868\u683C\u3002"}),title:v("div",{className:"flex justify-between items-center",style:{margin:"10px"},children:[e("div",{className:"text-[16px]",children:"\u6A21\u7248"}),e(me,{size:20,color:"#888888",onClick:()=>s(!1),className:"cursor-pointer"})]}),trigger:"click",destroyOnHidden:!0,placement:"bottomRight",getPopupContainer:p=>p,children:e("span",{children:e($,{mode:"text",icon:e("img",{src:Ze}),children:"\u4F7F\u7528\u6A21\u7248"})})}),e($,{onClick:c,mode:"text",icon:e("img",{src:je}),loading:R,children:"AI\u4F18\u5316"})]})]})},Ke=""+new URL("assets/empty.png",import.meta.url).href;var H=(a=>(a[a.DATE=0]="DATE",a[a.VIEW=1]="VIEW",a[a.ERROR=2]="ERROR",a[a.AUTHORIZE=3]="AUTHORIZE",a[a.DELETE=4]="DELETE",a[a.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",a[a.DOWNLOAD=6]="DOWNLOAD",a[a.EDIT=7]="EDIT",a[a.ADD=8]="ADD",a[a.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",a[a.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",a))(H||{}),ve=(a=>(a.GENERATING="generating",a.SUCCESS="success",a.FAIL="fail",a))(ve||{});const ce={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},Pe=a=>typeof a=="string"&&a in ce?ce[a]:ce.default,de=a=>{const{value:A,cell:F}=a;switch(F.columnId){case"importstatus":return A?e(pe,{title:"\u6709\u8FFD\u52A0\u5931\u8D25\u7684\u6587\u4EF6\uFF0C\u8BF7\u53CA\u65F6\u5904\u7406",children:e(Ve,{color:"red",bordered:!1,children:"\u8FFD\u52A0\u5931\u8D25"})}):e(Ce,{});case"status":const m=Pe(a.cell.statusType);return A=="\u5BFC\u5165\u5931\u8D25"?e(pe,{title:F.errorMsg,children:v("div",{className:"flex items-center gap-2",children:[e(Ee,{color:m,text:A}),e(xe,{size:14,color:"red"})]})}):e(Ee,{color:m,text:A});default:return e(Ce,{})}},he=[{statusType:"success",value:"\u5BFC\u5165\u6210\u529F",status:"30"},{statusType:"error",value:"\u5BFC\u5165\u5931\u8D25",status:"00"},{statusType:"default",value:"\u5F85\u5BFC\u5165",status:"10"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"20"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"11"}],Je=a=>{var m,o;const{cell:A,value:F}=a;return typeof F=="string"?e("div",{title:F,style:{maxWidth:240,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:F}):(m=A.tableMeta)!=null&&m.isGenDescription&&((o=A.tableMeta)==null?void 0:o.generateDescriptionStatus)=="generating"?v("div",{className:"flex items-center gap-1 text-[#84ADFF]",style:{color:"#84ADFF"},children:[e("span",{children:"\u751F\u6210\u4E2D"}),e(Re,{size:14})]}):"-"},Qe=({dbInfo:a,setDrawerTitle:A,setDrawerVisible:F,getBtnDisabled:m})=>v("div",{className:"flex flex-col items-center justify-center h-full",children:[e("div",{className:"text-xl font-semibold mb-3",children:e("img",{src:Ke,width:120})}),e("div",{className:"text-base mb-2",style:{color:"#888888"},children:"\u6682\u65E0\u6570\u636E\u6587\u4EF6"}),e("div",{className:"flex gap-3",children:e($,{mode:"primary",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",disabled:m&&m(8,a==null?void 0:a.permission),onClick:()=>{A("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),F(!0)}})})]}),{confirm:ye}=fe,Cu=a=>{const{url:A,token:F,role:m,id:o,dbType:k,CustomComponents:O,getBtnDisabled:E}=a,[z,M]=C({container:"ready",content:"ready"}),g=Fe(null),f=Fe(null),[U,G]=C(),[W,R]=C({}),[B,t]=C(),[s,i]=C(!1),[l,h]=C(""),[c,L]=C(),[p,_]=C(!1),[Y,q]=C(""),{getTableList:Z,delTableById:te,delFileById:ae,updateTableInfo:K,optimizeDesc:se,getTableTreeList:Q,reParseFile:ee,getDBDetailById:ue}=we({url:A,token:F,role:m,eventsEmit:a.eventsEmit});De(()=>(o&&k&&(M(n=>({...n,container:"loading"})),ie()),()=>{f.current&&(clearTimeout(f.current),f.current=null)}),[o,k]);const ie=async()=>{try{const n=await ue(o,k);n&&(t(n),M(u=>({...u,container:"ready",content:"loading"})))}catch(n){console.log("[TableApiError] getDBInfo:",n)}await b()},le=async()=>{try{if(k=="DirectDB"){const n=await Z(o);if(n){const u=oe(n);return G(u||[]),M(w=>({...w,content:"ready"})),u||[]}else M(u=>({...u,content:"error"}))}else{const n=await Q(o);if(n){const u=ne(n);return G(u||[]),M(w=>({...w,content:"ready"})),u||[]}else M(u=>({...u,content:"error"}))}}catch(n){console.log("[TableApiError] getTableList:",n)}};function ne(n){return(n||[]).map((u,w)=>{var S,N;let y=he.find(x=>x.status==u.status);const T=u.children.some(x=>x.status=="00");return{id:u.fileId.toString(),tableId:u.tableId,data:[{columnId:"name",value:(u==null?void 0:u.originalFilename)||"-",type:"label"},{columnId:"description",value:(S=u==null?void 0:u.tableMeta)==null?void 0:S.description,type:"customized",tableMeta:u==null?void 0:u.tableMeta},{columnId:"count",value:`${u.rowCount}\u884C\uFF0C${u.columnCount}\u5217`,type:"text"},{columnId:"status",...y,type:"customized",errorMsg:u.errorMsg},{columnId:"importstatus",value:T,type:"customized"},{columnId:"createdAt",value:u.gmtCreate,type:"date"},{columnId:"updatedAt",value:u.gmtModified,type:"date"},...u.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(H.VIEW,u.permission)},{columnId:"actions",value:"edit",label:"\u4FEE\u6539\u914D\u7F6E",type:"action",disabled:E&&E(H.EDIT,u.permission)},{columnId:"actions",value:"addData",label:"\u8FFD\u52A0\u6570\u636E",type:"action",disabled:E&&E(H.EDIT,u.permission)}]:[],...u.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action"}]:[],{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",disabled:E&&E(H.DELETE,u.permission)}],expanded:!1,...u.children&&((N=u.children)==null?void 0:N.length)>0&&{children:[...(u.children||[]).map(x=>{const ke=he.find(Te=>Te.status==x.status),Ie=[{columnId:"name",value:x.originalFilename,type:"text"},{columnId:"count",value:`${x.rowCount}\u884C\uFF0C${x.columnCount}\u5217`,type:"text"},{columnId:"status",...ke,errorMsg:x.errorMsg,type:"customized"},{columnId:"createdAt",value:x.gmtCreate,type:"date"},{columnId:"updatedAt",value:x.gmtModified,type:"date"},...x.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(H.VIEW,x.permission)}]:[],...x.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action",disabled:E&&E(H.ADD,x.permission)}]:[],{columnId:"actions",value:"delete_sub",label:"\u5220\u9664",type:"action",disabled:E&&E(H.DELETE,x.permission)}];return{id:x.fileId.toString(),tableId:x.tableId,data:Ie}})]}}})}function oe(n){return(n||[]).map((u,w)=>({id:u.id||Me(8),data:[{columnId:"name",value:u.physicalName},{columnId:"cnname",value:u.businessName},{columnId:"colcount",value:u.columnCount},{columnId:"count",value:`${u.rowCount}\u884C\uFF0C${u.columnCount}\u5217`},{columnId:"actions",value:"view",label:"\u67E5\u770B",disabled:E&&E(H.VIEW,u.permission)}]}))}async function d(n,u,w){switch(console.log("[adopter] mergedEventsEmit",n,u,w),n){case"table_action_delete":{try{ye({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u8BE5\u6570\u636E\u8868\u53CA\u5176\u8FFD\u52A0\u6570\u636E\u90FD\u5C06\u88AB\u5220\u9664\u4E14\u65E0\u6CD5\u6062\u590D",icon:e(xe,{color:"#FF4D4F",className:"mr-[8px]"}),okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await te(u.tableId,k)&&(g!=null&&g.current)&&(g==null||g.current.appFn.removeItem(u.id),X.success("\u5220\u9664\u6210\u529F"))}})}catch{console.log("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25")}break}case"table_action_edit":{q("\u4FEE\u6539\u6570\u636E\u914D\u7F6E"),_(!0),L(u);break}case"toolbar_upload":{h("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),i(!0);break}case"table_action_addData":{h("\u8FFD\u52A0\u6570\u636E"),i(!0),L(u);break}case"table_action_reValidate":{await ee(u.id)&&(f.current&&(clearTimeout(f.current),f.current=null),await b());break}case"table_info:update":{try{if(c!=null&&c.id){const y=(c==null?void 0:c.data.find(S=>S.columnId=="name").value)||"-";if(await K({tableId:c.tableId,description:u,businessName:y})&&(g!=null&&g.current)){const S={...c,data:c.data.map(N=>N.columnId=="description"?{...N,value:u}:N)};g==null||g.current.appFn.updateItem(S,c.id),X.success("\u4FEE\u6539\u914D\u7F6E\u6210\u529F")}}}catch(y){console.error("\u4FEE\u6539\u914D\u7F6E\u5931\u8D25",y)}finally{D()}break}case"table_action_delete_sub":{try{ye({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){const{id:y,tableId:T}=u;await ae(u.id)&&(g!=null&&g.current)&&(R(N=>({...N,[T]:[...N[T]||[],y]})),u.data.find(N=>N.status=="00")&&(f.current&&(clearTimeout(f.current),f.current=null),b()),w.removeItem(y,T),X.success("\u8FFD\u52A0\u6587\u4EF6\u6570\u636E\u5220\u9664\u6210\u529F"))}})}catch{console.log("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25")}break}case"toolbar_auth":{typeof a.eventsEmit=="function"&&a.eventsEmit("toolbar_auth",B);break}default:typeof a.eventsEmit=="function"&&a.eventsEmit(n,u);break}}const r=P(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"direct-table-view",views:[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"direct-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,columns:[{id:"name",title:"\u6570\u636E\u8868\u82F1\u6587\u540D\u79F0",type:"label"},{id:"cnname",title:"\u6570\u636E\u8868\u4E2D\u6587\u540D\u79F0",type:"label"},{id:"colcount",title:"\u5B57\u6BB5\u6570",type:"text"},{id:"count",title:"\u6570\u636E\u91CF",type:"text"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description"],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}]}),[U,k]),I=P(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"data-table-view",views:[{label:"\u4E0A\u4F20\u6570\u636E\u5217\u8868",id:"data-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"name",title:"\u6587\u4EF6\u540D",type:"label",tip:"\u6587\u4EF6\u540D"},{id:"description",title:"\u63CF\u8FF0",type:"customized",component:e(Je,{}),helpText:"\u6253\u5F00\u81EA\u52A8\u751F\u6210\u63CF\u8FF0\u5F00\u5173\u540E\uFF0C\u82E5\u63CF\u8FF0\u672A\u6B63\u5E38\u751F\u6210\uFF0C\u5219\u63CF\u8FF0\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u5982\u60A8\u4ECD\u7136\u9700\u8981\u63CF\u8FF0\uFF0C\u5219\u9700\u8981\u624B\u52A8\u6DFB\u52A0"},{id:"count",title:"\u6570\u636E\u91CF",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",component:e(de,{})},{id:"importstatus",title:"\u8FFD\u52A0\u63D0\u793A",type:"customized",component:e(de,{})},{id:"createdAt",title:"\u521B\u5EFA\u65F6\u95F4",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{id:"updatedAt",title:"\u66F4\u65B0\u65F6\u95F4",type:"date",tip:"\u66F4\u65B0\u65F6\u95F4"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"button",key:"upload",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",btnType:"primary",disabled:E&&E(H.ADD,B==null?void 0:B.permission),icon:e(He,{size:12})},{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description",["name"]],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}],subTableConfig:{type:"table",allowMultiSelect:!1,viewBehavior:"pagination",viewPageSize:5,columns:[{title:"\u8FFD\u52A0\u6587\u4EF6\u540D",id:"name",type:"text",tip:"\u8FFD\u52A0\u6587\u4EF6\u540D"},{title:"\u6570\u636E\u91CF",id:"count",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",tip:"\u5BFC\u5165\u72B6\u6001",component:e(de,{})},{title:"\u521B\u5EFA\u65F6\u95F4",id:"createdAt",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{title:"\u66F4\u6539\u65F6\u95F4",id:"updatedAt",type:"date",tip:"\u66F4\u6539\u65F6\u95F4"},{title:"\u64CD\u4F5C",id:"actions",type:"action"}]},subTablePendingIds:W,onSubTableRowAnimationComplete:(n,u)=>{R(w=>({...w,[n]:(w[n]||[]).filter(y=>y!==u)}))}}),[W,U,k,B]),D=n=>{i(!1),_(!1),L(void 0),n=="refresh"&&(f.current&&(clearTimeout(f.current),f.current=null),b())};function V(n){var u;if(!Array.isArray(n))return!0;for(const w of n){if(w.data){const y=w.data.find(S=>S.columnId==="status"),T=w.data.find(S=>S.columnId==="description");if(y&&(y.status==="20"||y.status==="11"||((u=T==null?void 0:T.tableMeta)==null?void 0:u.generateDescriptionStatus)==ve.GENERATING))return!1}if(Array.isArray(w.children)){for(const y of w.children)if(y.data){const T=y.data.find(S=>S.columnId==="status");if(T&&(T.status==="20"||T.status==="11"))return!1}}}return!0}const b=async()=>{const n=await le();V(n||[])?f.current&&(clearTimeout(f.current),f.current=null):(f.current&&(clearTimeout(f.current),f.current=null),f.current=setTimeout(()=>{b()},5e3))};return v(Se,{title:B==null?void 0:B.name,description:(B==null?void 0:B.description)||"-",goBack:()=>{var n;(n=a.eventsEmit)==null||n.call(a,"goBack",{})},children:[e(be,{dataSource:U,ref:g,eventsEmit:d,status:z,CustomComponents:{EmptyData:()=>e(Qe,{dbInfo:B,setDrawerTitle:h,setDrawerVisible:i,getBtnDisabled:E}),...O},...k=="DataTable"?I:r}),e(qe,{drawerTitle:l,drawerVisible:s,handleDrawerClose:D,dbId:o,token:F,url:A,role:m,tableInfo:c}),e(Xe,{drawerTitle:Y,drawerVisible:p,handleDrawerClose:D,tableInfo:c,optimizeDesc:se,eventsEmit:d})]})};export{Cu as default};
21
+ */const He=ue("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),Ge="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",$e="data:image/svg+xml,%3csvg%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42%2022C43.1046%2022%2044%2022.8954%2044%2024V42C44%2043.1046%2043.1046%2044%2042%2044H6C4.89543%2044%204%2043.1046%204%2042V24.0088C4%2022.9042%204.89543%2022.0078%206%2022.0078C7.10457%2022.0078%208%2022.9042%208%2024.0088V40H40V24C40%2022.8954%2040.8954%2022%2042%2022ZM24.0293%204.00195C24.0808%204.00272%2024.1322%204.00504%2024.1836%204.00977C24.1904%204.01042%2024.1973%204.011%2024.2041%204.01172C24.2673%204.01819%2024.3301%204.02757%2024.3926%204.04004C24.3939%204.04031%2024.3952%204.04075%2024.3965%204.04102C24.7693%204.11623%2025.125%204.29691%2025.4141%204.58594L34.4141%2013.5859C35.1951%2014.367%2035.1951%2015.633%2034.4141%2016.4141C33.633%2017.1951%2032.367%2017.1951%2031.5859%2016.4141L25.9922%2010.8203V32C25.9922%2033.1046%2025.0968%2034%2023.9922%2034C22.8876%2034%2021.9922%2033.1046%2021.9922%2032V10.8359L16.4141%2016.4141C15.633%2017.1951%2014.367%2017.1951%2013.5859%2016.4141C12.8049%2015.633%2012.8049%2014.367%2013.5859%2013.5859L22.498%204.67285C22.8016%204.33138%2023.2194%204.09559%2023.6924%204.02441C23.7122%204.02135%2023.732%204.01809%2023.752%204.01562C23.7862%204.01152%2023.8207%204.00919%2023.8555%204.00684C23.8887%204.00446%2023.9218%204.00268%2023.9551%204.00195C23.9674%204.00173%2023.9798%204%2023.9922%204C24.0046%204%2024.0169%204.00173%2024.0293%204.00195Z'%20fill='url(%23paint0_linear_4072_34663)'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_4072_34663'%20x1='4'%20y1='-7.25'%20x2='54.4707'%20y2='1.556'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%232B69FF'/%3e%3cstop%20offset='1'%20stop-color='%238F91FF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",we=({url:a,token:A,role:F,eventsEmit:m})=>{const o=_e.create({baseURL:a,timeout:1e6});return o.interceptors.request.use(t=>{let s=A;return!s&&!["user/login","user/kaptcha","user/regist"].some(l=>t.url.includes(l))?(m&&m("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(t.headers.Authorization=s||"",t.headers.userName=F==="\u672A\u767B\u5F55\u7528\u6237"?"":F,t)}),o.interceptors.response.use(t=>{const s=["user/kaptcha"],i=t.data;if(s.some(L=>t.config.url&&t.config.url.includes(L))||i.size&&i.type)return i;const{success:l,errorMsg:h,errorCode:c}=i;if(l)return i;m&&m("request:error_business",{errorCode:c,errorMsg:h||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:i})},t=>{var s,i,l,h,c,L,p,_,Y;if(t.message==="canceled")return Promise.reject(t);if(m){let q="request:error_network",Z={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:t};((s=t==null?void 0:t.response)==null?void 0:s.status)===401?(q="request:error_auth",Z={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:t,redirect:"/login"}):(((l=(i=t==null?void 0:t.response)==null?void 0:i.data)==null?void 0:l.errorCode)==="30013"||((c=(h=t==null?void 0:t.response)==null?void 0:h.data)==null?void 0:c.errorCode)==="30023")&&(q="request:error_business",Z={errorCode:(p=(L=t==null?void 0:t.response)==null?void 0:L.data)==null?void 0:p.errorCode,errorMsg:((Y=(_=t==null?void 0:t.response)==null?void 0:_.data)==null?void 0:Y.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:t}),m(q,Z)}return Promise.reject(t)}),{getTableList:async t=>{try{const s=await o.get(`/directDB/queryTableList/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("getTableList error:",s)}},getTableTreeList:async t=>{try{const s=await o.get(`/dataTable/queryTableFileTreeList/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("getTableTreeList error:",s)}},getDBDetailById:async(t,s)=>{const i=ge(s);try{const l=await o.get(`/${i}/queryDBInfo/${t}`),{success:h,data:c}=l;if(h)return c}catch(l){console.log("getDBDetailById error:",l)}},delTableById:async(t,s)=>{const i=ge(s);try{const l=await o.delete(`/${i}/deleteTable/${t}`),{success:h,data:c}=l;if(h)return c}catch(l){console.log("delTableById error:",l)}},delFileById:async t=>{try{const s=await o.delete(`/dataTable/deleteTableFileData/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("delFileById",s)}},parseFiles:async({fileIds:t,isGenDescription:s,tableDescriptionMap:i})=>{try{const l=await o.post("/dataTable/parseFiles",{fileIds:t,isGenDescription:s,tableDescriptionMap:i}),{success:h,data:c}=l;if(h)return c}catch(l){console.log("parseFiles error:",l)}},reParseFile:async t=>{try{const s=await o.post(`/dataTable/reParseFile/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("reParseFile error:",s)}},parseAppendFile:async({fileIds:t,tableId:s})=>{try{const i=await o.post("/dataTable/parseAppendFiles",{fileIds:t,tableId:s}),{success:l,data:h}=i;if(l)return h}catch(i){console.log("parseAppendFile error:",i)}},deleteUploadedFiles:async t=>{try{const s=await o.post("/dataTable/cancelUploadFile",{fileIds:t}),{success:i,data:l}=s;if(i)return l}catch(s){console.log("deleteUploadedFiles error:",s)}},getTableInfoById:async t=>{try{const s=await o.get(`/dataTable/queryTableMeta/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("getTableInfoById error:",s)}},updateTableInfo:async({tableId:t,description:s,businessName:i})=>{try{const l=await o.post("/dataTable/updateTableInfo",{tableId:t,businessName:i,description:s}),{success:h,data:c}=l;if(h)return c}catch(l){console.log("updateTableInfo error:",l)}},optimizeDesc:async t=>{try{const s=await o.get(`/genTableDescription/${t}`),{success:i,data:l}=s;if(i)return l}catch(s){console.log("optimizeDesc error:",s)}}}},ge=a=>a=="DataTable"?"dataTable":"directDB",re='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',We={colors:{background:"#ffffff",border:"#e5e7eb",appBackground:"#ffffff",listBackground:"#ffffff",dashboardBackground:"#ffffff"},space:{padding:"0",margin:"md",shadow:"none"}},qe=({drawerTitle:a,drawerVisible:A,handleDrawerClose:F,dbId:m,tableInfo:o,token:k,url:O,role:E})=>{const z=J(()=>({id:"upload",layout:"vertical",formWidth:"670px",fields:[{id:"fileIds",name:"fileIds",type:"uploader",required:!1,defaultValue:"",uploaderConfig:{multiple:!o,accept:".csv,.xlsx,.xls",maxFiles:o?1:20,url:"http://10.15.12.13:8888/index/database/dataTable/uploadFile",autoUpload:!0,headers:{Authorization:k},queryParams:{databaseId:m,...o&&{tableId:o.tableId}},placeholder:v("div",{children:[e("div",{className:"text-lg font-bold",children:"\u70B9\u51FB\u6216\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u6B64\u5904\u4E0A\u4F20"}),v("div",{className:"flex flex-col gap-1.8 mt-[12px]",children:[e("div",{className:"text-[#888888] font-[12px]",children:"\u6570\u91CF\uFF1A\u226420 \u6587\u4EF6\uFF08\u5F53\u524D 0/20\uFF09"}),e("div",{className:"text-[#888888] font-[12px]",style:{width:"580px"},children:"\u683C\u5F0F\uFF1A.xlsx / .xls / .csv /\uFF08\u7B2C\u4E00\u884C\u662F\u8868\u5934\uFF0C\u5176\u4ED6\u884C\u662F\u6570\u636E\uFF1BCSV \u652F\u6301 UTF-8/GBK/GB2312\u2026\uFF09"}),e("div",{className:"text-[#888888] font-[12px]",children:"\u5355\u6587\u4EF6\u9650\u5236\uFF1A \u226410\u4E07\u884C\uFF0C\u226460\u5217\uFF08\u8D85\u51FA\u81EA\u52A8\u5FFD\u7565\uFF09\uFF1B \u6BCF\u6587\u4EF6 \u22641\u4E2ASheet"}),e("div",{className:"text-[#888888] font-[12px]",children:"\u4E0A\u4F20\u7684\u6587\u4EF6\uFF0C\u5982\u679C\u6709\u4E0D\u7B26\u5408\u6587\u672C\u683C\u5F0F\u7684\u6570\u636E\u7CFB\u7EDF\u81EA\u52A8\u5FFD\u7565"})]})]}),listName:o?"\u8FFD\u52A0\u6587\u4EF6":"\u4E0A\u4F20\u6587\u4EF6\u5217\u8868",icons:{dragUpload:e("img",{src:$e,width:40}),itemStatus:{pending:e("span",{style:{fontSize:"12px",color:"#6b7280"}}),uploading:e("span",{style:{fontSize:"12px",color:"#007bff"}}),success:e("span",{style:{fontSize:"12px",color:"#10b981"}}),error:e("span",{style:{fontSize:"12px",color:"#ef4444"},children:"\u5931\u8D25"})},fileType:{default:e(Ue,{size:20,style:{color:"#6b7280"}})}},...!o&&{buttons:[{label:"\u4F7F\u7528\u6A21\u7248",icon:e("img",{src:Ge}),mode:"text",onClick:()=>{i(!0)}}]},...!o&&{itemForm:[{type:"textarea",name:"description",counter:150,placeholder:"\u4E3A\u4E86\u63D0\u9AD8\u95EE\u7B54\u51C6\u786E\u7387\uFF0C\u8BF7\u8F93\u5165\u63CF\u8FF0"}]}}}]}),[o]),[M,g]=C(!1),[f,U]=C({}),G=Fe(null),[W,R]=C(!1),[B,t]=C([]),[s,i]=C(!1),[l,h]=C(re),[c,L]=C(null),[p,_]=C(re),[Y,q]=C(0),{parseFiles:Z,parseAppendFile:te,deleteUploadedFiles:ae}=we({url:O,token:k,role:E}),K=j(async(d,r,I)=>{var D;switch(console.log("[DynamicFormAdopter] \u4E8B\u4EF6:",d,r),d){case"form:ready":r.formRef?G.current=r.formRef:console.log("\u274C data.formRef \u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u8868\u5355\u5F15\u7528");break;case"form:submit":P();break;case"form_field_change":U(b=>({...b,[r.fieldId]:r.value}));break;case"uploader:error":(D=r.item)!=null&&D.id?t(b=>[{id:r.item.id,status:r.item.status},...b]):X.error(r==null?void 0:r.message);break;case"uploader:success":t(b=>[{id:r.item.id,status:r.item.status},...b]);break;case"uploader:remove":const V=r.item.status;t(b=>b.filter(n=>n.id!==r.item.id)),V=="success"&&await ee([r.item.uploadApiRes]);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",d)}},[]),se=J(()=>({label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:"form-view",model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:"form-view",type:"form",size:"md",formWidth:z.formWidth,formConfig:{layout:z.layout,showReset:!1,showSubmit:!1,formWidth:z.formWidth,getFormData:()=>({...f,timestamp:new Date().toISOString(),formId:z.id}),onFieldChange:(d,r)=>{K("form_field_change",{fieldId:d,value:r},void 0)},onValidationError:d=>{K("form_validation_error",d,void 0)}}}],dataSource:[{id:z.id,fields:z.fields,defaultValues:{}}],eventsEmit:K,styles:{theme:We}}),[o,z]),P=async()=>{var d;try{g(!0);const r=await G.current.getAllData();if(r.isValid){const I=(d=r.fields.find(D=>D.name=="fileIds"))==null?void 0:d.value;if(Array.isArray(I)&&(I==null?void 0:I.length)>0){let D;if(o)D=await te({fileIds:I.map(V=>V.uploadApiRes),tableId:o.id});else{const V={fileIds:I.map(b=>b.uploadApiRes),tableDescriptionMap:I.reduce((b,n)=>(b[n.uploadApiRes]=n.formData.description,b),{}),isGenDescription:W};D=await Z(V)}D&&F("refresh")}}}catch(r){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",r)}finally{F(),g(!1),R(!1)}},Q=async d=>{var r;try{const I=await G.current.getAllData();if(I.isValid){const D=(r=I.fields.find(V=>V.name=="fileIds"))==null?void 0:r.value;if(D&&Array.isArray(D)&&(D==null?void 0:D.length)>0){const V=D.map(n=>n.uploadApiRes),b=await ee(V)}}}catch(I){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",I)}finally{F(),R(!1)}},ee=async d=>{try{const r=await ae(d);if(r)return r}catch(r){console.error("\u5220\u9664\u6587\u4EF6\u6570\u636E\u5931\u8D25:",r)}},ie=d=>{R(d)},le=j(d=>{h(d),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",d)},[]),ne=j(d=>{L(()=>d),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),oe=j(async()=>{try{if(!c){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const d=c("pure_string");await navigator.clipboard.writeText(d),X.success("\u5DF2\u590D\u5236",1)}catch(d){console.error("\u590D\u5236\u5931\u8D25:",d)}finally{i(!1)}},[c]);return v(Be,{title:a,className:"database-upload-drawer",placement:"right",width:720,closeIcon:!1,extra:e(me,{size:20,color:"#888888",onClick:()=>Q(),className:"cursor-pointer"}),open:A,destroyOnHidden:!0,footer:v("div",{className:`flex ${o?"justify-end":"justify-between"} items-center`,children:[!o&&v("div",{className:"flex gap-2 items-center",children:[e("span",{children:"\u81EA\u52A8\u751F\u6210\u6570\u636E\u8868\u63CF\u8FF0"})," ",e(pe,{title:"\u81EA\u52A8\u751F\u6210\u5F00\u542F\u65F6\u5C06\u57FA\u4E8E\u6570\u636E\u667A\u80FD\u751F\u6210\u63CF\u8FF0\uFF1B\u82E5\u5F00\u542F\u6B64\u529F\u80FD\u5E76\u624B\u52A8\u586B\u5199\u63CF\u8FF0\uFF0C\u5C06\u4F18\u5148\u91C7\u7528\u7528\u6237\u586B\u5199\u7684\u5185\u5BB9\u3002",children:e(Se,{size:14})}),e(ze,{onChange:ie})]}),v("div",{className:"flex self-end gap-3",children:[e($,{mode:"default",label:"\u53D6\u6D88",onClick:Q}),e($,{mode:"primary",label:"\u786E\u8BA4\u5BFC\u5165",loading:M,disabled:B.some(d=>d.status=="error"),onClick:async()=>{await P()}})]})]}),children:[e(be,{...se},"upload-file"),e(fe,{title:v("div",{children:["\u6A21\u7248",e("span",{className:"text-[12px] text-[#888888] ml-[8px]",children:"\u5B8C\u6210\u7F16\u8F91\u540E\uFF0C\u53EF\u5C06\u6587\u672C\u590D\u5236\u7C98\u8D34\u5230\u76F8\u5E94\u63CF\u8FF0\u6846\u4E2D\u3002"})]}),width:672,destroyOnHidden:!0,open:s,onCancel:()=>i(!1),footer:v("div",{className:"flex justify-end items-center gap-3",children:[e($,{mode:"default",label:"\u91CD\u7F6E",onClick:()=>{_(re),q(d=>d+1)}}),e($,{mode:"primary",label:"\u590D\u5236",onClick:oe})]}),children:e(Ae,{data:p,onChange:le,onGetData:ne,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},Y)})]})},Ze="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",je="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_4199_8826)'%3e%3cpath%20d='M15.5554%2012.4444C14.9626%2013.0373%2014.6666%2013.6293%2014.6666%2014.2222C14.6666%2014.8151%2014.9626%2015.4071%2015.5554%2016C14.9626%2015.4071%2014.3706%2015.1111%2013.7777%2015.1111C13.1848%2015.1111%2012.5928%2015.4071%2011.9999%2016C12.5928%2015.4071%2012.8888%2014.8151%2012.8888%2014.2222C12.8888%2013.6293%2012.5928%2013.0373%2011.9999%2012.4444C12.5928%2013.0373%2013.1848%2013.3333%2013.7777%2013.3333C14.3706%2013.3333%2014.9626%2013.0373%2015.5554%2012.4444ZM14.6488%204.01778C15.1905%204.55954%2015.4948%205.29431%2015.4948%206.06044C15.4948%206.82658%2015.1905%207.56135%2014.6488%208.10311L7.735%2015.0169C7.46766%2015.2892%207.14901%2015.5058%206.79746%2015.6543C6.44592%2015.8028%206.06844%2015.8801%205.68684%2015.8819C5.30523%2015.8836%204.92706%2015.8097%204.57417%2015.6645C4.22127%2015.5193%203.90065%2015.3056%203.63081%2015.0357C3.36097%2014.7659%203.14727%2014.4453%203.00205%2014.0924C2.85682%2013.7395%202.78295%2013.3613%202.7847%2012.9797C2.78646%2012.5981%202.8638%2012.2206%203.01226%2011.8691C3.16072%2011.5176%203.37736%2011.1989%203.64967%2010.9316L3.95545%2010.6249L3.85145%2010.5244C3.30922%2010.0267%202.76522%209.77778%202.22211%209.77778C1.62923%209.77778%201.03722%2010.0738%200.444336%2010.6667C1.03722%2010.0738%201.33322%209.48178%201.33322%208.88889C1.33322%208.296%201.03722%207.704%200.444336%207.11111C1.03722%207.704%201.62923%208%202.22211%208C2.815%208%203.407%207.704%203.99989%207.11111C3.407%207.704%203.111%208.296%203.111%208.88889C3.111%209.46667%203.39278%2010.0444%203.95545%2010.6222L10.5634%204.01778C11.1052%203.47606%2011.84%203.17173%2012.6061%203.17173C13.3723%203.17173%2014.107%203.47606%2014.6488%204.01778ZM9.55189%206.91378L4.59189%2011.8738C4.30004%2012.1655%204.13603%2012.5612%204.13594%2012.9739C4.1359%2013.1782%204.17611%2013.3806%204.25426%2013.5694C4.33242%2013.7582%204.44699%2013.9297%204.59145%2014.0742C4.7359%2014.2187%204.9074%2014.3334%205.09617%2014.4116C5.28493%2014.4898%205.48725%2014.5301%205.69158%2014.5302C6.10424%2014.5303%206.50004%2014.3664%206.79189%2014.0747L11.7519%209.11378L9.55189%206.91378ZM11.5066%204.96089L10.495%205.97156L12.695%208.17156L13.7057%207.16C13.9846%206.86582%2014.1377%206.47437%2014.1323%206.069C14.1269%205.66364%2013.9635%205.27639%2013.6768%204.98973C13.3902%204.70306%2013.0029%204.53964%2012.5976%204.53425C12.1922%204.52887%2011.8007%204.68194%2011.5066%204.96089ZM9.59545%200C8.85589%200.740444%208.48434%201.48178%208.48434%202.22222C8.48434%202.96267%208.85589%203.704%209.59545%204.44444C8.85589%203.704%208.11456%203.33333%207.37322%203.33333C6.63367%203.33333%205.89234%203.704%205.151%204.44444C5.89234%203.704%206.26211%202.96267%206.26211%202.22222C6.26211%201.48178%205.89322%200.740444%205.15189%200C5.89322%200.740444%206.63456%201.11111%207.37411%201.11111C8.11545%201.11111%208.85678%200.740444%209.59634%200H9.59545Z'%20fill='%23055AFF'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_4199_8826'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",{confirm:Oe}=fe,Ye='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',Xe=({drawerTitle:a,drawerVisible:A,tableInfo:F,handleDrawerClose:m,optimizeDesc:o,eventsEmit:k})=>{const O=J(()=>(F==null?void 0:F.data.find(p=>p.columnId=="name").value)||"-",[F]),[E,z]=C(""),[M,g]=C(null),[f,U]=C(""),[G,W]=C(0),[R,B]=C(!1),[t,s]=C(!1);De(()=>{const p=(F==null?void 0:F.data.find(_=>_.columnId=="description").value)||"-";U(p)},[F]);const i=()=>{Oe({title:"\u4F60\u786E\u5B9A\u8981\u4F7F\u7528\u6A21\u677F\u5417\uFF1F",content:"\u8FD9\u5C06\u66FF\u6362\u4F60\u5F53\u524D\u5DF2\u586B\u5199\u7684\u5185\u5BB9\uFF0C\u4E14\u65E0\u6CD5\u64A4\u9500\u3002",okText:"\u786E\u8BA4\u66FF\u6362",cancelText:"\u53D6\u6D88",onOk(){U(Ye),W(p=>p+1)},onCancel(){console.log("Cancel")}})},l=j(p=>{z(p),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",p)},[]),h=j(p=>{g(()=>p),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),c=async()=>{try{B(!0);const p=await o(F.tableId);p&&(U(p),W(_=>_+1),B(!1))}catch{X.error("AI \u4F18\u5316\u5931\u8D25")}},L=j(()=>{if(!M){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const p=M("pure_string");k("table_info:update",p)},[M,k]);return v(Be,{title:a,placement:"right",width:720,onClose:m,closeIcon:!1,extra:e(me,{size:20,color:"#888888",onClick:m,className:"cursor-pointer"}),open:A,destroyOnHidden:!0,footer:e("div",{className:"flex justify-end items-center",children:v("div",{className:"flex self-end gap-3",children:[e($,{mode:"default",label:"\u53D6\u6D88",onClick:m}),e($,{mode:"primary",label:"\u786E\u8BA4",onClick:()=>L(),disabled:R})]})}),children:[e("div",{className:"mb-[10px] font-bold",children:O}),v("div",{className:"mb-[10px]",children:[e("span",{style:{color:"#FF3B30",marginRight:"4px"},children:"*"}),e("span",{children:"\u6570\u636E\u8868\u63CF\u8FF0"}),e("span",{className:"text-[#888888] ml-[4px]",children:"(\u8BF7\u51C6\u786E\u586B\u5199\u8868\u683C\u7684\u5E94\u7528\u573A\u666F\u63CF\u8FF0\uFF0C\u5927\u6A21\u578B\u5C06\u4F9D\u8D56\u6B64\u4FE1\u606F\u8BC6\u522B\u5E76\u6B63\u786E\u8C03\u7528\u8BE5\u6570\u636E\u8868\u3002)"})]}),e(Ae,{data:f,onChange:l,onGetData:h,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},G),v("div",{children:[e(Ne,{open:t,onOpenChange:p=>s(!!p),content:e("div",{style:{width:"600px",margin:"10px",padding:"10px"},onClick:i,className:"hover:bg-gray-100 h-[80px] cursor-pointer rounded",children:"______\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86______\u573A\u666F\u7684\u6570\u636E\uFF0C\u5305\u542B______\u3001______\u3001______\u7B49\u4E3B\u8981\u5B57\u6BB5\uFF0C\u652F\u6301\u7528\u6237\u67E5\u8BE2______\u95EE\u9898(\u5927\u6982\u4ECB\u7ECD)\u5982\u679C\u6D89\u53CA\u591A\u8868\u5173\u8054\u67E5\u8BE2\uFF0C\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7______\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A______\u8868\u683C\u3002"}),title:v("div",{className:"flex justify-between items-center",style:{margin:"10px"},children:[e("div",{className:"text-[16px]",children:"\u6A21\u7248"}),e(me,{size:20,color:"#888888",onClick:()=>s(!1),className:"cursor-pointer"})]}),trigger:"click",destroyOnHidden:!0,placement:"bottomRight",getPopupContainer:p=>p,children:e("span",{children:e($,{mode:"text",icon:e("img",{src:Ze}),children:"\u4F7F\u7528\u6A21\u7248"})})}),e($,{onClick:c,mode:"text",icon:e("img",{src:je}),loading:R,children:"AI\u4F18\u5316"})]})]})},Ke=""+new URL("assets/empty.png",import.meta.url).href;var H=(a=>(a[a.DATE=0]="DATE",a[a.VIEW=1]="VIEW",a[a.ERROR=2]="ERROR",a[a.AUTHORIZE=3]="AUTHORIZE",a[a.DELETE=4]="DELETE",a[a.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",a[a.DOWNLOAD=6]="DOWNLOAD",a[a.EDIT=7]="EDIT",a[a.ADD=8]="ADD",a[a.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",a[a.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",a))(H||{}),ve=(a=>(a.GENERATING="generating",a.SUCCESS="success",a.FAIL="fail",a))(ve||{});const ce={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},Je=a=>typeof a=="string"&&a in ce?ce[a]:ce.default,de=a=>{const{value:A,cell:F}=a;switch(F.columnId){case"importstatus":return A?e(pe,{title:"\u6709\u8FFD\u52A0\u5931\u8D25\u7684\u6587\u4EF6\uFF0C\u8BF7\u53CA\u65F6\u5904\u7406",children:e(Ve,{color:"red",bordered:!1,children:"\u8FFD\u52A0\u5931\u8D25"})}):e(Ce,{});case"status":const m=Je(a.cell.statusType);return A=="\u5BFC\u5165\u5931\u8D25"?e(pe,{title:F.errorMsg,children:v("div",{className:"flex items-center gap-2",children:[e(Ee,{color:m,text:A}),e(xe,{size:14,color:"red"})]})}):e(Ee,{color:m,text:A});default:return e(Ce,{})}},he=[{statusType:"success",value:"\u5BFC\u5165\u6210\u529F",status:"30"},{statusType:"error",value:"\u5BFC\u5165\u5931\u8D25",status:"00"},{statusType:"default",value:"\u5F85\u5BFC\u5165",status:"10"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"20"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"11"}],Pe=a=>{var m,o;const{cell:A,value:F}=a;return typeof F=="string"?e("div",{title:F,style:{maxWidth:240,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:F}):(m=A.tableMeta)!=null&&m.isGenDescription&&((o=A.tableMeta)==null?void 0:o.generateDescriptionStatus)=="generating"?v("div",{className:"flex items-center gap-1 text-[#84ADFF]",style:{color:"#84ADFF"},children:[e("span",{children:"\u751F\u6210\u4E2D"}),e(Re,{size:14})]}):"-"},Qe=({dbInfo:a,setDrawerTitle:A,setDrawerVisible:F,getBtnDisabled:m})=>v("div",{className:"flex flex-col items-center justify-center h-full",children:[e("div",{className:"text-xl font-semibold mb-3",children:e("img",{src:Ke,width:120})}),e("div",{className:"text-base mb-2",style:{color:"#888888"},children:"\u6682\u65E0\u6570\u636E\u6587\u4EF6"}),e("div",{className:"flex gap-3",children:e($,{mode:"primary",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",disabled:m&&m(8,a==null?void 0:a.permission),onClick:()=>{A("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),F(!0)}})})]}),{confirm:ye}=fe,mu=a=>{const{url:A,token:F,role:m,id:o,dbType:k,CustomComponents:O,getBtnDisabled:E}=a,[z,M]=C({container:"ready",content:"ready"}),g=Fe(null),f=Fe(null),[U,G]=C(),[W,R]=C({}),[B,t]=C(),[s,i]=C(!1),[l,h]=C(""),[c,L]=C(),[p,_]=C(!1),[Y,q]=C(""),{getTableList:Z,delTableById:te,delFileById:ae,updateTableInfo:K,optimizeDesc:se,getTableTreeList:P,reParseFile:Q,getDBDetailById:ee}=we({url:A,token:F,role:m,eventsEmit:a.eventsEmit});De(()=>(o&&k&&(M(n=>({...n,container:"loading"})),ie()),()=>{f.current&&(clearTimeout(f.current),f.current=null)}),[o,k]);const ie=async()=>{try{const n=await ee(o,k);n&&(t(n),M(u=>({...u,container:"ready",content:"loading"})))}catch(n){console.log("[TableApiError] getDBInfo:",n)}await b()},le=async()=>{try{if(k=="DirectDB"){const n=await Z(o);if(n){const u=oe(n);return G(u||[]),M(w=>({...w,content:"ready"})),u||[]}else M(u=>({...u,content:"error"}))}else{const n=await P(o);if(n){const u=ne(n);return G(u||[]),M(w=>({...w,content:"ready"})),u||[]}else M(u=>({...u,content:"error"}))}}catch(n){console.log("[TableApiError] getTableList:",n)}};function ne(n){return(n||[]).map((u,w)=>{var S,N;let y=he.find(x=>x.status==u.status);const T=u.children.some(x=>x.status=="00");return{id:u.fileId.toString(),tableId:u.tableId,data:[{columnId:"name",value:(u==null?void 0:u.originalFilename)||"-",type:"label"},{columnId:"description",value:(S=u==null?void 0:u.tableMeta)==null?void 0:S.description,type:"customized",tableMeta:u==null?void 0:u.tableMeta},{columnId:"count",value:`${u.rowCount}\u884C\uFF0C${u.columnCount}\u5217`,type:"text"},{columnId:"status",...y,type:"customized",errorMsg:u.errorMsg},{columnId:"importstatus",value:T,type:"customized"},{columnId:"createdAt",value:u.gmtCreate,type:"date"},{columnId:"updatedAt",value:u.gmtModified,type:"date"},...u.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(H.VIEW,u.permission)},{columnId:"actions",value:"edit",label:"\u4FEE\u6539\u914D\u7F6E",type:"action",disabled:E&&E(H.EDIT,u.permission)},{columnId:"actions",value:"addData",label:"\u8FFD\u52A0\u6570\u636E",type:"action",disabled:E&&E(H.EDIT,u.permission)}]:[],...u.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action"}]:[],{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",disabled:E&&E(H.DELETE,u.permission)}],expanded:!1,...u.children&&((N=u.children)==null?void 0:N.length)>0&&{children:[...(u.children||[]).map(x=>{const ke=he.find(Te=>Te.status==x.status),Ie=[{columnId:"name",value:x.originalFilename,type:"text"},{columnId:"count",value:`${x.rowCount}\u884C\uFF0C${x.columnCount}\u5217`,type:"text"},{columnId:"status",...ke,errorMsg:x.errorMsg,type:"customized"},{columnId:"createdAt",value:x.gmtCreate,type:"date"},{columnId:"updatedAt",value:x.gmtModified,type:"date"},...x.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(H.VIEW,x.permission)}]:[],...x.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action",disabled:E&&E(H.ADD,x.permission)}]:[],{columnId:"actions",value:"delete_sub",label:"\u5220\u9664",type:"action",disabled:E&&E(H.DELETE,x.permission)}];return{id:x.fileId.toString(),tableId:x.tableId,data:Ie}})]}}})}function oe(n){return(n||[]).map((u,w)=>({id:u.id||Me(8),data:[{columnId:"name",value:u.physicalName},{columnId:"cnname",value:u.businessName},{columnId:"colcount",value:u.columnCount},{columnId:"count",value:`${u.rowCount}\u884C\uFF0C${u.columnCount}\u5217`},{columnId:"actions",value:"view",label:"\u67E5\u770B",disabled:E&&E(H.VIEW,u.permission)}]}))}async function d(n,u,w){switch(console.log("[adopter] mergedEventsEmit",n,u,w),n){case"table_action_delete":{try{ye({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u8BE5\u6570\u636E\u8868\u53CA\u5176\u8FFD\u52A0\u6570\u636E\u90FD\u5C06\u88AB\u5220\u9664\u4E14\u65E0\u6CD5\u6062\u590D",icon:e(xe,{color:"#FF4D4F",className:"mr-[8px]"}),okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await te(u.tableId,k)&&(g!=null&&g.current)&&(g==null||g.current.appFn.removeItem(u.id),X.success("\u5220\u9664\u6210\u529F"))}})}catch{console.log("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25")}break}case"table_action_edit":{q("\u4FEE\u6539\u6570\u636E\u914D\u7F6E"),_(!0),L(u);break}case"toolbar_upload":{h("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),i(!0);break}case"table_action_addData":{h("\u8FFD\u52A0\u6570\u636E"),i(!0),L(u);break}case"table_action_reValidate":{await Q(u.id)&&(f.current&&(clearTimeout(f.current),f.current=null),await b());break}case"table_info:update":{try{if(c!=null&&c.id){const y=(c==null?void 0:c.data.find(S=>S.columnId=="name").value)||"-";if(await K({tableId:c.tableId,description:u,businessName:y})&&(g!=null&&g.current)){const S={...c,data:c.data.map(N=>N.columnId=="description"?{...N,value:u}:N)};g==null||g.current.appFn.updateItem(S,c.id),X.success("\u4FEE\u6539\u914D\u7F6E\u6210\u529F")}}}catch(y){console.error("\u4FEE\u6539\u914D\u7F6E\u5931\u8D25",y)}finally{D()}break}case"table_action_delete_sub":{try{ye({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){const{id:y,tableId:T}=u;await ae(u.id)&&(g!=null&&g.current)&&(R(N=>({...N,[T]:[...N[T]||[],y]})),u.data.find(N=>N.status=="00")&&(f.current&&(clearTimeout(f.current),f.current=null),b()),w.removeItem(y,T),X.success("\u8FFD\u52A0\u6587\u4EF6\u6570\u636E\u5220\u9664\u6210\u529F"))}})}catch{console.log("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25")}break}case"toolbar_auth":{typeof a.eventsEmit=="function"&&a.eventsEmit("toolbar_auth",B);break}default:typeof a.eventsEmit=="function"&&a.eventsEmit(n,u);break}}const r=J(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"direct-table-view",views:[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"direct-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,columns:[{id:"name",title:"\u6570\u636E\u8868\u82F1\u6587\u540D\u79F0",type:"label"},{id:"cnname",title:"\u6570\u636E\u8868\u4E2D\u6587\u540D\u79F0",type:"label"},{id:"colcount",title:"\u5B57\u6BB5\u6570",type:"text"},{id:"count",title:"\u6570\u636E\u91CF",type:"text"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description"],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}]}),[U,k]),I=J(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"data-table-view",views:[{label:"\u4E0A\u4F20\u6570\u636E\u5217\u8868",id:"data-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"name",title:"\u6587\u4EF6\u540D",type:"label",tip:"\u6587\u4EF6\u540D"},{id:"description",title:"\u63CF\u8FF0",type:"customized",component:e(Pe,{}),helpText:"\u6253\u5F00\u81EA\u52A8\u751F\u6210\u63CF\u8FF0\u5F00\u5173\u540E\uFF0C\u82E5\u63CF\u8FF0\u672A\u6B63\u5E38\u751F\u6210\uFF0C\u5219\u63CF\u8FF0\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u5982\u60A8\u4ECD\u7136\u9700\u8981\u63CF\u8FF0\uFF0C\u5219\u9700\u8981\u624B\u52A8\u6DFB\u52A0"},{id:"count",title:"\u6570\u636E\u91CF",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",component:e(de,{})},{id:"importstatus",title:"\u8FFD\u52A0\u63D0\u793A",type:"customized",component:e(de,{})},{id:"createdAt",title:"\u521B\u5EFA\u65F6\u95F4",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{id:"updatedAt",title:"\u66F4\u65B0\u65F6\u95F4",type:"date",tip:"\u66F4\u65B0\u65F6\u95F4"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"button",key:"upload",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",btnType:"primary",disabled:E&&E(H.ADD,B==null?void 0:B.permission),icon:e(He,{size:12})},{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description",["name"]],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}],subTableConfig:{type:"table",allowMultiSelect:!1,viewBehavior:"pagination",viewPageSize:5,columns:[{title:"\u8FFD\u52A0\u6587\u4EF6\u540D",id:"name",type:"text",tip:"\u8FFD\u52A0\u6587\u4EF6\u540D"},{title:"\u6570\u636E\u91CF",id:"count",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",tip:"\u5BFC\u5165\u72B6\u6001",component:e(de,{})},{title:"\u521B\u5EFA\u65F6\u95F4",id:"createdAt",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{title:"\u66F4\u6539\u65F6\u95F4",id:"updatedAt",type:"date",tip:"\u66F4\u6539\u65F6\u95F4"},{title:"\u64CD\u4F5C",id:"actions",type:"action"}]},subTablePendingIds:W,onSubTableRowAnimationComplete:(n,u)=>{R(w=>({...w,[n]:(w[n]||[]).filter(y=>y!==u)}))}}),[W,U,k,B]),D=n=>{i(!1),_(!1),L(void 0),n=="refresh"&&(f.current&&(clearTimeout(f.current),f.current=null),b())};function V(n){var u;if(!Array.isArray(n))return!0;for(const w of n){if(w.data){const y=w.data.find(S=>S.columnId==="status"),T=w.data.find(S=>S.columnId==="description");if(y&&(y.status==="20"||y.status==="11"||((u=T==null?void 0:T.tableMeta)==null?void 0:u.generateDescriptionStatus)==ve.GENERATING))return!1}if(Array.isArray(w.children)){for(const y of w.children)if(y.data){const T=y.data.find(S=>S.columnId==="status");if(T&&(T.status==="20"||T.status==="11"))return!1}}}return!0}const b=async()=>{const n=await le();V(n||[])?f.current&&(clearTimeout(f.current),f.current=null):(f.current&&(clearTimeout(f.current),f.current=null),f.current=setTimeout(()=>{b()},5e3))};return v(Le,{title:B==null?void 0:B.name,description:(B==null?void 0:B.description)||"-",goBack:()=>{var n;(n=a.eventsEmit)==null||n.call(a,"goBack",{})},children:[e(be,{dataSource:U,ref:g,eventsEmit:d,status:z,CustomComponents:{EmptyData:()=>e(Qe,{dbInfo:B,setDrawerTitle:h,setDrawerVisible:i,getBtnDisabled:E}),...O},...k=="DataTable"?I:r}),e(qe,{drawerTitle:l,drawerVisible:s,handleDrawerClose:D,dbId:o,token:F,url:A,role:m,tableInfo:c}),e(Xe,{drawerTitle:Y,drawerVisible:p,handleDrawerClose:D,tableInfo:c,optimizeDesc:se,eventsEmit:d})]})};export{mu as default};