From b939e9d3623166188156c9284ef05a45659f449a Mon Sep 17 00:00:00 2001 From: jsy_zjg <31502350@qq.com> Date: Fri, 29 Nov 2024 10:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/work/land/index.vue | 32 ++++++++++++++++++++++++++++---- pages/work/user/index.vue | 30 ++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/pages/work/land/index.vue b/pages/work/land/index.vue index c225076..d0fd25e 100644 --- a/pages/work/land/index.vue +++ b/pages/work/land/index.vue @@ -91,9 +91,12 @@ } from "@/utils/permission" import store from "@/store" import plugin from "@/plugins" + import constant from "@/utils/constant.js" export default { data() { return { + isFirst:true, + user: store.state.user.user, windowHeight: null, defaultCheckedKeys: "", paging: null, @@ -122,14 +125,24 @@ methods: { /** 查询公司下拉树结构 */ getCompanyTree() { + const obj = { + status: 0, + delFlag: "0", + companyTypes: [1, 2, 3], + } store - .dispatch("companyTreeSelect", null) + .dispatch("companyTreeSelect", obj) .then(res => { this.treeList = res.data; if (this.treeList && this.treeList.length) { - let companyList = this.treeList[0].children.filter(x => x.id != 100); - if (companyList && companyList.length) { - this.defaultCheckedKeys = companyList[0].id + ""; + let cache_companyId = uni.getStorageSync("app_companyId") + if(cache_companyId){ + this.defaultCheckedKeys = cache_companyId + ""; + }else{ + let companyList = this.treeList[0].children.filter(x => x.id != 100); + if (companyList && companyList.length) { + this.defaultCheckedKeys = companyList[0].id + ""; + } } } }) @@ -192,6 +205,10 @@ handleTreeChange(values, currentItem) { this.query.companyGroupIds = ""; this.companyGroupId = values; + if(!this.isFirst){ + uni.setStorageSync("app_companyId", this.companyGroupId) + } + this.isFirst = false; this.selectCompanyObj = currentItem; if (this.all) { this.getCompanyGroupIds(); @@ -227,6 +244,13 @@ this.query.companyGroupIds += this.companyGroupId; } this.getListData(); + }, + // 缓存数据 + setStorage(type, data) { + uni.setStorageSync(type, { + userId: this.user.userId, + data: data, + }); } } } diff --git a/pages/work/user/index.vue b/pages/work/user/index.vue index ef53874..9bba320 100644 --- a/pages/work/user/index.vue +++ b/pages/work/user/index.vue @@ -119,6 +119,8 @@ export default { data() { return { + isFirst:true, + user: store.state.user.user, defaultCheckedKeys: "", list: [], windowHeight: null, @@ -170,14 +172,24 @@ methods: { /** 查询公司下拉树结构 */ getCompanyTree() { + const obj = { + status: 0, + delFlag: "0", + companyTypes: [1, 2, 3], + } store - .dispatch("companyTreeSelect", null) + .dispatch("companyTreeSelect", obj) .then(res => { this.treeList = res.data; if (this.treeList && this.treeList.length) { - let companyList = this.treeList[0].children.filter(x => x.id != 100); - if (companyList && companyList.length) { - this.defaultCheckedKeys = companyList[0].id + ""; + let cache_companyId = uni.getStorageSync("app_companyId") + if(cache_companyId){ + this.defaultCheckedKeys = cache_companyId + ""; + }else{ + let companyList = this.treeList[0].children.filter(x => x.id != 100); + if (companyList && companyList.length) { + this.defaultCheckedKeys = companyList[0].id + ""; + } } } }) @@ -241,6 +253,9 @@ handleTreeChange(values, currentItem) { this.query.companyGroupIds = ""; this.companyGroupId = values; + if(!this.isFirst){ + uni.setStorageSync("app_companyId", this.companyGroupId) + } this.selectCompanyObj = currentItem; if (this.all) { this.getCompanyGroupIds(); @@ -339,6 +354,13 @@ this.query.companyGroupIds += this.companyGroupId; } this.queryList(); + }, + // 缓存数据 + setStorage(type, data) { + uni.setStorageSync(type, { + userId: this.user.userId, + data: data, + }); } } }