var z=Object.defineProperty;var K=(a,e,t)=>e in a?z(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var o=(a,e,t)=>(K(a,typeof e!="symbol"?e+"":e,t),t);import{d as w,a as P,e as b,r as I,n as N,O,y as l,L as T,f as B,dk as U}from"./index-54f41458-1694675857467.js";class d{constructor(e){o(this,"saveKey","searchs");o(this,"initSearch",{form:{},page:{}});o(this,"searchs",{});o(this,"key","");this.key=e,this.searchs=this.parse()}save(){localStorage.setItem(this.saveKey,JSON.stringify(this.searchs))}parse(){let e={...p};try{const t=localStorage.getItem(this.saveKey);e=JSON.parse(t)||e}catch(t){}return e}get(e){const t=e||this.key;return this.searchs[t]||(this.searchs[t]={...p}),this.searchs[t]}remove(e){return this.searchs&&this.searchs[this.key]&&(e?delete this.searchs[this.key][e]:delete this.searchs[this.key],this.save()),this.searchs}getSearchs(){return this.searchs}removeByKey(e){return console.log("真正的删",e),delete this.searchs[e],this.save(),this.searchs}removeAll(){return this.searchs={},localStorage.setItem(this.saveKey,JSON.stringify(this.searchs)),this.searchs}removeByRouter(e){var t;this.searchs=this.parse();for(const s in this.searchs)(e===s||e===((t=this.searchs[s])==null?void 0:t.bind))&&(console.log("清除的页面",s),this.removeByKey(s))}removeByOtherRouter(e){var t;this.searchs=this.parse();for(const s in this.searchs)e===s||e===((t=this.searchs[s])==null?void 0:t.bind)||this.removeByKey(s)}update(e,t,s){this.searchs=this.parse();const r=t||this.key;return this.searchs[r]||(this.searchs[r]={...p}),s?this.searchs[r][s]=e:this.searchs[r]=e,this.save(),this.searchs}}const p={form:{},page:{}},j=w({name:"table-container",props:{page:{type:Number,default:1,required:!0},pageSize:{type:Number,default:10},pageTotal:{type:Number,default:0},saveKey:{type:String,default:""},sync:{type:Boolean,default:!1},checkedRowKeysRef:{type:Object}},emits:["update:page","update:pageSize","list"],setup(a,{slots:e,attrs:t,emit:s}){const r=P(),g=b({pageInformation:null}),h=I(0);h.value=Math.ceil(a.pageTotal/a.pageSize);const f=i=>{s("update:page",i),s("list"),c()},v=i=>{s("update:pageSize",i),s("list"),c()};N(()=>{if(a.sync){const i=new d(a.saveKey||r.path),n=i.get(a.saveKey||r.path);if(g.pageInformation=n,n&&n.page){for(const u in n.page)if(n.page.hasOwnProperty(u)&&["page","pageSize"].includes(u)){const m=n.page[u],k="update:".concat(u);s(k,m)}}a.saveKey&&i.update(r.path,void 0,"bind")}window.addEventListener("watchStorage",y)}),O(()=>{window.removeEventListener("watchStorage",y)}),l(()=>a.pageSize,()=>{h.value=Math.ceil(a.pageTotal/a.pageSize),c()}),l(()=>a.page,()=>{c()}),l(()=>a.pageTotal,()=>{h.value=Math.ceil(a.pageTotal/a.pageSize),c()});const S=T({get(){return a.page},set(i){s("update:page",i)}}),c=()=>{a.sync&&new d(a.saveKey||r.path).update({page:a.page,pageCount:h.value,pageSize:a.pageSize,saveKey:a.saveKey},void 0,"page")},y=()=>{const i=g.pageInformation&&g.pageInformation.page?g.pageInformation.page:null;S.value=i&&i.page?i.page:1};return()=>B(U,{style:{marginTop:"12px",justifyContent:"flex-end"},page:a.page,"onUpdate:page":i=>a.page=i,displayOrder:["quick-jumper","pages","size-picker"],pageCount:h.value,showQuickJumper:!0,showSizePicker:!0,pageSize:a.pageSize,prefix:()=>"共 ".concat(a.pageTotal," 条"),pageSizes:[10,20,30,40],onUpdatePage:f,onUpdatePageSize:v},null)}});export{j as P,d as S};