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 { ...@@ -39,6 +39,11 @@ export default {
let res = await that.$u.api[`${dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, { let res = await that.$u.api[`${dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, {
custom: { loading: false } custom: { loading: false }
}) })
// 文件夹类型的数据,直接拿接口返回数据
if (this.elementInfo.type === 'folder') {
that.elementData.dataList = res.data
return
}
if (dataProcessing) { if (dataProcessing) {
that.elementData.dataList = that.$u.common.converFunction(dataProcessing, res.data, value.queryFormatter) that.elementData.dataList = that.$u.common.converFunction(dataProcessing, res.data, value.queryFormatter)
} else if (dataConfig && dataConfig.value && dataConfig.value.length) { } else if (dataConfig && dataConfig.value && dataConfig.value.length) {
...@@ -96,6 +101,24 @@ export default { ...@@ -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() { clearTimer() {
clearInterval(this.timer) clearInterval(this.timer)
this.timer = null this.timer = null
...@@ -134,7 +157,7 @@ export default { ...@@ -134,7 +157,7 @@ export default {
that.handleStaticData(newVal) that.handleStaticData(newVal)
} else if (newVal.dataType === 'dynamic') { } else if (newVal.dataType === 'dynamic') {
that.handleDynamicData(newVal) that.handleDynamicData(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => { that.timer = setInterval(() => {
that.handleDynamicData(newVal) that.handleDynamicData(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
...@@ -145,7 +168,7 @@ export default { ...@@ -145,7 +168,7 @@ export default {
that.handlePublicData(newVal) that.handlePublicData(newVal)
} else if (newVal.dataType === 'dataSet') { } else if (newVal.dataType === 'dataSet') {
that.handleDataSet(newVal) that.handleDataSet(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => { that.timer = setInterval(() => {
that.handleDataSet(newVal) that.handleDataSet(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
...@@ -154,13 +177,22 @@ export default { ...@@ -154,13 +177,22 @@ export default {
} }
} else if (newVal.dataType === 'viewConfig') { } else if (newVal.dataType === 'viewConfig') {
that.handleViewConfig(newVal) that.handleViewConfig(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => { that.timer = setInterval(() => {
that.handleViewConfig(newVal) that.handleViewConfig(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
} else { } else {
clearInterval(that.timer) 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, deep: true,
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
<!-- 普通表格 --> <!-- 普通表格 -->
<NormalTable v-if="element.type == 'NormalTable'" :elementInfo="element"></NormalTable> <NormalTable v-if="element.type == 'NormalTable'" :elementInfo="element"></NormalTable>
<!-- <Table v-if="element.type == 'NormalTable'" :elementInfo="element"></Table> --> <!-- <Table v-if="element.type == 'NormalTable'" :elementInfo="element"></Table> -->
<Folder v-if="element.type == 'folder'" :elementInfo="element"></Folder>
</view> </view>
</template> </template>
...@@ -252,6 +253,8 @@ ...@@ -252,6 +253,8 @@
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
// 处理图层关系
res.data.Result.list = this.$u.common.elementFolderId(res.data.Result.list)
that.reportInfo = this.handleTabsLink(res.data.Result) that.reportInfo = this.handleTabsLink(res.data.Result)
// 清除数据 // 清除数据
if(uni.getStorageSync('reportInfo')) { if(uni.getStorageSync('reportInfo')) {
......
...@@ -258,7 +258,7 @@ const install = (Vue, vm) => { ...@@ -258,7 +258,7 @@ const install = (Vue, vm) => {
/** /**
* *
* @param yAxis 表单的yAxis设置 * @param axis 表单的axis设置
*/ */
const dealAxisFormatter = (axis) => { const dealAxisFormatter = (axis) => {
if (!axis) { if (!axis) {
...@@ -278,7 +278,25 @@ const install = (Vue, vm) => { ...@@ -278,7 +278,25 @@ const install = (Vue, vm) => {
return axis 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 = { vm.$u.common = {
converFunction, converFunction,
...@@ -291,7 +309,8 @@ const install = (Vue, vm) => { ...@@ -291,7 +309,8 @@ const install = (Vue, vm) => {
getQueryFromString, getQueryFromString,
filterRequestParams, filterRequestParams,
dealTooltip, 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