diff --git a/src/api/index.js b/src/api/index.js index b55e878..940f258 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -79,6 +79,7 @@ export default { downloadAgain:`/data/data/downloadAgain`, isDownload:`/data/data/product/isDownload`, getTableTime:`/data/data/tableTime/getTableTime`, + getLevel: `/data/category/getLevel`, // 数据操作记录 queryAccumulate:`/data/data/dataRecord/queryAccumulate`, diff --git a/src/components/menuTree/index.vue b/src/components/menuTree/index.vue new file mode 100644 index 0000000..4b39e34 --- /dev/null +++ b/src/components/menuTree/index.vue @@ -0,0 +1,35 @@ + + + + diff --git a/src/pages/data/list/index.vue b/src/pages/data/list/index.vue index 8ee4424..098782b 100644 --- a/src/pages/data/list/index.vue +++ b/src/pages/data/list/index.vue @@ -2,90 +2,7 @@
- +
@@ -181,9 +98,13 @@ import { mapState } from 'vuex' import axios from 'axios' import util from '@/libs/util' import Setting from '@/setting' +import menuTree from '@/components/menuTree' let startTimeLimit = '' let endTimeLimit = '' export default { + components: { + menuTree + }, data() { return { that: this, @@ -273,10 +194,11 @@ export default { } }, methods: { - getType() { + getType(id = 0) { // 获取分类 - this.$post(this.api.getTableByClassification).then(res => { - let typeId = this.typeId // 取得传值的id + this.$post(`${this.api.getLevel}?parentId=${id}`).then(res => { + const list = res.list + let typeId = this.typeId // 取得首页传过来的id let introduce = ''// 对应股票的介绍,规则为无children则取上级 let dataSource = '' // 数据来源,同上 let action @@ -295,20 +217,25 @@ export default { if (i) isFirst = false if (typeId && e.id == typeId) {// 若id匹配 action = String(e.id) - if (e.children.length) {// 若有下级 + if (e.children && e.children.length) {// 若有下级 if (!e.children[0].children.length) {// 找到下级的下级若无子级,则赋值勾选 action = String(e.children[0].id) } else {// 直接赋值 action = String(e.children[0].children[0].id) } } - } else if (e.children.length) { // id不匹配,递归找 + } else if (e.children && e.children.length) { // id不匹配,递归找 actionId(e.children) } }) } - this.typeList = res - actionId(res) + if (id) { + this.typeList[0].children = list + } else { + this.typeList = list + } + console.log(11, this.typeList) + actionId(list) this.defaultType = action this.introduce = introduce this.dataSource = dataSource @@ -354,44 +281,45 @@ export default { let introduce = '' let dataSource = '' this.keyword = '' - let list = this.typeList - let select = '' - // 获取最里层的第一个子级id - function getDeepest(data) { - if (data[0].children && data[0].children.length) { - getDeepest(data[0].children) - } else { - select = data[0].id - if (data[0].introduce) introduce = data[0].introduce - if (data[0].dataSource) dataSource = data[0].dataSource - } - } - function handleData(data) { - data.map((n, i) => { - // 匹配到点击的分类,默认展开子级第一个分类 - if (n.id == index) { - // 如果有子级,则递归取到最下面的第一级子级id,如果没有子级,则取当前id - if (n.children.length) { - getDeepest(n.children) - } else { - select = index - if (n.introduce) introduce = n.introduce - if (n.dataSource) dataSource = n.dataSource - } - } else { - handleData(n.children) - } - }) - } - handleData(list) - if (!introduce) introduce = list.find(n => n.id == indexPath[0]).introduce - if (!dataSource) dataSource = list.find(n => n.id == indexPath[0]).dataSource - this.defaultType = select - this.introduce = introduce - this.dataSource = dataSource - this.previewHead = [] - this.previewData = [] - this.initData() + this.getType(index) + // let list = this.typeList + // let select = '' + // // 获取最里层的第一个子级id + // function getDeepest(data) { + // if (data[0].children && data[0].children.length) { + // getDeepest(data[0].children) + // } else { + // select = data[0].id + // if (data[0].introduce) introduce = data[0].introduce + // if (data[0].dataSource) dataSource = data[0].dataSource + // } + // } + // function handleData(data) { + // data.map((n, i) => { + // // 匹配到点击的分类,默认展开子级第一个分类 + // if (n.id == index) { + // // 如果有子级,则递归取到最下面的第一级子级id,如果没有子级,则取当前id + // if (n.children.length) { + // getDeepest(n.children) + // } else { + // select = index + // if (n.introduce) introduce = n.introduce + // if (n.dataSource) dataSource = n.dataSource + // } + // } else { + // handleData(n.children) + // } + // }) + // } + // handleData(list) + // if (!introduce) introduce = list.find(n => n.id == indexPath[0]).introduce + // if (!dataSource) dataSource = list.find(n => n.id == indexPath[0]).dataSource + // this.defaultType = select + // this.introduce = introduce + // this.dataSource = dataSource + // this.previewHead = [] + // this.previewData = [] + // this.initData() }, previewCurrentChange(val) { this.currentRow = val diff --git a/src/setting.js b/src/setting.js index 08fe481..5689f17 100644 --- a/src/setting.js +++ b/src/setting.js @@ -24,7 +24,7 @@ const Setting = { showProgressBar: true, // 接口请求地址 // apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : 'http://39.108.250.202:9000',// 佳坤 - apiBaseURL: env === 'development' ? 'http://192.168.31.151:9000' : 'http://39.108.250.202:9000', + apiBaseURL: env === 'development' ? 'http://39.108.250.202:9000' : 'http://39.108.250.202:9000', // 接口请求返回错误时,弹窗的持续时间,单位:秒 modalDuration: 3, // 接口请求返回错误时,弹窗的类型,可选值为 Message 或 Notice