|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
<template> |
|
|
|
|
<div class="wrap"> |
|
|
|
|
<div class="left"> |
|
|
|
|
<el-menu class="menu" ref="type" @open="openType" @select="selectType" unique-opened :default-active="defaultType" :default-openeds="defaultOpenType"> |
|
|
|
|
<el-menu class="menu" ref="type" @open="selectType" @select="selectType" unique-opened :default-active="defaultType" :default-openeds="defaultOpenType"> |
|
|
|
|
<template v-for="item in typeList"> |
|
|
|
|
<!-- 如果第一层有子菜单,则继续循环 --> |
|
|
|
|
<template v-if="item.children.length"> |
|
|
|
@ -43,11 +43,21 @@ |
|
|
|
|
<template v-if="subItem4.children"> |
|
|
|
|
<el-submenu :index="subItem4.id" :key="subItem4.id"> |
|
|
|
|
<template slot="title"> |
|
|
|
|
<!-- <i :class="item.icon"></i> --> |
|
|
|
|
<!-- <span slot="title">{{ subItem2.title }}</span> --> |
|
|
|
|
{{ subItem4.categoryName }} |
|
|
|
|
</template> |
|
|
|
|
<el-menu-item v-for="(fiveItem,i) in subItem4.children" :key="i" :index="fiveItem.id">{{ fiveItem.categoryName }}</el-menu-item> |
|
|
|
|
<el-menu-item class="level-6" v-for="(subItem5,i) in subItem4.children" :key="i" :index="subItem5.id"> |
|
|
|
|
<!-- 如果第六层有子菜单,则继续循环 --> |
|
|
|
|
<template v-if="subItem5.children"> |
|
|
|
|
<el-submenu :index="subItem5.id" :key="subItem5.id"> |
|
|
|
|
<template slot="title"> |
|
|
|
|
{{ subItem5.categoryName }} |
|
|
|
|
</template> |
|
|
|
|
<el-menu-item v-for="(fiveItem,i) in subItem5.children" :key="i" :index="fiveItem.id">{{ fiveItem.categoryName }}</el-menu-item> |
|
|
|
|
</el-submenu> |
|
|
|
|
</template> |
|
|
|
|
<!-- 如果第五层没有子菜单 --> |
|
|
|
|
<el-menu-item v-else :index="subItem5.id" :key="subItem5.id">{{ subItem5.categoryName }}</el-menu-item> |
|
|
|
|
</el-menu-item> |
|
|
|
|
</el-submenu> |
|
|
|
|
</template> |
|
|
|
|
<!-- 如果第五层没有子菜单 --> |
|
|
|
@ -92,7 +102,7 @@ |
|
|
|
|
</div> |
|
|
|
|
<div class="page-content"> |
|
|
|
|
<div class="desc">{{introduce}}</div> |
|
|
|
|
|
|
|
|
|
<div style="margin-bottom: 30px"><span class="source">数据来源:</span>{{dataSource}}</div> |
|
|
|
|
<el-table :data="listData" class="table" ref="table" stripe header-align="center" row-key="id" highlight-current-row @current-change="previewCurrentChange"> |
|
|
|
|
<el-table-column type="index" width="100" label="序号" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="showName" label="数据表名称" align="center"></el-table-column> |
|
|
|
@ -168,8 +178,6 @@ import { mapState } from 'vuex' |
|
|
|
|
import axios from 'axios' |
|
|
|
|
import util from '@/libs/util' |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import bus from '@/libs/bus' |
|
|
|
|
|
|
|
|
|
let startTimeLimit = '' |
|
|
|
|
let endTimeLimit = '' |
|
|
|
|
export default { |
|
|
|
@ -177,11 +185,12 @@ export default { |
|
|
|
|
return { |
|
|
|
|
that: this, |
|
|
|
|
token: util.local.get(Setting.tokenKey), |
|
|
|
|
typeId: this.$route.query.typeId, |
|
|
|
|
typeId: this.$route.query.typeId, // 从首页跳转过来传的分类id |
|
|
|
|
typeList: [], |
|
|
|
|
defaultType: '', |
|
|
|
|
defaultOpenType: [], |
|
|
|
|
introduce: '', |
|
|
|
|
dataSource: '', |
|
|
|
|
keyword: '', |
|
|
|
|
search:'', |
|
|
|
|
listData: [], |
|
|
|
@ -249,11 +258,6 @@ export default { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
// bus.$on('initData',keyword => { |
|
|
|
|
// this.keyword = keyword |
|
|
|
|
// this.initData() |
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
this.getType() |
|
|
|
|
// 如果是从首页点下载按钮跳转过来的,就直接显示下载弹框 |
|
|
|
|
if(this.$route.query.download){ |
|
|
|
@ -266,78 +270,41 @@ export default { |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
getType(){ |
|
|
|
|
// 麻了,不写递归 |
|
|
|
|
this.$post(this.api.getTableByClassification).then(res => {// 请求菜单栏 |
|
|
|
|
// 获取分类 |
|
|
|
|
this.$post(this.api.getTableByClassification).then(res => { |
|
|
|
|
let typeId = this.typeId // 取得传值的id |
|
|
|
|
let introduce = ''// 对应股票的介绍,规则为无children则取上级 |
|
|
|
|
res.map(n => {// 循环第一次 |
|
|
|
|
n.id = String(n.id) |
|
|
|
|
if(typeId && n.id == typeId) introduce = n.introduce |
|
|
|
|
n.children.map(e => { // 循环第二次 |
|
|
|
|
e.id = String(e.id) |
|
|
|
|
if(typeId && e.id == typeId){ |
|
|
|
|
if(e.introduce){ |
|
|
|
|
introduce = e.introduce |
|
|
|
|
}else{ |
|
|
|
|
introduce = n.introduce |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(e.children.length && typeId == e.id){ |
|
|
|
|
this.defaultOpenType = [n.id,e.id] |
|
|
|
|
} |
|
|
|
|
e.children.map(j => {// 循环第三次 |
|
|
|
|
if(typeId && j.id == typeId && j.introduce){ |
|
|
|
|
if(j.introduce){ |
|
|
|
|
introduce = j.introduce |
|
|
|
|
}else if(e.introduce){ |
|
|
|
|
introduce = e.introduce |
|
|
|
|
}else{ |
|
|
|
|
introduce = n.introduce |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
j.id = String(j.id) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
let dataSource = '' // 数据来源,同上 |
|
|
|
|
let action |
|
|
|
|
// 取得选中的那一栏 |
|
|
|
|
function actionId(arr){//传入res |
|
|
|
|
if(arr&&arr.length>0){ |
|
|
|
|
arr.map(e=>{ |
|
|
|
|
arr && arr.map((e, i) => { |
|
|
|
|
e.id = String(e.id) |
|
|
|
|
if (!i) { |
|
|
|
|
// 获取介绍和来源 |
|
|
|
|
if (e.introduce) introduce = e.introduce |
|
|
|
|
if (e.dataSource) dataSource = e.dataSource |
|
|
|
|
if (!action) action = e.children[0].children.length ? String(e.children[0].children[0].id) : String(e.children[0].id) |
|
|
|
|
} |
|
|
|
|
if(typeId && e.id == typeId) {// 若id匹配 |
|
|
|
|
action = e.id |
|
|
|
|
if(e.children.length>0){// 若有下级 |
|
|
|
|
if(e.children[0].children.length===0){// 找到下级的下级若无子级,则赋值勾选 |
|
|
|
|
action = e.children[0].id |
|
|
|
|
action = String(e.id) |
|
|
|
|
if(e.children.length){// 若有下级 |
|
|
|
|
if(!e.children[0].children.length){// 找到下级的下级若无子级,则赋值勾选 |
|
|
|
|
action = String(e.children[0].id) |
|
|
|
|
}else{// 直接赋值 |
|
|
|
|
action = e.children[0].children[0].id |
|
|
|
|
action = String(e.children[0].children[0].id) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else if(e.children.length>0){// id不匹配,递归找 |
|
|
|
|
}else if(e.children.length){// id不匹配,递归找 |
|
|
|
|
actionId(e.children) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.typeList = res |
|
|
|
|
|
|
|
|
|
if(this.typeId){ |
|
|
|
|
actionId(res) |
|
|
|
|
this.defaultType = action |
|
|
|
|
// this.defaultType = this.typeId |
|
|
|
|
}else{ |
|
|
|
|
if(res[0].children.length && res[0].children[0].children.length){ |
|
|
|
|
this.defaultType = res[0].children[0].children[0].id |
|
|
|
|
introduce = res[0].children[0].children[0].introduce |
|
|
|
|
}else if(res[0].children.length){ |
|
|
|
|
this.defaultType = res[0].children[0].id |
|
|
|
|
if(!introduce) introduce = res[0].children[0].introduce |
|
|
|
|
}else{ |
|
|
|
|
this.defaultType = res[0].id |
|
|
|
|
if(!introduce) introduce = res[0].introduce |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.introduce = introduce |
|
|
|
|
this.dataSource = dataSource |
|
|
|
|
this.getData() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}, |
|
|
|
@ -358,82 +325,35 @@ export default { |
|
|
|
|
this.$refs.table.clearSelection() |
|
|
|
|
this.getData() |
|
|
|
|
}, |
|
|
|
|
selectType(index,indexPath){// 点击事件 |
|
|
|
|
// 分类展开及点击回调 |
|
|
|
|
selectType(index,indexPath){ |
|
|
|
|
let introduce = '' |
|
|
|
|
let dataSource = '' |
|
|
|
|
this.keyword = '' |
|
|
|
|
let list = this.typeList |
|
|
|
|
list.map(n => { |
|
|
|
|
let select = '' |
|
|
|
|
function handleData(data) { |
|
|
|
|
data.map((n, i) => { |
|
|
|
|
// 匹配到点击的分类,默认展开子级第一个分类 |
|
|
|
|
if(n.id == index){ |
|
|
|
|
introduce = n.introduce |
|
|
|
|
if (n.introduce) introduce = n.introduce |
|
|
|
|
if (n.dataSource) dataSource = n.dataSource |
|
|
|
|
if (!select) select = n.children.length ? (n.children[0].children.length ? n.children[0].children[0].id : n.children[0].id) : n.id |
|
|
|
|
}else{ |
|
|
|
|
n.children.map(n => { |
|
|
|
|
if(n.id == index){ |
|
|
|
|
introduce = n.introduce |
|
|
|
|
}else{ |
|
|
|
|
n.children.map(n => { |
|
|
|
|
if(n.id == index) introduce = n.introduce |
|
|
|
|
}) |
|
|
|
|
handleData(n.children) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
handleData(list) |
|
|
|
|
if(!introduce) introduce = list.find(n => n.id == indexPath[0]).introduce |
|
|
|
|
|
|
|
|
|
if(indexPath.length>=2){ |
|
|
|
|
let clikckId = indexPath[indexPath.length-1] |
|
|
|
|
let select |
|
|
|
|
function getSelect(arr){ |
|
|
|
|
if(arr.length>0){ |
|
|
|
|
arr.map(e=>{ |
|
|
|
|
if(e.id==clikckId){ |
|
|
|
|
if(e.children.length===0){ |
|
|
|
|
select = e.id |
|
|
|
|
}else{ |
|
|
|
|
if(e.children[0].children.length>0){ |
|
|
|
|
select = e.children[0].children[0].id |
|
|
|
|
}else{ |
|
|
|
|
select = e.children[0].id |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
getSelect(e.children) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
getSelect(this.typeList) |
|
|
|
|
console.log(select,'dig'); |
|
|
|
|
if(!dataSource) dataSource = list.find(n => n.id == indexPath[0]).dataSource |
|
|
|
|
this.defaultType = select |
|
|
|
|
}else{ |
|
|
|
|
this.defaultType = index |
|
|
|
|
} |
|
|
|
|
this.introduce = introduce |
|
|
|
|
this.dataSource = dataSource |
|
|
|
|
this.previewHead = [] |
|
|
|
|
this.previewData = [] |
|
|
|
|
this.initData() |
|
|
|
|
}, |
|
|
|
|
findId(data,id){ |
|
|
|
|
let result = '' |
|
|
|
|
data.forEach(n => { |
|
|
|
|
if(n.id == id){ |
|
|
|
|
if(n.children[0].children.length){ |
|
|
|
|
return result = n.children[0].children[0].id |
|
|
|
|
}else{ |
|
|
|
|
return result = n.children[0].id |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
this.findId(n.children,id) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
return result |
|
|
|
|
}, |
|
|
|
|
openType(index,indexPath){ |
|
|
|
|
console.log(11,this.typeList) |
|
|
|
|
let id = this.findId(this.typeList,index) |
|
|
|
|
this.selectType(id,indexPath) |
|
|
|
|
}, |
|
|
|
|
previewCurrentChange(val){ |
|
|
|
|
this.currentRow = val |
|
|
|
|
}, |
|
|
|
@ -629,6 +549,12 @@ export default { |
|
|
|
|
.el-menu-item.is-active{ |
|
|
|
|
color: $main-color; |
|
|
|
|
} |
|
|
|
|
.level-6 { |
|
|
|
|
padding-right: 0; |
|
|
|
|
.el-submenu__title { |
|
|
|
|
padding-left: 10px !important; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.right{ |
|
|
|
@ -637,9 +563,12 @@ export default { |
|
|
|
|
.page{ |
|
|
|
|
margin-bottom: 20px; |
|
|
|
|
.desc{ |
|
|
|
|
margin-bottom: 30px; |
|
|
|
|
margin-bottom: 20px; |
|
|
|
|
color: #333; |
|
|
|
|
} |
|
|
|
|
.source { |
|
|
|
|
color: #568DF2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|