|
|
@@ -226,10 +226,23 @@ export default {
|
|
|
this.loading = true;
|
|
|
listUserCourseCategory(this.queryParams).then(response => {
|
|
|
this.userCourseCategoryList = this.handleTree(response.data, "cateId", "pid");
|
|
|
+ this.fillType(this.userCourseCategoryList);
|
|
|
this.total = response.total;
|
|
|
this.loading = false;
|
|
|
});
|
|
|
},
|
|
|
+ /** type 只在顶级分类维护,子分类为空时继承父级的 type */
|
|
|
+ fillType(nodes, parentType) {
|
|
|
+ if (!nodes || !nodes.length) return
|
|
|
+ nodes.forEach(node => {
|
|
|
+ if ((node.type === null || node.type === undefined || node.type === '') && parentType != null) {
|
|
|
+ node.type = parentType
|
|
|
+ }
|
|
|
+ if (node.children && node.children.length) {
|
|
|
+ this.fillType(node.children, node.type)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
/** 转换课程分类数据结构 */
|
|
|
normalizer(node) {
|
|
|
if (node.children && !node.children.length) {
|