forked from github/dataease
Merge pull request #1940 from dataease/pr@dev@refactor_chart_edit
refactor: 视图编辑块优化
This commit is contained in:
commit
6475c388ec
@ -62,7 +62,12 @@ export default {
|
||||
methods: {
|
||||
// 过滤xaxis,extStack所有日期字段
|
||||
initFieldList() {
|
||||
const xAxis = JSON.parse(this.chart.xaxis)
|
||||
let xAxis = null
|
||||
if (Object.prototype.toString.call(this.chart.xaxis) === '[object Array]') {
|
||||
xAxis = JSON.parse(JSON.stringify(this.chart.xaxis))
|
||||
} else {
|
||||
xAxis = JSON.parse(this.chart.xaxis)
|
||||
}
|
||||
const t1 = xAxis.filter(ele => { return ele.deType === 1 })
|
||||
this.fieldList = t1
|
||||
// 如果没有选中字段,则默认选中第一个
|
||||
|
@ -13,7 +13,7 @@
|
||||
</span>
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<field-error-tips v-if="tagType === 'danger'" />
|
||||
<span v-if="item.deType === 1" class="summary-span">
|
||||
<span v-if="false && item.deType === 1" class="summary-span">
|
||||
{{ $t('chart.' + item.dateStyle) }}
|
||||
</span>
|
||||
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
|
||||
|
@ -13,7 +13,7 @@
|
||||
</span>
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<field-error-tips v-if="tagType === 'danger'" />
|
||||
<span v-if="item.deType === 1" class="summary-span">
|
||||
<span v-if="false && item.deType === 1" class="summary-span">
|
||||
{{ $t('chart.' + item.dateStyle) }}
|
||||
</span>
|
||||
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
|
||||
|
@ -17,7 +17,7 @@
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<field-error-tips v-if="tagType === 'danger'" />
|
||||
<span v-if="chart.type !== 'table-info' && item.summary" class="summary-span">
|
||||
{{ $t('chart.' + item.summary) }}<span v-if="item.compareCalc && item.compareCalc.type && item.compareCalc.type !== '' && item.compareCalc.type !== 'none'">-{{ $t('chart.' + item.compareCalc.type) }}</span>
|
||||
{{ $t('chart.' + item.summary) }}<span v-if="false && item.compareCalc && item.compareCalc.type && item.compareCalc.type !== '' && item.compareCalc.type !== 'none'">-{{ $t('chart.' + item.compareCalc.type) }}</span>
|
||||
</span>
|
||||
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
|
||||
</el-tag>
|
||||
@ -176,12 +176,17 @@ export default {
|
||||
}
|
||||
},
|
||||
isEnableCompare() {
|
||||
const xAxis = JSON.parse(this.chart.xaxis)
|
||||
let xAxis = null
|
||||
if (Object.prototype.toString.call(this.chart.xaxis) === '[object Array]') {
|
||||
xAxis = JSON.parse(JSON.stringify(this.chart.xaxis))
|
||||
} else {
|
||||
xAxis = JSON.parse(this.chart.xaxis)
|
||||
}
|
||||
const t1 = xAxis.filter(ele => {
|
||||
return ele.deType === 1
|
||||
})
|
||||
// 暂时只支持类别轴/维度的时间类型字段
|
||||
if (t1.length > 0 && this.chart.type !== 'text' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') {
|
||||
if (t1.length > 0 && this.chart.type !== 'text' && this.chart.type !== 'label' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') {
|
||||
this.disableEditCompare = false
|
||||
} else {
|
||||
this.disableEditCompare = true
|
||||
|
@ -17,7 +17,7 @@
|
||||
<span class="item-span-style" :title="item.name">{{ item.name }}</span>
|
||||
<field-error-tips v-if="tagType === 'danger'" />
|
||||
<span v-if="chart.type !== 'table-info' && item.summary" class="summary-span">
|
||||
{{ $t('chart.' + item.summary) }}<span v-if="item.compareCalc && item.compareCalc.type && item.compareCalc.type !== '' && item.compareCalc.type !== 'none'">-{{ $t('chart.' + item.compareCalc.type) }}</span>
|
||||
{{ $t('chart.' + item.summary) }}<span v-if="false && item.compareCalc && item.compareCalc.type && item.compareCalc.type !== '' && item.compareCalc.type !== 'none'">-{{ $t('chart.' + item.compareCalc.type) }}</span>
|
||||
</span>
|
||||
<i class="el-icon-arrow-down el-icon--right" style="position: absolute;top: 6px;right: 10px;" />
|
||||
</el-tag>
|
||||
@ -173,12 +173,17 @@ export default {
|
||||
}
|
||||
},
|
||||
isEnableCompare() {
|
||||
const xAxis = JSON.parse(this.chart.xaxis)
|
||||
let xAxis = null
|
||||
if (Object.prototype.toString.call(this.chart.xaxis) === '[object Array]') {
|
||||
xAxis = JSON.parse(JSON.stringify(this.chart.xaxis))
|
||||
} else {
|
||||
xAxis = JSON.parse(this.chart.xaxis)
|
||||
}
|
||||
const t1 = xAxis.filter(ele => {
|
||||
return ele.deType === 1
|
||||
})
|
||||
// 暂时只支持类别轴/维度的时间类型字段
|
||||
if (t1.length > 0 && this.chart.type !== 'text' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') {
|
||||
if (t1.length > 0 && this.chart.type !== 'text' && this.chart.type !== 'label' && this.chart.type !== 'gauge' && this.chart.type !== 'liquid') {
|
||||
this.disableEditCompare = false
|
||||
} else {
|
||||
this.disableEditCompare = true
|
||||
|
@ -89,7 +89,7 @@ export default {
|
||||
const chart = JSON.parse(JSON.stringify(this.chart))
|
||||
if (chart.xaxisExt) {
|
||||
let arr = null
|
||||
if (Object.prototype.toString.call(chart.xaxisExt) === '[object Object]') {
|
||||
if (Object.prototype.toString.call(chart.xaxisExt) === '[object Array]') {
|
||||
arr = JSON.parse(JSON.stringify(chart.xaxisExt))
|
||||
} else {
|
||||
arr = JSON.parse(chart.xaxisExt)
|
||||
@ -102,7 +102,7 @@ export default {
|
||||
const chart = JSON.parse(JSON.stringify(this.chart))
|
||||
if (chart.xaxis) {
|
||||
let arr = null
|
||||
if (Object.prototype.toString.call(chart.xaxis) === '[object Object]') {
|
||||
if (Object.prototype.toString.call(chart.xaxis) === '[object Array]') {
|
||||
arr = JSON.parse(JSON.stringify(chart.xaxis))
|
||||
} else {
|
||||
arr = JSON.parse(chart.xaxis)
|
||||
|
@ -1635,6 +1635,7 @@ export default {
|
||||
ele.filter = []
|
||||
}
|
||||
})
|
||||
this.chart = JSON.parse(JSON.stringify(view))
|
||||
this.view = JSON.parse(JSON.stringify(view))
|
||||
// stringify json param
|
||||
view.xaxis = JSON.stringify(view.xaxis)
|
||||
|
Loading…
Reference in New Issue
Block a user