NEZ-1767 fix: 设置图表宽导致图表重叠的问题
This commit is contained in:
@@ -210,6 +210,8 @@ export default {
|
|||||||
if (!this.isGroup) {
|
if (!this.isGroup) {
|
||||||
this.moveChart()
|
this.moveChart()
|
||||||
this.onScroll(this.scrollTop)
|
this.onScroll(this.scrollTop)
|
||||||
|
} else {
|
||||||
|
bus.$emit('groupChildMove')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
containerResizedEvent (i, newH, newW, newHPx, newWPx) {
|
containerResizedEvent (i, newH, newW, newHPx, newWPx) {
|
||||||
@@ -346,6 +348,65 @@ export default {
|
|||||||
},
|
},
|
||||||
refreshPanel () {
|
refreshPanel () {
|
||||||
bus.$emit('refreshPanel')
|
bus.$emit('refreshPanel')
|
||||||
|
},
|
||||||
|
createChartSuccess (params) {
|
||||||
|
const arr = this.copyDataList.filter(item => !item.staic)
|
||||||
|
const charts = []
|
||||||
|
let weight = 0
|
||||||
|
arr.forEach(item => {
|
||||||
|
const chart = {
|
||||||
|
id: item.id,
|
||||||
|
x: item.x,
|
||||||
|
y: item.y,
|
||||||
|
span: item.span,
|
||||||
|
height: item.height,
|
||||||
|
groupId: item.groupId,
|
||||||
|
weight: weight
|
||||||
|
}
|
||||||
|
if (!params.groupId && chart.y >= params.y) {
|
||||||
|
chart.y = chart.y + 1
|
||||||
|
}
|
||||||
|
if (params.id == item.id) {
|
||||||
|
chart.y = params.y
|
||||||
|
chart.x = params.x
|
||||||
|
}
|
||||||
|
charts.push(chart)
|
||||||
|
|
||||||
|
weight++
|
||||||
|
if (item.type === 'group') {
|
||||||
|
item.children && item.children.forEach(children => {
|
||||||
|
const childrenChart = {
|
||||||
|
id: children.id,
|
||||||
|
x: children.x,
|
||||||
|
y: children.y,
|
||||||
|
span: children.span,
|
||||||
|
height: children.height,
|
||||||
|
groupId: children.groupId,
|
||||||
|
weight: weight
|
||||||
|
}
|
||||||
|
if (item.id === params.groupId && children.y >= params.y) {
|
||||||
|
childrenChart.y = childrenChart.y + 1
|
||||||
|
}
|
||||||
|
if (params.id == childrenChart.id) {
|
||||||
|
childrenChart.y = params.y
|
||||||
|
childrenChart.x = params.x
|
||||||
|
}
|
||||||
|
charts.push(childrenChart)
|
||||||
|
weight++
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const chartParams = {
|
||||||
|
panelId: this.panelId,
|
||||||
|
charts: charts
|
||||||
|
}
|
||||||
|
if (charts && charts.length) {
|
||||||
|
this.$put('/visual/panel/chart/weights', chartParams).then(() => {
|
||||||
|
if (params.cb) {
|
||||||
|
params.cb()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
@@ -355,6 +416,8 @@ export default {
|
|||||||
this.init()
|
this.init()
|
||||||
if (!this.isGroup) {
|
if (!this.isGroup) {
|
||||||
bus.$on('groupMove', this.changeGroupHeight)
|
bus.$on('groupMove', this.changeGroupHeight)
|
||||||
|
bus.$on('creat-chart-success', this.createChartSuccess)
|
||||||
|
bus.$on('groupChildMove', this.moveChart)
|
||||||
this.$store.commit('setChartListId', `chartList${this.timestamp}`)
|
this.$store.commit('setChartListId', `chartList${this.timestamp}`)
|
||||||
window.addEventListener('resize', this.resize)
|
window.addEventListener('resize', this.resize)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,7 +261,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
resize () {
|
resize () {
|
||||||
console.log('reszie')
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getChart(this.chartId) && getChart(this.chartId).resize()
|
getChart(this.chartId) && getChart(this.chartId).resize()
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|||||||
@@ -207,6 +207,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 保存endpoint
|
// 保存endpoint
|
||||||
save () {
|
save () {
|
||||||
|
const self = this
|
||||||
|
let resetFlag = false // 页面是否需要重排
|
||||||
const arr = [this.$refs.chartForm.validate()]
|
const arr = [this.$refs.chartForm.validate()]
|
||||||
arr.push(this.$refs['childrenFrom' + this.editChart.datasource].$refs.chartForm.validate())
|
arr.push(this.$refs['childrenFrom' + this.editChart.datasource].$refs.chartForm.validate())
|
||||||
Promise.all(arr).then(res => {
|
Promise.all(arr).then(res => {
|
||||||
@@ -245,6 +247,7 @@ export default {
|
|||||||
if (params.x + params.span > 12) {
|
if (params.x + params.span > 12) {
|
||||||
params.x = 0
|
params.x = 0
|
||||||
params.y += 1
|
params.y += 1
|
||||||
|
resetFlag = true
|
||||||
}
|
}
|
||||||
delete params.panel
|
delete params.panel
|
||||||
if (params.type === 'table') {
|
if (params.type === 'table') {
|
||||||
@@ -257,8 +260,18 @@ export default {
|
|||||||
this.$put('visual/panel/chart', params).then(response => {
|
this.$put('visual/panel/chart', params).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||||
this.$emit('on-create-success', { id: this.panelId, name: this.panelName })
|
if (resetFlag) {
|
||||||
this.esc(true)
|
bus.$emit('creat-chart-success', {
|
||||||
|
...params,
|
||||||
|
cb: function () {
|
||||||
|
self.$emit('on-create-success', { id: this.panelId, name: this.panelName })
|
||||||
|
self.esc(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
self.$emit('on-create-success', { id: this.panelId, name: this.panelName })
|
||||||
|
self.esc(true)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg)
|
this.$message.error(response.msg)
|
||||||
}
|
}
|
||||||
@@ -267,8 +280,18 @@ export default {
|
|||||||
this.$post('visual/panel/chart', params).then(response => {
|
this.$post('visual/panel/chart', params).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||||
this.$emit('on-create-success', { id: this.panelId, name: this.panelName })
|
if (resetFlag) {
|
||||||
this.esc(true)
|
bus.$emit('creat-chart-success', {
|
||||||
|
...params,
|
||||||
|
cb: function () {
|
||||||
|
self.$emit('on-create-success', { id: this.panelId, name: this.panelName })
|
||||||
|
self.esc(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
self.$emit('on-create-success', { id: this.panelId, name: this.panelName })
|
||||||
|
self.esc(true)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg)
|
this.$message.error(response.msg)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user