base-b02b8c3b.js 2.1 KB

1
  1. import{f as u,A as o}from"./index-c9978dc1.js";import{u as c}from"./vue-router-0190217c.js";const P=u("base",{state:()=>({router:c(),Provinces:[],PageUpParam:{},nowPageData:[],pageTotal:0,keyid:"",tableRecord:[]}),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(s){let i=Object.keys(s).map((e,r,n)=>{var h={label:e,value:e,item:s[e]};return h});return i.forEach(e=>{e.item instanceof Array?(e.children=[],e.item.forEach(r=>{e.children.push({label:r,value:r})})):Object.keys(e.item).length!==0&&(e.children=a(e.item))}),i}this.Provinces=a(t.data)},async next(){console.log(this.keyid);const t=await this.checkPaginationData();if(t==0&&this.nowPageData.length==1||t==1&&this.PageUpParam.content.pageNumber==this.pageTotal)return!1;let a=s=>{let i=this.router.currentRoute.query.id,e="";s==1?e=this.nowPageData[0][this.keyid]:this.nowPageData.forEach((r,n)=>{r[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(s=>{a(1)})):a()},async previous(){const t=await this.checkPaginationData();if(t==0&&this.PageUpParam.content.pageNumber==1)return!1;const a=s=>{let i=this.router.currentRoute.query.id,e="";s==0?e=this.nowPageData[this.nowPageData.length-1][this.keyid]:this.nowPageData.forEach((r,n)=>{r[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 s=this.router.currentRoute.query.id,i=0;this.nowPageData.filter((e,r)=>{e[this.keyid]==s&&(i=r)}),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};