Commit cad8abef authored by leon's avatar leon

feat:use that repleace this in some functions

parent 1c032356
...@@ -32,27 +32,28 @@ ...@@ -32,27 +32,28 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
clearInterval(this.changeTimer) that.$nextTick(() => {
this.$refs['barMixMapCanvas'].init((canvas, width, height, canvasDpr) => { clearInterval(that.changeTimer)
chart = this.$echarts.init(canvas, null, { that.$refs['barMixMapCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
}) })
canvas.setChart(chart) canvas.setChart(chart)
let options = this.setMapOption() let options = that.setMapOption()
const { mapMixBarShow, mapMixBarChangeInterval} = this.elementInfo.option.mapMix const { mapMixBarShow, mapMixBarChangeInterval} = that.elementInfo.option.mapMix
let flag = true let flag = true
chart.setOption(options, true) chart.setOption(options, true)
chart.on('click', event => { chart.on('click', event => {
this.handleEchartsClick(event) that.handleEchartsClick(event)
}) })
// 柱状图 地图 切换 // 柱状图 地图 切换
if(mapMixBarShow && mapMixBarChangeInterval) { if(mapMixBarShow && mapMixBarChangeInterval) {
clearInterval(this.changeTimer) clearInterval(that.changeTimer)
this.changeTimer = setInterval(() => { that.changeTimer = setInterval(() => {
options = flag ? this.setBarOption() : this.setMapOption() options = flag ? that.setBarOption() : that.setMapOption()
flag = !flag flag = !flag
chart.setOption(options, true) chart.setOption(options, true)
}, mapMixBarChangeInterval * 1000) }, mapMixBarChangeInterval * 1000)
......
...@@ -28,15 +28,16 @@ ...@@ -28,15 +28,16 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['chinaMapCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['chinaMapCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
}) })
canvas.setChart(chart) canvas.setChart(chart)
const { dataList } = this.elementData const { dataList } = that.elementData
const seriesData = dataList.chinaMapAreas || [] const seriesData = dataList.chinaMapAreas || []
// 处理成地图所需的数据格式 // 处理成地图所需的数据格式
const finalData = []; const finalData = [];
...@@ -71,7 +72,7 @@ ...@@ -71,7 +72,7 @@
curveness: 0.2 curveness: 0.2
} }
}, },
data: this.convertData(item[1]) data: that.convertData(item[1])
}, { }, {
name: item[0], name: item[0],
type: 'effectScatter', type: 'effectScatter',
...@@ -84,15 +85,15 @@ ...@@ -84,15 +85,15 @@
show: true, show: true,
position: 'right', position: 'right',
formatter: value => { formatter: value => {
if(this.elementInfo.option.dataset.formatter) { if(that.elementInfo.option.dataset.formatter) {
return this.$u.common.converFunction(this.elementInfo.option.dataset.formatter, value) return that.$u.common.converFunction(that.elementInfo.option.dataset.formatter, value)
} else { } else {
return this.elementInfo.option.dataset.show ? `${value.data.name}:${value.data.value[2]}` : value.data.name return that.elementInfo.option.dataset.show ? `${value.data.name}:${value.data.value[2]}` : value.data.name
} }
}, },
fontSize: this.elementInfo.option.dataset.fontSize, fontSize: that.elementInfo.option.dataset.fontSize,
color: this.elementInfo.option.dataset.color, color: that.elementInfo.option.dataset.color,
fontWeight: this.elementInfo.option.dataset.fontWeight fontWeight: that.elementInfo.option.dataset.fontWeight
}, },
symbolSize: 4, symbolSize: 4,
itemStyle: { itemStyle: {
...@@ -109,10 +110,10 @@ ...@@ -109,10 +110,10 @@
const options = { const options = {
title: { title: {
...this.elementInfo.option.title ...that.elementInfo.option.title
}, },
legend: { legend: {
...this.elementInfo.option.legend ...that.elementInfo.option.legend
}, },
geo: { geo: {
map: 'china', map: 'china',
...@@ -132,7 +133,7 @@ ...@@ -132,7 +133,7 @@
} }
chart.setOption(options) chart.setOption(options)
chart.on('click', event => { chart.on('click', event => {
this.handleEchartsClick(event) that.handleEchartsClick(event)
}) })
return chart return chart
}) })
......
...@@ -28,11 +28,12 @@ ...@@ -28,11 +28,12 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.startVal = this.endVal that.$nextTick(() => {
this.endVal = this.elementData.dataList.endVal that.startVal = that.endVal
if(this.elementInfo.option.countTo.duration) { that.endVal = that.elementData.dataList.endVal
this.duration = this.elementInfo.option.countTo.duration * 1000 if(that.elementInfo.option.countTo.duration) {
that.duration = that.elementInfo.option.countTo.duration * 1000
} }
}) })
}, },
......
...@@ -23,9 +23,10 @@ ...@@ -23,9 +23,10 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['horizontalBarCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['horizontalBarCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
...@@ -38,15 +39,15 @@ ...@@ -38,15 +39,15 @@
preview, preview,
images images
} }
} = this.elementData } = that.elementData
const options = { const options = {
...this.elementInfo.option, ...that.elementInfo.option,
tooltip: {}, tooltip: {},
yAxis: { yAxis: {
...this.elementInfo.option.yAxis, ...that.elementInfo.option.yAxis,
data: categories data: categories
}, },
series: this.dealSeriesData(series) series: that.dealSeriesData(series)
} }
chart.setOption(options) chart.setOption(options)
chart.on('click', event => { chart.on('click', event => {
...@@ -57,7 +58,7 @@ ...@@ -57,7 +58,7 @@
urls: images urls: images
}) })
} else { } else {
this.handleEchartsClick(event) that.handleEchartsClick(event)
} }
}) })
return chart return chart
...@@ -69,14 +70,15 @@ ...@@ -69,14 +70,15 @@
*/ */
dealSeriesData(data) { dealSeriesData(data) {
if (!data) return if (!data) return
const that = this
const newData = data.map(item => { const newData = data.map(item => {
const config = { const config = {
type: 'bar', type: 'bar',
...this.elementInfo.option.bar, ...that.elementInfo.option.bar,
label: { label: {
...this.elementInfo.option.dataset, ...that.elementInfo.option.dataset,
formatter: val => { formatter: val => {
return this.$u.common.converFunction(this.elementInfo.option.dataset return that.$u.common.converFunction(that.elementInfo.option.dataset
.formatter, val) .formatter, val)
} }
} }
......
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['lineMixBarCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['lineMixBarCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
...@@ -41,28 +42,28 @@ ...@@ -41,28 +42,28 @@
categories, categories,
series series
} }
} = this.elementData } = that.elementData
const options = { const options = {
...this.elementInfo.option, ...that.elementInfo.option,
tooltip: {}, tooltip: {},
xAxis: { xAxis: {
...this.elementInfo.option.xAxis, ...that.elementInfo.option.xAxis,
data: categories data: categories
}, },
yAxis: [{ yAxis: [{
...this.elementInfo.option.yAxis, ...that.elementInfo.option.yAxis,
type: 'value' type: 'value'
}, },
{ {
...this.elementInfo.option.yAxis, ...that.elementInfo.option.yAxis,
type: 'value' type: 'value'
} }
], ],
series: this.dealSeriesData(series) series: that.dealSeriesData(series)
} }
chart.setOption(options) chart.setOption(options)
chart.on('click', event => { chart.on('click', event => {
this.handleEchartsClick(event) that.handleEchartsClick(event)
}) })
return chart return chart
}) })
...@@ -73,25 +74,26 @@ ...@@ -73,25 +74,26 @@
*/ */
dealSeriesData(data) { dealSeriesData(data) {
if (!data) return if (!data) return
const that = this
const newData = data.map(item => { const newData = data.map(item => {
let config = { let config = {
label: { label: {
...this.elementInfo.option.dataset, ...that.elementInfo.option.dataset,
formatter: val => { formatter: val => {
return this.$u.common.converFunction(this.elementInfo.option.dataset.formatter, val) return that.$u.common.converFunction(that.elementInfo.option.dataset.formatter, val)
} }
} }
} }
if (item.type === 'bar') { if (item.type === 'bar') {
config = { config = {
...config, ...config,
...this.elementInfo.option.bar ...that.elementInfo.option.bar
} }
} else if (item.type === 'line') { } else if (item.type === 'line') {
config = { config = {
yAxisIndex: 1, yAxisIndex: 1,
...config, ...config,
...this.elementInfo.option.line ...that.elementInfo.option.line
} }
} }
return { return {
......
...@@ -23,9 +23,10 @@ ...@@ -23,9 +23,10 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['normalbarCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['normalbarCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
...@@ -36,19 +37,19 @@ ...@@ -36,19 +37,19 @@
categories, categories,
series series
} }
} = this.elementData } = that.elementData
const options = { const options = {
...this.elementInfo.option, ...that.elementInfo.option,
tooltip: {}, tooltip: {},
xAxis: { xAxis: {
...this.elementInfo.option.xAxis, ...that.elementInfo.option.xAxis,
data: categories data: categories
}, },
series: this.dealSeriesData(series) series: that.dealSeriesData(series)
} }
chart.setOption(options) chart.setOption(options)
chart.on('click', event => { chart.on('click', event => {
this.handleEchartsClick(event) that.handleEchartsClick(event)
}) })
return chart return chart
}) })
...@@ -59,14 +60,15 @@ ...@@ -59,14 +60,15 @@
*/ */
dealSeriesData(data) { dealSeriesData(data) {
if (!data) return if (!data) return
const that = this
const newData = data.map(item => { const newData = data.map(item => {
const config = { const config = {
type: 'bar', type: 'bar',
...this.elementInfo.option.bar, ...that.elementInfo.option.bar,
label: { label: {
...this.elementInfo.option.dataset, ...that.elementInfo.option.dataset,
formatter: val => { formatter: val => {
return this.$u.common.converFunction(this.elementInfo.option.dataset return that.$u.common.converFunction(that.elementInfo.option.dataset
.formatter, val) .formatter, val)
} }
} }
......
...@@ -31,17 +31,18 @@ export default { ...@@ -31,17 +31,18 @@ export default {
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['normalGaugeCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['normalGaugeCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
}) })
canvas.setChart(chart) canvas.setChart(chart)
const { dataList: { guageChart } } = this.elementData const { dataList: { guageChart } } = that.elementData
const options = { const options = {
...this.elementInfo.option, ...that.elementInfo.option,
tooltip: { tooltip: {
formatter: '{a} <br/>{b} : {c}%' formatter: '{a} <br/>{b} : {c}%'
}, },
......
...@@ -22,9 +22,10 @@ ...@@ -22,9 +22,10 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['normalLineCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['normalLineCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
...@@ -35,22 +36,22 @@ ...@@ -35,22 +36,22 @@
categories, categories,
series series
} }
} = this.elementData } = that.elementData
const options = { const options = {
...this.elementInfo.option, ...that.elementInfo.option,
color: ['#00f2f1', '#ed3f35', '#1089E7', "#F8B448", "#8B78F6", '#8cd8ff', color: ['#00f2f1', '#ed3f35', '#1089E7', "#F8B448", "#8B78F6", '#8cd8ff',
'#f0ad54', '#ffffff', '#000000' '#f0ad54', '#ffffff', '#000000'
], ],
tooltip: {}, tooltip: {},
xAxis: { xAxis: {
...this.elementInfo.option.xAxis, ...that.elementInfo.option.xAxis,
data: categories data: categories
}, },
series: this.dealSeriesData(series) series: that.dealSeriesData(series)
} }
chart.setOption(options) chart.setOption(options)
chart.on('click', event => { chart.on('click', event => {
this.handleEchartsClick(event) that.handleEchartsClick(event)
}) })
return chart return chart
}) })
...@@ -61,14 +62,15 @@ ...@@ -61,14 +62,15 @@
*/ */
dealSeriesData(data) { dealSeriesData(data) {
if (!data) return if (!data) return
const that = this
const newData = data.map(item => { const newData = data.map(item => {
const config = { const config = {
type: 'line', type: 'line',
...this.elementInfo.option.line, ...that.elementInfo.option.line,
label: { label: {
...this.elementInfo.option.dataset, ...that.elementInfo.option.dataset,
formatter: val => { formatter: val => {
return this.$u.common.converFunction(this.elementInfo.option.dataset return that.$u.common.converFunction(that.elementInfo.option.dataset
.formatter, val) .formatter, val)
} }
} }
......
...@@ -31,27 +31,28 @@ export default { ...@@ -31,27 +31,28 @@ export default {
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['normalPieCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['normalPieCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
}) })
canvas.setChart(chart) canvas.setChart(chart)
const { dataList: { series } } = this.elementData const { dataList: { series } } = that.elementData
const options = { const options = {
...this.elementInfo.option, ...that.elementInfo.option,
color: ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'], color: ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'],
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
formatter: '{a}<br/>{b}:{c}({d}%)' formatter: '{a}<br/>{b}:{c}({d}%)'
}, },
series: this.dealSeriesData(series) series: that.dealSeriesData(series)
} }
chart.setOption(options) chart.setOption(options)
chart.on('click', event => { chart.on('click', event => {
this.handleEchartsClick(event) that.handleEchartsClick(event)
}) })
return chart return chart
}) })
......
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.$refs['normalRadarCanvas'].init((canvas, width, height, canvasDpr) => { that.$nextTick(() => {
chart = this.$echarts.init(canvas, null, { that.$refs['normalRadarCanvas'].init((canvas, width, height, canvasDpr) => {
chart = that.$echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
indicator, indicator,
series series
} }
} = this.elementData } = that.elementData
const config = { const config = {
tooltip: {}, tooltip: {},
radar: { radar: {
...@@ -50,9 +51,9 @@ ...@@ -50,9 +51,9 @@
series: [{ series: [{
type: 'radar', type: 'radar',
label: { label: {
...this.elementInfo.option.dataset ...that.elementInfo.option.dataset
}, },
data: this.dealSeriesData(series) data: that.dealSeriesData(series)
}] }]
} }
chart.setOption(config) chart.setOption(config)
......
...@@ -72,9 +72,10 @@ ...@@ -72,9 +72,10 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.columns = this.elementInfo.table.column that.$nextTick(() => {
this.chartTables = this.elementData.dataList.chartTables that.columns = that.elementInfo.table.column
that.chartTables = that.elementData.dataList.chartTables
}) })
}, },
cellClick(e) { cellClick(e) {
......
...@@ -45,9 +45,10 @@ ...@@ -45,9 +45,10 @@
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.endVal = this.elementData.dataList.endVal that.$nextTick(() => {
this.toOrderNumber(this.endVal) that.endVal = that.elementData.dataList.endVal
that.toOrderNumber(that.endVal)
}) })
}, },
......
...@@ -33,9 +33,10 @@ ...@@ -33,9 +33,10 @@
}, },
methods: { methods: {
getRealTime() { getRealTime() {
this.timer = setInterval(() => { const that = this
that.timer = setInterval(() => {
const timestamp = new Date().getTime() const timestamp = new Date().getTime()
this.realTime = this.$u.timeFormat(timestamp, this.getDateFormat()) that.realTime = that.$u.timeFormat(timestamp, that.getDateFormat())
}, 1000) }, 1000)
}, },
initChart() {}, initChart() {},
......
...@@ -24,8 +24,9 @@ ...@@ -24,8 +24,9 @@
}, },
methods:{ methods:{
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.imageUrl = this.elementData.dataList.imageUrl that.$nextTick(() => {
that.imageUrl = that.elementData.dataList.imageUrl
}) })
} }
} }
......
...@@ -89,8 +89,9 @@ ...@@ -89,8 +89,9 @@
}, },
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { const that = this
this.chartTables = this.elementData.dataList.chartTables that.$nextTick(() => {
that.chartTables = that.elementData.dataList.chartTables
}) })
}, },
cellClick(e) { cellClick(e) {
......
...@@ -24,15 +24,16 @@ export default { ...@@ -24,15 +24,16 @@ export default {
* 动态数据 * 动态数据
*/ */
async handleDynamicData (value) { async handleDynamicData (value) {
const that = this
let { dataUrl, dataMethod, dataFormatter, dataProcessing } = { ...value } let { dataUrl, dataMethod, dataFormatter, dataProcessing } = { ...value }
dataUrl = dataUrl.replace(/^(\/dashboardCharts)?|^(\/dashboardAPI)?/, '') dataUrl = dataUrl.replace(/^(\/dashboardCharts)?|^(\/dashboardAPI)?/, '')
let res = await this.$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 (dataProcessing) { if (dataProcessing) {
this.elementData.dataList = this.$u.common.converFunction(dataProcessing, res.data) that.elementData.dataList = that.$u.common.converFunction(dataProcessing, res.data)
} else { } else {
this.elementData.dataList = JSON.parse(JSON.stringify(res.data.Result)) that.elementData.dataList = JSON.parse(JSON.stringify(res.data.Result))
} }
}, },
/** /**
...@@ -52,16 +53,17 @@ export default { ...@@ -52,16 +53,17 @@ export default {
*/ */
async handleDataSet (value) { async handleDataSet (value) {
const { dataSetInfo } = value const { dataSetInfo } = value
let res = await this.$u.api.dataSetPreview(dataSetInfo) const that = this
let res = await that.$u.api.dataSetPreview(dataSetInfo)
const { Status, Msg } = res.data; const { Status, Msg } = res.data;
if (Status == "true") { if (Status == "true") {
if(dataSetInfo.script) { if(dataSetInfo.script) {
this.elementData.dataList = this.$u.common.converFunction(dataSetInfo.script, res.data.Result) that.elementData.dataList = that.$u.common.converFunction(dataSetInfo.script, res.data.Result)
} else { } else {
this.elementData.dataList = res.data.Result that.elementData.dataList = res.data.Result
} }
} else { } else {
this.$u.toast(Msg) that.$u.toast(Msg)
} }
}, },
clearTimer() { clearTimer() {
...@@ -85,31 +87,32 @@ export default { ...@@ -85,31 +87,32 @@ export default {
watch: { watch: {
'elementInfo.data': { 'elementInfo.data': {
handler(newVal) { handler(newVal) {
if(this.elementInfo.hide) return false const that = this
if(that.elementInfo.hide) return false
if (newVal.dataType === 'static') { if (newVal.dataType === 'static') {
this.handleStaticData(newVal) that.handleStaticData(newVal)
} }
else if (newVal.dataType === 'dynamic') { else if (newVal.dataType === 'dynamic') {
this.handleDynamicData(newVal) that.handleDynamicData(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling) {
this.timer = setInterval(() => { that.timer = setInterval(() => {
this.handleDynamicData(newVal) that.handleDynamicData(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
} else { } else {
clearInterval(this.timer) clearInterval(that.timer)
} }
} }
else if (newVal.dataType === 'public') { else if (newVal.dataType === 'public') {
this.handlePublicData(newVal) that.handlePublicData(newVal)
} }
else if (newVal.dataType === 'dataSet') { else if (newVal.dataType === 'dataSet') {
this.handleDataSet(newVal) that.handleDataSet(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling) {
this.timer = setInterval(() => { that.timer = setInterval(() => {
this.handleDataSet(newVal) that.handleDataSet(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
} else { } else {
clearInterval(this.timer) clearInterval(that.timer)
} }
} }
}, },
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
async onLoad() { async onLoad() {
var admin = uni.getStorageSync('admin') var admin = uni.getStorageSync('admin')
if (admin) { if (admin) {
this.$data.admin = admin this.admin = admin
} }
}, },
onShow() { onShow() {
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
itemList[2].count = Result.authorized; itemList[2].count = Result.authorized;
} }
this.$data.itemList = itemList this.itemList = itemList
}) })
}, },
// item 点击 // item 点击
......
<template> <template>
<view class="viewport-wrapper" :style="[styleObject]"> <view class="viewport-wrapper" :style="[styleObject]">
<template v-for="(element, index) in reportData"> <template v-for="(element, index) in reportInfo.list">
<view <view
class="view-element" class="view-element"
v-show="!element.hide" v-show="!element.hide"
...@@ -60,42 +60,51 @@ ...@@ -60,42 +60,51 @@
data() { data() {
return { return {
reportInfo: {}, reportInfo: {},
reportData: [], detailId: "",
timename: null, timename: null
detailId: ""
} }
}, },
computed: { computed: {
styleObject() { styleObject() {
if(JSON.stringify(this.reportInfo) == "{}") {
return
}
let params = {} let params = {}
const { backgroundColor, backgroundImage } = this.reportInfo const { backgroundColor, backgroundImage, width, height } = this.reportInfo.info
if(backgroundImage) params = { 'background-image': `url(${backgroundImage})` } if(backgroundImage) params = { 'background-image': `url(${backgroundImage})` }
return { return {
width: `${width * this.scale}px`,
height: `${height * this.scale}px`,
'background-color': backgroundColor, 'background-color': backgroundColor,
...params ...params
} }
}, },
scale() { scale() {
if(JSON.stringify(this.reportInfo) == "{}") {
return
}
const { windowWidth } = uni.getSystemInfoSync() const { windowWidth } = uni.getSystemInfoSync()
const { width, height } = this.reportInfo const { width, height } = this.reportInfo.info
return windowWidth / width return windowWidth / width
} }
}, },
onLoad(option) { onLoad(option) {
this.detailId = option.id this.detailId = option.id
this.userAuthCheck() this.userAuthCheck()
this.getReportCharts() },
onShow() {
const that = this
/** /**
* 组件交互 - 参数 * 组件交互 - 参数
*/ */
uni.$on('handleLinkParams', ({index, paramName, value}) => { uni.$on('handleLinkParams', ({index, paramName, value}) => {
this.handleValueChange(index, paramName, value) that.handleValueChange(index, paramName, value)
}) })
/** /**
* 组件交互 - 组件 * 组件交互 - 组件
*/ */
uni.$on('handleLinkComp', ({ showData, hideData }) => { uni.$on('handleLinkComp', ({ showData, hideData }) => {
this.reportData = this.reportData.map(item => { that.reportInfo.list = that.reportInfo.list.map(item => {
if(showData.includes(item.id)) item.hide = false if(showData.includes(item.id)) item.hide = false
if(hideData.includes(item.id)) item.hide = true if(hideData.includes(item.id)) item.hide = true
return item return item
...@@ -105,6 +114,7 @@ ...@@ -105,6 +114,7 @@
onUnload() { onUnload() {
// 移除监听事件 // 移除监听事件
uni.$off('handleLinkParams') uni.$off('handleLinkParams')
uni.$off('handleLinkComp')
clearInterval(this.timename) clearInterval(this.timename)
}, },
methods: { methods: {
...@@ -115,7 +125,7 @@ ...@@ -115,7 +125,7 @@
var authorized = uni.getStorageSync('authorized') var authorized = uni.getStorageSync('authorized')
if (userId) { if (userId) {
if (authorized) { if (authorized) {
this.getReportCharts()
} else { } else {
uni.reLaunch({ uni.reLaunch({
url:'../login/authorized' url:'../login/authorized'
...@@ -144,57 +154,56 @@ ...@@ -144,57 +154,56 @@
*/ */
async getReportCharts() { async getReportCharts() {
clearInterval(this.timename) clearInterval(this.timename)
let res = await this.$u.api.getReportCharts({id: this.detailId}) const that = this
let res = await that.$u.api.getReportCharts({id: that.detailId})
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
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) {
this.getGlobalData(info) that.getGlobalData(info)
if(info.dataPollingInterval) { if(info.dataPollingInterval) {
this.timename = setInterval(() => { that.timename = setInterval(() => {
this.getGlobalData(info) that.getGlobalData(info)
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
this.reportInfo = info that.reportInfo = res.data.Result
this.reportData = list
} }
}, },
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
async getGlobalData(info) { async getGlobalData(info) {
const that = this
const dataUrl = info.dataUrl.replace(/^(\/dashboardCharts)?|^(\/dashboardAPI)?/, '') const dataUrl = info.dataUrl.replace(/^(\/dashboardCharts)?|^(\/dashboardAPI)?/, '')
let res = await this.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, info.dataFormatter, { let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, info.dataFormatter, {
custom: { loading: false } custom: { loading: false }
}) })
this.$u.vuex('vuex_globalData', JSON.stringify(res.data)) that.$u.vuex('vuex_globalData', JSON.stringify(res.data))
}, },
/** /**
* 组件之间关联 * 组件之间关联
*/ */
handleValueChange(index, paramName, value) { handleValueChange(index, paramName, value) {
if(index.length && paramName && value) { if(index.length && paramName && value) {
this.reportData = this.reportData.map(item => { const that = this
that.reportInfo.list = that.reportInfo.list.map(item => {
const flag = index.includes(item.id) const flag = index.includes(item.id)
if(flag && item.type === 'BasicText' && item.data.dataType === 'static') { if(flag && item.type === 'BasicText' && item.data.dataType === 'static') {
this.$set(item.data.dataList, 'text', value) that.$set(item.data.dataList, 'text', value)
} }
if(flag && item.data.dataType === 'dynamic') { if(flag && item.data.dataType === 'dynamic') {
if(!item.data.dataFormatter) item.data.dataFormatter = {} if(!item.data.dataFormatter) item.data.dataFormatter = {}
this.$set(item.data.dataFormatter, paramName, value) that.$set(item.data.dataFormatter, paramName, value)
} }
if(flag && item.data.dataType === 'dataSet') { if(flag && item.data.dataType === 'dataSet') {
if(!item.data.dataSetInfo.queryFormatter) item.data.dataSetInfo.queryFormatter = {} if(!item.data.dataSetInfo.queryFormatter) item.data.dataSetInfo.queryFormatter = {}
this.$set(item.data.dataSetInfo.queryFormatter, paramName, value) that.$set(item.data.dataSetInfo.queryFormatter, paramName, value)
} }
return item return item
}) })
} }
} }
},
onReachBottom() {
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.getReportCharts() this.getReportCharts()
...@@ -203,18 +212,15 @@ ...@@ -203,18 +212,15 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.canvas { .viewport-wrapper {
position: relative; position: relative;
height: 100%; height: 100%;
user-select: none; user-select: none;
overflow: auto; // overflow: auto;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
background-position: center; background-position: center;
} }
.viewport-wrapper {
position: relative;
}
.view-element { .view-element {
position: absolute; position: absolute;
user-select: none; user-select: none;
......
<template> <template>
<view class="viewport-wrapper" :style="[styleObject]"> <view class="viewport-wrapper" :style="[styleObject]">
<template v-for="(element, index) in reportData"> <template v-for="(element, index) in reportInfo.list">
<view <view
class="view-element" class="view-element"
v-show="!element.hide" v-show="!element.hide"
...@@ -60,14 +60,16 @@ ...@@ -60,14 +60,16 @@
data() { data() {
return { return {
reportInfo: {}, reportInfo: {},
reportData: [],
timename: null timename: null
} }
}, },
computed: { computed: {
styleObject() { styleObject() {
if(JSON.stringify(this.reportInfo) == "{}") {
return
}
let params = {} let params = {}
const { backgroundColor, backgroundImage, width, height } = this.reportInfo const { backgroundColor, backgroundImage, width, height } = this.reportInfo.info
if(backgroundImage) params = { 'background-image': `url(${backgroundImage})` } if(backgroundImage) params = { 'background-image': `url(${backgroundImage})` }
return { return {
width: `${width * this.scale}px`, width: `${width * this.scale}px`,
...@@ -77,31 +79,39 @@ ...@@ -77,31 +79,39 @@
} }
}, },
scale() { scale() {
if(JSON.stringify(this.reportInfo) == "{}") {
return
}
const { windowWidth } = uni.getSystemInfoSync() const { windowWidth } = uni.getSystemInfoSync()
const { width, height } = this.reportInfo const { width, height } = this.reportInfo.info
return windowWidth / width return windowWidth / width
} }
}, },
onLoad() { onLoad() {
this.userAuthCheck() this.userAuthCheck()
},
// detail页面也会监听这两个事件,所有index页面需要在onShow里面增加监听,在onHide里面移除监听
onShow() {
const that = this
/** /**
* 组件交互 - 参数 * 组件交互 - 参数
*/ */
uni.$on('handleLinkParams', ({index, paramName, value}) => { uni.$on('handleLinkParams', ({index, paramName, value}) => {
this.handleValueChange(index, paramName, value) that.handleValueChange(index, paramName, value)
}) })
/** /**
* 组件交互 - 组件 * 组件交互 - 组件
*/ */
uni.$on('handleLinkComp', ({ showData, hideData }) => { uni.$on('handleLinkComp', ({ showData, hideData }) => {
this.reportData = this.reportData.map(item => { that.reportInfo.list = that.reportInfo.list.map(item => {
if(showData.includes(item.id)) item.hide = false if(showData.includes(item.id)) item.hide = false
if(hideData.includes(item.id)) item.hide = true if(hideData.includes(item.id)) item.hide = true
return item return item
}) })
}) })
}, },
onUnload() { onHide() {
// 移除监听事件 // 移除监听事件
uni.$off('handleLinkParams') uni.$off('handleLinkParams')
uni.$off('handleLinkComp') uni.$off('handleLinkComp')
...@@ -144,49 +154,51 @@ ...@@ -144,49 +154,51 @@
*/ */
async getReportCharts() { async getReportCharts() {
clearInterval(this.timename) clearInterval(this.timename)
let res = await this.$u.api.getReportCharts({id: '61cd2ba1c06bffbdae442c4f'}) const that = this
let res = await that.$u.api.getReportCharts({id: '61cd2ba1c06bffbdae442c4f'})
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
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) {
this.getGlobalData(info) that.getGlobalData(info)
if(info.dataPollingInterval) { if(info.dataPollingInterval) {
this.timename = setInterval(() => { that.timename = setInterval(() => {
this.getGlobalData(info) that.getGlobalData(info)
}, parseInt(info.dataPollingInterval) * 1000) }, parseInt(info.dataPollingInterval) * 1000)
} }
} }
this.reportInfo = info that.reportInfo = res.data.Result
this.reportData = list
} }
}, },
/** /**
* 获取全局接口数据 * 获取全局接口数据
*/ */
async getGlobalData(info) { async getGlobalData(info) {
const that = this
const dataUrl = info.dataUrl.replace(/^(\/dashboardCharts)?|^(\/dashboardAPI)?/, '') const dataUrl = info.dataUrl.replace(/^(\/dashboardCharts)?|^(\/dashboardAPI)?/, '')
let res = await this.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, info.dataFormatter, { let res = await that.$u.api[`${info.dataMethod.toLowerCase()}Http`](dataUrl, info.dataFormatter, {
custom: { loading: false } custom: { loading: false }
}) })
this.$u.vuex('vuex_globalData', JSON.stringify(res.data)) that.$u.vuex('vuex_globalData', JSON.stringify(res.data))
}, },
/** /**
* 组件之间关联 * 组件之间关联
*/ */
handleValueChange(index, paramName, value) { handleValueChange(index, paramName, value) {
if(index.length && paramName && value) { if(index.length && paramName && value) {
this.reportData = this.reportData.map(item => { const that = this
that.reportInfo.list = that.reportInfo.list.map(item => {
const flag = index.includes(item.id) const flag = index.includes(item.id)
if(flag && item.type === 'BasicText' && item.data.dataType === 'static') { if(flag && item.type === 'BasicText' && item.data.dataType === 'static') {
this.$set(item.data.dataList, 'text', value) that.$set(item.data.dataList, 'text', value)
} }
if(flag && item.data.dataType === 'dynamic') { if(flag && item.data.dataType === 'dynamic') {
if(!item.data.dataFormatter) item.data.dataFormatter = {} if(!item.data.dataFormatter) item.data.dataFormatter = {}
this.$set(item.data.dataFormatter, paramName, value) that.$set(item.data.dataFormatter, paramName, value)
} }
if(flag && item.data.dataType === 'dataSet') { if(flag && item.data.dataType === 'dataSet') {
if(!item.data.dataSetInfo.queryFormatter) item.data.dataSetInfo.queryFormatter = {} if(!item.data.dataSetInfo.queryFormatter) item.data.dataSetInfo.queryFormatter = {}
this.$set(item.data.dataSetInfo.queryFormatter, paramName, value) that.$set(item.data.dataSetInfo.queryFormatter, paramName, value)
} }
return item return item
}) })
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
pageSize: 10, pageSize: 10,
totalPages: 0, totalPages: 0,
totals: 0, totals: 0,
folderId: '61cd45a8c06bffbdae442d09', folderId: '621db7710668d7e647d5f4cc',
superAdmin: true superAdmin: true
} }
} }
...@@ -50,16 +50,18 @@ ...@@ -50,16 +50,18 @@
* 获取页面报表配置 * 获取页面报表配置
*/ */
async getReportList() { async getReportList() {
let res = await this.$u.api.getReportList(this.params) const that = this
let res = await that.$u.api.getReportList(that.params)
const { Status, Result } = res.data const { Status, Result } = res.data
uni.stopPullDownRefresh()
if (Status === 'true') { if (Status === 'true') {
if(this.params.pageNumber === 1) { if(that.params.pageNumber === 1) {
this.reportList = Result.content that.reportList = Result.content
} else { } else {
this.reportList = this.reportList.concat(Result.content) that.reportList = that.reportList.concat(Result.content)
} }
this.params.totals = Result.total that.params.totals = Result.total
this.params.totalPages = Result.totalPages that.params.totalPages = Result.totalPages
} }
}, },
......
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