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 { ...@@ -128,10 +128,6 @@ export default {
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series, preview, images } = this.elementData.dataList const { categories, series, preview, images } = this.elementData.dataList
var count = categories.length 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.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if (this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if (this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -165,6 +161,15 @@ export default { ...@@ -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()) { if (chart && chart.getOption()) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries option.series = dealSeries
......
...@@ -106,10 +106,6 @@ ...@@ -106,10 +106,6 @@
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
var count = categories.length 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.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -124,6 +120,14 @@ ...@@ -124,6 +120,14 @@
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) 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}]) 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) { if(chart) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries option.series = dealSeries
......
...@@ -98,10 +98,6 @@ ...@@ -98,10 +98,6 @@
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
var count = categories.length 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.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -116,6 +112,14 @@ ...@@ -116,6 +112,14 @@
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) 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}]) 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) { if(chart) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries option.series = dealSeries
......
...@@ -96,11 +96,10 @@ ...@@ -96,11 +96,10 @@
// 等待子组件完全挂载完成---chart初始化完成 // 等待子组件完全挂载完成---chart初始化完成
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
var count = categories.length if(!categories) {
if(count < this.elementInfo.dataZoom.count) { return
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
} }
var count = categories.length
if(this.labelShow) { if(this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -115,6 +114,14 @@ ...@@ -115,6 +114,14 @@
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) 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}]) 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) { if(chart) {
// 重新setOption,使得设置的formatter生效 // 重新setOption,使得设置的formatter生效
chart.setOption({ chart.setOption({
......
...@@ -113,8 +113,8 @@ ...@@ -113,8 +113,8 @@
}) })
}, },
destroyed() { destroyed() {
if(elementInfo && elementInfo.id) { if(this.elementInfo && this.elementInfo.id) {
uni.$off(elementInfo.id) uni.$off(this.elementInfo.id)
} }
}, },
methods: { methods: {
......
<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='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" :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"></u-tabs> :font-size="getFontSize()" @change="handleTabsChange"></u-tabs>
...@@ -35,9 +36,11 @@ ...@@ -35,9 +36,11 @@
</template> </template>
<u-dropdown v-if="elementInfo.option.tabs.type === 'dropdown'" :title-size="getFontSize()" ref="uDropdown" <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)"> <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)" <view class="drop-item" @click="handleDropdownValue(item)"
:style="{ :style="{
'color':tabsValue === item.value ? elementInfo.option.tabs.activeColor : elementInfo.option.tabs.color, 'color':tabsValue === item.value ? elementInfo.option.tabs.activeColor : elementInfo.option.tabs.color,
...@@ -242,6 +245,9 @@ ...@@ -242,6 +245,9 @@
}, },
getFontSize() { getFontSize() {
return this.$u.common.pxToRpx(this.elementInfo.option.tabs.fontSize) return this.$u.common.pxToRpx(this.elementInfo.option.tabs.fontSize)
},
getHeight() {
return this.$u.common.pxToRpx(this.elementInfo.height)
} }
}, },
watch: { watch: {
......
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
handler(newVal) { handler(newVal) {
const that = this const that = this
const storageData = uni.getStorageSync(this.elementInfo.id) 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) this.elementData.dataList = JSON.parse(storageData)
} }
if(that.elementInfo.hide) return false if(that.elementInfo.hide) return false
...@@ -165,7 +165,9 @@ export default { ...@@ -165,7 +165,9 @@ export default {
clearInterval(that.timer) clearInterval(that.timer)
} }
} else if (newVal.dataType === 'public') { } else if (newVal.dataType === 'public') {
if(that.vuex_globalData && that.vuex_globalData.elements.includes(that.elementInfo.id)) {
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 && newVal.dataPollingInterval > 0) { if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
...@@ -201,13 +203,21 @@ export default { ...@@ -201,13 +203,21 @@ export default {
/** /**
* 全局数据更新监测 * 全局数据更新监测
*/ */
'vuex_globalData' () { 'vuex_globalData' (newVal) {
if (this.elementInfo.data.dataType === 'public') this.handlePublicData(this.elementInfo.data) 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': { 'elementData.dataList': {
handler(newVal) { handler(newVal) {
if (newVal) {
this.setStorageData() this.setStorageData()
this.initChart() this.initChart()
}
}, },
deep: true, deep: true,
immediate: true immediate: true
......
...@@ -219,27 +219,24 @@ ...@@ -219,27 +219,24 @@
const { Status, Result: { info, list } } = res.data const { Status, Result: { info, list } } = res.data
if (Status === 'true') { if (Status === 'true') {
if(info.dataUrl) { if(info.dataUrl) {
that.getGlobalData(info) that.getGlobalData(info, list)
if(info.dataPollingInterval) { if(info.dataPollingInterval) {
that.timename = setInterval(() => { that.timename = setInterval(() => {
that.getGlobalData(info) that.getGlobalData(info, list)
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
that.reportInfo = res.data.Result
// 暂不支持tabs带入,没有做数据缓存
// that.reportInfo = this.handleTabsLink(res.data.Result)
// 清除数据 // 清除数据
if(uni.getStorageSync('reportInfo')) { if(uni.getStorageSync('reportInfo')) {
let info = JSON.parse(uni.getStorageSync('reportInfo')) let cacheInfo = JSON.parse(uni.getStorageSync('reportInfo'))
info.list.forEach(item => { 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) uni.removeStorageSync(item.id)
} }
}) })
} }
that.reportInfo = this.handleTabsLink(res.data.Result)
uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result)) uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result))
that.getStickyTables() that.getStickyTables()
} }
...@@ -250,29 +247,44 @@ ...@@ -250,29 +247,44 @@
handleTabsLink(data) { handleTabsLink(data) {
data.list.forEach(item => { data.list.forEach(item => {
if(item.type === 'NormalTabs' && (item.child.index.length || item.child.data.length)) { if(item.type === 'NormalTabs' && (item.child.index.length || item.child.data.length)) {
if (item.child.index.length) {
item.child.index.forEach(child => { item.child.index.forEach(child => {
const index = data.list.findIndex(i => i.id === child ) const index = data.list.findIndex(i => i.id === child )
if(index != -1) {
data.list[index].linkTabsId = item.id data.list[index].linkTabsId = item.id
}
}) })
}
if (item.child.data.length) {
item.child.data.forEach(child => { item.child.data.forEach(child => {
const index = data.list.findIndex(i => i.id === child.comp ) const index = data.list.findIndex(i => i.id === child.comp )
if(index != -1) {
data.list[index].linkTabsId = item.id data.list[index].linkTabsId = item.id
}
}) })
} }
}
}) })
return data return data
}, },
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
async getGlobalData(info) { async getGlobalData(info, list) {
const that = this const that = this
const dataUrl = info.dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '') const dataUrl = info.dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '')
const dataFormatter = this.$u.common.filterRequestParams({...info.dataFormatter}) const dataFormatter = this.$u.common.filterRequestParams({...info.dataFormatter})
let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, { let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, {
custom: { loading: false } 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> <template>
<view class="wrapper" :class="{'tabs-layout': showTabs}" :style="{width: `${theStyle.width - theStyle.left}px`, left:`${theStyle.left}px`}"> <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 <NormalTabs
v-if="showTabs"
:elementInfo="tabsElement" :elementInfo="tabsElement"
:style="{width: `${theStyle.width - theStyle.left}px`}"
></NormalTabs> ></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> <NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar>
<!-- 普通折线图 --> <!-- 普通折线图 -->
...@@ -42,6 +50,15 @@ ...@@ -42,6 +50,15 @@
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))
......
...@@ -246,27 +246,27 @@ ...@@ -246,27 +246,27 @@
const { Status, Result: { info, list } } = res.data const { Status, Result: { info, list } } = res.data
if (Status === 'true') { if (Status === 'true') {
if(info.dataUrl) { if(info.dataUrl) {
that.getGlobalData(info) that.getGlobalData(info, list)
if(info.dataPollingInterval) { if(info.dataPollingInterval) {
that.timename = setInterval(() => { that.timename = setInterval(() => {
that.getGlobalData(info) that.getGlobalData(info, list)
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
// 处理图层关系 // 处理图层关系
res.data.Result.list = this.$u.common.elementFolderId(res.data.Result.list) res.data.Result.list = this.$u.common.elementFolderId(res.data.Result.list)
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'))
info.list.forEach(item => { 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) uni.removeStorageSync(item.id)
} }
}) })
} }
that.reportInfo = this.handleTabsLink(res.data.Result)
uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result)) uni.setStorageSync('reportInfo', JSON.stringify(res.data.Result))
that.getStickyTables() that.getStickyTables()
} }
...@@ -300,14 +300,21 @@ ...@@ -300,14 +300,21 @@
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
async getGlobalData(info) { async getGlobalData(info,list) {
const that = this const that = this
const dataUrl = info.dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '') const dataUrl = info.dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '')
const dataFormatter = that.$u.common.filterRequestParams({...info.dataFormatter}) const dataFormatter = that.$u.common.filterRequestParams({...info.dataFormatter})
let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, { let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, dataFormatter, {
custom: { loading: false } 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 @@ ...@@ -134,7 +134,8 @@
popupStyle() { popupStyle() {
let style = {}; let style = {};
// 进行Y轴位移,展开状态时,恢复原位。收齐状态时,往上位移100%,进行隐藏 // 进行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['transition-duration'] = this.duration / 1000 + 's';
style.borderRadius = `0 0 ${this.$u.addUnit(this.borderRadius)} ${this.$u.addUnit(this.borderRadius)}`; style.borderRadius = `0 0 ${this.$u.addUnit(this.borderRadius)} ${this.$u.addUnit(this.borderRadius)}`;
return style; return style;
...@@ -291,6 +292,7 @@ ...@@ -291,6 +292,7 @@
&__popup { &__popup {
position: relative; position: relative;
z-index: 10; z-index: 10;
transform-origin: center top;
transition: all 0.3s; transition: all 0.3s;
transform: translate3D(0, -100%, 0); transform: translate3D(0, -100%, 0);
overflow: hidden; 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