feat ;修改 chart 参数调整

This commit is contained in:
zhangyu
2021-12-06 15:25:09 +08:00
parent 39c94f5dec
commit 4477c3e195
6 changed files with 30 additions and 24 deletions

View File

@@ -65,7 +65,7 @@ export default {
this.$emit('refresh')
},
editChart () {
this.$emit('edit-chart', this.chartInfo)
},
removeChart () {

View File

@@ -26,6 +26,7 @@
>
<panel-chart
:ref="'chart' + item.id"
@edit-chart="$emit('edit-chart', item)"
:chart-info="item"
:time-range="timeRange"
@showFullscreen="showFullscreen"

View File

@@ -93,7 +93,7 @@
</el-popover>
</el-col>
<el-col style="flex: 1">
<el-input maxlength="512" show-word-limit size="small" type="text" v-model="expressionsShow[index-1].legend" ></el-input>
<el-input maxlength="512" show-word-limit size="small" type="text" v-model="expressionsShow[index-1].legend" @change="expressionChange"></el-input>
</el-col>
</el-row>
</el-row>

View File

@@ -163,15 +163,16 @@ export default {
Promise.all(arr).then(res => {
this.editChart.panelId = this.panelId
const params = JSON.parse(JSON.stringify(this.editChart))
delete params.panel
if (!params.groupId) {
params.groupId = -1
params.groupId = 0
}
delete params.panel
if (params.id) { // 修改
this.$put('visual/panel/chart', params).then(response => {
if (response.code === 200) {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
this.$emit('on-create-success')
} else {
this.$message.error(response.msg)
}
@@ -181,6 +182,7 @@ export default {
if (response.code === 200) {
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
this.esc(true)
this.$emit('on-create-success')
} else {
this.$message.error(response.msg)
}

View File

@@ -428,7 +428,7 @@ export default {
},
watch: {
selectList (n) {
if (n.length === 1) {
if (n.length === 1 && !this.chartConfig.param.systemSelect) {
this.chartConfig.param.systemSelect = this.selectList[0].name
}
}
@@ -439,14 +439,21 @@ export default {
},
getSystemData () {
this.loading = true
this.$get('/mock/getSystemData').then(res => {
this.$get('/sys/config/key/stat_query_json').then(res => {
this.loading = false
if (res.code === 200) {
this.systemData = res.data.list
if (res.data.list.length) {
this.chartConfig.param.system = res.data.list[0].name
this.groupList = res.data.list[0].group
this.selectList = res.data.list[0].select
this.systemData = JSON.parse(res.data.paramValue)
if (this.systemData.length) {
if (!this.chartConfig.param.system) {
this.chartConfig.param.system = this.systemData[0].name
this.groupList = this.systemData[0].group
this.selectList = this.systemData[0].select
} else {
const system = this.systemData.find(item => item.name === this.chartConfig.param.system)
this.chartConfig.param.system = system.name
this.groupList = system.group
this.selectList = system.select
}
this.$refs.chartForm.clearValidate()
}
} else {

View File

@@ -90,7 +90,7 @@
:from="fromRoute.panel"
:panel-lock="panelLock"
:time-range="searchTime"
@on-edit-chart="editChart"
@edit-chart="editChart"
@on-refresh-time="refreshTime"
@on-remove-chart="delChart"
@on-add-group-item-chart="addGroupItem"
@@ -191,7 +191,7 @@ export default {
name: '',
type: 'line',
span: 4,
datasource: '1',
datasource: 'metrics',
height: 4,
unit: 2,
param: {
@@ -205,7 +205,7 @@ export default {
panel: '',
sync: 0,
remark: '',
groupId: -1
groupId: ''
},
pageObj: {
pageNo: 1,
@@ -385,6 +385,7 @@ export default {
},
// 编辑图表信息,打开编辑弹窗
editChart (data, copy) {
console.log(456)
if (copy) {
this.chart = JSON.parse(JSON.stringify(data))
this.chart.panelId = this.showPanel.id
@@ -394,19 +395,14 @@ export default {
this.$get('visual/panel/chart/' + data.id).then(res => {
if (res.code === 200) {
const chartData = res.data.data
if (typeof chartData.param === 'string') {
chartData.param = chartData.param ? JSON.parse(chartData.param) : {}
}
if (!chartData.param) {
chartData.param = { url: '', threshold: '' }
} else if (!chartData.param.threshold) {
chartData.param.threshold = ''
} else if (!chartData.param.url) {
chartData.param.url = ''
}
this.chart = JSON.parse(JSON.stringify(chartData))
this.chart.panelId = this.showPanel.id
this.chart.panelName = this.showPanel.name
this.chart.param = JSON.parse(this.chart.param)
this.chart.datasource = 'metrics'
if (!this.chart.groupId || this.chart.groupId == -1) {
this.chart.groupId = ''
}
this.rightBox.chart.show = true
} else {
this.$message.error(res.msg)