import{Q as a,R as t}from"./database.js?v=20260328163632";import{l as e,t as s,x as r}from"./utils-lib.js?v=20260328163632";import{k as o,r as m,c as p,w as l,V as c,_ as n,Y as i}from"./base-lib.js?v=20260328163632";import"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";const u=o({__name:"insert-data",props:{compData:{default:{primaryKey:"",keys:[],row:{},path:"",table:"",refresh:()=>{}}}},setup(o,{expose:u}){const f=o;e("请选择数据库文件");const h={labelStyle:"min-width: 100px"},y=m({formAttrs:{labelWidth:"auto"},formItems:[]}),w=p((()=>{var a;const t=[];return null==(a=f.compData.keys)||a.forEach((a=>{a.pk||t.push({label:a.name,attrs:h,children:[{type:"input",key:a.name,attrs:{placeholder:e("请输入")+a.name,clearable:!0,class:"!w-280px"}}]})})),t})),b=p((()=>(y.value.formItems=w.value,y.value))),[d,v,D]=s(b);return l((()=>f.compData.keys),(()=>{var a;null==(a=f.compData.keys)||a.forEach((a=>{a.pk&&!f.compData.row||(v.value[a.name]=f.compData.row?f.compData.row[a.name]:"")}))}),{immediate:!0}),u({onConfirm:async s=>{try{await D.value.validate();const{primaryKey:s,row:o}=f.compData;let m={path:f.compData.path,tab_name:f.compData.table,data:JSON.stringify(v.value)};const p=f.compData.row;p&&(m.where=s+"="+o[s]);return(await r({loading:e("正在提交，请稍后..."),request:p?a(m):t(m),message:!0,success:()=>f.compData.refresh()})).status}catch(o){}}}),(a,t)=>(c(),n(i(d),{class:"p-[20px] max-h-500px overflow-auto"}))}});export{u as default};
