var m=Object.defineProperty;var z=(a,e,t)=>e in a?m(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var c=(a,e,t)=>(z(a,typeof e!="symbol"?e+"":e,t),t);import{d as k,a as K,e as w,r as b,q as P,aq as I,a5 as g,J as N,f as B,bw as O}from"./index-8c26cc43-1776006071491.js";class p{constructor(e){c(this,"saveKey","searchs");c(this,"initSearch",{form:{},page:{}});c(this,"searchs",{});c(this,"key","");this.key=e,this.searchs=this.parse()}save(){localStorage.setItem(this.saveKey,JSON.stringify(this.searchs))}parse(){let e={...l};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]={...l}),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 n=t||this.key;return this.searchs[n]||(this.searchs[n]={...l}),s?this.searchs[n][s]=e:this.searchs[n]=e,this.save(),this.searchs}}const l={form:{},page:{}},T="_pagination_10j50_1",U={pagination:T},j=k({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},disabled:{type:Boolean,default:!1},pageSizes:{type:Array,default:()=>[10,20,30,40]}},emits:["update:page","update:pageSize","list"],setup(a,{emit:e}){const t=K(),s=w({pageInformation:null}),n=b(0);n.value=Math.ceil(a.pageTotal/a.pageSize);const d=i=>{e("update:page",i),e("list"),h()},y=i=>{e("update:pageSize",i),e("update:page",1),e("list"),h()};P(()=>{if(a.sync){const i=new p(a.saveKey||t.path),r=i.get(a.saveKey||t.path);if(s.pageInformation=r,r&&r.page){for(const o in r.page)if(r.page.hasOwnProperty(o)&&["page","pageSize"].includes(o)){const v=r.page[o],S="update:".concat(o);e(S,v)}}a.saveKey&&i.update(t.path,void 0,"bind")}window.addEventListener("watchStorage",u)}),I(()=>{window.removeEventListener("watchStorage",u)}),g(()=>a.pageSize,()=>{n.value=Math.ceil(a.pageTotal/a.pageSize),h()}),g(()=>a.page,()=>{h()}),g(()=>a.pageTotal,()=>{n.value=Math.ceil(a.pageTotal/a.pageSize),h()});const f=N({get(){return a.page},set(i){e("update:page",i)}}),h=()=>{a.sync&&new p(a.saveKey||t.path).update({page:a.page,pageCount:n.value,pageSize:a.pageSize,saveKey:a.saveKey},void 0,"page")},u=()=>{const i=s.pageInformation&&s.pageInformation.page?s.pageInformation.page:null;f.value=i&&i.page?i.page:1};return()=>B(O,{disabled:a.disabled,class:U.pagination,page:a.page,"onUpdate:page":i=>a.page=i,displayOrder:["quick-jumper","pages","size-picker"],pageCount:n.value,showQuickJumper:!0,showSizePicker:!0,pageSize:a.pageSize,prefix:()=>"共 ".concat(a.pageTotal," 条"),pageSizes:a.pageSizes,onUpdatePage:d,onUpdatePageSize:y},null)}});export{j as P,p as S};
