Unverified 提交 924037e2 authored 作者: 王嘉豪's avatar 王嘉豪 提交者: GitHub

Merge pull request #2115 from dataease/pr@dev@feat_switch-dataset

feat: 仪表板板切换视图数据集可以自动匹配新数据集字段
......@@ -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) {
......
......@@ -95,6 +95,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'
import { formatterItem } from '@/views/chart/chart/formatter'
export default {
......@@ -141,6 +142,7 @@ export default {
}
},
mounted() {
bus.$on('reset-change-table', () => this.getItemTagType())
this.init()
},
methods: {
......
......@@ -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) {
......
......@@ -118,6 +118,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'
import { formatterItem } from '@/views/chart/chart/formatter'
export default {
......@@ -174,6 +175,8 @@ export default {
mounted() {
this.init()
this.isEnableCompare()
bus.$on('reset-change-table', () => this.getItemTagType())
},
methods: {
init() {
......
......@@ -118,6 +118,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'
import { formatterItem } from '@/views/chart/chart/formatter'
export default {
......@@ -171,6 +172,7 @@ export default {
mounted() {
this.init()
this.isEnableCompare()
bus.$on('reset-change-table', () => this.getItemTagType())
},
methods: {
init() {
......
......@@ -880,7 +880,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"
......@@ -1493,11 +1493,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()
......@@ -1507,7 +1507,7 @@ export default {
})
}
},
initTableField(id) {
initTableField(id, optType) {
if (this.table) {
post('/dataset/table/getFieldsFromDE', this.table).then(response => {
this.dimension = response.data.dimension
......@@ -1515,7 +1515,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
......@@ -1525,6 +1533,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 === '' ||
......@@ -2223,20 +2260,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()
},
......
......@@ -40,7 +40,7 @@ module.exports = {
},
configureWebpack: {
name: name,
devtool: 'source-map',
devtool: 'cheap-module-source-map',
resolve: {
alias: {
'@': resolve('src')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论