1 |
- System.register(["./index-legacy-da1c415f-1694078809672.js"],(function(e,s){"use strict";var t,a,r,i,h,p,o,n,c,g;return{setters:[e=>{t=e.d,a=e.a,r=e.e,i=e.r,h=e.n,p=e.O,o=e.y,n=e.L,c=e.f,g=e.dk}],execute:function(){class s{saveKey="searchs";initSearch={form:{},page:{}};searchs={};key="";constructor(e){this.key=e,this.searchs=this.parse()}save(){localStorage.setItem(this.saveKey,JSON.stringify(this.searchs))}parse(){let e={...l};try{const s=localStorage.getItem(this.saveKey);e=JSON.parse(s)||e}catch(s){}return e}get(e){const s=e||this.key;return this.searchs[s]||(this.searchs[s]={...l}),this.searchs[s]}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){this.searchs=this.parse();for(const s in this.searchs)e!==s&&e!==this.searchs[s]?.bind||(console.log("清除的页面",s),this.removeByKey(s))}removeByOtherRouter(e){this.searchs=this.parse();for(const s in this.searchs)e===s||e===this.searchs[s]?.bind||this.removeByKey(s)}update(e,s,t){this.searchs=this.parse();const a=s||this.key;return this.searchs[a]||(this.searchs[a]={...l}),t?this.searchs[a][t]=e:this.searchs[a]=e,this.save(),this.searchs}}e("S",s);const l={form:{},page:{}};e("P",t({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(e,{slots:t,attrs:l,emit:u}){const y=a(),d=r({pageInformation:null}),v=i(0);v.value=Math.ceil(e.pageTotal/e.pageSize);const m=e=>{u("update:page",e),u("list"),z()},S=e=>{u("update:pageSize",e),u("list"),z()};h((()=>{if(e.sync){const t=new s(e.saveKey||y.path),a=t.get(e.saveKey||y.path);if(d.pageInformation=a,a&&a.page)for(const e in a.page)if(a.page.hasOwnProperty(e)&&["page","pageSize"].includes(e)){const s=a.page[e];u(`update:${e}`,s)}e.saveKey&&t.update(y.path,void 0,"bind")}window.addEventListener("watchStorage",K)})),p((()=>{window.removeEventListener("watchStorage",K)})),o((()=>e.pageSize),(()=>{v.value=Math.ceil(e.pageTotal/e.pageSize),z()})),o((()=>e.page),(()=>{z()})),o((()=>e.pageTotal),(()=>{v.value=Math.ceil(e.pageTotal/e.pageSize),z()}));const f=n({get:()=>e.page,set(e){u("update:page",e)}}),z=()=>{e.sync&&new s(e.saveKey||y.path).update({page:e.page,pageCount:v.value,pageSize:e.pageSize,saveKey:e.saveKey},void 0,"page")},K=()=>{const e=d.pageInformation&&d.pageInformation.page?d.pageInformation.page:null;f.value=e&&e.page?e.page:1};return()=>c(g,{style:{marginTop:"12px",justifyContent:"flex-end"},page:e.page,"onUpdate:page":s=>e.page=s,displayOrder:["quick-jumper","pages","size-picker"],pageCount:v.value,showQuickJumper:!0,showSizePicker:!0,pageSize:e.pageSize,prefix:()=>`共 ${e.pageTotal} 条`,pageSizes:[10,20,30,40],onUpdatePage:m,onUpdatePageSize:S},null)}}))}}}));
|