1 |
- import{S as l}from"./searchs.b637f0d6.js";import{d as y,e as h,a as m,r as z,B as v,bx as w,M as s,F as K,i as P,ci as b}from"./index.19a1245a.js";const x=y({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},pageSizes:{type:Array,default:()=>[10,20,30,40]},pageSlot:{type:Number,default:9}},emits:["update:page","update:pageSize","list"],setup(e,{slots:T,attrs:k,emit:t}){const o=h(),u=m({pageInformation:null}),g=z(0);g.value=Math.ceil(e.pageTotal/e.pageSize);const d=a=>{t("update:page",a),t("list"),i()},r=a=>{t("update:pageSize",a),t("list"),i()};v(()=>{if(e.sync){const a=new l(e.saveKey||o.path),n=a.get(e.saveKey||o.path);if(u.pageInformation=n,n&&n.page){for(const p in n.page)if(n.page.hasOwnProperty(p)&&["page","pageSize"].includes(p)){const f=n.page[p],S=`update:${p}`;t(S,f)}}e.saveKey&&a.update(o.path,void 0,"bind")}window.addEventListener("watchStorage",c)}),w(()=>{window.removeEventListener("watchStorage",c)}),s(()=>e.pageSize,()=>{g.value=Math.ceil(e.pageTotal/e.pageSize),i()}),s(()=>e.page,()=>{i()}),s(()=>e.pageTotal,()=>{g.value=Math.ceil(e.pageTotal/e.pageSize),i()}),K({get(){return e.page},set(a){t("update:page",a)}});const i=()=>{e.sync&&new l(e.saveKey||o.path).update({page:e.page,pageCount:g.value,pageSize:e.pageSize,saveKey:e.saveKey},void 0,"page")},c=()=>{let a=u.pageInformation&&u.pageInformation.page?u.pageInformation.page:null;a&&a.page&&a.page};return()=>P(b,{style:{marginTop:"12px",justifyContent:"flex-end"},page:e.page,"onUpdate:page":a=>e.page=a,displayOrder:["quick-jumper","pages","size-picker"],pageCount:g.value,showQuickJumper:!0,showSizePicker:!0,pageSize:e.pageSize,prefix:()=>`\u5171 ${e.pageTotal} \u6761`,pageSizes:e.pageSizes,onUpdatePage:d,onUpdatePageSize:r,pageSlot:e.pageSlot},null)}});export{x as P};
|