import{c as a,r as e,w as t,v as s,x as o,e as r,B as m,F as l,b0 as p,N as n,y as d,D as c,R as u,ab as i,a9 as f}from"./base-lib.js?v=1761009159";import{P as _,k as b,_ as w}from"./utils-lib.js?v=1761009159";import{updateTableData as D,createTableData as h}from"./database.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const v={class:"p-[20px] max-h-[50rem] overflow-auto"},y=w(a({__name:"insert-data",props:{compData:{default:{keys:[],row:{},path:"",table:"",refresh:()=>{}}}},setup(a,{expose:w}){const y=a,k=e(),g=e({});t(()=>y.compData.keys,()=>{var a;null==(a=y.compData.keys)||a.forEach(a=>{g.value[a.name]=y.compData.row?y.compData.row[a.name]:""})},{immediate:!0});const x={path:[{required:!0,message:"请选择数据库文件",trigger:["blur","change"]}]};return w({onConfirm:async a=>{await k.value.validate();let e={path:y.compData.path,table:y.compData.table,new_data:g.value,where_data:y.compData.row};const t=y.compData.row;t||delete e.where_data,e=JSON.stringify(e),await _({loading:"正在提交，请稍后...",request:t?D({data:e}):h({data:e}),message:!0}),a(),y.compData.refresh()}}),(a,e)=>{const t=b,_=i,w=f;return s(),o("div",v,[r(w,{model:d(g),ref_key:"insertDataForm",ref:k,rules:x,onSubmit:e[0]||(e[0]=u(()=>{},["prevent"]))},{default:m(()=>[(s(!0),o(l,null,p(a.compData.keys,(a,e)=>(s(),o(l,null,[1!==a.pk?(s(),n(_,{label:a.name,prop:a.name,key:e},{default:m(()=>[r(t,{type:"text",modelValue:d(g)[a.name],"onUpdate:modelValue":e=>d(g)[a.name]=e,name:"item.name",width:"28rem"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label","prop"])):c("",!0)],64))),256))]),_:1},8,["model"])])}}}),[["__scopeId","data-v-5cbc35c0"]]);export{y as default};
