提交 32299104 authored 作者: junjie's avatar junjie

feat(视图):视图优化,样式、属性调整时,不重新计算数据

上级 33320f6f
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<el-radio-group <el-radio-group
v-model="view.type" v-model="view.type"
style="width: 100%" style="width: 100%"
@change="save" @change="save(false)"
> >
<div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;"> <div style="width: 100%;display: flex;display: -webkit-flex;justify-content: space-between;flex-direction: row;flex-wrap: wrap;">
<el-radio value="bar" label="bar"><svg-icon icon-class="bar" class="chart-icon" /></el-radio> <el-radio value="bar" label="bar"><svg-icon icon-class="bar" class="chart-icon" /></el-radio>
...@@ -331,7 +331,8 @@ export default { ...@@ -331,7 +331,8 @@ export default {
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' } { required: true, message: this.$t('commons.input_content'), trigger: 'change' }
] ]
}, },
tabStatus: false tabStatus: false,
data: {}
} }
}, },
computed: { computed: {
...@@ -373,7 +374,7 @@ export default { ...@@ -373,7 +374,7 @@ export default {
this.quota = response.data.quota this.quota = response.data.quota
}) })
}, },
save() { save(getData) {
const view = JSON.parse(JSON.stringify(this.view)) const view = JSON.parse(JSON.stringify(this.view))
view.id = this.view.id view.id = this.view.id
view.sceneId = this.view.sceneId view.sceneId = this.view.sceneId
...@@ -417,7 +418,14 @@ export default { ...@@ -417,7 +418,14 @@ export default {
view.customFilter = JSON.stringify(view.customFilter) view.customFilter = JSON.stringify(view.customFilter)
post('/chart/view/save', view).then(response => { post('/chart/view/save', view).then(response => {
// this.get(response.data.id); // this.get(response.data.id);
this.getData(response.data.id) // this.getData(response.data.id)
if (getData) {
this.getData(response.data.id)
} else {
this.getChart(response.data.id)
}
this.$store.dispatch('chart/setChartSceneData', null) this.$store.dispatch('chart/setChartSceneData', null)
this.$store.dispatch('chart/setChartSceneData', response.data) this.$store.dispatch('chart/setChartSceneData', response.data)
}) })
...@@ -441,7 +449,26 @@ export default { ...@@ -441,7 +449,26 @@ export default {
this.view.customFilter = this.view.customFilter ? JSON.parse(this.view.customFilter) : {} this.view.customFilter = this.view.customFilter ? JSON.parse(this.view.customFilter) : {}
// 将视图传入echart组件 // 将视图传入echart组件
this.chart = response.data this.chart = response.data
console.log(JSON.stringify(this.chart)) this.data = response.data.data
// console.log(JSON.stringify(this.chart))
})
} else {
this.view = {}
}
},
getChart(id) {
if (id) {
post('/chart/view/get/' + id, {}).then(response => {
this.initTableData(response.data.tableId)
this.view = JSON.parse(JSON.stringify(response.data))
this.view.xaxis = this.view.xaxis ? JSON.parse(this.view.xaxis) : []
this.view.yaxis = this.view.yaxis ? JSON.parse(this.view.yaxis) : []
this.view.customAttr = this.view.customAttr ? JSON.parse(this.view.customAttr) : {}
this.view.customStyle = this.view.customStyle ? JSON.parse(this.view.customStyle) : {}
this.view.customFilter = this.view.customFilter ? JSON.parse(this.view.customFilter) : {}
response.data.data = this.data
this.chart = response.data
}) })
} else { } else {
this.view = {} this.view = {}
...@@ -450,26 +477,26 @@ export default { ...@@ -450,26 +477,26 @@ export default {
// 左边往右边拖动时的事件 // 左边往右边拖动时的事件
start1(e) { start1(e) {
console.log(e) // console.log(e)
e.clone.className = 'item-on-move' e.clone.className = 'item-on-move'
e.item.className = 'item-on-move' e.item.className = 'item-on-move'
}, },
end1(e) { end1(e) {
console.log(e) // console.log(e)
e.clone.className = 'item' e.clone.className = 'item'
e.item.className = 'item' e.item.className = 'item'
this.refuseMove(e) this.refuseMove(e)
this.removeCheckedKey(e) this.removeCheckedKey(e)
this.save() this.save(true)
}, },
// 右边往左边拖动时的事件 // 右边往左边拖动时的事件
start2(e) { start2(e) {
console.log(e) // console.log(e)
}, },
end2(e) { end2(e) {
console.log(e) // console.log(e)
this.removeDuplicateKey(e) this.removeDuplicateKey(e)
this.save() this.save(true)
}, },
removeCheckedKey(e) { removeCheckedKey(e) {
const that = this const that = this
...@@ -518,7 +545,7 @@ export default { ...@@ -518,7 +545,7 @@ export default {
}, },
// move回调方法 // move回调方法
onMove(e, originalEvent) { onMove(e, originalEvent) {
console.log(e) // console.log(e)
this.moveId = e.draggedContext.element.id this.moveId = e.draggedContext.element.id
// //不允许停靠 // //不允许停靠
// if (e.relatedContext.element.id == 1) return false; // if (e.relatedContext.element.id == 1) return false;
...@@ -529,12 +556,12 @@ export default { ...@@ -529,12 +556,12 @@ export default {
}, },
dimensionItemChange(item) { dimensionItemChange(item) {
this.save() this.save(true)
}, },
dimensionItemRemove(item) { dimensionItemRemove(item) {
this.view.xaxis.splice(item.index, 1) this.view.xaxis.splice(item.index, 1)
this.save() this.save(true)
}, },
quotaItemChange(item) { quotaItemChange(item) {
...@@ -544,12 +571,12 @@ export default { ...@@ -544,12 +571,12 @@ export default {
// ele.summary = item.summary // ele.summary = item.summary
// } // }
// }) // })
this.save() this.save(true)
}, },
quotaItemRemove(item) { quotaItemRemove(item) {
this.view.yaxis.splice(item.index, 1) this.view.yaxis.splice(item.index, 1)
this.save() this.save(true)
}, },
onColorChange(val) { onColorChange(val) {
...@@ -606,7 +633,7 @@ export default { ...@@ -606,7 +633,7 @@ export default {
}, },
saveDimensionFilter() { saveDimensionFilter() {
this.view.xaxis[this.dimensionItem.index].filter = this.dimensionItem.filter this.view.xaxis[this.dimensionItem.index].filter = this.dimensionItem.filter
this.save() this.save(true)
this.closeDimensionFilter() this.closeDimensionFilter()
}, },
...@@ -619,7 +646,7 @@ export default { ...@@ -619,7 +646,7 @@ export default {
}, },
saveQuotaFilter() { saveQuotaFilter() {
this.view.yaxis[this.quotaItem.index].filter = this.quotaItem.filter this.view.yaxis[this.quotaItem.index].filter = this.quotaItem.filter
this.save() this.save(true)
this.closeQuotaFilter() this.closeQuotaFilter()
}, },
...@@ -633,7 +660,7 @@ export default { ...@@ -633,7 +660,7 @@ export default {
} else if (this.itemForm.renameType === 'dimension') { } else if (this.itemForm.renameType === 'dimension') {
this.view.xaxis[this.itemForm.index].name = this.itemForm.name this.view.xaxis[this.itemForm.index].name = this.itemForm.name
} }
this.save() this.save(true)
this.closeRename() this.closeRename()
}, },
closeRename() { closeRename() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论