mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-11 11:56:44 +08:00
修改课程分类缓存问题
This commit is contained in:
@@ -17,15 +17,15 @@ const mutations={
|
||||
const actions={
|
||||
getSysTypeTree({commit}) {
|
||||
return new Promise((resolve,reject)=>{
|
||||
if(state.sysTypeTree.length>0){
|
||||
resolve(state.sysTypeTree);
|
||||
}else{
|
||||
let hasData = sessionStorage.getItem('sysTypeTree');
|
||||
if(hasData){
|
||||
let treeData = JSON.parse(hasData);
|
||||
commit('setSysTypeTree', treeData);
|
||||
resolve(treeData);
|
||||
}else{
|
||||
// if(state.sysTypeTree.length>0){
|
||||
// resolve(state.sysTypeTree);
|
||||
// }else{
|
||||
// let hasData = sessionStorage.getItem('sysTypeTree');
|
||||
// if(hasData){
|
||||
// let treeData = JSON.parse(hasData);
|
||||
// commit('setSysTypeTree', treeData);
|
||||
// resolve(treeData);
|
||||
// }else{
|
||||
apiType.tree(1).then(res=>{
|
||||
if(res.status === 200) {
|
||||
sessionStorage.setItem('sysTypeTree',JSON.stringify(res.result));
|
||||
@@ -51,8 +51,8 @@ const mutations={
|
||||
reject('资源归属获取失败!');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
});
|
||||
},
|
||||
loadSysTypes(context){
|
||||
|
||||
@@ -406,50 +406,15 @@ export default {
|
||||
this.resOwnerListMap=rs;
|
||||
});
|
||||
// 取消全局课程分类
|
||||
// this.getSysTypeTree().then(rs=>{
|
||||
// this.sysTypeListMap=rs;
|
||||
// })
|
||||
// 新增的获取内容分类
|
||||
this.getCourseList();
|
||||
this.getSysTypeTree().then(rs=>{
|
||||
this.sysTypeListMap=rs;
|
||||
})
|
||||
//已经加载tree的情况下,不需要再单独的加载一次
|
||||
this.loadResOwners();
|
||||
this.loadSysTypes();
|
||||
|
||||
},
|
||||
methods: {
|
||||
getCourseList(){
|
||||
// this.getSysTypeTree().then(rs => {
|
||||
// this.sysTypeListMap = rs;
|
||||
// console.log(rs,'您好啊好好');
|
||||
|
||||
// });
|
||||
apiType.tree(1).then(res=>{
|
||||
if(res.status === 200) {
|
||||
sessionStorage.setItem('sysTypeTree',JSON.stringify(res.result));
|
||||
this.$store.commit('sysType/setSysTypeTree', res.result);
|
||||
this.sysTypeListMap = res.result;
|
||||
//转化为map放到状态中
|
||||
let map=new Map();
|
||||
res.result.forEach(item=>{
|
||||
map.set(item.id, item.name);
|
||||
if(item.children && item.children!=''){
|
||||
item.children.forEach(child=>{
|
||||
map.set(child.id, child.name);
|
||||
if(child.children && child.children!=''){
|
||||
child.children.forEach(last=>{
|
||||
map.set(last.id, last.name);
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
this.$store.commit('sysType/setSysTypeMap', map);
|
||||
} else {
|
||||
// reject('资源归属获取失败!');
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
showStudent(row){
|
||||
//出现学员管理
|
||||
window.parent.openSelectStu(row);
|
||||
|
||||
Reference in New Issue
Block a user