base-a8aaa91c.js 2.1 KB

1
  1. import{e as u,A as o}from"./index-7688c5b5.js";import{u as c}from"./vue-router-d343d91b.js";const p=u("base",{state:()=>({router:c(),classAct:null,Provinces:[],PageUpParam:{},nowPageData:[],pageTotal:0,keyid:"",tableRecord:[],colMap:new Map,fullscreen:!1}),persist:{enabled:!0,strategies:[{storage:localStorage,paths:["PageUpParam","nowPageData","pageTotal","keyid"]}]},getters:{},actions:{async ProvincesData(){const t=await o.requested({classname:"system.tools",method:"query_arealist",content:{}});t.data;function a(r){let i=Object.keys(r).map((e,s,n)=>{var h={label:e,value:e,item:r[e]};return h});return i.forEach(e=>{e.item instanceof Array?(e.children=[],e.item.forEach(s=>{e.children.push({label:s,value:s})})):Object.keys(e.item).length!==0&&(e.children=a(e.item))}),i}return a(t.data)},async next(){const t=await this.checkPaginationData();if(t==0&&this.nowPageData.length==1||t==1&&this.PageUpParam.content.pageNumber==this.pageTotal)return!1;let a=r=>{let i=this.router.currentRoute.query.id,e="";r==1?e=this.nowPageData[0][this.keyid]:this.nowPageData.forEach((s,n)=>{s[this.keyid]==i&&(e=this.nowPageData[n+1][this.keyid])}),this.router.replace({path:this.router.currentRoute.path,query:{id:e}})};t==1?(this.PageUpParam.content.pageNumber++,this.newListData(r=>{a(1)})):a()},async previous(){const t=await this.checkPaginationData();if(t==0&&this.PageUpParam.content.pageNumber==1)return!1;const a=r=>{let i=this.router.currentRoute.query.id,e="";r==0?e=this.nowPageData[this.nowPageData.length-1][this.keyid]:this.nowPageData.forEach((s,n)=>{s[this.keyid]==i&&(e=this.nowPageData[n-1][this.keyid])}),this.router.replace({path:this.router.currentRoute.path,query:{id:e}})};t==0?(this.PageUpParam.content.pageNumber--,this.newListData(()=>{a(0)})):a()},checkPaginationData(){return new Promise((t,a)=>{let r=this.router.currentRoute.query.id,i=0;this.nowPageData.filter((e,s)=>{e[this.keyid]==r&&(i=s)}),i==0?t(0):i==this.nowPageData.length-1?t(1):t(-1)})},async newListData(t){const a=await o.requested(this.PageUpParam);this.nowPageData=a.data,this.pageTotal=a.pageTotal,t&&t()}}});export{p as u};