Commit dc4728d1 authored by Jenny's avatar Jenny

fix: APPF-3855 小程序报表切横屏优化

parent f923dd33
...@@ -63,8 +63,9 @@ ...@@ -63,8 +63,9 @@
show: true, show: true,
icon: svg.enterFull, icon: svg.enterFull,
onclick() { onclick() {
const element = {...that.elementInfo} const { linkTabsId } = that.elementInfo
const url = "/pages/fullscreen/fullscreen?element=" + encodeURIComponent(JSON.stringify(element)) let url = `/pages/fullscreen/fullscreen?element=${encodeURIComponent(JSON.stringify(that.elementInfo))}`
if(linkTabsId) url = `${url}&linkTabsId=${linkTabsId}`
uni.navigateTo({ uni.navigateTo({
url: url url: url
}) })
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<swiper v-if="elementInfo.option.tabs.type === 'group'" class="tab-swiper" <swiper v-if="elementInfo.option.tabs.type === 'group'" class="tab-swiper"
:indicator-dots="tabsGroup.length > 1" :style="[tabsStyle]" :indicator-color="'#ccc'" :indicator-dots="tabsGroup.length > 1" :style="[tabsStyle]" :indicator-color="'#ccc'"
:indicator-active-color="elementInfo.option.tabs.backgroundColor"> :indicator-active-color="elementInfo.option.tabs.backgroundColor">
<swiper-item class="tab-group" v-for="(item, index) in tabsGroup" :key="index"> <swiper-item :class="[styleType === 'vertical' ? 'tab-vertical' : 'tab-group']" v-for="(item, index) in tabsGroup" :key="index">
<view class="tab-item" :class="[tabsValue == tab.value ? 'active' : '']" v-for="tab in item" <view class="tab-item" :class="[tabsValue == tab.value ? 'active' : '']" v-for="tab in item"
:key="tab.value" @click="handleChangeTabValue(tab.value)"> :key="tab.value" @click="handleChangeTabValue(tab.value)">
{{ tab.name }} {{ tab.name }}
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
} = this.elementInfo.option.tabs } = this.elementInfo.option.tabs
return { return {
height: `${this.elementInfo.height}px`, height: `${this.elementInfo.height}px`,
'--width': `${100 / Number(count) - 2}%`, '--width': this.styleType != 'vertical' ? `${100 / Number(count) - 2}%` : '95%',
'--font-size': `${fontSize}px`, '--font-size': `${fontSize}px`,
'--color': color, '--color': color,
'--active-color': activeColor, '--active-color': activeColor,
...@@ -222,6 +222,12 @@ ...@@ -222,6 +222,12 @@
flex-wrap: wrap; flex-wrap: wrap;
width: 100%; width: 100%;
} }
.tab-vertical {
display: flex !important;
flex-direction: column;
align-items: center;
justify-content: center;
}
.tab-item { .tab-item {
width: var(--width); width: var(--width);
......
...@@ -9,9 +9,13 @@ export default { ...@@ -9,9 +9,13 @@ export default {
}, },
props: { props: {
elementInfo: { elementInfo: {
type: Object, type: Object,
required: true required: true
} },
styleType: {
type: String,
default: ''
}
}, },
methods: { methods: {
setStorageData() { setStorageData() {
......
<template> <template>
<view class="wrapper" :style="[theStyle]"> <view class="wrapper" :style="[theStyle]">
<template> <!-- 普通选项卡 -->
<!-- 普通柱状图 --> <NormalTabs v-if="linkTabsId && Object.keys(tabsElement).length" :elementInfo="tabsElement" class="tabs-position"></NormalTabs>
<NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar> <!-- 普通柱状图 -->
<!-- 普通折线图 --> <NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar>
<NormalLine v-if="element.type == 'NormalLine'" :elementInfo="element"></NormalLine> <!-- 普通折线图 -->
<!-- 横向柱状图 --> <NormalLine v-if="element.type == 'NormalLine'" :elementInfo="element"></NormalLine>
<HorizontalBar v-if="element.type == 'HorizontalBar'" :elementInfo="element"></HorizontalBar> <!-- 横向柱状图 -->
<!-- 折柱图 --> <HorizontalBar v-if="element.type == 'HorizontalBar'" :elementInfo="element"></HorizontalBar>
<LineMixBar v-if="element.type == 'LineMixBar'" :elementInfo="element"></LineMixBar> <!-- 折柱图 -->
</template> <LineMixBar v-if="element.type == 'LineMixBar'" :elementInfo="element"></LineMixBar>
</view> </view>
</template> </template>
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
export default { export default {
data() { data() {
return { return {
element: {} element: {},
linkTabsId: '',
tabsElement: {}
} }
}, },
computed: { computed: {
...@@ -30,11 +32,32 @@ ...@@ -30,11 +32,32 @@
}, },
}, },
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)
// data.option.tabs.type = 'vertical'
// data.height = uni.getSystemInfoSync().windowHeight
data.option.tabs.defaultValue = data.child.data.find(item => item.comp === this.element.id).name
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'))
this.element = info.list.find(item => showData[0] === item.id)
// 去掉全屏的定制按钮
const toolbox = {show: false}
this.element.option.toolbox = toolbox
})
}
} }
</script> </script>
...@@ -49,6 +72,20 @@ ...@@ -49,6 +72,20 @@
background-position: center; background-position: center;
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;
}
/* .tabs-position {
position: absolute;
left: 0;
top: 0;
width: 12%;
z-index: 999;
} */
</style> </style>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
that.reportInfo = res.data.Result that.reportInfo = this.handleTabsLink(res.data.Result)
// 清除数据 // 清除数据
if(uni.getStorageSync('reportInfo')) { if(uni.getStorageSync('reportInfo')) {
let info = JSON.parse(uni.getStorageSync('reportInfo')) let info = JSON.parse(uni.getStorageSync('reportInfo'))
...@@ -268,6 +268,20 @@ ...@@ -268,6 +268,20 @@
that.getStickyTables() that.getStickyTables()
} }
}, },
/**
* tabs 组件处理关联关系
*/
handleTabsLink(data) {
data.list.forEach(item => {
if(item.type === 'NormalTabs' && item.child.data.length) {
item.child.data.forEach(child => {
const index = data.list.findIndex(i => i.id === child.comp )
data.list[index].linkTabsId = item.id
})
}
})
return data
},
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
......
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