forked from github/dataease
feat: 仪表板板切换视图数据集可以自动匹配新数据集字段
This commit is contained in:
parent
6bc5ffd26d
commit
ea7ddde23a
@ -108,6 +108,7 @@
|
||||
<script>
|
||||
import { getItemType } from '@/views/chart/components/drag-item/utils'
|
||||
import FieldErrorTips from '@/views/chart/components/drag-item/components/FieldErrorTips'
|
||||
import bus from '@/utils/bus'
|
||||
|
||||
export default {
|
||||
name: 'ChartDragItem',
|
||||
@ -155,6 +156,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('reset-change-table', () => this.getItemTagType())
|
||||
},
|
||||
methods: {
|
||||
clickItem(param) {
|
||||
|
@ -89,6 +89,7 @@
|
||||
<script>
|
||||
import { getItemType } from '@/views/chart/components/drag-item/utils'
|
||||
import FieldErrorTips from '@/views/chart/components/drag-item/components/FieldErrorTips'
|
||||
import bus from '@/utils/bus'
|
||||
|
||||
export default {
|
||||
name: 'DimensionExtItem',
|
||||
@ -129,6 +130,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('reset-change-table', () => this.getItemTagType())
|
||||
},
|
||||
methods: {
|
||||
clickItem(param) {
|
||||
|
@ -92,6 +92,7 @@
|
||||
<script>
|
||||
import { getItemType } from '@/views/chart/components/drag-item/utils'
|
||||
import FieldErrorTips from '@/views/chart/components/drag-item/components/FieldErrorTips'
|
||||
import bus from '@/utils/bus'
|
||||
|
||||
export default {
|
||||
name: 'DimensionItem',
|
||||
@ -132,6 +133,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('reset-change-table', () => this.getItemTagType())
|
||||
},
|
||||
methods: {
|
||||
clickItem(param) {
|
||||
|
@ -28,6 +28,7 @@
|
||||
<script>
|
||||
import { getItemType } from '@/views/chart/components/drag-item/utils'
|
||||
import FieldErrorTips from '@/views/chart/components/drag-item/components/FieldErrorTips'
|
||||
import bus from '@/utils/bus'
|
||||
|
||||
export default {
|
||||
name: 'DrillItem',
|
||||
@ -71,6 +72,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('reset-change-table', () => this.getItemTagType())
|
||||
},
|
||||
methods: {
|
||||
clickItem(param) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
<script>
|
||||
import { getItemType } from '@/views/chart/components/drag-item/utils'
|
||||
import FieldErrorTips from '@/views/chart/components/drag-item/components/FieldErrorTips'
|
||||
import bus from '@/utils/bus'
|
||||
|
||||
export default {
|
||||
name: 'FilterItem',
|
||||
@ -72,6 +73,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('reset-change-table', () => this.getItemTagType())
|
||||
},
|
||||
methods: {
|
||||
clickItem(param) {
|
||||
|
@ -114,6 +114,7 @@
|
||||
import { compareItem } from '@/views/chart/chart/compare'
|
||||
import { getItemType } from '@/views/chart/components/drag-item/utils'
|
||||
import FieldErrorTips from '@/views/chart/components/drag-item/components/FieldErrorTips'
|
||||
import bus from '@/utils/bus'
|
||||
|
||||
export default {
|
||||
name: 'QuotaExtItem',
|
||||
@ -168,6 +169,8 @@ export default {
|
||||
mounted() {
|
||||
this.init()
|
||||
this.isEnableCompare()
|
||||
bus.$on('reset-change-table', () => this.getItemTagType())
|
||||
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
|
@ -114,6 +114,7 @@
|
||||
import { compareItem } from '@/views/chart/chart/compare'
|
||||
import { getItemType } from '@/views/chart/components/drag-item/utils'
|
||||
import FieldErrorTips from '@/views/chart/components/drag-item/components/FieldErrorTips'
|
||||
import bus from '@/utils/bus'
|
||||
|
||||
export default {
|
||||
name: 'QuotaItem',
|
||||
@ -165,6 +166,7 @@ export default {
|
||||
mounted() {
|
||||
this.init()
|
||||
this.isEnableCompare()
|
||||
bus.$on('reset-change-table', () => this.getItemTagType())
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
|
@ -877,7 +877,7 @@
|
||||
@onLegendChange="onLegendChange"
|
||||
/>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item v-if="chart.customStyle && view.customStyle.background" name="background" :title="$t('chart.background')">
|
||||
<el-collapse-item v-if="view.customStyle && view.customStyle.background" name="background" :title="$t('chart.background')">
|
||||
<background-color-selector
|
||||
:param="param"
|
||||
class="attr-selector"
|
||||
@ -1366,7 +1366,8 @@ export default {
|
||||
quotaItemCompare: {},
|
||||
showEditQuotaCompare: false,
|
||||
preChartId: '',
|
||||
pluginRenderOptions: []
|
||||
pluginRenderOptions: [],
|
||||
showChartSet: true
|
||||
|
||||
}
|
||||
},
|
||||
@ -1468,11 +1469,11 @@ export default {
|
||||
bus.$on('plugins-calc-style', this.calcStyle)
|
||||
bus.$on('plugin-chart-click', this.chartClick)
|
||||
},
|
||||
initTableData(id) {
|
||||
initTableData(id, optType) {
|
||||
if (id != null) {
|
||||
post('/dataset/table/getWithPermission/' + id, null).then(response => {
|
||||
this.table = response.data
|
||||
this.initTableField(id)
|
||||
this.initTableField(id, optType)
|
||||
}).catch(err => {
|
||||
this.table = null
|
||||
this.resetDatasetField()
|
||||
@ -1482,7 +1483,7 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
initTableField(id) {
|
||||
initTableField(id, optType) {
|
||||
if (this.table) {
|
||||
post('/dataset/table/getFieldsFromDE', this.table).then(response => {
|
||||
this.dimension = response.data.dimension
|
||||
@ -1490,7 +1491,15 @@ export default {
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.dimension))
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.quota))
|
||||
this.fieldFilter(this.searchField)
|
||||
if (optType === 'change') {
|
||||
this.resetChangeTable()
|
||||
this.$nextTick(() => {
|
||||
bus.$emit('reset-change-table', 'change')
|
||||
this.calcData()
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
this.resetView()
|
||||
this.httpRequest.status = err.response.data.success
|
||||
this.httpRequest.msg = err.response.data.message
|
||||
@ -1500,6 +1509,35 @@ export default {
|
||||
this.resetDatasetField()
|
||||
}
|
||||
},
|
||||
resetChangeTable() {
|
||||
const compareData = {}
|
||||
this.dimensionData.forEach(deimension => {
|
||||
compareData[deimension.originName] = deimension
|
||||
})
|
||||
this.quotaData.forEach(quota => {
|
||||
compareData[quota.originName] = quota
|
||||
})
|
||||
const compareCols = ['xaxis', 'xaxisExt', 'yaxis', 'yaxisExt', 'customFilter', 'extStack', 'extBubble', 'drillFields']
|
||||
this.viewFieldChange(compareData, compareCols)
|
||||
},
|
||||
viewFieldChange(compareData, compareCols) {
|
||||
const _this = this
|
||||
compareCols.forEach(compareCol => {
|
||||
_this.view[compareCol].forEach(function(item, index) {
|
||||
if (compareData[item.originName]) {
|
||||
const itemTemp = {
|
||||
...compareData[item.originName],
|
||||
name: item.name,
|
||||
deType: item.deType,
|
||||
type: item.type,
|
||||
groupType: item.groupType,
|
||||
sort: item.sort
|
||||
}
|
||||
_this.view[compareCol][index] = itemTemp
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
buildParam(getData, trigger, needRefreshGroup = false, switchType = false) {
|
||||
if (!this.view.resultCount ||
|
||||
this.view.resultCount === '' ||
|
||||
@ -2198,20 +2236,11 @@ export default {
|
||||
// 更换数据集
|
||||
changeChart() {
|
||||
this.view.dataFrom = 'dataset'
|
||||
if (this.view.tableId !== this.changeTable.id) {
|
||||
this.view.tableId = this.changeTable.id
|
||||
this.view.xaxis = []
|
||||
this.view.xaxisExt = []
|
||||
this.view.yaxis = []
|
||||
this.view.yaxisExt = []
|
||||
this.view.customFilter = []
|
||||
this.view.extStack = []
|
||||
this.view.extBubble = []
|
||||
this.view.drillFields = []
|
||||
}
|
||||
const optType = this.view.tableId === this.changeTable.id ? 'same' : 'change'
|
||||
// this.save(true, 'chart', false)
|
||||
this.view.tableId = this.changeTable.id
|
||||
this.calcData(true, 'chart', false)
|
||||
this.initTableData(this.view.tableId)
|
||||
this.initTableData(this.view.tableId, optType)
|
||||
this.closeChangeChart()
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user