|
|
@ -194,11 +194,10 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
getType(id = 0) { |
|
|
|
getType() { |
|
|
|
// 获取分类 |
|
|
|
// 获取分类 |
|
|
|
this.$post(`${this.api.getLevel}?parentId=${id}`).then(res => { |
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
const list = res.list |
|
|
|
let typeId = this.typeId // 取得传值的id |
|
|
|
let typeId = this.typeId // 取得首页传过来的id |
|
|
|
|
|
|
|
let introduce = ''// 对应股票的介绍,规则为无children则取上级 |
|
|
|
let introduce = ''// 对应股票的介绍,规则为无children则取上级 |
|
|
|
let dataSource = '' // 数据来源,同上 |
|
|
|
let dataSource = '' // 数据来源,同上 |
|
|
|
let action |
|
|
|
let action |
|
|
@ -217,25 +216,20 @@ export default { |
|
|
|
if (i) isFirst = false |
|
|
|
if (i) isFirst = false |
|
|
|
if (typeId && e.id == typeId) {// 若id匹配 |
|
|
|
if (typeId && e.id == typeId) {// 若id匹配 |
|
|
|
action = String(e.id) |
|
|
|
action = String(e.id) |
|
|
|
if (e.children && e.children.length) {// 若有下级 |
|
|
|
if (e.children.length) {// 若有下级 |
|
|
|
if (!e.children[0].children.length) {// 找到下级的下级若无子级,则赋值勾选 |
|
|
|
if (!e.children[0].children.length) {// 找到下级的下级若无子级,则赋值勾选 |
|
|
|
action = String(e.children[0].id) |
|
|
|
action = String(e.children[0].id) |
|
|
|
} else {// 直接赋值 |
|
|
|
} else {// 直接赋值 |
|
|
|
action = String(e.children[0].children[0].id) |
|
|
|
action = String(e.children[0].children[0].id) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (e.children && e.children.length) { // id不匹配,递归找 |
|
|
|
} else if (e.children.length) { // id不匹配,递归找 |
|
|
|
actionId(e.children) |
|
|
|
actionId(e.children) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
if (id) { |
|
|
|
this.typeList = res |
|
|
|
this.typeList[0].children = list |
|
|
|
actionId(res) |
|
|
|
} else { |
|
|
|
|
|
|
|
this.typeList = list |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(11, this.typeList) |
|
|
|
|
|
|
|
actionId(list) |
|
|
|
|
|
|
|
this.defaultType = action |
|
|
|
this.defaultType = action |
|
|
|
this.introduce = introduce |
|
|
|
this.introduce = introduce |
|
|
|
this.dataSource = dataSource |
|
|
|
this.dataSource = dataSource |
|
|
@ -281,45 +275,44 @@ export default { |
|
|
|
let introduce = '' |
|
|
|
let introduce = '' |
|
|
|
let dataSource = '' |
|
|
|
let dataSource = '' |
|
|
|
this.keyword = '' |
|
|
|
this.keyword = '' |
|
|
|
this.getType(index) |
|
|
|
let list = this.typeList |
|
|
|
// let list = this.typeList |
|
|
|
let select = '' |
|
|
|
// let select = '' |
|
|
|
// 获取最里层的第一个子级id |
|
|
|
// // 获取最里层的第一个子级id |
|
|
|
function getDeepest(data) { |
|
|
|
// function getDeepest(data) { |
|
|
|
if (data[0].children && data[0].children.length) { |
|
|
|
// if (data[0].children && data[0].children.length) { |
|
|
|
getDeepest(data[0].children) |
|
|
|
// getDeepest(data[0].children) |
|
|
|
} else { |
|
|
|
// } else { |
|
|
|
select = data[0].id |
|
|
|
// select = data[0].id |
|
|
|
if (data[0].introduce) introduce = data[0].introduce |
|
|
|
// if (data[0].introduce) introduce = data[0].introduce |
|
|
|
if (data[0].dataSource) dataSource = data[0].dataSource |
|
|
|
// if (data[0].dataSource) dataSource = data[0].dataSource |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
// } |
|
|
|
function handleData(data) { |
|
|
|
// function handleData(data) { |
|
|
|
data.map((n, i) => { |
|
|
|
// data.map((n, i) => { |
|
|
|
// 匹配到点击的分类,默认展开子级第一个分类 |
|
|
|
// // 匹配到点击的分类,默认展开子级第一个分类 |
|
|
|
if (n.id == index) { |
|
|
|
// if (n.id == index) { |
|
|
|
// 如果有子级,则递归取到最下面的第一级子级id,如果没有子级,则取当前id |
|
|
|
// // 如果有子级,则递归取到最下面的第一级子级id,如果没有子级,则取当前id |
|
|
|
if (n.children.length) { |
|
|
|
// if (n.children.length) { |
|
|
|
getDeepest(n.children) |
|
|
|
// getDeepest(n.children) |
|
|
|
} else { |
|
|
|
// } else { |
|
|
|
select = index |
|
|
|
// select = index |
|
|
|
if (n.introduce) introduce = n.introduce |
|
|
|
// if (n.introduce) introduce = n.introduce |
|
|
|
if (n.dataSource) dataSource = n.dataSource |
|
|
|
// if (n.dataSource) dataSource = n.dataSource |
|
|
|
} |
|
|
|
// } |
|
|
|
} else { |
|
|
|
// } else { |
|
|
|
handleData(n.children) |
|
|
|
// handleData(n.children) |
|
|
|
} |
|
|
|
// } |
|
|
|
}) |
|
|
|
// }) |
|
|
|
} |
|
|
|
// } |
|
|
|
handleData(list) |
|
|
|
// handleData(list) |
|
|
|
if (!introduce) introduce = list.find(n => n.id == indexPath[0]).introduce |
|
|
|
// if (!introduce) introduce = list.find(n => n.id == indexPath[0]).introduce |
|
|
|
if (!dataSource) dataSource = list.find(n => n.id == indexPath[0]).dataSource |
|
|
|
// if (!dataSource) dataSource = list.find(n => n.id == indexPath[0]).dataSource |
|
|
|
this.defaultType = select |
|
|
|
// this.defaultType = select |
|
|
|
this.introduce = introduce |
|
|
|
// this.introduce = introduce |
|
|
|
this.dataSource = dataSource |
|
|
|
// this.dataSource = dataSource |
|
|
|
this.previewHead = [] |
|
|
|
// this.previewHead = [] |
|
|
|
this.previewData = [] |
|
|
|
// this.previewData = [] |
|
|
|
this.initData() |
|
|
|
// this.initData() |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
previewCurrentChange(val) { |
|
|
|
previewCurrentChange(val) { |
|
|
|
this.currentRow = val |
|
|
|
this.currentRow = val |
|
|
|