Commit e940b85d authored by leon's avatar leon

feat:support folder data

parent 7da36d43
<template>
<view>
</view>
</template>
<script>
import echartElementData from '@/mixins/echartElementData.js'
export default {
name: 'Folder',
mixins: [echartElementData],
props: {
elementInfo: {
type: Object,
required: true
}
},
methods: {
initChart() {
uni.$emit(`folder_${this.elementInfo.id}`, this.elementData.dataList)
}
}
}
</script>
<style>
</style>
......@@ -39,6 +39,11 @@ export default {
let res = await that.$u.api[`${dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, {
custom: { loading: false }
})
// 文件夹类型的数据,直接拿接口返回数据
if (this.elementInfo.type === 'folder') {
that.elementData.dataList = res.data
return
}
if (dataProcessing) {
that.elementData.dataList = that.$u.common.converFunction(dataProcessing, res.data, value.queryFormatter)
} else if (dataConfig && dataConfig.value && dataConfig.value.length) {
......@@ -96,6 +101,24 @@ export default {
}
},
/** 文件数据 */
handleFolderData(value) {
const that = this
const { dataProcessing, dataConfig} = { ...value }
uni.$on(`folder_${that.elementInfo.folderId}`, data => {
if (!data) return
if (dataProcessing) {
that.elementData.dataList = that.$u.common.converFunction(dataProcessing, data)
return
}
if (dataConfig && dataConfig.value && dataConfig.value.length) {
that.elementData.dataList = that.$u.charts.parseChartData(data, that.elementInfo)
return
}
that.elementData.dataList = JSON.parse(JSON.stringify(data))
})
},
clearTimer() {
clearInterval(this.timer)
this.timer = null
......@@ -134,7 +157,7 @@ export default {
that.handleStaticData(newVal)
} else if (newVal.dataType === 'dynamic') {
that.handleDynamicData(newVal)
if (newVal.dataPolling) {
if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => {
that.handleDynamicData(newVal)
}, newVal.dataPollingInterval * 1000)
......@@ -145,7 +168,7 @@ export default {
that.handlePublicData(newVal)
} else if (newVal.dataType === 'dataSet') {
that.handleDataSet(newVal)
if (newVal.dataPolling) {
if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => {
that.handleDataSet(newVal)
}, newVal.dataPollingInterval * 1000)
......@@ -154,13 +177,22 @@ export default {
}
} else if (newVal.dataType === 'viewConfig') {
that.handleViewConfig(newVal)
if (newVal.dataPolling) {
if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => {
that.handleViewConfig(newVal)
}, newVal.dataPollingInterval * 1000)
} else {
clearInterval(that.timer)
}
} else if (newVal.dataType === 'folder') {
that.handleFolderData(newVal)
if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => {
that.handleFolderData(newVal)
}, newVal.dataPollingInterval * 1000)
} else {
clearInterval(that.timer)
}
}
},
deep: true,
......
......@@ -57,6 +57,7 @@
<!-- 普通表格 -->
<NormalTable v-if="element.type == 'NormalTable'" :elementInfo="element"></NormalTable>
<!-- <Table v-if="element.type == 'NormalTable'" :elementInfo="element"></Table> -->
<Folder v-if="element.type == 'folder'" :elementInfo="element"></Folder>
</view>
</template>
......@@ -252,6 +253,8 @@
}, parseInt(info.dataPollingInterval) * 1000)
}
}
// 处理图层关系
res.data.Result.list = this.$u.common.elementFolderId(res.data.Result.list)
that.reportInfo = this.handleTabsLink(res.data.Result)
// 清除数据
if(uni.getStorageSync('reportInfo')) {
......
......@@ -258,7 +258,7 @@ const install = (Vue, vm) => {
/**
*
* @param yAxis 表单的yAxis设置
* @param axis 表单的axis设置
*/
const dealAxisFormatter = (axis) => {
if (!axis) {
......@@ -276,9 +276,27 @@ const install = (Vue, vm) => {
}
}
return axis
}
}
/**
* 图层关系关联 子组件获取到folderId
* @param {elements}
*/
const elementFolderId = (elements) => {
elements.forEach(element => {
if (element.type === 'folder') {
element.child.data.forEach(item => {
const index = elements.findIndex(ele => ele.id === item)
if(index != -1) {
elements[index].folderId = element.id
elements[index].isChild = true
}
})
}
})
return elements
}
vm.$u.common = {
converFunction,
......@@ -291,7 +309,8 @@ const install = (Vue, vm) => {
getQueryFromString,
filterRequestParams,
dealTooltip,
dealAxisFormatter
dealAxisFormatter,
elementFolderId
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment