import{c as g,f as D,e as F,n as h}from"./vue-vendor-CxLCUzY4.js";import{r as I}from"./cgform.data-475d4984-B8WsIiLb.js";import{p as N}from"./antd-vue-vendor-CahNzUUa.js";var x=(s,f,a)=>new Promise((i,v)=>{var u=l=>{try{d(a.next(l))}catch(c){v(c)}},m=l=>{try{d(a.throw(l))}catch(c){v(c)}},d=l=>l.done?i(l.value):Promise.resolve(l.value).then(u,m);d((a=a.apply(s,f)).next())});function V(s){const f=g("tables"),a=g("fullScreenRef"),i=D(),v=D(!1),u=D([]),m=F(()=>({normal:a!=null&&a.value?430:260,noToolbar:a!=null&&a.value?480:320})),d=F(()=>["id"].concat(s.value.map(t=>t.key))),l=F(()=>({scrollY:{enabled:!0,gt:15},scrollX:{enabled:!0,gt:20}}));function c(t){return x(this,null,function*(){let e=i.value;if(yield e.fullValidateTable())throw{code:I,activeKey:t};let y=e.getTableData().map(b=>N(b,d.value)),p=e.getDeleteData().map(b=>b.id);return{tableData:y,deleteIds:p}})}function k(t,e=!1){return x(this,null,function*(){e?(u.value=[],yield h(),yield i.value.addOrInsert(t,0,null,{setActive:!1}),yield h(),i.value.recalcDisableRows()):u.value=t})}function w(t){let e=i.value,y=t.value.tableRef,p=t.value.getRemoveIds(),b=y.getXTable().internalData.tableFullData,R=e.getXTable().internalData.tableFullData;return b.forEach(o=>{let T=!1;if(R.forEach(n=>{if(o.id===n.id){let r=n.dbFieldName,E=n.dbFieldTxt;(o.dbFieldName!==r||o.dbFieldTxt!==E)&&e.setValues([{rowKey:n.id,values:{dbFieldName:o.dbFieldName,dbFieldTxt:o.dbFieldTxt}}]),T=!0}else p.forEach(r=>{r===n.id&&(e.removeRowsById(r),T=!0)})}),!T){let n=Object.assign({},o);s.value.forEach(r=>{r.key!=="dbFieldName"&&r.key!=="dbFieldTxt"&&(n[r.key]=r.defaultValue)}),e.addRows(n)}}),h()}return{tables:f,tableRef:i,loading:v,dataSource:u,columnKeys:d,tableHeight:m,tableProps:l,syncTable:w,validateData:c,setDataSource:k}}export{V as L};
