import{f as S,ay as d,ac as L,ax as b,cl as y,cm as V,cn as I}from"./index-9PRMimni.js";import{u as k}from"./tabsView-BXskTdVh.js";function T(i){const c=k(),u=S(),o=u.fullPath;function l(){return u.query.id?`${String(u.name)}${String(u.query.id)}`:String(u.name)}function C(t,n){const a=l(),e=c.tabsList.findIndex(s=>s.fullPath===o);if(e===-1)return;const r=c.tabsList[e];if(r.pageFormCache||(r.pageFormCache={}),r.pageFormCache[a]){const s=r.pageFormCache[a];if(s[String(n)]){const f=s[String(n)];t.setFieldsValue(f)}else s[String(n)]={}}else r.pageFormCache[a]={}}function m(t,n){const a=l(),e=c.tabsList.findIndex(f=>f.fullPath===o);if(e===-1)return;const r=c.tabsList[e];r.pageFormCache||(r.pageFormCache={});const s=r.pageFormCache;Reflect.has(s,a)?s[a][String(n)]=t.getFieldsValue():s[a]={}}function h(){const t=c.tabsList.findIndex(a=>a.fullPath===o);return t===-1?{}:c.tabsList[t].formCache}function g(t){const n=c.tabsList.findIndex(e=>e.fullPath===o);if(n===-1)return;const a=c.tabsList[n];a.formCache=t}function F(t){const n=[[!!i?.cacheKey,()=>{C(t,String(i?.cacheKey))}],[i?.isCache===!0,()=>{const e=h();e&&t.setFieldsValue(e)}],[i?.showActionButtonGroup!==!1,()=>{const e=h();e&&t.setFieldsValue(e)}],[!0,()=>{}]],a=[[!!i?.cacheKey,()=>{m(t,String(i?.cacheKey))}],[i?.isCache===!0,()=>{i?.deleteCache!==!0&&g(t.getFieldsValue())}],[i?.showActionButtonGroup!==!1,()=>{y()?.parent?.parent?.type.name==="Spin"&&g(t.getFieldsValue())}],[!0,()=>{}]];d(()=>i,()=>{i&&t.setProps(V(i));for(const[e,r]of n)if(e){r();break}},{immediate:!0,deep:!0}),I((e,r)=>{if(e.fullPath!==r.fullPath){for(const[s,f]of a)if(s){f();break}}}),b(()=>{for(const[e,r]of a)if(e){r();break}})}function x(){const t=c.tabsList.findIndex(a=>a.fullPath===o);return t===-1?{}:c.tabsList[t].tableCache}function p(t){const n=c.tabsList.findIndex(e=>e.fullPath===o);if(n===-1)return;const a=c.tabsList[n];a.tableCache=t}function P(t,n){if(!t){console.error("请传入当前的组件实例，或者获取到的当前组件实例不存在");return}const a=t.exposed;a&&(d(()=>n,async()=>{const e=x();e&&Reflect.has(e,"page")&&e.page!==1&&(await L(),a.updatePage(e.page))},{immediate:!0,deep:!0}),b(()=>{const e=a.getPageParams();p(e)}))}return{registerForm:F,registerTable:P}}export{T as u};
