Commit a6ef76c9 authored by zL's avatar zL

缓存

parent 2b4e4082
...@@ -174,7 +174,6 @@ export default { ...@@ -174,7 +174,6 @@ export default {
classificationList: [], //系统模板>分类 classificationList: [], //系统模板>分类
theTemplateList: [], //系统模板>分类>模板 theTemplateList: [], //系统模板>分类>模板
checkIndex: 0, // 系统模板>分类>选中效果 checkIndex: 0, // 系统模板>分类>选中效果
TemplateType: 0, //个人模板or系统模板>选中效果
MyCategories: [], // 个人模板>分类 MyCategories: [], // 个人模板>分类
ClassificationPopups: false, //个人模板>分类>添加弹窗 ClassificationPopups: false, //个人模板>分类>添加弹窗
checkClassification: 0, //个人模板>分类>选择效果 checkClassification: 0, //个人模板>分类>选择效果
...@@ -197,11 +196,30 @@ export default { ...@@ -197,11 +196,30 @@ export default {
CopyTemplate, CopyTemplate,
rename, rename,
}, },
computed: {
//个人模板or系统模板>选中效果
TemplateType() {
return this.$store.getters.get_templateType;
},
TemplateDate() {
return this.$store.getters.get_templateData;
},
},
created() { created() {
this.listOfSystem(); if (this.TemplateType === 0) {
if (this.$route.query.type) { // 系统模板
this.TemplateType = 1; this.listOfSystem();
if (!this.TemplateDate.index) return;
this.switchClassification(
this.TemplateDate.item,
this.TemplateDate.index
);
} else {
this.getFolderList(); this.getFolderList();
this.switchPersonalClassification(
this.TemplateDate.item,
this.TemplateDate.index
);
} }
}, },
methods: { methods: {
...@@ -329,6 +347,7 @@ export default { ...@@ -329,6 +347,7 @@ export default {
}, },
// 个人模板>分类>切换 // 个人模板>分类>切换
switchPersonalClassification(item, index) { switchPersonalClassification(item, index) {
this.$store.commit("setTemplateData", { item, index });
this.checkClassification = index; this.checkClassification = index;
this.getpersonalList(item.id); this.getpersonalList(item.id);
}, },
...@@ -355,20 +374,23 @@ export default { ...@@ -355,20 +374,23 @@ export default {
}); });
if (res) { if (res) {
this.MyCategories = res.data.results; this.MyCategories = res.data.results;
if (this.TemplateDate.index) return;
this.getpersonalList(this.MyCategories[0].id); this.getpersonalList(this.MyCategories[0].id);
this.checkClassification = 0; this.checkClassification = 0;
} }
}, },
//个人模板or系统模板切换 //个人模板or系统模板切换
SwitchTemplate(key) { SwitchTemplate(key) {
console.log(key);
switch (key) { switch (key) {
case 0: case 0:
this.TemplateType = 1; this.$store.commit("setTemplateType", 1);
this.$store.commit("setTemplateData", {});
this.getFolderList(); this.getFolderList();
break; break;
case 1: case 1:
this.TemplateType = 0; this.$store.commit("setTemplateType", 0);
this.$store.commit("setTemplateData", {});
this.listOfSystem();
break; break;
default: default:
break; break;
...@@ -384,6 +406,9 @@ export default { ...@@ -384,6 +406,9 @@ export default {
}, },
// 系统模板下的分类切换 // 系统模板下的分类切换
switchClassification(item, index) { switchClassification(item, index) {
if (index !== this.TemplateDate.index) {
this.$store.commit("setTemplateData", { item, index });
}
this.checkIndex = index; this.checkIndex = index;
if (item.detail) { if (item.detail) {
this.theTemplateList = item.detail; this.theTemplateList = item.detail;
...@@ -401,6 +426,7 @@ export default { ...@@ -401,6 +426,7 @@ export default {
}); });
if (res) { if (res) {
this.classificationList = res.data.results; this.classificationList = res.data.results;
if (this.TemplateDate.index) return;
if (res.data.results[0].detail) { if (res.data.results[0].detail) {
this.theTemplateList = res.data.results[0].detail; this.theTemplateList = res.data.results[0].detail;
this.$store.commit( this.$store.commit(
......
...@@ -2,6 +2,8 @@ import { StateTypes } from "./types"; ...@@ -2,6 +2,8 @@ import { StateTypes } from "./types";
import { GetterTree } from "vuex"; import { GetterTree } from "vuex";
const getters: GetterTree<StateTypes, any> = { const getters: GetterTree<StateTypes, any> = {
get_templateType: state => state.templateType,
get_templateData: state => state.templateData,
}; };
export default getters; export default getters;
...@@ -50,7 +50,14 @@ const mutations: MutationTree<StateTypes> = { ...@@ -50,7 +50,14 @@ const mutations: MutationTree<StateTypes> = {
}, },
setChainStatus(state, str) { setChainStatus(state, str) {
state.chainStatus = str state.chainStatus = str
} },
setTemplateType(state, num) {
state.templateType = num
},
setTemplateData(state, data) {
state.templateData = data
},
// templateData
}; };
export default mutations; export default mutations;
...@@ -14,7 +14,9 @@ const state: StateTypes = { ...@@ -14,7 +14,9 @@ const state: StateTypes = {
userInfos: {}, userInfos: {},
templateNum: 0, //模板数量 templateNum: 0, //模板数量
theAnchor: -1, theAnchor: -1,
chainStatus: '' chainStatus: '',
templateType: 0,
templateData: {}
}; };
export default state; export default state;
...@@ -13,6 +13,8 @@ export interface StateTypes { ...@@ -13,6 +13,8 @@ export interface StateTypes {
userInfos: object, // 用户信息 userInfos: object, // 用户信息
templateNum: number, // 模板数量 templateNum: number, // 模板数量
theAnchor: number, //用于记录增量列表的展开 theAnchor: number, //用于记录增量列表的展开
chainStatus: string chainStatus: string,
templateType: number,
templateData:any
} }
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