fix: 抽取修改别名方法为全局 修改正则
This commit is contained in:
@@ -640,27 +640,6 @@ export default {
|
|||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
clickLegend (legendName, index) {
|
clickLegend (legendName, index) {
|
||||||
/* 点击legend
|
/* 点击legend
|
||||||
* 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮
|
* 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ import chartBarStatis from './chart-bar-statistics'
|
|||||||
import logs from './logs'
|
import logs from './logs'
|
||||||
import { fromRoute } from '@/components/common/js/constants'
|
import { fromRoute } from '@/components/common/js/constants'
|
||||||
import chartTempData from '@/components/charts/chartTempData'
|
import chartTempData from '@/components/charts/chartTempData'
|
||||||
|
import { dealLegendAlias } from '@/components/common/js/tools'
|
||||||
// import visNetwork from './visNetwork'
|
// import visNetwork from './visNetwork'
|
||||||
export default {
|
export default {
|
||||||
name: 'chartList',
|
name: 'chartList',
|
||||||
@@ -900,7 +901,7 @@ export default {
|
|||||||
host = chartItem.elements[innerPos].expression
|
host = chartItem.elements[innerPos].expression
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.$refs['editChart' + chartItem.id][0].dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
let alias = dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -1136,7 +1137,7 @@ export default {
|
|||||||
host += '}'
|
host += '}'
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.$refs['editChart' + chartInfo.id][0].dealLegendAlias(host, chartInfo.elements[0].legend)
|
let alias = dealLegendAlias(host, chartInfo.elements[0].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ import chartGroup from './chart-group'
|
|||||||
import logs from './logs'
|
import logs from './logs'
|
||||||
import { fromRoute } from '@/components/common/js/constants'
|
import { fromRoute } from '@/components/common/js/constants'
|
||||||
import chartTempData from '@/components/charts/chartTempData'
|
import chartTempData from '@/components/charts/chartTempData'
|
||||||
import { chartResizeTool } from '@/components/common/js/tools'
|
import { chartResizeTool, dealLegendAlias } from '@/components/common/js/tools'
|
||||||
export default {
|
export default {
|
||||||
name: 'chartList',
|
name: 'chartList',
|
||||||
props: {
|
props: {
|
||||||
@@ -1164,7 +1164,7 @@ export default {
|
|||||||
host = chartItem.elements[innerPos].expression
|
host = chartItem.elements[innerPos].expression
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.$refs['editChart' + chartItem.id][0].dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
let alias = dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -1404,7 +1404,7 @@ export default {
|
|||||||
host += '}'
|
host += '}'
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.$refs['editChart' + chartInfo.id][0].dealLegendAlias(host, chartInfo.elements[0].legend)
|
let alias = dealLegendAlias(host, chartInfo.elements[0].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -538,27 +538,6 @@ export default {
|
|||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
clickLegend (legendName, index) {
|
clickLegend (legendName, index) {
|
||||||
/* 点击legend
|
/* 点击legend
|
||||||
* 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮
|
* 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮
|
||||||
|
|||||||
@@ -614,27 +614,6 @@ export default {
|
|||||||
this.orderByScreen = { order: item.order, prop: item.prop }
|
this.orderByScreen = { order: item.order, prop: item.prop }
|
||||||
this.seriesItemScreen = this.filterShowData(this.storedScreanTableData, this.screenPageObj, 'seriesScreen')
|
this.seriesItemScreen = this.filterShowData(this.storedScreanTableData, this.screenPageObj, 'seriesScreen')
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 获取格式
|
// 获取格式
|
||||||
getNumStr (num) {
|
getNumStr (num) {
|
||||||
if (num) {
|
if (num) {
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ import chartAlertList from './chart-alert-list'
|
|||||||
import chartConfig from '../page/dashboard/overview/chartConfig'
|
import chartConfig from '../page/dashboard/overview/chartConfig'
|
||||||
import diagram from '@/components/common/ChartDiagram/diagram'
|
import diagram from '@/components/common/ChartDiagram/diagram'
|
||||||
import moment from 'moment-timezone'
|
import moment from 'moment-timezone'
|
||||||
import { formatScientificNotation } from '@/components/common/js/tools'
|
import { formatScientificNotation, dealLegendAlias } from '@/components/common/js/tools'
|
||||||
export default {
|
export default {
|
||||||
name: 'chartPreview',
|
name: 'chartPreview',
|
||||||
components: {
|
components: {
|
||||||
@@ -572,7 +572,7 @@ export default {
|
|||||||
host = chartItem.elements[innerPos].expression
|
host = chartItem.elements[innerPos].expression
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
let alias = dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -1740,7 +1740,7 @@ export default {
|
|||||||
if (!host || host === '') {
|
if (!host || host === '') {
|
||||||
host = this.chart.elements[pos].expression
|
host = this.chart.elements[pos].expression
|
||||||
}
|
}
|
||||||
let alias = this.dealLegendAlias(host, this.chart.elements[pos].legend)
|
let alias = dealLegendAlias(host, this.chart.elements[pos].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -1780,27 +1780,6 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
screenPageNo (val) {
|
screenPageNo (val) {
|
||||||
this.screenPageObj.pageNo = val
|
this.screenPageObj.pageNo = val
|
||||||
this.seriesItemScreen = this.filterShowData(this.storedScreanTableData, this.screenPageObj)
|
this.seriesItemScreen = this.filterShowData(this.storedScreanTableData, this.screenPageObj)
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ import chartDataFormat from './chartDataFormat'
|
|||||||
import { randomcolor } from '../common/js/radomcolor/randomcolor.js'
|
import { randomcolor } from '../common/js/radomcolor/randomcolor.js'
|
||||||
import chartConfig from '../page/dashboard/overview/chartConfig'
|
import chartConfig from '../page/dashboard/overview/chartConfig'
|
||||||
import { getChart, setChart, lineChartMove, getMousePoint } from '../common/js/common'
|
import { getChart, setChart, lineChartMove, getMousePoint } from '../common/js/common'
|
||||||
import { getMetricTypeValue, chartResizeTool, formatScientificNotation } from '../common/js/tools'
|
import { getMetricTypeValue, chartResizeTool, formatScientificNotation, dealLegendAlias} from '../common/js/tools'
|
||||||
import moment from 'moment-timezone'
|
import moment from 'moment-timezone'
|
||||||
import chartDataList from '@/components/common/mixin/chartDataList'
|
import chartDataList from '@/components/common/mixin/chartDataList'
|
||||||
|
|
||||||
@@ -404,7 +404,6 @@ export default {
|
|||||||
const hasGrey = highlightNum < this.isGrey.length // 是否有置灰的
|
const hasGrey = highlightNum < this.isGrey.length // 是否有置灰的
|
||||||
const curIsGrey = this.isGrey[index] // 当前legend的状态
|
const curIsGrey = this.isGrey[index] // 当前legend的状态
|
||||||
const currentIsTheOnlyOneHighlight = !curIsGrey && highlightNum === 1 // 当前legend是否是目前唯一高亮的
|
const currentIsTheOnlyOneHighlight = !curIsGrey && highlightNum === 1 // 当前legend是否是目前唯一高亮的
|
||||||
|
|
||||||
const echart = getChart(this.chartIndex)
|
const echart = getChart(this.chartIndex)
|
||||||
if (echart) {
|
if (echart) {
|
||||||
if (!hasGrey) { // 1.除当前legend外全置灰
|
if (!hasGrey) { // 1.除当前legend外全置灰
|
||||||
@@ -493,7 +492,6 @@ export default {
|
|||||||
const hasGrey = highlightNum < this.isGreyScreen.length // 是否有置灰的
|
const hasGrey = highlightNum < this.isGreyScreen.length // 是否有置灰的
|
||||||
const curIsGrey = this.isGreyScreen[index] // 当前legend的状态
|
const curIsGrey = this.isGreyScreen[index] // 当前legend的状态
|
||||||
const currentIsTheOnlyOneHighlight = !curIsGrey && highlightNum === 1 // 当前legend是否是目前唯一高亮的
|
const currentIsTheOnlyOneHighlight = !curIsGrey && highlightNum === 1 // 当前legend是否是目前唯一高亮的
|
||||||
|
|
||||||
const echart = this.echartModalStore
|
const echart = this.echartModalStore
|
||||||
if (echart) {
|
if (echart) {
|
||||||
if (!hasGrey) { // 1.除当前legend外全置灰
|
if (!hasGrey) { // 1.除当前legend外全置灰
|
||||||
@@ -1725,7 +1723,7 @@ export default {
|
|||||||
if (!host || host === '') {
|
if (!host || host === '') {
|
||||||
host = elements.expression
|
host = elements.expression
|
||||||
}
|
}
|
||||||
let alias = this.dealLegendAlias(host, elements.legend)
|
let alias = dealLegendAlias(host, elements.legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -1823,27 +1821,6 @@ export default {
|
|||||||
this.$refs['localLoading' + this.chartIndex].startLoading()
|
this.$refs['localLoading' + this.chartIndex].startLoading()
|
||||||
this.divFirstShow = true
|
this.divFirstShow = true
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 获取格式
|
// 获取格式
|
||||||
getNumStr (num) {
|
getNumStr (num) {
|
||||||
if (num >= 1000) {
|
if (num >= 1000) {
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ import logTab from '@/components/page/dashboard/explore/logTab'
|
|||||||
import bus from '@/libs/bus'
|
import bus from '@/libs/bus'
|
||||||
import logsTempData from '@/components/charts/logsTempData'
|
import logsTempData from '@/components/charts/logsTempData'
|
||||||
import { fromRoute } from '@/components/common/js/constants'
|
import { fromRoute } from '@/components/common/js/constants'
|
||||||
|
import { dealLegendAlias } from '@/components/common/js/tools'
|
||||||
export default {
|
export default {
|
||||||
name: 'logs',
|
name: 'logs',
|
||||||
components: {
|
components: {
|
||||||
@@ -543,7 +544,7 @@ export default {
|
|||||||
host += '}'
|
host += '}'
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
alias = this.dealLegendAlias(host, this.chartData.elements[index].legend)
|
alias = dealLegendAlias(host, this.chartData.elements[index].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -622,7 +623,7 @@ export default {
|
|||||||
host += '}'
|
host += '}'
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
alias = this.dealLegendAlias(host, this.chartData.elements[index].legend)
|
alias = dealLegendAlias(host, this.chartData.elements[index].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -692,27 +693,6 @@ export default {
|
|||||||
reader.readAsText(error.response.data)
|
reader.readAsText(error.response.data)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dateChange (time) {
|
dateChange (time) {
|
||||||
this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss')
|
this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss')
|
||||||
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
|
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ import alertTable from '../project/popData/alertTable'
|
|||||||
import assetTable from '../project/popData/assetTable'
|
import assetTable from '../project/popData/assetTable'
|
||||||
import endpointTable from '../project/popData/endpointTable'
|
import endpointTable from '../project/popData/endpointTable'
|
||||||
import topoTooltip from '../project/L5/topoTooltip'
|
import topoTooltip from '../project/L5/topoTooltip'
|
||||||
import { getMetricTypeValue } from '../js/tools'
|
import { getMetricTypeValue, dealLegendAlias} from '../js/tools'
|
||||||
import bus from '../../../libs/bus'
|
import bus from '../../../libs/bus'
|
||||||
import CanvasContextMenu from '@/components/common/project/L5/CanvasContextMenu'
|
import CanvasContextMenu from '@/components/common/project/L5/CanvasContextMenu'
|
||||||
// 注册到画布
|
// 注册到画布
|
||||||
@@ -992,7 +992,7 @@ export default {
|
|||||||
host = pen.data.expressArr[innerPos]
|
host = pen.data.expressArr[innerPos]
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.dealLegendAlias(host, pen.data.legends[innerPos])
|
let alias = dealLegendAlias(host, pen.data.legends[innerPos])
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -1006,27 +1006,6 @@ export default {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Severity Label
|
// Severity Label
|
||||||
returnSeverityLabel (key) {
|
returnSeverityLabel (key) {
|
||||||
return this.$t(this.$CONSTANTS.alertMessage.severityData.find(s => { return s.value == key }).label)
|
return this.$t(this.$CONSTANTS.alertMessage.severityData.find(s => { return s.value == key }).label)
|
||||||
|
|||||||
@@ -864,3 +864,21 @@ export function formatScientificNotation (value, dot = 2) {
|
|||||||
return getTdDom(dom.parentElement);
|
return getTdDom(dom.parentElement);
|
||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
|
/* 处理legend的别名 */
|
||||||
|
export function dealLegendAlias (legend, expression) {
|
||||||
|
if (/\{\{.+\}\}/.test(expression)) {
|
||||||
|
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
||||||
|
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
||||||
|
const reg = new RegExp('\\b' + label + '=".+?"')
|
||||||
|
let value = null
|
||||||
|
if (reg.test(legend)) {
|
||||||
|
const find = legend.match(reg)[0]
|
||||||
|
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
||||||
|
}
|
||||||
|
return value || label
|
||||||
|
})
|
||||||
|
return labelValue
|
||||||
|
} else {
|
||||||
|
return expression
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import { fromRoute } from '@/components/common/js/constants'
|
|||||||
import chartTempData from '@/components/charts/chartTempData'
|
import chartTempData from '@/components/charts/chartTempData'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import chartDataFormat from '@/components/charts/chartDataFormat'
|
import chartDataFormat from '@/components/charts/chartDataFormat'
|
||||||
|
import { dealLegendAlias } from '@/components/common/js/tools'
|
||||||
export default {
|
export default {
|
||||||
name: 'topoTooltip',
|
name: 'topoTooltip',
|
||||||
components: {
|
components: {
|
||||||
@@ -299,7 +300,7 @@ export default {
|
|||||||
host = chartItem.elements[innerPos].expression
|
host = chartItem.elements[innerPos].expression
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.$refs['editChart' + chartItem.type].dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
let alias = dealLegendAlias(host, chartItem.elements[innerPos].legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ import alertTable from './popData/alertTable'
|
|||||||
import assetTable from './popData/assetTable'
|
import assetTable from './popData/assetTable'
|
||||||
import endpointTable from './popData/endpointTable'
|
import endpointTable from './popData/endpointTable'
|
||||||
import topoTooltip from './L5/topoTooltip'
|
import topoTooltip from './L5/topoTooltip'
|
||||||
import { getMetricTypeValue } from '../js/tools'
|
import { getMetricTypeValue, dealLegendAlias } from '../js/tools'
|
||||||
import bus from '../../../libs/bus'
|
import bus from '../../../libs/bus'
|
||||||
// 注册到画布
|
// 注册到画布
|
||||||
registerNode('rectangleImg', myShape, myAnchors, myIconRect, myTextRect)
|
registerNode('rectangleImg', myShape, myAnchors, myIconRect, myTextRect)
|
||||||
@@ -1005,7 +1005,7 @@ export default {
|
|||||||
host = pen.data.expressArr[innerPos]
|
host = pen.data.expressArr[innerPos]
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
let alias = this.dealLegendAlias(host, pen.data.legends[innerPos])
|
let alias = dealLegendAlias(host, pen.data.legends[innerPos])
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -1019,27 +1019,6 @@ export default {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 获取project Info
|
// 获取project Info
|
||||||
getProjectData (n) {
|
getProjectData (n) {
|
||||||
// 获取projectInfo
|
// 获取projectInfo
|
||||||
|
|||||||
@@ -107,6 +107,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
import chartConfig from '@/components/page/dashboard/overview/chartConfig'
|
import chartConfig from '@/components/page/dashboard/overview/chartConfig'
|
||||||
|
import { dealLegendAlias } from '@/components/common/js/tools'
|
||||||
export default {
|
export default {
|
||||||
name: 'logTab',
|
name: 'logTab',
|
||||||
props: {
|
props: {
|
||||||
@@ -481,7 +482,7 @@ export default {
|
|||||||
host += '}'
|
host += '}'
|
||||||
}
|
}
|
||||||
// 处理legend别名
|
// 处理legend别名
|
||||||
alias = this.dealLegendAlias(host, row.elements.legend)
|
alias = dealLegendAlias(host, row.elements.legend)
|
||||||
if (!alias || alias === '') {
|
if (!alias || alias === '') {
|
||||||
alias = host
|
alias = host
|
||||||
}
|
}
|
||||||
@@ -490,27 +491,6 @@ export default {
|
|||||||
}
|
}
|
||||||
return alias
|
return alias
|
||||||
},
|
},
|
||||||
dealLegendAlias: function (legend, expression) {
|
|
||||||
if (/\{\{.+\}\}/.test(expression)) {
|
|
||||||
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
|
|
||||||
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
|
|
||||||
const reg = new RegExp(',' + label + '=".+?"')
|
|
||||||
const reg1 = new RegExp('{' + label + '=".+?"')
|
|
||||||
let value = null
|
|
||||||
if (reg.test(legend)) {
|
|
||||||
const find = legend.match(reg)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
} else if (reg1.test(legend)) {
|
|
||||||
const find = legend.match(reg1)[0]
|
|
||||||
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
|
|
||||||
}
|
|
||||||
return value || label
|
|
||||||
})
|
|
||||||
return labelValue
|
|
||||||
} else {
|
|
||||||
return expression
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tooltipFormatter (params, a, b) {
|
tooltipFormatter (params, a, b) {
|
||||||
const vm = this
|
const vm = this
|
||||||
let str = `
|
let str = `
|
||||||
|
|||||||
Reference in New Issue
Block a user