Commit 363c52ad authored by leon's avatar leon

Merge branch 'develop' into feature-1.0.0

# Conflicts:
#	mixins/echartElementData.js
#	pages/index/index.vue
parents e940b85d 697d35cf
......@@ -128,10 +128,6 @@ export default {
this.$nextTick().then(() => {
const { categories, series, preview, images } = this.elementData.dataList
var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
}
if (this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
if (this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
......@@ -165,6 +161,15 @@ export default {
}
]
)
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if (chart && chart.getOption()) {
const option = chart.getOption()
option.series = dealSeries
......
......@@ -106,10 +106,6 @@
this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList
var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
}
if(this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
......@@ -124,6 +120,14 @@
this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}])
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if(chart) {
const option = chart.getOption()
option.series = dealSeries
......
......@@ -98,10 +98,6 @@
this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList
var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
}
if(this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
......@@ -116,6 +112,14 @@
this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}])
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if(chart) {
const option = chart.getOption()
option.series = dealSeries
......
......@@ -96,11 +96,10 @@
// 等待子组件完全挂载完成---chart初始化完成
this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList
var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
if(!categories) {
return
}
var count = categories.length
if(this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
......@@ -115,6 +114,14 @@
this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}])
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if(chart) {
// 重新setOption,使得设置的formatter生效
chart.setOption({
......
......@@ -113,8 +113,8 @@
})
},
destroyed() {
if(elementInfo && elementInfo.id) {
uni.$off(elementInfo.id)
if(this.elementInfo && this.elementInfo.id) {
uni.$off(this.elementInfo.id)
}
},
methods: {
......
<template>
<view class="normal-tabs">
<u-tabs v-if="elementInfo.option.tabs.type === 'tabs'" :list="elementData.dataList.series" :is-scroll='elementData.dataList.series.length > 4'
<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"
:inactive-color="elementInfo.option.tabs.color" :bg-color="elementInfo.option.tabs.backgroundColor"
:font-size="getFontSize()" @change="handleTabsChange"></u-tabs>
......@@ -35,9 +36,11 @@
</template>
<u-dropdown v-if="elementInfo.option.tabs.type === 'dropdown'" :title-size="getFontSize()" ref="uDropdown"
:active-color="elementInfo.option.tabs.color" :inactive-color="elementInfo.option.tabs.color">
:active-color="elementInfo.option.tabs.color" :inactive-color="elementInfo.option.tabs.color"
:menu-icon-size="getFontSize()" :height="getHeight()">
<u-dropdown-item v-model="tabsValue" :title="getSelectLabel(tabsValue)">
<view class="slot-content" :style="{'background-color': elementInfo.option.tabs.itemBackgroundColor}" v-for="(item, index) in elementData.dataList.series" :key="index">
<view class="slot-content" :style="{'background-color': elementInfo.option.tabs.itemBackgroundColor}"
v-for="(item, index) in elementData.dataList.series" :key="index">
<view class="drop-item" @click="handleDropdownValue(item)"
:style="{
'color':tabsValue === item.value ? elementInfo.option.tabs.activeColor : elementInfo.option.tabs.color,
......@@ -242,6 +245,9 @@
},
getFontSize() {
return this.$u.common.pxToRpx(this.elementInfo.option.tabs.fontSize)
},
getHeight() {
return this.$u.common.pxToRpx(this.elementInfo.height)
}
},
watch: {
......
......@@ -149,7 +149,7 @@ export default {
handler(newVal) {
const that = this
const storageData = uni.getStorageSync(this.elementInfo.id)
if(storageData && newVal.dataType !== 'static') {
if(storageData && JSON.stringify(storageData) != "{}" && newVal.dataType !== 'static') {
this.elementData.dataList = JSON.parse(storageData)
}
if(that.elementInfo.hide) return false
......@@ -165,7 +165,9 @@ export default {
clearInterval(that.timer)
}
} else if (newVal.dataType === 'public') {
if(that.vuex_globalData && that.vuex_globalData.elements.includes(that.elementInfo.id)) {
that.handlePublicData(newVal)
}
} else if (newVal.dataType === 'dataSet') {
that.handleDataSet(newVal)
if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
......@@ -201,13 +203,21 @@ export default {
/**
* 全局数据更新监测
*/
'vuex_globalData' () {
if (this.elementInfo.data.dataType === 'public') this.handlePublicData(this.elementInfo.data)
'vuex_globalData' (newVal) {
const elements = newVal.elements
/* elements.includes(this.elementInfo.id) 全局数据对应的elements包含当前的element id,
否则在切换页面的时候,被切换页面的全局组件也会再次请求,导致报错
*/
if (elements.includes(this.elementInfo.id) && this.elementInfo.data.dataType === 'public') {
this.handlePublicData(this.elementInfo.data)
}
},
'elementData.dataList': {
handler(newVal) {
if (newVal) {
this.setStorageData()
this.initChart()
}
},
deep: true,
immediate: true
......
......@@ -219,27 +219,24 @@
const { Status, Result: { info, list } } = res.data
if (Status === 'true') {
if(info.dataUrl) {
that.getGlobalData(info)
that.getGlobalData(info, list)
if(info.dataPollingInterval) {
that.timename = setInterval(() => {
that.getGlobalData(info)
that.getGlobalData(info, list)
}, parseInt(info.dataPollingInterval) * 1000)
}
}
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 => {
let cacheInfo = JSON.parse(uni.getStorageSync('reportInfo'))
cacheInfo.list.forEach(item => {
// 如果本地缓存的数组在接口请求的数组中不存在,则删除
if(!that.reportInfo.list.some(idx => idx.id == item.id)) {
if(!list.some(idx => idx.id == item.id)) {
uni.removeStorageSync(item.id)
}
})
}
that.reportInfo = this.handleTabsLink(res.data.Result)
uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result))
that.getStickyTables()
}
......@@ -250,29 +247,44 @@
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
},
/**
* 获取全局接口数据
*/
async getGlobalData(info) {
async getGlobalData(info, list) {
const that = this
const dataUrl = info.dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '')
const dataFormatter = this.$u.common.filterRequestParams({...info.dataFormatter})
let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, {
custom: { loading: false }
})
that.$u.vuex('vuex_globalData', res.data)
const elements = []
list.forEach(item => {
if(item.data.dataType === 'public') {
elements.push(item.id)
}
})
const data = {...res.data, elements}
that.$u.vuex('vuex_globalData', data)
},
/**
* 组件之间关联
......
<template>
<view class="wrapper" :class="{'tabs-layout': showTabs}" :style="{width: `${theStyle.width - theStyle.left}px`, left:`${theStyle.left}px`}">
<!-- 普通选项卡 -->
<view v-if="showTabs"
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
v-if="showTabs"
:elementInfo="tabsElement"
:style="{width: `${theStyle.width - theStyle.left}px`}"
></NormalTabs>
<view :style="{height: `${theStyle.height}px`, width: `${theStyle.width - theStyle.left}px`}">
</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>
<!-- 普通折线图 -->
......@@ -42,6 +50,15 @@
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) {
this.element = JSON.parse(decodeURIComponent(option.element))
......
......@@ -246,27 +246,27 @@
const { Status, Result: { info, list } } = res.data
if (Status === 'true') {
if(info.dataUrl) {
that.getGlobalData(info)
that.getGlobalData(info, list)
if(info.dataPollingInterval) {
that.timename = setInterval(() => {
that.getGlobalData(info)
that.getGlobalData(info, list)
}, 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')) {
let info = JSON.parse(uni.getStorageSync('reportInfo'))
info.list.forEach(item => {
// 如果本地缓存的数组在接口请求的数组中不存在,则删除
if(!that.reportInfo.list.some(idx => idx.id == item.id)) {
if(!list.some(idx => idx.id == item.id)) {
uni.removeStorageSync(item.id)
}
})
}
that.reportInfo = this.handleTabsLink(res.data.Result)
uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result))
that.getStickyTables()
}
......@@ -300,14 +300,21 @@
/**
* 获取全局接口数据
*/
async getGlobalData(info) {
async getGlobalData(info,list) {
const that = this
const dataUrl = info.dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '')
const dataFormatter = that.$u.common.filterRequestParams({...info.dataFormatter})
let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, {
custom: { loading: false }
})
that.$u.vuex('vuex_globalData', res.data)
const elements = []
list.forEach(item => {
if(item.data.dataType === 'public') {
elements.push(item.id)
}
})
const data = {...res.data, elements}
that.$u.vuex('vuex_globalData', data)
},
/**
* 组件之间关联
......
......@@ -134,7 +134,8 @@
popupStyle() {
let style = {};
// 进行Y轴位移,展开状态时,恢复原位。收齐状态时,往上位移100%,进行隐藏
style.transform = `translateY(${this.active ? 0 : '-100%'})`
// style.transform = `translateY(${this.active ? 0 : "-100%"})`;
style.transform = `scaleY(${this.active ? 1 : 0})`
style['transition-duration'] = this.duration / 1000 + 's';
style.borderRadius = `0 0 ${this.$u.addUnit(this.borderRadius)} ${this.$u.addUnit(this.borderRadius)}`;
return style;
......@@ -291,6 +292,7 @@
&__popup {
position: relative;
z-index: 10;
transform-origin: center top;
transition: all 0.3s;
transform: translate3D(0, -100%, 0);
overflow: hidden;
......
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