Commit 7602dff5 authored by leon's avatar leon

Merge branch 'develop' into feature-retail

parents 0023edeb d8bfcee2
<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>
...@@ -130,9 +130,11 @@ ...@@ -130,9 +130,11 @@
} }
if(chart) { if(chart) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries if(option) {
// 重新setOption,使得设置的formatter生效 option.series = dealSeries
chart.setOption(option) // 重新setOption,使得设置的formatter生效
chart.setOption(option)
}
} }
}) })
}, },
......
...@@ -131,7 +131,10 @@ ...@@ -131,7 +131,10 @@
} }
}, },
methods: { methods: {
initChart() { initChart() {
if(!this.elementData.dataList) {
return
}
this.tabsValue = this.elementInfo.option.tabs.defaultValue this.tabsValue = this.elementInfo.option.tabs.defaultValue
if (this.elementData.dataList.defaultValue) { if (this.elementData.dataList.defaultValue) {
this.tabsValue = this.elementData.dataList.defaultValue this.tabsValue = this.elementData.dataList.defaultValue
...@@ -266,7 +269,9 @@ ...@@ -266,7 +269,9 @@
display: flex !important; display: flex !important;
align-items: flex-start; align-items: flex-start;
flex-wrap: wrap; flex-wrap: wrap;
width: 100%; width: 100%;
justify-content: center;
align-items: center;
} }
.tab-vertical { .tab-vertical {
display: flex !important; display: flex !important;
...@@ -277,7 +282,7 @@ ...@@ -277,7 +282,7 @@
.tab-item { .tab-item {
width: var(--width); width: var(--width);
margin: 1%; margin: 3px;
font-size: var(--font-size); font-size: var(--font-size);
color: var(--color); color: var(--color);
border: var(--border-style); border: var(--border-style);
......
...@@ -35,5 +35,7 @@ Vue.use(HTTPApi, app) ...@@ -35,5 +35,7 @@ Vue.use(HTTPApi, app)
// 自定义方法 // 自定义方法
import common from './utils/common.js' import common from './utils/common.js'
Vue.use(common, app) Vue.use(common, app)
import charts from './mixins/charts.js'
Vue.use(charts, app)
app.$mount() app.$mount()
This diff is collapsed.
...@@ -33,12 +33,21 @@ export default { ...@@ -33,12 +33,21 @@ export default {
async handleDynamicData (value) { async handleDynamicData (value) {
const that = this const that = this
let { dataUrl, dataMethod, dataFormatter, dataProcessing, dataConfig } = { ...value } let { dataUrl, dataMethod, dataFormatter, dataProcessing, dataConfig } = { ...value }
if (!dataUrl.length) {
return
}
if(value.queryFormatter) dataFormatter = {...dataFormatter, ...value.queryFormatter} if(value.queryFormatter) dataFormatter = {...dataFormatter, ...value.queryFormatter}
dataUrl = dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '') dataUrl = dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '')
dataFormatter = that.$u.common.filterRequestParams({...dataFormatter}) dataFormatter = that.$u.common.filterRequestParams({...dataFormatter})
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) {
...@@ -95,6 +104,24 @@ export default { ...@@ -95,6 +104,24 @@ export default {
message.warning(Msg) message.warning(Msg)
} }
}, },
/** 文件数据 */
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)
...@@ -163,6 +190,15 @@ export default { ...@@ -163,6 +190,15 @@ export default {
} 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,
...@@ -181,8 +217,8 @@ export default { ...@@ -181,8 +217,8 @@ export default {
} }
}, },
'elementData.dataList': { 'elementData.dataList': {
handler(newVal) { handler(newVal,oldVal) {
if (newVal) { if (JSON.stringify(newVal) !== '{}' && JSON.stringify(newVal) !== JSON.stringify(oldVal) ) {
this.setStorageData() this.setStorageData()
this.initChart() this.initChart()
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,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>
<ModelData <ModelData
...@@ -226,6 +227,8 @@ ...@@ -226,6 +227,8 @@
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
// 处理图层关系
res.data.Result.list = this.$u.common.elementFolderId(res.data.Result.list)
// 清除数据 // 清除数据
if(uni.getStorageSync('reportInfo')) { if(uni.getStorageSync('reportInfo')) {
let cacheInfo = JSON.parse(uni.getStorageSync('reportInfo')) let cacheInfo = JSON.parse(uni.getStorageSync('reportInfo'))
...@@ -236,37 +239,11 @@ ...@@ -236,37 +239,11 @@
} }
}) })
} }
that.reportInfo = this.handleTabsLink(res.data.Result) that.reportInfo = res.data.Result
uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result)) uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result))
that.getStickyTables() that.getStickyTables()
} }
}, },
/**
* tabs 组件处理关联关系
*/
handleTabsLink(data) {
data.list.forEach(item => {
if(item.type === 'NormalTabs' && (item.child.index.length || item.child.data.length)) {
if (item.child.index.length) {
item.child.index.forEach(child => {
const index = data.list.findIndex(i => i.id === child )
if(index != -1) {
data.list[index].linkTabsId = item.id
}
})
}
if (item.child.data.length) {
item.child.data.forEach(child => {
const index = data.list.findIndex(i => i.id === child.comp )
if(index != -1) {
data.list[index].linkTabsId = item.id
}
})
}
}
})
return data
},
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
......
<template> <template>
<view class="wrapper" :class="{'tabs-layout': showTabs}" :style="{width: `${theStyle.width - theStyle.left}px`, left:`${theStyle.left}px`}"> <view class="wrapper" :style="{width: `${theStyle.width - theStyle.left}px`, left:`${theStyle.left}px`}">
<!-- 普通选项卡 -->
<view v-if="showTabs" <view :style="{ height: `${theStyle.height}px`, width: `${theStyle.width - theStyle.left}px`, zIndex: 9}">
style="position: fixed;top: 0;"
:style="{
width: `${parseInt(tabsElement.width * scale)}px`,
height: `${parseInt(tabsElement.height * (scale > 1 ? 1 : scale))}px`,
left: `${parseInt(tabsElement.left * scale)}px`,
zIndex: 10
}"
>
<NormalTabs
:elementInfo="tabsElement"
></NormalTabs>
</view>
<view :style="{'margin-top': `${tabsElement.height * (scale > 1 ? 1 : scale)}px`, height: `${theStyle.height}px`, width: `${theStyle.width - theStyle.left}px`, zIndex: 9}">
<!-- 普通柱状图 --> <!-- 普通柱状图 -->
<NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar> <NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar>
<!-- 普通折线图 --> <!-- 普通折线图 -->
...@@ -32,15 +19,10 @@ ...@@ -32,15 +19,10 @@
export default { export default {
data() { data() {
return { return {
element: {}, element: {}
linkTabsId: '',
tabsElement: {}
} }
}, },
computed: { computed: {
showTabs() {
return this.linkTabsId && Object.keys(this.tabsElement).length
},
theStyle() { theStyle() {
const { windowWidth, windowHeight, screenHeight, safeArea } = uni.getSystemInfoSync() const { windowWidth, windowHeight, screenHeight, safeArea } = uni.getSystemInfoSync()
const reduceBottom = screenHeight - safeArea.bottom const reduceBottom = screenHeight - safeArea.bottom
...@@ -50,71 +32,12 @@ ...@@ -50,71 +32,12 @@
left: safeArea.left left: safeArea.left
} }
}, },
scale() {
let info = JSON.parse(uni.getStorageSync('reportInfo'))
if(JSON.stringify(info) == "{}") {
return
}
const { windowWidth } = uni.getSystemInfoSync()
const { width, height } = info.info
return windowWidth / width
}
}, },
onLoad(option) { onLoad(option) {
this.element = JSON.parse(decodeURIComponent(option.element)) this.element = JSON.parse(decodeURIComponent(option.element))
this.linkTabsId = option.linkTabsId
if(this.linkTabsId && uni.getStorageSync('reportInfo')) {
let info = JSON.parse(uni.getStorageSync('reportInfo'))
const data = info.list.find(item => item.id === this.linkTabsId)
this.tabsElement = data
}
// 去掉全屏的定制按钮 // 去掉全屏的定制按钮
const toolbox = {show: false} const toolbox = {show: false}
this.element.option.toolbox = toolbox this.element.option.toolbox = toolbox
},
onShow() {
/**
* 组件交互 - 组件
*/
uni.$on('handleLinkComp', ({ showData, hideData }) => {
let info = JSON.parse(uni.getStorageSync('reportInfo'))
const data = info.list.find(item => showData[0] === item.id)
data.hide = false
// 去掉全屏的定制按钮
data.option.toolbox = { show: false }
this.element = data
}),
/**
* 组件交互 - 参数
*/
uni.$on('handleLinkParams', ({index, paramName, value}) => {
let reportInfo = JSON.parse(uni.getStorageSync('reportInfo'))
if(index.length && paramName) {
const that = this
reportInfo.list = reportInfo.list.map(item => {
const flag = index.includes(item.id)
if(flag && item.type === 'BasicText' && item.data.dataType === 'static') {
that.$set(item.data.dataList, 'text', value)
}
if(flag && item.data.dataType === 'dynamic') {
if(!item.data.queryFormatter) item.data.queryFormatter = {}
that.$set(item.data.queryFormatter, paramName, value)
}
if(flag && item.data.dataType === 'dataSet') {
if(!item.data.dataSetInfo.queryFormatter) item.data.dataSetInfo.queryFormatter = {}
that.$set(item.data.dataSetInfo.queryFormatter, paramName, value)
}
if(flag && item.data.dataType === 'public') {
if(!item.data.queryFormatter) item.data.queryFormatter = {}
that.$set(item.data.queryFormatter, paramName, value)
}
return item
})
}
this.element = reportInfo.list.find(item => index[0] === item.id)
// 去掉全屏的定制按钮
this.element.option.toolbox = { show: false }
})
} }
} }
</script> </script>
...@@ -133,12 +56,6 @@ ...@@ -133,12 +56,6 @@
padding-bottom: constant(safe-area-inset-bottom); /*兼容 IOS<11.2*/ padding-bottom: constant(safe-area-inset-bottom); /*兼容 IOS<11.2*/
padding-bottom: env(safe-area-inset-bottom); /*兼容 IOS>11.2*/ padding-bottom: env(safe-area-inset-bottom); /*兼容 IOS>11.2*/
} }
.tabs-layout {
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: column;
}
</style> </style>
...@@ -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>
...@@ -123,9 +124,9 @@ ...@@ -123,9 +124,9 @@
// detail页面也会监听这两个事件,所有index页面需要在onShow里面增加监听,在onHide里面移除监听 // detail页面也会监听这两个事件,所有index页面需要在onShow里面增加监听,在onHide里面移除监听
onShow() { onShow() {
const that = this const that = this
// if(uni.getStorageSync('reportInfo')) { if(Object.keys(that.reportInfo).length) {
// this.reportInfo = JSON.parse(uni.getStorageSync('reportInfo')) uni.setStorageSync('reportInfo', JSON.stringify(that.reportInfo))
// } }
/** /**
* 组件交互 - 参数 * 组件交互 - 参数
*/ */
...@@ -246,12 +247,14 @@ ...@@ -246,12 +247,14 @@
if (Status === 'true') { if (Status === 'true') {
if(info.dataUrl) { if(info.dataUrl) {
that.getGlobalData(info, list) that.getGlobalData(info, list)
if(info.dataPollingInterval) { if(info.dataPolling && info.dataPollingInterval > 0) {
that.timename = setInterval(() => { that.timename = setInterval(() => {
that.getGlobalData(info, list) that.getGlobalData(info, list)
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
// 处理图层关系
res.data.Result.list = this.$u.common.elementFolderId(res.data.Result.list)
// 清除数据 // 清除数据
if(uni.getStorageSync('reportInfo')) { if(uni.getStorageSync('reportInfo')) {
let info = JSON.parse(uni.getStorageSync('reportInfo')) let info = JSON.parse(uni.getStorageSync('reportInfo'))
...@@ -262,38 +265,11 @@ ...@@ -262,38 +265,11 @@
} }
}) })
} }
that.reportInfo = res.data.Result
that.reportInfo = this.handleTabsLink(res.data.Result) uni.setStorageSync('reportInfo', JSON.stringify(that.reportInfo))
uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result))
that.getStickyTables() that.getStickyTables()
} }
}, },
/**
* tabs 组件处理关联关系
*/
handleTabsLink(data) {
data.list.forEach(item => {
if(item.type === 'NormalTabs' && (item.child.index.length || item.child.data.length)) {
if (item.child.index.length) {
item.child.index.forEach(child => {
const index = data.list.findIndex(i => i.id === child )
if(index != -1) {
data.list[index].linkTabsId = item.id
}
})
}
if (item.child.data.length) {
item.child.data.forEach(child => {
const index = data.list.findIndex(i => i.id === child.comp )
if(index != -1) {
data.list[index].linkTabsId = item.id
}
})
}
}
})
return data
},
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
......
...@@ -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) {
...@@ -276,9 +276,27 @@ const install = (Vue, vm) => { ...@@ -276,9 +276,27 @@ 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