function keepaliveRules(toView, fromView) {
if (!toView || !fromView) return;
console.log(toView);
if (toView.name === "enterprisesApplication" && fromView.name !== "enterprisesDetailes") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "immigrationAgreement" && fromView.name !== "immigrationAgreementEdit") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "leaseAgreement" && fromView.name !== "leaseAgreementedit") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "EnterprisesInformation" && fromView.name !== "EnterprisesInformationDetails") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "BusinessRegister" && fromView.name !== "BusinessRegisterDetaile") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "BusinessChange" && fromView.name !== "BusinessChangeDetaile") {
cleanKeepalive(toView.instances.default);
}
let material = ["Application", "Acceptance"];
if (material.includes(toView.name) && fromView.name !== "material") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "policyCash" && fromView.name !== "policyDetaile") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "AppealManagement" && fromView.name !== "AppealDetail") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "PromotionManagement" && fromView.name !== "PromotionDetaile") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "FinishLeaseApplyList" && fromView.name !== "FinishLeaseApplyListDetails") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "FinishLeaseAgreementManage" && fromView.name !== "FinishLeaseAgreementManageEdit") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "taxKnows" && fromView.name !== "details") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "ThirdService" && fromView.name !== "thirdServiceDetails") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "questionnaireTemplate" && fromView.name !== "QuestionnaireView") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "estateManage" && fromView.name !== "estateDetailes") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "buildingManage" && fromView.name !== "buildingDetailes") {
cleanKeepalive(toView.instances.default);
}
if (toView.name === "floorManagement" && fromView.name !== "floorDetailes") {
cleanKeepalive(toView.instances.default);
}
}
function cleanKeepalive(def) {
if ( def.$vnode && def.$vnode.data.keepAlive) {
if ( def.$vnode.parent && def.$vnode.parent.componentInstance && def.$vnode.parent.componentInstance.cache) {
if(def.$vnode.componentOptions){
var key = def.$vnode.key == null ? def.$vnode.componentOptions.Ctor.cid + (def.$vnode.componentOptions.tag ? `::${def.$vnode.componentOptions.tag}` : '') : def.$vnode.key;
let cache = def.$vnode.parent.componentInstance.cache;
let keys = def.$vnode.parent.componentInstance.keys;
if (cache[key] != null) {
cache[key].componentInstance.$destroy();
let index = keys.indexOf(key);
if (index > -1) {
keys.splice(index, 1);
}
}
}
}
}
}
const keepalive = {
keepaliveRules: keepaliveRules
};
export default keepalive;