fix:修改 legend 显示的问题 以及 map显示的问题
This commit is contained in:
@@ -33,7 +33,8 @@ export default {
|
|||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
},
|
},
|
||||||
theme: localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`)
|
theme: localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`),
|
||||||
|
timer: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
@@ -41,6 +42,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initMap () {
|
initMap () {
|
||||||
|
if (this.timer) {
|
||||||
|
clearTimeout(this.timer)
|
||||||
|
this.timer = null
|
||||||
|
}
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
let loadPromise
|
let loadPromise
|
||||||
this.loadMapConfig().then((mapConfig) => {
|
this.loadMapConfig().then((mapConfig) => {
|
||||||
if (mapConfig && this.map) {
|
if (mapConfig && this.map) {
|
||||||
@@ -48,6 +54,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
return loadPromise
|
return loadPromise
|
||||||
|
}, 500)
|
||||||
},
|
},
|
||||||
loadMapConfig () {
|
loadMapConfig () {
|
||||||
const vm = this
|
const vm = this
|
||||||
@@ -65,7 +72,8 @@ export default {
|
|||||||
this.map.remove()
|
this.map.remove()
|
||||||
this.map = null
|
this.map = null
|
||||||
}
|
}
|
||||||
const mapId = 'map' + this.chartInfo.id
|
console.log(1212)
|
||||||
|
const mapId = document.getElementById('map' + this.chartInfo.id)
|
||||||
const map = L.map(mapId, {
|
const map = L.map(mapId, {
|
||||||
minZoom: mapConfig.minZoom,
|
minZoom: mapConfig.minZoom,
|
||||||
maxZoom: mapConfig.maxZoom,
|
maxZoom: mapConfig.maxZoom,
|
||||||
@@ -223,7 +231,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
// this.map.remove()
|
if (this.timer) {
|
||||||
|
clearTimeout(this.timer)
|
||||||
|
this.timer = null
|
||||||
|
}
|
||||||
|
this.map && this.map.remove()
|
||||||
this.map = null
|
this.map = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ export default {
|
|||||||
if (legend.endsWith(',')) {
|
if (legend.endsWith(',')) {
|
||||||
legend = legend.substr(0, legend.length - 1)
|
legend = legend.substr(0, legend.length - 1)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
if (data.metric.__name__) {
|
if (data.metric.__name__) {
|
||||||
legend += '}'
|
legend += '}'
|
||||||
}
|
}
|
||||||
})
|
|
||||||
if (!legend) {
|
if (!legend) {
|
||||||
legend = chartInfo.elements[expressionIndex].expression
|
legend = chartInfo.elements[expressionIndex].expression
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -770,8 +770,8 @@ export default {
|
|||||||
thresholds: [],
|
thresholds: [],
|
||||||
enable: {
|
enable: {
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true,
|
valueMapping: false,
|
||||||
thresholds: true
|
thresholds: false
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@@ -793,8 +793,8 @@ export default {
|
|||||||
valueMapping: [],
|
valueMapping: [],
|
||||||
enable: {
|
enable: {
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true,
|
valueMapping: false,
|
||||||
thresholds: true
|
thresholds: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -811,8 +811,8 @@ export default {
|
|||||||
valueMapping: [],
|
valueMapping: [],
|
||||||
enable: {
|
enable: {
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true,
|
valueMapping: false,
|
||||||
thresholds: true
|
thresholds: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -246,9 +246,9 @@ export default {
|
|||||||
nullType: 'null',
|
nullType: 'null',
|
||||||
legend: { placement: 'bottom', values: [] },
|
legend: { placement: 'bottom', values: [] },
|
||||||
enable: {
|
enable: {
|
||||||
thresholds: true,
|
thresholds: false,
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true
|
valueMapping: false
|
||||||
},
|
},
|
||||||
thresholds: [{ value: undefined, color: '#eeeeeeff' }]
|
thresholds: [{ value: undefined, color: '#eeeeeeff' }]
|
||||||
}
|
}
|
||||||
@@ -262,9 +262,9 @@ export default {
|
|||||||
unit: 2,
|
unit: 2,
|
||||||
type: 'log',
|
type: 'log',
|
||||||
enable: {
|
enable: {
|
||||||
thresholds: true,
|
thresholds: false,
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true
|
valueMapping: false
|
||||||
},
|
},
|
||||||
elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A' }],
|
elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A' }],
|
||||||
param: {
|
param: {
|
||||||
@@ -284,9 +284,9 @@ export default {
|
|||||||
nullType: 'null',
|
nullType: 'null',
|
||||||
statistics: 'last',
|
statistics: 'last',
|
||||||
enable: {
|
enable: {
|
||||||
thresholds: true,
|
thresholds: false,
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true
|
valueMapping: false
|
||||||
},
|
},
|
||||||
datasource: [{
|
datasource: [{
|
||||||
name: 'System',
|
name: 'System',
|
||||||
@@ -311,9 +311,9 @@ export default {
|
|||||||
height: 4,
|
height: 4,
|
||||||
type: 'url',
|
type: 'url',
|
||||||
enable: {
|
enable: {
|
||||||
thresholds: true,
|
thresholds: false,
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true
|
valueMapping: false
|
||||||
},
|
},
|
||||||
param: {
|
param: {
|
||||||
url: ''
|
url: ''
|
||||||
|
|||||||
@@ -8,7 +8,22 @@
|
|||||||
label-width="120px"
|
label-width="120px"
|
||||||
>
|
>
|
||||||
<div class="chart-title chart-title-config">
|
<div class="chart-title chart-title-config">
|
||||||
System
|
<span class="chart-title-content el-form-item" :class="{
|
||||||
|
'is-error' : systemNameShow[0].error,
|
||||||
|
'hide-input': systemNameShow[0].hideInput
|
||||||
|
}">
|
||||||
|
<i class="nz-icon nz-icon-arrow-down" :class="systemNameShow[0].show?'':'is-active'" @click.stop="showSystemNameShow(0)"></i>
|
||||||
|
<el-input
|
||||||
|
@mousedown.stop
|
||||||
|
v-model="chartConfig.param.datasource[0].name"
|
||||||
|
size="small"
|
||||||
|
@input="(val)=>{systemNameInput(val,0)}"
|
||||||
|
@change="systemNameChange(0)" style="width: 120px"
|
||||||
|
@focus.stop="showsystemInput(0,false)"
|
||||||
|
@blur="showsystemInput(0,true)"
|
||||||
|
/>
|
||||||
|
<div v-if="systemNameShow[0].error" class="el-form-item__error" style="top: 10px;left: 164px"> {{systemNameShow[0].error}}</div>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="system-chart-config" v-loading="loading" v-for="(item, index) in chartConfig.param.datasource " :key="index">
|
<div class="system-chart-config" v-loading="loading" v-for="(item, index) in chartConfig.param.datasource " :key="index">
|
||||||
<div class="system-chart-config-left">
|
<div class="system-chart-config-left">
|
||||||
@@ -427,6 +442,12 @@ export default {
|
|||||||
systemData: [],
|
systemData: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
rules: {},
|
rules: {},
|
||||||
|
systemNameShow: [{
|
||||||
|
error: false,
|
||||||
|
hideInput: true,
|
||||||
|
show: true,
|
||||||
|
oldName: ''
|
||||||
|
}],
|
||||||
groupList: [],
|
groupList: [],
|
||||||
selectList: [],
|
selectList: [],
|
||||||
oldType: '',
|
oldType: '',
|
||||||
@@ -513,8 +534,8 @@ export default {
|
|||||||
valueMapping: [],
|
valueMapping: [],
|
||||||
enable: {
|
enable: {
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true,
|
valueMapping: false,
|
||||||
thresholds: true
|
thresholds: false
|
||||||
},
|
},
|
||||||
datasource: [{
|
datasource: [{
|
||||||
name: 'System',
|
name: 'System',
|
||||||
@@ -541,8 +562,8 @@ export default {
|
|||||||
valueMapping: [],
|
valueMapping: [],
|
||||||
enable: {
|
enable: {
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true,
|
valueMapping: false,
|
||||||
thresholds: true
|
thresholds: false
|
||||||
},
|
},
|
||||||
datasource: [{
|
datasource: [{
|
||||||
name: 'System',
|
name: 'System',
|
||||||
@@ -562,6 +583,12 @@ export default {
|
|||||||
this.groupList = this.systemData[0].group
|
this.groupList = this.systemData[0].group
|
||||||
this.selectList = this.systemData[0].select
|
this.selectList = this.systemData[0].select
|
||||||
this.oldType = type
|
this.oldType = type
|
||||||
|
this.systemNameShow = [{
|
||||||
|
error: false,
|
||||||
|
hideInput: true,
|
||||||
|
show: true,
|
||||||
|
oldName: this.chartConfig.param.datasource[0].name
|
||||||
|
}]
|
||||||
this.change()
|
this.change()
|
||||||
},
|
},
|
||||||
changeSystem (item) {
|
changeSystem (item) {
|
||||||
@@ -583,12 +610,47 @@ export default {
|
|||||||
systemSelectChange (index) {
|
systemSelectChange (index) {
|
||||||
this.chartConfig.param.datasource[index].select = this.selectList.find(item => item.name === this.chartConfig.param.datasource[index].systemSelect)
|
this.chartConfig.param.datasource[index].select = this.selectList.find(item => item.name === this.chartConfig.param.datasource[index].systemSelect)
|
||||||
this.change()
|
this.change()
|
||||||
|
},
|
||||||
|
showSystemNameShow (index) {
|
||||||
|
this.systemNameShow[index].show = !this.systemNameShow[index].show
|
||||||
|
this.$set(this.systemNameShow, index, this.systemNameShow[index])
|
||||||
|
},
|
||||||
|
systemNameInput (val, index) {
|
||||||
|
const findIndex = this.systemNameShow.indexOf(val)
|
||||||
|
const lastIndex = this.systemNameShow.lastIndexOf(val)
|
||||||
|
if (findIndex !== -1 && lastIndex != -1 && lastIndex !== findIndex) {
|
||||||
|
this.systemNameShow[index].error = this.$t('error.nameDuplicate')
|
||||||
|
} else if (!val) {
|
||||||
|
this.systemNameShow[index].error = this.$t('validate.required')
|
||||||
|
} else {
|
||||||
|
this.systemNameShow[index].error = ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
systemNameChange (index) {
|
||||||
|
if (this.systemNameShow[index].error) {
|
||||||
|
this.expressionName[index] = this.systemNameShow[index].oldName
|
||||||
|
this.systemNameShow[index].error = ''
|
||||||
|
} else if (!this.expressionName[index]) {
|
||||||
|
this.expressionName[index] = this.systemNameShow[index].oldName
|
||||||
|
} else {
|
||||||
|
this.systemNameShow[index].oldName = this.expressionName[index]
|
||||||
|
}
|
||||||
|
this.change()
|
||||||
|
},
|
||||||
|
showsystemInput (index, flag) {
|
||||||
|
this.systemNameShow[index].hideInput = flag
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.init()
|
this.init()
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
this.systemNameShow = [{
|
||||||
|
error: false,
|
||||||
|
hideInput: true,
|
||||||
|
show: true,
|
||||||
|
oldName: this.chartConfig.param.datasource[0].name
|
||||||
|
}]
|
||||||
this.getSystemData()
|
this.getSystemData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,8 +205,8 @@ export default {
|
|||||||
legend: { placement: 'bottom', values: [], show: true },
|
legend: { placement: 'bottom', values: [], show: true },
|
||||||
enable: {
|
enable: {
|
||||||
legend: true,
|
legend: true,
|
||||||
valueMapping: true,
|
valueMapping: false,
|
||||||
thresholds: true
|
thresholds: false
|
||||||
},
|
},
|
||||||
thresholdShow: true,
|
thresholdShow: true,
|
||||||
thresholds: [{ value: undefined, color: randomcolor() }]
|
thresholds: [{ value: undefined, color: randomcolor() }]
|
||||||
|
|||||||
Reference in New Issue
Block a user