Commit f7f5fc62 authored by leon's avatar leon

feat: fullscreen display and fix some bug

parent 1d287822
...@@ -169,7 +169,7 @@ export default { ...@@ -169,7 +169,7 @@ export default {
} }
] ]
) )
if (chart) { if (chart && chart.getOption()) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries option.series = dealSeries
// 重新setOption,使得设置的formatter生效 // 重新setOption,使得设置的formatter生效
......
...@@ -112,8 +112,10 @@ ...@@ -112,8 +112,10 @@
this.sticky = sticky this.sticky = sticky
}) })
}, },
destroyed() { destroyed() {
uni.$off(elementInfo.id) if(elementInfo && elementInfo.id) {
uni.$off(elementInfo.id)
}
}, },
methods: { methods: {
initChart() { initChart() {
......
<template> <template>
<view class="normal-tabs"> <view class="normal-tabs">
<u-tabs v-if="elementInfo.option.tabs.type === 'tabs'" :list="elementData.dataList.series" :is-scroll="true" <u-tabs v-if="elementInfo.option.tabs.type === 'tabs'" :list="elementData.dataList.series" :is-scroll='elementData.dataList.series.length > 4'
:current="currentTabs" :active-color="elementInfo.option.tabs.activeColor" :current="currentTabs" :active-color="elementInfo.option.tabs.activeColor"
:inactive-color="elementInfo.option.tabs.color" :bg-color="elementInfo.option.tabs.backgroundColor" :inactive-color="elementInfo.option.tabs.color" :bg-color="elementInfo.option.tabs.backgroundColor"
:font-size="getFontSize()" @change="handleTabsChange">{{elementInfo.option.tabs.fontSize}}</u-tabs> :font-size="getFontSize()" @change="handleTabsChange"></u-tabs>
<u-subsection v-if="elementInfo.option.tabs.type === 'radio'" :list="elementData.dataList.series" <u-subsection v-if="elementInfo.option.tabs.type === 'radio'" :list="elementData.dataList.series"
:current="currentTabs" :active-color="elementInfo.option.tabs.activeColor" :current="currentTabs" :active-color="elementInfo.option.tabs.activeColor"
:inactive-color="elementInfo.option.tabs.color" :font-size="getFontSize()" :inactive-color="elementInfo.option.tabs.color" :font-size="getFontSize()"
......
...@@ -227,9 +227,41 @@ ...@@ -227,9 +227,41 @@
} }
} }
that.reportInfo = res.data.Result that.reportInfo = res.data.Result
// 暂不支持tabs带入,没有做数据缓存
// that.reportInfo = this.handleTabsLink(res.data.Result)
// 清除数据
if(uni.getStorageSync('reportInfo')) {
let info = JSON.parse(uni.getStorageSync('reportInfo'))
info.list.forEach(item => {
// 如果本地缓存的数组在接口请求的数组中不存在,则删除
if(!that.reportInfo.list.some(idx => idx.id == item.id)) {
uni.removeStorageSync(item.id)
}
})
}
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)) {
item.child.index.forEach(child => {
const index = data.list.findIndex(i => i.id === child )
data.list[index].linkTabsId = item.id
})
item.child.data.forEach(child => {
const index = data.list.findIndex(i => i.id === child.comp )
data.list[index].linkTabsId = item.id
})
}
})
return data
},
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
......
...@@ -3,10 +3,9 @@ ...@@ -3,10 +3,9 @@
<!-- 普通选项卡 --> <!-- 普通选项卡 -->
<NormalTabs <NormalTabs
v-if="showTabs" v-if="showTabs"
:elementInfo="tabsElement" :elementInfo="tabsElement"
styleType="vertical" style="height: 40px;margin-top: 5px;"
style="width: 80px;" :style="{width: `${theStyle.width - theStyle.left}px`}"
:style="{paddingLeft: `${theStyle.left}px`}"
></NormalTabs> ></NormalTabs>
<view :style="{height: `${theStyle.height}px`, width: `${theStyle.width - theStyle.left}px`}"> <view :style="{height: `${theStyle.height}px`, width: `${theStyle.width - theStyle.left}px`}">
<!-- 普通柱状图 --> <!-- 普通柱状图 -->
...@@ -39,8 +38,8 @@ ...@@ -39,8 +38,8 @@
const { windowWidth, windowHeight, screenHeight, safeArea } = uni.getSystemInfoSync() const { windowWidth, windowHeight, screenHeight, safeArea } = uni.getSystemInfoSync()
const reduceBottom = screenHeight - safeArea.bottom const reduceBottom = screenHeight - safeArea.bottom
return { return {
height: windowHeight - reduceBottom, height: this.showTabs ? windowHeight - reduceBottom - 50 : windowHeight - reduceBottom,
width: this.showTabs ? windowWidth - 80 : windowWidth, width: windowWidth,
left: safeArea.left left: safeArea.left
} }
}, },
...@@ -50,10 +49,9 @@ ...@@ -50,10 +49,9 @@
this.linkTabsId = option.linkTabsId this.linkTabsId = option.linkTabsId
if(this.linkTabsId && uni.getStorageSync('reportInfo')) { if(this.linkTabsId && uni.getStorageSync('reportInfo')) {
let info = JSON.parse(uni.getStorageSync('reportInfo')) let info = JSON.parse(uni.getStorageSync('reportInfo'))
const data = info.list.find(item => item.id === this.linkTabsId) const data = info.list.find(item => item.id === this.linkTabsId)
data.height = this.theStyle.height data.height = this.theStyle.height
data.option.tabs.defaultValue = data.child.data.find(item => item.comp === this.element.id).name this.tabsElement = data
this.tabsElement = data
} }
// 去掉全屏的定制按钮 // 去掉全屏的定制按钮
const toolbox = {show: false} const toolbox = {show: false}
...@@ -70,6 +68,37 @@ ...@@ -70,6 +68,37 @@
// 去掉全屏的定制按钮 // 去掉全屏的定制按钮
data.option.toolbox = { show: false } data.option.toolbox = { show: false }
this.element = data 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 }
}) })
} }
} }
...@@ -93,7 +122,8 @@ ...@@ -93,7 +122,8 @@
.tabs-layout { .tabs-layout {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
flex-direction: column;
} }
</style> </style>
...@@ -273,11 +273,19 @@ ...@@ -273,11 +273,19 @@
*/ */
handleTabsLink(data) { handleTabsLink(data) {
data.list.forEach(item => { data.list.forEach(item => {
if(item.type === 'NormalTabs' && item.child.data.length) { if(item.type === 'NormalTabs' && (item.child.index.length || item.child.data.length)) {
item.child.data.forEach(child => { if (item.child.index.length) {
const index = data.list.findIndex(i => i.id === child.comp ) item.child.index.forEach(child => {
data.list[index].linkTabsId = item.id const index = data.list.findIndex(i => i.id === child )
}) 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 )
data.list[index].linkTabsId = item.id
})
}
} }
}) })
return data return data
......
...@@ -116,24 +116,33 @@ ...@@ -116,24 +116,33 @@
this.currentIndex = nVal; this.currentIndex = nVal;
this.changeSectionStatus(nVal); this.changeSectionStatus(nVal);
} }
} },
}, list: {
created() { immediate: true,
// 将list的数据,传入listInfo数组,因为不能修改props传递的list值 handler(nVal) {
// 可以接受直接数组形式,或者数组元素为对象的形式,如:['简介', '评论'],或者[{name: '简介'}, {name: '评论'}] this.getListInfo()
this.listInfo = this.list.map((val, index) => { setTimeout(() => {
if (typeof val != 'object') { this.getTabsInfo();
let obj = { }, 10);
width: 0,
name: val
};
return obj;
} else {
val.width = 0;
return val;
} }
}); }
}, },
// created() {
// // 将list的数据,传入listInfo数组,因为不能修改props传递的list值
// // 可以接受直接数组形式,或者数组元素为对象的形式,如:['简介', '评论'],或者[{name: '简介'}, {name: '评论'}]
// this.listInfo = this.list.map((val, index) => {
// if (typeof val != 'object') {
// let obj = {
// width: 0,
// name: val
// };
// return obj;
// } else {
// val.width = 0;
// return val;
// }
// });
// },
computed: { computed: {
// 设置mode=subsection时,滑块特有的样式 // 设置mode=subsection时,滑块特有的样式
noBorderRight() { noBorderRight() {
...@@ -213,11 +222,27 @@ ...@@ -213,11 +222,27 @@
} }
}, },
mounted() { mounted() {
setTimeout(() => { // setTimeout(() => {
this.getTabsInfo(); // this.getTabsInfo();
}, 10); // }, 10);
}, },
methods: { methods: {
getListInfo () {
// 将list的数据,传入listInfo数组,因为不能修改props传递的list值
// 可以接受直接数组形式,或者数组元素为对象的形式,如:['简介', '评论'],或者[{name: '简介'}, {name: '评论'}]
this.listInfo = this.list.map((val, index) => {
if (typeof val != 'object') {
let obj = {
width: 0,
name: val
};
return obj;
} else {
val.width = 0;
return val;
}
});
},
// 改变滑块的样式 // 改变滑块的样式
changeSectionStatus(nVal) { changeSectionStatus(nVal) {
if (this.mode == 'subsection') { if (this.mode == 'subsection') {
......
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