Commit 7e92e791 by 曾经

页面缓存

parent 440cf518
<template>
<div id="app" class="dm-reset-style">
<keep-alive :include="keepAlive">
<router-view :key="$route.path"></router-view>
</keep-alive>
<router-view></router-view>
</div>
</template>
......@@ -11,11 +9,7 @@ import { mapState } from 'vuex';
export default {
name: 'App',
data() {
return {
keepAlive: []
}
},
computed: {
...mapState([
'uniqueId'
......@@ -23,11 +17,6 @@ export default {
},
created() {
this.setKeepAlive(this.$route, {});
this.$router.beforeEach((to, from, next) => {
this.setKeepAlive(to, from);
next();
});
this.baseUrl = window.location.origin.indexOf('localhost') > -1 ? 'http://www.gicdev.com' : window.location.origin;
this._getUserInfo();
this.changeTab();
......@@ -35,32 +24,6 @@ export default {
},
methods: {
setKeepAlive(to, from) {
if (Array.isArray(to.meta.fromPath)) {
const isKeepAlive = to.meta.fromPath.some(el => {
let menuUrlReg = el;
let pathConfigReg = /(:.*)(\/?)/;
const pathRegStr = '([\\d\\w]+[\\-]*[\\d\\w]*)';
while (pathConfigReg.test(menuUrlReg)) {
menuUrlReg = menuUrlReg.replace(pathConfigReg, `${pathRegStr}$2`);
}
pathConfigReg = /(\/\*)(\/?)/;
while (pathConfigReg.test(menuUrlReg)) {
menuUrlReg = menuUrlReg.replace(pathConfigReg, `${pathRegStr}$2`);
}
const reg = new RegExp(`^${menuUrlReg}$`);
return reg.test(from.path);
});
if (!isKeepAlive) {
this.keepAlive = this.keepAlive.filter(el => el != to.meta.componentName);
}
setTimeout(() => {
if (this.keepAlive.every(el => el != to.meta.componentName)) {
this.keepAlive.push(to.meta.componentName);
}
}, 100);
}
},
isEditClique() {
this.axios.get(`${this.baseUrl}/api-member/allow-edit-clique-grade?requestProject=member`).then((res) => {
if (res.data.errorCode == 0) {
......
......@@ -90,44 +90,27 @@ export default {
abnormalSettingSave: 0
};
},
created() {
if (sessionStorage.getItem("abnormalListSearchData")) {
this.searchData = JSON.parse(
sessionStorage.getItem("abnormalListSearchData")
);
}
// if(sessionStorage.getItem("abnormalListSearchDateRange")){
// this.dateValue = JSON.parse(
// sessionStorage.getItem("abnormalListSearchDateRange")
// );
// }
},
beforeMount() {
this.init();
},
watch: {
searchData: {
handler(newval) {
sessionStorage.setItem("abnormalListSearchData", JSON.stringify(newval));
},
deep: true,
immediate: false
},
dateValue:{
handler(value){
value = value || ['',''];
if(value[0] && value[1]){
this.searchData.startDate = +value[0];
this.searchData.endDate = +value[1];
// sessionStorage.setItem("abnormalListSearchDateRange",JSON.stringify([+value[0],+value[1]]));
}else{
this.searchData.startDate = '';
this.searchData.endDate = '';
// sessionStorage.removeItem("abnormalListSearchDateRange");
}
}
},
},
activated(){
this.init();
},
methods: {
init() {
this.getSetting().then(res => {
......
......@@ -72,24 +72,11 @@ export default {
abnormalSettingSave: 0
};
},
created() {
if (sessionStorage.getItem("frozenListSearchData")) {
this.searchData = JSON.parse(
sessionStorage.getItem("frozenListSearchData")
);
}
},
beforeMount() {
this.init();
},
watch: {
searchData: {
handler(newval) {
sessionStorage.setItem("frozenListSearchData", JSON.stringify(newval));
},
deep: true,
immediate: false
},
activated(){
this.init();
},
methods: {
init() {
......
......@@ -45,8 +45,8 @@ export default {
created() {
this.loadData();
},
watch: {
activated(){
this.loadData();
},
methods: {
loadData(){
......@@ -87,21 +87,6 @@ export default {
this.$refs.multipleTable.clearSelection();
},
submitForm(formName) {
// if(!(this.multipleList && this.multipleList.length)){
// this.$message.warning('请选择要冻结的会员');
// return;
// }
// this.$refs[formName].validate((valid) => {
// if (valid) {
// alert('submit!');
// } else {
// console.log('error submit!!');
// return false;
// }
// });
this.$confirm("是否冻结所选会员?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
......@@ -155,6 +140,12 @@ export default {
},
batchUpload(){
this.dialogImportVisible = true;
}
},
linkDetail(memberId) {
this.$router.push({
path: "/customerDetail",
query: { memberId }
});
},
}
};
......@@ -77,8 +77,8 @@ export default {
created() {
this.loadData();
},
watch: {
activated(){
this.loadData();
},
methods: {
loadData(){
......
......@@ -32,10 +32,9 @@
</div> -->
<div class="container">
<dm-layout projectName="member">
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
<keep-alive :include="keepAlive">
<router-view :key="$route.path"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
</dm-layout>
</div>
</template>
......@@ -48,6 +47,7 @@ export default {
name: "layout",
data() {
return {
keepAlive: [],
collapseFlag: false,
menuRouter: [],
bodyHeight: document.body.clientHeight || document.documentElement.clientHeight,
......@@ -61,6 +61,32 @@ export default {
}
},
methods: {
setKeepAlive(to, from) {
if (Array.isArray(to.meta.fromPath)) {
const isKeepAlive = to.meta.fromPath.some(el => {
let menuUrlReg = el;
let pathConfigReg = /(:.*)(\/?)/;
const pathRegStr = '([\\d\\w]+[\\-]*[\\d\\w]*)';
while (pathConfigReg.test(menuUrlReg)) {
menuUrlReg = menuUrlReg.replace(pathConfigReg, `${pathRegStr}$2`);
}
pathConfigReg = /(\/\*)(\/?)/;
while (pathConfigReg.test(menuUrlReg)) {
menuUrlReg = menuUrlReg.replace(pathConfigReg, `${pathRegStr}$2`);
}
const reg = new RegExp(`^${menuUrlReg}$`);
return reg.test(from.path);
});
if (!isKeepAlive) {
this.keepAlive = this.keepAlive.filter(el => el != to.meta.componentName);
}
setTimeout(() => {
if (this.keepAlive.every(el => el != to.meta.componentName)) {
this.keepAlive.push(to.meta.componentName);
}
}, 100);
}
},
toRouterView(val) {
this.$router.push({
path: val.path
......@@ -80,6 +106,11 @@ export default {
}
},
created() {
this.setKeepAlive(this.$route, {});
this.$router.beforeEach((to, from, next) => {
this.setKeepAlive(to, from);
next();
});
this.getClerkMenu();
window.onresize = () => {
return (() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment